@soonspacejs/plugin-cps-soonmanager 2.13.9 → 2.13.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -4,4 +4,4 @@ import t,{BaseObject3D as e}from"soonspacejs";import r from"@soonspacejs/plugin-
4
4
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
5
5
  r.read=function(t,e,r,i,n){var o,s,a=8*n-i-1,h=(1<<a)-1,u=h>>1,f=-7,l=r?n-1:0,c=r?-1:1,d=t[e+l];for(l+=c,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=i;f>0;s=256*s+t[e+l],l+=c,f-=8);if(0===o)o=1-u;else{if(o===h)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,i),o-=u}return(d?-1:1)*s*Math.pow(2,o-i)},r.write=function(t,e,r,i,n,o){var s,a,h,u=8*o-n-1,f=(1<<u)-1,l=f>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,p=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-s))<1&&(s--,h*=2),(e+=s+l>=1?c/h:c*Math.pow(2,1-l))*h>=2&&(s++,h/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*h-1)*Math.pow(2,n),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,n),s=0));n>=8;t[r+d]=255&a,d+=p,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;t[r+d]=255&s,d+=p,s/=256,u-=8);t[r+d-p]|=128*m}},{}],24:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],25:[function(t,e,r){Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function t(t,e){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=t,this.value=e}return t.prototype.rotateLeft=function(){var t=this.parent,e=this.brother,r=this.leftChild,i=this.rightChild;if(!i)throw new Error("unknown error");var n=i.leftChild,o=i.rightChild;return t&&(t.leftChild===this?t.leftChild=i:t.rightChild===this&&(t.rightChild=i)),i.parent=t,i.brother=e,i.leftChild=this,i.rightChild=o,e&&(e.brother=i),this.parent=i,this.brother=o,this.leftChild=r,this.rightChild=n,o&&(o.parent=i,o.brother=this),r&&(r.parent=this,r.brother=n),n&&(n.parent=this,n.brother=r),i},t.prototype.rotateRight=function(){var t=this.parent,e=this.brother,r=this.leftChild;if(!r)throw new Error("unknown error");var i=this.rightChild,n=r.leftChild,o=r.rightChild;return t&&(t.leftChild===this?t.leftChild=r:t.rightChild===this&&(t.rightChild=r)),r.parent=t,r.brother=e,r.leftChild=n,r.rightChild=this,e&&(e.brother=r),n&&(n.parent=r,n.brother=this),this.parent=r,this.brother=n,this.leftChild=o,this.rightChild=i,o&&(o.parent=this,o.brother=i),i&&(i.parent=this,i.brother=o),r},t.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},t.TreeNodeColorType={red:!0,black:!1},t}();Object.freeze(i),r.default=i},{}],26:[function(t,e,r){var i=this&&this.__generator||function(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return h([t,e])}}function h(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}};function n(t){var e=this;void 0===t&&(t=[]);var r=[],o=0,s=0,a=0,h=0,u=0,f=0;this.size=function(){return f},this.empty=function(){return 0===f},this.clear=function(){o=a=s=h=u=f=0,c.call(this,n.bucketSize),f=0},this.front=function(){return r[o][s]},this.back=function(){return r[a][h]},this.forEach=function(t){if(!this.empty()){var e=0;if(o!==a){for(u=s;u<n.bucketSize;++u)t(r[o][u],e++);for(u=o+1;u<a;++u)for(var i=0;i<n.bucketSize;++i)t(r[u][i],e++);for(u=0;u<=h;++u)t(r[a][u],e++)}else for(var u=s;u<=h;++u)t(r[o][u],e++)}};var l=function(t){var e=o*n.bucketSize+s,r=e+t,i=a*n.bucketSize+h;if(r<e||r>i)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(r/n.bucketSize),curNodePointerIndex:r%n.bucketSize}};this.getElementByPos=function(t){var e=l(t),i=e.curNodeBucketIndex,n=e.curNodePointerIndex;return r[i][n]},this.eraseElementByPos=function(t){var e=this;if(t<0||t>f)throw new Error("pos should more than 0 and less than queue's size");if(0===t)this.popFront();else if(t===this.size())this.popBack();else{for(var r=[],i=t+1;i<f;++i)r.push(this.getElementByPos(i));this.cut(t),this.popBack(),r.forEach((function(t){return e.pushBack(t)}))}},this.eraseElementByValue=function(t){if(!this.empty()){var e=[];this.forEach((function(r){r!==t&&e.push(r)}));for(var r=e.length,i=0;i<r;++i)this.setElementByPos(i,e[i]);this.cut(r-1)}};var c=function(t){for(var e=[],i=t*n.sigma,l=Math.max(Math.ceil(i/n.bucketSize),2),c=0;c<l;++c)e.push(new Array(n.bucketSize));var d=Math.ceil(t/n.bucketSize),p=Math.floor(l/2)-Math.floor(d/2),m=p,g=0;if(this.size())for(c=0;c<d;++c){for(var y=0;y<n.bucketSize;++y)if(e[p+c][y]=this.front(),this.popFront(),this.empty()){m=p+c,g=y;break}if(this.empty())break}r=e,o=p,s=0,a=m,h=g,u=l,f=t};this.pushBack=function(t){this.empty()||(a===u-1&&h===n.bucketSize-1&&c.call(this,this.size()),h<n.bucketSize-1?++h:a<u-1&&(++a,h=0)),++f,r[a][h]=t},this.popBack=function(){this.empty()||(1!==this.size()&&(h>0?--h:o<a&&(--a,h=n.bucketSize-1)),f>0&&--f)},this.setElementByPos=function(t,e){var i=l(t),n=i.curNodeBucketIndex,o=i.curNodePointerIndex;r[n][o]=e},this.insert=function(t,e,r){var i=this;if(void 0===r&&(r=1),0===t)for(;r--;)this.pushFront(e);else if(t===this.size())for(;r--;)this.pushBack(e);else{for(var n=[],o=t;o<f;++o)n.push(this.getElementByPos(o));for(this.cut(t-1),o=0;o<r;++o)this.pushBack(e);n.forEach((function(t){return i.pushBack(t)}))}},this.find=function(t){if(o===a){for(var e=s;e<=h;++e)if(r[o][e]===t)return!0;return!1}for(e=s;e<n.bucketSize;++e)if(r[o][e]===t)return!0;for(e=o+1;e<a;++e)for(var i=0;i<n.bucketSize;++i)if(r[e][i]===t)return!0;for(e=0;e<=h;++e)if(r[a][e]===t)return!0;return!1},this.reverse=function(){for(var t=0,e=f-1;t<e;){var r=this.getElementByPos(t);this.setElementByPos(t,this.getElementByPos(e)),this.setElementByPos(e,r),++t,--e}},this.unique=function(){if(!this.empty()){var t=[],e=this.front();this.forEach((function(r,i){0!==i&&r===e||(t.push(r),e=r)}));for(var r=0;r<f;++r)this.setElementByPos(r,t[r]);this.cut(t.length-1)}},this.sort=function(t){var e=[];this.forEach((function(t){e.push(t)})),e.sort(t);for(var r=0;r<f;++r)this.setElementByPos(r,e[r])},this.pushFront=function(t){this.empty()||(0===o&&0===s&&c.call(this,this.size()),s>0?--s:o>0&&(--o,s=n.bucketSize-1)),++f,r[o][s]=t},this.popFront=function(){this.empty()||(1!==this.size()&&(s<n.bucketSize-1?++s:o<a&&(++o,s=0)),f>0&&--f)},this.shrinkToFit=function(){var t=this,e=[];this.forEach((function(t){e.push(t)}));var i=e.length;r=[];for(var o=Math.ceil(i/n.bucketSize),s=0;s<o;++s)r.push(new Array(n.bucketSize));this.clear(),e.forEach((function(e){return t.pushBack(e)}))},this.cut=function(t){if(t<0)this.clear();else{var e=l(t),r=e.curNodeBucketIndex,i=e.curNodePointerIndex;a=r,h=i,f=t+1}},this[Symbol.iterator]=function(){return function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(0===f)return[2];if(o!==a)return[3,5];e=s,i.label=1;case 1:return e<=h?[4,r[o][e]]:[3,4];case 2:i.sent(),i.label=3;case 3:return++e,[3,1];case 4:return[2];case 5:e=s,i.label=6;case 6:return e<n.bucketSize?[4,r[o][e]]:[3,9];case 7:i.sent(),i.label=8;case 8:return++e,[3,6];case 9:e=o+1,i.label=10;case 10:if(!(e<a))return[3,15];t=0,i.label=11;case 11:return t<n.bucketSize?[4,r[e][t]]:[3,14];case 12:i.sent(),i.label=13;case 13:return++t,[3,11];case 14:return++e,[3,10];case 15:e=0,i.label=16;case 16:return e<=h?[4,r[a][e]]:[3,19];case 17:i.sent(),i.label=18;case 18:return++e,[3,16];case 19:return[2]}}))}()},function(){var i=n.bucketSize;t.size?i=t.size():t.length&&(i=t.length);var s=i*n.sigma;u=Math.ceil(s/n.bucketSize),u=Math.max(u,3);for(var h=0;h<u;++h)r.push(new Array(n.bucketSize));var f=Math.ceil(i/n.bucketSize);o=Math.floor(u/2)-Math.floor(f/2),a=o,t.forEach((function(t){return e.pushBack(t)}))}(),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),n.sigma=3,n.bucketSize=5e3,Object.freeze(n),r.default=n},{}],27:[function(t,e,r){var i=this&&this.__generator||function(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return h([t,e])}}function h(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=t("../LinkList/LinkList"),s=t("../Map/Map");function a(t,e,r){var h=this;if(void 0===t&&(t=[]),void 0===e&&(e=a.initSize),r=r||function(t){var e,r,i=0,o="";if("number"==typeof t)i=((i=Math.floor(t))<<5)-i,i&=i;else{o="string"!=typeof t?JSON.stringify(t):t;try{for(var s=n(o),a=s.next();!a.done;a=s.next())i=(i<<5)-i+a.value.charCodeAt(0),i&=i}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}}return i^=i>>>16},0!=(e&e-1))throw new Error("initBucketNum must be 2 to the power of n");var u=0,f=[],l=Math.max(a.initSize,Math.min(a.maxSize,e));this.size=function(){return u},this.empty=function(){return 0===u},this.clear=function(){u=0,l=e,f=[]},this.forEach=function(t){var e=0;f.forEach((function(r){r.forEach((function(r){t(r,e++)}))}))};var c=function(t){if(!(t>=a.maxSize)){l=2*t;var e=[];f.forEach((function(i,n){if(!i.empty()){if(i instanceof o.default&&1===i.size()){var h=i.front(),u=h.key,c=h.value;e[r(u)&l-1]=new o.default([{key:u,value:c}])}else if(i instanceof s.default){var d=new o.default,p=new o.default;i.forEach((function(e){0==(r(e.key)&t)?d.pushBack(e):p.pushBack(e)})),d.size()>a.untreeifyThreshold?e[n]=new s.default(d):d.size()&&(e[n]=d),p.size()>a.untreeifyThreshold?e[n+t]=new s.default(p):p.size()&&(e[n+t]=p)}else{var m=new o.default,g=new o.default;i.forEach((function(e){0==(r(e.key)&t)?m.pushBack(e):g.pushBack(e)})),m.size()&&(e[n]=m),g.size()&&(e[n+t]=g)}f[n].clear()}})),f=e}};this.setElement=function(t,e){var i,h;if(null==t)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=e){var d=r(t)&l-1;if(f[d]){var p=f[d].size();if(f[d]instanceof o.default){try{for(var m=n(f[d]),g=m.next();!g.done;g=m.next()){var y=g.value;if(y.key===t)return void(y.value=e)}}catch(t){i={error:t}}finally{try{g&&!g.done&&(h=m.return)&&h.call(m)}finally{if(i)throw i.error}}f[d].pushBack({key:t,value:e}),f[d].size()>=a.treeifyThreshold&&(f[d]=new s.default(f[d]))}else f[d].setElement(t,e);var b=f[d].size();u+=b-p}else++u,f[d]=new o.default([{key:t,value:e}]);u>l*a.sigma&&c.call(this,l)}else this.eraseElementByKey(t)},this.getElementByKey=function(t){var e,i,o=r(t)&l-1;if(f[o]){if(f[o]instanceof s.default)return f[o].getElementByKey(t);try{for(var a=n(f[o]),h=a.next();!h.done;h=a.next()){var u=h.value;if(u.key===t)return u.value}}catch(t){e={error:t}}finally{try{h&&!h.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}}},this.eraseElementByKey=function(t){var e,i,h=r(t)&l-1;if(f[h]){var c=f[h].size();if(f[h]instanceof s.default)f[h].eraseElementByKey(t),f[h].size()<=a.untreeifyThreshold&&(f[h]=new o.default(f[h]));else{var d=-1;try{for(var p=n(f[h]),m=p.next();!m.done;m=p.next()){var g=m.value;if(++d,g.key===t){f[h].eraseElementByPos(d);break}}}catch(t){e={error:t}}finally{try{m&&!m.done&&(i=p.return)&&i.call(p)}finally{if(e)throw e.error}}}var y=f[h].size();u+=y-c}},this.find=function(t){var e,i,o=r(t)&l-1;if(!f[o])return!1;if(f[o]instanceof s.default)return f[o].find(t);try{for(var a=n(f[o]),h=a.next();!h.done;h=a.next())if(h.value.key===t)return!0}catch(t){e={error:t}}finally{try{h&&!h.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}return!1},this[Symbol.iterator]=function(){return function(){var t,e,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:t=0,i.label=1;case 1:if(!(t<l))return[3,10];for(;t<l&&!f[t];)++t;if(t>=l)return[3,10];i.label=2;case 2:i.trys.push([2,7,8,9]),s=void 0,e=n(f[t]),r=e.next(),i.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:i.sent(),i.label=5;case 5:return r=e.next(),[3,3];case 6:return[3,9];case 7:return o=i.sent(),s={error:o},[3,9];case 8:try{r&&!r.done&&(a=e.return)&&a.call(e)}finally{if(s)throw s.error}return[7];case 9:return++t,[3,1];case 10:return[2]}}))}()},t.forEach((function(t){var e=t.key,r=t.value;return h.setElement(e,r)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),r.default=a},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(t,e,r){var i=this&&this.__generator||function(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return h([t,e])}}function h(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=t("../Set/Set"),s=t("../LinkList/LinkList");function a(t,e,r){var h=this;if(void 0===t&&(t=[]),void 0===e&&(e=a.initSize),r=r||function(t){var e=0,r="";if("number"==typeof t)e=((e=Math.floor(t))<<5)-e,e&=e;else{r="string"!=typeof t?JSON.stringify(t):t;for(var i=0;i<r.length;i++)e=(e<<5)-e+r.charCodeAt(i),e&=e}return e^=e>>>16},0!=(e&e-1))throw new Error("initBucketNum must be 2 to the power of n");var u=0,f=[],l=Math.max(a.initSize,Math.min(a.maxSize,e));this.size=function(){return u},this.empty=function(){return 0===u},this.clear=function(){u=0,l=e,f=[]},this.forEach=function(t){var e=0;f.forEach((function(r){r.forEach((function(r){t(r,e++)}))}))};var c=function(t){if(!(t>=a.maxSize)){l=2*t;var e=[];f.forEach((function(i,n){if(!i.empty()){if(i instanceof s.default&&1===i.size()){var h=i.front();if(void 0===h)throw new Error("unknown error");e[r(h)&l-1]=new s.default([h])}else if(i instanceof o.default){var u=new s.default,c=new s.default;i.forEach((function(e){0==(r(e)&t)?u.pushBack(e):c.pushBack(e)})),u.size()>a.untreeifyThreshold?e[n]=new o.default(u):u.size()&&(e[n]=u),c.size()>a.untreeifyThreshold?e[n+t]=new o.default(c):c.size()&&(e[n+t]=c)}else{var d=new s.default,p=new s.default;i.forEach((function(e){0==(r(e)&t)?d.pushBack(e):p.pushBack(e)})),d.size()&&(e[n]=d),p.size()&&(e[n+t]=p)}f[n].clear()}})),f=e}};this.insert=function(t){if(null==t)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var e=r(t)&l-1;if(f[e]){var i=f[e].size();if(f[e]instanceof s.default){if(f[e].find(t))return;f[e].pushBack(t),f[e].size()>=a.treeifyThreshold&&(f[e]=new o.default(f[e]))}else f[e].insert(t);var n=f[e].size();u+=n-i}else f[e]=new s.default([t]),++u;u>l*a.sigma&&c.call(this,l)},this.eraseElementByValue=function(t){var e=r(t)&l-1;if(f[e]){var i=f[e].size();f[e].eraseElementByValue(t),f[e]instanceof o.default&&f[e].size()<=a.untreeifyThreshold&&(f[e]=new s.default(f[e]));var n=f[e].size();u+=n-i}},this.find=function(t){var e=r(t)&l-1;return!!f[e]&&f[e].find(t)},this[Symbol.iterator]=function(){return function(){var t,e,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:t=0,i.label=1;case 1:if(!(t<l))return[3,10];for(;t<l&&!f[t];)++t;if(t>=l)return[3,10];i.label=2;case 2:i.trys.push([2,7,8,9]),s=void 0,e=n(f[t]),r=e.next(),i.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:i.sent(),i.label=5;case 5:return r=e.next(),[3,3];case 6:return[3,9];case 7:return o=i.sent(),s={error:o},[3,9];case 8:try{r&&!r.done&&(a=e.return)&&a.call(e)}finally{if(s)throw s.error}return[7];case 9:return++t,[3,1];case 10:return[2]}}))}()},t.forEach((function(t){return h.insert(t)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),r.default=a},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(t,e,r){var i=this&&this.__generator||function(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return h([t,e])}}function h(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}};Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function t(t){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=t}return t}();function o(t){var e=this;void 0===t&&(t=[]);var r=0,o=void 0,s=void 0;this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){o=s=void 0,r=0},this.front=function(){return null==o?void 0:o.value},this.back=function(){return null==s?void 0:s.value},this.forEach=function(t){for(var e=o,r=0;e;){if(void 0===e.value)throw new Error("unknown error");t(e.value,r++),e=e.next}},this.getElementByPos=function(t){if(t<0||t>=r)throw new Error("pos must more then 0 and less then the list length");for(var e=o;t--&&e;)e=e.next;if(!e||void 0===e.value)throw new Error("unknown error");return e.value},this.eraseElementByPos=function(t){if(t<0||t>=r)throw new Error("erase pos must more then 0 and less then the list length");if(0===t)this.popFront();else if(t===r-1)this.popBack();else{for(var e=o;t--;){if(!(null==e?void 0:e.next))throw new Error("unknown error");e=e.next}if(!e||!e.pre||!e.next)throw new Error("unknown error");var i=e.pre,n=e.next;n.pre=i,i.next=n,r>0&&--r}},this.eraseElementByValue=function(t){for(;o&&o.value===t;)this.popFront();for(;s&&s.value===t;)this.popBack();if(o)for(var e=o;e;){if(e.value===t){var i=e.pre,n=e.next;n&&(n.pre=i),i&&(i.next=n),r>0&&--r}e=e.next}},this.pushBack=function(t){if(null==t)throw new Error("you can't push null or undefined here");++r;var e=new n(t);s?(s.next=e,e.pre=s,s=e):o=s=e},this.popBack=function(){s&&(r>0&&--r,s&&(o===s?o=s=void 0:(s=s.pre)&&(s.next=void 0)))},this.setElementByPos=function(t,e){if(null==e)throw new Error("you can't set null or undefined here");if(t<0||t>=r)throw new Error("pos must more then 0 and less then the list length");for(var i=o;t--;){if(!i)throw new Error("unknown error");i=i.next}i&&(i.value=e)},this.insert=function(t,e,i){if(void 0===i&&(i=1),null==e)throw new Error("you can't insert null or undefined here");if(t<0||t>r)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(i<0)throw new Error("insert size must more than 0");if(0===t)for(;i--;)this.pushFront(e);else if(t===r)for(;i--;)this.pushBack(e);else{for(var s=o,a=1;a<t;++a){if(!(null==s?void 0:s.next))throw new Error("unknown error");s=null==s?void 0:s.next}if(!s)throw new Error("unknown error");var h=s.next;for(r+=i;i--;)s.next=new n(e),s.next.pre=s,s=s.next;s.next=h,h&&(h.pre=s)}},this.find=function(t){for(var e=o;e;){if(e.value===t)return!0;e=e.next}return!1},this.reverse=function(){for(var t=o,e=s,i=0;t&&e&&2*i<r;){var n=t.value;t.value=e.value,e.value=n,t=t.next,e=e.pre,++i}},this.unique=function(){for(var t=o;t;){for(var e=t;e&&e.next&&e.value===e.next.value;)e=e.next,r>0&&--r;t.next=e.next,t.next&&(t.next.pre=t),t=t.next}},this.sort=function(t){var e=[];this.forEach((function(t){e.push(t)})),e.sort(t);var r=o;e.forEach((function(t){r&&(r.value=t,r=r.next)}))},this.pushFront=function(t){if(null==t)throw new Error("you can't push null or undefined here");++r;var e=new n(t);o?(e.next=o,o.pre=e,o=e):o=s=e},this.popFront=function(){o&&(r>0&&--r,o&&(o===s?o=s=void 0:(o=o.next)&&(o.pre=void 0)))},this.merge=function(t){var e=this,i=o;t.forEach((function(t){for(;i&&void 0!==i.value&&i.value<=t;)i=i.next;if(void 0===i)e.pushBack(t),i=s;else if(i===o)e.pushFront(t),i=o;else{++r;var a=i.pre;a&&(a.next=new n(t),a.next.pre=a,a.next.next=i,i&&(i.pre=a.next))}}))},this[Symbol.iterator]=function(){return function(){var t;return i(this,(function(e){switch(e.label){case 0:t=o,e.label=1;case 1:if(void 0===t)return[3,3];if(!t.value)throw new Error("unknown error");return[4,t.value];case 2:return e.sent(),t=t.next,[3,1];case 3:return[2]}}))}()},t.forEach((function(t){return e.pushBack(t)})),Object.freeze(this)}Object.freeze(o),r.default=o},{}],30:[function(t,e,r){var i=this&&this.__generator||function(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return h([t,e])}}function h(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=t("../Base/TreeNode");function s(t,e){var r=this;void 0===t&&(t=[]),e=e||function(t,e){return t<e?-1:t>e?1:0};var s=0,a=new o.default;a.color=o.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=a.value=void 0,a.leftChild=a.rightChild=a.brother=void 0};var h=function(t){if(!t||void 0===t.key)throw new Error("unknown error");return t.leftChild?h(t.leftChild):t},u=function(t){if(!t||void 0===t.key)throw new Error("unknown error");return t.rightChild?u(t.rightChild):t};this.front=function(){if(!this.empty()){var t=h(a);if(void 0===t.key||void 0===t.value)throw new Error("unknown error");return{key:t.key,value:t.value}}},this.back=function(){if(!this.empty()){var t=u(a);if(void 0===t.key||void 0===t.value)throw new Error("unknown error");return{key:t.key,value:t.value}}},this.forEach=function(t){var e,r,i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next())t(s.value,i++)}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}},this.getElementByPos=function(t){var e,r;if(t<0||t>=this.size())throw new Error("pos must more than 0 and less than set's size");var i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next()){var a=s.value;if(i===t)return a;++i}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}throw new Error("unknown Error")};var f=function(t,r){if(t&&void 0!==t.key&&void 0!==t.value){var i=e(t.key,r);return 0===i?{key:t.key,value:t.value}:i<0?f(t.rightChild,r):f(t.leftChild,r)||{key:t.key,value:t.value}}};this.lowerBound=function(t){return f(a,t)};var l=function(t,r){if(t&&void 0!==t.key&&void 0!==t.value)return e(t.key,r)<=0?l(t.rightChild,r):l(t.leftChild,r)||{key:t.key,value:t.value}};this.upperBound=function(t){return l(a,t)};var c=function(t,r){if(t&&void 0!==t.key&&void 0!==t.value){var i=e(t.key,r);return 0===i?{key:t.key,value:t.value}:i>0?c(t.leftChild,r):c(t.rightChild,r)||{key:t.key,value:t.value}}};this.reverseLowerBound=function(t){return c(a,t)};var d=function(t,r){if(t&&void 0!==t.key&&void 0!==t.value)return e(t.key,r)>=0?d(t.leftChild,r):d(t.rightChild,r)||{key:t.key,value:t.value}};this.reverseUpperBound=function(t){return d(a,t)};var p=function(t){var e=t.parent;if(!e){if(t===a)return;throw new Error("unknown error")}if(t.color!==o.default.TreeNodeColorType.red){var r=t.brother;if(!r)throw new Error("unknown error");if(t===e.leftChild)if(r.color===o.default.TreeNodeColorType.red){r.color=o.default.TreeNodeColorType.black,e.color=o.default.TreeNodeColorType.red;var i=e.rotateLeft();a===e&&(a=i),p(t)}else r.color===o.default.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===o.default.TreeNodeColorType.red?(r.color=e.color,e.color=o.default.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=e.rotateLeft(),a===e&&(a=i),t.color=o.default.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,p(e)):(r.color=o.default.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=r.rotateRight(),a===r&&(a=i),p(t)));else t===e.rightChild&&(r.color===o.default.TreeNodeColorType.red?(r.color=o.default.TreeNodeColorType.black,e.color=o.default.TreeNodeColorType.red,i=e.rotateRight(),a===e&&(a=i),p(t)):r.color===o.default.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===o.default.TreeNodeColorType.red?(r.color=e.color,e.color=o.default.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=e.rotateRight(),a===e&&(a=i),t.color=o.default.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,p(e)):(r.color=o.default.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=r.rotateLeft(),a===r&&(a=i),p(t))))}else t.color=o.default.TreeNodeColorType.black},m=function(t){for(var e=t;e.leftChild||e.rightChild;){if(e.rightChild){e=h(e.rightChild);var r=t.key;t.key=e.key,e.key=r;var i=t.value;t.value=e.value,e.value=i,t=e}e.leftChild&&(e=u(e.leftChild),r=t.key,t.key=e.key,e.key=r,i=t.value,t.value=e.value,e.value=i,t=e)}p(e),e&&e.remove(),--s,a.color=o.default.TreeNodeColorType.black},g=function(t,e){return!(!t||void 0===t.key)&&(!!g(t.leftChild,e)||!!e(t)||g(t.rightChild,e))};this.eraseElementByPos=function(t){if(t<0||t>=s)throw new Error("pos must more than 0 and less than set's size");var e=0;g(a,(function(r){return t===e?(m(r),!0):(++e,!1)}))},this.eraseElementByKey=function(t){if(!this.empty()){var r=v(a,t);void 0!==r&&void 0!==r.key&&0===e(r.key,t)&&m(r)}};var y=function(t,r){if(!t||void 0===t.key)throw new Error("unknown error");var i=e(r,t.key);return i<0?t.leftChild?y(t.leftChild,r):(t.leftChild=new o.default,t.leftChild.parent=t,t.leftChild.brother=t.rightChild,t.rightChild&&(t.rightChild.brother=t.leftChild),t.leftChild):i>0?t.rightChild?y(t.rightChild,r):(t.rightChild=new o.default,t.rightChild.parent=t,t.rightChild.brother=t.leftChild,t.leftChild&&(t.leftChild.brother=t.rightChild),t.rightChild):t},b=function(t){var e=t.parent;if(!e){if(t===a)return;throw new Error("unknown error")}if(e.color!==o.default.TreeNodeColorType.black&&e.color===o.default.TreeNodeColorType.red){var r=e.brother,i=e.parent;if(!i)throw new Error("unknown error");if(r&&r.color===o.default.TreeNodeColorType.red)r.color=e.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,b(i);else if(!r||r.color===o.default.TreeNodeColorType.black)if(e===i.leftChild)if(t===e.leftChild){e.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red;var n=i.rotateRight();i===a&&(a=n)}else t===e.rightChild&&(n=e.rotateLeft(),i===a&&(a=n),b(e));else e===i.rightChild&&(t===e.leftChild?(n=e.rotateRight(),i===a&&(a=n),b(e)):t===e.rightChild&&(e.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,n=i.rotateLeft(),i===a&&(a=n)))}};this.setElement=function(t,r){if(null==t)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=r){if(this.empty())return++s,a.key=t,a.value=r,void(a.color=o.default.TreeNodeColorType.black);var i=y(a,t);void 0===i.key||0!==e(i.key,t)?(++s,i.key=t,i.value=r,b(i),a.color=o.default.TreeNodeColorType.black):i.value=r}else this.eraseElementByKey(t)};var v=function(t,r){if(t&&void 0!==t.key){var i=e(r,t.key);return i<0?v(t.leftChild,r):i>0?v(t.rightChild,r):t}};this.find=function(t){return!!v(a,t)},this.getElementByKey=function(t){var e=v(a,t);if(void 0===(null==e?void 0:e.key)||void 0===(null==e?void 0:e.value))throw new Error("unknown error");return e.value},this.union=function(t){var e=this;t.forEach((function(t){var r=t.key,i=t.value;return e.setElement(r,i)}))},this.getHeight=function(){if(this.empty())return 0;var t=function(e){return e?Math.max(t(e.leftChild),t(e.rightChild))+1:1};return t(a)};var w=function(t){return i(this,(function(e){switch(e.label){case 0:return t&&void 0!==t.key&&void 0!==t.value?[5,n(w(t.leftChild))]:[2];case 1:return e.sent(),[4,{key:t.key,value:t.value}];case 2:return e.sent(),[5,n(w(t.rightChild))];case 3:return e.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},t.forEach((function(t){var e=t.key,i=t.value;return r.setElement(e,i)})),Object.freeze(this)}Object.freeze(s),r.default=s},{"../Base/TreeNode":25}],31:[function(t,e,r){function i(t,e){void 0===t&&(t=[]),e=e||function(t,e){return t>e?-1:t<e?1:0};var r=[];t.forEach((function(t){return r.push(t)}));var i=r.length,n=function(t,e){if(t<0||t>=i)throw new Error("unknown error");if(e<0||e>=i)throw new Error("unknown error");var n=r[t];r[t]=r[e],r[e]=n},o=function(t){if(t<0||t>=i)throw new Error("unknown error");var o=2*t+1,s=2*t+2;o<i&&e(r[t],r[o])>0&&n(t,o),s<i&&e(r[t],r[s])>0&&n(t,s)};!function(){for(var t=Math.floor((i-1)/2);t>=0;--t)for(var o=t,s=2*o+1;s<i;){var a=s+1,h=s;if(a<i&&e(r[s],r[a])>0&&(h=a),e(r[o],r[h])<=0)break;n(o,h),s=2*(o=h)+1}}(),this.size=function(){return i},this.empty=function(){return 0===i},this.clear=function(){i=0,r.length=0},this.push=function(t){if(r.push(t),1!=++i)for(var n=i-1;n>0;){var s=Math.floor((n-1)/2);if(e(r[s],t)<=0)break;o(s),n=s}},this.pop=function(){if(!this.empty())if(1!==this.size()){var t=r[i-1];--i;for(var n=0;n<this.size();){var o=2*n+1,s=2*n+2;if(o>=this.size())break;var a=o;if(s<this.size()&&e(r[o],r[s])>0&&(a=s),e(r[a],t)>=0)break;r[n]=r[a],n=a}r[n]=t}else--i},this.top=function(){return r[0]},Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(i),r.default=i},{}],32:[function(t,e,r){Object.defineProperty(r,"__esModule",{value:!0});var i=t("../LinkList/LinkList");function n(t){void 0===t&&(t=[]);var e=new i.default(t);this.size=function(){return e.size()},this.empty=function(){return e.empty()},this.clear=function(){e.clear()},this.push=function(t){e.pushBack(t)},this.pop=function(){e.popFront()},this.front=function(){return e.front()},Object.freeze(this)}Object.freeze(n),r.default=n},{"../LinkList/LinkList":29}],33:[function(t,e,r){var i=this&&this.__generator||function(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return h([t,e])}}function h(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},n=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=t("../Base/TreeNode");function s(t,e){var r=this;void 0===t&&(t=[]),e=e||function(t,e){return t<e?-1:t>e?1:0};var s=0,a=new o.default;a.color=o.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=void 0,a.leftChild=a.rightChild=a.brother=a.parent=void 0,a.color=o.default.TreeNodeColorType.black};var h=function(t){if(!t||void 0===t.key)throw new Error("unknown error");return t.leftChild?h(t.leftChild):t},u=function(t){if(!t||void 0===t.key)throw new Error("unknown error");return t.rightChild?u(t.rightChild):t};this.front=function(){if(!this.empty())return h(a).key},this.back=function(){if(!this.empty())return u(a).key},this.forEach=function(t){var e,r,i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next())t(s.value,i++)}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}},this.getElementByPos=function(t){var e,r;if(t<0||t>=this.size())throw new Error("pos must more than 0 and less than set's size");var i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next()){var a=s.value;if(i===t)return a;++i}}catch(t){e={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}throw new Error("unknown error")};var f=function(t){var e=t.parent;if(!e){if(t===a)return;throw new Error("unknown error")}if(t.color!==o.default.TreeNodeColorType.red){var r=t.brother;if(!r)throw new Error("unknown error");if(t===e.leftChild)if(r.color===o.default.TreeNodeColorType.red){r.color=o.default.TreeNodeColorType.black,e.color=o.default.TreeNodeColorType.red;var i=e.rotateLeft();a===e&&(a=i),f(t)}else r.color===o.default.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===o.default.TreeNodeColorType.red?(r.color=e.color,e.color=o.default.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=e.rotateLeft(),a===e&&(a=i),t.color=o.default.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,f(e)):(r.color=o.default.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=r.rotateRight(),a===r&&(a=i),f(t)));else t===e.rightChild&&(r.color===o.default.TreeNodeColorType.red?(r.color=o.default.TreeNodeColorType.black,e.color=o.default.TreeNodeColorType.red,i=e.rotateRight(),a===e&&(a=i),f(t)):r.color===o.default.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===o.default.TreeNodeColorType.red?(r.color=e.color,e.color=o.default.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=e.rotateRight(),a===e&&(a=i),t.color=o.default.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,f(e)):(r.color=o.default.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=r.rotateLeft(),a===r&&(a=i),f(t))))}else t.color=o.default.TreeNodeColorType.black},l=function(t){for(var e=t;e.leftChild||e.rightChild;){if(e.rightChild){e=h(e.rightChild);var r=t.key;t.key=e.key,e.key=r,t=e}e.leftChild&&(e=u(e.leftChild),r=t.key,t.key=e.key,e.key=r,t=e)}f(e),e&&e.remove(),--s,a.color=o.default.TreeNodeColorType.black},c=function(t,e){return!(!t||void 0===t.key)&&(!!c(t.leftChild,e)||!!e(t)||c(t.rightChild,e))};this.eraseElementByPos=function(t){if(t<0||t>=s)throw new Error("pos must more than 0 and less than set's size");var e=0;c(a,(function(r){return t===e?(l(r),!0):(++e,!1)}))},this.eraseElementByValue=function(t){if(!this.empty()){var r=m(a,t);void 0!==r&&void 0!==r.key&&0===e(r.key,t)&&l(r)}};var d=function(t,r){if(!t||void 0===t.key)throw new Error("unknown error");var i=e(r,t.key);return i<0?t.leftChild?d(t.leftChild,r):(t.leftChild=new o.default,t.leftChild.parent=t,t.leftChild.brother=t.rightChild,t.rightChild&&(t.rightChild.brother=t.leftChild),t.leftChild):i>0?t.rightChild?d(t.rightChild,r):(t.rightChild=new o.default,t.rightChild.parent=t,t.rightChild.brother=t.leftChild,t.leftChild&&(t.leftChild.brother=t.rightChild),t.rightChild):t},p=function(t){var e=t.parent;if(!e){if(t===a)return;throw new Error("unknown error")}if(e.color!==o.default.TreeNodeColorType.black&&e.color===o.default.TreeNodeColorType.red){var r=e.brother,i=e.parent;if(!i)throw new Error("unknown error");if(r&&r.color===o.default.TreeNodeColorType.red)r.color=e.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,p(i);else if(!r||r.color===o.default.TreeNodeColorType.black)if(e===i.leftChild)if(t===e.leftChild){e.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red;var n=i.rotateRight();i===a&&(a=n)}else t===e.rightChild&&(n=e.rotateLeft(),i===a&&(a=n),p(e));else e===i.rightChild&&(t===e.leftChild?(n=e.rotateRight(),i===a&&(a=n),p(e)):t===e.rightChild&&(e.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,n=i.rotateLeft(),i===a&&(a=n)))}};this.insert=function(t){if(null==t)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++s,a.key=t,void(a.color=o.default.TreeNodeColorType.black);var r=d(a,t);void 0!==r.key&&0===e(r.key,t)||(++s,r.key=t,p(r),a.color=o.default.TreeNodeColorType.black)};var m=function(t,r){if(t&&void 0!==t.key){var i=e(r,t.key);return i<0?m(t.leftChild,r):i>0?m(t.rightChild,r):t}};this.find=function(t){var r=m(a,t);return void 0!==r&&void 0!==r.key&&0===e(r.key,t)};var g=function(t,r){if(t&&void 0!==t.key){var i=e(t.key,r);if(0===i)return t.key;if(i<0)return g(t.rightChild,r);var n=g(t.leftChild,r);return void 0!==n?n:t.key}};this.lowerBound=function(t){return g(a,t)};var y=function(t,r){if(t&&void 0!==t.key){if(e(t.key,r)<=0)return y(t.rightChild,r);var i=y(t.leftChild,r);return void 0!==i?i:t.key}};this.upperBound=function(t){return y(a,t)};var b=function(t,r){if(t&&void 0!==t.key){var i=e(t.key,r);if(0===i)return t.key;if(i>0)return b(t.leftChild,r);var n=b(t.rightChild,r);return void 0!==n?n:t.key}};this.reverseLowerBound=function(t){return b(a,t)};var v=function(t,r){if(t&&void 0!==t.key){if(e(t.key,r)>=0)return v(t.leftChild,r);var i=v(t.rightChild,r);return void 0!==i?i:t.key}};this.reverseUpperBound=function(t){return v(a,t)},this.union=function(t){var e=this;t.forEach((function(t){return e.insert(t)}))},this.getHeight=function(){if(this.empty())return 0;var t=function(e){return e?Math.max(t(e.leftChild),t(e.rightChild))+1:1};return t(a)};var w=function(t){return i(this,(function(e){switch(e.label){case 0:return t&&void 0!==t.key?[5,n(w(t.leftChild))]:[2];case 1:return e.sent(),[4,t.key];case 2:return e.sent(),[5,n(w(t.rightChild))];case 3:return e.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},t.forEach((function(t){return r.insert(t)})),Object.freeze(this)}Object.freeze(s),r.default=s},{"../Base/TreeNode":25}],34:[function(t,e,r){function i(t){var e=this;void 0===t&&(t=[]);var r=0,i=[];this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,i.length=0},this.push=function(t){i.push(t),++r},this.pop=function(){i.pop(),r>0&&--r},this.top=function(){return i[r-1]},t.forEach((function(t){return e.push(t)})),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(i),r.default=i},{}],35:[function(t,e,r){var i=this&&this.__generator||function(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return h([t,e])}}function h(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},n=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},o=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};function a(t){var e=this;void 0===t&&(t=[]);var r=0,a=[];this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,a.length=0},this.front=function(){if(!this.empty())return a[0]},this.back=function(){if(!this.empty())return a[r-1]},this.forEach=function(t){a.forEach(t)},this.getElementByPos=function(t){if(t<0||t>=r)throw new Error("pos must more than 0 and less than vector's size");return a[t]},this.eraseElementByPos=function(t){if(t<0||t>=r)throw new Error("pos must more than 0 and less than vector's size");for(var e=t;e<r-1;++e)a[e]=a[e+1];this.popBack()},this.eraseElementByValue=function(t){var e=[];this.forEach((function(r){r!==t&&e.push(r)})),e.forEach((function(t,e){a[e]=t}));for(var i=e.length;r>i;)this.popBack()},this.pushBack=function(t){a.push(t),++r},this.popBack=function(){a.pop(),r>0&&--r},this.setElementByPos=function(t,e){if(t<0||t>=r)throw new Error("pos must more than 0 and less than vector's size");a[t]=e},this.insert=function(t,e,i){if(void 0===i&&(i=1),t<0||t>r)throw new Error("pos must more than 0 and less than or equal to vector's size");a.splice.apply(a,o([t,0],n(new Array(i).fill(e)),!1)),r+=i},this.find=function(t){return a.includes(t)},this.reverse=function(){a.reverse()},this.unique=function(){var t,e=[];this.forEach((function(r,i){0!==i&&r===t||(e.push(r),t=r)})),e.forEach((function(t,e){a[e]=t}));for(var i=e.length;r>i;)this.popBack()},this.sort=function(t){a.sort(t)},this[Symbol.iterator]=function(){return function(){return i(this,(function(t){switch(t.label){case 0:return[5,s(a)];case 1:return[2,t.sent()]}}))}()},t.forEach((function(t){return e.pushBack(t)})),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(a),r.default=a},{}],36:[function(t,e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.HashMap=r.HashSet=r.Map=r.Set=r.PriorityQueue=r.Deque=r.LinkList=r.Queue=r.Stack=r.Vector=void 0;var i=t("./Vector/Vector");r.Vector=i.default;var n=t("./Stack/Stack");r.Stack=n.default;var o=t("./Queue/Queue");r.Queue=o.default;var s=t("./LinkList/LinkList");r.LinkList=s.default;var a=t("./Deque/Deque");r.Deque=a.default;var h=t("./PriorityQueue/PriorityQueue");r.PriorityQueue=h.default;var u=t("./Set/Set");r.Set=u.default;var f=t("./Map/Map");r.Map=f.default;var l=t("./HashSet/HashSet");r.HashSet=l.default;var c=t("./HashMap/HashMap");r.HashMap=c.default},{"./Deque/Deque":26,"./HashMap/HashMap":27,"./HashSet/HashSet":28,"./LinkList/LinkList":29,"./Map/Map":30,"./PriorityQueue/PriorityQueue":31,"./Queue/Queue":32,"./Set/Set":33,"./Stack/Stack":34,"./Vector/Vector":35}],37:[function(t,e,r){const i=t("yallist"),n=Symbol("max"),o=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),h=Symbol("maxAge"),u=Symbol("dispose"),f=Symbol("noDisposeOnSet"),l=Symbol("lruList"),c=Symbol("cache"),d=Symbol("updateAgeOnGet"),p=()=>1;class m{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[n]=t.max||1/0;const e=t.length||p;if(this[s]="function"!=typeof e?p:e,this[a]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[h]=t.maxAge||0,this[u]=t.dispose,this[f]=t.noDisposeOnSet||!1,this[d]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[n]=t||1/0,b(this)}get max(){return this[n]}set allowStale(t){this[a]=!!t}get allowStale(){return this[a]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[h]=t,b(this)}get maxAge(){return this[h]}set lengthCalculator(t){"function"!=typeof t&&(t=p),t!==this[s]&&(this[s]=t,this[o]=0,this[l].forEach((t=>{t.length=this[s](t.value,t.key),this[o]+=t.length}))),b(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[l].length}rforEach(t,e){e=e||this;for(let r=this[l].tail;null!==r;){const i=r.prev;_(this,t,r,e),r=i}}forEach(t,e){e=e||this;for(let r=this[l].head;null!==r;){const i=r.next;_(this,t,r,e),r=i}}keys(){return this[l].toArray().map((t=>t.key))}values(){return this[l].toArray().map((t=>t.value))}reset(){this[u]&&this[l]&&this[l].length&&this[l].forEach((t=>this[u](t.key,t.value))),this[c]=new Map,this[l]=new i,this[o]=0}dump(){return this[l].map((t=>!y(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[l]}set(t,e,r){if((r=r||this[h])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const i=r?Date.now():0,a=this[s](e,t);if(this[c].has(t)){if(a>this[n])return v(this,this[c].get(t)),!1;const s=this[c].get(t).value;return this[u]&&(this[f]||this[u](t,s.value)),s.now=i,s.maxAge=r,s.value=e,this[o]+=a-s.length,s.length=a,this.get(t),b(this),!0}const d=new w(t,e,a,i,r);return d.length>this[n]?(this[u]&&this[u](t,e),!1):(this[o]+=d.length,this[l].unshift(d),this[c].set(t,this[l].head),b(this),!0)}has(t){if(!this[c].has(t))return!1;const e=this[c].get(t).value;return!y(this,e)}get(t){return g(this,t,!0)}peek(t){return g(this,t,!1)}pop(){const t=this[l].tail;return t?(v(this,t),t.value):null}del(t){v(this,this[c].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const i=t[r],n=i.e||0;if(0===n)this.set(i.k,i.v);else{const t=n-e;t>0&&this.set(i.k,i.v,t)}}}prune(){this[c].forEach(((t,e)=>g(this,e,!1)))}}const g=(t,e,r)=>{const i=t[c].get(e);if(i){const e=i.value;if(y(t,e)){if(v(t,i),!t[a])return}else r&&(t[d]&&(i.value.now=Date.now()),t[l].unshiftNode(i));return e.value}},y=(t,e)=>{if(!e||!e.maxAge&&!t[h])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[h]&&r>t[h]},b=t=>{if(t[o]>t[n])for(let e=t[l].tail;t[o]>t[n]&&null!==e;){const r=e.prev;v(t,e),e=r}},v=(t,e)=>{if(e){const r=e.value;t[u]&&t[u](r.key,r.value),t[o]-=r.length,t[c].delete(r.key),t[l].removeNode(e)}};class w{constructor(t,e,r,i,n){this.key=t,this.value=e,this.length=r,this.now=i,this.maxAge=n||0}}const _=(t,e,r,i)=>{let n=r.value;y(t,n)&&(v(t,r),t[a]||(n=void 0)),n&&e.call(i,n.value,n.key,t)};e.exports=m},{yallist:83}],38:[function(t,e,r){(function(t){(function(){const r=e.exports;r.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"},r.codes={};for(const t in r.types){const e=r.types[t];r.codes[e]=t}r.CMD_SHIFT=4,r.CMD_MASK=240,r.DUP_MASK=8,r.QOS_MASK=3,r.QOS_SHIFT=1,r.RETAIN_MASK=1,r.VARBYTEINT_MASK=127,r.VARBYTEINT_FIN_MASK=128,r.VARBYTEINT_MAX=268435455,r.SESSIONPRESENT_MASK=1,r.SESSIONPRESENT_HEADER=t.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=t.from([r.codes.connack<<r.CMD_SHIFT]),r.USERNAME_MASK=128,r.PASSWORD_MASK=64,r.WILL_RETAIN_MASK=32,r.WILL_QOS_MASK=24,r.WILL_QOS_SHIFT=3,r.WILL_FLAG_MASK=4,r.CLEAN_SESSION_MASK=2,r.CONNECT_HEADER=t.from([r.codes.connect<<r.CMD_SHIFT]),r.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},r.propertiesCodes={};for(const t in r.properties){const e=r.properties[t];r.propertiesCodes[e]=t}function i(e){return[0,1,2].map((i=>[0,1].map((n=>[0,1].map((o=>{const s=t.alloc(1);return s.writeUInt8(r.codes[e]<<r.CMD_SHIFT|(n?r.DUP_MASK:0)|i<<r.QOS_SHIFT|o,0,!0),s}))))))}r.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"},r.PUBLISH_HEADER=i("publish"),r.SUBSCRIBE_HEADER=i("subscribe"),r.SUBSCRIBE_OPTIONS_QOS_MASK=3,r.SUBSCRIBE_OPTIONS_NL_MASK=1,r.SUBSCRIBE_OPTIONS_NL_SHIFT=2,r.SUBSCRIBE_OPTIONS_RAP_MASK=1,r.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,r.SUBSCRIBE_OPTIONS_RH_MASK=3,r.SUBSCRIBE_OPTIONS_RH_SHIFT=4,r.SUBSCRIBE_OPTIONS_RH=[0,16,32],r.SUBSCRIBE_OPTIONS_NL=4,r.SUBSCRIBE_OPTIONS_RAP=8,r.SUBSCRIBE_OPTIONS_QOS=[0,1,2],r.UNSUBSCRIBE_HEADER=i("unsubscribe"),r.ACKS={unsuback:i("unsuback"),puback:i("puback"),pubcomp:i("pubcomp"),pubrel:i("pubrel"),pubrec:i("pubrec")},r.SUBACK_HEADER=t.from([r.codes.suback<<r.CMD_SHIFT]),r.VERSION3=t.from([3]),r.VERSION4=t.from([4]),r.VERSION5=t.from([5]),r.VERSION131=t.from([131]),r.VERSION132=t.from([132]),r.QOS=[0,1,2].map((e=>t.from([e]))),r.EMPTY={pingreq:t.from([r.codes.pingreq<<4,0]),pingresp:t.from([r.codes.pingresp<<4,0]),disconnect:t.from([r.codes.disconnect<<4,0])}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:17}],39:[function(t,e,r){(function(r){(function(){const i=t("./writeToStream"),n=t("events");function o(t,e){const r=new s;return i(t,r,e),r.concat()}class s extends n{constructor(){super(),this._array=new Array(20),this._i=0}write(t){return this._array[this._i++]=t,!0}concat(){let t=0;const e=new Array(this._array.length),i=this._array;let n,o=0;for(n=0;n<i.length&&void 0!==i[n];n++)"string"!=typeof i[n]?e[n]=i[n].length:e[n]=r.byteLength(i[n]),t+=e[n];const s=r.allocUnsafe(t);for(n=0;n<i.length&&void 0!==i[n];n++)"string"!=typeof i[n]?(i[n].copy(s,o),o+=e[n]):(s.write(i[n],o),o+=e[n]);return s}}e.exports=o}).call(this)}).call(this,t("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(t,e,r){r.parser=t("./parser").parser,r.generate=t("./generate"),r.writeToStream=t("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(t,e,r){(function(t){(function(){const r=65536,i={},n=t.isBuffer(t.from([1,2]).subarray(0,1));function o(e){const r=t.allocUnsafe(2);return r.writeUInt8(e>>8,0),r.writeUInt8(255&e,1),r}function s(){for(let t=0;t<r;t++)i[t]=o(t)}function a(e){const r=4;let i=0,o=0;const s=t.allocUnsafe(r);do{i=e%128|0,(e=e/128|0)>0&&(i|=128),s.writeUInt8(i,o++)}while(e>0&&o<r);return e>0&&(o=0),n?s.subarray(0,o):s.slice(0,o)}function h(e){const r=t.allocUnsafe(4);return r.writeUInt32BE(e,0),r}e.exports={cache:i,generateCache:s,generateNumber:o,genBufVariableByteInt:a,generate4ByteBuffer:h}}).call(this)}).call(this,t("buffer").Buffer)},{buffer:17}],42:[function(t,e,r){class i{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}e.exports=i},{}],43:[function(t,e,r){const i=t("bl"),n=t("events"),o=t("./packet"),s=t("./constants"),a=t("debug")("mqtt-packet:parser");class h extends n{constructor(){super(),this.parser=this.constructor.parser}static parser(t){return this instanceof h?(this.settings=t||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new h).parser(t)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=i(),this._stateCounter=0}parse(t){for(this.error&&this._resetState(),this._list.append(t),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const t=this._list.readUInt8(0);return this.packet.cmd=s.types[t>>s.CMD_SHIFT],this.packet.retain=0!=(t&s.RETAIN_MASK),this.packet.qos=t>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(t&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const t=this._parseVarByteNum(!0);return t&&(this.packet.length=t.value,this._list.consume(t.bytes)),a("_parseLength %d",t.value),!!t}_parsePayload(){a("_parsePayload: payload %O",this._list);let t=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}t=!0}return a("_parsePayload complete result: %s",t),t}_parseConnect(){let t,e,r,i;a("_parseConnect");const n={},o=this.packet,h=this._parseString();if(null===h)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==h&&"MQIsdp"!==h)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=h,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),o.protocolVersion>=128&&(o.bridgeMode=!0,o.protocolVersion=o.protocolVersion-128),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(n.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,n.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,n.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,n.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(o.properties=t)}const u=this._parseString();if(null===u)return this._emitError(new Error("Packet too short"));if(o.clientId=u,a("_parseConnect: packet.clientId: %s",o.clientId),n.will){if(5===o.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(o.will.properties=t)}if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=t,a("_parseConnect: packet.will.topic: %s",o.will.topic),e=this._parseBuffer(),null===e)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=e,a("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(n.username){if(i=this._parseString(),null===i)return this._emitError(new Error("Cannot parse username"));o.username=i,a("_parseConnect: packet.username: %s",o.username)}if(n.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));o.password=r}return this.settings=o,a("_parseConnect: complete"),o}_parseConnack(){a("_parseConnack");const t=this.packet;if(this._list.length<1)return null;if(t.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?t.reasonCode=this._list.readUInt8(this._pos++):t.reasonCode=0;else{if(this._list.length<2)return null;t.returnCode=this._list.readUInt8(this._pos++)}if(-1===t.returnCode||-1===t.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const t=this.packet;if(t.topic=this._parseString(),null===t.topic)return this._emitError(new Error("Cannot parse topic"));if(!(t.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}t.payload=this._list.slice(this._pos,t.length),a("_parsePublish: payload from buffer list: %o",t.payload)}}_parseSubscribe(){a("_parseSubscribe");const t=this.packet;let e,r,i,n,o,h,u;if(1!==t.qos)return this._emitError(new Error("Wrong subscribe header"));if(t.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}for(;this._pos<t.length;){if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=t.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),i=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,h=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),n=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,u={topic:e,qos:i},5===this.settings.protocolVersion?(u.nl=h,u.rap=o,u.rh=n):this.settings.bridgeMode&&(u.rh=0,u.rap=!0,u.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",u),t.subscriptions.push(u)}}}_parseSuback(){a("_parseSuback");const t=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const t=this.packet;if(t.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}for(;this._pos<t.length;){const e=this._parseString();if(null===e)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",e),t.unsubscriptions.push(e)}}}_parseUnsuback(){a("_parseUnsuback");const t=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const e=this._parseProperties();for(Object.getOwnPropertyNames(e).length&&(t.properties=e),t.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const t=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(t.length>2?(t.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",t.reasonCode)):t.reasonCode=0,t.length>3)){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}return!0}_parseDisconnect(){const t=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?t.reasonCode=this._parseByte():t.reasonCode=0;const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(t.properties=e)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const t=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));t.reasonCode=this._parseByte();const e=this._parseProperties();return Object.getOwnPropertyNames(e).length&&(t.properties=e),a("_parseAuth: result: true"),!0}_parseMessageId(){const t=this.packet;return t.messageId=this._parseNum(),null===t.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",t.messageId),!0)}_parseString(t){const e=this._parseNum(),r=e+this._pos;if(-1===e||r>this._list.length||r>this.packet.length)return null;const i=this._list.toString("utf8",this._pos,r);return this._pos+=e,a("_parseString: result: %s",i),i}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const t=this._parseNum(),e=t+this._pos;if(-1===t||e>this._list.length||e>this.packet.length)return null;const r=this._list.slice(this._pos,e);return this._pos+=t,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const t=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",t),t}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const t=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",t),t}_parseVarByteNum(t){a("_parseVarByteNum");const e=4;let r,i=0,n=1,o=0,h=!1;const u=this._pos?this._pos:0;for(;i<e&&u+i<this._list.length;){if(r=this._list.readUInt8(u+i++),o+=n*(r&s.VARBYTEINT_MASK),n*=128,0==(r&s.VARBYTEINT_FIN_MASK)){h=!0;break}if(this._list.length<=i)break}return!h&&i===e&&this._list.length>=i&&this._emitError(new Error("Invalid variable byte integer")),u&&(this._pos+=i),h=!!h&&(t?{bytes:i,value:o}:o),a("_parseVarByteNum: result: %o",h),h}_parseByte(){let t;return this._pos<this._list.length&&(t=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",t),t}_parseByType(t){switch(a("_parseByType: type: %s",t),t){case"byte":return 0!==this._parseByte();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(){a("_parseProperties");const t=this._parseVarByteNum(),e=this._pos+t,r={};for(;this._pos<e;){const t=this._parseByte();if(!t)return this._emitError(new Error("Cannot parse property code type")),!1;const e=s.propertiesCodes[t];if(!e)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==e)r[e]?(Array.isArray(r[e])||(r[e]=[r[e]]),r[e].push(this._parseByType(s.propertiesTypes[e]))):r[e]=this._parseByType(s.propertiesTypes[e]);else{r[e]||(r[e]=Object.create(null));const t=this._parseByType(s.propertiesTypes[e]);if(r[e][t.name])if(Array.isArray(r[e][t.name]))r[e][t.name].push(t.value);else{const i=r[e][t.name];r[e][t.name]=[i],r[e][t.name].push(t.value)}else r[e][t.name]=t.value}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_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)),a("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(t){a("_emitError"),this.error=t,this.emit("error",t)}}e.exports=h},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(t,e,r){(function(r){(function(){const i=t("./constants"),n=r.allocUnsafe(0),o=r.from([0]),s=t("./numbers"),a=t("process-nextick-args").nextTick,h=t("debug")("mqtt-packet:writeToStream"),u=s.cache,f=s.generateNumber,l=s.generateCache,c=s.genBufVariableByteInt,d=s.generate4ByteBuffer;let p=P,m=!0;function g(t,e,r){switch(h("generate called"),e.cork&&(e.cork(),a(y,e)),m&&(m=!1,l()),h("generate: packet.cmd: %s",t.cmd),t.cmd){case"connect":return b(t,e);case"connack":return v(t,e,r);case"publish":return w(t,e,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return _(t,e,r);case"subscribe":return M(t,e,r);case"suback":return S(t,e,r);case"unsubscribe":return E(t,e,r);case"unsuback":return k(t,e,r);case"pingreq":case"pingresp":return A(t,e);case"disconnect":return O(t,e,r);case"auth":return T(t,e,r);default:return e.emit("error",new Error("Unknown command")),!1}}function y(t){t.uncork()}function b(t,e,n){const o=t||{},s=o.protocolId||"MQTT";let a=o.protocolVersion||4;const h=o.will;let u=o.clean;const f=o.keepalive||0,l=o.clientId||"",c=o.username,d=o.password,m=o.properties;void 0===u&&(u=!0);let g=0;if(!s||"string"!=typeof s&&!r.isBuffer(s))return e.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return e.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof l||r.isBuffer(l))&&(l||a>=4)&&(l||u))g+=r.byteLength(l)+2;else{if(a<4)return e.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*u==0)return e.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof f||f<0||f>65535||f%1!=0)return e.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=D(e,m);if(!y)return!1;g+=y.length}if(h){if("object"!=typeof h)return e.emit("error",new Error("Invalid will")),!1;if(!h.topic||"string"!=typeof h.topic)return e.emit("error",new Error("Invalid will topic")),!1;if(g+=r.byteLength(h.topic)+2,g+=2,h.payload){if(!(h.payload.length>=0))return e.emit("error",new Error("Invalid will payload")),!1;"string"==typeof h.payload?g+=r.byteLength(h.payload):g+=h.payload.length}var b={};if(5===a){if(!(b=D(e,h.properties)))return!1;g+=b.length}}let v=!1;if(null!=c){if(!z(c))return e.emit("error",new Error("Invalid username")),!1;v=!0,g+=r.byteLength(c)+2}if(null!=d){if(!v)return e.emit("error",new Error("Username is required to use password")),!1;if(!z(d))return e.emit("error",new Error("Invalid password")),!1;g+=F(d)+2}e.write(i.CONNECT_HEADER),R(e,g),L(e,s),o.bridgeMode&&(a+=128),e.write(131===a?i.VERSION131:132===a?i.VERSION132:4===a?i.VERSION4:5===a?i.VERSION5:i.VERSION3);let w=0;return w|=null!=c?i.USERNAME_MASK:0,w|=null!=d?i.PASSWORD_MASK:0,w|=h&&h.retain?i.WILL_RETAIN_MASK:0,w|=h&&h.qos?h.qos<<i.WILL_QOS_SHIFT:0,w|=h?i.WILL_FLAG_MASK:0,w|=u?i.CLEAN_SESSION_MASK:0,e.write(r.from([w])),p(e,f),5===a&&y.write(),L(e,l),h&&(5===a&&b.write(),C(e,h.topic),L(e,h.payload)),null!=c&&L(e,c),null!=d&&L(e,d),!0}function v(t,e,n){const s=n?n.protocolVersion:4,a=t||{},h=5===s?a.reasonCode:a.returnCode,u=a.properties;let f=2;if("number"!=typeof h)return e.emit("error",new Error("Invalid return code")),!1;let l=null;if(5===s){if(l=D(e,u),!l)return!1;f+=l.length}return e.write(i.CONNACK_HEADER),R(e,f),e.write(a.sessionPresent?i.SESSIONPRESENT_HEADER:o),e.write(r.from([h])),null!=l&&l.write(),!0}function w(t,e,o){h("publish: packet: %o",t);const s=o?o.protocolVersion:4,a=t||{},u=a.qos||0,f=a.retain?i.RETAIN_MASK:0,l=a.topic,c=a.payload||n,d=a.messageId,m=a.properties;let g=0;if("string"==typeof l)g+=r.byteLength(l)+2;else{if(!r.isBuffer(l))return e.emit("error",new Error("Invalid topic")),!1;g+=l.length+2}if(r.isBuffer(c)?g+=c.length:g+=r.byteLength(c),u&&"number"!=typeof d)return e.emit("error",new Error("Invalid messageId")),!1;u&&(g+=2);let y=null;if(5===s){if(y=D(e,m),!y)return!1;g+=y.length}return e.write(i.PUBLISH_HEADER[u][a.dup?1:0][f?1:0]),R(e,g),p(e,F(l)),e.write(l),u>0&&p(e,d),null!=y&&y.write(),h("publish: payload: %o",c),e.write(c)}function _(t,e,n){const o=n?n.protocolVersion:4,s=t||{},a=s.cmd||"puback",h=s.messageId,u=s.dup&&"pubrel"===a?i.DUP_MASK:0;let f=0;const l=s.reasonCode,c=s.properties;let d=5===o?3:2;if("pubrel"===a&&(f=1),"number"!=typeof h)return e.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===o&&"object"==typeof c){if(m=j(e,c,n,d),!m)return!1;d+=m.length}return e.write(i.ACKS[a][f][u][0]),R(e,d),p(e,h),5===o&&e.write(r.from([l])),null!==m&&m.write(),!0}function M(t,e,n){h("subscribe: packet: ");const o=n?n.protocolVersion:4,s=t||{},a=s.dup?i.DUP_MASK:0,u=s.messageId,f=s.subscriptions,l=s.properties;let c=0;if("number"!=typeof u)return e.emit("error",new Error("Invalid messageId")),!1;c+=2;let d=null;if(5===o){if(d=D(e,l),!d)return!1;c+=d.length}if("object"!=typeof f||!f.length)return e.emit("error",new Error("Invalid subscriptions")),!1;for(let t=0;t<f.length;t+=1){const i=f[t].topic,n=f[t].qos;if("string"!=typeof i)return e.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof n)return e.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===o){if("boolean"!=typeof(f[t].nl||!1))return e.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(f[t].rap||!1))return e.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const r=f[t].rh||0;if("number"!=typeof r||r>2)return e.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}c+=r.byteLength(i)+2+1}h("subscribe: writing to stream: %o",i.SUBSCRIBE_HEADER),e.write(i.SUBSCRIBE_HEADER[1][a?1:0][0]),R(e,c),p(e,u),null!==d&&d.write();let m=!0;for(const t of f){const n=t.topic,s=t.qos,a=+t.nl,h=+t.rap,u=t.rh;let f;C(e,n),f=i.SUBSCRIBE_OPTIONS_QOS[s],5===o&&(f|=a?i.SUBSCRIBE_OPTIONS_NL:0,f|=h?i.SUBSCRIBE_OPTIONS_RAP:0,f|=u?i.SUBSCRIBE_OPTIONS_RH[u]:0),m=e.write(r.from([f]))}return m}function S(t,e,n){const o=n?n.protocolVersion:4,s=t||{},a=s.messageId,h=s.granted,u=s.properties;let f=0;if("number"!=typeof a)return e.emit("error",new Error("Invalid messageId")),!1;if(f+=2,"object"!=typeof h||!h.length)return e.emit("error",new Error("Invalid qos vector")),!1;for(let t=0;t<h.length;t+=1){if("number"!=typeof h[t])return e.emit("error",new Error("Invalid qos vector")),!1;f+=1}let l=null;if(5===o){if(l=j(e,u,n,f),!l)return!1;f+=l.length}return e.write(i.SUBACK_HEADER),R(e,f),p(e,a),null!==l&&l.write(),e.write(r.from(h))}function E(t,e,n){const o=n?n.protocolVersion:4,s=t||{},a=s.messageId,h=s.dup?i.DUP_MASK:0,u=s.unsubscriptions,f=s.properties;let l=0;if("number"!=typeof a)return e.emit("error",new Error("Invalid messageId")),!1;if(l+=2,"object"!=typeof u||!u.length)return e.emit("error",new Error("Invalid unsubscriptions")),!1;for(let t=0;t<u.length;t+=1){if("string"!=typeof u[t])return e.emit("error",new Error("Invalid unsubscriptions")),!1;l+=r.byteLength(u[t])+2}let c=null;if(5===o){if(c=D(e,f),!c)return!1;l+=c.length}e.write(i.UNSUBSCRIBE_HEADER[1][h?1:0][0]),R(e,l),p(e,a),null!==c&&c.write();let d=!0;for(let t=0;t<u.length;t++)d=C(e,u[t]);return d}function k(t,e,n){const o=n?n.protocolVersion:4,s=t||{},a=s.messageId,h=s.dup?i.DUP_MASK:0,u=s.granted,f=s.properties,l=s.cmd,c=0;let d=2;if("number"!=typeof a)return e.emit("error",new Error("Invalid messageId")),!1;if(5===o){if("object"!=typeof u||!u.length)return e.emit("error",new Error("Invalid qos vector")),!1;for(let t=0;t<u.length;t+=1){if("number"!=typeof u[t])return e.emit("error",new Error("Invalid qos vector")),!1;d+=1}}let m=null;if(5===o){if(m=j(e,f,n,d),!m)return!1;d+=m.length}return e.write(i.ACKS[l][c][h][0]),R(e,d),p(e,a),null!==m&&m.write(),5===o&&e.write(r.from(u)),!0}function A(t,e,r){return e.write(i.EMPTY[t.cmd])}function O(t,e,n){const o=n?n.protocolVersion:4,s=t||{},a=s.reasonCode,h=s.properties;let u=5===o?1:0,f=null;if(5===o){if(f=j(e,h,n,u),!f)return!1;u+=f.length}return e.write(r.from([i.codes.disconnect<<4])),R(e,u),5===o&&e.write(r.from([a])),null!==f&&f.write(),!0}function T(t,e,n){const o=n?n.protocolVersion:4,s=t||{},a=s.reasonCode,h=s.properties;let u=5===o?1:0;5!==o&&e.emit("error",new Error("Invalid mqtt version for auth packet"));const f=j(e,h,n,u);return!!f&&(u+=f.length,e.write(r.from([i.codes.auth<<4])),R(e,u),e.write(r.from([a])),null!==f&&f.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>p===P,set(t){t?(u&&0!==Object.keys(u).length||(m=!0),p=P):(m=!1,p=B)}});const I={};function R(t,e){if(e>i.VARBYTEINT_MAX)return t.emit("error",new Error(`Invalid variable byte integer: ${e}`)),!1;let r=I[e];return r||(r=c(e),e<16384&&(I[e]=r)),h("writeVarByteInt: writing to stream: %o",r),t.write(r)}function C(t,e){const i=r.byteLength(e);return p(t,i),h("writeString: %s",e),t.write(e,"utf8")}function x(t,e,r){C(t,e),C(t,r)}function P(t,e){return h("writeNumberCached: number: %d",e),h("writeNumberCached: %o",u[e]),t.write(u[e])}function B(t,e){const r=f(e);return h("writeNumberGenerated: %o",r),t.write(r)}function N(t,e){const r=d(e);return h("write4ByteNumber: %o",r),t.write(r)}function L(t,e){"string"==typeof e?C(t,e):e?(p(t,e.length),t.write(e)):p(t,0)}function D(t,e){if("object"!=typeof e||null!=e.length)return{length:1,write(){q(t,{},0)}};let n=0;function o(e,n){let o=0;switch(i.propertiesTypes[e]){case"byte":if("boolean"!=typeof n)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=2;break;case"int8":if("number"!=typeof n||n<0||n>255)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=2;break;case"binary":if(n&&null===n)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=1+r.byteLength(n)+2;break;case"int16":if("number"!=typeof n||n<0||n>65535)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=3;break;case"int32":if("number"!=typeof n||n<0||n>4294967295)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=5;break;case"var":if("number"!=typeof n||n<0||n>268435455)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=1+r.byteLength(c(n));break;case"string":if("string"!=typeof n)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=3+r.byteLength(n.toString());break;case"pair":if("object"!=typeof n)return t.emit("error",new Error(`Invalid ${e}: ${n}`)),!1;o+=Object.getOwnPropertyNames(n).reduce(((t,e)=>{const i=n[e];return Array.isArray(i)?t+=i.reduce(((t,i)=>t+=3+r.byteLength(e.toString())+2+r.byteLength(i.toString())),0):t+=3+r.byteLength(e.toString())+2+r.byteLength(n[e].toString()),t}),0);break;default:return t.emit("error",new Error(`Invalid property ${e}: ${n}`)),!1}return o}if(e)for(const t in e){let r=0,i=0;const s=e[t];if(Array.isArray(s))for(let e=0;e<s.length;e++){if(i=o(t,s[e]),!i)return!1;r+=i}else{if(i=o(t,s),!i)return!1;r=i}if(!r)return!1;n+=r}return{length:r.byteLength(c(n))+n,write(){q(t,e,n)}}}function j(t,e,r,i){const n=["reasonString","userProperties"],o=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=D(t,e);if(o)for(;i+s.length>o;){const r=n.shift();if(!r||!e[r])return!1;delete e[r],s=D(t,e)}return s}function U(t,e,n){switch(i.propertiesTypes[e]){case"byte":t.write(r.from([i.properties[e]])),t.write(r.from([+n]));break;case"int8":t.write(r.from([i.properties[e]])),t.write(r.from([n]));break;case"binary":t.write(r.from([i.properties[e]])),L(t,n);break;case"int16":t.write(r.from([i.properties[e]])),p(t,n);break;case"int32":t.write(r.from([i.properties[e]])),N(t,n);break;case"var":t.write(r.from([i.properties[e]])),R(t,n);break;case"string":t.write(r.from([i.properties[e]])),C(t,n);break;case"pair":Object.getOwnPropertyNames(n).forEach((o=>{const s=n[o];Array.isArray(s)?s.forEach((n=>{t.write(r.from([i.properties[e]])),x(t,o.toString(),n.toString())})):(t.write(r.from([i.properties[e]])),x(t,o.toString(),s.toString()))}));break;default:return t.emit("error",new Error(`Invalid property ${e} value: ${n}`)),!1}}function q(t,e,r){R(t,r);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&null!==e[r]){const i=e[r];if(Array.isArray(i))for(let e=0;e<i.length;e++)U(t,r,i[e]);else U(t,r,i)}}function F(t){return t?t instanceof r?t.length:r.byteLength(t):0}function z(t){return"string"==typeof t||t instanceof r}e.exports=g}).call(this)}).call(this,t("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(t,e,r){var i=1e3,n=60*i,o=60*n,s=24*o,a=7*s,h=365.25*s;function u(t){if(!((t=String(t)).length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*h;case"weeks":case"week":case"w":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function f(t){var e=Math.abs(t);return e>=s?Math.round(t/s)+"d":e>=o?Math.round(t/o)+"h":e>=n?Math.round(t/n)+"m":e>=i?Math.round(t/i)+"s":t+"ms"}function l(t){var e=Math.abs(t);return e>=s?c(t,e,s,"day"):e>=o?c(t,e,o,"hour"):e>=n?c(t,e,n,"minute"):e>=i?c(t,e,i,"second"):t+" ms"}function c(t,e,r,i){var n=e>=1.5*r;return Math.round(t/r)+" "+i+(n?"s":"")}e.exports=function(t,e){e=e||{};var r=typeof t;if("string"===r&&t.length>0)return u(t);if("number"===r&&isFinite(t))return e.long?l(t):f(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],46:[function(t,e,r){const i=t("./lib/number-allocator.js");e.exports.NumberAllocator=i},{"./lib/number-allocator.js":47}],47:[function(t,e,r){const i=t("js-sdsl").Set,n=t("debug")("number-allocator:trace"),o=t("debug")("number-allocator:error");function s(t,e){this.low=t,this.high=e}function a(t,e){if(!(this instanceof a))return new a(t,e);this.min=t,this.max=e,this.ss=new i([],((t,e)=>t.compare(e))),n("Create"),this.clear()}s.prototype.equals=function(t){return this.low===t.low&&this.high===t.high},s.prototype.compare=function(t){return this.low<t.low&&this.high<t.low?-1:t.low<this.low&&t.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return n("alloc():empty"),null;const t=this.ss.front(),e=t.low;return e+1<=t.high?++t.low:this.ss.eraseElementByPos(0),n("alloc():"+e),e},a.prototype.use=function(t){const e=new s(t,t),r=this.ss.lowerBound(e);if(r){if(r.equals(e))return this.ss.eraseElementByValue(r),n("use():"+t),!0;if(r.low>t)return!1;if(r.low===t)return++r.low,n("use():"+t),!0;if(r.high===t)return--r.high,n("use():"+t),!0;const i=r.low;return r.low=t+1,this.ss.insert(new s(i,t-1)),n("use():"+t),!0}return n("use():failed"),!1},a.prototype.free=function(t){if(t<this.min||t>this.max)return void o("free():"+t+" is out of range");const e=new s(t,t),r=this.ss.lowerBound(e);if(r){if(r.low<=t&&t<=r.high)return void o("free():"+t+" has already been vacant");if(r===this.ss.front())t+1===r.low?--r.low:this.ss.insert(e);else{const i=this.ss.reverseLowerBound(e);i.high+1===t?t+1===r.low?(this.ss.eraseElementByValue(i),r.low=i.low):i.high=t:t+1===r.low?r.low=t:this.ss.insert(e)}}else{if(r===this.ss.front())return void this.ss.insert(e);const i=this.ss.reverseLowerBound(e);i.high+1===t?i.high=t:this.ss.insert(e)}n("free():"+t)},a.prototype.clear=function(){n("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const t of this.ss)console.log(t)},e.exports=a},{debug:18,"js-sdsl":36}],48:[function(t,e,r){var i=t("wrappy");function n(t){var e=function(){return e.called?e.value:(e.called=!0,e.value=t.apply(this,arguments))};return e.called=!1,e}function o(t){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=t.apply(this,arguments)},r=t.name||"Function wrapped with `once`";return e.onceError=r+" shouldn't be called more than once",e.called=!1,e}e.exports=i(n),e.exports.strict=i(o),n.proto=n((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},{wrappy:79}],49:[function(t,e,r){(function(t){(function(){function r(e,r,i,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,r)}));case 3:return t.nextTick((function(){e.call(null,r,i)}));case 4:return t.nextTick((function(){e.call(null,r,i,n)}));default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return t.nextTick((function(){e.apply(null,o)}))}}void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:r}:e.exports=t}).call(this)}).call(this,t("_process"))},{_process:50}],50:[function(t,e,r){var i,n,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function h(t){if(i===setTimeout)return setTimeout(t,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}function u(t){if(n===clearTimeout)return clearTimeout(t);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{return n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(t){i=s}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var f,l=[],c=!1,d=-1;function p(){c&&f&&(c=!1,f.length?l=f.concat(l):d=-1,l.length&&m())}function m(){if(!c){var t=h(p);c=!0;for(var e=l.length;e;){for(f=l,l=[];++d<e;)f&&f[d].run();d=-1,e=l.length}f=null,c=!1,u(t)}}function g(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];l.push(new g(t,e)),1!==l.length||c||h(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],51:[function(t,e,r){(function(t){(function(){!function(i){var n="object"==typeof r&&r&&!r.nodeType&&r,o="object"==typeof e&&e&&!e.nodeType&&e,s="object"==typeof t&&t;s.global!==s&&s.window!==s&&s.self!==s||(i=s);var a,h,u=2147483647,f=36,l=1,c=26,d=38,p=700,m=72,g=128,y="-",b=/^xn--/,v=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=f-l,S=Math.floor,E=String.fromCharCode;function k(t){throw new RangeError(_[t])}function A(t,e){for(var r=t.length,i=[];r--;)i[r]=e(t[r]);return i}function O(t,e){var r=t.split("@"),i="";return r.length>1&&(i=r[0]+"@",t=r[1]),i+A((t=t.replace(w,".")).split("."),e).join(".")}function T(t){for(var e,r,i=[],n=0,o=t.length;n<o;)(e=t.charCodeAt(n++))>=55296&&e<=56319&&n<o?56320==(64512&(r=t.charCodeAt(n++)))?i.push(((1023&e)<<10)+(1023&r)+65536):(i.push(e),n--):i.push(e);return i}function I(t){return A(t,(function(t){var e="";return t>65535&&(e+=E((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=E(t)})).join("")}function R(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:f}function C(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function x(t,e,r){var i=0;for(t=r?S(t/p):t>>1,t+=S(t/e);t>M*c>>1;i+=f)t=S(t/M);return S(i+(M+1)*t/(t+d))}function P(t){var e,r,i,n,o,s,a,h,d,p,b=[],v=t.length,w=0,_=g,M=m;for((r=t.lastIndexOf(y))<0&&(r=0),i=0;i<r;++i)t.charCodeAt(i)>=128&&k("not-basic"),b.push(t.charCodeAt(i));for(n=r>0?r+1:0;n<v;){for(o=w,s=1,a=f;n>=v&&k("invalid-input"),((h=R(t.charCodeAt(n++)))>=f||h>S((u-w)/s))&&k("overflow"),w+=h*s,!(h<(d=a<=M?l:a>=M+c?c:a-M));a+=f)s>S(u/(p=f-d))&&k("overflow"),s*=p;M=x(w-o,e=b.length+1,0==o),S(w/e)>u-_&&k("overflow"),_+=S(w/e),w%=e,b.splice(w++,0,_)}return I(b)}function B(t){var e,r,i,n,o,s,a,h,d,p,b,v,w,_,M,A=[];for(v=(t=T(t)).length,e=g,r=0,o=m,s=0;s<v;++s)(b=t[s])<128&&A.push(E(b));for(i=n=A.length,n&&A.push(y);i<v;){for(a=u,s=0;s<v;++s)(b=t[s])>=e&&b<a&&(a=b);for(a-e>S((u-r)/(w=i+1))&&k("overflow"),r+=(a-e)*w,e=a,s=0;s<v;++s)if((b=t[s])<e&&++r>u&&k("overflow"),b==e){for(h=r,d=f;!(h<(p=d<=o?l:d>=o+c?c:d-o));d+=f)M=h-p,_=f-p,A.push(E(C(p+M%_,0))),h=S(M/_);A.push(E(C(h,0))),o=x(r,w,i==n),r=0,++i}++r,++e}return A.join("")}function N(t){return O(t,(function(t){return b.test(t)?P(t.slice(4).toLowerCase()):t}))}function L(t){return O(t,(function(t){return v.test(t)?"xn--"+B(t):t}))}if(a={version:"1.4.1",ucs2:{decode:T,encode:I},decode:P,encode:B,toASCII:L,toUnicode:N},n&&o)if(e.exports==n)o.exports=a;else for(h in a)a.hasOwnProperty(h)&&(n[h]=a[h]);else i.punycode=a}(this)}).call(this)}).call(this,void 0!==et?et:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],52:[function(t,e,r){function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,o){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var h=1e3;o&&"number"==typeof o.maxKeys&&(h=o.maxKeys);var u=t.length;h>0&&u>h&&(u=h);for(var f=0;f<u;++f){var l,c,d,p,m=t[f].replace(a,"%20"),g=m.indexOf(r);g>=0?(l=m.substr(0,g),c=m.substr(g+1)):(l=m,c=""),d=decodeURIComponent(l),p=decodeURIComponent(c),i(s,d)?n(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],53:[function(t,e,r){var i=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};e.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?o(s(t),(function(s){var a=encodeURIComponent(i(s))+r;return n(t[s])?o(t[s],(function(t){return a+encodeURIComponent(i(t))})).join(e):a+encodeURIComponent(i(t[s]))})).join(e):a?encodeURIComponent(i(a))+r+encodeURIComponent(i(t)):""};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e){if(t.map)return t.map(e);for(var r=[],i=0;i<t.length;i++)r.push(e(t[i],i));return r}var s=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},{}],54:[function(t,e,r){r.decode=r.parse=t("./decode"),r.encode=r.stringify=t("./encode")},{"./decode":52,"./encode":53}],55:[function(t,e,r){function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var n={};function o(t,e,r){function o(t,r,i){return"string"==typeof e?e:e(t,r,i)}r||(r=Error);var s=function(t){function e(e,r,i){return t.call(this,o(e,r,i))||this}return i(e,t),e}(r);s.prototype.name=r.name,s.prototype.code=t,n[t]=s}function s(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}function a(t,e,r){return t.substr(!r||r<0?0:+r,e.length)===e}function h(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}function u(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}o("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),o("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,n;if("string"==typeof e&&a(e,"not ")?(i="must not be",e=e.replace(/^not /,"")):i="must be",h(t," argument"))n="The ".concat(t," ").concat(i," ").concat(s(e,"type"));else{var o=u(t,".")?"property":"argument";n='The "'.concat(t,'" ').concat(o," ").concat(i," ").concat(s(e,"type"))}return n+=". Received type ".concat(typeof r)}),TypeError),o("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),o("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),o("ERR_STREAM_PREMATURE_CLOSE","Premature close"),o("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),o("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),o("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),o("ERR_STREAM_WRITE_AFTER_END","write after end"),o("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),o("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),o("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},{}],56:[function(t,e,r){(function(r){(function(){var i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=u;var n=t("./_stream_readable"),o=t("./_stream_writable");t("inherits")(u,n);for(var s=i(o.prototype),a=0;a<s.length;a++){var h=s[a];u.prototype[h]||(u.prototype[h]=o.prototype[h])}function u(t){if(!(this instanceof u))return new u(t);n.call(this,t),o.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",f)))}function f(){this._writableState.ended||r.nextTick(l,this)}function l(t){t.end()}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})}).call(this)}).call(this,t("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(t,e,r){e.exports=n;var i=t("./_stream_transform");function n(t){if(!(this instanceof n))return new n(t);i.call(this,t)}t("inherits")(n,i),n.prototype._transform=function(t,e,r){r(null,t)}},{"./_stream_transform":59,inherits:24}],58:[function(t,e,r){(function(r,i){(function(){var n;e.exports=T,T.ReadableState=O,t("events").EventEmitter;var o=function(t,e){return t.listeners(e).length},s=t("./internal/streams/stream"),a=t("buffer").Buffer,h=i.Uint8Array||function(){};function u(t){return a.from(t)}function f(t){return a.isBuffer(t)||t instanceof h}var l,c=t("util");l=c&&c.debuglog?c.debuglog("stream"):function(){};var d,p,m,g=t("./internal/streams/buffer_list"),y=t("./internal/streams/destroy"),b=t("./internal/streams/state").getHighWaterMark,v=t("../errors").codes,w=v.ERR_INVALID_ARG_TYPE,_=v.ERR_STREAM_PUSH_AFTER_EOF,M=v.ERR_METHOD_NOT_IMPLEMENTED,S=v.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;t("inherits")(T,s);var E=y.errorOrDestroy,k=["error","close","destroy","pause","resume"];function A(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}function O(e,r,i){n=n||t("./_stream_duplex"),e=e||{},"boolean"!=typeof i&&(i=r instanceof n),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=b(this,e,"readableHighWaterMark",i),this.buffer=new g,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=!1!==e.emitClose,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&&(d||(d=t("string_decoder/").StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function T(e){if(n=n||t("./_stream_duplex"),!(this instanceof T))return new T(e);var r=this instanceof n;this._readableState=new O(e,this,r),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function I(t,e,r,i,n){l("readableAddChunk",e);var o,s=t._readableState;if(null===e)s.reading=!1,N(t,s);else if(n||(o=C(s,e)),o)E(t,o);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===a.prototype||(e=u(e)),i)s.endEmitted?E(t,new S):R(t,s,e,!0);else if(s.ended)E(t,new _);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?R(t,s,e,!1):j(t,s)):R(t,s,e,!1)}else i||(s.reading=!1,j(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function R(t,e,r,i){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&L(t)),j(t,e)}function C(t,e){var r;return f(e)||"string"==typeof e||void 0===e||t.objectMode||(r=new w("chunk",["string","Buffer","Uint8Array"],e)),r}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(t,e){e(t)},T.prototype.push=function(t,e){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof t&&((e=e||i.defaultEncoding)!==i.encoding&&(t=a.from(t,e),e=""),r=!0),I(this,t,e,!1,r)},T.prototype.unshift=function(t){return I(this,t,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(e){d||(d=t("string_decoder/").StringDecoder);var r=new d(e);this._readableState.decoder=r,this._readableState.encoding=this._readableState.decoder.encoding;for(var i=this._readableState.buffer.head,n="";null!==i;)n+=r.write(i.data),i=i.next;return this._readableState.buffer.clear(),""!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var x=1073741824;function P(t){return t>=x?t=x:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}function B(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=P(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function N(t,e){if(l("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?L(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,D(t)))}}function L(t){var e=t._readableState;l("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(l("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(D,t))}function D(t){var e=t._readableState;l("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,V(t)}function j(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(U,t,e))}function U(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(l("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function q(t){return function(){var e=t._readableState;l("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,V(t))}}function F(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function z(t){l("readable nexttick read 0"),t.read(0)}function H(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(K,t,e))}function K(t,e){l("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),V(t),e.flowing&&!e.reading&&t.read(0)}function V(t){var e=t._readableState;for(l("flow",e.flowing);e.flowing&&null!==t.read(););}function G(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function W(t){var e=t._readableState;l("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(Z,e,t))}function Z(t,e){if(l("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function Y(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}T.prototype.read=function(t){l("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return l("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?W(this):L(this),null;if(0===(t=B(t,e))&&e.ended)return 0===e.length&&W(this),null;var i,n=e.needReadable;return l("need readable",n),(0===e.length||e.length-t<e.highWaterMark)&&l("length less than watermark",n=!0),e.ended||e.reading?l("reading or ended",n=!1):n&&(l("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=B(r,e))),null===(i=t>0?G(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&W(this)),null!==i&&this.emit("data",i),i},T.prototype._read=function(t){E(this,new M("_read()"))},T.prototype.pipe=function(t,e){var i=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,l("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===r.stdout||t===r.stderr?y:h;function a(t,e){l("onunpipe"),t===i&&e&&!1===e.hasUnpiped&&(e.hasUnpiped=!0,c())}function h(){l("onend"),t.end()}n.endEmitted?r.nextTick(s):i.once("end",s),t.on("unpipe",a);var u=q(i);t.on("drain",u);var f=!1;function c(){l("cleanup"),t.removeListener("close",m),t.removeListener("finish",g),t.removeListener("drain",u),t.removeListener("error",p),t.removeListener("unpipe",a),i.removeListener("end",h),i.removeListener("end",y),i.removeListener("data",d),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u()}function d(e){l("ondata");var r=t.write(e);l("dest.write",r),!1===r&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==Y(n.pipes,t))&&!f&&(l("false write response, pause",n.awaitDrain),n.awaitDrain++),i.pause())}function p(e){l("onerror",e),y(),t.removeListener("error",p),0===o(t,"error")&&E(t,e)}function m(){t.removeListener("finish",g),y()}function g(){l("onfinish"),t.removeListener("close",m),y()}function y(){l("unpipe"),i.unpipe(t)}return i.on("data",d),A(t,"error",p),t.once("close",m),t.once("finish",g),t.emit("pipe",i),n.flowing||(l("pipe resume"),i.resume()),t},T.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=Y(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},T.prototype.on=function(t,e){var i=s.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,l("on readable",n.length,n.reading),n.length?L(this):n.reading||r.nextTick(z,this))),i},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var i=s.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(F,this),i},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(F,this),e},T.prototype.resume=function(){var t=this._readableState;return t.flowing||(l("resume"),t.flowing=!t.readableListening,H(this,t)),t.paused=!1,this},T.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on("end",(function(){if(l("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){l("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n||(r.objectMode||n&&n.length)&&(e.push(n)||(i=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var o=0;o<k.length;o++)t.on(k[o],this.emit.bind(this,k[o]));return this._read=function(e){l("wrapped _read",e),i&&(i=!1,t.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=t("./internal/streams/async_iterator")),p(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),T._fromList=G,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(e,r){return void 0===m&&(m=t("./internal/streams/from")),m(T,e,r)})}).call(this)}).call(this,t("_process"),void 0!==et?et:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/async_iterator":61,"./internal/streams/buffer_list":62,"./internal/streams/destroy":63,"./internal/streams/from":65,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,events:22,inherits:24,"string_decoder/":75,util:16}],59:[function(t,e,r){e.exports=f;var i=t("../errors").codes,n=i.ERR_METHOD_NOT_IMPLEMENTED,o=i.ERR_MULTIPLE_CALLBACK,s=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,h=t("./_stream_duplex");function u(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function f(t){if(!(this instanceof f))return new f(t);h.call(this,t),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",l)}function l(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?c(this,null,null):this._flush((function(e,r){c(t,e,r)}))}function c(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new a;if(t._transformState.transforming)throw new s;return t.push(null)}t("inherits")(f,h),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,h.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new n("_transform()"))},f.prototype._write=function(t,e,r){var i=this._transformState;if(i.writecb=r,i.writechunk=t,i.writeencoding=e,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},f.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},f.prototype._destroy=function(t,e){h.prototype._destroy.call(this,t,(function(t){e(t)}))}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(t,e,r){(function(r,i){(function(){function n(t){var e=this;this.next=null,this.entry=null,this.finish=function(){K(e,t)}}var o;e.exports=O,O.WritableState=A;var s={deprecate:t("util-deprecate")},a=t("./internal/streams/stream"),h=t("buffer").Buffer,u=i.Uint8Array||function(){};function f(t){return h.from(t)}function l(t){return h.isBuffer(t)||t instanceof u}var c,d=t("./internal/streams/destroy"),p=t("./internal/streams/state").getHighWaterMark,m=t("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,b=m.ERR_MULTIPLE_CALLBACK,v=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,_=m.ERR_STREAM_NULL_VALUES,M=m.ERR_STREAM_WRITE_AFTER_END,S=m.ERR_UNKNOWN_ENCODING,E=d.errorOrDestroy;function k(){}function A(e,r,i){o=o||t("./_stream_duplex"),e=e||{},"boolean"!=typeof i&&(i=r instanceof o),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=p(this,e,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){N(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function O(e){var r=this instanceof(o=o||t("./_stream_duplex"));if(!r&&!c.call(O,this))return new O(e);this._writableState=new A(e,this,r),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),a.call(this)}function T(t,e){var i=new M;E(t,i),r.nextTick(e,i)}function I(t,e,i,n){var o;return null===i?o=new _:"string"==typeof i||e.objectMode||(o=new g("chunk",["string","Buffer"],i)),!o||(E(t,o),r.nextTick(n,o),!1)}function R(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,r)),e}function C(t,e,r,i,n,o){if(!r){var s=R(e,i,n);i!==s&&(r=!0,n="buffer",i=s)}var a=e.objectMode?1:i.length;e.length+=a;var h=e.length<e.highWaterMark;if(h||(e.needDrain=!0),e.writing||e.corked){var u=e.lastBufferedRequest;e.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},u?u.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else x(t,e,!1,a,i,n,o);return h}function x(t,e,r,i,n,o,s){e.writelen=i,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new w("write")):r?t._writev(n,e.onwrite):t._write(n,o,e.onwrite),e.sync=!1}function P(t,e,i,n,o){--e.pendingcb,i?(r.nextTick(o,n),r.nextTick(z,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),z(t,e))}function B(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}function N(t,e){var i=t._writableState,n=i.sync,o=i.writecb;if("function"!=typeof o)throw new b;if(B(i),e)P(t,i,n,e,o);else{var s=U(i)||t.destroyed;s||i.corked||i.bufferProcessing||!i.bufferedRequest||j(t,i),n?r.nextTick(L,t,i,s,o):L(t,i,s,o)}}function L(t,e,r,i){r||D(t,e),e.pendingcb--,i(),z(t,e)}function D(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}function j(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,o=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,h=!0;r;)o[a]=r,r.isBuf||(h=!1),r=r.next,a+=1;o.allBuffers=h,x(t,e,!0,e.length,o,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new n(e),e.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,f=r.encoding,l=r.callback;if(x(t,e,!1,e.objectMode?1:u.length,u,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function U(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function q(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),z(t,e)}))}function F(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(q,t,e)))}function z(t,e){var r=U(e);if(r&&(F(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return r}function H(t,e,i){e.ending=!0,z(t,e),i&&(e.finished?r.nextTick(i):t.once("finish",i)),e.ended=!0,t.writable=!1}function K(t,e,r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree.next=t}t("inherits")(O,a),A.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(A.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(c=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(t){return!!c.call(this,t)||this===O&&t&&t._writableState instanceof A}})):c=function(t){return t instanceof this},O.prototype.pipe=function(){E(this,new v)},O.prototype.write=function(t,e,r){var i=this._writableState,n=!1,o=!i.objectMode&&l(t);return o&&!h.isBuffer(t)&&(t=f(t)),"function"==typeof e&&(r=e,e=null),o?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=k),i.ending?T(this,r):(o||I(this,i,t,r))&&(i.pendingcb++,n=C(this,i,o,t,e,r)),n},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||j(this,t))},O.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new S(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),O.prototype._write=function(t,e,r){r(new y("_write()"))},O.prototype._writev=null,O.prototype.end=function(t,e,r){var i=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||H(this,i,r),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),O.prototype.destroy=d.destroy,O.prototype._undestroy=d.undestroy,O.prototype._destroy=function(t,e){e(t)}}).call(this)}).call(this,t("_process"),void 0!==et?et:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/destroy":63,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,inherits:24,"util-deprecate":78}],61:[function(t,e,r){(function(r){(function(){var i;function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=t("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),h=Symbol("error"),u=Symbol("ended"),f=Symbol("lastPromise"),l=Symbol("handlePromise"),c=Symbol("stream");function d(t,e){return{value:t,done:e}}function p(t){var e=t[s];if(null!==e){var r=t[c].read();null!==r&&(t[f]=null,t[s]=null,t[a]=null,e(d(r,!1)))}}function m(t){r.nextTick(p,t)}function g(t,e){return function(r,i){t.then((function(){e[u]?r(d(void 0,!0)):e[l](r,i)}),i)}}var y=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((n(i={get stream(){return this[c]},next:function(){var t=this,e=this[h];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(d(void 0,!0));if(this[c].destroyed)return new Promise((function(e,i){r.nextTick((function(){t[h]?i(t[h]):e(d(void 0,!0))}))}));var i,n=this[f];if(n)i=new Promise(g(n,this));else{var o=this[c].read();if(null!==o)return Promise.resolve(d(o,!1));i=new Promise(this[l])}return this[f]=i,i}},Symbol.asyncIterator,(function(){return this})),n(i,"return",(function(){var t=this;return new Promise((function(e,r){t[c].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),i),y),v=function(t){var e,r=Object.create(b,(n(e={},c,{value:t,writable:!0}),n(e,s,{value:null,writable:!0}),n(e,a,{value:null,writable:!0}),n(e,h,{value:null,writable:!0}),n(e,u,{value:t._readableState.endEmitted,writable:!0}),n(e,l,{value:function(t,e){var i=r[c].read();i?(r[f]=null,r[s]=null,r[a]=null,t(d(i,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[f]=null,o(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[a];return null!==e&&(r[f]=null,r[s]=null,r[a]=null,e(t)),void(r[h]=t)}var i=r[s];null!==i&&(r[f]=null,r[s]=null,r[a]=null,i(d(void 0,!0))),r[u]=!0})),t.on("readable",m.bind(null,r)),r};e.exports=v}).call(this)}).call(this,t("_process"))},{"./end-of-stream":64,_process:50}],62:[function(t,e,r){function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function n(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function h(t,e,r){return e&&a(t.prototype,e),r&&a(t,r),t}var u=t("buffer").Buffer,f=t("util").inspect,l=f&&f.custom||"inspect";function c(t,e,r){u.prototype.copy.call(t,e,r)}e.exports=function(){function t(){s(this,t),this.head=null,this.tail=null,this.length=0}return h(t,[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e=u.allocUnsafe(t>>>0),r=this.head,i=0;r;)c(r.data,e,i),i+=r.data.length,r=r.next;return e}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,i=e.data;for(t-=i.length;e=e.next;){var n=e.data,o=t>n.length?n.length:t;if(o===n.length?i+=n:i+=n.slice(0,t),0==(t-=o)){o===n.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(o));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,i=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var n=r.data,o=t>n.length?n.length:t;if(n.copy(e,e.length-t,0,o),0==(t-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,e}},{key:l,value:function(t,e){return f(this,n({},e,{depth:0,customInspect:!1}))}}]),t}()},{buffer:17,util:16}],63:[function(t,e,r){(function(t){(function(){function r(e,r){var o=this,a=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return a||h?(r?r(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,t.nextTick(s,this,e)):t.nextTick(s,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!r&&e?o._writableState?o._writableState.errorEmitted?t.nextTick(n,o):(o._writableState.errorEmitted=!0,t.nextTick(i,o,e)):t.nextTick(i,o,e):r?(t.nextTick(n,o),r(e)):t.nextTick(n,o)})),this)}function i(t,e){s(t,e),n(t)}function n(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function o(){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 s(t,e){t.emit("error",e)}function a(t,e){var r=t._readableState,i=t._writableState;r&&r.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}e.exports={destroy:r,undestroy:o,errorOrDestroy:a}}).call(this)}).call(this,t("_process"))},{_process:50}],64:[function(t,e,r){var i=t("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function n(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];t.apply(this,i)}}}function o(){}function s(t){return t.setHeader&&"function"==typeof t.abort}function a(t,e,r){if("function"==typeof e)return a(t,null,e);e||(e={}),r=n(r||o);var h=e.readable||!1!==e.readable&&t.readable,u=e.writable||!1!==e.writable&&t.writable,f=function(){t.writable||c()},l=t._writableState&&t._writableState.finished,c=function(){u=!1,l=!0,h||r.call(t)},d=t._readableState&&t._readableState.endEmitted,p=function(){h=!1,d=!0,u||r.call(t)},m=function(e){r.call(t,e)},g=function(){var e;return h&&!d?(t._readableState&&t._readableState.ended||(e=new i),r.call(t,e)):u&&!l?(t._writableState&&t._writableState.ended||(e=new i),r.call(t,e)):void 0},y=function(){t.req.on("finish",c)};return s(t)?(t.on("complete",c),t.on("abort",g),t.req?y():t.on("request",y)):u&&!t._writableState&&(t.on("end",f),t.on("close",f)),t.on("end",p),t.on("finish",c),!1!==e.error&&t.on("error",m),t.on("close",g),function(){t.removeListener("complete",c),t.removeListener("abort",g),t.removeListener("request",y),t.req&&t.req.removeListener("finish",c),t.removeListener("end",f),t.removeListener("close",f),t.removeListener("finish",c),t.removeListener("end",p),t.removeListener("error",m),t.removeListener("close",g)}}e.exports=a},{"../../../errors":55}],65:[function(t,e,r){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(t,e,r){var i;function n(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}var o=t("../../../errors").codes,s=o.ERR_MISSING_ARGS,a=o.ERR_STREAM_DESTROYED;function h(t){if(t)throw t}function u(t){return t.setHeader&&"function"==typeof t.abort}function f(e,r,o,s){s=n(s);var h=!1;e.on("close",(function(){h=!0})),void 0===i&&(i=t("./end-of-stream")),i(e,{readable:r,writable:o},(function(t){if(t)return s(t);h=!0,s()}));var f=!1;return function(t){if(!h&&!f)return f=!0,u(e)?e.abort():"function"==typeof e.destroy?e.destroy():void s(t||new a("pipe"))}}function l(t){t()}function c(t,e){return t.pipe(e)}function d(t){return t.length?"function"!=typeof t[t.length-1]?h:t.pop():h}function p(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var i,n=d(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new s("streams");var o=e.map((function(t,r){var s=r<e.length-1;return f(t,s,r>0,(function(t){i||(i=t),t&&o.forEach(l),s||(o.forEach(l),n(i))}))}));return e.reduce(c)}e.exports=p},{"../../../errors":55,"./end-of-stream":64}],67:[function(t,e,r){var i=t("../../../errors").codes.ERR_INVALID_OPT_VALUE;function n(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}function o(t,e,r,o){var s=n(e,o,r);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new i(o?r:"highWaterMark",s);return Math.floor(s)}return t.objectMode?16:16384}e.exports={getHighWaterMark:o}},{"../../../errors":55}],68:[function(t,e,r){e.exports=t("events").EventEmitter},{events:22}],69:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js"),r.finished=t("./lib/internal/streams/end-of-stream.js"),r.pipeline=t("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":56,"./lib/_stream_passthrough.js":57,"./lib/_stream_readable.js":58,"./lib/_stream_transform.js":59,"./lib/_stream_writable.js":60,"./lib/internal/streams/end-of-stream.js":64,"./lib/internal/streams/pipeline.js":66}],70:[function(t,e,r){function i(t,e,r){var i=this;this._callback=t,this._args=r,this._interval=setInterval(t,e,this._args),this.reschedule=function(t){t||(t=i._interval),i._interval&&clearInterval(i._interval),i._interval=setInterval(i._callback,t,i._args)},this.clear=function(){i._interval&&(clearInterval(i._interval),i._interval=void 0)},this.destroy=function(){i._interval&&clearInterval(i._interval),i._callback=void 0,i._interval=void 0,i._args=void 0}}function n(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var t;if(arguments.length>0){t=new Array(arguments.length-2);for(var e=0;e<t.length;e++)t[e]=arguments[e+2]}return new i(arguments[0],arguments[1],t)}e.exports=n},{}],71:[function(t,e,r){e.exports=t("./index.js")()},{"./index.js":72}],72:[function(t,e,r){(function(t){(function(){function r(e){return e instanceof t?t.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function i(t){return(t=t||{}).circles?n(t):t.proto?o:i;function e(t,e){for(var i=Object.keys(t),n=new Array(i.length),o=0;o<i.length;o++){var s=i[o],a=t[s];"object"!=typeof a||null===a?n[s]=a:a instanceof Date?n[s]=new Date(a):ArrayBuffer.isView(a)?n[s]=r(a):n[s]=e(a)}return n}function i(t){if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return e(t,i);if(t instanceof Map)return new Map(e(Array.from(t),i));if(t instanceof Set)return new Set(e(Array.from(t),i));var n={};for(var o in t)if(!1!==Object.hasOwnProperty.call(t,o)){var s=t[o];"object"!=typeof s||null===s?n[o]=s:s instanceof Date?n[o]=new Date(s):s instanceof Map?n[o]=new Map(e(Array.from(s),i)):s instanceof Set?n[o]=new Set(e(Array.from(s),i)):ArrayBuffer.isView(s)?n[o]=r(s):n[o]=i(s)}return n}function o(t){if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return e(t,o);if(t instanceof Map)return new Map(e(Array.from(t),o));if(t instanceof Set)return new Set(e(Array.from(t),o));var i={};for(var n in t){var s=t[n];"object"!=typeof s||null===s?i[n]=s:s instanceof Date?i[n]=new Date(s):s instanceof Map?i[n]=new Map(e(Array.from(s),o)):s instanceof Set?i[n]=new Set(e(Array.from(s),o)):ArrayBuffer.isView(s)?i[n]=r(s):i[n]=o(s)}return i}}function n(t){var e=[],i=[];return t.proto?s:o;function n(t,n){for(var o=Object.keys(t),s=new Array(o.length),a=0;a<o.length;a++){var h=o[a],u=t[h];if("object"!=typeof u||null===u)s[h]=u;else if(u instanceof Date)s[h]=new Date(u);else if(ArrayBuffer.isView(u))s[h]=r(u);else{var f=e.indexOf(u);s[h]=-1!==f?i[f]:n(u)}}return s}function o(t){if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return n(t,o);if(t instanceof Map)return new Map(n(Array.from(t),o));if(t instanceof Set)return new Set(n(Array.from(t),o));var s={};for(var a in e.push(t),i.push(s),t)if(!1!==Object.hasOwnProperty.call(t,a)){var h=t[a];if("object"!=typeof h||null===h)s[a]=h;else if(h instanceof Date)s[a]=new Date(h);else if(h instanceof Map)s[a]=new Map(n(Array.from(h),o));else if(h instanceof Set)s[a]=new Set(n(Array.from(h),o));else if(ArrayBuffer.isView(h))s[a]=r(h);else{var u=e.indexOf(h);s[a]=-1!==u?i[u]:o(h)}}return e.pop(),i.pop(),s}function s(t){if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return n(t,s);if(t instanceof Map)return new Map(n(Array.from(t),s));if(t instanceof Set)return new Set(n(Array.from(t),s));var o={};for(var a in e.push(t),i.push(o),t){var h=t[a];if("object"!=typeof h||null===h)o[a]=h;else if(h instanceof Date)o[a]=new Date(h);else if(h instanceof Map)o[a]=new Map(n(Array.from(h),s));else if(h instanceof Set)o[a]=new Set(n(Array.from(h),s));else if(ArrayBuffer.isView(h))o[a]=r(h);else{var u=e.indexOf(h);o[a]=-1!==u?i[u]:s(h)}}return e.pop(),i.pop(),o}}e.exports=i}).call(this)}).call(this,t("buffer").Buffer)},{buffer:17}],73:[function(t,e,r){
6
6
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
7
- var i=t("buffer"),n=i.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=i:(o(i,r),r.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},{buffer:17}],74:[function(t,e,r){function i(t){var e=t._readableState;return e?e.objectMode||"number"==typeof t._duplexState?t.read():t.read(n(e)):null}function n(t){return t.buffer.length?t.buffer.head?t.buffer.head.data.length:t.buffer[0].length:t.length}e.exports=i},{}],75:[function(t,e,r){var i=t("safe-buffer").Buffer,n=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function s(t){var e=o(t);if("string"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}function a(t){var e;switch(this.encoding=s(t),this.encoding){case"utf16le":this.text=p,this.end=m,e=4;break;case"utf8":this.fillLast=l,e=4;break;case"base64":this.text=g,this.end=y,e=3;break;default:return this.write=b,void(this.end=v)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function h(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function u(t,e,r){var i=e.length-1;if(i<r)return 0;var n=h(e[i]);return n>=0?(n>0&&(t.lastNeed=n-1),n):--i<r||-2===n?0:(n=h(e[i]))>=0?(n>0&&(t.lastNeed=n-2),n):--i<r||-2===n?0:(n=h(e[i]))>=0?(n>0&&(2===n?n=0:t.lastNeed=n-3),n):0}function f(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}function l(t){var e=this.lastTotal-this.lastNeed,r=f(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){var r=u(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)}function d(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function p(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function m(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function g(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function y(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function b(t){return t.toString(this.encoding)}function v(t){return t&&t.length?this.write(t):""}r.StringDecoder=a,a.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},a.prototype.end=d,a.prototype.text=c,a.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":73}],76:[function(t,e,r){var i=t("punycode"),n=t("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=w,r.resolve=M,r.resolveObject=S,r.format=_,r.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,h=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(u),l=["%","/","?",";","#"].concat(f),c=["/","?","#"],d=255,p=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function w(t,e,r){if(t&&n.isObject(t)&&t instanceof o)return t;var i=new o;return i.parse(t,e,r),i}function _(t){return n.isString(t)&&(t=w(t)),t instanceof o?t.format():o.prototype.format.call(t)}function M(t,e){return w(t,!1,!0).resolve(e)}function S(t,e){return t?w(t,!1,!0).resolveObject(e):e}o.prototype.parse=function(t,e,r){if(!n.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o<t.indexOf("#")?"?":"#",u=t.split(a),w=/\\/g;u[0]=u[0].replace(w,"/");var _=t=u.join(a);if(_=_.trim(),!r&&1===t.split("#").length){var M=h.exec(_);if(M)return this.path=_,this.href=_,this.pathname=M[1],M[2]?(this.search=M[2],this.query=e?v.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var S=s.exec(_);if(S){var E=(S=S[0]).toLowerCase();this.protocol=E,_=_.substr(S.length)}if(r||S||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===_.substr(0,2);!k||S&&y[S]||(_=_.substr(2),this.slashes=!0)}if(!y[S]&&(k||S&&!b[S])){for(var A,O,T=-1,I=0;I<c.length;I++)-1!==(R=_.indexOf(c[I]))&&(-1===T||R<T)&&(T=R);for(-1!==(O=-1===T?_.lastIndexOf("@"):_.lastIndexOf("@",T))&&(A=_.slice(0,O),_=_.slice(O+1),this.auth=decodeURIComponent(A)),T=-1,I=0;I<l.length;I++){var R;-1!==(R=_.indexOf(l[I]))&&(-1===T||R<T)&&(T=R)}-1===T&&(T=_.length),this.host=_.slice(0,T),_=_.slice(T),this.parseHost(),this.hostname=this.hostname||"";var C="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!C)for(var x=this.hostname.split(/\./),P=(I=0,x.length);I<P;I++){var B=x[I];if(B&&!B.match(p)){for(var N="",L=0,D=B.length;L<D;L++)B.charCodeAt(L)>127?N+="x":N+=B[L];if(!N.match(p)){var j=x.slice(0,I),U=x.slice(I+1),q=B.match(m);q&&(j.push(q[1]),U.unshift(q[2])),U.length&&(_="/"+U.join(".")+_),this.hostname=j.join(".");break}}}this.hostname.length>d?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=i.toASCII(this.hostname));var F=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+F,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[E])for(I=0,P=f.length;I<P;I++){var H=f[I];if(-1!==_.indexOf(H)){var K=encodeURIComponent(H);K===H&&(K=escape(H)),_=_.split(H).join(K)}}var V=_.indexOf("#");-1!==V&&(this.hash=_.substr(V),_=_.slice(0,V));var G=_.indexOf("?");if(-1!==G?(this.search=_.substr(G),this.query=_.substr(G+1),e&&(this.query=v.parse(this.query)),_=_.slice(0,G)):e&&(this.search="",this.query={}),_&&(this.pathname=_),b[E]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){F=this.pathname||"";var W=this.search||"";this.path=F+W}return this.href=this.format(),this},o.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",i=this.hash||"",o=!1,s="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&n.isObject(this.query)&&Object.keys(this.query).length&&(s=v.stringify(this.query));var a=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||b[e])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),i&&"#"!==i.charAt(0)&&(i="#"+i),a&&"?"!==a.charAt(0)&&(a="?"+a),e+o+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+i},o.prototype.resolve=function(t){return this.resolveObject(w(t,!1,!0)).format()},o.prototype.resolveObject=function(t){if(n.isString(t)){var e=new o;e.parse(t,!1,!0),t=e}for(var r=new o,i=Object.keys(this),s=0;s<i.length;s++){var a=i[s];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var h=Object.keys(t),u=0;u<h.length;u++){var f=h[u];"protocol"!==f&&(r[f]=t[f])}return b[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!b[t.protocol]){for(var l=Object.keys(t),c=0;c<l.length;c++){var d=l[c];r[d]=t[d]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||y[t.protocol])r.pathname=t.pathname;else{for(var p=(t.pathname||"").split("/");p.length&&!(t.host=p.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),r.pathname=p.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var m=r.pathname||"",g=r.search||"";r.path=m+g}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),w=t.host||t.pathname&&"/"===t.pathname.charAt(0),_=w||v||r.host&&t.pathname,M=_,S=r.pathname&&r.pathname.split("/")||[],E=(p=t.pathname&&t.pathname.split("/")||[],r.protocol&&!b[r.protocol]);if(E&&(r.hostname="",r.port=null,r.host&&(""===S[0]?S[0]=r.host:S.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===p[0]?p[0]=t.host:p.unshift(t.host)),t.host=null),_=_&&(""===p[0]||""===S[0])),w)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,S=p;else if(p.length)S||(S=[]),S.pop(),S=S.concat(p),r.search=t.search,r.query=t.query;else if(!n.isNullOrUndefined(t.search))return E&&(r.hostname=r.host=S.shift(),(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),r.search=t.search,r.query=t.query,n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=S.slice(-1)[0],A=(r.host||t.host||S.length>1)&&("."===k||".."===k)||""===k,O=0,T=S.length;T>=0;T--)"."===(k=S[T])?S.splice(T,1):".."===k?(S.splice(T,1),O++):O&&(S.splice(T,1),O--);if(!_&&!M)for(;O--;O)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),A&&"/"!==S.join("/").substr(-1)&&S.push("");var I,R=""===S[0]||S[0]&&"/"===S[0].charAt(0);return E&&(r.hostname=r.host=R?"":S.length?S.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),(_=_||r.host&&S.length)&&!R&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":77,punycode:51,querystring:54}],77:[function(t,e,r){e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],78:[function(t,e,r){(function(t){(function(){function r(t,e){if(i("noDeprecation"))return t;var r=!1;function n(){if(!r){if(i("throwDeprecation"))throw new Error(e);i("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return n}function i(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=r}).call(this)}).call(this,void 0!==et?et:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(t,e,r){function i(t,e){if(t&&e)return i(t)(e);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var i=t.apply(this,e),n=e[e.length-1];return"function"==typeof i&&i!==n&&Object.keys(n).forEach((function(t){i[t]=n[t]})),i}}e.exports=i},{}],80:[function(t,e,r){e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(t,e,r){e.exports=n;var i=Object.prototype.hasOwnProperty;function n(){for(var t={},e=0;e<arguments.length;e++){var r=arguments[e];for(var n in r)i.call(r,n)&&(t[n]=r[n])}return t}},{}],82:[function(t,e,r){e.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},{}],83:[function(t,e,r){function i(t){var e=this;if(e instanceof i||(e=new i),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)e.push(arguments[r]);return e}function n(t,e,r){var i=e===t.head?new a(r,null,e,t):new a(r,e,e.next,t);return null===i.next&&(t.tail=i),null===i.prev&&(t.head=i),t.length++,i}function o(t,e){t.tail=new a(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function s(t,e){t.head=new a(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function a(t,e,r,i){if(!(this instanceof a))return new a(t,e,r,i);this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=i,i.Node=a,i.create=i,i.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e},i.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}},i.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}},i.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)o(this,arguments[t]);return this.length},i.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)s(this,arguments[t]);return this.length},i.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}},i.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}},i.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,i=0;null!==r;i++)t.call(e,r.value,i,this),r=r.next},i.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,i=this.length-1;null!==r;i--)t.call(e,r.value,i,this),r=r.prev},i.prototype.get=function(t){for(var e=0,r=this.head;null!==r&&e<t;e++)r=r.next;if(e===t&&null!==r)return r.value},i.prototype.getReverse=function(t){for(var e=0,r=this.tail;null!==r&&e<t;e++)r=r.prev;if(e===t&&null!==r)return r.value},i.prototype.map=function(t,e){e=e||this;for(var r=new i,n=this.head;null!==n;)r.push(t.call(e,n.value,this)),n=n.next;return r},i.prototype.mapReverse=function(t,e){e=e||this;for(var r=new i,n=this.tail;null!==n;)r.push(t.call(e,n.value,this)),n=n.prev;return r},i.prototype.reduce=function(t,e){var r,i=this.head;if(arguments.length>1)r=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,r=this.head.value}for(var n=0;null!==i;n++)r=t(r,i.value,n),i=i.next;return r},i.prototype.reduceReverse=function(t,e){var r,i=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==i;n--)r=t(r,i.value,n),i=i.prev;return r},i.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},i.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},i.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new i;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=0,o=this.head;null!==o&&n<t;n++)o=o.next;for(;null!==o&&n<e;n++,o=o.next)r.push(o.value);return r},i.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new i;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=this.length,o=this.tail;null!==o&&n>e;n--)o=o.prev;for(;null!==o&&n>t;n--,o=o.prev)r.push(o.value);return r},i.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var i=0,o=this.head;null!==o&&i<t;i++)o=o.next;var s=[];for(i=0;o&&i<e;i++)s.push(o.value),o=this.removeNode(o);for(null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev),i=0;i<r.length;i++)o=n(this,o,r[i]);return s},i.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;null!==r;r=r.prev){var i=r.prev;r.prev=r.next,r.next=i}return this.head=e,this.tail=t,this};try{t("./iterator.js")(i)}catch(t){}},{"./iterator.js":82}]},{},[12])(12);var AO=rt(EO);const OO=Object.create(null);OO.open="0",OO.close="1",OO.ping="2",OO.pong="3",OO.message="4",OO.upgrade="5",OO.noop="6";const TO=Object.create(null);Object.keys(OO).forEach((t=>{TO[OO[t]]=t}));const IO={type:"error",data:"parser error"},RO="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),CO="function"==typeof ArrayBuffer,xO=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,PO=({type:t,data:e},r,i)=>RO&&e instanceof Blob?r?i(e):BO(e,i):CO&&(e instanceof ArrayBuffer||xO(e))?r?i(e):BO(new Blob([e]),i):i(OO[t]+(e||"")),BO=(t,e)=>{const r=new FileReader;return r.onload=function(){const t=r.result.split(",")[1];e("b"+(t||""))},r.readAsDataURL(t)};function NO(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let LO;const DO="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",jO="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)jO[DO.charCodeAt(t)]=t;const UO="function"==typeof ArrayBuffer,qO=(t,e)=>{if("string"!=typeof t)return{type:"message",data:zO(t,e)};const r=t.charAt(0);if("b"===r)return{type:"message",data:FO(t.substring(1),e)};return TO[r]?t.length>1?{type:TO[r],data:t.substring(1)}:{type:TO[r]}:IO},FO=(t,e)=>{if(UO){const r=(t=>{let e,r,i,n,o,s=.75*t.length,a=t.length,h=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);const u=new ArrayBuffer(s),f=new Uint8Array(u);for(e=0;e<a;e+=4)r=jO[t.charCodeAt(e)],i=jO[t.charCodeAt(e+1)],n=jO[t.charCodeAt(e+2)],o=jO[t.charCodeAt(e+3)],f[h++]=r<<2|i>>4,f[h++]=(15&i)<<4|n>>2,f[h++]=(3&n)<<6|63&o;return u})(t);return zO(r,e)}return{base64:!0,data:t}},zO=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,HO=String.fromCharCode(30);function KO(){return new TransformStream({transform(t,e){!function(t,e){RO&&t.data instanceof Blob?t.data.arrayBuffer().then(NO).then(e):CO&&(t.data instanceof ArrayBuffer||xO(t.data))?e(NO(t.data)):PO(t,!1,(t=>{LO||(LO=new TextEncoder),e(LO.encode(t))}))}(t,(r=>{const i=r.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const t=new DataView(n.buffer);t.setUint8(0,126),t.setUint16(1,i)}else{n=new Uint8Array(9);const t=new DataView(n.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(i))}t.data&&"string"!=typeof t.data&&(n[0]|=128),e.enqueue(n),e.enqueue(r)}))}})}let VO;function GO(t){return t.reduce(((t,e)=>t+e.length),0)}function WO(t,e){if(t[0].length===e)return t.shift();const r=new Uint8Array(e);let i=0;for(let n=0;n<e;n++)r[n]=t[0][i++],i===t[0].length&&(t.shift(),i=0);return t.length&&i<t[0].length&&(t[0]=t[0].slice(i)),r}function ZO(t){if(t)return function(t){for(var e in ZO.prototype)t[e]=ZO.prototype[e];return t}(t)}ZO.prototype.on=ZO.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},ZO.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},ZO.prototype.off=ZO.prototype.removeListener=ZO.prototype.removeAllListeners=ZO.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,i=this._callbacks["$"+t];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n=0;n<i.length;n++)if((r=i[n])===e||r.fn===e){i.splice(n,1);break}return 0===i.length&&delete this._callbacks["$"+t],this},ZO.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(r){i=0;for(var n=(r=r.slice(0)).length;i<n;++i)r[i].apply(this,e)}return this},ZO.prototype.emitReserved=ZO.prototype.emit,ZO.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},ZO.prototype.hasListeners=function(t){return!!this.listeners(t).length};const YO="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function XO(t,...e){return e.reduce(((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e)),{})}const JO=YO.setTimeout,QO=YO.clearTimeout;function $O(t,e){e.useNativeTimers?(t.setTimeoutFn=JO.bind(YO),t.clearTimeoutFn=QO.bind(YO)):(t.setTimeoutFn=YO.setTimeout.bind(YO),t.clearTimeoutFn=YO.clearTimeout.bind(YO))}class tT extends Error{constructor(t,e,r){super(t),this.description=e,this.context=r,this.type="TransportError"}}class eT extends ZO{constructor(t){super(),this.writable=!1,$O(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,r){return super.emitReserved("error",new tT(t,e,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=qO(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}(t);return e.length?"?"+e:""}}const rT="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),iT=64,nT={};let oT,sT=0,aT=0;function hT(t){let e="";do{e=rT[t%iT]+e,t=Math.floor(t/iT)}while(t>0);return e}function uT(){const t=hT(+new Date);return t!==oT?(sT=0,oT=t):t+"."+hT(sT++)}for(;aT<iT;aT++)nT[rT[aT]]=aT;let fT=!1;try{fT="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const lT=fT;function cT(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||lT))return new XMLHttpRequest}catch(t){}if(!e)try{return new(YO[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function dT(){}const pT=null!=new cT({xdomain:!1}).responseType;class mT extends ZO{constructor(t,e){super(),$O(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=void 0!==e.data?e.data:null,this.create()}create(){var t;const e=XO(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd;const r=this.xhr=new cT(e);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&r.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(t){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{r.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this.opts.cookieJar)||void 0===t||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var t;3===r.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=mT.requestsCount++,mT.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=dT,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete mT.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(mT.requestsCount=0,mT.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",gT);else if("function"==typeof addEventListener){addEventListener("onpagehide"in YO?"pagehide":"unload",gT,!1)}function gT(){for(let t in mT.requests)mT.requests.hasOwnProperty(t)&&mT.requests[t].abort()}const yT="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),bT=YO.WebSocket||YO.MozWebSocket,vT="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const wT={websocket:class extends eT{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,r=vT?{}:XO(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=vT?new bT(t,e,r):e?new bT(t,e):new bT(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;PO(r,this.supportsBinary,(t=>{try{this.ws.send(t)}catch(t){}i&&yT((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=uT()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!bT}},webtransport:class extends eT{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){VO||(VO=new TextDecoder);const r=[];let i=0,n=-1,o=!1;return new TransformStream({transform(s,a){for(r.push(s);;){if(0===i){if(GO(r)<1)break;const t=WO(r,1);o=128==(128&t[0]),n=127&t[0],i=n<126?3:126===n?1:2}else if(1===i){if(GO(r)<2)break;const t=WO(r,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),i=3}else if(2===i){if(GO(r)<8)break;const t=WO(r,8),e=new DataView(t.buffer,t.byteOffset,t.length),o=e.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(IO);break}n=o*Math.pow(2,32)+e.getUint32(4),i=3}else{if(GO(r)<n)break;const t=WO(r,n);a.enqueue(qO(o?t:VO.decode(t),e)),i=0}if(0===n||n>t){a.enqueue(IO);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(e).getReader(),i=KO();i.readable.pipeTo(t.writable),this.writer=i.writable.getWriter();const n=()=>{r.read().then((({done:t,value:e})=>{t||(this.onPacket(e),n())})).catch((t=>{}))};n();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;this.writer.write(r).then((()=>{i&&yT((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends eT{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let r=location.port;r||(r=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||r!==t.port}const e=t&&t.forceBase64;this.supportsBinary=pT&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const r=t.split(HO),i=[];for(let t=0;t<r.length;t++){const n=qO(r[t],e);if(i.push(n),"error"===n.type)break}return i})(t,this.socket.binaryType).forEach((t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const r=t.length,i=new Array(r);let n=0;t.forEach(((t,o)=>{PO(t,!1,(t=>{i[o]=t,++n===r&&e(i.join(HO))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=uT()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new mT(this.uri(),t)}doWrite(t,e){const r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},_T=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,MT=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ST(t){const e=t,r=t.indexOf("["),i=t.indexOf("]");-1!=r&&-1!=i&&(t=t.substring(0,r)+t.substring(r,i).replace(/:/g,";")+t.substring(i,t.length));let n=_T.exec(t||""),o={},s=14;for(;s--;)o[MT[s]]=n[s]||"";return-1!=r&&-1!=i&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(t,e){const r=/\/{2,9}/g,i=e.replace(r,"/").split("/");"/"!=e.slice(0,1)&&0!==e.length||i.splice(0,1);"/"==e.slice(-1)&&i.splice(i.length-1,1);return i}(0,o.path),o.queryKey=function(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,i){e&&(r[e]=i)})),r}(0,o.query),o}let ET=class t extends ZO{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=ST(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=ST(e.host).host),$O(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},r=t.split("&");for(let t=0,i=r.length;t<i;t++){let i=r[t].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const r=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new wT[t](r)}open(){let e;if(this.opts.rememberUpgrade&&t.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(t){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(e){let r=this.createTransport(e),i=!1;t.priorWebsocketSuccess=!1;const n=()=>{i||(r.send([{type:"ping",data:"probe"}]),r.once("packet",(e=>{if(!i)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;t.priorWebsocketSuccess="websocket"===r.name,this.transport.pause((()=>{i||"closed"!==this.readyState&&(f(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=r.name,this.emitReserved("upgradeError",t)}})))};function o(){i||(i=!0,f(),r.close(),r=null)}const s=t=>{const e=new Error("probe error: "+t);e.transport=r.name,o(),this.emitReserved("upgradeError",e)};function a(){s("transport closed")}function h(){s("socket closed")}function u(t){r&&t.name!==r.name&&o()}const f=()=>{r.removeListener("open",n),r.removeListener("error",s),r.removeListener("close",a),this.off("close",h),this.off("upgrading",u)};r.once("open",n),r.once("error",s),r.once("close",a),this.once("close",h),this.once("upgrading",u),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{i||r.open()}),200):r.open()}onOpen(){if(this.readyState="open",t.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(t+="string"==typeof(e=i)?function(t){let e=0,r=0;for(let i=0,n=t.length;i<n;i++)e=t.charCodeAt(i),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(i++,r+=4);return r}(e):Math.ceil(1.33*(e.byteLength||e.size))),r>0&&t>this.maxPayload)return this.writeBuffer.slice(0,r);t+=2}var e;return this.writeBuffer}write(t,e,r){return this.sendPacket("message",t,e,r),this}send(t,e,r){return this.sendPacket("message",t,e,r),this}sendPacket(t,e,r,i){if("function"==typeof e&&(i=e,e=void 0),"function"==typeof r&&(i=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const n={type:t,data:e,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},r=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():t()})):this.upgrading?r():t()),this}onError(e){t.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let r=0;const i=t.length;for(;r<i;r++)~this.transports.indexOf(t[r])&&e.push(t[r]);return e}};ET.protocol=4;const kT="function"==typeof ArrayBuffer,AT=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,OT=Object.prototype.toString,TT="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===OT.call(Blob),IT="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===OT.call(File);function RT(t){return kT&&(t instanceof ArrayBuffer||AT(t))||TT&&t instanceof Blob||IT&&t instanceof File}function CT(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,r=t.length;e<r;e++)if(CT(t[e]))return!0;return!1}if(RT(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return CT(t.toJSON(),!0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&CT(t[e]))return!0;return!1}function xT(t){const e=[],r=t.data,i=t;return i.data=PT(r,e),i.attachments=e.length,{packet:i,buffers:e}}function PT(t,e){if(!t)return t;if(RT(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}if(Array.isArray(t)){const r=new Array(t.length);for(let i=0;i<t.length;i++)r[i]=PT(t[i],e);return r}if("object"==typeof t&&!(t instanceof Date)){const r={};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=PT(t[i],e));return r}return t}function BT(t,e){return t.data=NT(t.data,e),delete t.attachments,t}function NT(t,e){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=NT(t[r],e);else if("object"==typeof t)for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=NT(t[r],e));return t}const LT=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var DT;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(DT||(DT={}));function jT(t){return"[object Object]"===Object.prototype.toString.call(t)}class UT extends ZO{constructor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const r=e.type===DT.BINARY_EVENT;r||e.type===DT.BINARY_ACK?(e.type=r?DT.EVENT:DT.ACK,this.reconstructor=new qT(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!RT(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===DT[r.type])throw new Error("unknown packet type "+r.type);if(r.type===DT.BINARY_EVENT||r.type===DT.BINARY_ACK){const i=e+1;for(;"-"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(i,e);if(n!=Number(n)||"-"!==t.charAt(e))throw new Error("Illegal attachments");r.attachments=Number(n)}if("/"===t.charAt(e+1)){const i=e+1;for(;++e;){if(","===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(i,e)}else r.nsp="/";const i=t.charAt(e+1);if(""!==i&&Number(i)==i){const i=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(i,e+1))}if(t.charAt(++e)){const i=this.tryParse(t.substr(e));if(!UT.isPayloadValid(r.type,i))throw new Error("invalid payload");r.data=i}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(t){return!1}}static isPayloadValid(t,e){switch(t){case DT.CONNECT:return jT(e);case DT.DISCONNECT:return void 0===e;case DT.CONNECT_ERROR:return"string"==typeof e||jT(e);case DT.EVENT:case DT.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===LT.indexOf(e[0]));case DT.ACK:case DT.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class qT{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=BT(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var FT=Object.freeze({__proto__:null,Decoder:UT,Encoder:class{constructor(t){this.replacer=t}encode(t){return t.type!==DT.EVENT&&t.type!==DT.ACK||!CT(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===DT.EVENT?DT.BINARY_EVENT:DT.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==DT.BINARY_EVENT&&t.type!==DT.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=xT(t),r=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(r),i}},get PacketType(){return DT},protocol:5});function zT(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const HT=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class KT extends ZO{constructor(t,e,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[zT(t,"open",this.onopen.bind(this)),zT(t,"packet",this.onpacket.bind(this)),zT(t,"error",this.onerror.bind(this)),zT(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(HT.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const r={type:DT.EVENT,data:e,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,i=e.pop();this._registerAckCallback(t,i),r.id=t}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(t,e){var r;const i=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===i)return void(this.acks[t]=e);const n=this.io.setTimeoutFn((()=>{delete this.acks[t];for(let e=0;e<this.sendBuffer.length;e++)this.sendBuffer[e].id===t&&this.sendBuffer.splice(e,1);e.call(this,new Error("operation has timed out"))}),i);this.acks[t]=(...t)=>{this.io.clearTimeoutFn(n),e.apply(this,[null,...t])}}emitWithAck(t,...e){const r=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((i,n)=>{e.push(((t,e)=>r?t?n(t):i(e):i(t))),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...i)=>{if(r!==this._queue[0])return;return null!==t?r.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...i)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:DT.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case DT.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case DT.EVENT:case DT.BINARY_EVENT:this.onevent(t);break;case DT.ACK:case DT.BINARY_ACK:this.onack(t);break;case DT.DISCONNECT:this.ondisconnect();break;case DT.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const r of e)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let r=!1;return function(...i){r||(r=!0,e.packet({type:DT.ACK,id:t,data:i}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:DT.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const r of e)r.apply(this,t.data)}}}function VT(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}VT.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-r:t+r}return 0|Math.min(t,this.max)},VT.prototype.reset=function(){this.attempts=0},VT.prototype.setMin=function(t){this.ms=t},VT.prototype.setMax=function(t){this.max=t},VT.prototype.setJitter=function(t){this.jitter=t};class GT extends ZO{constructor(t,e){var r;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,$O(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=e.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new VT({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const i=e.parser||FT;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new ET(this.uri,this.opts);const e=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=zT(e,"open",(function(){r.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},o=zT(e,"error",n);if(!1!==this._timeout){const t=this._timeout,r=this.setTimeoutFn((()=>{i(),n(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(i),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(zT(t,"ping",this.onping.bind(this)),zT(t,"data",this.ondata.bind(this)),zT(t,"error",this.onerror.bind(this)),zT(t,"close",this.onclose.bind(this)),zT(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){yT((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new KT(this,t,e),this.nsps[t]=r),r}_destroy(t){const e=Object.keys(this.nsps);for(const t of e){if(this.nsps[t].active)return}this._close()}_packet(t){const e=this.encoder.encode(t);for(let r=0;r<e.length;r++)this.engine.write(e[r],t.options)}cleanup(){this.subs.forEach((t=>t())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const WT={};function ZT(t,e){"object"==typeof t&&(e=t,t=void 0);const r=function(t,e="",r){let i=t;r=r||"undefined"!=typeof location&&location,null==t&&(t=r.protocol+"//"+r.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?r.protocol+t:r.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==r?r.protocol+"//"+t:"https://"+t),i=ST(t)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const n=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+n+":"+i.port+e,i.href=i.protocol+"://"+n+(r&&r.port===i.port?"":":"+i.port),i}(t,(e=e||{}).path||"/socket.io"),i=r.source,n=r.id,o=r.path,s=WT[n]&&o in WT[n].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||s?a=new GT(i,e):(WT[n]||(WT[n]=new GT(i,e)),a=WT[n]),r.query&&!e.query&&(e.query=r.queryKey),a.socket(r.path,e)}Object.assign(ZT,{Manager:GT,Socket:KT,io:ZT,connect:ZT});class YT{constructor(t,e){this.method="GET",this.protocol="HTTPS",this.body=null,this.interval=0,this.timeout=1e4,this.responseType="",this.filteredData=null,this.XHR=void 0,this.isInterval=!1,this.successCallback=void 0,this.errorCallback=void 0,this.statusCallback=void 0,this.onTimeout=()=>{this.XHR&&(this.onErrorCallback(new Error("Error: timeout")),this.circulateRequest())},this.onLoad=()=>{if(this.XHR){if(this.responseData=this.toObject(this.XHR.response),4!==this.XHR.readyState||200!=this.XHR.status&&304!=this.XHR.status)this.onErrorCallback(new Error(this.XHR.statusText));else{try{this.filteredData=this.filter?this.filter(this.responseData):this.responseData}catch(t){this.filteredData=void 0,console.error(t)}this.onSuccessCallback(this.responseData,this.filteredData)}this.circulateRequest()}},this.onError=()=>{this.XHR&&this.onErrorCallback(new Error(this.XHR.statusText))},this.url=t,e&&(this.option=e,this.method=e.method?e.method.toUpperCase():"GET",this.protocol=e.protocol?e.protocol.toUpperCase():"HTTPS",this.headers=e.headers?e.headers:void 0,this.params=e.params?e.params:void 0,this.body=e.body?e.body:null,this.interval=void 0!==e.interval?e.interval:0,this.timeout=e.timeout?e.timeout:1e4,this.responseType=void 0!==e.responseType?e.responseType:"",e.filter&&(this.filter="function"==typeof e.filter?e.filter:new Function("response",e.filter)))}get getUrl(){return this.url}get getOption(){return Object.assign(Object.assign({},this.option),{url:this.url})}get getStatus(){var t;return null===(t=this.XHR)||void 0===t?void 0:t.status}get getRequesting(){return this.isInterval&&0!==this.interval}get getResponseData(){return this.responseData}get getFilterData(){return this.filteredData}send(){this.isInterval=!0,this.request()}abort(){this.isInterval=!1}onceSend(){this.request()}listen(t,e){this.successCallback=t,e&&(this.errorCallback=e)}on(t,e){switch(t){case"onSuccess":this.successCallback=e;break;case"onError":this.errorCallback=e;break;case"onStatus":this.statusCallback=e}}onStatusCallback(t,e){this.statusCallback&&this.statusCallback(t,e)}onErrorCallback(t){this.errorCallback&&this.errorCallback(t),this.onStatusCallback("error",t)}onSuccessCallback(t,e){this.successCallback&&this.successCallback(t,e),this.onStatusCallback("success")}request(){try{if(this.onStatusCallback("connect"),this.XHR||(this.XHR=new XMLHttpRequest),this.XHR.open(this.method,this.paramsUrl()),this.XHR.responseType=this.responseType,this.XHR.timeout=this.timeout,this.XHR.onload=this.onLoad,this.XHR.onerror=this.onError,this.XHR.ontimeout=this.onTimeout,this.headers)for(const t in this.headers)Object.prototype.hasOwnProperty.call(this.headers,t)&&"multipart/form-data"!==this.headers[t]&&this.XHR.setRequestHeader(t,this.headers[t]);this.XHR.send(this.body)}catch(t){console.error(t),this.onErrorCallback(t)}}circulateRequest(){if(this.getRequesting){const t=setTimeout((()=>{this.request(),clearTimeout(t)}),this.interval)}else this.isInterval&&(this.isInterval=!1)}paramsUrl(){let t=this.url+"?";if(this.params)for(const e in this.params)Object.prototype.hasOwnProperty.call(this.params,e)&&(t+=encodeURIComponent(e)+"="+encodeURIComponent(this.params[e])+"&");return t.slice(0,-1)}toObject(t){if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}}}var XT,JT,QT,$T,tI,eI,rI,iI,nI,oI,sI,aI,hI,uI,fI,lI,cI,dI,pI,mI,gI;function yI(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}function bI(t){let e=t.protocolValue+t.url;return t.port&&(e+=":"+t.port),e}function vI(t,e,r=!1,i,n,o){try{if(!e)return t;let n="";r&&yI(t)&&(n=`const { ${Object.keys(t).join(",")} } = response;`);const a=new Function("response",n+e)(t),h=i?function(t){return"number"==typeof t}(s=a)?`${s}`:yI(s)?JSON.stringify(s,null,2):s:a;return o&&o(h),h}catch(t){return n&&n(t),t}var s}function wI(t,e){if(t.protocol!==JT.HTTP)return;const r=t.configureJson,i=function(t,e){switch(e){case eI.SECOND:return 1e3*t;case eI.MINUTE:return 1e3*t*60;case eI.HOUR:return 1e3*t*60*60;case eI.DAY:return 1e3*t*60*60*24;default:return 1e3*t}}(r.interval,r.unit),n=Object.assign(e[XT.HEADERS],t[XT.HEADERS]);let o=null;const s=r.params,a=new FormData;switch(a.set("default","defaultData"),r.bodyType){case $T.NONE:break;case $T.JSON:n["Content-Type"]=rI.JSON,o=r.body.json;break;case $T.XML:n["Content-Type"]=rI.XML,o=r.body.xml;break;case $T.X_WWW_FORM_URLENCODED:n["Content-Type"]=rI.FORM_URLENCODED;o=function(t){const e=new URLSearchParams;for(const r in t)Object.prototype.hasOwnProperty.call(t,"key")&&e.append(r,t[r]);return e.toString()}(r.body["x-www-form-urlencoded"]);break;case $T.FORM_DATA:{n["Content-Type"]=rI.FORM_DATA;const t=r.body["form-data"];for(const e in t)a.set(e,t[e]);o=a;break}}return{params:s,headers:n,interval:i,body:o,method:r.method,filter:r.filter,protocol:e.protocol}}function _I(t,e,r,i){const n=(t,e)=>{r({status:t,message:e})};e.on("reconnect",(()=>{n(iI.CONNECT)})),e.on("close",(t=>{const e=t||new Error("连接关闭");n(iI.CLOSE,e)})),e.on("error",(t=>{n(iI.ERROR,t)})),e.on("message",((r,n,o)=>{i({api:t,client:e,data:{topic:r,payload:n,packet:o}})})),e.on("connect",(r=>{if(0===r.returnCode)n(iI.SUCCESS,r),function(t,e){const r=t.configureJson,i=r.subscription;if(0==i.length)return;const n={};i.forEach((t=>{t.topic&&(n[t.topic]={qos:t.qos})})),Object.keys(n).length>0&&e.subscribe(n,(t=>{t&&console.error(t)}))}(t,e);else{const t=void 0!==r.returnCode?String(r.returnCode):r.cmd;e.emit("close",new Error(t))}}))}function MI(t,e,r,i){const n=bI(e),o=function(t){if(t.protocol!==JT.MQTT)return;const e=t.configureJson,{baseConfig:r,willMessage:i}=e,n={clientId:r.clientId,keepalive:r.keepAlive,protocolVersion:Number(r.version),protocolId:"MQTT",reconnectPeriod:0};return i&&i.topic&&(n.will={topic:i.topic,payload:i.message||"",qos:i.qos,retain:i.retain}),r.username&&(n.username=r.username),r.password&&(n.password=r.password),n}(t),s=AO.connect(n+(t.url||""),o),a=t.configureJson,{successCallback:h,errorCallback:u}=a;return _I(t,s,(({status:e,message:i})=>{const n=e!==iI.CONNECT?i:void 0;r({api:t,client:s,status:e,message:n}),e===iI.CONNECT&&h?vI({connect:i,client:s},h,!0):e!==iI.ERROR&&e!==iI.CLOSE||!u||vI({error:i,client:s},u,!0)}),i),s}function SI(t,e,r,i){let n=bI(e);const o=function(t,e){if(t.protocol!==JT.WEBSOCKET)return;const r=t.configureJson,i=Object.assign(e[XT.HEADERS],t[XT.HEADERS]),{subProtocols:n,query:o}=r,s=n?n.split(","):["websocket","polling"];return{reconnection:!1,reconnectionAttempts:0,path:t.url,query:o,transports:s,extraHeaders:i,withCredentials:!0}}(t,e),s=t.configureJson,{successCallback:a,errorCallback:h,nameSpace:u}=s;u&&(n+=(/^\/.*/.test(u)?"":"/")+u);const f=ZT(n,o);return function(t,e,r,i){const n=t.configureJson,{eventList:o}=n;e.on("connect",(()=>{r(iI.SUCCESS)})),e.on("disconnect",(t=>{r(iI.CLOSE,new Error(t))})),e.on("connect_error",(t=>{r(iI.ERROR,t)})),e.on("reconnect",(()=>{r(iI.CONNECT)})),e.on("reconnect_error",(t=>{r(iI.ERROR,t)})),e.on("reconnect_failed",(t=>{r(iI.ERROR,t||new Error("reconnect_failed"))}));for(let r=0;r<o.length;r++){const n=o[r];e.on(n.event,((...r)=>{i({api:t,client:e,data:{message:r,event:n.event}})}))}}(t,f,((e,i)=>{r({status:e,api:t,client:f,message:i}),e===iI.SUCCESS&&a?vI({socket:f},a,!0):e!==iI.ERROR&&e!==iI.CLOSE||!h||vI({error:i,socket:f},h,!0)}),i),f.connect(),f}!function(t){t.PARAMS="params",t.BODY="body",t.HEADERS="headers"}(XT||(XT={})),function(t){t.HTTP="HTTP",t.MQTT="MQTT",t.WEBSOCKET="WebSocket"}(JT||(JT={})),function(t){t.HTTPS="https://",t.HTTP="http://",t.MQTTS="wss://",t.MQTT="ws://",t.WSS="wss://",t.WS="ws://"}(QT||(QT={})),function(t){t.NONE="none",t.FORM_DATA="form-data",t.X_WWW_FORM_URLENCODED="x-www-form-urlencoded",t.JSON="json",t.XML="xml"}($T||($T={})),function(t){t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.OPTIONS="OPTIONS",t.DELETE="DELETE"}(tI||(tI={})),function(t){t.SECOND="second",t.MINUTE="minute",t.HOUR="hour",t.DAY="day"}(eI||(eI={})),JT.HTTP,JT.HTTP,JT.MQTT,JT.MQTT,JT.WEBSOCKET,JT.WEBSOCKET,function(t){t.JSON="application/json;charset=UTF-8",t.TEXT="text/plain;charset=UTF-8",t.XML="application/xml;charset=UTF-8",t.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",t.FORM_DATA="multipart/form-data"}(rI||(rI={})),function(t){t.SUCCESS="success",t.ERROR="error",t.CONNECT="connect",t.CLOSE="close"}(iI||(iI={}));class EI{constructor(t,e){this.sourceEnv=t,this.sourceApi=e,nI.add(this),oI.set(this,{}),sI.set(this,void 0),aI.set(this,void 0),W(this,nI,"m",hI).call(this)}on(t,e){"onStatus"===t?Z(this,sI,e,"f"):"onMessage"===t&&Z(this,aI,e,"f")}getClientById(t){return W(this,oI,"f")[t]}requestAll(){const t=this.sourceApi;t&&t.length>0&&W(this,nI,"m",cI).call(this,t)}requestById(t){const e=this.sourceApi.filter((e=>t.some((t=>t===e.id))));e&&e.length>0&&W(this,nI,"m",cI).call(this,e)}closeAll(){for(const t in W(this,oI,"f"))if(Object.prototype.hasOwnProperty.call(W(this,oI,"f"),t)){const e=W(this,oI,"f")[t];W(this,nI,"m",lI).call(this,e)}}closeById(t){for(let e=0;e<t.length;e++){const r=t[e],i=W(this,oI,"f")[r];W(this,nI,"m",lI).call(this,i)}}}oI=new WeakMap,sI=new WeakMap,aI=new WeakMap,nI=new WeakSet,hI=function(){Z(this,oI,{},"f")},uI=function(t){console.log("onStatus",t),W(this,sI,"f")&&W(this,sI,"f").call(this,t)},fI=function(t){console.log("onMessage",t),W(this,aI,"f")&&W(this,aI,"f").call(this,t)},lI=function(t){t instanceof YT?t.abort():t instanceof KT?t.close():t instanceof EO.MqttClient&&t.end()},cI=function(t){for(let e=0;e<t.length;e++){const r=t[e],i=W(this,nI,"m",gI).call(this,r.sid);if(r.nodeArray&&r.nodeArray.length>0&&i)switch(r.protocol){case JT.HTTP:W(this,nI,"m",dI).call(this,r,i);break;case JT.MQTT:W(this,nI,"m",pI).call(this,r,i);break;case JT.WEBSOCKET:W(this,nI,"m",mI).call(this,r,i)}}},dI=function(t,e){let r=W(this,oI,"f")[t.id];if(r)return r.send();r=function(t,e,r,i){const n=bI(e),o=wI(t,e),s=new YT(n+t.url,o);return s.on("onSuccess",((e,r)=>{i({api:t,client:s,data:r||e})})),s.on("onError",(e=>{i({api:t,client:s,data:e})})),s.on("onStatus",((e,i)=>{r({api:t,client:s,status:e,message:i})})),s.send(),s}(t,e,W(this,nI,"m",uI).bind(this),W(this,nI,"m",fI).bind(this)),W(this,oI,"f")[t.id]=r},pI=function(t,e){let r=W(this,oI,"f")[t.id];if(r)return r.reconnect();r=MI(t,e,W(this,nI,"m",uI).bind(this),W(this,nI,"m",fI).bind(this)),W(this,oI,"f")[t.id]=r},mI=function(t,e){let r=W(this,oI,"f")[t.id];if(r)return r.connect();r=SI(t,e,W(this,nI,"m",uI).bind(this),W(this,nI,"m",fI).bind(this)),W(this,oI,"f")[t.id]=r},gI=function(t){return this.sourceEnv.find((e=>e.id===t))};const kI=(t,e)=>e.filter((e=>e.nodeId===t&&"PANEL"===e.contentType)),AI=t=>{try{return JSON.parse(t)}catch(t){return null}};var OI,TI,II,RI,CI,xI,PI,BI,NI,LI,DI,jI,UI,qI,FI,zI,HI,KI,VI,GI,WI,ZI,YI,XI,JI,QI,$I,tR,eR,rR,iR,nR,oR,sR,aR,hR,uR;class fR{constructor(t,e,r,i){this.treeList=t,this.poiList=e,this.plugin=r,this.cpsPlugin=i,OI.add(this),TI.set(this,{}),W(this,OI,"m",II).call(this)}batchPoi(t,e){t.nodeArray&&0!==t.nodeArray.length&&("HTTP"===t.protocol?W(this,OI,"m",xI).call(this,t.nodeArray,e):"MQTT"===t.protocol?W(this,OI,"m",RI).call(this,t.nodeArray,e):"WebSocket"===t.protocol&&W(this,OI,"m",CI).call(this,t.nodeArray,e))}}TI=new WeakMap,OI=new WeakSet,II=function(){if(this.treeList){const t=(t=>{const e=[],r={},i=(t,e)=>{for(const n of t){const{id:t,pid:o,familyId:s,name:a,renderType:h,children:u,deviceCode:f}=n,l=Object.assign(Object.assign({},n),{id:t,pid:o,familyId:s,name:a,renderType:h,children:[],deviceCode:f});e.push(l),r[t]=l,u.length>0&&i(u,l.children)}};return i(t,e),{treeNodes:e,flatNodes:r}})(this.treeList);Z(this,TI,t.flatNodes,"f")}},RI=function(t,e){const{payload:r,topic:i}=e,n=AI(r.toString()),o=null==t?void 0:t.filter((t=>{var e;return null===(e=t.eventList)||void 0===e?void 0:e.some((t=>((t,e)=>{if(t===e)return!0;const r=t.split("/"),i=e.split("/"),n=r.indexOf("#"),o=r.indexOf("+");if(-1!==n){if(-1!==o&&o<n)return r.slice(0,n).every(((t,e)=>"+"===t||t===i[e]||void 0));{const r=t.indexOf("#");if(t.slice(0,r)===e.slice(0,r))return!0}}else if(-1!==o&&r.length===i.length)return r.every(((t,e)=>"+"===t||t===i[e]||void 0));return!1})(t,i)))}));o&&W(this,OI,"m",xI).call(this,o,n)},CI=function(t,e){const{event:r,message:i}=e,n=t.filter((t=>{var e;return null===(e=t.eventList)||void 0===e?void 0:e.some((t=>t===r))}));n&&W(this,OI,"m",xI).call(this,n,i)},xI=function(t,e){if(!this.poiList)return;const r=[];for(let i=0;i<t.length;i++){const n=t[i],o=kI(n.nodeId,this.poiList),s=W(this,OI,"m",PI).call(this,e,n.matchParams||"",n.nodeId);s&&(o.forEach((t=>{if(t.contentData){const e=t.contentData.ds_user["接口数据"];if(!e)return;for(const t in s)if(Object.prototype.hasOwnProperty.call(s,t)){const r=s[t];e.hasOwnProperty(t)&&(e[t].value=r)}}})),r.push(...o))}r.length>0&&W(this,OI,"m",BI).call(this,r)},PI=function(t,e,r){const i=W(this,TI,"f")[r],n=null==i?void 0:i.deviceCode;if(i&&n)return"[object Array]"===Object.prototype.toString.call(t)?t.find((t=>String(t[e])===n)):"[object Object]"===Object.prototype.toString.call(t)?t:void 0},BI=function(t){this.plugin&&this.plugin.batchRender({dataSource:t.map(this.cpsPlugin.formatPoiData)})};class lR{constructor(t,e){this.plugin=t,this.cpsPlugin=e,NI.add(this)}listen(t){var e;const r=null===(e=this.cpsPlugin.poiData)||void 0===e?void 0:e.find(((e,r,i)=>{var n;return e.nodeId===(null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.modelId)}));if(r){const e=W(this,NI,"m",LI).call(this,t,r);W(this,NI,"m",DI).call(this,[e])}}}NI=new WeakSet,LI=function(t,e){var r,i,n;const o=null==t?void 0:t.target,s=null==t?void 0:t.value,a=null==t?void 0:t.property;try{if("label"!=a&&"value"!=a)return e;const t=function(t){return $k(t,5)}(e.contentData),h=null==o?void 0:o.group,u=null==o?void 0:o.key;return(null===(n=null===(i=null===(r=null==t?void 0:t.ds_user)||void 0===r?void 0:r[h])||void 0===i?void 0:i[u])||void 0===n?void 0:n[a])&&(t.ds_user[h][u][a]=s||""),e.contentData=t,e.content=JSON.stringify(t),e}catch(t){return console.error("generatePoiDataByUserData error",t),e}},DI=function(t){this.plugin&&this.plugin.batchRender({dataSource:t.map(this.cpsPlugin.formatPoiData)})};const{groupBy:cR,warn:dR,getExtension:pR}=t.utils,mR={syncProperties:!0,syncModelVisions:!0,needsModelsBoundsTree:!0,applyPresetEffects:!0,loadSceneAlgorithm:cO.DFS,loadLevel:1/0,loadPoi:!1,refreshPoiByDataSource:!1,loadFlowData:!1,objectPrefixId:"",asId:"sid"};class gR extends p{get path(){return W(this,UI,"f")}set path(t){W(this,UI,"f")!==t&&(Z(this,qI,!0,"f"),Z(this,UI,t,"f"),this.progress.loaded=0,this.progress.total=0)}constructor(t,e){super(),this.ssp=t,jI.add(this),UI.set(this,""),qI.set(this,!0),this.progress={loaded:0,total:0},this.sceneGroup=null,this.metaData=null,this.treeData=null,this.flatData=null,this.faltDataMap=null,this.poiData=null,this.dataSourceData=null,this.topologyData=null,this.propertiesData=null,this.objectsAnimations=new Map,this.animationsData=null,this.modelVisionsData=null,this.spacesData=null,this.effectPlugin=new i(this.ssp),this.atmospherePlugin=new n(this.ssp),this.soonflow=new class{nodeTypeMethods;outInstances;constructor(t,e){this.nodeTypeMethods=t,this.outInstances=e}async parseFlow(t,e){return new jt(t,e,this.nodeTypeMethods,this.outInstances).runParse()}unregisterFlow(t,e){new Ut(t,e,this.nodeTypeMethods,this.outInstances)}}(Xi,{ssp:this.ssp,cpsManager:this}),this.flowData=null,FI.set(this,dO),zI.set(this,new bO(this.ssp.viewport)),HI.set(this,!1),KI.set(this,!1),VI.set(this,!1),GI.set(this,new Map),this.formatPoiData=t=>{const{dimensional:e,poiId:r,media:i,display:n,scale:o,x:s,y:a,z:h,rotationX:u,rotationY:f,rotationZ:l,width:c,height:d,nodeId:p,contentType:m,style:g,contentData:y}=t;return{id:r,pid:p,visible:n,width:c,height:d,type:e,contentType:m,position:{x:s,y:a,z:h},rotation:{x:Math.PI/180*u,y:Math.PI/180*f,z:Math.PI/180*l},scale:{x:o/100,y:o/100,z:o/100},style:g,dataSource:(b=y,null==b?[]:XA(b,((t,e)=>XA(t,((t,r)=>XA(t,((t,i)=>({index:t.index,value:t.value||"",group:r,key:i,label:t.label||i,customId:[e,r,i].join("/"),dataOrigin:e})))),2)))),fileUrl:(null==i?void 0:i.assetId)||(null==i?void 0:i.fileId)?(null==i?void 0:i.url)?W(this,jI,"m",rR).call(this,i.url):void 0:null==i?void 0:i.url};var b},(null==e?void 0:e.key)&&this.setKey(e.key),(null==e?void 0:e.path)&&this.setPath(e.path)}setKey(t){t!==vO(W(this,FI,"f").debugKey)&&(W(this,FI,"f").key=t)}async fetchMetaData(){const t=await W(this,jI,"m",nR).call(this,JA);return this.metaData=t,t}async fetchTreeData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,$A));return W(this,jI,"m",WI).call(this,t),t}async fetchFlatData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,tO));return this.flatData=t,this.faltDataMap=cR(t,"id"),t}async fetchPoiData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,eO));return this.poiData=t.map((t=>Object.assign(Object.assign({},t),{contentData:JSON.parse(t.content||"{}")}))),this.poiData}async fetchDataSourceData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,rO));return this.dataSourceData=t,t}async fetchTopologyData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,iO)).then((t=>{const e={linkWidth:.1,linkColor:["#00ff00"],nodeRadius:.05,nodeColor:"#0000ff"};return t.map((t=>{const r=Object.assign(Object.assign({},e),t);return r.imgUrl&&(r.imgUrl=`${this.path}${r.imgUrl}`),r}))}));return this.topologyData=t,t}async fetchPropertiesData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,nO)).then((t=>{const e=t.map((t=>{const e=this.ssp.utils.propertiesCtx;return new Proxy(t,{set:(t,r,i)=>{var n;return this.ssp.signals.propertiesChanged.dispatch({value:i,property:String(r),target:t,source:null!==(n=null==e?void 0:e.source)&&void 0!==n?n:"unknown"}),Reflect.set(t,r,i)}})}));return e})).then((t=>cR(t,"modelId")));return this.propertiesData=t,t}async fetchAnimationsData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,oO)).then((t=>cR(t,"modelId")));return this.animationsData=t,t}async fetchModelVisionsData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,sO)).then((t=>new Map(Object.entries(t))));return this.modelVisionsData=t,t}async fetchSpacesData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,aO)).then((t=>wO(t,"sid")));return this.spacesData=t,t}async loadPoi(t=!1,e=!1){var i,n;const o=this.ssp.getPlugin(uO)||this.ssp.registerPlugin(r,uO);try{await this.fetchPoiData();const r=null!==(n=null===(i=this.poiData)||void 0===i?void 0:i.map(this.formatPoiData))&&void 0!==n?n:[];o.batchRender({dataSource:r}),t&&this.refreshPoiByDataSource(),e&&this.refreshByUserData()}catch(t){}}async refreshPoiByDataSource(){const t=this.ssp.getPlugin(uO)||this.ssp.registerPlugin(r,uO);try{const{dataSources:e,dataSourceApis:r}=await this.fetchDataSourceData(),i=new fR(this.treeData,this.poiData,t,this);if(e&&r){const t=new EI(e,r);t.requestAll(),t.on("onMessage",(({api:t,data:e})=>{i.batchPoi(t,e)}))}}catch(t){}}async refreshByUserData(){const t=this.ssp.getPlugin(uO)||this.ssp.registerPlugin(r,uO);try{const e=new lR(t,this);this.ssp.signals.propertiesChanged.add((t=>{e.listen(t)}))}catch(t){}}async runWithCode(t){return this.ssp.utils.runWithCode(t)}getTreeNodeById(t,e,r){if(!e)return;const i=e.find((e=>W(this,jI,"m",oR).call(this,e,r.asId)===t));if(i)return i;for(let i=0;i<e.length;i++){const n=this.getTreeNodeById(t,e[i].children,r);if(n)return n}}setPath(t){this.path=t}async loadScene(t={}){var e,r;const{key:i,path:n}=t;if(i&&this.setKey(i),n&&this.setPath(n),!this.path)return Promise.reject("请设置 path");this.flatData||await this.fetchFlatData(),this.progress.total=null!==(r=null===(e=this.flatData)||void 0===e?void 0:e.length)&&void 0!==r?r:0;const{version:o}=await this.fetchMetaData();if(o>=1.2&&W(this,qI,"f")){if(await W(this,jI,"m",XI).call(this),!W(this,HI,"f")&&!W(this,KI,"f"))return Promise.reject(`未授权的场景包:${this.path}`);!W(this,HI,"f")&&W(this,KI,"f")&&(W(this,VI,"f")||W(this,zI,"f").addToViewport()),Z(this,qI,!1,"f")}else o<1.2&&await this.fetchTreeData();const s=Object.assign(Object.assign({},mR),t);this.sceneGroup||(this.sceneGroup=this.ssp.createGroup(Object.assign({name:"root",id:this.path},s.sceneGroupInfo)));const a=[];s.syncProperties&&a.push(this.fetchPropertiesData()),s.syncModelVisions&&a.push(this.fetchModelVisionsData()),await Promise.allSettled(a),s.loadSceneAlgorithm===cO.BFS?await W(this,jI,"m",uR).call(this,s):s.loadSceneAlgorithm===cO.DFS&&await W(this,jI,"m",hR).call(this,s),this.ssp.updateAllDecalGeometry({snapping:!0,snappingDistance:1,uvMap:0});const h=[];s.applyPresetEffects&&h.push(this.presetEffects()),s.loadPoi&&h.push(this.loadPoi(s.refreshPoiByDataSource)),s.loadFlowData&&h.push(this.loadFlowData()),await Promise.allSettled(h),s.needsModelsBoundsTree&&this.ssp.computeModelsBoundsTree()}async presetEffects(t={}){var e,r,i,n,o,s,a,h,u;const{atmosphere:f=!0,hdr:l=!0,ssao:c=!0,directionalLightShadow:d=!0,toneMappping:p=!0}=t;if(await this.ssp.render(),!this.sceneGroup)return void qt("presetEffects: SceneGroup is not exist!");const g=this.sceneGroup.getBoundingBox(),{min:y,max:b}=g,v=g.getCenter(new m),w=g.getSize(new m),{environment:_,previewSettings:M}=await this.fetchMetaData(),S=null!==(e=AI(null!=M?M:""))&&void 0!==e?e:{},E=f&&(null===(r=S.atmosphere)||void 0===r?void 0:r.enabled);if(E){const{month:t,day:e,hours:r,longitude:i,latitude:n,altitude:o,groundAlbedo:s,castShadow:a}=S.atmosphere,h=W(this,jI,"m",rR).call(this,"/assets/atmosphere");Object.assign(this.atmospherePlugin,{longitude:i,latitude:n,altitude:o,groundAlbedo:s,castShadow:a}),this.atmospherePlugin.target.copy(v),this.atmospherePlugin.distance=w.length(),this.atmospherePlugin.date.setMonth(t),this.atmospherePlugin.date.setDate(e),this.atmospherePlugin.date.setHours(r/60),this.atmospherePlugin.date.setMinutes(r%60),this.atmospherePlugin.start(h)}l&&_&&"default"!==(null===(i=S.environment)||void 0===i?void 0:i.HDR)&&!E&&this.ssp.setEnvironment({file:W(this,jI,"m",rR).call(this,_),background:null===(o=null===(n=S.environment)||void 0===n?void 0:n.background)||void 0===o||o});c&&S.ssao&&(this.ssp.setSSAO(S.ssao),S.ssao.enabled&&dR("环境光遮蔽已开启,如卡顿请使用 ssp.setSSAO 关闭"));if(d&&!f){const t=`${this.path}_directionalLight`;this.ssp.removeObjectById(t);let e=null!==(a=null===(s=S.directionalLight)||void 0===s?void 0:s.degree)&&void 0!==a?a:45;this.ssp.utils.isObject(d)&&"number"==typeof d.angle&&(e=d.angle);const r=Math.tan(Math.PI/180*e)*w.x;this.ssp.createDirectionalLight({id:t,name:"directionalLight",position:{x:b.x,y:r,z:b.z},target:{x:y.x,y:y.y,z:y.z},openShadow:!0,shadowAutoUpdate:!1,intensity:null!==(u=null===(h=S.directionalLight)||void 0===h?void 0:h.intensity)&&void 0!==u?u:10,mapSize:this.ssp.viewport.renderer.capabilities.maxTextureSize/2})}p&&S.toneMappping&&this.ssp.setToneMapping(Object.assign({},S.toneMappping))}async getTopologies(){return this.fetchTopologyData()}sortTopologyNodes(t,e){var r;const i=t.nodes.reduce(((t,e)=>(t.set(e.id,e),t)),new Map);if(e&&!i.has(e))return void this.ssp.utils.error(`startNodeId ${e} 未找到对应 node`);let n=e?i.get(e):t.nodes[0];if(!n)return;const o=new Set;o.add(n);for(let e=0;e<t.nodes.length-1;e++){let t;for(const e of null!==(r=n.graphs)&&void 0!==r?r:[]){const r=i.get(e.targetNodeId);if(r&&!o.has(r)){t=r;break}}if(!t)break;n=t,o.add(n)}return Object.assign(Object.assign({},t),{nodes:[...new Set([...o,...t.nodes])]})}async playAnimationById(t,e=0,r={}){const{utils:{error:i}}=this.ssp,n=this.ssp.getObjectById(t);return n?this.playObjectAnimation(n,e,r):(i(`playAnimationById: id 为 ${t} 场景对象未找到`),!1)}async playObjectAnimation(t,e=0,{autoStopPrevious:r=!0,onStart:i,onUpdate:n}={}){var s;const a=await this.fetchAnimationsData(),{utils:{error:h}}=this.ssp,u=W(this,jI,"m",sR).call(this,t.userData),f=a.get(u);if(r&&this.stopObjectAnimation(t),f){const r=f[e];if(r)try{const e=new o(this.ssp,t);e.addEventListener("start",(({tween:t})=>null==i?void 0:i(t))),e.addEventListener("update",(({source:t,tween:e})=>null==n?void 0:n(t,e))),this.objectsAnimations.has(u)||this.objectsAnimations.set(u,new Set),null===(s=this.objectsAnimations.get(u))||void 0===s||s.add(e);const a=r.keyframes.map((t=>{var{x:e,y:r,z:i,rotationX:n,rotationY:o,rotationZ:s,scaleX:a,scaleY:h,scaleZ:u}=t,f=_(t,["x","y","z","rotationX","rotationY","rotationZ","scaleX","scaleY","scaleZ"]);return Object.assign({position:{x:e,y:r,z:i},rotation:{x:n,y:o,z:s},scale:{x:a,y:h,z:u}},f)}));return await e.play(a),!0}catch(t){}else h(`id: ${u} 未找到索引为 ${e} 的动画`)}else h(`id: ${u} 未找到动画`);return!1}async stopObjectAnimation(t){var e,r;const i=W(this,jI,"m",sR).call(this,t.userData);return!!this.objectsAnimations.has(i)&&(null===(e=this.objectsAnimations.get(i))||void 0===e||e.forEach((t=>t.stop())),null===(r=this.objectsAnimations.get(i))||void 0===r||r.clear(),!0)}async flyToSceneFromVisionsData(t=0){const{utils:{error:e}}=this.ssp;if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const r=this.modelVisionsData.get(""),i=null==r?void 0:r[t];if(i){const{camera:t,position:e,target:r,zoom:n=1}=i;return await this.ssp.setCamera("O"===t?"orthographic":"perspective",{position:e,target:r,zoom:n},!0),!0}e("场景视角数据未找到")}return!1}async flyToMainSceneFromVisionsData(t=!0){if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const t=this.modelVisionsData.get("");if(t){const e=t.findIndex((t=>t.primary));if(e>-1)return this.flyToSceneFromVisionsData(e)}}return t&&this.ssp.flyMainViewpoint(),!1}async flyToObjectFromVisionsData(t,e=0){const{utils:{error:r}}=this.ssp;if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const i=this.modelVisionsData.get(W(this,jI,"m",sR).call(this,t.userData)),n=null==i?void 0:i[e];if(n){const{camera:t,position:e,target:r,zoom:i=1}=n;return await this.ssp.setCamera("O"===t?"orthographic":"perspective",{position:e,target:r,zoom:i},!0),!0}r("对象视角数据未找到")}return!1}async flyToMainObjectFromVisionsData(t,e=!0){if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const e=this.modelVisionsData.get(W(this,jI,"m",sR).call(this,t.userData));if(e){const r=e.findIndex((t=>t.primary));if(r>-1)return this.flyToObjectFromVisionsData(t,r)}}return e&&this.ssp.flyToObj(t),!1}async loadFlowData(){const t=new Ft(this.path),{flowList:e}=await t.getFlowData();return this.flowData=e,e}async runFlowById(t){if(!this.flowData)return Promise.reject("CpsManagerPlugin.runFlowById(): 请先调用 loadFlowData 获取 flowData");const e=this.flowData.find((e=>e.id===t));if(!e)return Promise.reject(`CpsManagerPlugin.runFlowById() flowData not found by flowId(${t})`);const{nodes:r,edges:i}=e;return this.soonflow.parseFlow(r,i)}async getSpaceAssets(t){var e;this.spacesData||await this.fetchSpacesData();const r=[],i=null===(e=this.spacesData)||void 0===e?void 0:e.get(W(this,jI,"m",sR).call(this,t.userData));return i&&i.assets&&i.assets.length>0&&i.assets.forEach((t=>{const e=this.ssp.getObjectByUserDataProperty("id",t);r.push(...e)})),r}}UI=new WeakMap,qI=new WeakMap,FI=new WeakMap,zI=new WeakMap,HI=new WeakMap,KI=new WeakMap,VI=new WeakMap,GI=new WeakMap,jI=new WeakSet,WI=function(t){if(!t)return;const e=t=>{W(this,jI,"m",ZI).call(this,t),Reflect.deleteProperty(t,"path"),t.children&&t.children.forEach(e)};t.forEach(e),this.treeData=t},ZI=function(t){t.path&&W(this,GI,"f").set(t.sid,t.path)},YI=function(t){var e;return null!==(e=W(this,GI,"f").get(t.sid))&&void 0!==e?e:null},XI=async function(){let e;const{resource:r}=await this.fetchMetaData();if(W(this,FI,"f").verifyKey){if(e=await W(this,jI,"m",JI).call(this,r),"forbid"===e)return void Z(this,HI,!1,"f");if("noServerEnc"===e)await W(this,jI,"m",tR).call(this,r);else{const t=W(this,FI,"f").verifyKey,{verifiedRes:r,dec:i}=W(this,jI,"m",$I).call(this,e,t);Z(this,HI,r,"f"),W(this,HI,"f")&&W(this,jI,"m",WI).call(this,i)}}else if(W(this,FI,"f").key){const{verifiedRes:t}=await W(this,jI,"m",eR).call(this,r);t||await W(this,jI,"m",tR).call(this,r)}else W(this,FI,"f").debugKey?await W(this,jI,"m",tR).call(this,r):t.utils.error("许可证密钥不存在")},JI=async function(t){const e=Math.random().toString(36).substring(2),{verifyKey:r}=W(this,FI,"f"),i=new yM(r,"pkcs8-public",{environment:"browser",signingScheme:"pkcs1-md5",encryptionScheme:"pkcs1"}),n=i.encrypt(e,"base64"),o=await W(this,jI,"m",QI).call(this,W(this,jI,"m",rR).call(this,t),n),{license:s,serverEnc:a}=o;if(!a)return"noServerEnc";return i.decryptPublic(a,"utf8")!==e?"forbid":s},QI=async function(t,e=""){try{const r=await fetch(t,{headers:{token:e}}),i=r.headers,n=await r.json();return{license:n,serverEnc:i.get("token")}}catch(t){return{license:{content:"",sign:""},serverEnc:""}}},$I=function(t,e){let r=null,i=!0;try{const i=new yM(e,"pkcs8-public",{environment:"browser",signingScheme:"pkcs1-md5",encryptionScheme:"pkcs1"});if(2===t.version)r=_O(t,i);else r=((t,e)=>{const{content:r,sign:i}=t;if(!e.verify(r,i,"base64","base64"))throw new Error("v1 error");return e.decryptPublic(r,"json")})(t,i)}catch(t){i=!1,this.ssp.utils.error("秘钥 key 验证失败")}return{verifiedRes:i,dec:r}},tR=async function(t){const e=await W(this,jI,"m",nR).call(this,t),r=vO(W(this,FI,"f").debugKey),{verifiedRes:i,dec:n}=W(this,jI,"m",$I).call(this,e,r);Z(this,KI,i,"f"),W(this,KI,"f")&&W(this,jI,"m",WI).call(this,n)},eR=async function(t){const e=await W(this,jI,"m",nR).call(this,t),r=W(this,FI,"f").key,{verifiedRes:i,dec:n}=W(this,jI,"m",$I).call(this,e,r);return Z(this,VI,i,"f"),Z(this,KI,i,"f"),W(this,VI,"f")&&W(this,jI,"m",WI).call(this,n),{verifiedRes:i,dec:n}},rR=function(t){const e=W(this,UI,"f");if(e){const r=/\?([^/?&#:]+=[^?&]+&)*[^/?&#:]+=.*$/;t=t.startsWith("/")?t:`/${t}`,t=(t=r.test(e)?encodeURIComponent(t):encodeURI(t)).replaceAll(/#/g,"%23")}return`${e}${t}`},iR=async function(t){const{resource:e}=await this.fetchMetaData();return`${t}.${pR(e)||"json"}`},nR=async function(t){const{utils:e}=this.ssp;return e.fetchFile(W(this,jI,"m",rR).call(this,t),"json")},oR=function(t,e=mR.asId){var r;return null!==(r=t[e])&&void 0!==r?r:t.id},sR=function(t){return t.sid||t.id},aR=async function(t,r){var i;const{syncProperties:n,hiddenObjects:o,objectPrefixId:s}=r,{name:a,renderType:h,matrix:u,shape:f,visible:l}=t,c=W(this,jI,"m",oR).call(this,t,r.asId),d=[t.id,t.sid],p=`${s}${c}`,{ssp:m}=this,b=(new g).fromArray(u),v=W(this,jI,"m",YI).call(this,t),w=this.ssp.getObjectById(p);if(w)return w;let _=null,M=l;if((null==o?void 0:o.has(c))&&(M=!1),"3D"===h)if(v)try{_=await m.loadModel({id:p,url:W(this,jI,"m",rR).call(this,v)})}catch(t){console.error(t)}else dR(`id: ${c} path 为空`);else if("GROUP"===h||"STUB"===h)_=m.createGroup({id:p});else if("POLYGON"===h||"CIRCLE"===h){const t=m.createCanvas3D({id:p});f&&("POLYGON"===h&&f.points?t.createPolygon({id:`polygon/${p}`,yHeight:f.height,points:f.points,color:"blue",opacity:.5}):"CIRCLE"===h&&t.createCircle({id:`circle/${p}`,radius:f.radius,color:"blue",opacity:.5})),_=t}else!function(t){return"AREA"===t||"FLOOR"===t||"ROOM"===t}(t.renderType)?"WATER_SURFACE"===h?_=function(t,e,r){var i,n,o,s,a;const{effectPlugin:h}=t,{name:u,shape:f,extra:l={}}=e;return f&&f.points&&f.points.length>0?h.createWater({id:r,name:u,polygon:f.points,sunColor:null!==(i=l.sunColor)&&void 0!==i?i:"#ffffff",waterColor:null!==(n=l.waterColor)&&void 0!==n?n:"#7F7F7F",distortionScale:null!==(o=l.distortionScale)&&void 0!==o?o:20,alpha:null!==(s=l.alpha)&&void 0!==s?s:1,speed:null!==(a=l.speed)&&void 0!==a?a:1}):null}(this,t,p):"DECAL"===h?_=await async function(t,e,r,i){const{name:n}=e;return i?await t.createDecal({id:r,name:n,url:i,snapping:!1}):null}(this.ssp,t,p,v):"GS"===h&&v&&(_=await async function(t,r,i){const n=new y,o=new e(r);if(t.addObject(o),i){const t=await n.load(i);o.add(t)}return o}(this.ssp,t,W(this,jI,"m",rR).call(this,v))):_=function(t,e,r){const{name:i,shape:n,extra:o}=e,s=t.createCanvas3D({id:r,name:i});if((null==n?void 0:n.points)&&n.points.length>0){const{points:t}=n;s.createPolygon({id:`${r}/polygon`,points:t,depth:(null==n?void 0:n.depth)||0,yHeight:(null==n?void 0:n.height)||0,color:(null==o?void 0:o.color)||"#00f",opacity:(null==o?void 0:o.alpha)||.5})}return s}(this.ssp,t,p);if(_){!1===M&&_.hide(),_.name=a,_.extraIds=d,b.decompose(_.position,_.quaternion,_.scale);const e=Object.assign({},t);if(Reflect.deleteProperty(e,"children"),_.userData=e,n&&this.propertiesData){const t=this.propertiesData.get(c);t&&(_.userData[hO]=t)}}return(null===(i=this.faltDataMap)||void 0===i?void 0:i.has(t.id))&&(this.progress.loaded+=1,this.dispatchEvent({type:"progressing",progress:this.progress})),_},hR=async function(t){if(!this.treeData)throw new TypeError("treeData is null");const{loadLevel:e,loadTargetId:r}=t;let i=this.treeData;if(r){const e=this.getTreeNodeById(r,this.treeData,t);if(!e)throw new ReferenceError("根据 loadTargetId 未找到对应树节点");i=[e]}else i=this.treeData;const n=async(r,i,o=0)=>{if(o++,e&&o>e)return;const{ssp:s}=this,a=await W(this,jI,"m",aR).call(this,r,t);a&&s.addObject(a,null!=i?i:this.sceneGroup),await Promise.allSettled(r.children.map((t=>n(t,a,o))))};await Promise.allSettled(i.map((t=>n(t,t.pid?this.ssp.getObjectByUserDataProperty("id",t.pid)[0]:null,0))))},uR=async function(t){if(!this.treeData)throw new TypeError("treeData is null");const e=[],r=Object.create(null),i=[],{ssp:n}=this;for(e.push(...this.treeData);e.length>0;){e.splice(0,e.length).forEach((t=>{i.push(t),e.push(...t.children.map((e=>(r[e.id]=t.id,e))))}))}await Promise.allSettled(i.map((e=>W(this,jI,"m",aR).call(this,e,t)))),Object.entries(r).forEach((([t,e])=>{const r=n.getObjectById(t),i=n.getObjectById(e);r&&n.addObject(r,null!=i?i:this.sceneGroup)}))};export{oO as ANIMATIONS_DATA_FILE_PATH,rO as DATA_SOURCE_FILE_PATH,tO as FLAT_DATA_FILE_PATH,cO as LoadSceneAlgorithm,JA as META_DATA_FILE_PATH,sO as MODEL_VISIONS_DATA_FILE_PATH,eO as POI_DATA_FILE_PATH,uO as POI_PLUGIN_NAME,nO as PROPERTIES_DATA_FLEE_PATH,hO as PROPERTIES_KEY,fO as PoiContentTypeEnum,aO as SPACES_DATA_FILE_PATH,iO as TOPOLOGY_DATA_FILE_PATH,$A as TREE_DATA_FILE_PATH,gR as default};
7
+ var i=t("buffer"),n=i.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=i:(o(i,r),r.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},{buffer:17}],74:[function(t,e,r){function i(t){var e=t._readableState;return e?e.objectMode||"number"==typeof t._duplexState?t.read():t.read(n(e)):null}function n(t){return t.buffer.length?t.buffer.head?t.buffer.head.data.length:t.buffer[0].length:t.length}e.exports=i},{}],75:[function(t,e,r){var i=t("safe-buffer").Buffer,n=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function s(t){var e=o(t);if("string"!=typeof e&&(i.isEncoding===n||!n(t)))throw new Error("Unknown encoding: "+t);return e||t}function a(t){var e;switch(this.encoding=s(t),this.encoding){case"utf16le":this.text=p,this.end=m,e=4;break;case"utf8":this.fillLast=l,e=4;break;case"base64":this.text=g,this.end=y,e=3;break;default:return this.write=b,void(this.end=v)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function h(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function u(t,e,r){var i=e.length-1;if(i<r)return 0;var n=h(e[i]);return n>=0?(n>0&&(t.lastNeed=n-1),n):--i<r||-2===n?0:(n=h(e[i]))>=0?(n>0&&(t.lastNeed=n-2),n):--i<r||-2===n?0:(n=h(e[i]))>=0?(n>0&&(2===n?n=0:t.lastNeed=n-3),n):0}function f(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}function l(t){var e=this.lastTotal-this.lastNeed,r=f(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){var r=u(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)}function d(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e}function p(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function m(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function g(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function y(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function b(t){return t.toString(this.encoding)}function v(t){return t&&t.length?this.write(t):""}r.StringDecoder=a,a.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},a.prototype.end=d,a.prototype.text=c,a.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":73}],76:[function(t,e,r){var i=t("punycode"),n=t("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=w,r.resolve=M,r.resolveObject=S,r.format=_,r.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,h=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(u),l=["%","/","?",";","#"].concat(f),c=["/","?","#"],d=255,p=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=t("querystring");function w(t,e,r){if(t&&n.isObject(t)&&t instanceof o)return t;var i=new o;return i.parse(t,e,r),i}function _(t){return n.isString(t)&&(t=w(t)),t instanceof o?t.format():o.prototype.format.call(t)}function M(t,e){return w(t,!1,!0).resolve(e)}function S(t,e){return t?w(t,!1,!0).resolveObject(e):e}o.prototype.parse=function(t,e,r){if(!n.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var o=t.indexOf("?"),a=-1!==o&&o<t.indexOf("#")?"?":"#",u=t.split(a),w=/\\/g;u[0]=u[0].replace(w,"/");var _=t=u.join(a);if(_=_.trim(),!r&&1===t.split("#").length){var M=h.exec(_);if(M)return this.path=_,this.href=_,this.pathname=M[1],M[2]?(this.search=M[2],this.query=e?v.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var S=s.exec(_);if(S){var E=(S=S[0]).toLowerCase();this.protocol=E,_=_.substr(S.length)}if(r||S||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var k="//"===_.substr(0,2);!k||S&&y[S]||(_=_.substr(2),this.slashes=!0)}if(!y[S]&&(k||S&&!b[S])){for(var A,O,T=-1,I=0;I<c.length;I++)-1!==(R=_.indexOf(c[I]))&&(-1===T||R<T)&&(T=R);for(-1!==(O=-1===T?_.lastIndexOf("@"):_.lastIndexOf("@",T))&&(A=_.slice(0,O),_=_.slice(O+1),this.auth=decodeURIComponent(A)),T=-1,I=0;I<l.length;I++){var R;-1!==(R=_.indexOf(l[I]))&&(-1===T||R<T)&&(T=R)}-1===T&&(T=_.length),this.host=_.slice(0,T),_=_.slice(T),this.parseHost(),this.hostname=this.hostname||"";var C="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!C)for(var x=this.hostname.split(/\./),P=(I=0,x.length);I<P;I++){var B=x[I];if(B&&!B.match(p)){for(var N="",L=0,D=B.length;L<D;L++)B.charCodeAt(L)>127?N+="x":N+=B[L];if(!N.match(p)){var j=x.slice(0,I),U=x.slice(I+1),q=B.match(m);q&&(j.push(q[1]),U.unshift(q[2])),U.length&&(_="/"+U.join(".")+_),this.hostname=j.join(".");break}}}this.hostname.length>d?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=i.toASCII(this.hostname));var F=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+F,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[E])for(I=0,P=f.length;I<P;I++){var H=f[I];if(-1!==_.indexOf(H)){var K=encodeURIComponent(H);K===H&&(K=escape(H)),_=_.split(H).join(K)}}var V=_.indexOf("#");-1!==V&&(this.hash=_.substr(V),_=_.slice(0,V));var G=_.indexOf("?");if(-1!==G?(this.search=_.substr(G),this.query=_.substr(G+1),e&&(this.query=v.parse(this.query)),_=_.slice(0,G)):e&&(this.search="",this.query={}),_&&(this.pathname=_),b[E]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){F=this.pathname||"";var W=this.search||"";this.path=F+W}return this.href=this.format(),this},o.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",i=this.hash||"",o=!1,s="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&n.isObject(this.query)&&Object.keys(this.query).length&&(s=v.stringify(this.query));var a=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||b[e])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),i&&"#"!==i.charAt(0)&&(i="#"+i),a&&"?"!==a.charAt(0)&&(a="?"+a),e+o+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(a=a.replace("#","%23"))+i},o.prototype.resolve=function(t){return this.resolveObject(w(t,!1,!0)).format()},o.prototype.resolveObject=function(t){if(n.isString(t)){var e=new o;e.parse(t,!1,!0),t=e}for(var r=new o,i=Object.keys(this),s=0;s<i.length;s++){var a=i[s];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var h=Object.keys(t),u=0;u<h.length;u++){var f=h[u];"protocol"!==f&&(r[f]=t[f])}return b[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!b[t.protocol]){for(var l=Object.keys(t),c=0;c<l.length;c++){var d=l[c];r[d]=t[d]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||y[t.protocol])r.pathname=t.pathname;else{for(var p=(t.pathname||"").split("/");p.length&&!(t.host=p.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),r.pathname=p.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var m=r.pathname||"",g=r.search||"";r.path=m+g}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),w=t.host||t.pathname&&"/"===t.pathname.charAt(0),_=w||v||r.host&&t.pathname,M=_,S=r.pathname&&r.pathname.split("/")||[],E=(p=t.pathname&&t.pathname.split("/")||[],r.protocol&&!b[r.protocol]);if(E&&(r.hostname="",r.port=null,r.host&&(""===S[0]?S[0]=r.host:S.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===p[0]?p[0]=t.host:p.unshift(t.host)),t.host=null),_=_&&(""===p[0]||""===S[0])),w)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,S=p;else if(p.length)S||(S=[]),S.pop(),S=S.concat(p),r.search=t.search,r.query=t.query;else if(!n.isNullOrUndefined(t.search))return E&&(r.hostname=r.host=S.shift(),(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),r.search=t.search,r.query=t.query,n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var k=S.slice(-1)[0],A=(r.host||t.host||S.length>1)&&("."===k||".."===k)||""===k,O=0,T=S.length;T>=0;T--)"."===(k=S[T])?S.splice(T,1):".."===k?(S.splice(T,1),O++):O&&(S.splice(T,1),O--);if(!_&&!M)for(;O--;O)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),A&&"/"!==S.join("/").substr(-1)&&S.push("");var I,R=""===S[0]||S[0]&&"/"===S[0].charAt(0);return E&&(r.hostname=r.host=R?"":S.length?S.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),(_=_||r.host&&S.length)&&!R&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":77,punycode:51,querystring:54}],77:[function(t,e,r){e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],78:[function(t,e,r){(function(t){(function(){function r(t,e){if(i("noDeprecation"))return t;var r=!1;function n(){if(!r){if(i("throwDeprecation"))throw new Error(e);i("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}return n}function i(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=r}).call(this)}).call(this,void 0!==et?et:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(t,e,r){function i(t,e){if(t&&e)return i(t)(e);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var i=t.apply(this,e),n=e[e.length-1];return"function"==typeof i&&i!==n&&Object.keys(n).forEach((function(t){i[t]=n[t]})),i}}e.exports=i},{}],80:[function(t,e,r){e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(t,e,r){e.exports=n;var i=Object.prototype.hasOwnProperty;function n(){for(var t={},e=0;e<arguments.length;e++){var r=arguments[e];for(var n in r)i.call(r,n)&&(t[n]=r[n])}return t}},{}],82:[function(t,e,r){e.exports=function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}},{}],83:[function(t,e,r){function i(t){var e=this;if(e instanceof i||(e=new i),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)e.push(arguments[r]);return e}function n(t,e,r){var i=e===t.head?new a(r,null,e,t):new a(r,e,e.next,t);return null===i.next&&(t.tail=i),null===i.prev&&(t.head=i),t.length++,i}function o(t,e){t.tail=new a(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function s(t,e){t.head=new a(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function a(t,e,r,i){if(!(this instanceof a))return new a(t,e,r,i);this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}e.exports=i,i.Node=a,i.create=i,i.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e},i.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}},i.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}},i.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)o(this,arguments[t]);return this.length},i.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)s(this,arguments[t]);return this.length},i.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}},i.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}},i.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,i=0;null!==r;i++)t.call(e,r.value,i,this),r=r.next},i.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,i=this.length-1;null!==r;i--)t.call(e,r.value,i,this),r=r.prev},i.prototype.get=function(t){for(var e=0,r=this.head;null!==r&&e<t;e++)r=r.next;if(e===t&&null!==r)return r.value},i.prototype.getReverse=function(t){for(var e=0,r=this.tail;null!==r&&e<t;e++)r=r.prev;if(e===t&&null!==r)return r.value},i.prototype.map=function(t,e){e=e||this;for(var r=new i,n=this.head;null!==n;)r.push(t.call(e,n.value,this)),n=n.next;return r},i.prototype.mapReverse=function(t,e){e=e||this;for(var r=new i,n=this.tail;null!==n;)r.push(t.call(e,n.value,this)),n=n.prev;return r},i.prototype.reduce=function(t,e){var r,i=this.head;if(arguments.length>1)r=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,r=this.head.value}for(var n=0;null!==i;n++)r=t(r,i.value,n),i=i.next;return r},i.prototype.reduceReverse=function(t,e){var r,i=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==i;n--)r=t(r,i.value,n),i=i.prev;return r},i.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},i.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},i.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new i;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=0,o=this.head;null!==o&&n<t;n++)o=o.next;for(;null!==o&&n<e;n++,o=o.next)r.push(o.value);return r},i.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new i;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=this.length,o=this.tail;null!==o&&n>e;n--)o=o.prev;for(;null!==o&&n>t;n--,o=o.prev)r.push(o.value);return r},i.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var i=0,o=this.head;null!==o&&i<t;i++)o=o.next;var s=[];for(i=0;o&&i<e;i++)s.push(o.value),o=this.removeNode(o);for(null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev),i=0;i<r.length;i++)o=n(this,o,r[i]);return s},i.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;null!==r;r=r.prev){var i=r.prev;r.prev=r.next,r.next=i}return this.head=e,this.tail=t,this};try{t("./iterator.js")(i)}catch(t){}},{"./iterator.js":82}]},{},[12])(12);var AO=rt(EO);const OO=Object.create(null);OO.open="0",OO.close="1",OO.ping="2",OO.pong="3",OO.message="4",OO.upgrade="5",OO.noop="6";const TO=Object.create(null);Object.keys(OO).forEach((t=>{TO[OO[t]]=t}));const IO={type:"error",data:"parser error"},RO="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),CO="function"==typeof ArrayBuffer,xO=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,PO=({type:t,data:e},r,i)=>RO&&e instanceof Blob?r?i(e):BO(e,i):CO&&(e instanceof ArrayBuffer||xO(e))?r?i(e):BO(new Blob([e]),i):i(OO[t]+(e||"")),BO=(t,e)=>{const r=new FileReader;return r.onload=function(){const t=r.result.split(",")[1];e("b"+(t||""))},r.readAsDataURL(t)};function NO(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let LO;const DO="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",jO="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)jO[DO.charCodeAt(t)]=t;const UO="function"==typeof ArrayBuffer,qO=(t,e)=>{if("string"!=typeof t)return{type:"message",data:zO(t,e)};const r=t.charAt(0);if("b"===r)return{type:"message",data:FO(t.substring(1),e)};return TO[r]?t.length>1?{type:TO[r],data:t.substring(1)}:{type:TO[r]}:IO},FO=(t,e)=>{if(UO){const r=(t=>{let e,r,i,n,o,s=.75*t.length,a=t.length,h=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);const u=new ArrayBuffer(s),f=new Uint8Array(u);for(e=0;e<a;e+=4)r=jO[t.charCodeAt(e)],i=jO[t.charCodeAt(e+1)],n=jO[t.charCodeAt(e+2)],o=jO[t.charCodeAt(e+3)],f[h++]=r<<2|i>>4,f[h++]=(15&i)<<4|n>>2,f[h++]=(3&n)<<6|63&o;return u})(t);return zO(r,e)}return{base64:!0,data:t}},zO=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,HO=String.fromCharCode(30);function KO(){return new TransformStream({transform(t,e){!function(t,e){RO&&t.data instanceof Blob?t.data.arrayBuffer().then(NO).then(e):CO&&(t.data instanceof ArrayBuffer||xO(t.data))?e(NO(t.data)):PO(t,!1,(t=>{LO||(LO=new TextEncoder),e(LO.encode(t))}))}(t,(r=>{const i=r.length;let n;if(i<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,i);else if(i<65536){n=new Uint8Array(3);const t=new DataView(n.buffer);t.setUint8(0,126),t.setUint16(1,i)}else{n=new Uint8Array(9);const t=new DataView(n.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(i))}t.data&&"string"!=typeof t.data&&(n[0]|=128),e.enqueue(n),e.enqueue(r)}))}})}let VO;function GO(t){return t.reduce(((t,e)=>t+e.length),0)}function WO(t,e){if(t[0].length===e)return t.shift();const r=new Uint8Array(e);let i=0;for(let n=0;n<e;n++)r[n]=t[0][i++],i===t[0].length&&(t.shift(),i=0);return t.length&&i<t[0].length&&(t[0]=t[0].slice(i)),r}function ZO(t){if(t)return function(t){for(var e in ZO.prototype)t[e]=ZO.prototype[e];return t}(t)}ZO.prototype.on=ZO.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},ZO.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},ZO.prototype.off=ZO.prototype.removeListener=ZO.prototype.removeAllListeners=ZO.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,i=this._callbacks["$"+t];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var n=0;n<i.length;n++)if((r=i[n])===e||r.fn===e){i.splice(n,1);break}return 0===i.length&&delete this._callbacks["$"+t],this},ZO.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(r){i=0;for(var n=(r=r.slice(0)).length;i<n;++i)r[i].apply(this,e)}return this},ZO.prototype.emitReserved=ZO.prototype.emit,ZO.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},ZO.prototype.hasListeners=function(t){return!!this.listeners(t).length};const YO="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function XO(t,...e){return e.reduce(((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e)),{})}const JO=YO.setTimeout,QO=YO.clearTimeout;function $O(t,e){e.useNativeTimers?(t.setTimeoutFn=JO.bind(YO),t.clearTimeoutFn=QO.bind(YO)):(t.setTimeoutFn=YO.setTimeout.bind(YO),t.clearTimeoutFn=YO.clearTimeout.bind(YO))}class tT extends Error{constructor(t,e,r){super(t),this.description=e,this.context=r,this.type="TransportError"}}class eT extends ZO{constructor(t){super(),this.writable=!1,$O(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,r){return super.emitReserved("error",new tT(t,e,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=qO(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e}(t);return e.length?"?"+e:""}}const rT="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),iT=64,nT={};let oT,sT=0,aT=0;function hT(t){let e="";do{e=rT[t%iT]+e,t=Math.floor(t/iT)}while(t>0);return e}function uT(){const t=hT(+new Date);return t!==oT?(sT=0,oT=t):t+"."+hT(sT++)}for(;aT<iT;aT++)nT[rT[aT]]=aT;let fT=!1;try{fT="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const lT=fT;function cT(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||lT))return new XMLHttpRequest}catch(t){}if(!e)try{return new(YO[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}function dT(){}const pT=null!=new cT({xdomain:!1}).responseType;class mT extends ZO{constructor(t,e){super(),$O(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.data=void 0!==e.data?e.data:null,this.create()}create(){var t;const e=XO(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd;const r=this.xhr=new cT(e);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&r.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(t){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{r.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this.opts.cookieJar)||void 0===t||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var t;3===r.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=mT.requestsCount++,mT.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=dT,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete mT.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(mT.requestsCount=0,mT.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",gT);else if("function"==typeof addEventListener){addEventListener("onpagehide"in YO?"pagehide":"unload",gT,!1)}function gT(){for(let t in mT.requests)mT.requests.hasOwnProperty(t)&&mT.requests[t].abort()}const yT="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),bT=YO.WebSocket||YO.MozWebSocket,vT="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const wT={websocket:class extends eT{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,r=vT?{}:XO(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=vT?new bT(t,e,r):e?new bT(t,e):new bT(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;PO(r,this.supportsBinary,(t=>{try{this.ws.send(t)}catch(t){}i&&yT((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=uT()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!bT}},webtransport:class extends eT{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){VO||(VO=new TextDecoder);const r=[];let i=0,n=-1,o=!1;return new TransformStream({transform(s,a){for(r.push(s);;){if(0===i){if(GO(r)<1)break;const t=WO(r,1);o=128==(128&t[0]),n=127&t[0],i=n<126?3:126===n?1:2}else if(1===i){if(GO(r)<2)break;const t=WO(r,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),i=3}else if(2===i){if(GO(r)<8)break;const t=WO(r,8),e=new DataView(t.buffer,t.byteOffset,t.length),o=e.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(IO);break}n=o*Math.pow(2,32)+e.getUint32(4),i=3}else{if(GO(r)<n)break;const t=WO(r,n);a.enqueue(qO(o?t:VO.decode(t),e)),i=0}if(0===n||n>t){a.enqueue(IO);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(e).getReader(),i=KO();i.readable.pipeTo(t.writable),this.writer=i.writable.getWriter();const n=()=>{r.read().then((({done:t,value:e})=>{t||(this.onPacket(e),n())})).catch((t=>{}))};n();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const r=t[e],i=e===t.length-1;this.writer.write(r).then((()=>{i&&yT((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends eT{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let r=location.port;r||(r=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||r!==t.port}const e=t&&t.forceBase64;this.supportsBinary=pT&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const r=t.split(HO),i=[];for(let t=0;t<r.length;t++){const n=qO(r[t],e);if(i.push(n),"error"===n.type)break}return i})(t,this.socket.binaryType).forEach((t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const r=t.length,i=new Array(r);let n=0;t.forEach(((t,o)=>{PO(t,!1,(t=>{i[o]=t,++n===r&&e(i.join(HO))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=uT()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new mT(this.uri(),t)}doWrite(t,e){const r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},_T=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,MT=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ST(t){const e=t,r=t.indexOf("["),i=t.indexOf("]");-1!=r&&-1!=i&&(t=t.substring(0,r)+t.substring(r,i).replace(/:/g,";")+t.substring(i,t.length));let n=_T.exec(t||""),o={},s=14;for(;s--;)o[MT[s]]=n[s]||"";return-1!=r&&-1!=i&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(t,e){const r=/\/{2,9}/g,i=e.replace(r,"/").split("/");"/"!=e.slice(0,1)&&0!==e.length||i.splice(0,1);"/"==e.slice(-1)&&i.splice(i.length-1,1);return i}(0,o.path),o.queryKey=function(t,e){const r={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,i){e&&(r[e]=i)})),r}(0,o.query),o}let ET=class t extends ZO{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=ST(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=ST(e.host).host),$O(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},r=t.split("&");for(let t=0,i=r.length;t<i;t++){let i=r[t].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const r=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new wT[t](r)}open(){let e;if(this.opts.rememberUpgrade&&t.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(t){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(e){let r=this.createTransport(e),i=!1;t.priorWebsocketSuccess=!1;const n=()=>{i||(r.send([{type:"ping",data:"probe"}]),r.once("packet",(e=>{if(!i)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",r),!r)return;t.priorWebsocketSuccess="websocket"===r.name,this.transport.pause((()=>{i||"closed"!==this.readyState&&(f(),this.setTransport(r),r.send([{type:"upgrade"}]),this.emitReserved("upgrade",r),r=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=r.name,this.emitReserved("upgradeError",t)}})))};function o(){i||(i=!0,f(),r.close(),r=null)}const s=t=>{const e=new Error("probe error: "+t);e.transport=r.name,o(),this.emitReserved("upgradeError",e)};function a(){s("transport closed")}function h(){s("socket closed")}function u(t){r&&t.name!==r.name&&o()}const f=()=>{r.removeListener("open",n),r.removeListener("error",s),r.removeListener("close",a),this.off("close",h),this.off("upgrading",u)};r.once("open",n),r.once("error",s),r.once("close",a),this.once("close",h),this.once("upgrading",u),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{i||r.open()}),200):r.open()}onOpen(){if(this.readyState="open",t.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),this.resetPingTimeout(),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){const i=this.writeBuffer[r].data;if(i&&(t+="string"==typeof(e=i)?function(t){let e=0,r=0;for(let i=0,n=t.length;i<n;i++)e=t.charCodeAt(i),e<128?r+=1:e<2048?r+=2:e<55296||e>=57344?r+=3:(i++,r+=4);return r}(e):Math.ceil(1.33*(e.byteLength||e.size))),r>0&&t>this.maxPayload)return this.writeBuffer.slice(0,r);t+=2}var e;return this.writeBuffer}write(t,e,r){return this.sendPacket("message",t,e,r),this}send(t,e,r){return this.sendPacket("message",t,e,r),this}sendPacket(t,e,r,i){if("function"==typeof e&&(i=e,e=void 0),"function"==typeof r&&(i=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const n={type:t,data:e,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},r=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():t()})):this.upgrading?r():t()),this}onError(e){t.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let r=0;const i=t.length;for(;r<i;r++)~this.transports.indexOf(t[r])&&e.push(t[r]);return e}};ET.protocol=4;const kT="function"==typeof ArrayBuffer,AT=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,OT=Object.prototype.toString,TT="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===OT.call(Blob),IT="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===OT.call(File);function RT(t){return kT&&(t instanceof ArrayBuffer||AT(t))||TT&&t instanceof Blob||IT&&t instanceof File}function CT(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,r=t.length;e<r;e++)if(CT(t[e]))return!0;return!1}if(RT(t))return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return CT(t.toJSON(),!0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&CT(t[e]))return!0;return!1}function xT(t){const e=[],r=t.data,i=t;return i.data=PT(r,e),i.attachments=e.length,{packet:i,buffers:e}}function PT(t,e){if(!t)return t;if(RT(t)){const r={_placeholder:!0,num:e.length};return e.push(t),r}if(Array.isArray(t)){const r=new Array(t.length);for(let i=0;i<t.length;i++)r[i]=PT(t[i],e);return r}if("object"==typeof t&&!(t instanceof Date)){const r={};for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=PT(t[i],e));return r}return t}function BT(t,e){return t.data=NT(t.data,e),delete t.attachments,t}function NT(t,e){if(!t)return t;if(t&&!0===t._placeholder){if("number"==typeof t.num&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]=NT(t[r],e);else if("object"==typeof t)for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(t[r]=NT(t[r],e));return t}const LT=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var DT;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(DT||(DT={}));function jT(t){return"[object Object]"===Object.prototype.toString.call(t)}class UT extends ZO{constructor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const r=e.type===DT.BINARY_EVENT;r||e.type===DT.BINARY_ACK?(e.type=r?DT.EVENT:DT.ACK,this.reconstructor=new qT(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!RT(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===DT[r.type])throw new Error("unknown packet type "+r.type);if(r.type===DT.BINARY_EVENT||r.type===DT.BINARY_ACK){const i=e+1;for(;"-"!==t.charAt(++e)&&e!=t.length;);const n=t.substring(i,e);if(n!=Number(n)||"-"!==t.charAt(e))throw new Error("Illegal attachments");r.attachments=Number(n)}if("/"===t.charAt(e+1)){const i=e+1;for(;++e;){if(","===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(i,e)}else r.nsp="/";const i=t.charAt(e+1);if(""!==i&&Number(i)==i){const i=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(i,e+1))}if(t.charAt(++e)){const i=this.tryParse(t.substr(e));if(!UT.isPayloadValid(r.type,i))throw new Error("invalid payload");r.data=i}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(t){return!1}}static isPayloadValid(t,e){switch(t){case DT.CONNECT:return jT(e);case DT.DISCONNECT:return void 0===e;case DT.CONNECT_ERROR:return"string"==typeof e||jT(e);case DT.EVENT:case DT.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===LT.indexOf(e[0]));case DT.ACK:case DT.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class qT{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=BT(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var FT=Object.freeze({__proto__:null,Decoder:UT,Encoder:class{constructor(t){this.replacer=t}encode(t){return t.type!==DT.EVENT&&t.type!==DT.ACK||!CT(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===DT.EVENT?DT.BINARY_EVENT:DT.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==DT.BINARY_EVENT&&t.type!==DT.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}encodeAsBinary(t){const e=xT(t),r=this.encodeAsString(e.packet),i=e.buffers;return i.unshift(r),i}},get PacketType(){return DT},protocol:5});function zT(t,e,r){return t.on(e,r),function(){t.off(e,r)}}const HT=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class KT extends ZO{constructor(t,e,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[zT(t,"open",this.onopen.bind(this)),zT(t,"packet",this.onpacket.bind(this)),zT(t,"error",this.onerror.bind(this)),zT(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(HT.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const r={type:DT.EVENT,data:e,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,i=e.pop();this._registerAckCallback(t,i),r.id=t}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(t,e){var r;const i=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===i)return void(this.acks[t]=e);const n=this.io.setTimeoutFn((()=>{delete this.acks[t];for(let e=0;e<this.sendBuffer.length;e++)this.sendBuffer[e].id===t&&this.sendBuffer.splice(e,1);e.call(this,new Error("operation has timed out"))}),i);this.acks[t]=(...t)=>{this.io.clearTimeoutFn(n),e.apply(this,[null,...t])}}emitWithAck(t,...e){const r=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((i,n)=>{e.push(((t,e)=>r?t?n(t):i(e):i(t))),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...i)=>{if(r!==this._queue[0])return;return null!==t?r.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...i)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:DT.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case DT.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case DT.EVENT:case DT.BINARY_EVENT:this.onevent(t);break;case DT.ACK:case DT.BINARY_ACK:this.onack(t);break;case DT.DISCONNECT:this.ondisconnect();break;case DT.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const r of e)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let r=!1;return function(...i){r||(r=!0,e.packet({type:DT.ACK,id:t,data:i}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:DT.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const r of e)r.apply(this,t.data)}}}function VT(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}VT.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-r:t+r}return 0|Math.min(t,this.max)},VT.prototype.reset=function(){this.attempts=0},VT.prototype.setMin=function(t){this.ms=t},VT.prototype.setMax=function(t){this.max=t},VT.prototype.setJitter=function(t){this.jitter=t};class GT extends ZO{constructor(t,e){var r;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.opts=e,$O(this,e),this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=e.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new VT({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const i=e.parser||FT;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new ET(this.uri,this.opts);const e=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=zT(e,"open",(function(){r.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},o=zT(e,"error",n);if(!1!==this._timeout){const t=this._timeout,r=this.setTimeoutFn((()=>{i(),n(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(i),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(zT(t,"ping",this.onping.bind(this)),zT(t,"data",this.ondata.bind(this)),zT(t,"error",this.onerror.bind(this)),zT(t,"close",this.onclose.bind(this)),zT(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){yT((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new KT(this,t,e),this.nsps[t]=r),r}_destroy(t){const e=Object.keys(this.nsps);for(const t of e){if(this.nsps[t].active)return}this._close()}_packet(t){const e=this.encoder.encode(t);for(let r=0;r<e.length;r++)this.engine.write(e[r],t.options)}cleanup(){this.subs.forEach((t=>t())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const WT={};function ZT(t,e){"object"==typeof t&&(e=t,t=void 0);const r=function(t,e="",r){let i=t;r=r||"undefined"!=typeof location&&location,null==t&&(t=r.protocol+"//"+r.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?r.protocol+t:r.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==r?r.protocol+"//"+t:"https://"+t),i=ST(t)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const n=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+n+":"+i.port+e,i.href=i.protocol+"://"+n+(r&&r.port===i.port?"":":"+i.port),i}(t,(e=e||{}).path||"/socket.io"),i=r.source,n=r.id,o=r.path,s=WT[n]&&o in WT[n].nsps;let a;return e.forceNew||e["force new connection"]||!1===e.multiplex||s?a=new GT(i,e):(WT[n]||(WT[n]=new GT(i,e)),a=WT[n]),r.query&&!e.query&&(e.query=r.queryKey),a.socket(r.path,e)}Object.assign(ZT,{Manager:GT,Socket:KT,io:ZT,connect:ZT});class YT{constructor(t,e){this.method="GET",this.protocol="HTTPS",this.body=null,this.interval=0,this.timeout=1e4,this.responseType="",this.filteredData=null,this.XHR=void 0,this.isInterval=!1,this.successCallback=void 0,this.errorCallback=void 0,this.statusCallback=void 0,this.onTimeout=()=>{this.XHR&&(this.onErrorCallback(new Error("Error: timeout")),this.circulateRequest())},this.onLoad=()=>{if(this.XHR){if(this.responseData=this.toObject(this.XHR.response),4!==this.XHR.readyState||200!=this.XHR.status&&304!=this.XHR.status)this.onErrorCallback(new Error(this.XHR.statusText));else{try{this.filteredData=this.filter?this.filter(this.responseData):this.responseData}catch(t){this.filteredData=void 0,console.error(t)}this.onSuccessCallback(this.responseData,this.filteredData)}this.circulateRequest()}},this.onError=()=>{this.XHR&&this.onErrorCallback(new Error(this.XHR.statusText))},this.url=t,e&&(this.option=e,this.method=e.method?e.method.toUpperCase():"GET",this.protocol=e.protocol?e.protocol.toUpperCase():"HTTPS",this.headers=e.headers?e.headers:void 0,this.params=e.params?e.params:void 0,this.body=e.body?e.body:null,this.interval=void 0!==e.interval?e.interval:0,this.timeout=e.timeout?e.timeout:1e4,this.responseType=void 0!==e.responseType?e.responseType:"",e.filter&&(this.filter="function"==typeof e.filter?e.filter:new Function("response",e.filter)))}get getUrl(){return this.url}get getOption(){return Object.assign(Object.assign({},this.option),{url:this.url})}get getStatus(){var t;return null===(t=this.XHR)||void 0===t?void 0:t.status}get getRequesting(){return this.isInterval&&0!==this.interval}get getResponseData(){return this.responseData}get getFilterData(){return this.filteredData}send(){this.isInterval=!0,this.request()}abort(){this.isInterval=!1}onceSend(){this.request()}listen(t,e){this.successCallback=t,e&&(this.errorCallback=e)}on(t,e){switch(t){case"onSuccess":this.successCallback=e;break;case"onError":this.errorCallback=e;break;case"onStatus":this.statusCallback=e}}onStatusCallback(t,e){this.statusCallback&&this.statusCallback(t,e)}onErrorCallback(t){this.errorCallback&&this.errorCallback(t),this.onStatusCallback("error",t)}onSuccessCallback(t,e){this.successCallback&&this.successCallback(t,e),this.onStatusCallback("success")}request(){try{if(this.onStatusCallback("connect"),this.XHR||(this.XHR=new XMLHttpRequest),this.XHR.open(this.method,this.paramsUrl()),this.XHR.responseType=this.responseType,this.XHR.timeout=this.timeout,this.XHR.onload=this.onLoad,this.XHR.onerror=this.onError,this.XHR.ontimeout=this.onTimeout,this.headers)for(const t in this.headers)Object.prototype.hasOwnProperty.call(this.headers,t)&&"multipart/form-data"!==this.headers[t]&&this.XHR.setRequestHeader(t,this.headers[t]);this.XHR.send(this.body)}catch(t){console.error(t),this.onErrorCallback(t)}}circulateRequest(){if(this.getRequesting){const t=setTimeout((()=>{this.request(),clearTimeout(t)}),this.interval)}else this.isInterval&&(this.isInterval=!1)}paramsUrl(){let t=this.url+"?";if(this.params)for(const e in this.params)Object.prototype.hasOwnProperty.call(this.params,e)&&(t+=encodeURIComponent(e)+"="+encodeURIComponent(this.params[e])+"&");return t.slice(0,-1)}toObject(t){if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}}}var XT,JT,QT,$T,tI,eI,rI,iI,nI,oI,sI,aI,hI,uI,fI,lI,cI,dI,pI,mI,gI;function yI(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}function bI(t){let e=t.protocolValue+t.url;return t.port&&(e+=":"+t.port),e}function vI(t,e,r=!1,i,n,o){try{if(!e)return t;let n="";r&&yI(t)&&(n=`const { ${Object.keys(t).join(",")} } = response;`);const a=new Function("response",n+e)(t),h=i?function(t){return"number"==typeof t}(s=a)?`${s}`:yI(s)?JSON.stringify(s,null,2):s:a;return o&&o(h),h}catch(t){return n&&n(t),t}var s}function wI(t,e){if(t.protocol!==JT.HTTP)return;const r=t.configureJson,i=function(t,e){switch(e){case eI.SECOND:return 1e3*t;case eI.MINUTE:return 1e3*t*60;case eI.HOUR:return 1e3*t*60*60;case eI.DAY:return 1e3*t*60*60*24;default:return 1e3*t}}(r.interval,r.unit),n=Object.assign(e[XT.HEADERS],t[XT.HEADERS]);let o=null;const s=r.params,a=new FormData;switch(a.set("default","defaultData"),r.bodyType){case $T.NONE:break;case $T.JSON:n["Content-Type"]=rI.JSON,o=r.body.json;break;case $T.XML:n["Content-Type"]=rI.XML,o=r.body.xml;break;case $T.X_WWW_FORM_URLENCODED:n["Content-Type"]=rI.FORM_URLENCODED;o=function(t){const e=new URLSearchParams;for(const r in t)Object.prototype.hasOwnProperty.call(t,"key")&&e.append(r,t[r]);return e.toString()}(r.body["x-www-form-urlencoded"]);break;case $T.FORM_DATA:{n["Content-Type"]=rI.FORM_DATA;const t=r.body["form-data"];for(const e in t)a.set(e,t[e]);o=a;break}}return{params:s,headers:n,interval:i,body:o,method:r.method,filter:r.filter,protocol:e.protocol}}function _I(t,e,r,i){const n=(t,e)=>{r({status:t,message:e})};e.on("reconnect",(()=>{n(iI.CONNECT)})),e.on("close",(t=>{const e=t||new Error("连接关闭");n(iI.CLOSE,e)})),e.on("error",(t=>{n(iI.ERROR,t)})),e.on("message",((r,n,o)=>{i({api:t,client:e,data:{topic:r,payload:n,packet:o}})})),e.on("connect",(r=>{if(0===r.returnCode)n(iI.SUCCESS,r),function(t,e){const r=t.configureJson,i=r.subscription;if(0==i.length)return;const n={};i.forEach((t=>{t.topic&&(n[t.topic]={qos:t.qos})})),Object.keys(n).length>0&&e.subscribe(n,(t=>{t&&console.error(t)}))}(t,e);else{const t=void 0!==r.returnCode?String(r.returnCode):r.cmd;e.emit("close",new Error(t))}}))}function MI(t,e,r,i){const n=bI(e),o=function(t){if(t.protocol!==JT.MQTT)return;const e=t.configureJson,{baseConfig:r,willMessage:i}=e,n={clientId:r.clientId,keepalive:r.keepAlive,protocolVersion:Number(r.version),protocolId:"MQTT",reconnectPeriod:0};return i&&i.topic&&(n.will={topic:i.topic,payload:i.message||"",qos:i.qos,retain:i.retain}),r.username&&(n.username=r.username),r.password&&(n.password=r.password),n}(t),s=AO.connect(n+(t.url||""),o),a=t.configureJson,{successCallback:h,errorCallback:u}=a;return _I(t,s,(({status:e,message:i})=>{const n=e!==iI.CONNECT?i:void 0;r({api:t,client:s,status:e,message:n}),e===iI.CONNECT&&h?vI({connect:i,client:s},h,!0):e!==iI.ERROR&&e!==iI.CLOSE||!u||vI({error:i,client:s},u,!0)}),i),s}function SI(t,e,r,i){let n=bI(e);const o=function(t,e){if(t.protocol!==JT.WEBSOCKET)return;const r=t.configureJson,i=Object.assign(e[XT.HEADERS],t[XT.HEADERS]),{subProtocols:n,query:o}=r,s=n?n.split(","):["websocket","polling"];return{reconnection:!1,reconnectionAttempts:0,path:t.url,query:o,transports:s,extraHeaders:i,withCredentials:!0}}(t,e),s=t.configureJson,{successCallback:a,errorCallback:h,nameSpace:u}=s;u&&(n+=(/^\/.*/.test(u)?"":"/")+u);const f=ZT(n,o);return function(t,e,r,i){const n=t.configureJson,{eventList:o}=n;e.on("connect",(()=>{r(iI.SUCCESS)})),e.on("disconnect",(t=>{r(iI.CLOSE,new Error(t))})),e.on("connect_error",(t=>{r(iI.ERROR,t)})),e.on("reconnect",(()=>{r(iI.CONNECT)})),e.on("reconnect_error",(t=>{r(iI.ERROR,t)})),e.on("reconnect_failed",(t=>{r(iI.ERROR,t||new Error("reconnect_failed"))}));for(let r=0;r<o.length;r++){const n=o[r];e.on(n.event,((...r)=>{i({api:t,client:e,data:{message:r,event:n.event}})}))}}(t,f,((e,i)=>{r({status:e,api:t,client:f,message:i}),e===iI.SUCCESS&&a?vI({socket:f},a,!0):e!==iI.ERROR&&e!==iI.CLOSE||!h||vI({error:i,socket:f},h,!0)}),i),f.connect(),f}!function(t){t.PARAMS="params",t.BODY="body",t.HEADERS="headers"}(XT||(XT={})),function(t){t.HTTP="HTTP",t.MQTT="MQTT",t.WEBSOCKET="WebSocket"}(JT||(JT={})),function(t){t.HTTPS="https://",t.HTTP="http://",t.MQTTS="wss://",t.MQTT="ws://",t.WSS="wss://",t.WS="ws://"}(QT||(QT={})),function(t){t.NONE="none",t.FORM_DATA="form-data",t.X_WWW_FORM_URLENCODED="x-www-form-urlencoded",t.JSON="json",t.XML="xml"}($T||($T={})),function(t){t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.OPTIONS="OPTIONS",t.DELETE="DELETE"}(tI||(tI={})),function(t){t.SECOND="second",t.MINUTE="minute",t.HOUR="hour",t.DAY="day"}(eI||(eI={})),JT.HTTP,JT.HTTP,JT.MQTT,JT.MQTT,JT.WEBSOCKET,JT.WEBSOCKET,function(t){t.JSON="application/json;charset=UTF-8",t.TEXT="text/plain;charset=UTF-8",t.XML="application/xml;charset=UTF-8",t.FORM_URLENCODED="application/x-www-form-urlencoded;charset=UTF-8",t.FORM_DATA="multipart/form-data"}(rI||(rI={})),function(t){t.SUCCESS="success",t.ERROR="error",t.CONNECT="connect",t.CLOSE="close"}(iI||(iI={}));class EI{constructor(t,e){this.sourceEnv=t,this.sourceApi=e,nI.add(this),oI.set(this,{}),sI.set(this,void 0),aI.set(this,void 0),W(this,nI,"m",hI).call(this)}on(t,e){"onStatus"===t?Z(this,sI,e,"f"):"onMessage"===t&&Z(this,aI,e,"f")}getClientById(t){return W(this,oI,"f")[t]}requestAll(){const t=this.sourceApi;t&&t.length>0&&W(this,nI,"m",cI).call(this,t)}requestById(t){const e=this.sourceApi.filter((e=>t.some((t=>t===e.id))));e&&e.length>0&&W(this,nI,"m",cI).call(this,e)}closeAll(){for(const t in W(this,oI,"f"))if(Object.prototype.hasOwnProperty.call(W(this,oI,"f"),t)){const e=W(this,oI,"f")[t];W(this,nI,"m",lI).call(this,e)}}closeById(t){for(let e=0;e<t.length;e++){const r=t[e],i=W(this,oI,"f")[r];W(this,nI,"m",lI).call(this,i)}}}oI=new WeakMap,sI=new WeakMap,aI=new WeakMap,nI=new WeakSet,hI=function(){Z(this,oI,{},"f")},uI=function(t){console.log("onStatus",t),W(this,sI,"f")&&W(this,sI,"f").call(this,t)},fI=function(t){console.log("onMessage",t),W(this,aI,"f")&&W(this,aI,"f").call(this,t)},lI=function(t){t instanceof YT?t.abort():t instanceof KT?t.close():t instanceof EO.MqttClient&&t.end()},cI=function(t){for(let e=0;e<t.length;e++){const r=t[e],i=W(this,nI,"m",gI).call(this,r.sid);if(r.nodeArray&&r.nodeArray.length>0&&i)switch(r.protocol){case JT.HTTP:W(this,nI,"m",dI).call(this,r,i);break;case JT.MQTT:W(this,nI,"m",pI).call(this,r,i);break;case JT.WEBSOCKET:W(this,nI,"m",mI).call(this,r,i)}}},dI=function(t,e){let r=W(this,oI,"f")[t.id];if(r)return r.send();r=function(t,e,r,i){const n=bI(e),o=wI(t,e),s=new YT(n+t.url,o);return s.on("onSuccess",((e,r)=>{i({api:t,client:s,data:r||e})})),s.on("onError",(e=>{i({api:t,client:s,data:e})})),s.on("onStatus",((e,i)=>{r({api:t,client:s,status:e,message:i})})),s.send(),s}(t,e,W(this,nI,"m",uI).bind(this),W(this,nI,"m",fI).bind(this)),W(this,oI,"f")[t.id]=r},pI=function(t,e){let r=W(this,oI,"f")[t.id];if(r)return r.reconnect();r=MI(t,e,W(this,nI,"m",uI).bind(this),W(this,nI,"m",fI).bind(this)),W(this,oI,"f")[t.id]=r},mI=function(t,e){let r=W(this,oI,"f")[t.id];if(r)return r.connect();r=SI(t,e,W(this,nI,"m",uI).bind(this),W(this,nI,"m",fI).bind(this)),W(this,oI,"f")[t.id]=r},gI=function(t){return this.sourceEnv.find((e=>e.id===t))};const kI=(t,e)=>e.filter((e=>e.nodeId===t&&"PANEL"===e.contentType)),AI=t=>{try{return JSON.parse(t)}catch(t){return null}};var OI,TI,II,RI,CI,xI,PI,BI,NI,LI,DI,jI,UI,qI,FI,zI,HI,KI,VI,GI,WI,ZI,YI,XI,JI,QI,$I,tR,eR,rR,iR,nR,oR,sR,aR,hR,uR;class fR{constructor(t,e,r,i){this.treeList=t,this.poiList=e,this.plugin=r,this.cpsPlugin=i,OI.add(this),TI.set(this,{}),W(this,OI,"m",II).call(this)}batchPoi(t,e){t.nodeArray&&0!==t.nodeArray.length&&("HTTP"===t.protocol?W(this,OI,"m",xI).call(this,t.nodeArray,e):"MQTT"===t.protocol?W(this,OI,"m",RI).call(this,t.nodeArray,e):"WebSocket"===t.protocol&&W(this,OI,"m",CI).call(this,t.nodeArray,e))}}TI=new WeakMap,OI=new WeakSet,II=function(){if(this.treeList){const t=(t=>{const e=[],r={},i=(t,e)=>{for(const n of t){const{id:t,pid:o,familyId:s,name:a,renderType:h,children:u,deviceCode:f}=n,l=Object.assign(Object.assign({},n),{id:t,pid:o,familyId:s,name:a,renderType:h,children:[],deviceCode:f});e.push(l),r[t]=l,u.length>0&&i(u,l.children)}};return i(t,e),{treeNodes:e,flatNodes:r}})(this.treeList);Z(this,TI,t.flatNodes,"f")}},RI=function(t,e){const{payload:r,topic:i}=e,n=AI(r.toString()),o=null==t?void 0:t.filter((t=>{var e;return null===(e=t.eventList)||void 0===e?void 0:e.some((t=>((t,e)=>{if(t===e)return!0;const r=t.split("/"),i=e.split("/"),n=r.indexOf("#"),o=r.indexOf("+");if(-1!==n){if(-1!==o&&o<n)return r.slice(0,n).every(((t,e)=>"+"===t||t===i[e]||void 0));{const r=t.indexOf("#");if(t.slice(0,r)===e.slice(0,r))return!0}}else if(-1!==o&&r.length===i.length)return r.every(((t,e)=>"+"===t||t===i[e]||void 0));return!1})(t,i)))}));o&&W(this,OI,"m",xI).call(this,o,n)},CI=function(t,e){const{event:r,message:i}=e,n=t.filter((t=>{var e;return null===(e=t.eventList)||void 0===e?void 0:e.some((t=>t===r))}));n&&W(this,OI,"m",xI).call(this,n,i)},xI=function(t,e){if(!this.poiList)return;const r=[];for(let i=0;i<t.length;i++){const n=t[i],o=kI(n.nodeId,this.poiList),s=W(this,OI,"m",PI).call(this,e,n.matchParams||"",n.nodeId);s&&(o.forEach((t=>{if(t.contentData){const e=t.contentData.ds_user["接口数据"];if(!e)return;for(const t in s)if(Object.prototype.hasOwnProperty.call(s,t)){const r=s[t];e.hasOwnProperty(t)&&(e[t].value=r)}}})),r.push(...o))}r.length>0&&W(this,OI,"m",BI).call(this,r)},PI=function(t,e,r){const i=W(this,TI,"f")[r],n=null==i?void 0:i.deviceCode;if(i&&n)return"[object Array]"===Object.prototype.toString.call(t)?t.find((t=>String(t[e])===n)):"[object Object]"===Object.prototype.toString.call(t)?t:void 0},BI=function(t){this.plugin&&this.plugin.batchRender({dataSource:t.map(this.cpsPlugin.formatPoiData)})};class lR{constructor(t,e){this.plugin=t,this.cpsPlugin=e,NI.add(this)}listen(t){var e;const r=null===(e=this.cpsPlugin.poiData)||void 0===e?void 0:e.find(((e,r,i)=>{var n;return e.nodeId===(null===(n=null==t?void 0:t.target)||void 0===n?void 0:n.modelId)}));if(r){const e=W(this,NI,"m",LI).call(this,t,r);W(this,NI,"m",DI).call(this,[e])}}}NI=new WeakSet,LI=function(t,e){var r,i,n;const o=null==t?void 0:t.target,s=null==t?void 0:t.value,a=null==t?void 0:t.property;try{if("label"!=a&&"value"!=a)return e;const t=function(t){return $k(t,5)}(e.contentData),h=null==o?void 0:o.group,u=null==o?void 0:o.key;return(null===(n=null===(i=null===(r=null==t?void 0:t.ds_user)||void 0===r?void 0:r[h])||void 0===i?void 0:i[u])||void 0===n?void 0:n[a])&&(t.ds_user[h][u][a]=s||""),e.contentData=t,e.content=JSON.stringify(t),e}catch(t){return console.error("generatePoiDataByUserData error",t),e}},DI=function(t){this.plugin&&this.plugin.batchRender({dataSource:t.map(this.cpsPlugin.formatPoiData)})};const{groupBy:cR,warn:dR,getExtension:pR}=t.utils,mR={syncProperties:!0,syncModelVisions:!0,needsModelsBoundsTree:!0,applyPresetEffects:!0,loadSceneAlgorithm:cO.DFS,loadLevel:1/0,loadPoi:!1,refreshPoiByDataSource:!1,loadFlowData:!1,objectPrefixId:"",asId:"sid"};class gR extends p{get path(){return W(this,UI,"f")}set path(t){W(this,UI,"f")!==t&&(Z(this,qI,!0,"f"),Z(this,UI,t,"f"),this.progress.loaded=0,this.progress.total=0)}constructor(t,e){super(),this.ssp=t,jI.add(this),UI.set(this,""),qI.set(this,!0),this.progress={loaded:0,total:0},this.sceneGroup=null,this.metaData=null,this.treeData=null,this.flatData=null,this.faltDataMap=null,this.poiData=null,this.dataSourceData=null,this.topologyData=null,this.propertiesData=null,this.objectsAnimations=new Map,this.animationsData=null,this.modelVisionsData=null,this.spacesData=null,this.effectPlugin=new i(this.ssp),this.atmospherePlugin=new n(this.ssp),this.soonflow=new class{nodeTypeMethods;outInstances;constructor(t,e){this.nodeTypeMethods=t,this.outInstances=e}async parseFlow(t,e){return new jt(t,e,this.nodeTypeMethods,this.outInstances).runParse()}unregisterFlow(t,e){new Ut(t,e,this.nodeTypeMethods,this.outInstances)}}(Xi,{ssp:this.ssp,cpsManager:this}),this.flowData=null,FI.set(this,dO),zI.set(this,new bO(this.ssp.viewport)),HI.set(this,!1),KI.set(this,!1),VI.set(this,!1),GI.set(this,new Map),this.formatPoiData=t=>{const{dimensional:e,poiId:r,media:i,display:n,scale:o,x:s,y:a,z:h,rotationX:u,rotationY:f,rotationZ:l,width:c,height:d,nodeId:p,contentType:m,style:g,contentData:y}=t;return{id:r,pid:p,visible:n,width:c,height:d,type:e,contentType:m,position:{x:s,y:a,z:h},rotation:{x:Math.PI/180*u,y:Math.PI/180*f,z:Math.PI/180*l},scale:{x:o/100,y:o/100,z:o/100},style:g,dataSource:(b=y,null==b?[]:XA(b,((t,e)=>XA(t,((t,r)=>XA(t,((t,i)=>({index:t.index,value:t.value||"",group:r,key:i,label:t.label||i,customId:[e,r,i].join("/"),dataOrigin:e})))),2)))),fileUrl:(null==i?void 0:i.assetId)||(null==i?void 0:i.fileId)?(null==i?void 0:i.url)?W(this,jI,"m",rR).call(this,i.url):void 0:null==i?void 0:i.url};var b},(null==e?void 0:e.key)&&this.setKey(e.key),(null==e?void 0:e.path)&&this.setPath(e.path)}setKey(t){t!==vO(W(this,FI,"f").debugKey)&&(W(this,FI,"f").key=t)}async fetchMetaData(){const t=await W(this,jI,"m",nR).call(this,JA);return this.metaData=t,t}async fetchTreeData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,$A));return W(this,jI,"m",WI).call(this,t),t}async fetchFlatData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,tO));return this.flatData=t,this.faltDataMap=cR(t,"id"),t}async fetchPoiData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,eO));return this.poiData=t.map((t=>Object.assign(Object.assign({},t),{contentData:JSON.parse(t.content||"{}")}))),this.poiData}async fetchDataSourceData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,rO));return this.dataSourceData=t,t}async fetchTopologyData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,iO)).then((t=>{const e={linkWidth:.1,linkColor:["#00ff00"],nodeRadius:.05,nodeColor:"#0000ff"};return t.map((t=>{const r=Object.assign(Object.assign({},e),t);return r.imgUrl&&(r.imgUrl=`${this.path}${r.imgUrl}`),r}))}));return this.topologyData=t,t}async fetchPropertiesData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,nO)).then((t=>{const e=t.map((t=>{const e=this.ssp.utils.propertiesCtx;return new Proxy(t,{set:(t,r,i)=>{var n;return this.ssp.signals.propertiesChanged.dispatch({value:i,property:String(r),target:t,source:null!==(n=null==e?void 0:e.source)&&void 0!==n?n:"unknown"}),Reflect.set(t,r,i)}})}));return e})).then((t=>cR(t,"modelId")));return this.propertiesData=t,t}async fetchAnimationsData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,oO)).then((t=>cR(t,"modelId")));return this.animationsData=t,t}async fetchModelVisionsData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,sO)).then((t=>new Map(Object.entries(t))));return this.modelVisionsData=t,t}async fetchSpacesData(){const t=await W(this,jI,"m",nR).call(this,await W(this,jI,"m",iR).call(this,aO)).then((t=>wO(t,"sid")));return this.spacesData=t,t}async loadPoi(t=!1,e=!1){var i,n;const o=this.ssp.getPlugin(uO)||this.ssp.registerPlugin(r,uO);try{await this.fetchPoiData();const r=null!==(n=null===(i=this.poiData)||void 0===i?void 0:i.map(this.formatPoiData))&&void 0!==n?n:[];o.batchRender({dataSource:r}),t&&this.refreshPoiByDataSource(),e&&this.refreshByUserData()}catch(t){}}async refreshPoiByDataSource(){const t=this.ssp.getPlugin(uO)||this.ssp.registerPlugin(r,uO);try{const{dataSources:e,dataSourceApis:r}=await this.fetchDataSourceData(),i=new fR(this.treeData,this.poiData,t,this);if(e&&r){const t=new EI(e,r);t.requestAll(),t.on("onMessage",(({api:t,data:e})=>{i.batchPoi(t,e)}))}}catch(t){}}async refreshByUserData(){const t=this.ssp.getPlugin(uO)||this.ssp.registerPlugin(r,uO);try{const e=new lR(t,this);this.ssp.signals.propertiesChanged.add((t=>{e.listen(t)}))}catch(t){}}async runWithCode(t){return this.ssp.utils.runWithCode(t)}getTreeNodeById(t,e,r){if(!e)return;const i=e.find((e=>W(this,jI,"m",oR).call(this,e,r.asId)===t));if(i)return i;for(let i=0;i<e.length;i++){const n=this.getTreeNodeById(t,e[i].children,r);if(n)return n}}setPath(t){this.path=t}async loadScene(t={}){var e,r;const{key:i,path:n}=t;if(i&&this.setKey(i),n&&this.setPath(n),!this.path)return Promise.reject("请设置 path");this.flatData||await this.fetchFlatData(),this.progress.total=null!==(r=null===(e=this.flatData)||void 0===e?void 0:e.length)&&void 0!==r?r:0;const{version:o}=await this.fetchMetaData();if(o>=1.2&&W(this,qI,"f")){if(await W(this,jI,"m",XI).call(this),!W(this,HI,"f")&&!W(this,KI,"f"))return Promise.reject(`未授权的场景包:${this.path}`);!W(this,HI,"f")&&W(this,KI,"f")&&(W(this,VI,"f")||W(this,zI,"f").addToViewport()),Z(this,qI,!1,"f")}else o<1.2&&await this.fetchTreeData();const s=Object.assign(Object.assign({},mR),t);this.sceneGroup||(this.sceneGroup=this.ssp.createGroup(Object.assign({name:"root",id:this.path},s.sceneGroupInfo)));const a=[];s.syncProperties&&a.push(this.fetchPropertiesData()),s.syncModelVisions&&a.push(this.fetchModelVisionsData()),await Promise.allSettled(a),s.loadSceneAlgorithm===cO.BFS?await W(this,jI,"m",uR).call(this,s):s.loadSceneAlgorithm===cO.DFS&&await W(this,jI,"m",hR).call(this,s),this.ssp.updateAllDecalGeometry({snapping:!0,snappingDistance:1,uvMap:0});const h=[];s.applyPresetEffects&&h.push(this.presetEffects()),s.loadPoi&&h.push(this.loadPoi(s.refreshPoiByDataSource)),s.loadFlowData&&h.push(this.loadFlowData()),await Promise.allSettled(h),s.needsModelsBoundsTree&&this.ssp.computeModelsBoundsTree()}async presetEffects(t={}){var e,r,i,n,o,s,a,h,u;const{atmosphere:f=!0,hdr:l=!0,ssao:c=!0,directionalLightShadow:d=!0,toneMappping:p=!0}=t;if(await this.ssp.render(),!this.sceneGroup)return void qt("presetEffects: SceneGroup is not exist!");const g=this.sceneGroup.getBoundingBox(),{min:y,max:b}=g,v=g.getCenter(new m),w=g.getSize(new m),{environment:_,previewSettings:M}=await this.fetchMetaData(),S=null!==(e=AI(null!=M?M:""))&&void 0!==e?e:{},E=f&&(null===(r=S.atmosphere)||void 0===r?void 0:r.enabled);if(E){const{month:t,day:e,hours:r,longitude:i,latitude:n,altitude:o,groundAlbedo:s,castShadow:a}=S.atmosphere,h=W(this,jI,"m",rR).call(this,"/assets/atmosphere");Object.assign(this.atmospherePlugin,{longitude:i,latitude:n,altitude:o,groundAlbedo:s,castShadow:a}),this.atmospherePlugin.target.copy(v),this.atmospherePlugin.distance=w.length(),this.atmospherePlugin.date.setMonth(t),this.atmospherePlugin.date.setDate(e),this.atmospherePlugin.date.setHours(r/60),this.atmospherePlugin.date.setMinutes(r%60),this.atmospherePlugin.start(h)}l&&_&&"default"!==(null===(i=S.environment)||void 0===i?void 0:i.HDR)&&!E&&this.ssp.setEnvironment({file:W(this,jI,"m",rR).call(this,_),background:null===(o=null===(n=S.environment)||void 0===n?void 0:n.background)||void 0===o||o});c&&S.ssao&&(this.ssp.setSSAO(S.ssao),S.ssao.enabled&&dR("环境光遮蔽已开启,如卡顿请使用 ssp.setSSAO 关闭"));if(d&&!f){const t=`${this.path}_directionalLight`;this.ssp.removeObjectById(t);let e=null!==(a=null===(s=S.directionalLight)||void 0===s?void 0:s.degree)&&void 0!==a?a:45;this.ssp.utils.isObject(d)&&"number"==typeof d.angle&&(e=d.angle);const r=Math.tan(Math.PI/180*e)*w.x;this.ssp.createDirectionalLight({id:t,name:"directionalLight",position:{x:b.x,y:r,z:b.z},target:{x:y.x,y:y.y,z:y.z},openShadow:!0,shadowAutoUpdate:!1,intensity:null!==(u=null===(h=S.directionalLight)||void 0===h?void 0:h.intensity)&&void 0!==u?u:10,mapSize:this.ssp.viewport.renderer.capabilities.maxTextureSize/2})}p&&S.toneMappping&&this.ssp.setToneMapping(Object.assign({},S.toneMappping))}async getTopologies(){return this.fetchTopologyData()}sortTopologyNodes(t,e){var r;const i=t.nodes.reduce(((t,e)=>(t.set(e.id,e),t)),new Map);if(e&&!i.has(e))return void this.ssp.utils.error(`startNodeId ${e} 未找到对应 node`);let n=e?i.get(e):t.nodes[0];if(!n)return;const o=new Set;o.add(n);for(let e=0;e<t.nodes.length-1;e++){let t;for(const e of null!==(r=n.graphs)&&void 0!==r?r:[]){const r=i.get(e.targetNodeId);if(r&&!o.has(r)){t=r;break}}if(!t)break;n=t,o.add(n)}return Object.assign(Object.assign({},t),{nodes:[...new Set([...o,...t.nodes])]})}async playAnimationById(t,e=0,r={}){const{utils:{error:i}}=this.ssp,n=this.ssp.getObjectById(t);return n?this.playObjectAnimation(n,e,r):(i(`playAnimationById: id 为 ${t} 场景对象未找到`),!1)}async playObjectAnimation(t,e=0,{autoStopPrevious:r=!0,onStart:i,onUpdate:n}={}){var s;const a=await this.fetchAnimationsData(),{utils:{error:h}}=this.ssp,u=W(this,jI,"m",sR).call(this,t.userData),f=a.get(u);if(r&&this.stopObjectAnimation(t),f){const r=f[e];if(r)try{const e=new o(this.ssp,t);e.addEventListener("start",(({tween:t})=>null==i?void 0:i(t))),e.addEventListener("update",(({source:t,tween:e})=>null==n?void 0:n(t,e))),this.objectsAnimations.has(u)||this.objectsAnimations.set(u,new Set),null===(s=this.objectsAnimations.get(u))||void 0===s||s.add(e);const a=r.keyframes.map((t=>{var{x:e,y:r,z:i,rotationX:n,rotationY:o,rotationZ:s,scaleX:a,scaleY:h,scaleZ:u}=t,f=_(t,["x","y","z","rotationX","rotationY","rotationZ","scaleX","scaleY","scaleZ"]);return Object.assign({position:{x:e,y:r,z:i},rotation:{x:n,y:o,z:s},scale:{x:a,y:h,z:u}},f)}));return await e.play(a),!0}catch(t){}else h(`id: ${u} 未找到索引为 ${e} 的动画`)}else h(`id: ${u} 未找到动画`);return!1}async stopObjectAnimation(t){var e,r;const i=W(this,jI,"m",sR).call(this,t.userData);return!!this.objectsAnimations.has(i)&&(null===(e=this.objectsAnimations.get(i))||void 0===e||e.forEach((t=>t.stop())),null===(r=this.objectsAnimations.get(i))||void 0===r||r.clear(),!0)}async flyToSceneFromVisionsData(t=0){const{utils:{error:e}}=this.ssp;if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const r=this.modelVisionsData.get(""),i=null==r?void 0:r[t];if(i){const{camera:t,position:e,target:r,zoom:n=1}=i;return await this.ssp.setCamera("O"===t?"orthographic":"perspective",{position:e,target:r,zoom:n},!0),!0}e("场景视角数据未找到")}return!1}async flyToMainSceneFromVisionsData(t=!0){if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const t=this.modelVisionsData.get("");if(t){const e=t.findIndex((t=>t.primary));if(e>-1)return this.flyToSceneFromVisionsData(e)}}return t&&this.ssp.flyMainViewpoint(),!1}async flyToObjectFromVisionsData(t,e=0){const{utils:{error:r}}=this.ssp;if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const i=this.modelVisionsData.get(W(this,jI,"m",sR).call(this,t.userData)),n=null==i?void 0:i[e];if(n){const{camera:t,position:e,target:r,zoom:i=1}=n;return await this.ssp.setCamera("O"===t?"orthographic":"perspective",{position:e,target:r,zoom:i},!0),!0}r("对象视角数据未找到")}return!1}async flyToMainObjectFromVisionsData(t,e=!0){if(this.modelVisionsData||await this.fetchModelVisionsData(),this.modelVisionsData){const e=this.modelVisionsData.get(W(this,jI,"m",sR).call(this,t.userData));if(e){const r=e.findIndex((t=>t.primary));if(r>-1)return this.flyToObjectFromVisionsData(t,r)}}return e&&this.ssp.flyToObj(t),!1}async loadFlowData(){const t=new Ft(this.path),{flowList:e}=await t.getFlowData();return this.flowData=e,e}async runFlowById(t){if(!this.flowData)return Promise.reject("CpsManagerPlugin.runFlowById(): 请先调用 loadFlowData 获取 flowData");const e=this.flowData.find((e=>e.id===t));if(!e)return Promise.reject(`CpsManagerPlugin.runFlowById() flowData not found by flowId(${t})`);const{nodes:r,edges:i}=e;return this.soonflow.parseFlow(r,i)}async getSpaceAssets(t){var e;this.spacesData||await this.fetchSpacesData();const r=[],i=null===(e=this.spacesData)||void 0===e?void 0:e.get(W(this,jI,"m",sR).call(this,t.userData));return i&&i.assets&&i.assets.length>0&&i.assets.forEach((t=>{const e=this.ssp.getObjectByUserDataProperty("id",t);r.push(...e)})),r}}UI=new WeakMap,qI=new WeakMap,FI=new WeakMap,zI=new WeakMap,HI=new WeakMap,KI=new WeakMap,VI=new WeakMap,GI=new WeakMap,jI=new WeakSet,WI=function(t){if(!t)return;const e=t=>{W(this,jI,"m",ZI).call(this,t),Reflect.deleteProperty(t,"path"),t.children&&t.children.forEach(e)};t.forEach(e),this.treeData=t},ZI=function(t){t.path&&W(this,GI,"f").set(t.sid,t.path)},YI=function(t){var e;return null!==(e=W(this,GI,"f").get(t.sid))&&void 0!==e?e:null},XI=async function(){let e;const{resource:r}=await this.fetchMetaData();if(W(this,FI,"f").verifyKey){if(e=await W(this,jI,"m",JI).call(this,r),"forbid"===e)return void Z(this,HI,!1,"f");if("noServerEnc"===e)await W(this,jI,"m",tR).call(this,r);else{const t=W(this,FI,"f").verifyKey,{verifiedRes:r,dec:i}=W(this,jI,"m",$I).call(this,e,t);Z(this,HI,r,"f"),W(this,HI,"f")&&W(this,jI,"m",WI).call(this,i)}}else if(W(this,FI,"f").key){const{verifiedRes:t}=await W(this,jI,"m",eR).call(this,r);t||await W(this,jI,"m",tR).call(this,r)}else W(this,FI,"f").debugKey?await W(this,jI,"m",tR).call(this,r):t.utils.error("许可证密钥不存在")},JI=async function(t){const e=Math.random().toString(36).substring(2),{verifyKey:r}=W(this,FI,"f"),i=new yM(r,"pkcs8-public",{environment:"browser",signingScheme:"pkcs1-md5",encryptionScheme:"pkcs1"}),n=i.encrypt(e,"base64"),o=await W(this,jI,"m",QI).call(this,W(this,jI,"m",rR).call(this,t),n),{license:s,serverEnc:a}=o;if(!a)return"noServerEnc";return i.decryptPublic(a,"utf8")!==e?"forbid":s},QI=async function(t,e=""){try{const r=await fetch(t,{headers:{token:e}}),i=r.headers,n=await r.json();return{license:n,serverEnc:i.get("token")}}catch(t){return{license:{content:"",sign:""},serverEnc:""}}},$I=function(t,e){let r=null,i=!0;try{const i=new yM(e,"pkcs8-public",{environment:"browser",signingScheme:"pkcs1-md5",encryptionScheme:"pkcs1"});if(2===t.version)r=_O(t,i);else r=((t,e)=>{const{content:r,sign:i}=t;if(!e.verify(r,i,"base64","base64"))throw new Error("v1 error");return e.decryptPublic(r,"json")})(t,i)}catch(t){i=!1,this.ssp.utils.error("秘钥 key 验证失败")}return{verifiedRes:i,dec:r}},tR=async function(t){const e=await W(this,jI,"m",nR).call(this,t),r=vO(W(this,FI,"f").debugKey),{verifiedRes:i,dec:n}=W(this,jI,"m",$I).call(this,e,r);Z(this,KI,i,"f"),W(this,KI,"f")&&W(this,jI,"m",WI).call(this,n)},eR=async function(t){const e=await W(this,jI,"m",nR).call(this,t),r=W(this,FI,"f").key,{verifiedRes:i,dec:n}=W(this,jI,"m",$I).call(this,e,r);return Z(this,VI,i,"f"),Z(this,KI,i,"f"),W(this,VI,"f")&&W(this,jI,"m",WI).call(this,n),{verifiedRes:i,dec:n}},rR=function(t){const e=W(this,UI,"f");if(e){const r=/\?([^/?&#:]+=[^?&]+&)*[^/?&#:]+=.*$/;t=t.startsWith("/")?t:`/${t}`,t=(t=r.test(e)?encodeURIComponent(t):encodeURI(t)).replaceAll(/#/g,"%23")}return`${e}${t}`},iR=async function(t){const{resource:e}=await this.fetchMetaData();return`${t}.${pR(e)||"json"}`},nR=async function(t){const{utils:e}=this.ssp;return e.fetchFile(W(this,jI,"m",rR).call(this,t),"json")},oR=function(t,e=mR.asId){var r;return null!==(r=t[e])&&void 0!==r?r:t.id},sR=function(t){return t.sid||t.id},aR=async function(t,r){var i;const{syncProperties:n,hiddenObjects:o,objectPrefixId:s}=r,{name:a,renderType:h,matrix:u,shape:f,visible:l}=t,c=W(this,jI,"m",oR).call(this,t,r.asId),d=[t.id,t.sid],p=`${s}${c}`,{ssp:m}=this,b=(new g).fromArray(u),v=W(this,jI,"m",YI).call(this,t),w=this.ssp.getObjectById(p);if(w)return w;let _=null,M=l;if((null==o?void 0:o.has(c))&&(M=!1),"3D"===h)if(v)try{_=await m.loadModel({id:p,url:W(this,jI,"m",rR).call(this,v)})}catch(t){console.error(t)}else dR(`id: ${c} path 为空`);else if("GROUP"===h||"STUB"===h)_=m.createGroup({id:p});else if("POLYGON"===h||"CIRCLE"===h){const t=m.createCanvas3D({id:p});f&&("POLYGON"===h&&f.points?t.createPolygon({id:`polygon/${p}`,yHeight:f.height,points:f.points,color:"blue",opacity:.5}):"CIRCLE"===h&&t.createCircle({id:`circle/${p}`,radius:f.radius,color:"blue",opacity:.5})),_=t}else!function(t){return"AREA"===t||"FLOOR"===t||"ROOM"===t}(t.renderType)?"WATER_SURFACE"===h?_=function(t,e,r){var i,n,o,s,a;const{effectPlugin:h}=t,{name:u,shape:f,extra:l={}}=e;return f&&f.points&&f.points.length>0?h.createWater({id:r,name:u,polygon:f.points,sunColor:null!==(i=l.sunColor)&&void 0!==i?i:"#ffffff",waterColor:null!==(n=l.waterColor)&&void 0!==n?n:"#7F7F7F",distortionScale:null!==(o=l.distortionScale)&&void 0!==o?o:20,alpha:null!==(s=l.alpha)&&void 0!==s?s:1,speed:null!==(a=l.speed)&&void 0!==a?a:1}):null}(this,t,p):"DECAL"===h?_=await async function(t,e,r,i){const{name:n}=e;return i?await t.createDecal({id:r,name:n,url:i,snapping:!1}):null}(this.ssp,t,p,v):"GS"===h&&v&&(_=await async function(t,r,i){const n=new y(t),o=new e(r);if(t.addObject(o),i){const t=await n.load(i);o.add(t)}return o}(this.ssp,t,W(this,jI,"m",rR).call(this,v))):_=function(t,e,r){const{name:i,shape:n,extra:o}=e,s=t.createCanvas3D({id:r,name:i});if((null==n?void 0:n.points)&&n.points.length>0){const{points:t}=n;s.createPolygon({id:`${r}/polygon`,points:t,depth:(null==n?void 0:n.depth)||0,yHeight:(null==n?void 0:n.height)||0,color:(null==o?void 0:o.color)||"#00f",opacity:(null==o?void 0:o.alpha)||.5})}return s}(this.ssp,t,p);if(_){!1===M&&_.hide(),_.name=a,_.extraIds=d,b.decompose(_.position,_.quaternion,_.scale);const e=Object.assign({},t);if(Reflect.deleteProperty(e,"children"),_.userData=e,n&&this.propertiesData){const t=this.propertiesData.get(c);t&&(_.userData[hO]=t)}}return(null===(i=this.faltDataMap)||void 0===i?void 0:i.has(t.id))&&(this.progress.loaded+=1,this.dispatchEvent({type:"progressing",progress:this.progress})),_},hR=async function(t){if(!this.treeData)throw new TypeError("treeData is null");const{loadLevel:e,loadTargetId:r}=t;let i=this.treeData;if(r){const e=this.getTreeNodeById(r,this.treeData,t);if(!e)throw new ReferenceError("根据 loadTargetId 未找到对应树节点");i=[e]}else i=this.treeData;const n=async(r,i,o=0)=>{if(o++,e&&o>e)return;const{ssp:s}=this,a=await W(this,jI,"m",aR).call(this,r,t);a&&s.addObject(a,null!=i?i:this.sceneGroup),await Promise.allSettled(r.children.map((t=>n(t,a,o))))};await Promise.allSettled(i.map((t=>n(t,t.pid?this.ssp.getObjectByUserDataProperty("id",t.pid)[0]:null,0))))},uR=async function(t){if(!this.treeData)throw new TypeError("treeData is null");const e=[],r=Object.create(null),i=[],{ssp:n}=this;for(e.push(...this.treeData);e.length>0;){e.splice(0,e.length).forEach((t=>{i.push(t),e.push(...t.children.map((e=>(r[e.id]=t.id,e))))}))}await Promise.allSettled(i.map((e=>W(this,jI,"m",aR).call(this,e,t)))),Object.entries(r).forEach((([t,e])=>{const r=n.getObjectById(t),i=n.getObjectById(e);r&&n.addObject(r,null!=i?i:this.sceneGroup)}))};export{oO as ANIMATIONS_DATA_FILE_PATH,rO as DATA_SOURCE_FILE_PATH,tO as FLAT_DATA_FILE_PATH,cO as LoadSceneAlgorithm,JA as META_DATA_FILE_PATH,sO as MODEL_VISIONS_DATA_FILE_PATH,eO as POI_DATA_FILE_PATH,uO as POI_PLUGIN_NAME,nO as PROPERTIES_DATA_FLEE_PATH,hO as PROPERTIES_KEY,fO as PoiContentTypeEnum,aO as SPACES_DATA_FILE_PATH,iO as TOPOLOGY_DATA_FILE_PATH,$A as TREE_DATA_FILE_PATH,gR as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-cps-soonmanager",
3
3
  "pluginName": "CpsSoonmanagerPlugin",
4
- "version": "2.13.9",
4
+ "version": "2.13.10",
5
5
  "description": "Sync cps soonmanager data plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "author": "xunwei",
15
15
  "license": "UNLICENSED",
16
- "gitHead": "a5596909f48bd136905b85f239e13690f9f2c66e",
16
+ "gitHead": "6bca3b98477ef9c2fa0ba5f67d461561896bb0ff",
17
17
  "dependencyPlugins": [
18
18
  "plugin-poi-renderer",
19
19
  "plugin-effect",
@@ -33,11 +33,11 @@
33
33
  "socket.io-client": "^4.7.2"
34
34
  },
35
35
  "peerDependencies": {
36
- "@soonspacejs/plugin-atmosphere": "2.13.9",
37
- "@soonspacejs/plugin-effect": "2.13.9",
38
- "@soonspacejs/plugin-gs3d-loader": "2.13.9",
39
- "@soonspacejs/plugin-poi-renderer": "2.13.9",
40
- "soonspacejs": "2.13.9",
36
+ "@soonspacejs/plugin-atmosphere": "2.13.10",
37
+ "@soonspacejs/plugin-effect": "2.13.10",
38
+ "@soonspacejs/plugin-gs3d-loader": "2.13.10",
39
+ "@soonspacejs/plugin-poi-renderer": "2.13.10",
40
+ "soonspacejs": "2.13.10",
41
41
  "umanager-animation-parser": "^0.0.6"
42
42
  }
43
43
  }