@amityco/ts-sdk 0.0.1-beta.21 → 0.0.1-beta.24
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/@types/domains/channel.d.ts +1 -2
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +5 -2
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +2 -2
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/reaction.d.ts +1 -1
- package/dist/@types/domains/reaction.d.ts.map +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts +2 -1
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts +1 -0
- package/dist/channel/api/queryChannels.d.ts.map +1 -1
- package/dist/channel/api/updateChannel.d.ts +1 -1
- package/dist/channel/api/updateChannel.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts +3 -1
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/comment/api/queryComments.d.ts +1 -0
- package/dist/comment/api/queryComments.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts +1 -0
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/query/query.d.ts.map +1 -1
- package/dist/index.cjs.js +204 -68
- package/dist/index.esm.js +203 -68
- package/dist/index.umd.js +5 -5
- package/dist/message/api/createMessage.d.ts +2 -2
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/api/updateMessage.d.ts +2 -2
- package/dist/message/api/updateMessage.d.ts.map +1 -1
- package/dist/message/events/onMessageUpdated.d.ts.map +1 -1
- package/dist/reaction/events/onReactionAdded.d.ts.map +1 -1
- package/dist/reaction/utils/index.d.ts +1 -0
- package/dist/reaction/utils/index.d.ts.map +1 -1
- package/dist/reaction/utils/prepareMessagePayloadForCache.d.ts +3 -0
- package/dist/reaction/utils/prepareMessagePayloadForCache.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +1 -2
- package/src/@types/domains/content.ts +7 -1
- package/src/@types/domains/message.ts +2 -1
- package/src/@types/domains/reaction.ts +1 -1
- package/src/channel/api/queryChannelMembers.ts +4 -4
- package/src/channel/api/queryChannels.ts +1 -0
- package/src/channel/api/updateChannel.ts +1 -1
- package/src/client/api/connectClient.ts +12 -7
- package/src/comment/api/queryComments.ts +6 -3
- package/src/core/model/identifyModel.ts +18 -0
- package/src/core/query/paging.ts +3 -3
- package/src/core/query/query.ts +19 -1
- package/src/message/api/createMessage.ts +24 -8
- package/src/message/api/updateMessage.ts +2 -2
- package/src/message/events/onMessageUpdated.ts +9 -1
- package/src/reaction/events/onReactionAdded.ts +4 -0
- package/src/reaction/utils/index.ts +1 -0
- package/src/reaction/utils/prepareMessagePayloadForCache.ts +40 -0
package/dist/index.umd.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var Amity=function(e){"use strict";var t;const n="object"==typeof globalThis?globalThis:"object"==typeof global?global:window,{process:r={}}=n,o="production"===(null===(t=r.env)||void 0===t?void 0:t.NODE_ENV);var i,s;const a=null!==(s=null===(i=r.env)||void 0===i?void 0:i.VERSION)&&void 0!==s?s:"__dev__",c="function"==typeof atob,l="function"==typeof btoa,u="function"==typeof Buffer,h="function"==typeof TextDecoder?new TextDecoder:void 0,f="function"==typeof TextEncoder?new TextEncoder:void 0,p=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),d=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(p),m=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,g=String.fromCharCode.bind(String),y="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),v=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),b=l?e=>btoa(e):u?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,n,r,o,i="";const s=e.length%3;for(let s=0;s<e.length;){if((n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255||(o=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|o,i+=p[t>>18&63]+p[t>>12&63]+p[t>>6&63]+p[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},w=u?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(g.apply(null,e.subarray(n,n+4096)));return b(t.join(""))},C=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?g(192|t>>>6)+g(128|63&t):g(224|t>>>12&15)+g(128|t>>>6&63)+g(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return g(240|t>>>18&7)+g(128|t>>>12&63)+g(128|t>>>6&63)+g(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,k=u?e=>Buffer.from(e,"utf8").toString("base64"):f?e=>w(f.encode(e)):e=>b(e.replace(_,C)),S=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,E=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return g(55296+(t>>>10))+g(56320+(1023&t));case 3:return g((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return g((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},A=c?e=>atob(v(e)):u?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!m.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,o="";for(let i=0;i<e.length;)t=d[e.charAt(i++)]<<18|d[e.charAt(i++)]<<12|(n=d[e.charAt(i++)])<<6|(r=d[e.charAt(i++)]),o+=64===n?g(t>>16&255):64===r?g(t>>16&255,t>>8&255):g(t>>16&255,t>>8&255,255&t);return o},T=u?e=>y(Buffer.from(e,"base64")):e=>y(A(e),(e=>e.charCodeAt(0))),x=u?e=>Buffer.from(e,"base64").toString("utf8"):h?e=>h.decode(T(e)):e=>A(e).replace(S,E),I=e=>x(v(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),O=e=>["skip","limit"].some((t=>t in e)),R=e=>["after","before","first","last","limit"].some((t=>t in e)),P=e=>"limit"in e,B=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),F=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t&&R(e)?Number.isNaN(null==e?void 0:e.before)?Number.isNaN(null==e?void 0:e.after)?Number.isNaN(null==e?void 0:e.limit)||(r={last:e.limit}):r={after:e.after,first:e.limit}:r={before:e.before,last:e.limit}:"afterbeforeraw"===t&&(r=e),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(k(e)):k(e))(JSON.stringify(r)):void 0},N=e=>{if(!e)return;const t=JSON.parse(I(e));if(O(t))return{after:t.skip,limit:t.limit};if(R(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}},j=e=>{if(!e)return;const t=JSON.parse(I(e));return P(t)?t:void 0},M=e=>"locally"in e,U=e=>"optimistically"in e,L=e=>M(e)||U(e),D=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),q=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},z=(e,...t)=>({func:e,args:t}),$=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},H=({func:e,args:t},n,r=$("cache_then_server"))=>{let o;if(L(e)&&0!==r.lifeSpan){try{o=U(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(V(void 0,{origin:"local",loading:!1,error:e}))}const i=D(o)&&q(o,r.lifeSpan);if(null==n||n(V(o,{origin:"local",loading:!(M(e)&&i)})),i)return}else null==n||n(V(void 0,{origin:"local",loading:!0}));e(...t).then((e=>{null==n||n(V(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(V(void 0,{origin:"server",loading:!1,error:e}))}))};function V(e,t){return B(e)||D(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class W extends Error{constructor(e,t,n){super(`Amity SDK (${t}): ${e}`),this.code=t,this.level=n,this.type="ASC",this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,W)}}class K extends W{constructor(e,t,n){super(e,t,n)}}class Q extends W{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class J extends W{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let Y=null;const X=()=>{if(!Y)throw new W("There is no active client",8e5,"fatal");return Y},G=e=>{Y=e};let Z,ee=[];const te=["disconnected","error","connect_error","reconnect_error","reconnect_failed","v3.channel.didUpdate","v3.channel.didUpdate","v3.channel.didJoin","v3.channel.didLeave","v3.channel.didAddUsers","v3.channel.didRemoveUsers","v3.channel.didBan","v3.channel.didUnban","v3.message.didCreate","v3.message.didUpdate","v3.message.didDelete"],ne=["connect","message","disconnect","error","close","end","reconnect"],re=()=>{return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}};var e},oe=(e,t,n,r)=>{const{log:o,emitter:i}=e,s=Date.now();o(`${t}(tmpid: ${s}) > listen`);const a=(...e)=>{o(`${t}(tmpid: ${s}) > trigger`,e),r(...e)};return i.on(n,a),()=>{o(`${t}(tmpid: ${s}) > dispose`),i.off(n,a)}},ie=(e,t)=>{const{emitter:n}=X();var r;r=()=>{n.emit(e,t)},clearTimeout(Z),ee.push(r),Z=setTimeout((()=>{ee.forEach((e=>e())),ee=[]}),0)};let se=null;const ae=()=>{if(!se)throw new W("Connect client first",8e5,"fatal");return se};var ce;e.SubscriptionLevels=void 0,(ce=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",ce.POST="post",ce.COMMENT="comment",ce.POST_AND_COMMENT="post_and_comment",ce.USER="user";const le=(e,t)=>{switch(t){case"post":return`${e}/post/+`;case"comment":return`${e}/post/+/comment/+`;case"post_and_comment":return`${e}/post/#`;default:return e}},ue=()=>{const e=ae(),[t]=e.path.split("/user/");return t};let he,fe;function pe(e,t){const{mqtt:n,emitter:r,accessToken:o}=X(),i=ae();return he===o&&fe===i._id||(he=o,fe=i._id,n.connect({accessToken:he,userId:fe}),((e,t)=>{ne.forEach((n=>{e.on(n,((...e)=>t.emit(n,1===e.length?e[0]:e)))})),e.on("message",((e,n)=>{const r=JSON.parse(n.toString());t.emit(r.eventType,r.data)}))})(n,r)),n.subscribe(e,t)}var de="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ge(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const ye=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:ve}=Object.prototype,{propertyIsEnumerable:be}=Object,we=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),Ce=de,_e={concatArrays:!1,ignoreUndefined:!1},ke=e=>{const t=[];for(const n in e)ve.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)be.call(e,r)&&t.push(r)}return t};function Se(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return ke(e).forEach((n=>{we(t,n,Se(e[n]))})),t}(e):ye(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return ke(e).forEach((n=>{we(t,n,Se(e[n]))})),t}(e):e}const Ee=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?we(e,n,Ae(e[n],t[n],r)):we(e,n,Se(t[n])))})),e);function Ae(e,t,n){return n.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,n)=>{let r=e.slice(0,0),o=0;return[e,t].forEach((t=>{const i=[];for(let n=0;n<t.length;n++)ve.call(t,n)&&(i.push(String(n)),we(r,o++,t===e?t[n]:Se(t[n])));r=Ee(r,t,ke(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):ye(t)&&ye(e)?Ee(e,t,ke(t),n):Se(t)}const Te=function(...e){const t=Ae(Se(_e),this!==Ce&&this||{},_e);let n={_:{}};for(const r of e)if(void 0!==r){if(!ye(r))throw new TypeError("`"+r+"` is not an Option Object");n=Ae(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0});function xe(e,t){return new Promise(((n,r)=>{try{const r=e();null==t||t(null,r),n(r)}catch(e){null==t||t(e),r(e)}}))}function Ie(e,t,n){return Promise.all(e).then((e=>{var r;const o=null!==(r=null==n?void 0:n(e))&&void 0!==r?r:null;return null==t||t(null,o),Promise.resolve(o)}),(e=>(null==t||t(e),Promise.reject(e))))}const Oe={getItem:(e,t)=>xe((()=>window.localStorage.getItem(e)),t),setItem:(e,t,n)=>xe((()=>window.localStorage.setItem(e,t)),n),removeItem:(e,t)=>xe((()=>window.localStorage.removeItem(e)),t),mergeItem:(e,t,n)=>xe((()=>function(e,t){const n=window.localStorage.getItem(e);if(n){const r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(Te(r,o));window.localStorage.setItem(e,i)}else window.localStorage.setItem(e,t)}(e,t)),n),clear:e=>xe((()=>window.localStorage.clear()),e),getAllKeys:e=>xe((()=>{const e=window.localStorage.length,t=[];for(let n=0;n<e;n+=1){const e=window.localStorage.key(n)||"";t.push(e)}return t}),e),flushGetRequests:()=>{},multiGet:(e,t)=>Ie(e.map((e=>Oe.getItem(e))),t,(t=>t.map(((t,n)=>[e[n],t])))),multiSet:(e,t)=>Ie(e.map((e=>Oe.setItem(e[0],e[1]))),t),multiRemove:(e,t)=>Ie(e.map((e=>Oe.removeItem(e))),t),multiMerge:(e,t)=>Ie(e.map((e=>{var t,n;return null!==(t=null===(n=Oe.mergeItem)||void 0===n?void 0:n.call(Oe,e[0],e[1]))&&void 0!==t?t:Promise.reject("Not implemented")})),t)},Re=e=>JSON.stringify(e,((e,t)=>{return"object"==typeof t?(n=t,Object.keys(n).sort().reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:n[t]})),{})):t;var n})),Pe=e=>JSON.parse(e),Be=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>Be(e[n],t[n])))),Fe=e=>{const{log:t,cache:n}=X();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=Pe(t);return Be(e,n)})).map((e=>n.data[e]))},Ne=e=>{const{log:t,cache:n}=X();if(!n)return;t("cache/api/pullFromCache",e);const r=Re(e);return n.data[r]?n.data[r]:void 0},je=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=X();if(!o)return!1;r("cache/api/pushToCache",{key:e,data:t,options:n}),!(null==n?void 0:n.hasOwnProperty("offline"))&&o.persistIf&&(n.offline=o.persistIf(e,t));const i=Re(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},Me=(e,t,n)=>{const{log:r,cache:o}=X();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=Ne(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return je(e,s,n),!0},Ue=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=X();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return Ne(e)?Me(e,t,n):je(e,t,n)},Le=(e,t=!1)=>{const{log:n,cache:r}=X();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>Pe(e))).filter((t=>Be(e,t))).map((e=>Le(e,!0))).every((e=>e));const o=Re(e);return o in r.data&&(delete r.data[o],!0)};var De={exports:{}},qe=1e3,ze=6e4,$e=60*ze,He=24*$e,Ve=7*He,We=365.25*He,Ke=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*We;case"weeks":case"week":case"w":return n*Ve;case"days":case"day":case"d":return n*He;case"hours":case"hour":case"hrs":case"hr":case"h":return n*$e;case"minutes":case"minute":case"mins":case"min":case"m":return n*ze;case"seconds":case"second":case"secs":case"sec":case"s":return n*qe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=He)return Qe(e,t,He,"day");if(t>=$e)return Qe(e,t,$e,"hour");if(t>=ze)return Qe(e,t,ze,"minute");if(t>=qe)return Qe(e,t,qe,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=He)return Math.round(e/He)+"d";if(t>=$e)return Math.round(e/$e)+"h";if(t>=ze)return Math.round(e/ze)+"m";if(t>=qe)return Math.round(e/qe)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Qe(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var Je=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Ke,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Je(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(De,De.exports);var Ye=De.exports;const Xe={EU:"eu",SG:"sg",US:"us"},Ge={http:"https://api.{region}.amity.co",mqtt:"wss://sse.{region}.amity.co:443/mqtt"};function Ze(e,t){return Ge[e].replace("{region}",t)}var et={exports:{}},tt=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},nt=tt,rt=Object.prototype.toString;function ot(e){return"[object Array]"===rt.call(e)}function it(e){return void 0===e}function st(e){return null!==e&&"object"==typeof e}function at(e){if("[object Object]"!==rt.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ct(e){return"[object Function]"===rt.call(e)}function lt(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),ot(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var ut={isArray:ot,isArrayBuffer:function(e){return"[object ArrayBuffer]"===rt.call(e)},isBuffer:function(e){return null!==e&&!it(e)&&null!==e.constructor&&!it(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:st,isPlainObject:at,isUndefined:it,isDate:function(e){return"[object Date]"===rt.call(e)},isFile:function(e){return"[object File]"===rt.call(e)},isBlob:function(e){return"[object Blob]"===rt.call(e)},isFunction:ct,isStream:function(e){return st(e)&&ct(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:lt,merge:function e(){var t={};function n(n,r){at(t[r])&&at(n)?t[r]=e(t[r],n):at(n)?t[r]=e({},n):ot(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)lt(arguments[r],n);return t},extend:function(e,t,n){return lt(t,(function(t,r){e[r]=n&&"function"==typeof t?nt(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},ht=ut;function ft(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var pt=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(ht.isURLSearchParams(t))r=t.toString();else{var o=[];ht.forEach(t,(function(e,t){null!=e&&(ht.isArray(e)?t+="[]":e=[e],ht.forEach(e,(function(e){ht.isDate(e)?e=e.toISOString():ht.isObject(e)&&(e=JSON.stringify(e)),o.push(ft(t)+"="+ft(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},dt=ut;function mt(){this.handlers=[]}mt.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},mt.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},mt.prototype.forEach=function(e){dt.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var gt=mt,yt=ut,vt=function(e){return!(!e||!e.__CANCEL__)},bt=ut,wt=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},Ct=function(e,t,n,r,o){var i=new Error(e);return wt(i,t,n,r,o)},_t=Ct,kt=ut,St=kt.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),kt.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),kt.isString(r)&&s.push("path="+r),kt.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Et=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},At=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Tt=ut,xt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],It=ut,Ot=It.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=It.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},Rt=ut,Pt=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(_t("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},Bt=St,Ft=pt,Nt=function(e,t){return e&&!Et(t)?At(e,t):t},jt=function(e){var t,n,r,o={};return e?(Tt.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=Tt.trim(e.substr(0,r)).toLowerCase(),n=Tt.trim(e.substr(r+1)),t){if(o[t]&&xt.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},Mt=Ot,Ut=Ct,Lt=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;Rt.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(s+":"+a)}var c=Nt(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),Ft(c,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in i?jt(i.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:r,config:e,request:i};Pt(t,n,o),i=null}},i.onabort=function(){i&&(n(Ut("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(Ut("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(Ut(t,e,"ECONNABORTED",i)),i=null},Rt.isStandardBrowserEnv()){var l=(e.withCredentials||Mt(c))&&e.xsrfCookieName?Bt.read(e.xsrfCookieName):void 0;l&&(o[e.xsrfHeaderName]=l)}if("setRequestHeader"in i&&Rt.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),Rt.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),n(e),i=null)})),r||(r=null),i.send(r)}))},Dt=ut,qt=function(e,t){bt.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},zt={"Content-Type":"application/x-www-form-urlencoded"};function $t(e,t){!Dt.isUndefined(e)&&Dt.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Ht,Vt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Ht=Lt),Ht),transformRequest:[function(e,t){return qt(t,"Accept"),qt(t,"Content-Type"),Dt.isFormData(e)||Dt.isArrayBuffer(e)||Dt.isBuffer(e)||Dt.isStream(e)||Dt.isFile(e)||Dt.isBlob(e)?e:Dt.isArrayBufferView(e)?e.buffer:Dt.isURLSearchParams(e)?($t(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Dt.isObject(e)?($t(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};Vt.headers={common:{Accept:"application/json, text/plain, */*"}},Dt.forEach(["delete","get","head"],(function(e){Vt.headers[e]={}})),Dt.forEach(["post","put","patch"],(function(e){Vt.headers[e]=Dt.merge(zt)}));var Wt=Vt,Kt=ut,Qt=function(e,t,n){return yt.forEach(n,(function(n){e=n(e,t)})),e},Jt=vt,Yt=Wt;function Xt(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Gt=ut,Zt=function(e,t){t=t||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function a(e,t){return Gt.isPlainObject(e)&&Gt.isPlainObject(t)?Gt.merge(e,t):Gt.isPlainObject(t)?Gt.merge({},t):Gt.isArray(t)?t.slice():t}function c(r){Gt.isUndefined(t[r])?Gt.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}Gt.forEach(r,(function(e){Gt.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),Gt.forEach(o,c),Gt.forEach(i,(function(r){Gt.isUndefined(t[r])?Gt.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),Gt.forEach(s,(function(r){r in t?n[r]=a(e[r],t[r]):r in e&&(n[r]=a(void 0,e[r]))}));var l=r.concat(o).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return Gt.forEach(u,c),n},en=ut,tn=pt,nn=gt,rn=function(e){return Xt(e),e.headers=e.headers||{},e.data=Qt(e.data,e.headers,e.transformRequest),e.headers=Kt.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Kt.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Yt.adapter)(e).then((function(t){return Xt(e),t.data=Qt(t.data,t.headers,e.transformResponse),t}),(function(t){return Jt(t)||(Xt(e),t&&t.response&&(t.response.data=Qt(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},on=Zt;function sn(e){this.defaults=e,this.interceptors={request:new nn,response:new nn}}sn.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=on(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[rn,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},sn.prototype.getUri=function(e){return e=on(this.defaults,e),tn(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},en.forEach(["delete","get","head","options"],(function(e){sn.prototype[e]=function(t,n){return this.request(on(n||{},{method:e,url:t,data:(n||{}).data}))}})),en.forEach(["post","put","patch"],(function(e){sn.prototype[e]=function(t,n,r){return this.request(on(r||{},{method:e,url:t,data:n}))}}));var an=sn;function cn(e){this.message=e}cn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},cn.prototype.__CANCEL__=!0;var ln=cn,un=ln;function hn(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new un(e),t(n.reason))}))}hn.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},hn.source=function(){var e;return{token:new hn((function(t){e=t})),cancel:e}};var fn=hn,pn=ut,dn=tt,mn=an,gn=Zt;function yn(e){var t=new mn(e),n=dn(mn.prototype.request,t);return pn.extend(n,mn.prototype,t),pn.extend(n,t),n}var vn=yn(Wt);vn.Axios=mn,vn.create=function(e){return yn(gn(vn.defaults,e))},vn.Cancel=ln,vn.CancelToken=fn,vn.isCancel=vt,vn.all=function(e){return Promise.all(e)},vn.spread=function(e){return function(t){return e.apply(null,t)}},vn.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},et.exports=vn,et.exports.default=vn;var bn=et.exports,wn={exports:{}};wn.exports=_n;var Cn=wn.exports.HttpsAgent=_n;function _n(){}var kn=wn.exports;const Sn=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new Q(e.code);if("error"===e.status)throw new K(e.message,e.code,"error")},En=(e,t)=>Object.entries(e).filter((([,e])=>void 0!==e)).map((([e,n])=>{const r=t?`${t}[${e}]`:e;return Array.isArray(n)?n.map((e=>`${r}[]=${e}`)).join("&"):"object"!=typeof n?`${r}=${n}`:En(n,null!=t?t:e)})).join("&"),An=e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=bn.create({baseURL:e,httpAgent:new kn(t),httpsAgent:new Cn(t),paramsSerializer:En});return n.interceptors.response.use((e=>e),(e=>{var t;const{response:n}=e;console.error(null!==(t=null==n?void 0:n.data)&&void 0!==t?t:e),n&&Sn(n.data)})),n};var Tn={exports:{}},xn=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,In=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],On=function(e){var t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));for(var o=xn.exec(e||""),i={},s=14;s--;)i[In[s]]=o[s]||"";return-1!=n&&-1!=r&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i},Rn={exports:{}},Pn={exports:{}},Bn=1e3,Fn=6e4,Nn=60*Fn,jn=24*Nn,Mn=365.25*jn,Un=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Mn;case"days":case"day":case"d":return n*jn;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Nn;case"minutes":case"minute":case"mins":case"min":case"m":return n*Fn;case"seconds":case"second":case"secs":case"sec":case"s":return n*Bn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return Ln(e,jn,"day")||Ln(e,Nn,"hour")||Ln(e,Fn,"minute")||Ln(e,Bn,"second")||e+" ms"}(e):function(e){if(e>=jn)return Math.round(e/jn)+"d";if(e>=Nn)return Math.round(e/Nn)+"h";if(e>=Fn)return Math.round(e/Fn)+"m";if(e>=Bn)return Math.round(e/Bn)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ln(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Un,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Pn,Pn.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Pn.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(Rn,Rn.exports);var Dn=On,qn=Rn.exports("socket.io-client:url"),zn=function(e,t){var n=e;t=t||"undefined"!=typeof location&&location,null==e&&(e=t.protocol+"//"+t.host);"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?t.protocol+e:t.host+e),/^(https?|wss?):\/\//.test(e)||(qn("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),qn("parse %s",e),n=Dn(e));n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443"));n.path=n.path||"/";var r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port,n.href=n.protocol+"://"+r+(t&&t.port===n.port?"":":"+n.port),n};var $n={},Hn={exports:{}},Vn={exports:{}},Wn=1e3,Kn=6e4,Qn=60*Kn,Jn=24*Qn,Yn=365.25*Jn,Xn=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Yn;case"days":case"day":case"d":return n*Jn;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Qn;case"minutes":case"minute":case"mins":case"min":case"m":return n*Kn;case"seconds":case"second":case"secs":case"sec":case"s":return n*Wn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return Gn(e,Jn,"day")||Gn(e,Qn,"hour")||Gn(e,Kn,"minute")||Gn(e,Wn,"second")||e+" ms"}(e):function(e){if(e>=Jn)return Math.round(e/Jn)+"d";if(e>=Qn)return Math.round(e/Qn)+"h";if(e>=Kn)return Math.round(e/Kn)+"m";if(e>=Wn)return Math.round(e/Wn)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Gn(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Xn,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Vn,Vn.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Vn.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(Hn,Hn.exports);var Zn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(Zn);var er={},tr={}.toString,nr=Array.isArray||function(e){return"[object Array]"==tr.call(e)},rr=function(e){return or&&Buffer.isBuffer(e)||ir&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},or="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,ir="function"==typeof ArrayBuffer;var sr=nr,ar=rr,cr=Object.prototype.toString,lr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===cr.call(Blob),ur="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===cr.call(File);function hr(e,t){if(!e)return e;if(ar(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(sr(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=hr(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=hr(e[i],t);return r}return e}function fr(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(sr(e))for(var n=0;n<e.length;n++)e[n]=fr(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=fr(e[r],t);return e}er.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=hr(n,t),r.attachments=t.length,{packet:r,buffers:t}},er.reconstructPacket=function(e,t){return e.data=fr(e.data,t),e.attachments=void 0,e},er.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(lr&&o instanceof Blob||ur&&o instanceof File){n++;var a=new FileReader;a.onload=function(){s?s[i]=this.result:r=this.result,--n||t(r)},a.readAsArrayBuffer(o)}else if(sr(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!ar(o))for(var l in o)e(o[l],l,o)}(r),n||t(r)},function(e){var t=Hn.exports("socket.io-parser"),n=Zn.exports,r=er,o=nr,i=rr;function s(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=s,e.Decoder=l;var a=e.ERROR+'"encode error"';function c(n){var r=""+n.type;if(e.BINARY_EVENT!==n.type&&e.BINARY_ACK!==n.type||(r+=n.attachments+"-"),n.nsp&&"/"!==n.nsp&&(r+=n.nsp+","),null!=n.id&&(r+=n.id),null!=n.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(n.data);if(!1===o)return a;r+=o}return t("encoded %j as %s",n,r),r}function l(){this.reconstructor=null}function u(e){this.reconPack=e,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}s.prototype.encode=function(n,o){(t("encoding packet %j",n),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type)?function(e,t){function n(e){var n=r.deconstructPacket(e),o=c(n.packet),i=n.buffers;i.unshift(o),t(i)}r.removeBlobs(e,n)}(n,o):o([c(n)])},n(l.prototype),l.prototype.add=function(n){var r;if("string"==typeof n)r=function(n){var r=0,i={type:Number(n.charAt(0))};if(null==e.types[i.type])return h("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s=r+1;"-"!==n.charAt(++r)&&r!=n.length;);var a=n.substring(s,r);if(a!=Number(a)||"-"!==n.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(a)}if("/"===n.charAt(r+1)){for(s=r+1;++r;){if(","===(l=n.charAt(r)))break;if(r===n.length)break}i.nsp=n.substring(s,r)}else i.nsp="/";var c=n.charAt(r+1);if(""!==c&&Number(c)==c){for(s=r+1;++r;){var l;if(null==(l=n.charAt(r))||Number(l)!=l){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==u&&(i.type===e.ERROR||o(u))))return h("invalid payload");i.data=u}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new u(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!i(n)&&!n.base64)throw new Error("Unknown type: "+n);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(n))&&(this.reconstructor=null,this.emit("decoded",r))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},u.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=r.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},u.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}($n);var pr={exports:{}},dr={},mr={exports:{}};try{mr.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){mr.exports=!1}var gr=mr.exports,yr=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||gr))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&r)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},vr={exports:{}},br={},wr=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},Cr={}.toString,_r=Array.isArray||function(e){return"[object Array]"==Cr.call(e)},kr=Object.prototype.toString,Sr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===kr.call(Blob),Er="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===kr.call(File),Ar=function e(t){if(!t||"object"!=typeof t)return!1;if(_r(t)){for(var n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||Sr&&t instanceof Blob||Er&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&e(t[o]))return!0;return!1};var Tr=function(e,t,n){var r=e.byteLength;if(t=t||0,n=n||r,e.slice)return e.slice(t,n);if(t<0&&(t+=r),n<0&&(n+=r),n>r&&(n=r),t>=r||t>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(e),i=new Uint8Array(n-t),s=t,a=0;s<n;s++,a++)i[a]=o[s];return i.buffer},xr=function(e,t,n){var r=!1;return n=n||Ir,o.count=e,0===e?t():o;function o(e,i){if(o.count<=0)throw new Error("after called too many times");--o.count,e?(r=!0,t(e),t=n):0!==o.count||r||t(null,i)}};function Ir(){}
|
|
2
|
-
/*! https://mths.be/utf8js v2.1.2 by @mathias */var Or,Rr,Pr,Br=String.fromCharCode;function Fr(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function Nr(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function jr(e,t){return Br(e>>t&63|128)}function Mr(e,t){if(0==(4294967168&e))return Br(e);var n="";return 0==(4294965248&e)?n=Br(e>>6&31|192):0==(4294901760&e)?(Nr(e,t)||(e=65533),n=Br(e>>12&15|224),n+=jr(e,6)):0==(4292870144&e)&&(n=Br(e>>18&7|240),n+=jr(e,12),n+=jr(e,6)),n+=Br(63&e|128)}function Ur(){if(Pr>=Rr)throw Error("Invalid byte index");var e=255&Or[Pr];if(Pr++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function Lr(e){var t,n;if(Pr>Rr)throw Error("Invalid byte index");if(Pr==Rr)return!1;if(t=255&Or[Pr],Pr++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|Ur())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|Ur()<<6|Ur())>=2048)return Nr(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|Ur()<<12|Ur()<<6|Ur())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var Dr={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Fr(e),o=r.length,i=-1,s="";++i<o;)s+=Mr(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;Or=Fr(e),Rr=Or.length,Pr=0;for(var r,o=[];!1!==(r=Lr(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=Br((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Br(t);return o}(o)}},qr={};!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=new Uint8Array(256),n=0;n<e.length;n++)t[e.charCodeAt(n)]=n;qr.encode=function(t){var n,r=new Uint8Array(t),o=r.length,i="";for(n=0;n<o;n+=3)i+=e[r[n]>>2],i+=e[(3&r[n])<<4|r[n+1]>>4],i+=e[(15&r[n+1])<<2|r[n+2]>>6],i+=e[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},qr.decode=function(e){var n,r,o,i,s,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),h=new Uint8Array(u);for(n=0;n<c;n+=4)r=t[e.charCodeAt(n)],o=t[e.charCodeAt(n+1)],i=t[e.charCodeAt(n+2)],s=t[e.charCodeAt(n+3)],h[l++]=r<<2|o>>4,h[l++]=(15&o)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return u}}();var zr=void 0!==zr?zr:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,$r=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),Hr=$r&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),Vr=zr&&zr.prototype.append&&zr.prototype.getBlob;function Wr(e){return e.map((function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var n=new Uint8Array(e.byteLength);n.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer}return t}return e}))}function Kr(e,t){t=t||{};var n=new zr;return Wr(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function Qr(e,t){return new Blob(Wr(e),t||{})}"undefined"!=typeof Blob&&(Kr.prototype=Blob.prototype,Qr.prototype=Blob.prototype);var Jr=$r?Hr?Blob:Qr:Vr?Kr:void 0;!function(e){var t,n=wr,r=Ar,o=Tr,i=xr,s=Dr;"undefined"!=typeof ArrayBuffer&&(t=qr);var a="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),c="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),l=a||c;e.protocol=3;var u=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},h=n(u),f={type:"error",data:"parser error"},p=Jr;function d(e,t,n){for(var r=new Array(e.length),o=i(e.length,n),s=function(e,n,o){t(n,(function(t,n){r[e]=n,o(t,r)}))},a=0;a<e.length;a++)s(a,e[a],o)}e.encodePacket=function(t,n,r,o){"function"==typeof n&&(o=n,n=!1),"function"==typeof r&&(o=r,r=null);var i=void 0===t.data?void 0:t.data.buffer||t.data;if("undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=u[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}(t,n,o);if(void 0!==p&&i instanceof p)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(l)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=new FileReader;return o.onload=function(){e.encodePacket({type:t.type,data:o.result},n,!0,r)},o.readAsArrayBuffer(t.data)}(t,n,r);var o=new Uint8Array(1);o[0]=u[t.type];var i=new p([o.buffer,t.data]);return r(i)}(t,n,o);if(i&&i.base64)return function(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}(t,o);var a=u[t.type];return void 0!==t.data&&(a+=r?s.encode(String(t.data),{strict:!1}):String(t.data)),o(""+a)},e.encodeBase64Packet=function(t,n){var r,o="b"+e.packets[t.type];if(void 0!==p&&t.data instanceof p){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(t.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];r=String.fromCharCode.apply(null,a)}return o+=btoa(r),n(o)},e.decodePacket=function(t,n,r){if(void 0===t)return f;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&!1===(t=function(e){try{e=s.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return f;var i=t.charAt(0);return Number(i)==i&&h[i]?t.length>1?{type:h[i],data:t.substring(1)}:{type:h[i]}:f}i=new Uint8Array(t)[0];var a=o(t,1);return p&&"blob"===n&&(a=new p([a])),{type:h[i],data:a}},e.decodeBase64Packet=function(e,n){var r=h[e.charAt(0)];if(!t)return{type:r,data:{base64:!0,data:e.substr(1)}};var o=t.decode(e.substr(1));return"blob"===n&&p&&(o=new p([o])),{type:r,data:o}},e.encodePayload=function(t,n,o){"function"==typeof n&&(o=n,n=null);var i=r(t);if(n&&i)return p&&!l?e.encodePayloadAsBlob(t,o):e.encodePayloadAsArrayBuffer(t,o);if(!t.length)return o("0:");d(t,(function(t,r){e.encodePacket(t,!!i&&n,!1,(function(e){r(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return o(t.join(""))}))},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);var o;if("function"==typeof n&&(r=n,n=null),""===t)return r(f,0,1);for(var i,s,a="",c=0,l=t.length;c<l;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return r(f,0,1);if(a!=(s=t.substr(c+1,i)).length)return r(f,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),f.type===o.type&&f.data===o.data)return r(f,0,1);if(!1===r(o,c+i,l))return}c+=i,a=""}else a+=u}return""!==a?r(f,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){if(!t.length)return n(new ArrayBuffer(0));d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){return n(null,e)}))}),(function(e,t){var r=t.reduce((function(e,t){var n;return e+(n="string"==typeof t?t.length:t.byteLength).toString().length+n+2}),0),o=new Uint8Array(r),i=0;return t.forEach((function(e){var t="string"==typeof e,n=e;if(t){for(var r=new Uint8Array(e.length),s=0;s<e.length;s++)r[s]=e.charCodeAt(s);n=r.buffer}o[i++]=t?0:1;var a=n.byteLength.toString();for(s=0;s<a.length;s++)o[i++]=parseInt(a[s]);o[i++]=255;for(r=new Uint8Array(n),s=0;s<r.length;s++)o[i++]=r[s]})),n(o.buffer)}))},e.encodePayloadAsBlob=function(t,n){d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);e=r.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,p){var a=new p([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new p(t))}))},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var i=t,s=[];i.byteLength>0;){for(var a=new Uint8Array(i),c=0===a[0],l="",u=1;255!==a[u];u++){if(l.length>310)return r(f,0,1);l+=a[u]}i=o(i,2+l.length),l=parseInt(l);var h=o(i,0,l);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var p=new Uint8Array(h);h="";for(u=0;u<p.length;u++)h+=String.fromCharCode(p[u])}s.push(h),i=o(i,l)}var d=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,d)}))}}(br);var Yr={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(Yr);var Xr=br,Gr=Zr;function Zr(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}(0,Yr.exports)(Zr.prototype),Zr.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},Zr.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},Zr.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},Zr.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},Zr.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},Zr.prototype.onData=function(e){var t=Xr.decodePacket(e,this.socket.binaryType);this.onPacket(t)},Zr.prototype.onPacket=function(e){this.emit("packet",e)},Zr.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var eo,to={encode:function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},decode:function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},no=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},ro="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),oo={},io=0,so=0;function ao(e){var t="";do{t=ro[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function co(){var e=ao(+new Date);return e!==eo?(io=0,eo=e):e+"."+ao(io++)}for(;so<64;so++)oo[ro[so]]=so;co.encode=ao,co.decode=function(e){var t=0;for(so=0;so<e.length;so++)t=64*t+oo[e.charAt(so)];return t};var lo=co,uo={exports:{}},ho={exports:{}},fo=1e3,po=60*fo,mo=60*po,go=24*mo,yo=365.25*go,vo=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*yo;case"days":case"day":case"d":return n*go;case"hours":case"hour":case"hrs":case"hr":case"h":return n*mo;case"minutes":case"minute":case"mins":case"min":case"m":return n*po;case"seconds":case"second":case"secs":case"sec":case"s":return n*fo;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return bo(e,go,"day")||bo(e,mo,"hour")||bo(e,po,"minute")||bo(e,fo,"second")||e+" ms"}(e):function(e){if(e>=go)return Math.round(e/go)+"d";if(e>=mo)return Math.round(e/mo)+"h";if(e>=po)return Math.round(e/po)+"m";if(e>=fo)return Math.round(e/fo)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function bo(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=vo,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(ho,ho.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=ho.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(uo,uo.exports);var wo=Gr,Co=to,_o=br,ko=no,So=lo,Eo=uo.exports("engine.io-client:polling"),Ao=xo,To=null!=new yr({xdomain:!1}).responseType;function xo(e){var t=e&&e.forceBase64;To&&!t||(this.supportsBinary=!1),wo.call(this,e)}ko(xo,wo),xo.prototype.name="polling",xo.prototype.doOpen=function(){this.poll()},xo.prototype.pause=function(e){var t=this;function n(){Eo("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(Eo("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){Eo("pre-pause polling complete"),--r||n()}))),this.writable||(Eo("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){Eo("pre-pause writing complete"),--r||n()})))}else n()},xo.prototype.poll=function(){Eo("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},xo.prototype.onData=function(e){var t=this;Eo("polling got data %s",e);_o.decodePayload(e,this.socket.binaryType,(function(e,n,r){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():Eo('ignoring poll - transport state "%s"',this.readyState))},xo.prototype.doClose=function(){var e=this;function t(){Eo("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Eo("transport open - closing"),t()):(Eo("transport not open - deferring close"),this.once("open",t))},xo.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};_o.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},xo.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=So()),this.supportsBinary||e.sid||(e.b64=1),e=Co.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e};var Io=yr,Oo=Ao,Ro=Yr.exports,Po=no,Bo=uo.exports("engine.io-client:polling-xhr");function Fo(){}function No(e){if(Oo.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,"undefined"!=typeof location){var t="https:"===location.protocol,n=location.port;n||(n=t?443:80),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port,this.xs=e.secure!==t}}function jo(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}if(vr.exports=No,vr.exports.Request=jo,Po(No,Oo),No.prototype.supportsBinary=!0,No.prototype.request=function(e){return(e=e||{}).uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new jo(e)},No.prototype.doWrite=function(e,t){var n="string"!=typeof e&&void 0!==e,r=this.request({method:"POST",data:e,isBinary:n}),o=this;r.on("success",t),r.on("error",(function(e){o.onError("xhr post error",e)})),this.sendXhr=r},No.prototype.doPoll=function(){Bo("xhr poll");var e=this.request(),t=this;e.on("data",(function(e){t.onData(e)})),e.on("error",(function(e){t.onError("xhr poll error",e)})),this.pollXhr=e},Ro(jo.prototype),jo.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new Io(e),n=this;try{Bo("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders)for(var r in t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0),this.extraHeaders)this.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.extraHeaders[r])}catch(e){}if("POST"===this.method)try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=!0),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){n.onLoad()},t.onerror=function(){n.onError(t.responseText)}):t.onreadystatechange=function(){if(2===t.readyState)try{var e=t.getResponseHeader("Content-Type");n.supportsBinary&&"application/octet-stream"===e&&(t.responseType="arraybuffer")}catch(e){}4===t.readyState&&(200===t.status||1223===t.status?n.onLoad():setTimeout((function(){n.onError(t.status)}),0))},Bo("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=jo.requestsCount++,jo.requests[this.index]=this)},jo.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},jo.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},jo.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},jo.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Fo:this.xhr.onreadystatechange=Fo,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete jo.requests[this.index],this.xhr=null}},jo.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch(e){}e="application/octet-stream"===t&&this.xhr.response||this.xhr.responseText}catch(e){this.onError(e)}null!=e&&this.onData(e)},jo.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},jo.prototype.abort=function(){this.cleanup()},jo.requestsCount=0,jo.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Uo);else if("function"==typeof addEventListener){var Mo="onpagehide"in self?"pagehide":"unload";addEventListener(Mo,Uo,!1)}function Uo(){for(var e in jo.requests)jo.requests.hasOwnProperty(e)&&jo.requests[e].abort()}var Lo,Do=Ao,qo=Wo,zo=/\n/g,$o=/\\n/g;function Ho(){}function Vo(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==de?de:{}}function Wo(e){if(Do.call(this,e),this.query=this.query||{},!Lo){var t=Vo();Lo=t.___eio=t.___eio||[]}this.index=Lo.length;var n=this;Lo.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=Ho)}),!1)}no(Wo,Do),Wo.prototype.supportsBinary=!1,Wo.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),Do.prototype.doClose.call(this)},Wo.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(t,n):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)}),100)},Wo.prototype.doWrite=function(e,t){var n=this;if(!this.form){var r,o=document.createElement("form"),i=document.createElement("textarea"),s=this.iframeId="eio_iframe_"+this.index;o.className="socketio",o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px",o.target=s,o.method="POST",o.setAttribute("accept-charset","utf-8"),i.name="d",o.appendChild(i),document.body.appendChild(o),this.form=o,this.area=i}function a(){c(),t()}function c(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(e){n.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+n.iframeId+'">';r=document.createElement(e)}catch(e){(r=document.createElement("iframe")).name=n.iframeId,r.src="javascript:0"}r.id=n.iframeId,n.form.appendChild(r),n.iframe=r}this.form.action=this.uri(),c(),e=e.replace($o,"\\\n"),this.area.value=e.replace(zo,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var Ko,Qo,Jo=Gr,Yo=br,Xo=to,Go=no,Zo=lo,ei=uo.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)Ko=WebSocket;else if("undefined"!=typeof self)Ko=self.WebSocket||self.MozWebSocket;else try{Qo=require("ws")}catch(e){}var ti=Ko||Qo,ni=ri;function ri(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=Ko&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(ti=Qo),Jo.call(this,e)}Go(ri,Jo),ri.prototype.name="websocket",ri.prototype.supportsBinary=!0,ri.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new ti(e,t):new ti(e):new ti(e,t,n)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},ri.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},ri.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){Yo.encodePacket(e,t.supportsBinary,(function(r){if(!t.usingBrowserWebSocket){var o={};if(e.options&&(o.compress=e.options.compress),t.perMessageDeflate)("string"==typeof r?Buffer.byteLength(r):r.length)<t.perMessageDeflate.threshold&&(o.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(r):t.ws.send(r,o)}catch(e){ei("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},ri.prototype.onClose=function(){Jo.prototype.onClose.call(this)},ri.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},ri.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",n="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=Zo()),this.supportsBinary||(e.b64=1),(e=Xo.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},ri.prototype.check=function(){return!(!ti||"__initialize"in ti&&this.name===ri.prototype.name)};var oi=yr,ii=vr.exports,si=qo,ai=ni;dr.polling=function(e){var t=!1,n=!1,r=!1!==e.jsonp;if("undefined"!=typeof location){var o="https:"===location.protocol,i=location.port;i||(i=o?443:80),t=e.hostname!==location.hostname||i!==e.port,n=e.secure!==o}if(e.xdomain=t,e.xscheme=n,"open"in new oi(e)&&!e.forceJSONP)return new ii(e);if(!r)throw new Error("JSONP disabled");return new si(e)},dr.websocket=ai;var ci=[].indexOf,li=function(e,t){if(ci)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},ui=dr,hi=Yr.exports,fi=uo.exports("engine.io-client:socket"),pi=li,di=br,mi=On,gi=to,yi=vi;function vi(e,t){if(!(this instanceof vi))return new vi(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=mi(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=mi(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=gi.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||null,this.key=t.key||null,this.passphrase=t.passphrase||null,this.cert=t.cert||null,this.ca=t.ca||null,this.ciphers=t.ciphers||null,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}vi.priorWebsocketSuccess=!1,hi(vi.prototype),vi.protocol=di.protocol,vi.Socket=vi,vi.Transport=Gr,vi.transports=dr,vi.parser=br,vi.prototype.createTransport=function(e){fi('creating transport "%s"',e);var t=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.query);t.EIO=di.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new ui[e]({query:t,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative})},vi.prototype.open=function(){var e;if(this.rememberUpgrade&&vi.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout((function(){t.emit("error","No transports available")}),0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},vi.prototype.setTransport=function(e){fi("setting transport %s",e.name);var t=this;this.transport&&(fi("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",(function(){t.onDrain()})).on("packet",(function(e){t.onPacket(e)})).on("error",(function(e){t.onError(e)})).on("close",(function(){t.onClose("transport close")}))},vi.prototype.probe=function(e){fi('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,r=this;function o(){if(r.onlyBinaryUpgrades){var o=!this.supportsBinary&&r.transport.supportsBinary;n=n||o}n||(fi('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(o){if(!n)if("pong"===o.type&&"probe"===o.data){if(fi('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;vi.priorWebsocketSuccess="websocket"===t.name,fi('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(fi("changing transport and sending upgrade packet"),u(),r.setTransport(t),t.send([{type:"upgrade"}]),r.emit("upgrade",t),t=null,r.upgrading=!1,r.flush())}))}else{fi('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,r.emit("upgradeError",i)}})))}function i(){n||(n=!0,u(),t.close(),t=null)}function s(n){var o=new Error("probe error: "+n);o.transport=t.name,i(),fi('probe transport "%s" failed because of error: %s',e,n),r.emit("upgradeError",o)}function a(){s("transport closed")}function c(){s("socket closed")}function l(e){t&&e.name!==t.name&&(fi('"%s" works - aborting "%s"',e.name,t.name),i())}function u(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),r.removeListener("close",c),r.removeListener("upgrading",l)}vi.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()},vi.prototype.onOpen=function(){if(fi("socket open"),this.readyState="open",vi.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){fi("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},vi.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(fi('socket receive: type "%s", data "%s"',e.type,e.data),this.emit("packet",e),this.emit("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emit("data",e.data),this.emit("message",e.data)}else fi('packet received with socket readyState "%s"',this.readyState)},vi.prototype.onHandshake=function(e){this.emit("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},vi.prototype.onHeartbeat=function(e){clearTimeout(this.pingTimeoutTimer);var t=this;t.pingTimeoutTimer=setTimeout((function(){"closed"!==t.readyState&&t.onClose("ping timeout")}),e||t.pingInterval+t.pingTimeout)},vi.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){fi("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},vi.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},vi.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},vi.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(fi("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},vi.prototype.write=vi.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},vi.prototype.sendPacket=function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emit("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}},vi.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var e=this;this.writeBuffer.length?this.once("drain",(function(){this.upgrading?r():t()})):this.upgrading?r():t()}function t(){e.onClose("forced close"),fi("socket closing - telling transport to close"),e.transport.close()}function n(){e.removeListener("upgrade",n),e.removeListener("upgradeError",n),t()}function r(){e.once("upgrade",n),e.once("upgradeError",n)}return this},vi.prototype.onError=function(e){fi("socket error %j",e),vi.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},vi.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){fi('socket close with reason: "%s"',e);clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",e,t),this.writeBuffer=[],this.prevBufferLen=0}},vi.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~pi(this.transports,e[n])&&t.push(e[n]);return t},pr.exports=yi,pr.exports.parser=br;var bi={exports:{}},wi={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(wi);var Ci=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n};var _i=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var ki=[].slice,Si=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=ki.call(arguments,2);return function(){return t.apply(e,n.concat(ki.call(arguments)))}};!function(e,t){var n=$n,r=wi.exports,o=Ci,i=_i,s=Si,a=Rn.exports("socket.io-client:socket"),c=to,l=Ar;e.exports=f;var u={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},h=r.prototype.emit;function f(e,t,n){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}r(f.prototype),f.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[i(e,"open",s(this,"onopen")),i(e,"packet",s(this,"onpacket")),i(e,"close",s(this,"onclose"))]}},f.prototype.open=f.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},f.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},f.prototype.emit=function(e){if(u.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:l(t))?n.BINARY_EVENT:n.EVENT,data:t,options:{}};return r.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=t.pop(),r.id=this.ids++),this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this},f.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},f.prototype.onopen=function(){if(a("transport is open - connecting"),"/"!==this.nsp)if(this.query){var e="object"==typeof this.query?c.encode(this.query):this.query;a("sending connect packet with query %s",e),this.packet({type:n.CONNECT,query:e})}else this.packet({type:n.CONNECT})},f.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},f.prototype.onpacket=function(e){var t=e.nsp===this.nsp,r=e.type===n.ERROR&&"/"===e.nsp;if(t||r)switch(e.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(e);break;case n.ACK:case n.BINARY_ACK:this.onack(e);break;case n.DISCONNECT:this.ondisconnect();break;case n.ERROR:this.emit("error",e.data)}},f.prototype.onevent=function(e){var t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?h.apply(this,t):this.receiveBuffer.push(t)},f.prototype.ack=function(e){var t=this,r=!1;return function(){if(!r){r=!0;var i=o(arguments);a("sending ack %j",i),t.packet({type:l(i)?n.BINARY_ACK:n.ACK,id:e,data:i})}}},f.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)},f.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},f.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)h.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},f.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},f.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},f.prototype.close=f.prototype.disconnect=function(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:n.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},f.prototype.compress=function(e){return this.flags.compress=e,this},f.prototype.binary=function(e){return this.flags.binary=e,this}}(bi);var Ei=Ai;function Ai(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ai.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},Ai.prototype.reset=function(){this.attempts=0},Ai.prototype.setMin=function(e){this.ms=e},Ai.prototype.setMax=function(e){this.max=e},Ai.prototype.setJitter=function(e){this.jitter=e};var Ti=pr.exports,xi=bi.exports,Ii=wi.exports,Oi=$n,Ri=_i,Pi=Si,Bi=Rn.exports("socket.io-client:manager"),Fi=li,Ni=Ei,ji=Object.prototype.hasOwnProperty,Mi=Ui;function Ui(e,t){if(!(this instanceof Ui))return new Ui(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new Ni({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=t.parser||Oi;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}Ui.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)ji.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},Ui.prototype.updateSocketIds=function(){for(var e in this.nsps)ji.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},Ui.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Ii(Ui.prototype),Ui.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},Ui.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},Ui.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},Ui.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},Ui.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},Ui.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},Ui.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},Ui.prototype.open=Ui.prototype.connect=function(e,t){if(Bi("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Bi("opening %s",this.uri),this.engine=Ti(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=Ri(n,"open",(function(){r.onopen(),e&&e()})),i=Ri(n,"error",(function(t){if(Bi("connect_error"),r.cleanup(),r.readyState="closed",r.emitAll("connect_error",t),e){var n=new Error("Connection error");n.data=t,e(n)}else r.maybeReconnectOnOpen()}));if(!1!==this._timeout){var s=this._timeout;Bi("connect attempt will timeout after %d",s);var a=setTimeout((function(){Bi("connect attempt timed out after %d",s),o.destroy(),n.close(),n.emit("error","timeout"),r.emitAll("connect_timeout",s)}),s);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(o),this.subs.push(i),this},Ui.prototype.onopen=function(){Bi("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(Ri(e,"data",Pi(this,"ondata"))),this.subs.push(Ri(e,"ping",Pi(this,"onping"))),this.subs.push(Ri(e,"pong",Pi(this,"onpong"))),this.subs.push(Ri(e,"error",Pi(this,"onerror"))),this.subs.push(Ri(e,"close",Pi(this,"onclose"))),this.subs.push(Ri(this.decoder,"decoded",Pi(this,"ondecoded")))},Ui.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},Ui.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},Ui.prototype.ondata=function(e){this.decoder.add(e)},Ui.prototype.ondecoded=function(e){this.emit("packet",e)},Ui.prototype.onerror=function(e){Bi("error",e),this.emitAll("error",e)},Ui.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new xi(this,e,t),this.nsps[e]=n;var r=this;n.on("connecting",o),n.on("connect",(function(){n.id=r.generateId(e)})),this.autoConnect&&o()}function o(){~Fi(r.connecting,n)||r.connecting.push(n)}return n},Ui.prototype.destroy=function(e){var t=Fi(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},Ui.prototype.packet=function(e){Bi("writing packet %j",e);var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,(function(n){for(var r=0;r<n.length;r++)t.engine.write(n[r],e.options);t.encoding=!1,t.processPacketQueue()})))},Ui.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},Ui.prototype.cleanup=function(){Bi("cleanup");for(var e=this.subs.length,t=0;t<e;t++){this.subs.shift().destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},Ui.prototype.close=Ui.prototype.disconnect=function(){Bi("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},Ui.prototype.onclose=function(e){Bi("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},Ui.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Bi("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Bi("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Bi("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Bi("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Bi("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},Ui.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)},function(e,t){var n=zn,r=$n,o=Mi,i=Rn.exports("socket.io-client");e.exports=t=a;var s=t.managers={};function a(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,a=n(e),c=a.source,l=a.id,u=a.path,h=s[l]&&u in s[l].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),r=o(c,t)):(s[l]||(i("new io instance for %s",c),s[l]=o(c,t)),r=s[l]),a.query&&!t.query&&(t.query=a.query),r.socket(a.path,t)}t.protocol=r.protocol,t.connect=a,t.Manager=Mi,t.Socket=bi.exports}(Tn,Tn.exports);var Li=Tn.exports;var Di={exports:{}};Di.exports=function(){function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(!a&&ge)return ge(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,(function(e){return o(t[s][1][e]||e)}),l,l.exports,e,t,n,r)}return n[s].exports}for(var i=ge,s=0;s<r.length;s++)o(r[s]);return o}return e}()({1:[function(e,t,n){(function(n,r){(function(){const o=e("events").EventEmitter,i=e("./store"),s=e("./topic-alias-recv"),a=e("./topic-alias-send"),c=e("mqtt-packet"),l=e("./default-message-id-provider"),u=e("readable-stream").Writable,h=e("inherits"),f=e("reinterval"),p=e("rfdc/default"),d=e("./validations"),m=e("xtend"),g=e("debug")("mqttjs:client"),y=n?n.nextTick:function(e){setTimeout(e,0)},v=r.setImmediate||function(e){y(e)},b={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},w=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],C={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function _(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function k(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let n;t.properties&&(n=t.properties.topicAlias);const r=t.topic.toString();if(e.topicAliasSend)if(n){if(0!==r.length&&(g("applyTopicAlias :: register topic: %s - alias: %d",r,n),!e.topicAliasSend.put(r,n)))return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",r,n),new Error("Sending Topic Alias out of range")}else 0!==r.length&&(e.options.autoAssignTopicAlias?(n=e.topicAliasSend.getAliasByTopic(r),n?(t.topic="",t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",r,n)):(n=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(r,n),t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto assign topic: %s - alias: %d",r,n))):e.options.autoUseTopicAlias&&(n=e.topicAliasSend.getAliasByTopic(r),n&&(t.topic="",t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto use topic: %s - alias: %d",r,n))));else if(n)return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",r,n),new Error("Sending Topic Alias out of range")}}function S(e,t){let n;t.properties&&(n=t.properties.topicAlias);let r=t.topic.toString();if(0===r.length){if(void 0===n)return new Error("Unregistered Topic Alias");if(r=e.topicAliasSend.getTopicByAlias(n),void 0===r)return new Error("Unregistered Topic Alias");t.topic=r}n&&delete t.properties.topicAlias}function E(e,t,n){g("sendPacket :: packet: %O",t),g("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),g("sendPacket :: writing to stream");const r=c.writeToStream(t,e.stream,e.options);g("sendPacket :: writeToStream result %s",r),!r&&n&&n!==I?(g("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(g("sendPacket :: invoking cb"),n())}function A(e){e&&(g("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function T(e){e&&(g("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function x(e,t,n,r){g("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let o,i=t;if("publish"===i.cmd&&(i=p(t),o=S(e,i),o))return n&&n(o);e.outgoingStore.put(i,(function(o){if(o)return n&&n(o);r(),E(e,t,n)}))}function I(e){g("nop ::",e)}function O(e,t){let n;const r=this;if(!(this instanceof O))return new O(e,t);for(n in this.options=t||{},b)void 0===this.options[n]?this.options[n]=b[n]:this.options[n]=t[n];g("MqttClient :: options.protocol",t.protocol),g("MqttClient :: options.protocolVersion",t.protocolVersion),g("MqttClient :: options.username",t.username),g("MqttClient :: options.keepalive",t.keepalive),g("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),g("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),g("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:_(),g("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new l:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new i,this.incomingStore=t.incomingStore||new i,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?g("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;function t(){const n=e.shift();g("deliver :: entry %o",n);let o=null;if(!n)return void r._resubscribe();o=n.packet,g("deliver :: call _sendPacket for %o",o);let i=!0;o.messageId&&0!==o.messageId&&(r.messageIdProvider.register(o.messageId)||(i=!1)),i?r._sendPacket(o,(function(e){n.cb&&n.cb(e),t()})):(g("messageId: %d has already used. The message is skipped and removed.",o.messageId),t())}g("connect :: sending queued packets"),t()})),this.on("close",(function(){g("close :: connected set to `false`"),this.connected=!1,g("close :: clearing connackTimer"),clearTimeout(this.connackTimer),g("close :: clearing ping timer"),null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),g("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),g("MqttClient :: setting up stream"),this._setupStream()}h(O,o),O.prototype._setupStream=function(){const e=this,t=new u,n=c.parser(this.options);let r=null;const o=[];function i(){if(o.length)y(s);else{const e=r;r=null,e()}}function s(){g("work :: getting next packet in queue");const t=o.shift();if(t)g("work :: packet pulled from queue"),e._handlePacket(t,i);else{g("work :: no packets in queue");const e=r;r=null,g("work :: done flag is %s",!!e),e&&e()}}function a(t){g("streamErrorHandler :: error",t.message),w.includes(t.code)?(g("streamErrorHandler :: emitting error"),e.emit("error",t)):I(t)}g("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),g("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),n.on("packet",(function(e){g("parser :: on packet push to packets array."),o.push(e)})),t._write=function(e,t,o){r=o,g("writable stream :: parsing buffer"),n.parse(e),s()},g("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",a),this.stream.on("close",(function(){g("(%s)stream :: on close",e.options.clientId),T(e.outgoing),g("stream: emit close to MqttClient"),e.emit("close")})),g("_setupStream: sending packet `connect`");const l=Object.create(this.options);if(l.cmd="connect",this.topicAliasRecv&&(l.properties||(l.properties={}),this.topicAliasRecv&&(l.properties.topicAliasMaximum=this.topicAliasRecv.max)),E(this,l),n.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&E(this,m({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){g("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)}),this.options.connectTimeout)},O.prototype._handlePacket=function(e,t){const n=this.options;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(g("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},O.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==I?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},O.prototype.publish=function(e,t,n,r){g("publish :: message `%s` to topic `%s`",t,e);const o=this.options;if("function"==typeof n&&(r=n,n=null),n=m({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;const i=this,s=function(){let s=0;if((1===n.qos||2===n.qos)&&(s=i._nextId(),null===s))return g("No messageId left"),!1;const a={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:s,dup:n.dup};switch(5===o.protocolVersion&&(a.properties=n.properties),g("publish :: qos",n.qos),n.qos){case 1:case 2:i.outgoing[a.messageId]={volatile:!1,cb:r||I},g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,void 0,n.cbStorePut);break;default:g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,r,n.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:n.cbStorePut,callback:r}),this},O.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const n=[];let r=t.shift();const o=r.resubscribe;let i=t.pop()||I,s=t.pop();const a=this.options.protocolVersion;delete r.resubscribe,"string"==typeof r&&(r=[r]),"function"!=typeof i&&(s=i,i=I);const c=d.validateTopics(r);if(null!==c)return v(i,new Error("Invalid topic "+c)),this;if(this._checkDisconnecting(i))return g("subscribe: discconecting true"),this;const l={qos:0};if(5===a&&(l.nl=!1,l.rap=!1,l.rh=0),s=m(l,s),Array.isArray(r)?r.forEach((function(t){if(g("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||o){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),g("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),n.push(e)}})):Object.keys(r).forEach((function(t){if(g("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<r[t].qos||o){const e={topic:t,qos:r[t].qos};5===a&&(e.nl=r[t].nl,e.rap=r[t].rap,e.rh=r[t].rh,e.properties=s.properties),g("subscribe: pushing `%s` to subs list",e),n.push(e)}})),!n.length)return i(null,[]),this;const u=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const r={cmd:"subscribe",subscriptions:n,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(r.properties=s.properties),e.options.resubscribe){g("subscribe :: resubscribe true");const t=[];n.forEach((function(n){if(e.options.reconnectPeriod>0){const r={qos:n.qos};5===a&&(r.nl=n.nl||!1,r.rap=n.rap||!1,r.rh=n.rh||0,r.properties=n.properties),e._resubscribeTopics[n.topic]=r,t.push(n.topic)}})),e.messageIdToTopic[r.messageId]=t}return e.outgoing[r.messageId]={volatile:!0,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)n[t].qos=e[t]}i(e,n)}},g("subscribe :: call _sendPacket"),e._sendPacket(r),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!u())&&this._storeProcessingQueue.push({invoke:u,callback:i}),this},O.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let n=t.shift(),r=t.pop()||I,o=t.pop();"string"==typeof n&&(n=[n]),"function"!=typeof r&&(o=r,r=I);const i=d.validateTopics(n);if(null!==i)return v(r,new Error("Invalid topic "+i)),this;if(e._checkDisconnecting(r))return this;const s=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const i={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof n?i.unsubscriptions=[n]:Array.isArray(n)&&(i.unsubscriptions=n),e.options.resubscribe&&i.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t]})),"object"==typeof o&&o.properties&&(i.properties=o.properties),e.outgoing[i.messageId]={volatile:!0,cb:r},g("unsubscribe: call _sendPacket"),e._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:r}),this},O.prototype.end=function(e,t,n){const r=this;function o(){g("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(g("end :: closeStores: emitting end"),r.emit("end"),n){const r=e||t;g("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){g("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{g("end :: finish :: calling process.nextTick on closeStores"),y(o.bind(r))}),t)}return g("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||I,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=I))),"object"!=typeof t&&(n=t,t=null),g("end :: cb? %s",!!n),n=n||I,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(g("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(g("end :: (%s) :: immediately calling finish",r.options.clientId),i()),this)},O.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},O.prototype.reconnect=function(e){g("client reconnect");const t=this,n=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new i,t.outgoingStore=t.options.outgoingStore||new i,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},O.prototype._reconnect=function(){g("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),g("client already connected. disconnecting first.")):(g("_reconnect: calling _setupStream"),this._setupStream())},O.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(g("_setupReconnect :: emit `offline` state"),this.emit("offline"),g("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),g("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){g("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):g("_setupReconnect :: doing nothing...")},O.prototype._clearReconnect=function(){g("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},O.prototype._cleanUp=function(e,t){const n=arguments[2];if(t&&(g("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),g("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&A(this.outgoing),g("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=m({cmd:"disconnect"},n);g("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,v.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(g("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(g("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(g("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},O.prototype._sendPacket=function(e,t,n){g("_sendPacket :: (%s) :: start",this.options.clientId),n=n||I,t=t||I;const r=k(this,e);if(r)t(r);else{if(!this.connected)return"auth"===e.cmd?(this._shiftPingInterval(),void E(this,e,t)):(g("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,n));switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void x(this,e,t,n);default:return void E(this,e,t)}switch(e.qos){case 2:case 1:x(this,e,t,n);break;default:E(this,e,t)}g("_sendPacket :: (%s) :: end",this.options.clientId)}},O.prototype._storePacket=function(e,t,n){g("_storePacket :: packet: %o",e),g("_storePacket :: cb? %s",!!t),n=n||I;let r=e;if("publish"===r.cmd){r=p(e);const n=S(this,r);if(n)return t&&t(n)}0===(r.qos||0)&&this.queueQoSZero||"publish"!==r.cmd?this.queue.push({packet:r,cb:t}):r.qos>0?(t=this.outgoing[r.messageId]?this.outgoing[r.messageId].cb:null,this.outgoingStore.put(r,(function(e){if(e)return t&&t(e);n()}))):t&&t(new Error("No connection to broker"))},O.prototype._setupPingTimer=function(){g("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=f((function(){e._checkPing()}),1e3*this.options.keepalive))},O.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},O.prototype._checkPing=function(){g("_checkPing :: checking ping..."),this.pingResp?(g("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(g("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},O.prototype._handlePingresp=function(){this.pingResp=!0},O.prototype._handleConnack=function(e){g("_handleConnack");const t=this.options,n=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(0===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){const e=new Error("Connection refused: "+C[n]);e.code=n,this.emit("error",e)}},O.prototype._handleAuth=function(e){const t=this.options.protocolVersion,n=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=n,void this.emit("error",e)}const r=this;this.handleAuth(e,(function(e,t){if(e)r.emit("error",e);else if(24===n)r.reconnecting=!1,r._sendPacket(t);else{const t=new Error("Connection refused: "+C[n]);e.code=n,r.emit("error",t)}}))},O.prototype.handleAuth=function(e,t){t()},O.prototype._handlePublish=function(e,t){g("_handlePublish: packet %o",e),t=void 0!==t?t:I;let n=e.topic.toString();const r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===n.length){if(!(t>0&&t<=65535))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return g("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));n=e,g("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",n,t)}}else{if(!this.topicAliasRecv.put(n,t))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));g("_handlePublish :: registered topic: %s - alias: %d",n,t)}}switch(g("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(n,r,e,(function(n,r){return n instanceof Error||(r=n,n=null),n?s.emit("error",n):-1===c.indexOf(r)?s.emit("error",new Error("Wrong reason code for pubrec")):void(r?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:r},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(n,r,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",n,r,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},t)})))}));break;case 0:this.emit("message",n,r,e),this.handleMessage(e,t);break;default:g("_handlePublish: unknown QoS. Doing nothing.")}},O.prototype.handleMessage=function(e,t){t()},O.prototype._handleAck=function(e){const t=e.messageId,n=e.cmd;let r=null;const o=this.outgoing[t]?this.outgoing[t].cb:null,i=this;let s;if(o){switch(g("_handleAck :: packet type",n),n){case"pubcomp":case"puback":{const n=e.reasonCode;n&&n>0&&16!==n&&(s=new Error("Publish error: "+C[n]),s.code=n,o(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,o),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case"pubrec":{r={cmd:"pubrel",qos:2,messageId:t};const n=e.reasonCode;n&&n>0&&16!==n?(s=new Error("Publish error: "+C[n]),s.code=n,o(s,e)):this._sendPacket(r);break}case"suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let n=0;n<e.granted.length;n++)if(0!=(128&e.granted[n])){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete i._resubscribeTopics[e]}))}this._invokeStoreProcessingQueue(),o(null,e);break;case"unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),o(null);break;default:i.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else g("_handleAck :: Server sent an ack in error. Ignoring.")},O.prototype._handlePubrel=function(e,t){g("handling pubrel packet"),t=void 0!==t?t:I;const n=e.messageId,r=this,o={cmd:"pubcomp",messageId:n};r.incomingStore.get(e,(function(e,n){e?r._sendPacket(o,t):(r.emit("message",n.topic,n.payload,n),r.handleMessage(n,(function(e){if(e)return t(e);r.incomingStore.del(n,I),r._sendPacket(o,t)})))}))},O.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},O.prototype._nextId=function(){return this.messageIdProvider.allocate()},O.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},O.prototype._resubscribe=function(){g("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){g("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const n={};n[e[t]]=this._resubscribeTopics[e[t]],n.resubscribe=!0,this.subscribe(n,{properties:n[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},O.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;function n(){let r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,t._flushStoreProcessingQueue(),o()}function s(){if(!r)return;t._storeProcessing=!0;const e=r.read(1);let n;e?t._packetIdsDuringStoreProcessing[e.messageId]?s():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(n=t.outgoing[e.messageId]?t.outgoing[e.messageId].cb:null,t.outgoing[e.messageId]={volatile:!1,cb:function(e,t){n&&n(e,t),s()}},t._packetIdsDuringStoreProcessing[e.messageId]=!0,t.messageIdProvider.register(e.messageId)?t._sendPacket(e):g("messageId: %d has already used.",e.messageId)):r.once("readable",s)}t.once("close",i),r.on("error",(function(e){o(),t._flushStoreProcessingQueue(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){let r=!0;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){r=!1;break}r?(o(),t.removeListener("close",i),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):n()})),s()}this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,n()},O.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},O.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},O.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},t.exports=O}).call(this)}).call(this,e("_process"),void 0!==de?de:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(e,t,n){const{Buffer:r}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c,l=!1;function u(){const e=new o;return e._write=function(e,t,n){s.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){s.closeSocket({success:function(){e()}})},e}function h(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function f(e,t){const n="alis"===e.protocol?"wss":"ws";let r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function p(){l||(l=!0,s.onSocketOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=r.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?r.from(e):r.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((function(){c.end(),c.destroy()})),s.onSocketError((function(e){c.destroy(e)})))}function d(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";h(t);const r=f(t,e);return s=t.my,s.connectSocket({url:r,protocols:n}),a=u(),c=i.obj(),p(),c}t.exports=d},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(e,t,n){const r=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const n=t.port,i=t.hostname;return o("port %d and host %s",n,i),r.createConnection(n,i)}t.exports=i},{debug:18,net:16}],4:[function(e,t,n){const r=e("tls"),o=e("net"),i=e("debug")("mqttjs:tls");function s(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===o.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,i("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const n=r.connect(t);function s(r){t.rejectUnauthorized&&e.emit("error",r),n.end()}return n.on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",s)})),n.on("error",s),n}t.exports=s},{debug:18,net:16,tls:16}],5:[function(e,t,n){(function(n){(function(){const{Buffer:r}=e("buffer"),o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform,c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],l=void 0!==n&&"browser"===n.title||"function"==typeof __webpack_require__;function u(e,t){let n=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function h(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),l||"wss"!==e.protocol||c.forEach((function(n){Object.prototype.hasOwnProperty.call(e,n)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,n)&&(t.wsOptions[n]=e[n])})),t}function f(e){const t=h(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}function p(e,t,n){i("createWebSocket"),i("protocol: "+n.protocolId+" "+n.protocolVersion);const r="MQIsdp"===n.protocolId&&3===n.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+t+" and protocol: "+r),new o(t,[r],n.wsOptions)}function d(e,t){const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",r=u(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");const n=h(t),r=u(n,e),s=p(e,r,n),a=o.createWebSocketStream(s,n.wsOptions);return a.url=r,s.on("close",(()=>{a.destroy()})),a}function g(e,t){let n;i("browserStreamBuilder");const o=f(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,l=!t.objectMode,u=d(e,t),h=m(t,C,_);t.objectMode||(h._writev=w),h.on("close",(()=>{u.close()}));const p=void 0!==u.addEventListener;function m(e,t,n){const r=new a({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}function g(){n.setReadable(h),n.setWritable(h),n.emit("connect")}function y(){n.end(),n.destroy()}function v(e){n.destroy(e)}function b(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),h.push(t)}function w(e,t){const n=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?n[t]=r.from(e[t],"utf8"):n[t]=e[t].chunk;this._write(r.concat(n),"binary",t)}function C(e,t,n){u.bufferedAmount>o&&setTimeout(C,c,e,t,n),l&&"string"==typeof e&&(e=r.from(e,"utf8"));try{u.send(e)}catch(e){return n(e)}n()}function _(e){u.close(),e()}return u.readyState===u.OPEN?n=h:(n=n=s(void 0,void 0,t),t.objectMode||(n._writev=w),p?u.addEventListener("open",g):u.onopen=g),n.socket=u,p?(u.addEventListener("close",y),u.addEventListener("error",v),u.addEventListener("message",b)):(u.onclose=y,u.onerror=v,u.onmessage=b),n}t.exports=l?g:m}).call(this)}).call(this,e("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(e,t,n){const{Buffer:r}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c;function l(){const e=new o;return e._write=function(e,t,n){s.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){s.close({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){const n="wxs"===e.protocol?"wss":"ws";let r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function f(){s.onOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),a.push(t)})),s.onClose((function(){c.end(),c.destroy()})),s.onError((function(e){c.destroy(new Error(e.errMsg))}))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);const r=h(t,e);s=wx.connectSocket({url:r,protocols:[n]}),a=l(),c=i.obj(),c._destroy=function(e,t){s.close({success:function(){t&&t(e)}})};const o=c.destroy;return c.destroy=function(){c.destroy=o;const e=this;setTimeout((function(){s.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(c),f(),c}t.exports=p},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(e,t,n){function r(){if(!(this instanceof r))return new r;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}r.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},r.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},r.prototype.register=function(e){return!0},r.prototype.deallocate=function(e){},r.prototype.clear=function(){},t.exports=r},{}],8:[function(e,t,n){const r=e("xtend"),o=e("readable-stream").Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=r(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new o(i),t=[];let n=!1,r=0;return this._inflights.forEach((function(e,n){t.push(e)})),e._read=function(){!n&&r<t.length?this.push(t[r++]):this.push(null)},e.destroy=function(){if(n)return;const e=this;n=!0,setTimeout((function(){e.emit("close")}),0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=a},{"readable-stream":69,xtend:81}],9:[function(e,t,n){function r(e){if(!(this instanceof r))return new r(e);this.aliasToTopic={},this.max=e}r.prototype.put=function(e,t){return!(0===t||t>this.max||(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,0))},r.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},r.prototype.clear=function(){this.aliasToTopic={}},t.exports=r},{}],10:[function(e,t,n){const r=e("lru-cache"),o=e("number-allocator").NumberAllocator;function i(e){if(!(this instanceof i))return new i(e);e>0&&(this.aliasToTopic=new r({max:e}),this.topicToAlias={},this.numberAllocator=new o(1,e),this.max=e,this.length=0)}i.prototype.put=function(e,t){if(0===t||t>this.max)return!1;const n=this.aliasToTopic.get(t);return n&&delete this.topicToAlias[n],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},i.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},i.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},i.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},i.prototype.getLruAlias=function(){const e=this.numberAllocator.firstVacant();return e||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},t.exports=i},{"lru-cache":37,"number-allocator":46}],11:[function(e,t,n){function r(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(let t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],12:[function(e,t,n){(function(n){(function(){const r=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function l(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function u(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const n=i.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=s(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(l(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!c[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,n){return(!e||n%2!=0)&&"function"==typeof c[t]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function n(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a("calling streambuilder for",t.protocol),c[t.protocol](e,t)}t.protocol&&(t.defaultProtocol=t.protocol);const o=new r(n,t);return o.on("error",(function(){})),o}void 0!==n&&"browser"!==n.title||"function"!=typeof __webpack_require__?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=u,t.exports.connect=u,t.exports.MqttClient=r,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":8,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:50,debug:18,url:76,xtend:81}],13:[function(e,t,n){n.byteLength=u,n.toByteArray=f,n.fromByteArray=m;for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r}function h(e,t,n){return 3*(t+n)/4-n}function f(e){var t,n,r=l(e),s=r[0],a=r[1],c=new i(h(e,s,a)),u=0,f=a>0?s-4:s;for(n=0;n<f;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[u++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c}function p(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function d(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(p(r));return o.join("")}function m(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,c=n-o;a<c;a+=s)i.push(d(e,a,a+s>c?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],14:[function(e,t,n){const{Buffer:r}=e("buffer"),o=Symbol.for("BufferList");function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},i.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},i.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,n,o){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof o||o>this.length)&&(o=this.length),n>=this.length)return e||r.alloc(0);if(o<=0)return e||r.alloc(0);const i=!!e,s=this._offset(n),a=o-n;let c=a,l=i&&t||0,u=s[1];if(0===n&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-u)return i?this._bufs[s[0]].copy(e,t,u,u+c):this._bufs[s[0]].slice(u,u+c);i||(e=r.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const n=this._bufs[t].length-u;if(!(c>n)){this._bufs[t].copy(e,l,u,u+c),l+=n;break}this._bufs[t].copy(e,l,u),l+=n,c-=n,u&&(u=0)}return e.length>l?e.slice(0,l):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),o=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,r[1]),0!==n[1]&&(o[0]=o[0].slice(n[1])),this._new(o)},i.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(r.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(r.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const t=this._bufs[i];for(;s<t.length;)if(t.length-s>=e.length){const n=t.indexOf(e,s);if(-1!==n)return this._reverseOffset([i,n]);s=t.length-e.length+1}else{const t=this._reverseOffset([i,s]);if(this._match(t,e))return t;s++}s=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let n=0;n<t.length;n++)if(this.get(e+n)!==t[n])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){null===e[t]?i.prototype[t]=function(e,n){return this.slice(e,e+n)[t](0,n)}:i.prototype[t]=function(n=0){return this.slice(n,n+e[t])[t](0)}}(t)}(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return null!=e&&e[o]},t.exports=i},{buffer:17}],15:[function(e,t,n){const r=e("readable-stream").Duplex,o=e("inherits"),i=e("./BufferList");function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}i._init.call(this,e),r.call(this)}o(s,r),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){r.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof i||s.isBufferList(e)},s.isBufferList=i.isBufferList,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(e,t,n){},{}],17:[function(e,t,n){(function(t){(function(){var t=e("base64-js"),r=e("ieee754");n.Buffer=a,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return f(e,t);if(ArrayBuffer.isView(e))return p(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return d(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return a.from(r,t,n);var o=m(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e,t,n){return l(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}function h(e){return l(e),s(e<0?0:0|g(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|v(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function p(e){for(var t=e.length<0?0:0|g(e.length),n=s(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return(r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n)).__proto__=a.prototype,r}function m(e){if(a.isBuffer(e)){var t=0|g(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||X(e.length)?s(0):p(e):"Buffer"===e.type&&Array.isArray(e.data)?p(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Q(e).length;default:if(o)return r?-1:V(e).length;t=(""+t).toLowerCase(),o=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,n);case"utf8":case"utf-8":return O(this,t,n);case"ascii":return B(this,t,n);case"latin1":case"binary":return F(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function C(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),X(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:_(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):_(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(i=n;i<a;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,f=0;f<c;f++)if(l(e,i+f)!==l(t,f)){h=!1;break}if(h)return i}return-1}function k(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(X(a))return s;e[n+s]=a}return s}function S(e,t,n,r){return J(V(t,e.length-n),e,n,r)}function E(e,t,n,r){return J(W(t),e,n,r)}function A(e,t,n,r){return E(e,t,n,r)}function T(e,t,n,r){return J(Q(t),e,n,r)}function x(e,t,n,r){return J(K(t,e.length-n),e,n,r)}function I(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function O(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,l=e[o],u=null,h=l>239?4:l>223?3:l>191?2:1;if(o+h<=n)switch(h){case 1:l<128&&(u=l);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&l)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=h}return P(r)}n.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,n){return c(e,t,n)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,n){return u(e,t,n)},a.allocUnsafe=function(e){return h(e)},a.allocUnsafeSlow=function(e){return h(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(Y(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=a.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(Y(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},a.byteLength=v,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?O(this,0,e):b.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,o){if(Y(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),l=this.slice(r,o),u=e.slice(t,n),h=0;h<c;++h)if(l[h]!==u[h]){i=l[h],s=u[h];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return k(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return E(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return T(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function P(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=R));return n}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function F(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function N(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=H(e[i]);return o}function j(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function M(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,n,r,o,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function L(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(e,t,n,o,i){return t=+t,n>>>=0,i||L(e,t,n,4),r.write(e,t,n,o,23,4),n+4}function q(e,t,n,o,i){return t=+t,n>>>=0,i||L(e,t,n,8),r.write(e,t,n,o,52,8),n+8}a.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return r.__proto__=a.prototype,r},a.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},a.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},a.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||U(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||U(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);U(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);U(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,n){return D(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return D(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var i=o-1;i>=0;--i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var o=e.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,r),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=s[i%c]}return this};var z=/[^+/0-9A-Za-z-_]/g;function $(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function V(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function W(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function K(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}function Q(e){return t.toByteArray($(e))}function J(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(e,t,n){(function(r){(function(){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}function s(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}n.formatArgs=i,n.save=s,n.load=a,n.useColors=o,n.storage=c(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":19,_process:50}],19:[function(e,t,n){function r(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let t,n,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(t||o);n.diff=i,n.prev=t,n.curr=o,t=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";s++;const i=r.formatters[o];if("function"==typeof i){const r=e[s];t=i.call(n,r),e.splice(s,1),s--}return t})),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return a.namespace=e,a.useColors=r.useColors(),a.color=r.selectColor(e),a.extend=o,a.destroy=r.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==r.namespaces&&(n=r.namespaces,i=r.enabled(e)),i),set:e=>{s=e}}),"function"==typeof r.init&&r.init(a),a}function o(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function i(e){let t;r.save(e),r.namespaces=e,r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...r.names.map(c),...r.skips.map(c).map((e=>"-"+e))].join(",");return r.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1}function c(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=i,r.enabled=a,r.humanize=e("ms"),r.destroy=u,Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}t.exports=r},{ms:45}],20:[function(e,t,n){(function(n,r){(function(){var o=e("readable-stream"),i=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},u=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(n){n?u(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},f=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},p=function(){},d=function(e){return new o.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},m=function(e,t,n){if(!(this instanceof m))return new m(e,t,n);o.Duplex.call(this,n),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!n||!1!==n.autoDestroy,this._forwardDestroy=!n||!1!==n.destroy,this._forwardEnd=!n||!1!==n.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(m,o.Duplex),m.obj=function(e,t,n){return n||(n={}),n.objectMode=!0,n.highWaterMark=16,new m(e,t,n)},m.prototype.cork=function(){1==++this._corked&&this.emit("cork")},m.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},m.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=i(e,{writable:!0,readable:!1},h(this,this._forwardEnd)),o=function(){var e=t._ondrain;t._ondrain=null,e&&e()},s=function(){t._writable.removeListener("drain",o),r()};this._unwrite&&n.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=s,this.uncork()}else this.end()},m.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t=this,n=i(e,{writable:!1,readable:!0},h(this)),r=function(){t._forward()},o=function(){t.push(null)},s=function(){t._readable2.removeListener("readable",r),t._readable2.removeListener("end",o),n()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:d(e),this._readable2.on("readable",r),this._readable2.on("end",o),this._unread=s,this._forward()}},m.prototype._read=function(){this._drained=!0,this._forward()},m.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},m.prototype.destroy=function(e,t){if(t||(t=p),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},m.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},m.prototype._write=function(e,t,n){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,n)):e===c?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:this.destroyed||n()):n()},m.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){f(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)}))}))},m.prototype.end=function(e,t,n){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(c),o.Writable.prototype.end.call(this,n))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:50,buffer:17,"end-of-stream":21,inherits:24,"readable-stream":69,"stream-shift":74}],21:[function(e,t,n){(function(n){(function(){var r=e("once"),o=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},s=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,c){if("function"==typeof t)return a(e,null,t);t||(t={}),c=r(c||o);var l=e._writableState,u=e._readableState,h=t.readable||!1!==t.readable&&e.readable,f=t.writable||!1!==t.writable&&e.writable,p=!1,d=function(){e.writable||m()},m=function(){f=!1,h||c.call(e)},g=function(){h=!1,f||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},v=function(t){c.call(e,t)},b=function(){n.nextTick(w)},w=function(){if(!p)return(!h||u&&u.ended&&!u.destroyed)&&(!f||l&&l.ended&&!l.destroyed)?void 0:c.call(e,new Error("premature close"))},C=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",b),e.req?C():e.on("request",C)):f&&!l&&(e.on("end",d),e.on("close",d)),s(e)&&e.on("exit",y),e.on("end",g),e.on("finish",m),!1!==t.error&&e.on("error",v),e.on("close",b),function(){p=!0,e.removeListener("complete",m),e.removeListener("abort",b),e.removeListener("request",C),e.req&&e.req.removeListener("finish",m),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",m),e.removeListener("exit",y),e.removeListener("end",g),e.removeListener("error",v),e.removeListener("close",b)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:50,once:48}],22:[function(e,t,n){var r=Object.create||S,o=Object.keys||E,i=Function.prototype.bind||A;function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,n){if(t)e.call(n);else for(var r=e.length,o=_(e,r),i=0;i<r;++i)o[i].call(n)}function f(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].call(n,r)}function p(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=_(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function d(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=_(e,s),c=0;c<s;++c)a[c].call(n,r,o,i)}function m(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].apply(n,r)}function g(e,t,n,o){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[n,a]:[a,n]:o?a.unshift(n):a.push(n),!a.warned&&(i=u(e))&&i>0&&a.length>i){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function v(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=i.call(y,r);return o.listener=n,r.wrapFn=o,o}function b(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?k(o):_(o,o.length):[]}function w(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function C(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}function _(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function k(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function S(e){var t=function(){};return t.prototype=e,new t}function E(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t);return t}function A(e){var t=this;return function(){return t.apply(e,arguments)}}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:h(n,l,this);break;case 2:f(n,l,this,arguments[1]);break;case 3:p(n,l,this,arguments[1],arguments[2]);break;case 4:d(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];m(n,l,this,o)}return!0},s.prototype.addListener=function(e,t){return g(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return g(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,v(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,v(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():C(n,i),1===n.length&&(o[e]=n[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,i;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=o(n);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return b(this,e,!0)},s.prototype.rawListeners=function(e){return b(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},s.prototype.listenerCount=w,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(e,t,n){
|
|
1
|
+
var Amity=function(e){"use strict";var t;const r="object"==typeof globalThis?globalThis:"object"==typeof global?global:window,{process:n={}}=r,o="production"===(null===(t=n.env)||void 0===t?void 0:t.NODE_ENV);var i,s;const a=null!==(s=null===(i=n.env)||void 0===i?void 0:i.VERSION)&&void 0!==s?s:"__dev__",c="function"==typeof atob,l="function"==typeof btoa,u="function"==typeof Buffer,h="function"==typeof TextDecoder?new TextDecoder:void 0,f="function"==typeof TextEncoder?new TextEncoder:void 0,d=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),p=(e=>{let t={};return e.forEach(((e,r)=>t[e]=r)),t})(d),m=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,g=String.fromCharCode.bind(String),y="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),v=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),b=l?e=>btoa(e):u?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,r,n,o,i="";const s=e.length%3;for(let s=0;s<e.length;){if((r=e.charCodeAt(s++))>255||(n=e.charCodeAt(s++))>255||(o=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|o,i+=d[t>>18&63]+d[t>>12&63]+d[t>>6&63]+d[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},w=u?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,n=e.length;r<n;r+=4096)t.push(g.apply(null,e.subarray(r,r+4096)));return b(t.join(""))},C=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?g(192|t>>>6)+g(128|63&t):g(224|t>>>12&15)+g(128|t>>>6&63)+g(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return g(240|t>>>18&7)+g(128|t>>>12&63)+g(128|t>>>6&63)+g(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,k=u?e=>Buffer.from(e,"utf8").toString("base64"):f?e=>w(f.encode(e)):e=>b(e.replace(_,C)),S=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,E=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return g(55296+(t>>>10))+g(56320+(1023&t));case 3:return g((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return g((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},A=c?e=>atob(v(e)):u?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!m.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,r,n,o="";for(let i=0;i<e.length;)t=p[e.charAt(i++)]<<18|p[e.charAt(i++)]<<12|(r=p[e.charAt(i++)])<<6|(n=p[e.charAt(i++)]),o+=64===r?g(t>>16&255):64===n?g(t>>16&255,t>>8&255):g(t>>16&255,t>>8&255,255&t);return o},T=u?e=>y(Buffer.from(e,"base64")):e=>y(A(e),(e=>e.charCodeAt(0))),x=u?e=>Buffer.from(e,"base64").toString("utf8"):h?e=>h.decode(T(e)):e=>A(e).replace(S,E),I=e=>x(v(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),O=e=>["skip","limit"].some((t=>t in e)),R=e=>["after","before","first","last","limit"].some((t=>t in e)),P=e=>"limit"in e,B=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),N=(e,t)=>{var r;if(!e||!Object.keys(e).length)return;let n={};return"skiplimit"===t?n={skip:null!==(r=e.after)&&void 0!==r?r:0,limit:e.limit}:"afterbefore"===t&&R(e)?Number.isNaN(Number(null==e?void 0:e.before))?Number.isNaN(Number(null==e?void 0:e.after))?Number.isNaN(Number(null==e?void 0:e.limit))||(n={last:e.limit}):n={after:e.after,first:e.limit}:n={before:e.before,last:e.limit}:"afterbeforeraw"===t&&(n=e),Object.keys(n).length?((e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(k(e)):k(e))(JSON.stringify(n)):void 0},j=e=>{if(!e)return;const t=JSON.parse(I(e));if(O(t))return{after:t.skip,limit:t.limit};if(R(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}},F=e=>{if(!e)return;const t=JSON.parse(I(e));return P(t)?t:void 0},M={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,category:({categoryId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,poll:({pollId:e})=>e,reaction:({reactionId:e})=>e,stream:({streamId:e})=>e,follow:({from:e,to:t})=>`${e}#${t}`,followCount:({userId:e})=>e},U=e=>M[e],L={file:["fileId","attributes"],user:["userId","avatarFileId"],role:["roleId"],channel:["channelId","rateLimit"],channelUsers:["channelId","userId","membership"],message:["messageId"],community:["communityId","onlyAdminCanPost"],category:["categoryId"],communityUsers:["userId","communityId","communityMembership"],post:["postId","feedId"],comment:["commentId","referenceId"],poll:["pollId"],reaction:["reactionId"],stream:["streamId"],follow:["from","to"],followCount:["userId","followerCount"]},D=e=>{var t;return null===(t=Object.entries(L).find((([t,r])=>((e,t)=>{const r=Object.keys(e);return t.every((e=>r.includes(e)))})(e,r))))||void 0===t?void 0:t[0]},q={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",categories:"category",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",polls:"poll",reactions:"reaction",videoStreamings:"stream",follows:"follow",followCounts:"followCount"},z=e=>"locally"in e,$=e=>"optimistically"in e,H=e=>z(e)||$(e),V=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),W=(e,t=0)=>{var r;return Date.now()-(null!==(r=null==e?void 0:e.cachedAt)&&void 0!==r?r:0)<=t},K=(e,...t)=>({func:e,args:t}),Q=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},J=({func:e,args:t},r,n=Q("cache_then_server"))=>{let o;if(H(e)&&0!==n.lifeSpan){try{o=$(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==r||r(X(void 0,{origin:"local",loading:!1,error:e}))}const i=V(o)&&W(o,n.lifeSpan);if(null==r||r(X(o,{origin:"local",loading:!(z(e)&&i)})),i)return}else null==r||r(X(void 0,{origin:"local",loading:!0}));let i=t;if($(e)){const e=o&&o.data&&(e=>{var t;const r=D(e);if(r)return null===(t=L[r])||void 0===t?void 0:t[0]})(o.data);i=e?[Object.assign(Object.assign({},t[0]),{[e]:o.data[e]})]:t}e(...i).then((e=>{null==r||r(X(e,{origin:"server",loading:!1}))})).catch((e=>{null==r||r(X(void 0,{origin:"server",loading:!1,error:e}))}))};function X(e,t){return B(e)||V(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class Y extends Error{constructor(e,t,r){super(`Amity SDK (${t}): ${e}`),this.code=t,this.level=r,this.type="ASC",this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,Y)}}class G extends Y{constructor(e,t,r){super(e,t,r)}}class Z extends Y{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class ee extends Y{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let te=null;const re=()=>{if(!te)throw new Y("There is no active client",8e5,"fatal");return te},ne=e=>{te=e};let oe,ie=[];const se=["disconnected","error","connect_error","reconnect_error","reconnect_failed","v3.channel.didUpdate","v3.channel.didUpdate","v3.channel.didJoin","v3.channel.didLeave","v3.channel.didAddUsers","v3.channel.didRemoveUsers","v3.channel.didBan","v3.channel.didUnban","v3.message.didCreate","v3.message.didUpdate","v3.message.didDelete"],ae=["connect","message","disconnect","error","close","end","reconnect"],ce=()=>{return{all:e=e||new Map,on:function(t,r){var n=e.get(t);n?n.push(r):e.set(t,[r])},off:function(t,r){var n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var n=e.get(t);n&&n.slice().map((function(e){e(r)})),(n=e.get("*"))&&n.slice().map((function(e){e(t,r)}))}};var e},le=(e,t,r,n)=>{const{log:o,emitter:i}=e,s=Date.now();o(`${t}(tmpid: ${s}) > listen`);const a=(...e)=>{o(`${t}(tmpid: ${s}) > trigger`,e),n(...e)};return i.on(r,a),()=>{o(`${t}(tmpid: ${s}) > dispose`),i.off(r,a)}},ue=(e,t)=>{const{emitter:r}=re();var n;n=()=>{r.emit(e,t)},clearTimeout(oe),ie.push(n),oe=setTimeout((()=>{ie.forEach((e=>e())),ie=[]}),0)};let he=null;const fe=()=>{if(!he)throw new Y("Connect client first",8e5,"fatal");return he};var de;e.SubscriptionLevels=void 0,(de=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",de.POST="post",de.COMMENT="comment",de.POST_AND_COMMENT="post_and_comment",de.USER="user";const pe=(e,t)=>{switch(t){case"post":return`${e}/post/+`;case"comment":return`${e}/post/+/comment/+`;case"post_and_comment":return`${e}/post/#`;default:return e}},me=()=>{const e=fe(),[t]=e.path.split("/user/");return t};let ge,ye;function ve(e,t){const{mqtt:r,emitter:n,accessToken:o}=re(),i=fe();return ge===o&&ye===i._id||(ge=o,ye=i._id,r.connect({accessToken:ge,userId:ye}),((e,t)=>{ae.forEach((r=>{e.on(r,((...e)=>t.emit(r,1===e.length?e[0]:e)))})),e.on("message",((e,r)=>{const n=JSON.parse(r.toString());t.emit(n.eventType,n.data)}))})(r,n)),r.subscribe(e,t)}var be="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ce(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}const _e=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:ke}=Object.prototype,{propertyIsEnumerable:Se}=Object,Ee=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),Ae=be,Te={concatArrays:!1,ignoreUndefined:!1},xe=e=>{const t=[];for(const r in e)ke.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)Se.call(e,n)&&t.push(n)}return t};function Ie(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return xe(e).forEach((r=>{Ee(t,r,Ie(e[r]))})),t}(e):_e(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return xe(e).forEach((r=>{Ee(t,r,Ie(e[r]))})),t}(e):e}const Oe=(e,t,r,n)=>(r.forEach((r=>{void 0===t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?Ee(e,r,Re(e[r],t[r],n)):Ee(e,r,Ie(t[r])))})),e);function Re(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach((t=>{const i=[];for(let r=0;r<t.length;r++)ke.call(t,r)&&(i.push(String(r)),Ee(n,o++,t===e?t[r]:Ie(t[r])));n=Oe(n,t,xe(t).filter((e=>!i.includes(e))),r)})),n})(e,t,r):_e(t)&&_e(e)?Oe(e,t,xe(t),r):Ie(t)}const Pe=function(...e){const t=Re(Ie(Te),this!==Ae&&this||{},Te);let r={_:{}};for(const n of e)if(void 0!==n){if(!_e(n))throw new TypeError("`"+n+"` is not an Option Object");r=Re(r,{_:n},t)}return r._}.bind({concatArrays:!0,ignoreUndefined:!0});function Be(e,t){return new Promise(((r,n)=>{try{const n=e();null==t||t(null,n),r(n)}catch(e){null==t||t(e),n(e)}}))}function Ne(e,t,r){return Promise.all(e).then((e=>{var n;const o=null!==(n=null==r?void 0:r(e))&&void 0!==n?n:null;return null==t||t(null,o),Promise.resolve(o)}),(e=>(null==t||t(e),Promise.reject(e))))}const je={getItem:(e,t)=>Be((()=>window.localStorage.getItem(e)),t),setItem:(e,t,r)=>Be((()=>window.localStorage.setItem(e,t)),r),removeItem:(e,t)=>Be((()=>window.localStorage.removeItem(e)),t),mergeItem:(e,t,r)=>Be((()=>function(e,t){const r=window.localStorage.getItem(e);if(r){const n=JSON.parse(r),o=JSON.parse(t),i=JSON.stringify(Pe(n,o));window.localStorage.setItem(e,i)}else window.localStorage.setItem(e,t)}(e,t)),r),clear:e=>Be((()=>window.localStorage.clear()),e),getAllKeys:e=>Be((()=>{const e=window.localStorage.length,t=[];for(let r=0;r<e;r+=1){const e=window.localStorage.key(r)||"";t.push(e)}return t}),e),flushGetRequests:()=>{},multiGet:(e,t)=>Ne(e.map((e=>je.getItem(e))),t,(t=>t.map(((t,r)=>[e[r],t])))),multiSet:(e,t)=>Ne(e.map((e=>je.setItem(e[0],e[1]))),t),multiRemove:(e,t)=>Ne(e.map((e=>je.removeItem(e))),t),multiMerge:(e,t)=>Ne(e.map((e=>{var t,r;return null!==(t=null===(r=je.mergeItem)||void 0===r?void 0:r.call(je,e[0],e[1]))&&void 0!==t?t:Promise.reject("Not implemented")})),t)},Fe=e=>JSON.stringify(e,((e,t)=>{return"object"==typeof t?(r=t,Object.keys(r).sort().reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:r[t]})),{})):t;var r})),Me=e=>JSON.parse(e),Ue=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((r=>Ue(e[r],t[r])))),Le=e=>{const{log:t,cache:r}=re();if(r)return t("cache/api/queryCache",{key:e}),Object.keys(r.data).filter((t=>{const r=Me(t);return Ue(e,r)})).map((e=>r.data[e]))},De=e=>{const{log:t,cache:r}=re();if(!r)return;t("cache/api/pullFromCache",e);const n=Fe(e);return r.data[n]?r.data[n]:void 0},qe=(e,t,r={cachedAt:Date.now()})=>{const{log:n,cache:o}=re();if(!o)return!1;n("cache/api/pushToCache",{key:e,data:t,options:r}),!(null==r?void 0:r.hasOwnProperty("offline"))&&o.persistIf&&(r.offline=o.persistIf(e,t));const i=Fe(e);return o.data[i]=Object.assign({key:e,data:t},r),!0},ze=(e,t,r)=>{const{log:n,cache:o}=re();if(!o)return!1;n("cache/api/mergeInCache",{key:e,mutation:t});const i=De(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return qe(e,s,r),!0},$e=(e,t,r={cachedAt:Date.now()})=>{const{log:n,cache:o}=re();if(!o)return!1;n("cache/api/upsertInCache",{key:e,data:t,options:r});return De(e)?ze(e,t,r):qe(e,t,r)},He=(e,t=!1)=>{const{log:r,cache:n}=re();if(!n)return!1;if(r("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(n.data).map((e=>Me(e))).filter((t=>Ue(e,t))).map((e=>He(e,!0))).every((e=>e));const o=Fe(e);return o in n.data&&(delete n.data[o],!0)};var Ve={exports:{}},We=1e3,Ke=6e4,Qe=60*Ke,Je=24*Qe,Xe=7*Je,Ye=365.25*Je,Ge=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*Ye;case"weeks":case"week":case"w":return r*Xe;case"days":case"day":case"d":return r*Je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Qe;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ke;case"seconds":case"second":case"secs":case"sec":case"s":return r*We;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=Je)return Ze(e,t,Je,"day");if(t>=Qe)return Ze(e,t,Qe,"hour");if(t>=Ke)return Ze(e,t,Ke,"minute");if(t>=We)return Ze(e,t,We,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Je)return Math.round(e/Je)+"d";if(t>=Qe)return Math.round(e/Qe)+"h";if(t>=Ke)return Math.round(e/Ke)+"m";if(t>=We)return Math.round(e/We)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ze(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}var et=function(e){function t(e){let n,o,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(n||o);r.diff=i,r.prev=n,r.curr=o,n=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,o)=>{if("%%"===n)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];n=i.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=Ge,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),t.splice(o,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=et(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ve,Ve.exports);var tt=Ve.exports;const rt={EU:"eu",SG:"sg",US:"us"},nt={http:"https://api.{region}.amity.co",mqtt:"wss://sse.{region}.amity.co:443/mqtt"};function ot(e,t){return nt[e].replace("{region}",t)}var it={exports:{}},st=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},at=st,ct=Object.prototype.toString;function lt(e){return"[object Array]"===ct.call(e)}function ut(e){return void 0===e}function ht(e){return null!==e&&"object"==typeof e}function ft(e){if("[object Object]"!==ct.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function dt(e){return"[object Function]"===ct.call(e)}function pt(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),lt(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var mt={isArray:lt,isArrayBuffer:function(e){return"[object ArrayBuffer]"===ct.call(e)},isBuffer:function(e){return null!==e&&!ut(e)&&null!==e.constructor&&!ut(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:ht,isPlainObject:ft,isUndefined:ut,isDate:function(e){return"[object Date]"===ct.call(e)},isFile:function(e){return"[object File]"===ct.call(e)},isBlob:function(e){return"[object Blob]"===ct.call(e)},isFunction:dt,isStream:function(e){return ht(e)&&dt(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:pt,merge:function e(){var t={};function r(r,n){ft(t[n])&&ft(r)?t[n]=e(t[n],r):ft(r)?t[n]=e({},r):lt(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)pt(arguments[n],r);return t},extend:function(e,t,r){return pt(t,(function(t,n){e[n]=r&&"function"==typeof t?at(t,r):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},gt=mt;function yt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var vt=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(gt.isURLSearchParams(t))n=t.toString();else{var o=[];gt.forEach(t,(function(e,t){null!=e&&(gt.isArray(e)?t+="[]":e=[e],gt.forEach(e,(function(e){gt.isDate(e)?e=e.toISOString():gt.isObject(e)&&(e=JSON.stringify(e)),o.push(yt(t)+"="+yt(e))})))})),n=o.join("&")}if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},bt=mt;function wt(){this.handlers=[]}wt.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},wt.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},wt.prototype.forEach=function(e){bt.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Ct=wt,_t=mt,kt=function(e){return!(!e||!e.__CANCEL__)},St=mt,Et=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},At=function(e,t,r,n,o){var i=new Error(e);return Et(i,t,r,n,o)},Tt=At,xt=mt,It=xt.isStandardBrowserEnv()?{write:function(e,t,r,n,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),xt.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),xt.isString(n)&&s.push("path="+n),xt.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Ot=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Rt=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Pt=mt,Bt=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],Nt=mt,jt=Nt.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=Nt.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},Ft=mt,Mt=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(Tt("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},Ut=It,Lt=vt,Dt=function(e,t){return e&&!Ot(t)?Rt(e,t):t},qt=function(e){var t,r,n,o={};return e?(Pt.forEach(e.split("\n"),(function(e){if(n=e.indexOf(":"),t=Pt.trim(e.substr(0,n)).toLowerCase(),r=Pt.trim(e.substr(n+1)),t){if(o[t]&&Bt.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([r]):o[t]?o[t]+", "+r:r}})),o):o},zt=jt,$t=At,Ht=function(e){return new Promise((function(t,r){var n=e.data,o=e.headers;Ft.isFormData(n)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(s+":"+a)}var c=Dt(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),Lt(c,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in i?qt(i.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:n,config:e,request:i};Mt(t,r,o),i=null}},i.onabort=function(){i&&(r($t("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){r($t("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r($t(t,e,"ECONNABORTED",i)),i=null},Ft.isStandardBrowserEnv()){var l=(e.withCredentials||zt(c))&&e.xsrfCookieName?Ut.read(e.xsrfCookieName):void 0;l&&(o[e.xsrfHeaderName]=l)}if("setRequestHeader"in i&&Ft.forEach(o,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),Ft.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),r(e),i=null)})),n||(n=null),i.send(n)}))},Vt=mt,Wt=function(e,t){St.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},Kt={"Content-Type":"application/x-www-form-urlencoded"};function Qt(e,t){!Vt.isUndefined(e)&&Vt.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Jt,Xt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Jt=Ht),Jt),transformRequest:[function(e,t){return Wt(t,"Accept"),Wt(t,"Content-Type"),Vt.isFormData(e)||Vt.isArrayBuffer(e)||Vt.isBuffer(e)||Vt.isStream(e)||Vt.isFile(e)||Vt.isBlob(e)?e:Vt.isArrayBufferView(e)?e.buffer:Vt.isURLSearchParams(e)?(Qt(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Vt.isObject(e)?(Qt(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};Xt.headers={common:{Accept:"application/json, text/plain, */*"}},Vt.forEach(["delete","get","head"],(function(e){Xt.headers[e]={}})),Vt.forEach(["post","put","patch"],(function(e){Xt.headers[e]=Vt.merge(Kt)}));var Yt=Xt,Gt=mt,Zt=function(e,t,r){return _t.forEach(r,(function(r){e=r(e,t)})),e},er=kt,tr=Yt;function rr(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var nr=mt,or=function(e,t){t=t||{};var r={},n=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function a(e,t){return nr.isPlainObject(e)&&nr.isPlainObject(t)?nr.merge(e,t):nr.isPlainObject(t)?nr.merge({},t):nr.isArray(t)?t.slice():t}function c(n){nr.isUndefined(t[n])?nr.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}nr.forEach(n,(function(e){nr.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),nr.forEach(o,c),nr.forEach(i,(function(n){nr.isUndefined(t[n])?nr.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),nr.forEach(s,(function(n){n in t?r[n]=a(e[n],t[n]):n in e&&(r[n]=a(void 0,e[n]))}));var l=n.concat(o).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return nr.forEach(u,c),r},ir=mt,sr=vt,ar=Ct,cr=function(e){return rr(e),e.headers=e.headers||{},e.data=Zt(e.data,e.headers,e.transformRequest),e.headers=Gt.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Gt.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||tr.adapter)(e).then((function(t){return rr(e),t.data=Zt(t.data,t.headers,e.transformResponse),t}),(function(t){return er(t)||(rr(e),t&&t.response&&(t.response.data=Zt(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},lr=or;function ur(e){this.defaults=e,this.interceptors={request:new ar,response:new ar}}ur.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=lr(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[cr,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},ur.prototype.getUri=function(e){return e=lr(this.defaults,e),sr(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ir.forEach(["delete","get","head","options"],(function(e){ur.prototype[e]=function(t,r){return this.request(lr(r||{},{method:e,url:t,data:(r||{}).data}))}})),ir.forEach(["post","put","patch"],(function(e){ur.prototype[e]=function(t,r,n){return this.request(lr(n||{},{method:e,url:t,data:r}))}}));var hr=ur;function fr(e){this.message=e}fr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},fr.prototype.__CANCEL__=!0;var dr=fr,pr=dr;function mr(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new pr(e),t(r.reason))}))}mr.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},mr.source=function(){var e;return{token:new mr((function(t){e=t})),cancel:e}};var gr=mr,yr=mt,vr=st,br=hr,wr=or;function Cr(e){var t=new br(e),r=vr(br.prototype.request,t);return yr.extend(r,br.prototype,t),yr.extend(r,t),r}var _r=Cr(Yt);_r.Axios=br,_r.create=function(e){return Cr(wr(_r.defaults,e))},_r.Cancel=dr,_r.CancelToken=gr,_r.isCancel=kt,_r.all=function(e){return Promise.all(e)},_r.spread=function(e){return function(t){return e.apply(null,t)}},_r.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},it.exports=_r,it.exports.default=_r;var kr=it.exports,Sr={exports:{}};Sr.exports=Ar;var Er=Sr.exports.HttpsAgent=Ar;function Ar(){}var Tr=Sr.exports;const xr=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new Z(e.code);if("error"===e.status)throw new G(e.message,e.code,"error")},Ir=(e,t)=>Object.entries(e).filter((([,e])=>void 0!==e)).map((([e,r])=>{const n=t?`${t}[${e}]`:e;return Array.isArray(r)?r.map((e=>`${n}[]=${e}`)).join("&"):"object"!=typeof r?`${n}=${r}`:Ir(r,null!=t?t:e)})).join("&"),Or=e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},r=kr.create({baseURL:e,httpAgent:new Tr(t),httpsAgent:new Er(t),paramsSerializer:Ir});return r.interceptors.response.use((e=>e),(e=>{var t;const{response:r}=e;console.error(null!==(t=null==r?void 0:r.data)&&void 0!==t?t:e),r&&xr(r.data)})),r};var Rr={exports:{}},Pr=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Br=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Nr=function(e){var t=e,r=e.indexOf("["),n=e.indexOf("]");-1!=r&&-1!=n&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));for(var o=Pr.exec(e||""),i={},s=14;s--;)i[Br[s]]=o[s]||"";return-1!=r&&-1!=n&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i},jr={exports:{}},Fr={exports:{}},Mr=1e3,Ur=6e4,Lr=60*Ur,Dr=24*Lr,qr=365.25*Dr,zr=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*qr;case"days":case"day":case"d":return r*Dr;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Lr;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ur;case"seconds":case"second":case"secs":case"sec":case"s":return r*Mr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&!1===isNaN(e))return t.long?function(e){return $r(e,Dr,"day")||$r(e,Lr,"hour")||$r(e,Ur,"minute")||$r(e,Mr,"second")||e+" ms"}(e):function(e){if(e>=Dr)return Math.round(e/Dr)+"d";if(e>=Lr)return Math.round(e/Lr)+"h";if(e>=Ur)return Math.round(e/Ur)+"m";if(e>=Mr)return Math.round(e/Mr)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function $r(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}!function(e,t){function r(e){var r;function o(){if(o.enabled){var e=o,n=+new Date,i=n-(r||n);e.diff=i,e.prev=r,e.curr=n,r=n;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=s[c];r=o.call(e,i),s.splice(c,1),c--}return r})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),o.destroy=n,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function n(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var r;t.save(e),t.names=[],t.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(r=0;r<t.instances.length;r++){var i=t.instances[r];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=zr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Fr,Fr.exports),function(e,t){function r(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Fr.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=r,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}(jr,jr.exports);var Hr=Nr,Vr=jr.exports("socket.io-client:url"),Wr=function(e,t){var r=e;t=t||"undefined"!=typeof location&&location,null==e&&(e=t.protocol+"//"+t.host);"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?t.protocol+e:t.host+e),/^(https?|wss?):\/\//.test(e)||(Vr("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),Vr("parse %s",e),r=Hr(e));r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443"));r.path=r.path||"/";var n=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+n+":"+r.port,r.href=r.protocol+"://"+n+(t&&t.port===r.port?"":":"+r.port),r};var Kr={},Qr={exports:{}},Jr={exports:{}},Xr=1e3,Yr=6e4,Gr=60*Yr,Zr=24*Gr,en=365.25*Zr,tn=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*en;case"days":case"day":case"d":return r*Zr;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Gr;case"minutes":case"minute":case"mins":case"min":case"m":return r*Yr;case"seconds":case"second":case"secs":case"sec":case"s":return r*Xr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&!1===isNaN(e))return t.long?function(e){return rn(e,Zr,"day")||rn(e,Gr,"hour")||rn(e,Yr,"minute")||rn(e,Xr,"second")||e+" ms"}(e):function(e){if(e>=Zr)return Math.round(e/Zr)+"d";if(e>=Gr)return Math.round(e/Gr)+"h";if(e>=Yr)return Math.round(e/Yr)+"m";if(e>=Xr)return Math.round(e/Xr)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function rn(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}!function(e,t){function r(e){var r;function o(){if(o.enabled){var e=o,n=+new Date,i=n-(r||n);e.diff=i,e.prev=r,e.curr=n,r=n;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=s[c];r=o.call(e,i),s.splice(c,1),c--}return r})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),o.destroy=n,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function n(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var r;t.save(e),t.names=[],t.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(r=0;r<t.instances.length;r++){var i=t.instances[r];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=tn,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Jr,Jr.exports),function(e,t){function r(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Jr.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=r,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}(Qr,Qr.exports);var nn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var r in t.prototype)e[r]=t.prototype[r];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(nn);var on={},sn={}.toString,an=Array.isArray||function(e){return"[object Array]"==sn.call(e)},cn=function(e){return ln&&Buffer.isBuffer(e)||un&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},ln="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,un="function"==typeof ArrayBuffer;var hn=an,fn=cn,dn=Object.prototype.toString,pn="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===dn.call(Blob),mn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===dn.call(File);function gn(e,t){if(!e)return e;if(fn(e)){var r={_placeholder:!0,num:t.length};return t.push(e),r}if(hn(e)){for(var n=new Array(e.length),o=0;o<e.length;o++)n[o]=gn(e[o],t);return n}if("object"==typeof e&&!(e instanceof Date)){n={};for(var i in e)n[i]=gn(e[i],t);return n}return e}function yn(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(hn(e))for(var r=0;r<e.length;r++)e[r]=yn(e[r],t);else if("object"==typeof e)for(var n in e)e[n]=yn(e[n],t);return e}on.deconstructPacket=function(e){var t=[],r=e.data,n=e;return n.data=gn(r,t),n.attachments=t.length,{packet:n,buffers:t}},on.reconstructPacket=function(e,t){return e.data=yn(e.data,t),e.attachments=void 0,e},on.removeBlobs=function(e,t){var r=0,n=e;!function e(o,i,s){if(!o)return o;if(pn&&o instanceof Blob||mn&&o instanceof File){r++;var a=new FileReader;a.onload=function(){s?s[i]=this.result:n=this.result,--r||t(n)},a.readAsArrayBuffer(o)}else if(hn(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!fn(o))for(var l in o)e(o[l],l,o)}(n),r||t(n)},function(e){var t=Qr.exports("socket.io-parser"),r=nn.exports,n=on,o=an,i=cn;function s(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=s,e.Decoder=l;var a=e.ERROR+'"encode error"';function c(r){var n=""+r.type;if(e.BINARY_EVENT!==r.type&&e.BINARY_ACK!==r.type||(n+=r.attachments+"-"),r.nsp&&"/"!==r.nsp&&(n+=r.nsp+","),null!=r.id&&(n+=r.id),null!=r.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(r.data);if(!1===o)return a;n+=o}return t("encoded %j as %s",r,n),n}function l(){this.reconstructor=null}function u(e){this.reconPack=e,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}s.prototype.encode=function(r,o){(t("encoding packet %j",r),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type)?function(e,t){function r(e){var r=n.deconstructPacket(e),o=c(r.packet),i=r.buffers;i.unshift(o),t(i)}n.removeBlobs(e,r)}(r,o):o([c(r)])},r(l.prototype),l.prototype.add=function(r){var n;if("string"==typeof r)n=function(r){var n=0,i={type:Number(r.charAt(0))};if(null==e.types[i.type])return h("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s=n+1;"-"!==r.charAt(++n)&&n!=r.length;);var a=r.substring(s,n);if(a!=Number(a)||"-"!==r.charAt(n))throw new Error("Illegal attachments");i.attachments=Number(a)}if("/"===r.charAt(n+1)){for(s=n+1;++n;){if(","===(l=r.charAt(n)))break;if(n===r.length)break}i.nsp=r.substring(s,n)}else i.nsp="/";var c=r.charAt(n+1);if(""!==c&&Number(c)==c){for(s=n+1;++n;){var l;if(null==(l=r.charAt(n))||Number(l)!=l){--n;break}if(n===r.length)break}i.id=Number(r.substring(s,n+1))}if(r.charAt(++n)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(r.substr(n));if(!(!1!==u&&(i.type===e.ERROR||o(u))))return h("invalid payload");i.data=u}return t("decoded %s as %j",r,i),i}(r),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type?(this.reconstructor=new u(n),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",n)):this.emit("decoded",n);else{if(!i(r)&&!r.base64)throw new Error("Unknown type: "+r);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(n=this.reconstructor.takeBinaryData(r))&&(this.reconstructor=null,this.emit("decoded",n))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},u.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},u.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(Kr);var vn={exports:{}},bn={},wn={exports:{}};try{wn.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){wn.exports=!1}var Cn=wn.exports,_n=function(e){var t=e.xdomain,r=e.xscheme,n=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Cn))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!r&&n)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},kn={exports:{}},Sn={},En=Object.keys||function(e){var t=[],r=Object.prototype.hasOwnProperty;for(var n in e)r.call(e,n)&&t.push(n);return t},An={}.toString,Tn=Array.isArray||function(e){return"[object Array]"==An.call(e)},xn=Object.prototype.toString,In="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===xn.call(Blob),On="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===xn.call(File),Rn=function e(t){if(!t||"object"!=typeof t)return!1;if(Tn(t)){for(var r=0,n=t.length;r<n;r++)if(e(t[r]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||In&&t instanceof Blob||On&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&e(t[o]))return!0;return!1};var Pn=function(e,t,r){var n=e.byteLength;if(t=t||0,r=r||n,e.slice)return e.slice(t,r);if(t<0&&(t+=n),r<0&&(r+=n),r>n&&(r=n),t>=n||t>=r||0===n)return new ArrayBuffer(0);for(var o=new Uint8Array(e),i=new Uint8Array(r-t),s=t,a=0;s<r;s++,a++)i[a]=o[s];return i.buffer},Bn=function(e,t,r){var n=!1;return r=r||Nn,o.count=e,0===e?t():o;function o(e,i){if(o.count<=0)throw new Error("after called too many times");--o.count,e?(n=!0,t(e),t=r):0!==o.count||n||t(null,i)}};function Nn(){}
|
|
2
|
+
/*! https://mths.be/utf8js v2.1.2 by @mathias */var jn,Fn,Mn,Un=String.fromCharCode;function Ln(e){for(var t,r,n=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(r=e.charCodeAt(o++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),o--):n.push(t);return n}function Dn(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function qn(e,t){return Un(e>>t&63|128)}function zn(e,t){if(0==(4294967168&e))return Un(e);var r="";return 0==(4294965248&e)?r=Un(e>>6&31|192):0==(4294901760&e)?(Dn(e,t)||(e=65533),r=Un(e>>12&15|224),r+=qn(e,6)):0==(4292870144&e)&&(r=Un(e>>18&7|240),r+=qn(e,12),r+=qn(e,6)),r+=Un(63&e|128)}function $n(){if(Mn>=Fn)throw Error("Invalid byte index");var e=255&jn[Mn];if(Mn++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function Hn(e){var t,r;if(Mn>Fn)throw Error("Invalid byte index");if(Mn==Fn)return!1;if(t=255&jn[Mn],Mn++,0==(128&t))return t;if(192==(224&t)){if((r=(31&t)<<6|$n())>=128)return r;throw Error("Invalid continuation byte")}if(224==(240&t)){if((r=(15&t)<<12|$n()<<6|$n())>=2048)return Dn(r,e)?r:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(r=(7&t)<<18|$n()<<12|$n()<<6|$n())>=65536&&r<=1114111)return r;throw Error("Invalid UTF-8 detected")}var Vn={version:"2.1.2",encode:function(e,t){for(var r=!1!==(t=t||{}).strict,n=Ln(e),o=n.length,i=-1,s="";++i<o;)s+=zn(n[i],r);return s},decode:function(e,t){var r=!1!==(t=t||{}).strict;jn=Ln(e),Fn=jn.length,Mn=0;for(var n,o=[];!1!==(n=Hn(r));)o.push(n);return function(e){for(var t,r=e.length,n=-1,o="";++n<r;)(t=e[n])>65535&&(o+=Un((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Un(t);return o}(o)}},Wn={};!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=new Uint8Array(256),r=0;r<e.length;r++)t[e.charCodeAt(r)]=r;Wn.encode=function(t){var r,n=new Uint8Array(t),o=n.length,i="";for(r=0;r<o;r+=3)i+=e[n[r]>>2],i+=e[(3&n[r])<<4|n[r+1]>>4],i+=e[(15&n[r+1])<<2|n[r+2]>>6],i+=e[63&n[r+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},Wn.decode=function(e){var r,n,o,i,s,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),h=new Uint8Array(u);for(r=0;r<c;r+=4)n=t[e.charCodeAt(r)],o=t[e.charCodeAt(r+1)],i=t[e.charCodeAt(r+2)],s=t[e.charCodeAt(r+3)],h[l++]=n<<2|o>>4,h[l++]=(15&o)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return u}}();var Kn=void 0!==Kn?Kn:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,Qn=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),Jn=Qn&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),Xn=Kn&&Kn.prototype.append&&Kn.prototype.getBlob;function Yn(e){return e.map((function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var r=new Uint8Array(e.byteLength);r.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=r.buffer}return t}return e}))}function Gn(e,t){t=t||{};var r=new Kn;return Yn(e).forEach((function(e){r.append(e)})),t.type?r.getBlob(t.type):r.getBlob()}function Zn(e,t){return new Blob(Yn(e),t||{})}"undefined"!=typeof Blob&&(Gn.prototype=Blob.prototype,Zn.prototype=Blob.prototype);var eo=Qn?Jn?Blob:Zn:Xn?Gn:void 0;!function(e){var t,r=En,n=Rn,o=Pn,i=Bn,s=Vn;"undefined"!=typeof ArrayBuffer&&(t=Wn);var a="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),c="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),l=a||c;e.protocol=3;var u=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},h=r(u),f={type:"error",data:"parser error"},d=eo;function p(e,t,r){for(var n=new Array(e.length),o=i(e.length,r),s=function(e,r,o){t(r,(function(t,r){n[e]=r,o(t,n)}))},a=0;a<e.length;a++)s(a,e[a],o)}e.encodePacket=function(t,r,n,o){"function"==typeof r&&(o=r,r=!1),"function"==typeof n&&(o=n,n=null);var i=void 0===t.data?void 0:t.data.buffer||t.data;if("undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer)return function(t,r,n){if(!r)return e.encodeBase64Packet(t,n);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=u[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return n(s.buffer)}(t,r,o);if(void 0!==d&&i instanceof d)return function(t,r,n){if(!r)return e.encodeBase64Packet(t,n);if(l)return function(t,r,n){if(!r)return e.encodeBase64Packet(t,n);var o=new FileReader;return o.onload=function(){e.encodePacket({type:t.type,data:o.result},r,!0,n)},o.readAsArrayBuffer(t.data)}(t,r,n);var o=new Uint8Array(1);o[0]=u[t.type];var i=new d([o.buffer,t.data]);return n(i)}(t,r,o);if(i&&i.base64)return function(t,r){var n="b"+e.packets[t.type]+t.data.data;return r(n)}(t,o);var a=u[t.type];return void 0!==t.data&&(a+=n?s.encode(String(t.data),{strict:!1}):String(t.data)),o(""+a)},e.encodeBase64Packet=function(t,r){var n,o="b"+e.packets[t.type];if(void 0!==d&&t.data instanceof d){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];r(o+e)},i.readAsDataURL(t.data)}try{n=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];n=String.fromCharCode.apply(null,a)}return o+=btoa(n),r(o)},e.decodePacket=function(t,r,n){if(void 0===t)return f;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),r);if(n&&!1===(t=function(e){try{e=s.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return f;var i=t.charAt(0);return Number(i)==i&&h[i]?t.length>1?{type:h[i],data:t.substring(1)}:{type:h[i]}:f}i=new Uint8Array(t)[0];var a=o(t,1);return d&&"blob"===r&&(a=new d([a])),{type:h[i],data:a}},e.decodeBase64Packet=function(e,r){var n=h[e.charAt(0)];if(!t)return{type:n,data:{base64:!0,data:e.substr(1)}};var o=t.decode(e.substr(1));return"blob"===r&&d&&(o=new d([o])),{type:n,data:o}},e.encodePayload=function(t,r,o){"function"==typeof r&&(o=r,r=null);var i=n(t);if(r&&i)return d&&!l?e.encodePayloadAsBlob(t,o):e.encodePayloadAsArrayBuffer(t,o);if(!t.length)return o("0:");p(t,(function(t,n){e.encodePacket(t,!!i&&r,!1,(function(e){n(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return o(t.join(""))}))},e.decodePayload=function(t,r,n){if("string"!=typeof t)return e.decodePayloadAsBinary(t,r,n);var o;if("function"==typeof r&&(n=r,r=null),""===t)return n(f,0,1);for(var i,s,a="",c=0,l=t.length;c<l;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return n(f,0,1);if(a!=(s=t.substr(c+1,i)).length)return n(f,0,1);if(s.length){if(o=e.decodePacket(s,r,!1),f.type===o.type&&f.data===o.data)return n(f,0,1);if(!1===n(o,c+i,l))return}c+=i,a=""}else a+=u}return""!==a?n(f,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,r){if(!t.length)return r(new ArrayBuffer(0));p(t,(function(t,r){e.encodePacket(t,!0,!0,(function(e){return r(null,e)}))}),(function(e,t){var n=t.reduce((function(e,t){var r;return e+(r="string"==typeof t?t.length:t.byteLength).toString().length+r+2}),0),o=new Uint8Array(n),i=0;return t.forEach((function(e){var t="string"==typeof e,r=e;if(t){for(var n=new Uint8Array(e.length),s=0;s<e.length;s++)n[s]=e.charCodeAt(s);r=n.buffer}o[i++]=t?0:1;var a=r.byteLength.toString();for(s=0;s<a.length;s++)o[i++]=parseInt(a[s]);o[i++]=255;for(n=new Uint8Array(r),s=0;s<n.length;s++)o[i++]=n[s]})),r(o.buffer)}))},e.encodePayloadAsBlob=function(t,r){p(t,(function(t,r){e.encodePacket(t,!0,!0,(function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var n=new Uint8Array(e.length),o=0;o<e.length;o++)n[o]=e.charCodeAt(o);e=n.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,d){var a=new d([t.buffer,s.buffer,e]);r(null,a)}}))}),(function(e,t){return r(new d(t))}))},e.decodePayloadAsBinary=function(t,r,n){"function"==typeof r&&(n=r,r=null);for(var i=t,s=[];i.byteLength>0;){for(var a=new Uint8Array(i),c=0===a[0],l="",u=1;255!==a[u];u++){if(l.length>310)return n(f,0,1);l+=a[u]}i=o(i,2+l.length),l=parseInt(l);var h=o(i,0,l);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var d=new Uint8Array(h);h="";for(u=0;u<d.length;u++)h+=String.fromCharCode(d[u])}s.push(h),i=o(i,l)}var p=s.length;s.forEach((function(t,o){n(e.decodePacket(t,r,!0),o,p)}))}}(Sn);var to={exports:{}};!function(e){function t(e){if(e)return function(e){for(var r in t.prototype)e[r]=t.prototype[r];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),r=this._callbacks["$"+e];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(to);var ro=Sn,no=oo;function oo(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}(0,to.exports)(oo.prototype),oo.prototype.onError=function(e,t){var r=new Error(e);return r.type="TransportError",r.description=t,this.emit("error",r),this},oo.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},oo.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},oo.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},oo.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},oo.prototype.onData=function(e){var t=ro.decodePacket(e,this.socket.binaryType);this.onPacket(t)},oo.prototype.onPacket=function(e){this.emit("packet",e)},oo.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var io,so={encode:function(e){var t="";for(var r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t},decode:function(e){for(var t={},r=e.split("&"),n=0,o=r.length;n<o;n++){var i=r[n].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},ao=function(e,t){var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},co="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),lo={},uo=0,ho=0;function fo(e){var t="";do{t=co[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function po(){var e=fo(+new Date);return e!==io?(uo=0,io=e):e+"."+fo(uo++)}for(;ho<64;ho++)lo[co[ho]]=ho;po.encode=fo,po.decode=function(e){var t=0;for(ho=0;ho<e.length;ho++)t=64*t+lo[e.charAt(ho)];return t};var mo=po,go={exports:{}},yo={exports:{}},vo=1e3,bo=60*vo,wo=60*bo,Co=24*wo,_o=365.25*Co,ko=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*_o;case"days":case"day":case"d":return r*Co;case"hours":case"hour":case"hrs":case"hr":case"h":return r*wo;case"minutes":case"minute":case"mins":case"min":case"m":return r*bo;case"seconds":case"second":case"secs":case"sec":case"s":return r*vo;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&!1===isNaN(e))return t.long?function(e){return So(e,Co,"day")||So(e,wo,"hour")||So(e,bo,"minute")||So(e,vo,"second")||e+" ms"}(e):function(e){if(e>=Co)return Math.round(e/Co)+"d";if(e>=wo)return Math.round(e/wo)+"h";if(e>=bo)return Math.round(e/bo)+"m";if(e>=vo)return Math.round(e/vo)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function So(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}!function(e,t){function r(e){var r;function o(){if(o.enabled){var e=o,n=+new Date,i=n-(r||n);e.diff=i,e.prev=r,e.curr=n,r=n;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(r,n){if("%%"===r)return r;c++;var o=t.formatters[n];if("function"==typeof o){var i=s[c];r=o.call(e,i),s.splice(c,1),c--}return r})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),o.destroy=n,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function n(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=r.debug=r.default=r).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var r;t.save(e),t.names=[],t.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(r=0;r<t.instances.length;r++){var i=t.instances[r];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=ko,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(yo,yo.exports),function(e,t){function r(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=yo.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=r,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}(go,go.exports);var Eo=no,Ao=so,To=Sn,xo=ao,Io=mo,Oo=go.exports("engine.io-client:polling"),Ro=Bo,Po=null!=new _n({xdomain:!1}).responseType;function Bo(e){var t=e&&e.forceBase64;Po&&!t||(this.supportsBinary=!1),Eo.call(this,e)}xo(Bo,Eo),Bo.prototype.name="polling",Bo.prototype.doOpen=function(){this.poll()},Bo.prototype.pause=function(e){var t=this;function r(){Oo("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var n=0;this.polling&&(Oo("we are currently polling - waiting to pause"),n++,this.once("pollComplete",(function(){Oo("pre-pause polling complete"),--n||r()}))),this.writable||(Oo("we are currently writing - waiting to pause"),n++,this.once("drain",(function(){Oo("pre-pause writing complete"),--n||r()})))}else r()},Bo.prototype.poll=function(){Oo("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},Bo.prototype.onData=function(e){var t=this;Oo("polling got data %s",e);To.decodePayload(e,this.socket.binaryType,(function(e,r,n){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():Oo('ignoring poll - transport state "%s"',this.readyState))},Bo.prototype.doClose=function(){var e=this;function t(){Oo("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Oo("transport open - closing"),t()):(Oo("transport not open - deferring close"),this.once("open",t))},Bo.prototype.write=function(e){var t=this;this.writable=!1;var r=function(){t.writable=!0,t.emit("drain")};To.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,r)}))},Bo.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",r="";return!1!==this.timestampRequests&&(e[this.timestampParam]=Io()),this.supportsBinary||e.sid||(e.b64=1),e=Ao.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(r=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+r+this.path+e};var No=_n,jo=Ro,Fo=to.exports,Mo=ao,Uo=go.exports("engine.io-client:polling-xhr");function Lo(){}function Do(e){if(jo.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,"undefined"!=typeof location){var t="https:"===location.protocol,r=location.port;r||(r=t?443:80),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port,this.xs=e.secure!==t}}function qo(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}if(kn.exports=Do,kn.exports.Request=qo,Mo(Do,jo),Do.prototype.supportsBinary=!0,Do.prototype.request=function(e){return(e=e||{}).uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new qo(e)},Do.prototype.doWrite=function(e,t){var r="string"!=typeof e&&void 0!==e,n=this.request({method:"POST",data:e,isBinary:r}),o=this;n.on("success",t),n.on("error",(function(e){o.onError("xhr post error",e)})),this.sendXhr=n},Do.prototype.doPoll=function(){Uo("xhr poll");var e=this.request(),t=this;e.on("data",(function(e){t.onData(e)})),e.on("error",(function(e){t.onError("xhr poll error",e)})),this.pollXhr=e},Fo(qo.prototype),qo.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new No(e),r=this;try{Uo("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders)for(var n in t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0),this.extraHeaders)this.extraHeaders.hasOwnProperty(n)&&t.setRequestHeader(n,this.extraHeaders[n])}catch(e){}if("POST"===this.method)try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=!0),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){r.onLoad()},t.onerror=function(){r.onError(t.responseText)}):t.onreadystatechange=function(){if(2===t.readyState)try{var e=t.getResponseHeader("Content-Type");r.supportsBinary&&"application/octet-stream"===e&&(t.responseType="arraybuffer")}catch(e){}4===t.readyState&&(200===t.status||1223===t.status?r.onLoad():setTimeout((function(){r.onError(t.status)}),0))},Uo("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){r.onError(e)}),0)}"undefined"!=typeof document&&(this.index=qo.requestsCount++,qo.requests[this.index]=this)},qo.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},qo.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},qo.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},qo.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Lo:this.xhr.onreadystatechange=Lo,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete qo.requests[this.index],this.xhr=null}},qo.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch(e){}e="application/octet-stream"===t&&this.xhr.response||this.xhr.responseText}catch(e){this.onError(e)}null!=e&&this.onData(e)},qo.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},qo.prototype.abort=function(){this.cleanup()},qo.requestsCount=0,qo.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",$o);else if("function"==typeof addEventListener){var zo="onpagehide"in self?"pagehide":"unload";addEventListener(zo,$o,!1)}function $o(){for(var e in qo.requests)qo.requests.hasOwnProperty(e)&&qo.requests[e].abort()}var Ho,Vo=Ro,Wo=Yo,Ko=/\n/g,Qo=/\\n/g;function Jo(){}function Xo(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==be?be:{}}function Yo(e){if(Vo.call(this,e),this.query=this.query||{},!Ho){var t=Xo();Ho=t.___eio=t.___eio||[]}this.index=Ho.length;var r=this;Ho.push((function(e){r.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){r.script&&(r.script.onerror=Jo)}),!1)}ao(Yo,Vo),Yo.prototype.supportsBinary=!1,Yo.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),Vo.prototype.doClose.call(this)},Yo.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var r=document.getElementsByTagName("script")[0];r?r.parentNode.insertBefore(t,r):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)}),100)},Yo.prototype.doWrite=function(e,t){var r=this;if(!this.form){var n,o=document.createElement("form"),i=document.createElement("textarea"),s=this.iframeId="eio_iframe_"+this.index;o.className="socketio",o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px",o.target=s,o.method="POST",o.setAttribute("accept-charset","utf-8"),i.name="d",o.appendChild(i),document.body.appendChild(o),this.form=o,this.area=i}function a(){c(),t()}function c(){if(r.iframe)try{r.form.removeChild(r.iframe)}catch(e){r.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+r.iframeId+'">';n=document.createElement(e)}catch(e){(n=document.createElement("iframe")).name=r.iframeId,n.src="javascript:0"}n.id=r.iframeId,r.form.appendChild(n),r.iframe=n}this.form.action=this.uri(),c(),e=e.replace(Qo,"\\\n"),this.area.value=e.replace(Ko,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===r.iframe.readyState&&a()}:this.iframe.onload=a};var Go,Zo,ei=no,ti=Sn,ri=so,ni=ao,oi=mo,ii=go.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)Go=WebSocket;else if("undefined"!=typeof self)Go=self.WebSocket||self.MozWebSocket;else try{Zo=require("ws")}catch(e){}var si=Go||Zo,ai=ci;function ci(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=Go&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(si=Zo),ei.call(this,e)}ni(ci,ei),ci.prototype.name="websocket",ci.prototype.supportsBinary=!0,ci.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,r={agent:this.agent,perMessageDeflate:this.perMessageDeflate};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(r.headers=this.extraHeaders),this.localAddress&&(r.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new si(e,t):new si(e):new si(e,t,r)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},ci.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},ci.prototype.write=function(e){var t=this;this.writable=!1;for(var r=e.length,n=0,o=r;n<o;n++)!function(e){ti.encodePacket(e,t.supportsBinary,(function(n){if(!t.usingBrowserWebSocket){var o={};if(e.options&&(o.compress=e.options.compress),t.perMessageDeflate)("string"==typeof n?Buffer.byteLength(n):n.length)<t.perMessageDeflate.threshold&&(o.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(n):t.ws.send(n,o)}catch(e){ii("websocket closed before onclose event")}--r||i()}))}(e[n]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},ci.prototype.onClose=function(){ei.prototype.onClose.call(this)},ci.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},ci.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",r="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(r=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=oi()),this.supportsBinary||(e.b64=1),(e=ri.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+r+this.path+e},ci.prototype.check=function(){return!(!si||"__initialize"in si&&this.name===ci.prototype.name)};var li=_n,ui=kn.exports,hi=Wo,fi=ai;bn.polling=function(e){var t=!1,r=!1,n=!1!==e.jsonp;if("undefined"!=typeof location){var o="https:"===location.protocol,i=location.port;i||(i=o?443:80),t=e.hostname!==location.hostname||i!==e.port,r=e.secure!==o}if(e.xdomain=t,e.xscheme=r,"open"in new li(e)&&!e.forceJSONP)return new ui(e);if(!n)throw new Error("JSONP disabled");return new hi(e)},bn.websocket=fi;var di=[].indexOf,pi=function(e,t){if(di)return e.indexOf(t);for(var r=0;r<e.length;++r)if(e[r]===t)return r;return-1},mi=bn,gi=to.exports,yi=go.exports("engine.io-client:socket"),vi=pi,bi=Sn,wi=Nr,Ci=so,_i=ki;function ki(e,t){if(!(this instanceof ki))return new ki(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=wi(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=wi(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=Ci.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||null,this.key=t.key||null,this.passphrase=t.passphrase||null,this.cert=t.cert||null,this.ca=t.ca||null,this.ciphers=t.ciphers||null,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}ki.priorWebsocketSuccess=!1,gi(ki.prototype),ki.protocol=bi.protocol,ki.Socket=ki,ki.Transport=no,ki.transports=bn,ki.parser=Sn,ki.prototype.createTransport=function(e){yi('creating transport "%s"',e);var t=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}(this.query);t.EIO=bi.protocol,t.transport=e;var r=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new mi[e]({query:t,socket:this,agent:r.agent||this.agent,hostname:r.hostname||this.hostname,port:r.port||this.port,secure:r.secure||this.secure,path:r.path||this.path,forceJSONP:r.forceJSONP||this.forceJSONP,jsonp:r.jsonp||this.jsonp,forceBase64:r.forceBase64||this.forceBase64,enablesXDR:r.enablesXDR||this.enablesXDR,timestampRequests:r.timestampRequests||this.timestampRequests,timestampParam:r.timestampParam||this.timestampParam,policyPort:r.policyPort||this.policyPort,pfx:r.pfx||this.pfx,key:r.key||this.key,passphrase:r.passphrase||this.passphrase,cert:r.cert||this.cert,ca:r.ca||this.ca,ciphers:r.ciphers||this.ciphers,rejectUnauthorized:r.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:r.perMessageDeflate||this.perMessageDeflate,extraHeaders:r.extraHeaders||this.extraHeaders,forceNode:r.forceNode||this.forceNode,localAddress:r.localAddress||this.localAddress,requestTimeout:r.requestTimeout||this.requestTimeout,protocols:r.protocols||void 0,isReactNative:this.isReactNative})},ki.prototype.open=function(){var e;if(this.rememberUpgrade&&ki.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout((function(){t.emit("error","No transports available")}),0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},ki.prototype.setTransport=function(e){yi("setting transport %s",e.name);var t=this;this.transport&&(yi("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",(function(){t.onDrain()})).on("packet",(function(e){t.onPacket(e)})).on("error",(function(e){t.onError(e)})).on("close",(function(){t.onClose("transport close")}))},ki.prototype.probe=function(e){yi('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),r=!1,n=this;function o(){if(n.onlyBinaryUpgrades){var o=!this.supportsBinary&&n.transport.supportsBinary;r=r||o}r||(yi('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(o){if(!r)if("pong"===o.type&&"probe"===o.data){if(yi('probe transport "%s" pong',e),n.upgrading=!0,n.emit("upgrading",t),!t)return;ki.priorWebsocketSuccess="websocket"===t.name,yi('pausing current transport "%s"',n.transport.name),n.transport.pause((function(){r||"closed"!==n.readyState&&(yi("changing transport and sending upgrade packet"),u(),n.setTransport(t),t.send([{type:"upgrade"}]),n.emit("upgrade",t),t=null,n.upgrading=!1,n.flush())}))}else{yi('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,n.emit("upgradeError",i)}})))}function i(){r||(r=!0,u(),t.close(),t=null)}function s(r){var o=new Error("probe error: "+r);o.transport=t.name,i(),yi('probe transport "%s" failed because of error: %s',e,r),n.emit("upgradeError",o)}function a(){s("transport closed")}function c(){s("socket closed")}function l(e){t&&e.name!==t.name&&(yi('"%s" works - aborting "%s"',e.name,t.name),i())}function u(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),n.removeListener("close",c),n.removeListener("upgrading",l)}ki.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()},ki.prototype.onOpen=function(){if(yi("socket open"),this.readyState="open",ki.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){yi("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},ki.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(yi('socket receive: type "%s", data "%s"',e.type,e.data),this.emit("packet",e),this.emit("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emit("data",e.data),this.emit("message",e.data)}else yi('packet received with socket readyState "%s"',this.readyState)},ki.prototype.onHandshake=function(e){this.emit("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},ki.prototype.onHeartbeat=function(e){clearTimeout(this.pingTimeoutTimer);var t=this;t.pingTimeoutTimer=setTimeout((function(){"closed"!==t.readyState&&t.onClose("ping timeout")}),e||t.pingInterval+t.pingTimeout)},ki.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){yi("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},ki.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},ki.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},ki.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(yi("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},ki.prototype.write=ki.prototype.send=function(e,t,r){return this.sendPacket("message",e,t,r),this},ki.prototype.sendPacket=function(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r=null),"closing"!==this.readyState&&"closed"!==this.readyState){(r=r||{}).compress=!1!==r.compress;var o={type:e,data:t,options:r};this.emit("packetCreate",o),this.writeBuffer.push(o),n&&this.once("flush",n),this.flush()}},ki.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var e=this;this.writeBuffer.length?this.once("drain",(function(){this.upgrading?n():t()})):this.upgrading?n():t()}function t(){e.onClose("forced close"),yi("socket closing - telling transport to close"),e.transport.close()}function r(){e.removeListener("upgrade",r),e.removeListener("upgradeError",r),t()}function n(){e.once("upgrade",r),e.once("upgradeError",r)}return this},ki.prototype.onError=function(e){yi("socket error %j",e),ki.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},ki.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){yi('socket close with reason: "%s"',e);clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",e,t),this.writeBuffer=[],this.prevBufferLen=0}},ki.prototype.filterUpgrades=function(e){for(var t=[],r=0,n=e.length;r<n;r++)~vi(this.transports,e[r])&&t.push(e[r]);return t},vn.exports=_i,vn.exports.parser=Sn;var Si={exports:{}},Ei={exports:{}};!function(e){function t(e){if(e)return function(e){for(var r in t.prototype)e[r]=t.prototype[r];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),r=this._callbacks["$"+e];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(Ei);var Ai=function(e,t){for(var r=[],n=(t=t||0)||0;n<e.length;n++)r[n-t]=e[n];return r};var Ti=function(e,t,r){return e.on(t,r),{destroy:function(){e.removeListener(t,r)}}};var xi=[].slice,Ii=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var r=xi.call(arguments,2);return function(){return t.apply(e,r.concat(xi.call(arguments)))}};!function(e,t){var r=Kr,n=Ei.exports,o=Ai,i=Ti,s=Ii,a=jr.exports("socket.io-client:socket"),c=so,l=Rn;e.exports=f;var u={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},h=n.prototype.emit;function f(e,t,r){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},r&&r.query&&(this.query=r.query),this.io.autoConnect&&this.open()}n(f.prototype),f.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[i(e,"open",s(this,"onopen")),i(e,"packet",s(this,"onpacket")),i(e,"close",s(this,"onclose"))]}},f.prototype.open=f.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},f.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},f.prototype.emit=function(e){if(u.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),n={type:(void 0!==this.flags.binary?this.flags.binary:l(t))?r.BINARY_EVENT:r.EVENT,data:t,options:{}};return n.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=t.pop(),n.id=this.ids++),this.connected?this.packet(n):this.sendBuffer.push(n),this.flags={},this},f.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},f.prototype.onopen=function(){if(a("transport is open - connecting"),"/"!==this.nsp)if(this.query){var e="object"==typeof this.query?c.encode(this.query):this.query;a("sending connect packet with query %s",e),this.packet({type:r.CONNECT,query:e})}else this.packet({type:r.CONNECT})},f.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},f.prototype.onpacket=function(e){var t=e.nsp===this.nsp,n=e.type===r.ERROR&&"/"===e.nsp;if(t||n)switch(e.type){case r.CONNECT:this.onconnect();break;case r.EVENT:case r.BINARY_EVENT:this.onevent(e);break;case r.ACK:case r.BINARY_ACK:this.onack(e);break;case r.DISCONNECT:this.ondisconnect();break;case r.ERROR:this.emit("error",e.data)}},f.prototype.onevent=function(e){var t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?h.apply(this,t):this.receiveBuffer.push(t)},f.prototype.ack=function(e){var t=this,n=!1;return function(){if(!n){n=!0;var i=o(arguments);a("sending ack %j",i),t.packet({type:l(i)?r.BINARY_ACK:r.ACK,id:e,data:i})}}},f.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)},f.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},f.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)h.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},f.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},f.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},f.prototype.close=f.prototype.disconnect=function(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:r.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},f.prototype.compress=function(e){return this.flags.compress=e,this},f.prototype.binary=function(e){return this.flags.binary=e,this}}(Si);var Oi=Ri;function Ri(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ri.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},Ri.prototype.reset=function(){this.attempts=0},Ri.prototype.setMin=function(e){this.ms=e},Ri.prototype.setMax=function(e){this.max=e},Ri.prototype.setJitter=function(e){this.jitter=e};var Pi=vn.exports,Bi=Si.exports,Ni=Ei.exports,ji=Kr,Fi=Ti,Mi=Ii,Ui=jr.exports("socket.io-client:manager"),Li=pi,Di=Oi,qi=Object.prototype.hasOwnProperty,zi=$i;function $i(e,t){if(!(this instanceof $i))return new $i(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new Di({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var r=t.parser||ji;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}$i.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)qi.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},$i.prototype.updateSocketIds=function(){for(var e in this.nsps)qi.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},$i.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Ni($i.prototype),$i.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},$i.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},$i.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},$i.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},$i.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},$i.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},$i.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},$i.prototype.open=$i.prototype.connect=function(e,t){if(Ui("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Ui("opening %s",this.uri),this.engine=Pi(this.uri,this.opts);var r=this.engine,n=this;this.readyState="opening",this.skipReconnect=!1;var o=Fi(r,"open",(function(){n.onopen(),e&&e()})),i=Fi(r,"error",(function(t){if(Ui("connect_error"),n.cleanup(),n.readyState="closed",n.emitAll("connect_error",t),e){var r=new Error("Connection error");r.data=t,e(r)}else n.maybeReconnectOnOpen()}));if(!1!==this._timeout){var s=this._timeout;Ui("connect attempt will timeout after %d",s);var a=setTimeout((function(){Ui("connect attempt timed out after %d",s),o.destroy(),r.close(),r.emit("error","timeout"),n.emitAll("connect_timeout",s)}),s);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(o),this.subs.push(i),this},$i.prototype.onopen=function(){Ui("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(Fi(e,"data",Mi(this,"ondata"))),this.subs.push(Fi(e,"ping",Mi(this,"onping"))),this.subs.push(Fi(e,"pong",Mi(this,"onpong"))),this.subs.push(Fi(e,"error",Mi(this,"onerror"))),this.subs.push(Fi(e,"close",Mi(this,"onclose"))),this.subs.push(Fi(this.decoder,"decoded",Mi(this,"ondecoded")))},$i.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},$i.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},$i.prototype.ondata=function(e){this.decoder.add(e)},$i.prototype.ondecoded=function(e){this.emit("packet",e)},$i.prototype.onerror=function(e){Ui("error",e),this.emitAll("error",e)},$i.prototype.socket=function(e,t){var r=this.nsps[e];if(!r){r=new Bi(this,e,t),this.nsps[e]=r;var n=this;r.on("connecting",o),r.on("connect",(function(){r.id=n.generateId(e)})),this.autoConnect&&o()}function o(){~Li(n.connecting,r)||n.connecting.push(r)}return r},$i.prototype.destroy=function(e){var t=Li(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},$i.prototype.packet=function(e){Ui("writing packet %j",e);var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,(function(r){for(var n=0;n<r.length;n++)t.engine.write(r[n],e.options);t.encoding=!1,t.processPacketQueue()})))},$i.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},$i.prototype.cleanup=function(){Ui("cleanup");for(var e=this.subs.length,t=0;t<e;t++){this.subs.shift().destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},$i.prototype.close=$i.prototype.disconnect=function(){Ui("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},$i.prototype.onclose=function(e){Ui("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},$i.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Ui("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Ui("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var r=setTimeout((function(){e.skipReconnect||(Ui("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Ui("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Ui("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(r)}})}},$i.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)},function(e,t){var r=Wr,n=Kr,o=zi,i=jr.exports("socket.io-client");e.exports=t=a;var s=t.managers={};function a(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var n,a=r(e),c=a.source,l=a.id,u=a.path,h=s[l]&&u in s[l].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),n=o(c,t)):(s[l]||(i("new io instance for %s",c),s[l]=o(c,t)),n=s[l]),a.query&&!t.query&&(t.query=a.query),n.socket(a.path,t)}t.protocol=n.protocol,t.connect=a,t.Manager=zi,t.Socket=Si.exports}(Rr,Rr.exports);var Hi=Rr.exports;var Vi={exports:{}};Vi.exports=function(){function e(t,r,n){function o(s,a){if(!r[s]){if(!t[s]){if(!a&&Ce)return Ce(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};t[s][0].call(l.exports,(function(e){return o(t[s][1][e]||e)}),l,l.exports,e,t,r,n)}return r[s].exports}for(var i=Ce,s=0;s<n.length;s++)o(n[s]);return o}return e}()({1:[function(e,t,r){(function(r,n){(function(){const o=e("events").EventEmitter,i=e("./store"),s=e("./topic-alias-recv"),a=e("./topic-alias-send"),c=e("mqtt-packet"),l=e("./default-message-id-provider"),u=e("readable-stream").Writable,h=e("inherits"),f=e("reinterval"),d=e("rfdc/default"),p=e("./validations"),m=e("xtend"),g=e("debug")("mqttjs:client"),y=r?r.nextTick:function(e){setTimeout(e,0)},v=n.setImmediate||function(e){y(e)},b={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},w=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],C={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function _(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function k(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let r;t.properties&&(r=t.properties.topicAlias);const n=t.topic.toString();if(e.topicAliasSend)if(r){if(0!==n.length&&(g("applyTopicAlias :: register topic: %s - alias: %d",n,r),!e.topicAliasSend.put(n,r)))return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),new Error("Sending Topic Alias out of range")}else 0!==n.length&&(e.options.autoAssignTopicAlias?(r=e.topicAliasSend.getAliasByTopic(n),r?(t.topic="",t.properties={...t.properties,topicAlias:r},g("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",n,r)):(r=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(n,r),t.properties={...t.properties,topicAlias:r},g("applyTopicAlias :: auto assign topic: %s - alias: %d",n,r))):e.options.autoUseTopicAlias&&(r=e.topicAliasSend.getAliasByTopic(n),r&&(t.topic="",t.properties={...t.properties,topicAlias:r},g("applyTopicAlias :: auto use topic: %s - alias: %d",n,r))));else if(r)return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",n,r),new Error("Sending Topic Alias out of range")}}function S(e,t){let r;t.properties&&(r=t.properties.topicAlias);let n=t.topic.toString();if(0===n.length){if(void 0===r)return new Error("Unregistered Topic Alias");if(n=e.topicAliasSend.getTopicByAlias(r),void 0===n)return new Error("Unregistered Topic Alias");t.topic=n}r&&delete t.properties.topicAlias}function E(e,t,r){g("sendPacket :: packet: %O",t),g("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),g("sendPacket :: writing to stream");const n=c.writeToStream(t,e.stream,e.options);g("sendPacket :: writeToStream result %s",n),!n&&r&&r!==I?(g("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(g("sendPacket :: invoking cb"),r())}function A(e){e&&(g("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function T(e){e&&(g("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function x(e,t,r,n){g("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let o,i=t;if("publish"===i.cmd&&(i=d(t),o=S(e,i),o))return r&&r(o);e.outgoingStore.put(i,(function(o){if(o)return r&&r(o);n(),E(e,t,r)}))}function I(e){g("nop ::",e)}function O(e,t){let r;const n=this;if(!(this instanceof O))return new O(e,t);for(r in this.options=t||{},b)void 0===this.options[r]?this.options[r]=b[r]:this.options[r]=t[r];g("MqttClient :: options.protocol",t.protocol),g("MqttClient :: options.protocolVersion",t.protocolVersion),g("MqttClient :: options.username",t.username),g("MqttClient :: options.keepalive",t.keepalive),g("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),g("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),g("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:_(),g("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new l:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new i,this.incomingStore=t.incomingStore||new i,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?g("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;function t(){const r=e.shift();g("deliver :: entry %o",r);let o=null;if(!r)return void n._resubscribe();o=r.packet,g("deliver :: call _sendPacket for %o",o);let i=!0;o.messageId&&0!==o.messageId&&(n.messageIdProvider.register(o.messageId)||(i=!1)),i?n._sendPacket(o,(function(e){r.cb&&r.cb(e),t()})):(g("messageId: %d has already used. The message is skipped and removed.",o.messageId),t())}g("connect :: sending queued packets"),t()})),this.on("close",(function(){g("close :: connected set to `false`"),this.connected=!1,g("close :: clearing connackTimer"),clearTimeout(this.connackTimer),g("close :: clearing ping timer"),null!==n.pingTimer&&(n.pingTimer.clear(),n.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),g("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),g("MqttClient :: setting up stream"),this._setupStream()}h(O,o),O.prototype._setupStream=function(){const e=this,t=new u,r=c.parser(this.options);let n=null;const o=[];function i(){if(o.length)y(s);else{const e=n;n=null,e()}}function s(){g("work :: getting next packet in queue");const t=o.shift();if(t)g("work :: packet pulled from queue"),e._handlePacket(t,i);else{g("work :: no packets in queue");const e=n;n=null,g("work :: done flag is %s",!!e),e&&e()}}function a(t){g("streamErrorHandler :: error",t.message),w.includes(t.code)?(g("streamErrorHandler :: emitting error"),e.emit("error",t)):I(t)}g("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),g("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){g("parser :: on packet push to packets array."),o.push(e)})),t._write=function(e,t,o){n=o,g("writable stream :: parsing buffer"),r.parse(e),s()},g("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",a),this.stream.on("close",(function(){g("(%s)stream :: on close",e.options.clientId),T(e.outgoing),g("stream: emit close to MqttClient"),e.emit("close")})),g("_setupStream: sending packet `connect`");const l=Object.create(this.options);if(l.cmd="connect",this.topicAliasRecv&&(l.properties||(l.properties={}),this.topicAliasRecv&&(l.properties.topicAliasMaximum=this.topicAliasRecv.max)),E(this,l),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&E(this,m({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){g("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)}),this.options.connectTimeout)},O.prototype._handlePacket=function(e,t){const r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(g("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},O.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==I?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},O.prototype.publish=function(e,t,r,n){g("publish :: message `%s` to topic `%s`",t,e);const o=this.options;if("function"==typeof r&&(n=r,r=null),r=m({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(n))return this;const i=this,s=function(){let s=0;if((1===r.qos||2===r.qos)&&(s=i._nextId(),null===s))return g("No messageId left"),!1;const a={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:s,dup:r.dup};switch(5===o.protocolVersion&&(a.properties=r.properties),g("publish :: qos",r.qos),r.qos){case 1:case 2:i.outgoing[a.messageId]={volatile:!1,cb:n||I},g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,void 0,r.cbStorePut);break;default:g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,n,r.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:r.cbStorePut,callback:n}),this},O.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const r=[];let n=t.shift();const o=n.resubscribe;let i=t.pop()||I,s=t.pop();const a=this.options.protocolVersion;delete n.resubscribe,"string"==typeof n&&(n=[n]),"function"!=typeof i&&(s=i,i=I);const c=p.validateTopics(n);if(null!==c)return v(i,new Error("Invalid topic "+c)),this;if(this._checkDisconnecting(i))return g("subscribe: discconecting true"),this;const l={qos:0};if(5===a&&(l.nl=!1,l.rap=!1,l.rh=0),s=m(l,s),Array.isArray(n)?n.forEach((function(t){if(g("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||o){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),g("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),r.push(e)}})):Object.keys(n).forEach((function(t){if(g("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<n[t].qos||o){const e={topic:t,qos:n[t].qos};5===a&&(e.nl=n[t].nl,e.rap=n[t].rap,e.rh=n[t].rh,e.properties=s.properties),g("subscribe: pushing `%s` to subs list",e),r.push(e)}})),!r.length)return i(null,[]),this;const u=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const n={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(n.properties=s.properties),e.options.resubscribe){g("subscribe :: resubscribe true");const t=[];r.forEach((function(r){if(e.options.reconnectPeriod>0){const n={qos:r.qos};5===a&&(n.nl=r.nl||!1,n.rap=r.rap||!1,n.rh=r.rh||0,n.properties=r.properties),e._resubscribeTopics[r.topic]=n,t.push(r.topic)}})),e.messageIdToTopic[n.messageId]=t}return e.outgoing[n.messageId]={volatile:!0,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)r[t].qos=e[t]}i(e,r)}},g("subscribe :: call _sendPacket"),e._sendPacket(n),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!u())&&this._storeProcessingQueue.push({invoke:u,callback:i}),this},O.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let r=t.shift(),n=t.pop()||I,o=t.pop();"string"==typeof r&&(r=[r]),"function"!=typeof n&&(o=n,n=I);const i=p.validateTopics(r);if(null!==i)return v(n,new Error("Invalid topic "+i)),this;if(e._checkDisconnecting(n))return this;const s=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const i={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof r?i.unsubscriptions=[r]:Array.isArray(r)&&(i.unsubscriptions=r),e.options.resubscribe&&i.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t]})),"object"==typeof o&&o.properties&&(i.properties=o.properties),e.outgoing[i.messageId]={volatile:!0,cb:n},g("unsubscribe: call _sendPacket"),e._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:n}),this},O.prototype.end=function(e,t,r){const n=this;function o(){g("end :: closeStores: closing incoming and outgoing stores"),n.disconnected=!0,n.incomingStore.close((function(e){n.outgoingStore.close((function(t){if(g("end :: closeStores: emitting end"),n.emit("end"),r){const n=e||t;g("end :: closeStores: invoking callback with args"),r(n)}}))})),n._deferredReconnect&&n._deferredReconnect()}function i(){g("end :: (%s) :: finish :: calling _cleanUp with force %s",n.options.clientId,e),n._cleanUp(e,(()=>{g("end :: finish :: calling process.nextTick on closeStores"),y(o.bind(n))}),t)}return g("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(r=t||I,t=e,e=!1,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=I))),"object"!=typeof t&&(r=t,t=null),g("end :: cb? %s",!!r),r=r||I,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(g("end :: (%s) :: calling finish in 10ms once outgoing is empty",n.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(g("end :: (%s) :: immediately calling finish",n.options.clientId),i()),this)},O.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},O.prototype.reconnect=function(e){g("client reconnect");const t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new i,t.outgoingStore=t.options.outgoingStore||new i,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},O.prototype._reconnect=function(){g("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),g("client already connected. disconnecting first.")):(g("_reconnect: calling _setupStream"),this._setupStream())},O.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(g("_setupReconnect :: emit `offline` state"),this.emit("offline"),g("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),g("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){g("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):g("_setupReconnect :: doing nothing...")},O.prototype._clearReconnect=function(){g("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},O.prototype._cleanUp=function(e,t){const r=arguments[2];if(t&&(g("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),g("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&A(this.outgoing),g("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=m({cmd:"disconnect"},r);g("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,v.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(g("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(g("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(g("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},O.prototype._sendPacket=function(e,t,r){g("_sendPacket :: (%s) :: start",this.options.clientId),r=r||I,t=t||I;const n=k(this,e);if(n)t(n);else{if(!this.connected)return"auth"===e.cmd?(this._shiftPingInterval(),void E(this,e,t)):(g("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r));switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void x(this,e,t,r);default:return void E(this,e,t)}switch(e.qos){case 2:case 1:x(this,e,t,r);break;default:E(this,e,t)}g("_sendPacket :: (%s) :: end",this.options.clientId)}},O.prototype._storePacket=function(e,t,r){g("_storePacket :: packet: %o",e),g("_storePacket :: cb? %s",!!t),r=r||I;let n=e;if("publish"===n.cmd){n=d(e);const r=S(this,n);if(r)return t&&t(r)}0===(n.qos||0)&&this.queueQoSZero||"publish"!==n.cmd?this.queue.push({packet:n,cb:t}):n.qos>0?(t=this.outgoing[n.messageId]?this.outgoing[n.messageId].cb:null,this.outgoingStore.put(n,(function(e){if(e)return t&&t(e);r()}))):t&&t(new Error("No connection to broker"))},O.prototype._setupPingTimer=function(){g("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=f((function(){e._checkPing()}),1e3*this.options.keepalive))},O.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},O.prototype._checkPing=function(){g("_checkPing :: checking ping..."),this.pingResp?(g("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(g("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},O.prototype._handlePingresp=function(){this.pingResp=!0},O.prototype._handleConnack=function(e){g("_handleConnack");const t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){const e=new Error("Connection refused: "+C[r]);e.code=r,this.emit("error",e)}},O.prototype._handleAuth=function(e){const t=this.options.protocolVersion,r=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=r,void this.emit("error",e)}const n=this;this.handleAuth(e,(function(e,t){if(e)n.emit("error",e);else if(24===r)n.reconnecting=!1,n._sendPacket(t);else{const t=new Error("Connection refused: "+C[r]);e.code=r,n.emit("error",t)}}))},O.prototype.handleAuth=function(e,t){t()},O.prototype._handlePublish=function(e,t){g("_handlePublish: packet %o",e),t=void 0!==t?t:I;let r=e.topic.toString();const n=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===r.length){if(!(t>0&&t<=65535))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return g("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));r=e,g("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,t)}}else{if(!this.topicAliasRecv.put(r,t))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));g("_handlePublish :: registered topic: %s - alias: %d",r,t)}}switch(g("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(r,n,e,(function(r,n){return r instanceof Error||(n=r,r=null),r?s.emit("error",r):-1===c.indexOf(n)?s.emit("error",new Error("Wrong reason code for pubrec")):void(n?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:n},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(r,n,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,n,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},t)})))}));break;case 0:this.emit("message",r,n,e),this.handleMessage(e,t);break;default:g("_handlePublish: unknown QoS. Doing nothing.")}},O.prototype.handleMessage=function(e,t){t()},O.prototype._handleAck=function(e){const t=e.messageId,r=e.cmd;let n=null;const o=this.outgoing[t]?this.outgoing[t].cb:null,i=this;let s;if(o){switch(g("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{const r=e.reasonCode;r&&r>0&&16!==r&&(s=new Error("Publish error: "+C[r]),s.code=r,o(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,o),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case"pubrec":{n={cmd:"pubrel",qos:2,messageId:t};const r=e.reasonCode;r&&r>0&&16!==r?(s=new Error("Publish error: "+C[r]),s.code=r,o(s,e)):this._sendPacket(n);break}case"suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let r=0;r<e.granted.length;r++)if(0!=(128&e.granted[r])){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete i._resubscribeTopics[e]}))}this._invokeStoreProcessingQueue(),o(null,e);break;case"unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),o(null);break;default:i.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else g("_handleAck :: Server sent an ack in error. Ignoring.")},O.prototype._handlePubrel=function(e,t){g("handling pubrel packet"),t=void 0!==t?t:I;const r=e.messageId,n=this,o={cmd:"pubcomp",messageId:r};n.incomingStore.get(e,(function(e,r){e?n._sendPacket(o,t):(n.emit("message",r.topic,r.payload,r),n.handleMessage(r,(function(e){if(e)return t(e);n.incomingStore.del(r,I),n._sendPacket(o,t)})))}))},O.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},O.prototype._nextId=function(){return this.messageIdProvider.allocate()},O.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},O.prototype._resubscribe=function(){g("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){g("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const r={};r[e[t]]=this._resubscribeTopics[e[t]],r.resubscribe=!0,this.subscribe(r,{properties:r[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},O.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;function r(){let n=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){n.destroy(),n=null,t._flushStoreProcessingQueue(),o()}function s(){if(!n)return;t._storeProcessing=!0;const e=n.read(1);let r;e?t._packetIdsDuringStoreProcessing[e.messageId]?s():t.disconnecting||t.reconnectTimer?n.destroy&&n.destroy():(r=t.outgoing[e.messageId]?t.outgoing[e.messageId].cb:null,t.outgoing[e.messageId]={volatile:!1,cb:function(e,t){r&&r(e,t),s()}},t._packetIdsDuringStoreProcessing[e.messageId]=!0,t.messageIdProvider.register(e.messageId)?t._sendPacket(e):g("messageId: %d has already used.",e.messageId)):n.once("readable",s)}t.once("close",i),n.on("error",(function(e){o(),t._flushStoreProcessingQueue(),t.removeListener("close",i),t.emit("error",e)})),n.on("end",(function(){let n=!0;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){n=!1;break}n?(o(),t.removeListener("close",i),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):r()})),s()}this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,r()},O.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},O.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},O.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},t.exports=O}).call(this)}).call(this,e("_process"),void 0!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(e,t,r){const{Buffer:n}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c,l=!1;function u(){const e=new o;return e._write=function(e,t,r){s.sendSocketMessage({data:e.buffer,success:function(){r()},fail:function(){r(new Error)}})},e._flush=function(e){s.closeSocket({success:function(){e()}})},e}function h(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function f(e,t){const r="alis"===e.protocol?"wss":"ws";let n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function d(){l||(l=!0,s.onSocketOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=n.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((function(){c.end(),c.destroy()})),s.onSocketError((function(e){c.destroy(e)})))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";h(t);const n=f(t,e);return s=t.my,s.connectSocket({url:n,protocols:r}),a=u(),c=i.obj(),d(),c}t.exports=p},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(e,t,r){const n=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const r=t.port,i=t.hostname;return o("port %d and host %s",r,i),n.createConnection(r,i)}t.exports=i},{debug:18,net:16}],4:[function(e,t,r){const n=e("tls"),o=e("net"),i=e("debug")("mqttjs:tls");function s(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===o.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,i("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const r=n.connect(t);function s(n){t.rejectUnauthorized&&e.emit("error",n),r.end()}return r.on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",s)})),r.on("error",s),r}t.exports=s},{debug:18,net:16,tls:16}],5:[function(e,t,r){(function(r){(function(){const{Buffer:n}=e("buffer"),o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform,c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],l=void 0!==r&&"browser"===r.title||"function"==typeof __webpack_require__;function u(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function h(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),l||"wss"!==e.protocol||c.forEach((function(r){Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,r)&&(t.wsOptions[r]=e[r])})),t}function f(e){const t=h(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}function d(e,t,r){i("createWebSocket"),i("protocol: "+r.protocolId+" "+r.protocolVersion);const n="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+t+" and protocol: "+n),new o(t,[n],r.wsOptions)}function p(e,t){const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",n=u(t,e),o=new WebSocket(n,[r]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");const r=h(t),n=u(r,e),s=d(e,n,r),a=o.createWebSocketStream(s,r.wsOptions);return a.url=n,s.on("close",(()=>{a.destroy()})),a}function g(e,t){let r;i("browserStreamBuilder");const o=f(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,l=!t.objectMode,u=p(e,t),h=m(t,C,_);t.objectMode||(h._writev=w),h.on("close",(()=>{u.close()}));const d=void 0!==u.addEventListener;function m(e,t,r){const n=new a({objectModeMode:e.objectMode});return n._write=t,n._flush=r,n}function g(){r.setReadable(h),r.setWritable(h),r.emit("connect")}function y(){r.end(),r.destroy()}function v(e){r.destroy(e)}function b(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),h.push(t)}function w(e,t){const r=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=n.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(n.concat(r),"binary",t)}function C(e,t,r){u.bufferedAmount>o&&setTimeout(C,c,e,t,r),l&&"string"==typeof e&&(e=n.from(e,"utf8"));try{u.send(e)}catch(e){return r(e)}r()}function _(e){u.close(),e()}return u.readyState===u.OPEN?r=h:(r=r=s(void 0,void 0,t),t.objectMode||(r._writev=w),d?u.addEventListener("open",g):u.onopen=g),r.socket=u,d?(u.addEventListener("close",y),u.addEventListener("error",v),u.addEventListener("message",b)):(u.onclose=y,u.onerror=v,u.onmessage=b),r}t.exports=l?g:m}).call(this)}).call(this,e("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(e,t,r){const{Buffer:n}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c;function l(){const e=new o;return e._write=function(e,t,r){s.send({data:e.buffer,success:function(){r()},fail:function(e){r(new Error(e))}})},e._flush=function(e){s.close({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){const r="wxs"===e.protocol?"wss":"ws";let n=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(n=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function f(){s.onOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),a.push(t)})),s.onClose((function(){c.end(),c.destroy()})),s.onError((function(e){c.destroy(new Error(e.errMsg))}))}function d(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);const n=h(t,e);s=wx.connectSocket({url:n,protocols:[r]}),a=l(),c=i.obj(),c._destroy=function(e,t){s.close({success:function(){t&&t(e)}})};const o=c.destroy;return c.destroy=function(){c.destroy=o;const e=this;setTimeout((function(){s.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(c),f(),c}t.exports=d},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(e,t,r){function n(){if(!(this instanceof n))return new n;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}n.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},n.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},n.prototype.register=function(e){return!0},n.prototype.deallocate=function(e){},n.prototype.clear=function(){},t.exports=n},{}],8:[function(e,t,r){const n=e("xtend"),o=e("readable-stream").Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=n(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new o(i),t=[];let r=!1,n=0;return this._inflights.forEach((function(e,r){t.push(e)})),e._read=function(){!r&&n<t.length?this.push(t[n++]):this.push(null)},e.destroy=function(){if(r)return;const e=this;r=!0,setTimeout((function(){e.emit("close")}),0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=a},{"readable-stream":69,xtend:81}],9:[function(e,t,r){function n(e){if(!(this instanceof n))return new n(e);this.aliasToTopic={},this.max=e}n.prototype.put=function(e,t){return!(0===t||t>this.max||(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,0))},n.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},n.prototype.clear=function(){this.aliasToTopic={}},t.exports=n},{}],10:[function(e,t,r){const n=e("lru-cache"),o=e("number-allocator").NumberAllocator;function i(e){if(!(this instanceof i))return new i(e);e>0&&(this.aliasToTopic=new n({max:e}),this.topicToAlias={},this.numberAllocator=new o(1,e),this.max=e,this.length=0)}i.prototype.put=function(e,t){if(0===t||t>this.max)return!1;const r=this.aliasToTopic.get(t);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},i.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},i.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},i.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},i.prototype.getLruAlias=function(){const e=this.numberAllocator.firstVacant();return e||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},t.exports=i},{"lru-cache":37,"number-allocator":46}],11:[function(e,t,r){function n(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(let t=0;t<e.length;t++)if(!n(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],12:[function(e,t,r){(function(r){(function(){const n=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function l(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function u(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const r=i.parse(e,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(t=s(r,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(l(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!c[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,r){return(!e||r%2!=0)&&"function"==typeof c[t]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function r(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a("calling streambuilder for",t.protocol),c[t.protocol](e,t)}t.protocol&&(t.defaultProtocol=t.protocol);const o=new n(r,t);return o.on("error",(function(){})),o}void 0!==r&&"browser"!==r.title||"function"!=typeof __webpack_require__?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=u,t.exports.connect=u,t.exports.MqttClient=n,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":8,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:50,debug:18,url:76,xtend:81}],13:[function(e,t,r){r.byteLength=u,r.toByteArray=f,r.fromByteArray=m;for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e){var t=l(e),r=t[0],n=t[1];return 3*(r+n)/4-n}function h(e,t,r){return 3*(t+r)/4-r}function f(e){var t,r,n=l(e),s=n[0],a=n[1],c=new i(h(e,s,a)),u=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)t=o[e.charCodeAt(r)]<<18|o[e.charCodeAt(r+1)]<<12|o[e.charCodeAt(r+2)]<<6|o[e.charCodeAt(r+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===a&&(t=o[e.charCodeAt(r)]<<2|o[e.charCodeAt(r+1)]>>4,c[u++]=255&t),1===a&&(t=o[e.charCodeAt(r)]<<10|o[e.charCodeAt(r+1)]<<4|o[e.charCodeAt(r+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c}function d(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function p(e,t,r){for(var n,o=[],i=t;i<r;i+=3)n=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(d(n));return o.join("")}function m(e){for(var t,r=e.length,o=r%3,i=[],s=16383,a=0,c=r-o;a<c;a+=s)i.push(p(e,a,a+s>c?c:a+s));return 1===o?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],14:[function(e,t,r){const{Buffer:n}=e("buffer"),o=Symbol.for("BufferList");function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let r=0;r<this._bufs.length;r++){const n=t+this._bufs[r].length;if(e<n||r===this._bufs.length-1)return[r,e-t];t=n}},i.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},i.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,r,o){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof o||o>this.length)&&(o=this.length),r>=this.length)return e||n.alloc(0);if(o<=0)return e||n.alloc(0);const i=!!e,s=this._offset(r),a=o-r;let c=a,l=i&&t||0,u=s[1];if(0===r&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-u)return i?this._bufs[s[0]].copy(e,t,u,u+c):this._bufs[s[0]].slice(u,u+c);i||(e=n.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-u;if(!(c>r)){this._bufs[t].copy(e,l,u,u+c),l+=r;break}this._bufs[t].copy(e,l,u),l+=r,c-=r,u&&(u=0)}return e.length>l?e.slice(0,l):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),n=this._offset(t),o=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,n[1]),0!==r[1]&&(o[0]=o[0].slice(r[1])),this._new(o)},i.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(n.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(n.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=n.from([e]):"string"==typeof e?e=n.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=n.from(e.buffer,e.byteOffset,e.byteLength):n.isBuffer(e)||(e=n.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const t=this._bufs[i];for(;s<t.length;)if(t.length-s>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([i,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([i,s]);if(this._match(t,e))return t;s++}s=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){null===e[t]?i.prototype[t]=function(e,r){return this.slice(e,e+r)[t](0,r)}:i.prototype[t]=function(r=0){return this.slice(r,r+e[t])[t](0)}}(t)}(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return null!=e&&e[o]},t.exports=i},{buffer:17}],15:[function(e,t,r){const n=e("readable-stream").Duplex,o=e("inherits"),i=e("./BufferList");function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}i._init.call(this,e),n.call(this)}o(s,n),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){n.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof i||s.isBufferList(e)},s.isBufferList=i.isBufferList,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(e,t,r){},{}],17:[function(e,t,r){(function(t){(function(){var t=e("base64-js"),n=e("ieee754");r.Buffer=a,r.SlowBuffer=y,r.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,r)}function c(e,t,r){if("string"==typeof e)return f(e,t);if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return p(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return a.from(n,t,r);var o=m(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e,t,r){return l(e),e<=0?s(e):void 0!==t?"string"==typeof r?s(e).fill(t,r):s(e).fill(t):s(e)}function h(e){return l(e),s(e<0?0:0|g(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|v(e,t),n=s(r),o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}function d(e){for(var t=e.length<0?0:0|g(e.length),r=s(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function p(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r)).__proto__=a.prototype,n}function m(e){if(a.isBuffer(e)){var t=0|g(e.length),r=s(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||Y(e.length)?s(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Q(e).length;default:if(o)return n?-1:V(e).length;t=(""+t).toLowerCase(),o=!0}}function b(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,r);case"utf8":case"utf-8":return O(this,t,r);case"ascii":return B(this,t,r);case"latin1":case"binary":return N(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function w(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function C(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:_(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,n,o){var i,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(i=r;i<a;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(r+c>a&&(r=a-c),i=r;i>=0;i--){for(var h=!0,f=0;f<c;f++)if(l(e,i+f)!==l(t,f)){h=!1;break}if(h)return i}return-1}function k(e,t,r,n){r=Number(r)||0;var o=e.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=t.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(Y(a))return s;e[r+s]=a}return s}function S(e,t,r,n){return J(V(t,e.length-r),e,r,n)}function E(e,t,r,n){return J(W(t),e,r,n)}function A(e,t,r,n){return E(e,t,r,n)}function T(e,t,r,n){return J(Q(t),e,r,n)}function x(e,t,r,n){return J(K(t,e.length-r),e,r,n)}function I(e,r,n){return 0===r&&n===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,n))}function O(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o<r;){var i,s,a,c,l=e[o],u=null,h=l>239?4:l>223?3:l>191?2:1;if(o+h<=r)switch(h){case 1:l<128&&(u=l);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&l)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),o+=h}return P(n)}r.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,r){return c(e,t,r)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,r){return u(e,t,r)},a.allocUnsafe=function(e){return h(e)},a.allocUnsafeSlow=function(e){return h(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o<i;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=a.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var i=e[r];if(X(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},a.byteLength=v,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?O(this,0,e):b.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,r,n,o){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),c=Math.min(i,s),l=this.slice(n,o),u=e.slice(t,r),h=0;h<c;++h)if(l[h]!==u[h]){i=l[h],s=u[h];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},a.prototype.indexOf=function(e,t,r){return C(this,e,t,r,!0)},a.prototype.lastIndexOf=function(e,t,r){return C(this,e,t,r,!1)},a.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return k(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":return E(this,e,t,r);case"latin1":case"binary":return A(this,e,t,r);case"base64":return T(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function P(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=R));return r}function B(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(127&e[o]);return n}function N(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;o<r;++o)n+=String.fromCharCode(e[o]);return n}function j(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=t;i<r;++i)o+=H(e[i]);return o}function F(e,t,r){for(var n=e.slice(t,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,r,n,o,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function L(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(e,t,r,o,i){return t=+t,r>>>=0,i||L(e,t,r,4),n.write(e,t,r,o,23,4),r+4}function q(e,t,r,o,i){return t=+t,r>>>=0,i||L(e,t,r,8),n.write(e,t,r,o,52,8),r+8}a.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return n.__proto__=a.prototype,n},a.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n},a.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},a.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i<t&&(o*=256);)n+=this[e+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),n.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),n.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),n.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i<r&&(o*=256);)this[t+i]=e/o&255;return t+r},a.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<r&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);U(this,e,t,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,r){return D(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return D(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return q(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return q(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var i=o-1;i>=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return o},a.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var i;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,n),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=s[i%c]}return this};var z=/[^+/0-9A-Za-z-_]/g;function $(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function V(e,t){var r;t=t||1/0;for(var n=e.length,o=null,i=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function W(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function K(e,t){for(var r,n,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}function Q(e){return t.toByteArray($(e))}function J(e,t,r,n){for(var o=0;o<n&&!(o+r>=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(e,t,r){(function(n){(function(){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let n=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(o=n))})),e.splice(o,0,r)}function s(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=r.storage.getItem("debug")}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}r.formatArgs=i,r.save=s,r.load=a,r.useColors=o,r.storage=c(),r.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(r);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":19,_process:50}],19:[function(e,t,r){function n(t){function r(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return n.colors[Math.abs(t)%n.colors.length]}function n(e){let t,r,i,s=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),i=o-(t||o);r.diff=i,r.prev=t,r.curr=o,t=o,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";s++;const i=n.formatters[o];if("function"==typeof i){const n=e[s];t=i.call(r,n),e.splice(s,1),s--}return t})),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return a.namespace=e,a.useColors=n.useColors(),a.color=n.selectColor(e),a.extend=o,a.destroy=n.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(r!==n.namespaces&&(r=n.namespaces,i=n.enabled(e)),i),set:e=>{s=e}}),"function"==typeof n.init&&n.init(a),a}function o(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function i(e){let t;n.save(e),n.namespaces=e,n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(t=0;t<o;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...n.names.map(c),...n.skips.map(c).map((e=>"-"+e))].join(",");return n.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1}function c(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.debug=n,n.default=n,n.coerce=l,n.disable=s,n.enable=i,n.enabled=a,n.humanize=e("ms"),n.destroy=u,Object.keys(t).forEach((e=>{n[e]=t[e]})),n.names=[],n.skips=[],n.formatters={},n.selectColor=r,n.enable(n.load()),n}t.exports=n},{ms:45}],20:[function(e,t,r){(function(r,n){(function(){var o=e("readable-stream"),i=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=n.from&&n.from!==Uint8Array.from?n.from([0]):new n([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},u=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(r){r?u(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},f=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},d=function(){},p=function(e){return new o.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},m=function(e,t,r){if(!(this instanceof m))return new m(e,t,r);o.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(m,o.Duplex),m.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new m(e,t,r)},m.prototype.cork=function(){1==++this._corked&&this.emit("cork")},m.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},m.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,n=i(e,{writable:!0,readable:!1},h(this,this._forwardEnd)),o=function(){var e=t._ondrain;t._ondrain=null,e&&e()},s=function(){t._writable.removeListener("drain",o),n()};this._unwrite&&r.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=s,this.uncork()}else this.end()},m.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t=this,r=i(e,{writable:!1,readable:!0},h(this)),n=function(){t._forward()},o=function(){t.push(null)},s=function(){t._readable2.removeListener("readable",n),t._readable2.removeListener("end",o),r()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:p(e),this._readable2.on("readable",n),this._readable2.on("end",o),this._unread=s,this._forward()}},m.prototype._read=function(){this._drained=!0,this._forward()},m.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},m.prototype.destroy=function(e,t){if(t||(t=d),this.destroyed)return t(null);this.destroyed=!0;var n=this;r.nextTick((function(){n._destroy(e),t(null)}))},m.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},m.prototype._write=function(e,t,r){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,r)):e===c?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()):r()},m.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){f(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)}))}))},m.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(c),o.Writable.prototype.end.call(this,r))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:50,buffer:17,"end-of-stream":21,inherits:24,"readable-stream":69,"stream-shift":74}],21:[function(e,t,r){(function(r){(function(){var n=e("once"),o=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},s=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,c){if("function"==typeof t)return a(e,null,t);t||(t={}),c=n(c||o);var l=e._writableState,u=e._readableState,h=t.readable||!1!==t.readable&&e.readable,f=t.writable||!1!==t.writable&&e.writable,d=!1,p=function(){e.writable||m()},m=function(){f=!1,h||c.call(e)},g=function(){h=!1,f||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},v=function(t){c.call(e,t)},b=function(){r.nextTick(w)},w=function(){if(!d)return(!h||u&&u.ended&&!u.destroyed)&&(!f||l&&l.ended&&!l.destroyed)?void 0:c.call(e,new Error("premature close"))},C=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",b),e.req?C():e.on("request",C)):f&&!l&&(e.on("end",p),e.on("close",p)),s(e)&&e.on("exit",y),e.on("end",g),e.on("finish",m),!1!==t.error&&e.on("error",v),e.on("close",b),function(){d=!0,e.removeListener("complete",m),e.removeListener("abort",b),e.removeListener("request",C),e.req&&e.req.removeListener("finish",m),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",m),e.removeListener("exit",y),e.removeListener("end",g),e.removeListener("error",v),e.removeListener("close",b)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:50,once:48}],22:[function(e,t,r){var n=Object.create||S,o=Object.keys||E,i=Function.prototype.bind||A;function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,r){if(t)e.call(r);else for(var n=e.length,o=_(e,n),i=0;i<n;++i)o[i].call(r)}function f(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].call(r,n)}function d(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=_(e,i),a=0;a<i;++a)s[a].call(r,n,o)}function p(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,a=_(e,s),c=0;c<s;++c)a[c].call(r,n,o,i)}function m(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].apply(r,n)}function g(e,t,r,o){var i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),a=s[t]):(s=e._events=n(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[r,a]:[a,r]:o?a.unshift(r):a.push(r),!a.warned&&(i=u(e))&&i>0&&a.length>i){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=r,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function v(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=i.call(y,n);return o.listener=r,n.wrapFn=o,o}function b(e,t,r){var n=e._events;if(!n)return[];var o=n[t];return o?"function"==typeof o?r?[o.listener||o]:[o]:r?k(o):_(o,o.length):[]}function w(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function C(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}function _(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function k(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function S(e){var t=function(){};return t.prototype=e,new t}function E(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t);return t}function A(e){var t=this;return function(){return t.apply(e,arguments)}}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,r,n,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:h(r,l,this);break;case 2:f(r,l,this,arguments[1]);break;case 3:d(r,l,this,arguments[1],arguments[2]);break;case 4:p(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];m(r,l,this,o)}return!0},s.prototype.addListener=function(e,t){return g(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return g(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,v(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,v(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(r=o[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=n(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){a=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():C(r,i),1===r.length&&(o[e]=r[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,r,i;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=n(null),this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=n(null):delete r[e]),this;if(0===arguments.length){var s,a=o(r);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=n(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return b(this,e,!0)},s.prototype.rawListeners=function(e){return b(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},s.prototype.listenerCount=w,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(e,t,r){
|
|
3
3
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
4
|
-
n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,l=c>>1,u=-7,h=n?o-1:0,f=n?-1:1,p=e[t+h];for(h+=f,i=p&(1<<-u)-1,p>>=-u,u+=a;u>0;i=256*i+e[t+h],h+=f,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+e[t+h],h+=f,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),i-=l}return(p?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,d=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[n+p]=255&a,p+=d,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;e[n+p]=255&s,p+=d,s/=256,l-=8);e[n+p-d]|=128*m}},{}],24:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],25:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){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=e,this.value=t}return e.prototype.rotateLeft=function(){var e=this.parent,t=this.brother,n=this.leftChild,r=this.rightChild;if(!r)throw new Error("unknown error");var o=r.leftChild,i=r.rightChild;return e&&(e.leftChild===this?e.leftChild=r:e.rightChild===this&&(e.rightChild=r)),r.parent=e,r.brother=t,r.leftChild=this,r.rightChild=i,t&&(t.brother=r),this.parent=r,this.brother=i,this.leftChild=n,this.rightChild=o,i&&(i.parent=r,i.brother=this),n&&(n.parent=this,n.brother=o),o&&(o.parent=this,o.brother=n),r},e.prototype.rotateRight=function(){var e=this.parent,t=this.brother,n=this.leftChild;if(!n)throw new Error("unknown error");var r=this.rightChild,o=n.leftChild,i=n.rightChild;return e&&(e.leftChild===this?e.leftChild=n:e.rightChild===this&&(e.rightChild=n)),n.parent=e,n.brother=t,n.leftChild=o,n.rightChild=this,t&&(t.brother=n),o&&(o.parent=n,o.brother=this),this.parent=n,this.brother=o,this.leftChild=i,this.rightChild=r,i&&(i.parent=this,i.brother=r),r&&(r.parent=this,r.brother=i),n},e.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},e.TreeNodeColorType={red:!0,black:!1},e}();Object.freeze(r),n.default=r},{}],26:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};function o(e){var t=this;void 0===e&&(e=[]);var n=[],i=0,s=0,a=0,c=0,l=0,u=0;this.size=function(){return u},this.empty=function(){return 0===u},this.clear=function(){i=a=s=c=l=u=0,f.call(this,o.bucketSize),u=0},this.front=function(){return n[i][s]},this.back=function(){return n[a][c]},this.forEach=function(e){if(!this.empty()){var t=0;if(i!==a){for(l=s;l<o.bucketSize;++l)e(n[i][l],t++);for(l=i+1;l<a;++l)for(var r=0;r<o.bucketSize;++r)e(n[l][r],t++);for(l=0;l<=c;++l)e(n[a][l],t++)}else for(var l=s;l<=c;++l)e(n[i][l],t++)}};var h=function(e){var t=i*o.bucketSize+s,n=t+e,r=a*o.bucketSize+c;if(n<t||n>r)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(n/o.bucketSize),curNodePointerIndex:n%o.bucketSize}};this.getElementByPos=function(e){var t=h(e),r=t.curNodeBucketIndex,o=t.curNodePointerIndex;return n[r][o]},this.eraseElementByPos=function(e){var t=this;if(e<0||e>u)throw new Error("pos should more than 0 and less than queue's size");if(0===e)this.popFront();else if(e===this.size())this.popBack();else{for(var n=[],r=e+1;r<u;++r)n.push(this.getElementByPos(r));this.cut(e),this.popBack(),n.forEach((function(e){return t.pushBack(e)}))}},this.eraseElementByValue=function(e){if(!this.empty()){var t=[];this.forEach((function(n){n!==e&&t.push(n)}));for(var n=t.length,r=0;r<n;++r)this.setElementByPos(r,t[r]);this.cut(n-1)}};var f=function(e){for(var t=[],r=e*o.sigma,h=Math.max(Math.ceil(r/o.bucketSize),2),f=0;f<h;++f)t.push(new Array(o.bucketSize));var p=Math.ceil(e/o.bucketSize),d=Math.floor(h/2)-Math.floor(p/2),m=d,g=0;if(this.size())for(f=0;f<p;++f){for(var y=0;y<o.bucketSize;++y)if(t[d+f][y]=this.front(),this.popFront(),this.empty()){m=d+f,g=y;break}if(this.empty())break}n=t,i=d,s=0,a=m,c=g,l=h,u=e};this.pushBack=function(e){this.empty()||(a===l-1&&c===o.bucketSize-1&&f.call(this,this.size()),c<o.bucketSize-1?++c:a<l-1&&(++a,c=0)),++u,n[a][c]=e},this.popBack=function(){this.empty()||(1!==this.size()&&(c>0?--c:i<a&&(--a,c=o.bucketSize-1)),u>0&&--u)},this.setElementByPos=function(e,t){var r=h(e),o=r.curNodeBucketIndex,i=r.curNodePointerIndex;n[o][i]=t},this.insert=function(e,t,n){var r=this;if(void 0===n&&(n=1),0===e)for(;n--;)this.pushFront(t);else if(e===this.size())for(;n--;)this.pushBack(t);else{for(var o=[],i=e;i<u;++i)o.push(this.getElementByPos(i));for(this.cut(e-1),i=0;i<n;++i)this.pushBack(t);o.forEach((function(e){return r.pushBack(e)}))}},this.find=function(e){if(i===a){for(var t=s;t<=c;++t)if(n[i][t]===e)return!0;return!1}for(t=s;t<o.bucketSize;++t)if(n[i][t]===e)return!0;for(t=i+1;t<a;++t)for(var r=0;r<o.bucketSize;++r)if(n[t][r]===e)return!0;for(t=0;t<=c;++t)if(n[a][t]===e)return!0;return!1},this.reverse=function(){for(var e=0,t=u-1;e<t;){var n=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,n),++e,--t}},this.unique=function(){if(!this.empty()){var e=[],t=this.front();this.forEach((function(n,r){0!==r&&n===t||(e.push(n),t=n)}));for(var n=0;n<u;++n)this.setElementByPos(n,e[n]);this.cut(e.length-1)}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);for(var n=0;n<u;++n)this.setElementByPos(n,t[n])},this.pushFront=function(e){this.empty()||(0===i&&0===s&&f.call(this,this.size()),s>0?--s:i>0&&(--i,s=o.bucketSize-1)),++u,n[i][s]=e},this.popFront=function(){this.empty()||(1!==this.size()&&(s<o.bucketSize-1?++s:i<a&&(++i,s=0)),u>0&&--u)},this.shrinkToFit=function(){var e=this,t=[];this.forEach((function(e){t.push(e)}));var r=t.length;n=[];for(var i=Math.ceil(r/o.bucketSize),s=0;s<i;++s)n.push(new Array(o.bucketSize));this.clear(),t.forEach((function(t){return e.pushBack(t)}))},this.cut=function(e){if(e<0)this.clear();else{var t=h(e),n=t.curNodeBucketIndex,r=t.curNodePointerIndex;a=n,c=r,u=e+1}},this[Symbol.iterator]=function(){return function(){var e,t;return r(this,(function(r){switch(r.label){case 0:if(0===u)return[2];if(i!==a)return[3,5];t=s,r.label=1;case 1:return t<=c?[4,n[i][t]]:[3,4];case 2:r.sent(),r.label=3;case 3:return++t,[3,1];case 4:return[2];case 5:t=s,r.label=6;case 6:return t<o.bucketSize?[4,n[i][t]]:[3,9];case 7:r.sent(),r.label=8;case 8:return++t,[3,6];case 9:t=i+1,r.label=10;case 10:if(!(t<a))return[3,15];e=0,r.label=11;case 11:return e<o.bucketSize?[4,n[t][e]]:[3,14];case 12:r.sent(),r.label=13;case 13:return++e,[3,11];case 14:return++t,[3,10];case 15:t=0,r.label=16;case 16:return t<=c?[4,n[a][t]]:[3,19];case 17:r.sent(),r.label=18;case 18:return++t,[3,16];case 19:return[2]}}))}()},function(){var r=o.bucketSize;e.size?r=e.size():e.length&&(r=e.length);var s=r*o.sigma;l=Math.ceil(s/o.bucketSize),l=Math.max(l,3);for(var c=0;c<l;++c)n.push(new Array(o.bucketSize));var u=Math.ceil(r/o.bucketSize);i=Math.floor(l/2)-Math.floor(u/2),a=i,e.forEach((function(e){return t.pushBack(e)}))}(),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),o.sigma=3,o.bucketSize=5e3,Object.freeze(o),n.default=o},{}],27:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../LinkList/LinkList"),s=e("../Map/Map");function a(e,t,n){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),n=n||function(e){var t,n,r=0,i="";if("number"==typeof e)r=((r=Math.floor(e))<<5)-r,r&=r;else{i="string"!=typeof e?JSON.stringify(e):e;try{for(var s=o(i),a=s.next();!a.done;a=s.next())r=(r<<5)-r+a.value.charCodeAt(0),r&=r}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}return r^=r>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(n){n.forEach((function(n){e(n,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(r,o){if(!r.empty()){if(r instanceof i.default&&1===r.size()){var c=r.front(),l=c.key,f=c.value;t[n(l)&h-1]=new i.default([{key:l,value:f}])}else if(r instanceof s.default){var p=new i.default,d=new i.default;r.forEach((function(t){0==(n(t.key)&e)?p.pushBack(t):d.pushBack(t)})),p.size()>a.untreeifyThreshold?t[o]=new s.default(p):p.size()&&(t[o]=p),d.size()>a.untreeifyThreshold?t[o+e]=new s.default(d):d.size()&&(t[o+e]=d)}else{var m=new i.default,g=new i.default;r.forEach((function(t){0==(n(t.key)&e)?m.pushBack(t):g.pushBack(t)})),m.size()&&(t[o]=m),g.size()&&(t[o+e]=g)}u[o].clear()}})),u=t}};this.setElement=function(e,t){var r,c;if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=t){var p=n(e)&h-1;if(u[p]){var d=u[p].size();if(u[p]instanceof i.default){try{for(var m=o(u[p]),g=m.next();!g.done;g=m.next()){var y=g.value;if(y.key===e)return void(y.value=t)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(c=m.return)&&c.call(m)}finally{if(r)throw r.error}}u[p].pushBack({key:e,value:t}),u[p].size()>=a.treeifyThreshold&&(u[p]=new s.default(u[p]))}else u[p].setElement(e,t);var v=u[p].size();l+=v-d}else++l,u[p]=new i.default([{key:e,value:t}]);l>h*a.sigma&&f.call(this,h)}else this.eraseElementByKey(e)},this.getElementByKey=function(e){var t,r,i=n(e)&h-1;if(u[i]){if(u[i]instanceof s.default)return u[i].getElementByKey(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next()){var l=c.value;if(l.key===e)return l.value}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},this.eraseElementByKey=function(e){var t,r,c=n(e)&h-1;if(u[c]){var f=u[c].size();if(u[c]instanceof s.default)u[c].eraseElementByKey(e),u[c].size()<=a.untreeifyThreshold&&(u[c]=new i.default(u[c]));else{var p=-1;try{for(var d=o(u[c]),m=d.next();!m.done;m=d.next()){var g=m.value;if(++p,g.key===e){u[c].eraseElementByPos(p);break}}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=d.return)&&r.call(d)}finally{if(t)throw t.error}}}var y=u[c].size();l+=y-f}},this.find=function(e){var t,r,i=n(e)&h-1;if(!u[i])return!1;if(u[i]instanceof s.default)return u[i].find(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next())if(c.value.key===e)return!0}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return!1},this[Symbol.iterator]=function(){return function(){var e,t,n,i,s,a;return r(this,(function(r){switch(r.label){case 0:e=0,r.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];r.label=2;case 2:r.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),n=t.next(),r.label=3;case 3:return n.done?[3,6]:[4,n.value];case 4:r.sent(),r.label=5;case 5:return n=t.next(),[3,3];case 6:return[3,9];case 7:return i=r.sent(),s={error:i},[3,9];case 8:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){var t=e.key,n=e.value;return c.setElement(t,n)})),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),n.default=a},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Set/Set"),s=e("../LinkList/LinkList");function a(e,t,n){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),n=n||function(e){var t=0,n="";if("number"==typeof e)t=((t=Math.floor(e))<<5)-t,t&=t;else{n="string"!=typeof e?JSON.stringify(e):e;for(var r=0;r<n.length;r++)t=(t<<5)-t+n.charCodeAt(r),t&=t}return t^=t>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(n){n.forEach((function(n){e(n,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(r,o){if(!r.empty()){if(r instanceof s.default&&1===r.size()){var c=r.front();if(void 0===c)throw new Error("unknown error");t[n(c)&h-1]=new s.default([c])}else if(r instanceof i.default){var l=new s.default,f=new s.default;r.forEach((function(t){0==(n(t)&e)?l.pushBack(t):f.pushBack(t)})),l.size()>a.untreeifyThreshold?t[o]=new i.default(l):l.size()&&(t[o]=l),f.size()>a.untreeifyThreshold?t[o+e]=new i.default(f):f.size()&&(t[o+e]=f)}else{var p=new s.default,d=new s.default;r.forEach((function(t){0==(n(t)&e)?p.pushBack(t):d.pushBack(t)})),p.size()&&(t[o]=p),d.size()&&(t[o+e]=d)}u[o].clear()}})),u=t}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var t=n(e)&h-1;if(u[t]){var r=u[t].size();if(u[t]instanceof s.default){if(u[t].find(e))return;u[t].pushBack(e),u[t].size()>=a.treeifyThreshold&&(u[t]=new i.default(u[t]))}else u[t].insert(e);var o=u[t].size();l+=o-r}else u[t]=new s.default([e]),++l;l>h*a.sigma&&f.call(this,h)},this.eraseElementByValue=function(e){var t=n(e)&h-1;if(u[t]){var r=u[t].size();u[t].eraseElementByValue(e),u[t]instanceof i.default&&u[t].size()<=a.untreeifyThreshold&&(u[t]=new s.default(u[t]));var o=u[t].size();l+=o-r}},this.find=function(e){var t=n(e)&h-1;return!!u[t]&&u[t].find(e)},this[Symbol.iterator]=function(){return function(){var e,t,n,i,s,a;return r(this,(function(r){switch(r.label){case 0:e=0,r.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];r.label=2;case 2:r.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),n=t.next(),r.label=3;case 3:return n.done?[3,6]:[4,n.value];case 4:r.sent(),r.label=5;case 5:return n=t.next(),[3,3];case 6:return[3,9];case 7:return i=r.sent(),s={error:i},[3,9];case 8:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){return c.insert(e)})),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),n.default=a},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e}return e}();function i(e){var t=this;void 0===e&&(e=[]);var n=0,i=void 0,s=void 0;this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){i=s=void 0,n=0},this.front=function(){return null==i?void 0:i.value},this.back=function(){return null==s?void 0:s.value},this.forEach=function(e){for(var t=i,n=0;t;){if(void 0===t.value)throw new Error("unknown error");e(t.value,n++),t=t.next}},this.getElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more then 0 and less then the list length");for(var t=i;e--&&t;)t=t.next;if(!t||void 0===t.value)throw new Error("unknown error");return t.value},this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("erase pos must more then 0 and less then the list length");if(0===e)this.popFront();else if(e===n-1)this.popBack();else{for(var t=i;e--;){if(!(null==t?void 0:t.next))throw new Error("unknown error");t=t.next}if(!t||!t.pre||!t.next)throw new Error("unknown error");var r=t.pre,o=t.next;o.pre=r,r.next=o,n>0&&--n}},this.eraseElementByValue=function(e){for(;i&&i.value===e;)this.popFront();for(;s&&s.value===e;)this.popBack();if(i)for(var t=i;t;){if(t.value===e){var r=t.pre,o=t.next;o&&(o.pre=r),r&&(r.next=o),n>0&&--n}t=t.next}},this.pushBack=function(e){if(null==e)throw new Error("you can't push null or undefined here");++n;var t=new o(e);s?(s.next=t,t.pre=s,s=t):i=s=t},this.popBack=function(){s&&(n>0&&--n,s&&(i===s?i=s=void 0:(s=s.pre)&&(s.next=void 0)))},this.setElementByPos=function(e,t){if(null==t)throw new Error("you can't set null or undefined here");if(e<0||e>=n)throw new Error("pos must more then 0 and less then the list length");for(var r=i;e--;){if(!r)throw new Error("unknown error");r=r.next}r&&(r.value=t)},this.insert=function(e,t,r){if(void 0===r&&(r=1),null==t)throw new Error("you can't insert null or undefined here");if(e<0||e>n)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(r<0)throw new Error("insert size must more than 0");if(0===e)for(;r--;)this.pushFront(t);else if(e===n)for(;r--;)this.pushBack(t);else{for(var s=i,a=1;a<e;++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 c=s.next;for(n+=r;r--;)s.next=new o(t),s.next.pre=s,s=s.next;s.next=c,c&&(c.pre=s)}},this.find=function(e){for(var t=i;t;){if(t.value===e)return!0;t=t.next}return!1},this.reverse=function(){for(var e=i,t=s,r=0;e&&t&&2*r<n;){var o=e.value;e.value=t.value,t.value=o,e=e.next,t=t.pre,++r}},this.unique=function(){for(var e=i;e;){for(var t=e;t&&t.next&&t.value===t.next.value;)t=t.next,n>0&&--n;e.next=t.next,e.next&&(e.next.pre=e),e=e.next}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);var n=i;t.forEach((function(e){n&&(n.value=e,n=n.next)}))},this.pushFront=function(e){if(null==e)throw new Error("you can't push null or undefined here");++n;var t=new o(e);i?(t.next=i,i.pre=t,i=t):i=s=t},this.popFront=function(){i&&(n>0&&--n,i&&(i===s?i=s=void 0:(i=i.next)&&(i.pre=void 0)))},this.merge=function(e){var t=this,r=i;e.forEach((function(e){for(;r&&void 0!==r.value&&r.value<=e;)r=r.next;if(void 0===r)t.pushBack(e),r=s;else if(r===i)t.pushFront(e),r=i;else{++n;var a=r.pre;a&&(a.next=new o(e),a.next.pre=a,a.next.next=r,r&&(r.pre=a.next))}}))},this[Symbol.iterator]=function(){return function(){var e;return r(this,(function(t){switch(t.label){case 0:e=i,t.label=1;case 1:if(void 0===e)return[3,3];if(!e.value)throw new Error("unknown error");return[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.freeze(i),n.default=i},{}],30:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var n=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.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 c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty()){var e=c(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.back=function(){if(!this.empty()){var e=l(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.forEach=function(e){var t,n,r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,r++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,n;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===e)return a;++r}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw new Error("unknown Error")};var u=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value){var r=t(e.key,n);return 0===r?{key:e.key,value:e.value}:r<0?u(e.rightChild,n):u(e.leftChild,n)||{key:e.key,value:e.value}}};this.lowerBound=function(e){return u(a,e)};var h=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,n)<=0?h(e.rightChild,n):h(e.leftChild,n)||{key:e.key,value:e.value}};this.upperBound=function(e){return h(a,e)};var f=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value){var r=t(e.key,n);return 0===r?{key:e.key,value:e.value}:r>0?f(e.leftChild,n):f(e.rightChild,n)||{key:e.key,value:e.value}}};this.reverseLowerBound=function(e){return f(a,e)};var p=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,n)>=0?p(e.leftChild,n):p(e.rightChild,n)||{key:e.key,value:e.value}};this.reverseUpperBound=function(e){return p(a,e)};var d=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var n=e.brother;if(!n)throw new Error("unknown error");if(e===t.leftChild)if(n.color===i.default.TreeNodeColorType.red){n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var r=t.rotateLeft();a===t&&(a=r),d(e)}else n.color===i.default.TreeNodeColorType.black&&(n.rightChild&&n.rightChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=t.rotateLeft(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||!n.leftChild||n.leftChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,d(t)):(n.color=i.default.TreeNodeColorType.red,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=n.rotateRight(),a===n&&(a=r),d(e)));else e===t.rightChild&&(n.color===i.default.TreeNodeColorType.red?(n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,r=t.rotateRight(),a===t&&(a=r),d(e)):n.color===i.default.TreeNodeColorType.black&&(n.leftChild&&n.leftChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=t.rotateRight(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||!n.rightChild||n.rightChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,d(t)):(n.color=i.default.TreeNodeColorType.red,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=n.rotateLeft(),a===n&&(a=r),d(e))))}else e.color=i.default.TreeNodeColorType.black},m=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var n=e.key;e.key=t.key,t.key=n;var r=e.value;e.value=t.value,t.value=r,e=t}t.leftChild&&(t=l(t.leftChild),n=e.key,e.key=t.key,t.key=n,r=e.value,e.value=t.value,t.value=r,e=t)}d(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},g=function(e,t){return!(!e||void 0===e.key)&&(!!g(e.leftChild,t)||!!t(e)||g(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;g(a,(function(n){return e===t?(m(n),!0):(++t,!1)}))},this.eraseElementByKey=function(e){if(!this.empty()){var n=b(a,e);void 0!==n&&void 0!==n.key&&0===t(n.key,e)&&m(n)}};var y=function(e,n){if(!e||void 0===e.key)throw new Error("unknown error");var r=t(n,e.key);return r<0?e.leftChild?y(e.leftChild,n):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):r>0?e.rightChild?y(e.rightChild,n):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},v=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var n=t.brother,r=t.parent;if(!r)throw new Error("unknown error");if(n&&n.color===i.default.TreeNodeColorType.red)n.color=t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,v(r);else if(!n||n.color===i.default.TreeNodeColorType.black)if(t===r.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red;var o=r.rotateRight();r===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),r===a&&(a=o),v(t));else t===r.rightChild&&(e===t.leftChild?(o=t.rotateRight(),r===a&&(a=o),v(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,o=r.rotateLeft(),r===a&&(a=o)))}};this.setElement=function(e,n){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=n){if(this.empty())return++s,a.key=e,a.value=n,void(a.color=i.default.TreeNodeColorType.black);var r=y(a,e);void 0===r.key||0!==t(r.key,e)?(++s,r.key=e,r.value=n,v(r),a.color=i.default.TreeNodeColorType.black):r.value=n}else this.eraseElementByKey(e)};var b=function(e,n){if(e&&void 0!==e.key){var r=t(n,e.key);return r<0?b(e.leftChild,n):r>0?b(e.rightChild,n):e}};this.find=function(e){return!!b(a,e)},this.getElementByKey=function(e){var t=b(a,e);if(void 0===(null==t?void 0:t.key)||void 0===(null==t?void 0:t.value))throw new Error("unknown error");return t.value},this.union=function(e){var t=this;e.forEach((function(e){var n=e.key,r=e.value;return t.setElement(n,r)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return r(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key&&void 0!==e.value?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,{key:e.key,value:e.value}];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){var t=e.key,r=e.value;return n.setElement(t,r)})),Object.freeze(this)}Object.freeze(s),n.default=s},{"../Base/TreeNode":25}],31:[function(e,t,n){function r(e,t){void 0===e&&(e=[]),t=t||function(e,t){return e>t?-1:e<t?1:0};var n=[];e.forEach((function(e){return n.push(e)}));var r=n.length,o=function(e,t){if(e<0||e>=r)throw new Error("unknown error");if(t<0||t>=r)throw new Error("unknown error");var o=n[e];n[e]=n[t],n[t]=o},i=function(e){if(e<0||e>=r)throw new Error("unknown error");var i=2*e+1,s=2*e+2;i<r&&t(n[e],n[i])>0&&o(e,i),s<r&&t(n[e],n[s])>0&&o(e,s)};!function(){for(var e=Math.floor((r-1)/2);e>=0;--e)for(var i=e,s=2*i+1;s<r;){var a=s+1,c=s;if(a<r&&t(n[s],n[a])>0&&(c=a),t(n[i],n[c])<=0)break;o(i,c),s=2*(i=c)+1}}(),this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,n.length=0},this.push=function(e){if(n.push(e),1!=++r)for(var o=r-1;o>0;){var s=Math.floor((o-1)/2);if(t(n[s],e)<=0)break;i(s),o=s}},this.pop=function(){if(!this.empty())if(1!==this.size()){var e=n[r-1];--r;for(var o=0;o<this.size();){var i=2*o+1,s=2*o+2;if(i>=this.size())break;var a=i;if(s<this.size()&&t(n[i],n[s])>0&&(a=s),t(n[a],e)>=0)break;n[o]=n[a],o=a}n[o]=e}else--r},this.top=function(){return n[0]},Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],32:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var r=e("../LinkList/LinkList");function o(e){void 0===e&&(e=[]);var t=new r.default(e);this.size=function(){return t.size()},this.empty=function(){return t.empty()},this.clear=function(){t.clear()},this.push=function(e){t.pushBack(e)},this.pop=function(){t.popFront()},this.front=function(){return t.front()},Object.freeze(this)}Object.freeze(o),n.default=o},{"../LinkList/LinkList":29}],33:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var n=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.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=i.default.TreeNodeColorType.black};var c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty())return c(a).key},this.back=function(){if(!this.empty())return l(a).key},this.forEach=function(e){var t,n,r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,r++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,n;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===e)return a;++r}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw new Error("unknown error")};var u=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var n=e.brother;if(!n)throw new Error("unknown error");if(e===t.leftChild)if(n.color===i.default.TreeNodeColorType.red){n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var r=t.rotateLeft();a===t&&(a=r),u(e)}else n.color===i.default.TreeNodeColorType.black&&(n.rightChild&&n.rightChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=t.rotateLeft(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||!n.leftChild||n.leftChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,u(t)):(n.color=i.default.TreeNodeColorType.red,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=n.rotateRight(),a===n&&(a=r),u(e)));else e===t.rightChild&&(n.color===i.default.TreeNodeColorType.red?(n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,r=t.rotateRight(),a===t&&(a=r),u(e)):n.color===i.default.TreeNodeColorType.black&&(n.leftChild&&n.leftChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=t.rotateRight(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||!n.rightChild||n.rightChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,u(t)):(n.color=i.default.TreeNodeColorType.red,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=n.rotateLeft(),a===n&&(a=r),u(e))))}else e.color=i.default.TreeNodeColorType.black},h=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var n=e.key;e.key=t.key,t.key=n,e=t}t.leftChild&&(t=l(t.leftChild),n=e.key,e.key=t.key,t.key=n,e=t)}u(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},f=function(e,t){return!(!e||void 0===e.key)&&(!!f(e.leftChild,t)||!!t(e)||f(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;f(a,(function(n){return e===t?(h(n),!0):(++t,!1)}))},this.eraseElementByValue=function(e){if(!this.empty()){var n=m(a,e);void 0!==n&&void 0!==n.key&&0===t(n.key,e)&&h(n)}};var p=function(e,n){if(!e||void 0===e.key)throw new Error("unknown error");var r=t(n,e.key);return r<0?e.leftChild?p(e.leftChild,n):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):r>0?e.rightChild?p(e.rightChild,n):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},d=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var n=t.brother,r=t.parent;if(!r)throw new Error("unknown error");if(n&&n.color===i.default.TreeNodeColorType.red)n.color=t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,d(r);else if(!n||n.color===i.default.TreeNodeColorType.black)if(t===r.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red;var o=r.rotateRight();r===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),r===a&&(a=o),d(t));else t===r.rightChild&&(e===t.leftChild?(o=t.rotateRight(),r===a&&(a=o),d(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,o=r.rotateLeft(),r===a&&(a=o)))}};this.insert=function(e){if(null==e)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=e,void(a.color=i.default.TreeNodeColorType.black);var n=p(a,e);void 0!==n.key&&0===t(n.key,e)||(++s,n.key=e,d(n),a.color=i.default.TreeNodeColorType.black)};var m=function(e,n){if(e&&void 0!==e.key){var r=t(n,e.key);return r<0?m(e.leftChild,n):r>0?m(e.rightChild,n):e}};this.find=function(e){var n=m(a,e);return void 0!==n&&void 0!==n.key&&0===t(n.key,e)};var g=function(e,n){if(e&&void 0!==e.key){var r=t(e.key,n);if(0===r)return e.key;if(r<0)return g(e.rightChild,n);var o=g(e.leftChild,n);return void 0!==o?o:e.key}};this.lowerBound=function(e){return g(a,e)};var y=function(e,n){if(e&&void 0!==e.key){if(t(e.key,n)<=0)return y(e.rightChild,n);var r=y(e.leftChild,n);return void 0!==r?r:e.key}};this.upperBound=function(e){return y(a,e)};var v=function(e,n){if(e&&void 0!==e.key){var r=t(e.key,n);if(0===r)return e.key;if(r>0)return v(e.leftChild,n);var o=v(e.rightChild,n);return void 0!==o?o:e.key}};this.reverseLowerBound=function(e){return v(a,e)};var b=function(e,n){if(e&&void 0!==e.key){if(t(e.key,n)>=0)return b(e.leftChild,n);var r=b(e.rightChild,n);return void 0!==r?r:e.key}};this.reverseUpperBound=function(e){return b(a,e)},this.union=function(e){var t=this;e.forEach((function(e){return t.insert(e)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return r(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){return n.insert(e)})),Object.freeze(this)}Object.freeze(s),n.default=s},{"../Base/TreeNode":25}],34:[function(e,t,n){function r(e){var t=this;void 0===e&&(e=[]);var n=0,r=[];this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,r.length=0},this.push=function(e){r.push(e),++n},this.pop=function(){r.pop(),n>0&&--n},this.top=function(){return r[n-1]},e.forEach((function(e){return t.push(e)})),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],35:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function a(e){var t=this;void 0===e&&(e=[]);var n=0,a=[];this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,a.length=0},this.front=function(){if(!this.empty())return a[0]},this.back=function(){if(!this.empty())return a[n-1]},this.forEach=function(e){a.forEach(e)},this.getElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");return a[e]},this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");for(var t=e;t<n-1;++t)a[t]=a[t+1];this.popBack()},this.eraseElementByValue=function(e){var t=[];this.forEach((function(n){n!==e&&t.push(n)})),t.forEach((function(e,t){a[t]=e}));for(var r=t.length;n>r;)this.popBack()},this.pushBack=function(e){a.push(e),++n},this.popBack=function(){a.pop(),n>0&&--n},this.setElementByPos=function(e,t){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");a[e]=t},this.insert=function(e,t,r){if(void 0===r&&(r=1),e<0||e>n)throw new Error("pos must more than 0 and less than or equal to vector's size");a.splice.apply(a,i([e,0],o(new Array(r).fill(t)),!1)),n+=r},this.find=function(e){return a.includes(e)},this.reverse=function(){a.reverse()},this.unique=function(){var e,t=[];this.forEach((function(n,r){0!==r&&n===e||(t.push(n),e=n)})),t.forEach((function(e,t){a[t]=e}));for(var r=t.length;n>r;)this.popBack()},this.sort=function(e){a.sort(e)},this[Symbol.iterator]=function(){return function(){return r(this,(function(e){switch(e.label){case 0:return[5,s(a)];case 1:return[2,e.sent()]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(a),n.default=a},{}],36:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.HashMap=n.HashSet=n.Map=n.Set=n.PriorityQueue=n.Deque=n.LinkList=n.Queue=n.Stack=n.Vector=void 0;var r=e("./Vector/Vector");n.Vector=r.default;var o=e("./Stack/Stack");n.Stack=o.default;var i=e("./Queue/Queue");n.Queue=i.default;var s=e("./LinkList/LinkList");n.LinkList=s.default;var a=e("./Deque/Deque");n.Deque=a.default;var c=e("./PriorityQueue/PriorityQueue");n.PriorityQueue=c.default;var l=e("./Set/Set");n.Set=l.default;var u=e("./Map/Map");n.Map=u.default;var h=e("./HashSet/HashSet");n.HashSet=h.default;var f=e("./HashMap/HashMap");n.HashMap=f.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(e,t,n){const r=e("yallist"),o=Symbol("max"),i=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),c=Symbol("maxAge"),l=Symbol("dispose"),u=Symbol("noDisposeOnSet"),h=Symbol("lruList"),f=Symbol("cache"),p=Symbol("updateAgeOnGet"),d=()=>1;class m{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[o]=e.max||1/0;const t=e.length||d;if(this[s]="function"!=typeof t?d:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[c]=e.maxAge||0,this[l]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[p]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[o]=e||1/0,v(this)}get max(){return this[o]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[c]=e,v(this)}get maxAge(){return this[c]}set lengthCalculator(e){"function"!=typeof e&&(e=d),e!==this[s]&&(this[s]=e,this[i]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[i]+=e.length}))),v(this)}get lengthCalculator(){return this[s]}get length(){return this[i]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let n=this[h].tail;null!==n;){const r=n.prev;C(this,e,n,t),n=r}}forEach(e,t){t=t||this;for(let n=this[h].head;null!==n;){const r=n.next;C(this,e,n,t),n=r}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[l]&&this[h]&&this[h].length&&this[h].forEach((e=>this[l](e.key,e.value))),this[f]=new Map,this[h]=new r,this[i]=0}dump(){return this[h].map((e=>!y(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,n){if((n=n||this[c])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const r=n?Date.now():0,a=this[s](t,e);if(this[f].has(e)){if(a>this[o])return b(this,this[f].get(e)),!1;const s=this[f].get(e).value;return this[l]&&(this[u]||this[l](e,s.value)),s.now=r,s.maxAge=n,s.value=t,this[i]+=a-s.length,s.length=a,this.get(e),v(this),!0}const p=new w(e,t,a,r,n);return p.length>this[o]?(this[l]&&this[l](e,t),!1):(this[i]+=p.length,this[h].unshift(p),this[f].set(e,this[h].head),v(this),!0)}has(e){if(!this[f].has(e))return!1;const t=this[f].get(e).value;return!y(this,t)}get(e){return g(this,e,!0)}peek(e){return g(this,e,!1)}pop(){const e=this[h].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[f].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const r=e[n],o=r.e||0;if(0===o)this.set(r.k,r.v);else{const e=o-t;e>0&&this.set(r.k,r.v,e)}}}prune(){this[f].forEach(((e,t)=>g(this,t,!1)))}}const g=(e,t,n)=>{const r=e[f].get(t);if(r){const t=r.value;if(y(e,t)){if(b(e,r),!e[a])return}else n&&(e[p]&&(r.value.now=Date.now()),e[h].unshiftNode(r));return t.value}},y=(e,t)=>{if(!t||!t.maxAge&&!e[c])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[c]&&n>e[c]},v=e=>{if(e[i]>e[o])for(let t=e[h].tail;e[i]>e[o]&&null!==t;){const n=t.prev;b(e,t),t=n}},b=(e,t)=>{if(t){const n=t.value;e[l]&&e[l](n.key,n.value),e[i]-=n.length,e[f].delete(n.key),e[h].removeNode(t)}};class w{constructor(e,t,n,r,o){this.key=e,this.value=t,this.length=n,this.now=r,this.maxAge=o||0}}const C=(e,t,n,r)=>{let o=n.value;y(e,o)&&(b(e,n),e[a]||(o=void 0)),o&&t.call(r,o.value,o.key,e)};t.exports=m},{yallist:83}],38:[function(e,t,n){(function(e){(function(){const n=t.exports;n.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=e.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=e.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=e.from([n.codes.connect<<n.CMD_SHIFT]),n.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function r(t){return[0,1,2].map((r=>[0,1].map((o=>[0,1].map((i=>{const s=e.alloc(1);return s.writeUInt8(n.codes[t]<<n.CMD_SHIFT|(o?n.DUP_MASK:0)|r<<n.QOS_SHIFT|i,0,!0),s}))))))}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=e.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=e.from([3]),n.VERSION4=e.from([4]),n.VERSION5=e.from([5]),n.VERSION131=e.from([131]),n.VERSION132=e.from([132]),n.QOS=[0,1,2].map((t=>e.from([t]))),n.EMPTY={pingreq:e.from([n.codes.pingreq<<4,0]),pingresp:e.from([n.codes.pingresp<<4,0]),disconnect:e.from([n.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],39:[function(e,t,n){(function(n){(function(){const r=e("./writeToStream"),o=e("events");function i(e,t){const n=new s;return r(e,n,t),n.concat()}class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),r=this._array;let o,i=0;for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?t[o]=r[o].length:t[o]=n.byteLength(r[o]),e+=t[o];const s=n.allocUnsafe(e);for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?(r[o].copy(s,i),i+=t[o]):(s.write(r[o],i),i+=t[o]);return s}}t.exports=i}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(e,t,n){n.parser=e("./parser").parser,n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(e,t,n){(function(e){(function(){const n=65536,r={},o=e.isBuffer(e.from([1,2]).subarray(0,1));function i(t){const n=e.allocUnsafe(2);return n.writeUInt8(t>>8,0),n.writeUInt8(255&t,1),n}function s(){for(let e=0;e<n;e++)r[e]=i(e)}function a(t){const n=4;let r=0,i=0;const s=e.allocUnsafe(n);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),s.writeUInt8(r,i++)}while(t>0&&i<n);return t>0&&(i=0),o?s.subarray(0,i):s.slice(0,i)}function c(t){const n=e.allocUnsafe(4);return n.writeUInt32BE(t,0),n}t.exports={cache:r,generateCache:s,generateNumber:i,genBufVariableByteInt:a,generate4ByteBuffer:c}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],42:[function(e,t,n){class r{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=r},{}],43:[function(e,t,n){const r=e("bl"),o=e("events"),i=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),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 e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!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"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;a("_parseConnect");const o={},i=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.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(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.properties=e)}const l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(i.clientId=l,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=e,a("_parseConnect: packet.will.topic: %s",i.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));i.username=r,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));i.password=n}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,n,r,o,i,c,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=0!=(n>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(n>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=n>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:r},5===this.settings.protocolVersion?(l.nl=c,l.rap=i,l.rh=o):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,a("_parseString: result: %s",r),r}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");const t=4;let n,r=0,o=1,i=0,c=!1;const l=this._pos?this._pos:0;for(;r<t&&l+r<this._list.length;){if(n=this._list.readUInt8(l+r++),i+=o*(n&s.VARBYTEINT_MASK),o*=128,0==(n&s.VARBYTEINT_FIN_MASK)){c=!0;break}if(this._list.length<=r)break}return!c&&r===t&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=r),c=!!c&&(e?{bytes:r,value:i}:i),a("_parseVarByteNum: result: %o",c),c}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){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 e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(s.propertiesTypes[t]))):n[t]=this._parseByType(s.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_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 i,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}t.exports=c},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(e,t,n){(function(n){(function(){const r=e("./constants"),o=n.allocUnsafe(0),i=n.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,c=e("debug")("mqtt-packet:writeToStream"),l=s.cache,u=s.generateNumber,h=s.generateCache,f=s.genBufVariableByteInt,p=s.generate4ByteBuffer;let d=B,m=!0;function g(e,t,n){switch(c("generate called"),t.cork&&(t.cork(),a(y,t)),m&&(m=!1,h()),c("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return v(e,t);case"connack":return b(e,t,n);case"publish":return w(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return C(e,t,n);case"subscribe":return _(e,t,n);case"suback":return k(e,t,n);case"unsubscribe":return S(e,t,n);case"unsuback":return E(e,t,n);case"pingreq":case"pingresp":return A(e,t);case"disconnect":return T(e,t,n);case"auth":return x(e,t,n);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}function v(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let l=i.clean;const u=i.keepalive||0,h=i.clientId||"",f=i.username,p=i.password,m=i.properties;void 0===l&&(l=!0);let g=0;if(!s||"string"!=typeof s&&!n.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof h||n.isBuffer(h))&&(h||a>=4)&&(h||l))g+=n.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*l==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=M(t,m);if(!y)return!1;g+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(g+=n.byteLength(c.topic)+2,g+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?g+=n.byteLength(c.payload):g+=c.payload.length}var v={};if(5===a){if(!(v=M(t,c.properties)))return!1;g+=v.length}}let b=!1;if(null!=f){if(!z(f))return t.emit("error",new Error("Invalid username")),!1;b=!0,g+=n.byteLength(f)+2}if(null!=p){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!z(p))return t.emit("error",new Error("Invalid password")),!1;g+=q(p)+2}t.write(r.CONNECT_HEADER),O(t,g),j(t,s),i.bridgeMode&&(a+=128),t.write(131===a?r.VERSION131:132===a?r.VERSION132:4===a?r.VERSION4:5===a?r.VERSION5:r.VERSION3);let w=0;return w|=null!=f?r.USERNAME_MASK:0,w|=null!=p?r.PASSWORD_MASK:0,w|=c&&c.retain?r.WILL_RETAIN_MASK:0,w|=c&&c.qos?c.qos<<r.WILL_QOS_SHIFT:0,w|=c?r.WILL_FLAG_MASK:0,w|=l?r.CLEAN_SESSION_MASK:0,t.write(n.from([w])),d(t,u),5===a&&y.write(),j(t,h),c&&(5===a&&v.write(),R(t,c.topic),j(t,c.payload)),null!=f&&j(t,f),null!=p&&j(t,p),!0}function b(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,l=a.properties;let u=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=M(t,l),!h)return!1;u+=h.length}return t.write(r.CONNACK_HEADER),O(t,u),t.write(a.sessionPresent?r.SESSIONPRESENT_HEADER:i),t.write(n.from([c])),null!=h&&h.write(),!0}function w(e,t,i){c("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},l=a.qos||0,u=a.retain?r.RETAIN_MASK:0,h=a.topic,f=a.payload||o,p=a.messageId,m=a.properties;let g=0;if("string"==typeof h)g+=n.byteLength(h)+2;else{if(!n.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;g+=h.length+2}if(n.isBuffer(f)?g+=f.length:g+=n.byteLength(f),l&&"number"!=typeof p)return t.emit("error",new Error("Invalid messageId")),!1;l&&(g+=2);let y=null;if(5===s){if(y=M(t,m),!y)return!1;g+=y.length}return t.write(r.PUBLISH_HEADER[l][a.dup?1:0][u?1:0]),O(t,g),d(t,q(h)),t.write(h),l>0&&d(t,p),null!=y&&y.write(),c("publish: payload: %o",f),t.write(f)}function C(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,l=s.dup&&"pubrel"===a?r.DUP_MASK:0;let u=0;const h=s.reasonCode,f=s.properties;let p=5===i?3:2;if("pubrel"===a&&(u=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof f){if(m=U(t,f,o,p),!m)return!1;p+=m.length}return t.write(r.ACKS[a][u][l][0]),O(t,p),d(t,c),5===i&&t.write(n.from([h])),null!==m&&m.write(),!0}function _(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?r.DUP_MASK:0,l=s.messageId,u=s.subscriptions,h=s.properties;let f=0;if("number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;f+=2;let p=null;if(5===i){if(p=M(t,h),!p)return!1;f+=p.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const r=u[e].topic,o=u[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(u[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(u[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=u[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}f+=n.byteLength(r)+2+1}c("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),t.write(r.SUBSCRIBE_HEADER[1][a?1:0][0]),O(t,f),d(t,l),null!==p&&p.write();let m=!0;for(const e of u){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,l=e.rh;let u;R(t,o),u=r.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(u|=a?r.SUBSCRIBE_OPTIONS_NL:0,u|=c?r.SUBSCRIBE_OPTIONS_RAP:0,u|=l?r.SUBSCRIBE_OPTIONS_RH[l]:0),m=t.write(n.from([u]))}return m}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,l=s.properties;let u=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(u+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;u+=1}let h=null;if(5===i){if(h=U(t,l,o,u),!h)return!1;u+=h.length}return t.write(r.SUBACK_HEADER),O(t,u),d(t,a),null!==h&&h.write(),t.write(n.from(c))}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.unsubscriptions,u=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=n.byteLength(l[e])+2}let f=null;if(5===i){if(f=M(t,u),!f)return!1;h+=f.length}t.write(r.UNSUBSCRIBE_HEADER[1][c?1:0][0]),O(t,h),d(t,a),null!==f&&f.write();let p=!0;for(let e=0;e<l.length;e++)p=R(t,l[e]);return p}function E(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.granted,u=s.properties,h=s.cmd,f=0;let p=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),!1;p+=1}}let m=null;if(5===i){if(m=U(t,u,o,p),!m)return!1;p+=m.length}return t.write(r.ACKS[h][f][c][0]),O(t,p),d(t,a),null!==m&&m.write(),5===i&&t.write(n.from(l)),!0}function A(e,t,n){return t.write(r.EMPTY[e.cmd])}function T(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0,u=null;if(5===i){if(u=U(t,c,o,l),!u)return!1;l+=u.length}return t.write(n.from([r.codes.disconnect<<4])),O(t,l),5===i&&t.write(n.from([a])),null!==u&&u.write(),!0}function x(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const u=U(t,c,o,l);return!!u&&(l+=u.length,t.write(n.from([r.codes.auth<<4])),O(t,l),t.write(n.from([a])),null!==u&&u.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>d===B,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),d=B):(m=!1,d=F)}});const I={};function O(e,t){if(t>r.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=I[t];return n||(n=f(t),t<16384&&(I[t]=n)),c("writeVarByteInt: writing to stream: %o",n),e.write(n)}function R(e,t){const r=n.byteLength(t);return d(e,r),c("writeString: %s",t),e.write(t,"utf8")}function P(e,t,n){R(e,t),R(e,n)}function B(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",l[t]),e.write(l[t])}function F(e,t){const n=u(t);return c("writeNumberGenerated: %o",n),e.write(n)}function N(e,t){const n=p(t);return c("write4ByteNumber: %o",n),e.write(n)}function j(e,t){"string"==typeof t?R(e,t):t?(d(e,t.length),e.write(t)):d(e,0)}function M(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){D(e,{},0)}};let o=0;function i(t,o){let i=0;switch(r.propertiesTypes[t]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(f(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3+n.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce(((e,t)=>{const r=o[t];return Array.isArray(r)?e+=r.reduce(((e,r)=>e+=3+n.byteLength(t.toString())+2+n.byteLength(r.toString())),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(o[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${o}`)),!1}return i}if(t)for(const e in t){let n=0,r=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(r=i(e,s[t]),!r)return!1;n+=r}else{if(r=i(e,s),!r)return!1;n=r}if(!n)return!1;o+=n}return{length:n.byteLength(f(o))+o,write(){D(e,t,o)}}}function U(e,t,n,r){const o=["reasonString","userProperties"],i=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0;let s=M(e,t);if(i)for(;r+s.length>i;){const n=o.shift();if(!n||!t[n])return!1;delete t[n],s=M(e,t)}return s}function L(e,t,o){switch(r.propertiesTypes[t]){case"byte":e.write(n.from([r.properties[t]])),e.write(n.from([+o]));break;case"int8":e.write(n.from([r.properties[t]])),e.write(n.from([o]));break;case"binary":e.write(n.from([r.properties[t]])),j(e,o);break;case"int16":e.write(n.from([r.properties[t]])),d(e,o);break;case"int32":e.write(n.from([r.properties[t]])),N(e,o);break;case"var":e.write(n.from([r.properties[t]])),O(e,o);break;case"string":e.write(n.from([r.properties[t]])),R(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach((i=>{const s=o[i];Array.isArray(s)?s.forEach((o=>{e.write(n.from([r.properties[t]])),P(e,i.toString(),o.toString())})):(e.write(n.from([r.properties[t]])),P(e,i.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${o}`)),!1}}function D(e,t,n){O(e,n);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&null!==t[n]){const r=t[n];if(Array.isArray(r))for(let t=0;t<r.length;t++)L(e,n,r[t]);else L(e,n,r)}}function q(e){return e?e instanceof n?e.length:n.byteLength(e):0}function z(e){return"string"==typeof e||e instanceof n}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,c=365.25*s;function l(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function u(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}function h(e){var t=Math.abs(e);return t>=s?f(e,t,s,"day"):t>=i?f(e,t,i,"hour"):t>=o?f(e,t,o,"minute"):t>=r?f(e,t,r,"second"):e+" ms"}function f(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return l(e);if("number"===n&&isFinite(e))return t.long?h(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],46:[function(e,t,n){const r=e("./lib/number-allocator.js");t.exports.NumberAllocator=r},{"./lib/number-allocator.js":47}],47:[function(e,t,n){const r=e("js-sdsl").Set,o=e("debug")("number-allocator:trace"),i=e("debug")("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new r([],((e,t)=>e.compare(t))),o("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.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 o("alloc():empty"),null;const e=this.ss.front(),t=e.low;return t+1<=e.high?++e.low:this.ss.eraseElementByPos(0),o("alloc():"+t),t},a.prototype.use=function(e){const t=new s(e,e),n=this.ss.lowerBound(t);if(n){if(n.equals(t))return this.ss.eraseElementByValue(n),o("use():"+e),!0;if(n.low>e)return!1;if(n.low===e)return++n.low,o("use():"+e),!0;if(n.high===e)return--n.high,o("use():"+e),!0;const r=n.low;return n.low=e+1,this.ss.insert(new s(r,e-1)),o("use():"+e),!0}return o("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void i("free():"+e+" is out of range");const t=new s(e,e),n=this.ss.lowerBound(t);if(n){if(n.low<=e&&e<=n.high)return void i("free():"+e+" has already been vacant");if(n===this.ss.front())e+1===n.low?--n.low:this.ss.insert(t);else{const r=this.ss.reverseLowerBound(t);r.high+1===e?e+1===n.low?(this.ss.eraseElementByValue(r),n.low=r.low):r.high=e:e+1===n.low?n.low=e:this.ss.insert(t)}}else{if(n===this.ss.front())return void this.ss.insert(t);const r=this.ss.reverseLowerBound(t);r.high+1===e?r.high=e:this.ss.insert(t)}o("free():"+e)},a.prototype.clear=function(){o("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 e of this.ss)console.log(e)},t.exports=a},{debug:18,"js-sdsl":36}],48:[function(e,t,n){var r=e("wrappy");function o(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(o),t.exports.strict=r(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},{wrappy:79}],49:[function(e,t,n){(function(e){(function(){function n(t,n,r,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,n)}));case 3:return e.nextTick((function(){t.call(null,n,r)}));case 4:return e.nextTick((function(){t.call(null,n,r,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:n}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:50}],50:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function l(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var u,h=[],f=!1,p=-1;function d(){f&&u&&(f=!1,u.length?h=u.concat(h):p=-1,h.length&&m())}function m(){if(!f){var e=c(d);f=!0;for(var t=h.length;t;){for(u=h,h=[];++p<t;)u&&u[p].run();p=-1,t=h.length}u=null,f=!1,l(e)}}function g(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new g(e,t)),1!==h.length||f||c(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],51:[function(e,t,n){(function(e){(function(){!function(r){var o="object"==typeof n&&n&&!n.nodeType&&n,i="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,c,l=2147483647,u=36,h=1,f=26,p=38,d=700,m=72,g=128,y="-",v=/^xn--/,b=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=u-h,k=Math.floor,S=String.fromCharCode;function E(e){throw new RangeError(C[e])}function A(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function T(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+A((e=e.replace(w,".")).split("."),t).join(".")}function x(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function I(e){return A(e,(function(e){var t="";return e>65535&&(t+=S((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=S(e)})).join("")}function O(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:u}function R(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,n){var r=0;for(e=n?k(e/d):e>>1,e+=k(e/t);e>_*f>>1;r+=u)e=k(e/_);return k(r+(_+1)*e/(e+p))}function B(e){var t,n,r,o,i,s,a,c,p,d,v=[],b=e.length,w=0,C=g,_=m;for((n=e.lastIndexOf(y))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&E("not-basic"),v.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<b;){for(i=w,s=1,a=u;o>=b&&E("invalid-input"),((c=O(e.charCodeAt(o++)))>=u||c>k((l-w)/s))&&E("overflow"),w+=c*s,!(c<(p=a<=_?h:a>=_+f?f:a-_));a+=u)s>k(l/(d=u-p))&&E("overflow"),s*=d;_=P(w-i,t=v.length+1,0==i),k(w/t)>l-C&&E("overflow"),C+=k(w/t),w%=t,v.splice(w++,0,C)}return I(v)}function F(e){var t,n,r,o,i,s,a,c,p,d,v,b,w,C,_,A=[];for(b=(e=x(e)).length,t=g,n=0,i=m,s=0;s<b;++s)(v=e[s])<128&&A.push(S(v));for(r=o=A.length,o&&A.push(y);r<b;){for(a=l,s=0;s<b;++s)(v=e[s])>=t&&v<a&&(a=v);for(a-t>k((l-n)/(w=r+1))&&E("overflow"),n+=(a-t)*w,t=a,s=0;s<b;++s)if((v=e[s])<t&&++n>l&&E("overflow"),v==t){for(c=n,p=u;!(c<(d=p<=i?h:p>=i+f?f:p-i));p+=u)_=c-d,C=u-d,A.push(S(R(d+_%C,0))),c=k(_/C);A.push(S(R(c,0))),i=P(n,w,r==o),n=0,++r}++n,++t}return A.join("")}function N(e){return T(e,(function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e}))}function j(e){return T(e,(function(e){return b.test(e)?"xn--"+F(e):e}))}if(a={version:"1.4.1",ucs2:{decode:x,encode:I},decode:B,encode:F,toASCII:j,toUnicode:N},o&&i)if(t.exports==o)i.exports=a;else for(c in a)a.hasOwnProperty(c)&&(o[c]=a[c]);else r.punycode=a}(this)}).call(this)}).call(this,void 0!==de?de:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],52:[function(e,t,n){function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var l=e.length;c>0&&l>c&&(l=c);for(var u=0;u<l;++u){var h,f,p,d,m=e[u].replace(a,"%20"),g=m.indexOf(n);g>=0?(h=m.substr(0,g),f=m.substr(g+1)):(h=m,f=""),p=decodeURIComponent(h),d=decodeURIComponent(f),r(s,p)?o(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],53:[function(e,t,n){var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],54:[function(e,t,n){n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":52,"./encode":53}],55:[function(e,t,n){function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var o={};function i(e,t,n){function i(e,n,r){return"string"==typeof t?t:t(e,n,r)}n||(n=Error);var s=function(e){function t(t,n,r){return e.call(this,i(t,n,r))||this}return r(t,e),t}(n);s.prototype.name=n.name,s.prototype.code=e,o[e]=s}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function c(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function l(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o;if("string"==typeof t&&a(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",c(e," argument"))o="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var i=l(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(i," ").concat(r," ").concat(s(t,"type"))}return o+=". Received type ".concat(typeof n)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=o},{}],56:[function(e,t,n){(function(n){(function(){var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(l,o);for(var s=r(i.prototype),a=0;a<s.length;a++){var c=s[a];l.prototype[c]||(l.prototype[c]=i.prototype[c])}function l(e){if(!(this instanceof l))return new l(e);o.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",u)))}function u(){this._writableState.ended||n.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}e("inherits")(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":59,inherits:24}],58:[function(e,t,n){(function(n,r){(function(){var o;t.exports=x,x.ReadableState=T,e("events").EventEmitter;var i=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,c=r.Uint8Array||function(){};function l(e){return a.from(e)}function u(e){return a.isBuffer(e)||e instanceof c}var h,f=e("util");h=f&&f.debuglog?f.debuglog("stream"):function(){};var p,d,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),v=e("./internal/streams/state").getHighWaterMark,b=e("../errors").codes,w=b.ERR_INVALID_ARG_TYPE,C=b.ERR_STREAM_PUSH_AFTER_EOF,_=b.ERR_METHOD_NOT_IMPLEMENTED,k=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(x,s);var S=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function A(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function T(t,n,r){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof o),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v(this,t,"readableHighWaterMark",r),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!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=e("string_decoder/").StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function x(t){if(o=o||e("./_stream_duplex"),!(this instanceof x))return new x(t);var n=this instanceof o;this._readableState=new T(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function I(e,t,n,r,o){h("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,N(e,s);else if(o||(i=R(s,t)),i)S(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=l(t)),r)s.endEmitted?S(e,new k):O(e,s,t,!0);else if(s.ended)S(e,new C);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?O(e,s,t,!1):U(e,s)):O(e,s,t,!1)}else r||(s.reading=!1,U(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function O(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&j(e)),U(e,t)}function R(e,t){var n;return u(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new w("chunk",["string","Buffer","Uint8Array"],t)),n}Object.defineProperty(x.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),x.prototype.destroy=y.destroy,x.prototype._undestroy=y.undestroy,x.prototype._destroy=function(e,t){t(e)},x.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=a.from(e,t),t=""),n=!0),I(this,e,t,!1,n)},x.prototype.unshift=function(e){return I(this,e,null,!0,!1)},x.prototype.isPaused=function(){return!1===this._readableState.flowing},x.prototype.setEncoding=function(t){p||(p=e("string_decoder/").StringDecoder);var n=new p(t);this._readableState.decoder=n,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,o="";null!==r;)o+=n.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};var P=1073741824;function B(e){return e>=P?e=P:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function F(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=B(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function N(e,t){if(h("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?j(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}function j(e){var t=e._readableState;h("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(M,e))}function M(e){var t=e._readableState;h("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,V(e)}function U(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(L,e,t))}function L(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(h("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function D(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,V(e))}}function q(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function z(e){h("readable nexttick read 0"),e.read(0)}function $(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(H,e,t))}function H(e,t){h("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),V(e),t.flowing&&!t.reading&&e.read(0)}function V(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function W(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function K(e){var t=e._readableState;h("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(Q,t,e))}function Q(e,t){if(h("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function J(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}x.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?K(this):j(this),null;if(0===(e=F(e,t))&&t.ended)return 0===t.length&&K(this),null;var r,o=t.needReadable;return h("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&h("length less than watermark",o=!0),t.ended||t.reading?h("reading or ended",o=!1):o&&(h("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=F(n,t))),null===(r=e>0?W(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&K(this)),null!==r&&this.emit("data",r),r},x.prototype._read=function(e){S(this,new _("_read()"))},x.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?y:c;function a(e,t){h("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,f())}function c(){h("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=D(r);e.on("drain",l);var u=!1;function f(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",p),u=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l()}function p(t){h("ondata");var n=e.write(t);h("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==J(o.pipes,e))&&!u&&(h("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(t){h("onerror",t),y(),e.removeListener("error",d),0===i(e,"error")&&S(e,t)}function m(){e.removeListener("finish",g),y()}function g(){h("onfinish"),e.removeListener("close",m),y()}function y(){h("unpipe"),r.unpipe(e)}return r.on("data",p),A(e,"error",d),e.once("close",m),e.once("finish",g),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},x.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=J(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},x.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,h("on readable",o.length,o.reading),o.length?j(this):o.reading||n.nextTick(z,this))),r},x.prototype.addListener=x.prototype.on,x.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(q,this),r},x.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(q,this),t},x.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!e.readableListening,$(this,e)),e.paused=!1,this},x.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},x.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var o in e.on("end",(function(){if(h("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){h("wrapped data"),n.decoder&&(o=n.decoder.write(o)),n.objectMode&&null==o||(n.objectMode||o&&o.length)&&(t.push(o)||(r=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var i=0;i<E.length;i++)e.on(E[i],this.emit.bind(this,E[i]));return this._read=function(t){h("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(x.prototype[Symbol.asyncIterator]=function(){return void 0===d&&(d=e("./internal/streams/async_iterator")),d(this)}),Object.defineProperty(x.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(x.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(x.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),x._fromList=W,Object.defineProperty(x.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(x.from=function(t,n){return void 0===m&&(m=e("./internal/streams/from")),m(x,t,n)})}).call(this)}).call(this,e("_process"),void 0!==de?de:"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(e,t,n){t.exports=u;var r=e("../errors").codes,o=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=e("./_stream_duplex");function l(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);c.call(this,e),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush((function(t,n){f(e,t,n)}))}function f(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(u,c),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,n){n(new o("_transform()"))},u.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},u.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(e,t,n){(function(n,r){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){H(t,e)}}var i;t.exports=T,T.WritableState=A;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,l=r.Uint8Array||function(){};function u(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof l}var f,p=e("./internal/streams/destroy"),d=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,v=m.ERR_MULTIPLE_CALLBACK,b=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,C=m.ERR_STREAM_NULL_VALUES,_=m.ERR_STREAM_WRITE_AFTER_END,k=m.ERR_UNKNOWN_ENCODING,S=p.errorOrDestroy;function E(){}function A(t,n,r){i=i||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=d(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){N(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function T(t){var n=this instanceof(i=i||e("./_stream_duplex"));if(!n&&!f.call(T,this))return new T(t);this._writableState=new A(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function x(e,t){var r=new _;S(e,r),n.nextTick(t,r)}function I(e,t,r,o){var i;return null===r?i=new C:"string"==typeof r||t.objectMode||(i=new g("chunk",["string","Buffer"],r)),!i||(S(e,i),n.nextTick(o,i),!1)}function O(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,n)),t}function R(e,t,n,r,o,i){if(!n){var s=O(t,r,o);r!==s&&(n=!0,o="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else P(e,t,!1,a,r,o,i);return c}function P(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function B(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(z,e,t),e._writableState.errorEmitted=!0,S(e,o)):(i(o),e._writableState.errorEmitted=!0,S(e,o),z(e,t))}function F(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function N(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new v;if(F(r),t)B(e,r,o,t,i);else{var s=L(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||U(e,r),o?n.nextTick(j,e,r,s,i):j(e,r,s,i)}}function j(e,t,n,r){n||M(e,t),t.pendingcb--,r(),z(e,t)}function M(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function U(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),s=t.corkedRequestsFree;s.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,P(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,h=n.callback;if(P(e,t,!1,t.objectMode?1:l.length,l,u,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function L(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function D(e,t){e._final((function(n){t.pendingcb--,n&&S(e,n),t.prefinished=!0,e.emit("prefinish"),z(e,t)}))}function q(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(D,e,t)))}function z(e,t){var n=L(t);if(n&&(q(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function $(e,t,r){t.ending=!0,z(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function H(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}e("inherits")(T,a),A.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(A.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===T&&e&&e._writableState instanceof A}})):f=function(e){return e instanceof this},T.prototype.pipe=function(){S(this,new b)},T.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=u(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=E),r.ending?x(this,n):(i||I(this,r,e,n))&&(r.pendingcb++,o=R(this,r,i,e,t,n)),o},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||U(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new k(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,n){n(new y("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||$(this,r,n),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=p.destroy,T.prototype._undestroy=p.undestroy,T.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==de?de:"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(e,t,n){(function(n){(function(){var r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),h=Symbol("handlePromise"),f=Symbol("stream");function p(e,t){return{value:e,done:t}}function d(e){var t=e[s];if(null!==t){var n=e[f].read();null!==n&&(e[u]=null,e[s]=null,e[a]=null,t(p(n,!1)))}}function m(e){n.nextTick(d,e)}function g(e,t){return function(n,r){e.then((function(){t[l]?n(p(void 0,!0)):t[h](n,r)}),r)}}var y=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(r={get stream(){return this[f]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(p(void 0,!0));if(this[f].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[c]?r(e[c]):t(p(void 0,!0))}))}));var r,o=this[u];if(o)r=new Promise(g(o,this));else{var i=this[f].read();if(null!==i)return Promise.resolve(p(i,!1));r=new Promise(this[h])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var e=this;return new Promise((function(t,n){e[f].destroy(null,(function(e){e?n(e):t(p(void 0,!0))}))}))})),r),y),b=function(e){var t,n=Object.create(v,(o(t={},f,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var r=n[f].read();r?(n[u]=null,n[s]=null,n[a]=null,e(p(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[u]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[u]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var r=n[s];null!==r&&(n[u]=null,n[s]=null,n[a]=null,r(p(void 0,!0))),n[l]=!0})),e.on("readable",m.bind(null,n)),n};t.exports=b}).call(this)}).call(this,e("_process"))},{"./end-of-stream":64,_process:50}],62:[function(e,t,n){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}var l=e("buffer").Buffer,u=e("util").inspect,h=u&&u.custom||"inspect";function f(e,t,n){l.prototype.copy.call(e,t,n)}t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return l.alloc(0);for(var t=l.allocUnsafe(e>>>0),n=this.head,r=0;n;)f(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?r+=o:r+=o.slice(0,e),0==(e-=i)){i===o.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=l.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(i));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return u(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:17,util:16}],63:[function(e,t,n){(function(e){(function(){function n(t,n){var i=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(n?n(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!n&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(o,i):(i._writableState.errorEmitted=!0,e.nextTick(r,i,t)):e.nextTick(r,i,t):n?(e.nextTick(o,i),n(t)):e.nextTick(o,i)})),this)}function r(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i(){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(e,t){e.emit("error",t)}function a(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:n,undestroy:i,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:50}],64:[function(e,t,n){var r=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function o(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];e.apply(this,r)}}}function i(){}function s(e){return e.setHeader&&"function"==typeof e.abort}function a(e,t,n){if("function"==typeof t)return a(e,null,t);t||(t={}),n=o(n||i);var c=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,u=function(){e.writable||f()},h=e._writableState&&e._writableState.finished,f=function(){l=!1,h=!0,c||n.call(e)},p=e._readableState&&e._readableState.endEmitted,d=function(){c=!1,p=!0,l||n.call(e)},m=function(t){n.call(e,t)},g=function(){var t;return c&&!p?(e._readableState&&e._readableState.ended||(t=new r),n.call(e,t)):l&&!h?(e._writableState&&e._writableState.ended||(t=new r),n.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return s(e)?(e.on("complete",f),e.on("abort",g),e.req?y():e.on("request",y)):l&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",d),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",f),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",d),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":55}],65:[function(e,t,n){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(e,t,n){var r;function o(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=e("../../../errors").codes,s=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function c(e){if(e)throw e}function l(e){return e.setHeader&&"function"==typeof e.abort}function u(t,n,i,s){s=o(s);var c=!1;t.on("close",(function(){c=!0})),void 0===r&&(r=e("./end-of-stream")),r(t,{readable:n,writable:i},(function(e){if(e)return s(e);c=!0,s()}));var u=!1;return function(e){if(!c&&!u)return u=!0,l(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function f(e,t){return e.pipe(t)}function p(e){return e.length?"function"!=typeof e[e.length-1]?c:e.pop():c}function d(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=p(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new s("streams");var i=t.map((function(e,n){var s=n<t.length-1;return u(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(h),s||(i.forEach(h),o(r))}))}));return t.reduce(f)}t.exports=d},{"../../../errors":55,"./end-of-stream":64}],67:[function(e,t,n){var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function o(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}function i(e,t,n,i){var s=o(t,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}},{"../../../errors":55}],68:[function(e,t,n){t.exports=e("events").EventEmitter},{events:22}],69:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./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(e,t,n){function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}function o(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new r(arguments[0],arguments[1],e)}t.exports=o},{}],71:[function(e,t,n){t.exports=e("./index.js")()},{"./index.js":72}],72:[function(e,t,n){(function(e){(function(){function n(t){return t instanceof e?e.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function r(e){return(e=e||{}).circles?o(e):e.proto?i:r;function t(e,t){for(var r=Object.keys(e),o=new Array(r.length),i=0;i<r.length;i++){var s=r[i],a=e[s];"object"!=typeof a||null===a?o[s]=a:a instanceof Date?o[s]=new Date(a):ArrayBuffer.isView(a)?o[s]=n(a):o[s]=t(a)}return o}function r(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,r);if(e instanceof Map)return new Map(t(Array.from(e),r));if(e instanceof Set)return new Set(t(Array.from(e),r));var o={};for(var i in e)if(!1!==Object.hasOwnProperty.call(e,i)){var s=e[i];"object"!=typeof s||null===s?o[i]=s:s instanceof Date?o[i]=new Date(s):s instanceof Map?o[i]=new Map(t(Array.from(s),r)):s instanceof Set?o[i]=new Set(t(Array.from(s),r)):ArrayBuffer.isView(s)?o[i]=n(s):o[i]=r(s)}return o}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,i);if(e instanceof Map)return new Map(t(Array.from(e),i));if(e instanceof Set)return new Set(t(Array.from(e),i));var r={};for(var o in e){var s=e[o];"object"!=typeof s||null===s?r[o]=s:s instanceof Date?r[o]=new Date(s):s instanceof Map?r[o]=new Map(t(Array.from(s),i)):s instanceof Set?r[o]=new Set(t(Array.from(s),i)):ArrayBuffer.isView(s)?r[o]=n(s):r[o]=i(s)}return r}}function o(e){var t=[],r=[];return e.proto?s:i;function o(e,o){for(var i=Object.keys(e),s=new Array(i.length),a=0;a<i.length;a++){var c=i[a],l=e[c];if("object"!=typeof l||null===l)s[c]=l;else if(l instanceof Date)s[c]=new Date(l);else if(ArrayBuffer.isView(l))s[c]=n(l);else{var u=t.indexOf(l);s[c]=-1!==u?r[u]:o(l)}}return s}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,i);if(e instanceof Map)return new Map(o(Array.from(e),i));if(e instanceof Set)return new Set(o(Array.from(e),i));var s={};for(var a in t.push(e),r.push(s),e)if(!1!==Object.hasOwnProperty.call(e,a)){var c=e[a];if("object"!=typeof c||null===c)s[a]=c;else if(c instanceof Date)s[a]=new Date(c);else if(c instanceof Map)s[a]=new Map(o(Array.from(c),i));else if(c instanceof Set)s[a]=new Set(o(Array.from(c),i));else if(ArrayBuffer.isView(c))s[a]=n(c);else{var l=t.indexOf(c);s[a]=-1!==l?r[l]:i(c)}}return t.pop(),r.pop(),s}function s(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,s);if(e instanceof Map)return new Map(o(Array.from(e),s));if(e instanceof Set)return new Set(o(Array.from(e),s));var i={};for(var a in t.push(e),r.push(i),e){var c=e[a];if("object"!=typeof c||null===c)i[a]=c;else if(c instanceof Date)i[a]=new Date(c);else if(c instanceof Map)i[a]=new Map(o(Array.from(c),s));else if(c instanceof Set)i[a]=new Set(o(Array.from(c),s));else if(ArrayBuffer.isView(c))i[a]=n(c);else{var l=t.indexOf(c);i[a]=-1!==l?r[l]:s(c)}}return t.pop(),r.pop(),i}}t.exports=r}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],73:[function(e,t,n){
|
|
4
|
+
r.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,c=(1<<a)-1,l=c>>1,u=-7,h=r?o-1:0,f=r?-1:1,d=e[t+h];for(h+=f,i=d&(1<<-u)-1,d>>=-u,u+=a;u>0;i=256*i+e[t+h],h+=f,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=n;u>0;s=256*s+e[t+h],h+=f,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),i-=l}return(d?-1:1)*s*Math.pow(2,i-n)},r.write=function(e,t,r,n,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,p=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[r+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;e[r+d]=255&s,d+=p,s/=256,l-=8);e[r+d-p]|=128*m}},{}],24:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],25:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){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=e,this.value=t}return e.prototype.rotateLeft=function(){var e=this.parent,t=this.brother,r=this.leftChild,n=this.rightChild;if(!n)throw new Error("unknown error");var o=n.leftChild,i=n.rightChild;return e&&(e.leftChild===this?e.leftChild=n:e.rightChild===this&&(e.rightChild=n)),n.parent=e,n.brother=t,n.leftChild=this,n.rightChild=i,t&&(t.brother=n),this.parent=n,this.brother=i,this.leftChild=r,this.rightChild=o,i&&(i.parent=n,i.brother=this),r&&(r.parent=this,r.brother=o),o&&(o.parent=this,o.brother=r),n},e.prototype.rotateRight=function(){var e=this.parent,t=this.brother,r=this.leftChild;if(!r)throw new Error("unknown error");var n=this.rightChild,o=r.leftChild,i=r.rightChild;return e&&(e.leftChild===this?e.leftChild=r:e.rightChild===this&&(e.rightChild=r)),r.parent=e,r.brother=t,r.leftChild=o,r.rightChild=this,t&&(t.brother=r),o&&(o.parent=r,o.brother=this),this.parent=r,this.brother=o,this.leftChild=i,this.rightChild=n,i&&(i.parent=this,i.brother=n),n&&(n.parent=this,n.brother=i),r},e.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},e.TreeNodeColorType={red:!0,black:!1},e}();Object.freeze(n),r.default=n},{}],26:[function(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};function o(e){var t=this;void 0===e&&(e=[]);var r=[],i=0,s=0,a=0,c=0,l=0,u=0;this.size=function(){return u},this.empty=function(){return 0===u},this.clear=function(){i=a=s=c=l=u=0,f.call(this,o.bucketSize),u=0},this.front=function(){return r[i][s]},this.back=function(){return r[a][c]},this.forEach=function(e){if(!this.empty()){var t=0;if(i!==a){for(l=s;l<o.bucketSize;++l)e(r[i][l],t++);for(l=i+1;l<a;++l)for(var n=0;n<o.bucketSize;++n)e(r[l][n],t++);for(l=0;l<=c;++l)e(r[a][l],t++)}else for(var l=s;l<=c;++l)e(r[i][l],t++)}};var h=function(e){var t=i*o.bucketSize+s,r=t+e,n=a*o.bucketSize+c;if(r<t||r>n)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(r/o.bucketSize),curNodePointerIndex:r%o.bucketSize}};this.getElementByPos=function(e){var t=h(e),n=t.curNodeBucketIndex,o=t.curNodePointerIndex;return r[n][o]},this.eraseElementByPos=function(e){var t=this;if(e<0||e>u)throw new Error("pos should more than 0 and less than queue's size");if(0===e)this.popFront();else if(e===this.size())this.popBack();else{for(var r=[],n=e+1;n<u;++n)r.push(this.getElementByPos(n));this.cut(e),this.popBack(),r.forEach((function(e){return t.pushBack(e)}))}},this.eraseElementByValue=function(e){if(!this.empty()){var t=[];this.forEach((function(r){r!==e&&t.push(r)}));for(var r=t.length,n=0;n<r;++n)this.setElementByPos(n,t[n]);this.cut(r-1)}};var f=function(e){for(var t=[],n=e*o.sigma,h=Math.max(Math.ceil(n/o.bucketSize),2),f=0;f<h;++f)t.push(new Array(o.bucketSize));var d=Math.ceil(e/o.bucketSize),p=Math.floor(h/2)-Math.floor(d/2),m=p,g=0;if(this.size())for(f=0;f<d;++f){for(var y=0;y<o.bucketSize;++y)if(t[p+f][y]=this.front(),this.popFront(),this.empty()){m=p+f,g=y;break}if(this.empty())break}r=t,i=p,s=0,a=m,c=g,l=h,u=e};this.pushBack=function(e){this.empty()||(a===l-1&&c===o.bucketSize-1&&f.call(this,this.size()),c<o.bucketSize-1?++c:a<l-1&&(++a,c=0)),++u,r[a][c]=e},this.popBack=function(){this.empty()||(1!==this.size()&&(c>0?--c:i<a&&(--a,c=o.bucketSize-1)),u>0&&--u)},this.setElementByPos=function(e,t){var n=h(e),o=n.curNodeBucketIndex,i=n.curNodePointerIndex;r[o][i]=t},this.insert=function(e,t,r){var n=this;if(void 0===r&&(r=1),0===e)for(;r--;)this.pushFront(t);else if(e===this.size())for(;r--;)this.pushBack(t);else{for(var o=[],i=e;i<u;++i)o.push(this.getElementByPos(i));for(this.cut(e-1),i=0;i<r;++i)this.pushBack(t);o.forEach((function(e){return n.pushBack(e)}))}},this.find=function(e){if(i===a){for(var t=s;t<=c;++t)if(r[i][t]===e)return!0;return!1}for(t=s;t<o.bucketSize;++t)if(r[i][t]===e)return!0;for(t=i+1;t<a;++t)for(var n=0;n<o.bucketSize;++n)if(r[t][n]===e)return!0;for(t=0;t<=c;++t)if(r[a][t]===e)return!0;return!1},this.reverse=function(){for(var e=0,t=u-1;e<t;){var r=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,r),++e,--t}},this.unique=function(){if(!this.empty()){var e=[],t=this.front();this.forEach((function(r,n){0!==n&&r===t||(e.push(r),t=r)}));for(var r=0;r<u;++r)this.setElementByPos(r,e[r]);this.cut(e.length-1)}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);for(var r=0;r<u;++r)this.setElementByPos(r,t[r])},this.pushFront=function(e){this.empty()||(0===i&&0===s&&f.call(this,this.size()),s>0?--s:i>0&&(--i,s=o.bucketSize-1)),++u,r[i][s]=e},this.popFront=function(){this.empty()||(1!==this.size()&&(s<o.bucketSize-1?++s:i<a&&(++i,s=0)),u>0&&--u)},this.shrinkToFit=function(){var e=this,t=[];this.forEach((function(e){t.push(e)}));var n=t.length;r=[];for(var i=Math.ceil(n/o.bucketSize),s=0;s<i;++s)r.push(new Array(o.bucketSize));this.clear(),t.forEach((function(t){return e.pushBack(t)}))},this.cut=function(e){if(e<0)this.clear();else{var t=h(e),r=t.curNodeBucketIndex,n=t.curNodePointerIndex;a=r,c=n,u=e+1}},this[Symbol.iterator]=function(){return function(){var e,t;return n(this,(function(n){switch(n.label){case 0:if(0===u)return[2];if(i!==a)return[3,5];t=s,n.label=1;case 1:return t<=c?[4,r[i][t]]:[3,4];case 2:n.sent(),n.label=3;case 3:return++t,[3,1];case 4:return[2];case 5:t=s,n.label=6;case 6:return t<o.bucketSize?[4,r[i][t]]:[3,9];case 7:n.sent(),n.label=8;case 8:return++t,[3,6];case 9:t=i+1,n.label=10;case 10:if(!(t<a))return[3,15];e=0,n.label=11;case 11:return e<o.bucketSize?[4,r[t][e]]:[3,14];case 12:n.sent(),n.label=13;case 13:return++e,[3,11];case 14:return++t,[3,10];case 15:t=0,n.label=16;case 16:return t<=c?[4,r[a][t]]:[3,19];case 17:n.sent(),n.label=18;case 18:return++t,[3,16];case 19:return[2]}}))}()},function(){var n=o.bucketSize;e.size?n=e.size():e.length&&(n=e.length);var s=n*o.sigma;l=Math.ceil(s/o.bucketSize),l=Math.max(l,3);for(var c=0;c<l;++c)r.push(new Array(o.bucketSize));var u=Math.ceil(n/o.bucketSize);i=Math.floor(l/2)-Math.floor(u/2),a=i,e.forEach((function(e){return t.pushBack(e)}))}(),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),o.sigma=3,o.bucketSize=5e3,Object.freeze(o),r.default=o},{}],27:[function(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var i=e("../LinkList/LinkList"),s=e("../Map/Map");function a(e,t,r){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),r=r||function(e){var t,r,n=0,i="";if("number"==typeof e)n=((n=Math.floor(e))<<5)-n,n&=n;else{i="string"!=typeof e?JSON.stringify(e):e;try{for(var s=o(i),a=s.next();!a.done;a=s.next())n=(n<<5)-n+a.value.charCodeAt(0),n&=n}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}return n^=n>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(r){r.forEach((function(r){e(r,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(n,o){if(!n.empty()){if(n instanceof i.default&&1===n.size()){var c=n.front(),l=c.key,f=c.value;t[r(l)&h-1]=new i.default([{key:l,value:f}])}else if(n instanceof s.default){var d=new i.default,p=new i.default;n.forEach((function(t){0==(r(t.key)&e)?d.pushBack(t):p.pushBack(t)})),d.size()>a.untreeifyThreshold?t[o]=new s.default(d):d.size()&&(t[o]=d),p.size()>a.untreeifyThreshold?t[o+e]=new s.default(p):p.size()&&(t[o+e]=p)}else{var m=new i.default,g=new i.default;n.forEach((function(t){0==(r(t.key)&e)?m.pushBack(t):g.pushBack(t)})),m.size()&&(t[o]=m),g.size()&&(t[o+e]=g)}u[o].clear()}})),u=t}};this.setElement=function(e,t){var n,c;if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=t){var d=r(e)&h-1;if(u[d]){var p=u[d].size();if(u[d]instanceof i.default){try{for(var m=o(u[d]),g=m.next();!g.done;g=m.next()){var y=g.value;if(y.key===e)return void(y.value=t)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(c=m.return)&&c.call(m)}finally{if(n)throw n.error}}u[d].pushBack({key:e,value:t}),u[d].size()>=a.treeifyThreshold&&(u[d]=new s.default(u[d]))}else u[d].setElement(e,t);var v=u[d].size();l+=v-p}else++l,u[d]=new i.default([{key:e,value:t}]);l>h*a.sigma&&f.call(this,h)}else this.eraseElementByKey(e)},this.getElementByKey=function(e){var t,n,i=r(e)&h-1;if(u[i]){if(u[i]instanceof s.default)return u[i].getElementByKey(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next()){var l=c.value;if(l.key===e)return l.value}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}}},this.eraseElementByKey=function(e){var t,n,c=r(e)&h-1;if(u[c]){var f=u[c].size();if(u[c]instanceof s.default)u[c].eraseElementByKey(e),u[c].size()<=a.untreeifyThreshold&&(u[c]=new i.default(u[c]));else{var d=-1;try{for(var p=o(u[c]),m=p.next();!m.done;m=p.next()){var g=m.value;if(++d,g.key===e){u[c].eraseElementByPos(d);break}}}catch(e){t={error:e}}finally{try{m&&!m.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}}var y=u[c].size();l+=y-f}},this.find=function(e){var t,n,i=r(e)&h-1;if(!u[i])return!1;if(u[i]instanceof s.default)return u[i].find(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next())if(c.value.key===e)return!0}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!1},this[Symbol.iterator]=function(){return function(){var e,t,r,i,s,a;return n(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];n.label=2;case 2:n.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),r=t.next(),n.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:n.sent(),n.label=5;case 5:return r=t.next(),[3,3];case 6:return[3,9];case 7:return i=n.sent(),s={error:i},[3,9];case 8:try{r&&!r.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){var t=e.key,r=e.value;return c.setElement(t,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(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var i=e("../Set/Set"),s=e("../LinkList/LinkList");function a(e,t,r){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),r=r||function(e){var t=0,r="";if("number"==typeof e)t=((t=Math.floor(e))<<5)-t,t&=t;else{r="string"!=typeof e?JSON.stringify(e):e;for(var n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n),t&=t}return t^=t>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(r){r.forEach((function(r){e(r,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(n,o){if(!n.empty()){if(n instanceof s.default&&1===n.size()){var c=n.front();if(void 0===c)throw new Error("unknown error");t[r(c)&h-1]=new s.default([c])}else if(n instanceof i.default){var l=new s.default,f=new s.default;n.forEach((function(t){0==(r(t)&e)?l.pushBack(t):f.pushBack(t)})),l.size()>a.untreeifyThreshold?t[o]=new i.default(l):l.size()&&(t[o]=l),f.size()>a.untreeifyThreshold?t[o+e]=new i.default(f):f.size()&&(t[o+e]=f)}else{var d=new s.default,p=new s.default;n.forEach((function(t){0==(r(t)&e)?d.pushBack(t):p.pushBack(t)})),d.size()&&(t[o]=d),p.size()&&(t[o+e]=p)}u[o].clear()}})),u=t}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var t=r(e)&h-1;if(u[t]){var n=u[t].size();if(u[t]instanceof s.default){if(u[t].find(e))return;u[t].pushBack(e),u[t].size()>=a.treeifyThreshold&&(u[t]=new i.default(u[t]))}else u[t].insert(e);var o=u[t].size();l+=o-n}else u[t]=new s.default([e]),++l;l>h*a.sigma&&f.call(this,h)},this.eraseElementByValue=function(e){var t=r(e)&h-1;if(u[t]){var n=u[t].size();u[t].eraseElementByValue(e),u[t]instanceof i.default&&u[t].size()<=a.untreeifyThreshold&&(u[t]=new s.default(u[t]));var o=u[t].size();l+=o-n}},this.find=function(e){var t=r(e)&h-1;return!!u[t]&&u[t].find(e)},this[Symbol.iterator]=function(){return function(){var e,t,r,i,s,a;return n(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];n.label=2;case 2:n.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),r=t.next(),n.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:n.sent(),n.label=5;case 5:return r=t.next(),[3,3];case 6:return[3,9];case 7:return i=n.sent(),s={error:i},[3,9];case 8:try{r&&!r.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){return c.insert(e)})),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(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e}return e}();function i(e){var t=this;void 0===e&&(e=[]);var r=0,i=void 0,s=void 0;this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){i=s=void 0,r=0},this.front=function(){return null==i?void 0:i.value},this.back=function(){return null==s?void 0:s.value},this.forEach=function(e){for(var t=i,r=0;t;){if(void 0===t.value)throw new Error("unknown error");e(t.value,r++),t=t.next}},this.getElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var t=i;e--&&t;)t=t.next;if(!t||void 0===t.value)throw new Error("unknown error");return t.value},this.eraseElementByPos=function(e){if(e<0||e>=r)throw new Error("erase pos must more then 0 and less then the list length");if(0===e)this.popFront();else if(e===r-1)this.popBack();else{for(var t=i;e--;){if(!(null==t?void 0:t.next))throw new Error("unknown error");t=t.next}if(!t||!t.pre||!t.next)throw new Error("unknown error");var n=t.pre,o=t.next;o.pre=n,n.next=o,r>0&&--r}},this.eraseElementByValue=function(e){for(;i&&i.value===e;)this.popFront();for(;s&&s.value===e;)this.popBack();if(i)for(var t=i;t;){if(t.value===e){var n=t.pre,o=t.next;o&&(o.pre=n),n&&(n.next=o),r>0&&--r}t=t.next}},this.pushBack=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new o(e);s?(s.next=t,t.pre=s,s=t):i=s=t},this.popBack=function(){s&&(r>0&&--r,s&&(i===s?i=s=void 0:(s=s.pre)&&(s.next=void 0)))},this.setElementByPos=function(e,t){if(null==t)throw new Error("you can't set null or undefined here");if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var n=i;e--;){if(!n)throw new Error("unknown error");n=n.next}n&&(n.value=t)},this.insert=function(e,t,n){if(void 0===n&&(n=1),null==t)throw new Error("you can't insert null or undefined here");if(e<0||e>r)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(n<0)throw new Error("insert size must more than 0");if(0===e)for(;n--;)this.pushFront(t);else if(e===r)for(;n--;)this.pushBack(t);else{for(var s=i,a=1;a<e;++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 c=s.next;for(r+=n;n--;)s.next=new o(t),s.next.pre=s,s=s.next;s.next=c,c&&(c.pre=s)}},this.find=function(e){for(var t=i;t;){if(t.value===e)return!0;t=t.next}return!1},this.reverse=function(){for(var e=i,t=s,n=0;e&&t&&2*n<r;){var o=e.value;e.value=t.value,t.value=o,e=e.next,t=t.pre,++n}},this.unique=function(){for(var e=i;e;){for(var t=e;t&&t.next&&t.value===t.next.value;)t=t.next,r>0&&--r;e.next=t.next,e.next&&(e.next.pre=e),e=e.next}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);var r=i;t.forEach((function(e){r&&(r.value=e,r=r.next)}))},this.pushFront=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new o(e);i?(t.next=i,i.pre=t,i=t):i=s=t},this.popFront=function(){i&&(r>0&&--r,i&&(i===s?i=s=void 0:(i=i.next)&&(i.pre=void 0)))},this.merge=function(e){var t=this,n=i;e.forEach((function(e){for(;n&&void 0!==n.value&&n.value<=e;)n=n.next;if(void 0===n)t.pushBack(e),n=s;else if(n===i)t.pushFront(e),n=i;else{++r;var a=n.pre;a&&(a.next=new o(e),a.next.pre=a,a.next.next=n,n&&(n.pre=a.next))}}))},this[Symbol.iterator]=function(){return function(){var e;return n(this,(function(t){switch(t.label){case 0:e=i,t.label=1;case 1:if(void 0===e)return[3,3];if(!e.value)throw new Error("unknown error");return[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.freeze(i),r.default=i},{}],30:[function(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.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 c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty()){var e=c(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.back=function(){if(!this.empty()){var e=l(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.forEach=function(e){var t,r,n=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,n++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var n=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(n===e)return a;++n}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}throw new Error("unknown Error")};var u=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var n=t(e.key,r);return 0===n?{key:e.key,value:e.value}:n<0?u(e.rightChild,r):u(e.leftChild,r)||{key:e.key,value:e.value}}};this.lowerBound=function(e){return u(a,e)};var h=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)<=0?h(e.rightChild,r):h(e.leftChild,r)||{key:e.key,value:e.value}};this.upperBound=function(e){return h(a,e)};var f=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var n=t(e.key,r);return 0===n?{key:e.key,value:e.value}:n>0?f(e.leftChild,r):f(e.rightChild,r)||{key:e.key,value:e.value}}};this.reverseLowerBound=function(e){return f(a,e)};var d=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)>=0?d(e.leftChild,r):d(e.rightChild,r)||{key:e.key,value:e.value}};this.reverseUpperBound=function(e){return d(a,e)};var p=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild)if(r.color===i.default.TreeNodeColorType.red){r.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var n=t.rotateLeft();a===t&&(a=n),p(e)}else r.color===i.default.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===i.default.TreeNodeColorType.red?(r.color=t.color,t.color=i.default.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=i.default.TreeNodeColorType.black),n=t.rotateLeft(),a===t&&(a=n),e.color=i.default.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==i.default.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==i.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==i.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==i.default.TreeNodeColorType.black||(r.color=i.default.TreeNodeColorType.red,p(t)):(r.color=i.default.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=i.default.TreeNodeColorType.black),n=r.rotateRight(),a===r&&(a=n),p(e)));else e===t.rightChild&&(r.color===i.default.TreeNodeColorType.red?(r.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,n=t.rotateRight(),a===t&&(a=n),p(e)):r.color===i.default.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===i.default.TreeNodeColorType.red?(r.color=t.color,t.color=i.default.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=i.default.TreeNodeColorType.black),n=t.rotateRight(),a===t&&(a=n),e.color=i.default.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==i.default.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==i.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==i.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==i.default.TreeNodeColorType.black||(r.color=i.default.TreeNodeColorType.red,p(t)):(r.color=i.default.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=i.default.TreeNodeColorType.black),n=r.rotateLeft(),a===r&&(a=n),p(e))))}else e.color=i.default.TreeNodeColorType.black},m=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var r=e.key;e.key=t.key,t.key=r;var n=e.value;e.value=t.value,t.value=n,e=t}t.leftChild&&(t=l(t.leftChild),r=e.key,e.key=t.key,t.key=r,n=e.value,e.value=t.value,t.value=n,e=t)}p(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},g=function(e,t){return!(!e||void 0===e.key)&&(!!g(e.leftChild,t)||!!t(e)||g(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;g(a,(function(r){return e===t?(m(r),!0):(++t,!1)}))},this.eraseElementByKey=function(e){if(!this.empty()){var r=b(a,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&m(r)}};var y=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var n=t(r,e.key);return n<0?e.leftChild?y(e.leftChild,r):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):n>0?e.rightChild?y(e.rightChild,r):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},v=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var r=t.brother,n=t.parent;if(!n)throw new Error("unknown error");if(r&&r.color===i.default.TreeNodeColorType.red)r.color=t.color=i.default.TreeNodeColorType.black,n.color=i.default.TreeNodeColorType.red,v(n);else if(!r||r.color===i.default.TreeNodeColorType.black)if(t===n.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,n.color=i.default.TreeNodeColorType.red;var o=n.rotateRight();n===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),n===a&&(a=o),v(t));else t===n.rightChild&&(e===t.leftChild?(o=t.rotateRight(),n===a&&(a=o),v(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,n.color=i.default.TreeNodeColorType.red,o=n.rotateLeft(),n===a&&(a=o)))}};this.setElement=function(e,r){if(null==e)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=e,a.value=r,void(a.color=i.default.TreeNodeColorType.black);var n=y(a,e);void 0===n.key||0!==t(n.key,e)?(++s,n.key=e,n.value=r,v(n),a.color=i.default.TreeNodeColorType.black):n.value=r}else this.eraseElementByKey(e)};var b=function(e,r){if(e&&void 0!==e.key){var n=t(r,e.key);return n<0?b(e.leftChild,r):n>0?b(e.rightChild,r):e}};this.find=function(e){return!!b(a,e)},this.getElementByKey=function(e){var t=b(a,e);if(void 0===(null==t?void 0:t.key)||void 0===(null==t?void 0:t.value))throw new Error("unknown error");return t.value},this.union=function(e){var t=this;e.forEach((function(e){var r=e.key,n=e.value;return t.setElement(r,n)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return n(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key&&void 0!==e.value?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,{key:e.key,value:e.value}];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){var t=e.key,n=e.value;return r.setElement(t,n)})),Object.freeze(this)}Object.freeze(s),r.default=s},{"../Base/TreeNode":25}],31:[function(e,t,r){function n(e,t){void 0===e&&(e=[]),t=t||function(e,t){return e>t?-1:e<t?1:0};var r=[];e.forEach((function(e){return r.push(e)}));var n=r.length,o=function(e,t){if(e<0||e>=n)throw new Error("unknown error");if(t<0||t>=n)throw new Error("unknown error");var o=r[e];r[e]=r[t],r[t]=o},i=function(e){if(e<0||e>=n)throw new Error("unknown error");var i=2*e+1,s=2*e+2;i<n&&t(r[e],r[i])>0&&o(e,i),s<n&&t(r[e],r[s])>0&&o(e,s)};!function(){for(var e=Math.floor((n-1)/2);e>=0;--e)for(var i=e,s=2*i+1;s<n;){var a=s+1,c=s;if(a<n&&t(r[s],r[a])>0&&(c=a),t(r[i],r[c])<=0)break;o(i,c),s=2*(i=c)+1}}(),this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,r.length=0},this.push=function(e){if(r.push(e),1!=++n)for(var o=n-1;o>0;){var s=Math.floor((o-1)/2);if(t(r[s],e)<=0)break;i(s),o=s}},this.pop=function(){if(!this.empty())if(1!==this.size()){var e=r[n-1];--n;for(var o=0;o<this.size();){var i=2*o+1,s=2*o+2;if(i>=this.size())break;var a=i;if(s<this.size()&&t(r[i],r[s])>0&&(a=s),t(r[a],e)>=0)break;r[o]=r[a],o=a}r[o]=e}else--n},this.top=function(){return r[0]},Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(n),r.default=n},{}],32:[function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("../LinkList/LinkList");function o(e){void 0===e&&(e=[]);var t=new n.default(e);this.size=function(){return t.size()},this.empty=function(){return t.empty()},this.clear=function(){t.clear()},this.push=function(e){t.pushBack(e)},this.pop=function(){t.popFront()},this.front=function(){return t.front()},Object.freeze(this)}Object.freeze(o),r.default=o},{"../LinkList/LinkList":29}],33:[function(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.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=i.default.TreeNodeColorType.black};var c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty())return c(a).key},this.back=function(){if(!this.empty())return l(a).key},this.forEach=function(e){var t,r,n=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,n++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var n=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(n===e)return a;++n}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}throw new Error("unknown error")};var u=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild)if(r.color===i.default.TreeNodeColorType.red){r.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var n=t.rotateLeft();a===t&&(a=n),u(e)}else r.color===i.default.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===i.default.TreeNodeColorType.red?(r.color=t.color,t.color=i.default.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=i.default.TreeNodeColorType.black),n=t.rotateLeft(),a===t&&(a=n),e.color=i.default.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==i.default.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==i.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==i.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==i.default.TreeNodeColorType.black||(r.color=i.default.TreeNodeColorType.red,u(t)):(r.color=i.default.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=i.default.TreeNodeColorType.black),n=r.rotateRight(),a===r&&(a=n),u(e)));else e===t.rightChild&&(r.color===i.default.TreeNodeColorType.red?(r.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,n=t.rotateRight(),a===t&&(a=n),u(e)):r.color===i.default.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===i.default.TreeNodeColorType.red?(r.color=t.color,t.color=i.default.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=i.default.TreeNodeColorType.black),n=t.rotateRight(),a===t&&(a=n),e.color=i.default.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==i.default.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==i.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==i.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==i.default.TreeNodeColorType.black||(r.color=i.default.TreeNodeColorType.red,u(t)):(r.color=i.default.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=i.default.TreeNodeColorType.black),n=r.rotateLeft(),a===r&&(a=n),u(e))))}else e.color=i.default.TreeNodeColorType.black},h=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var r=e.key;e.key=t.key,t.key=r,e=t}t.leftChild&&(t=l(t.leftChild),r=e.key,e.key=t.key,t.key=r,e=t)}u(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},f=function(e,t){return!(!e||void 0===e.key)&&(!!f(e.leftChild,t)||!!t(e)||f(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;f(a,(function(r){return e===t?(h(r),!0):(++t,!1)}))},this.eraseElementByValue=function(e){if(!this.empty()){var r=m(a,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&h(r)}};var d=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var n=t(r,e.key);return n<0?e.leftChild?d(e.leftChild,r):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):n>0?e.rightChild?d(e.rightChild,r):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},p=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var r=t.brother,n=t.parent;if(!n)throw new Error("unknown error");if(r&&r.color===i.default.TreeNodeColorType.red)r.color=t.color=i.default.TreeNodeColorType.black,n.color=i.default.TreeNodeColorType.red,p(n);else if(!r||r.color===i.default.TreeNodeColorType.black)if(t===n.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,n.color=i.default.TreeNodeColorType.red;var o=n.rotateRight();n===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),n===a&&(a=o),p(t));else t===n.rightChild&&(e===t.leftChild?(o=t.rotateRight(),n===a&&(a=o),p(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,n.color=i.default.TreeNodeColorType.red,o=n.rotateLeft(),n===a&&(a=o)))}};this.insert=function(e){if(null==e)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=e,void(a.color=i.default.TreeNodeColorType.black);var r=d(a,e);void 0!==r.key&&0===t(r.key,e)||(++s,r.key=e,p(r),a.color=i.default.TreeNodeColorType.black)};var m=function(e,r){if(e&&void 0!==e.key){var n=t(r,e.key);return n<0?m(e.leftChild,r):n>0?m(e.rightChild,r):e}};this.find=function(e){var r=m(a,e);return void 0!==r&&void 0!==r.key&&0===t(r.key,e)};var g=function(e,r){if(e&&void 0!==e.key){var n=t(e.key,r);if(0===n)return e.key;if(n<0)return g(e.rightChild,r);var o=g(e.leftChild,r);return void 0!==o?o:e.key}};this.lowerBound=function(e){return g(a,e)};var y=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)<=0)return y(e.rightChild,r);var n=y(e.leftChild,r);return void 0!==n?n:e.key}};this.upperBound=function(e){return y(a,e)};var v=function(e,r){if(e&&void 0!==e.key){var n=t(e.key,r);if(0===n)return e.key;if(n>0)return v(e.leftChild,r);var o=v(e.rightChild,r);return void 0!==o?o:e.key}};this.reverseLowerBound=function(e){return v(a,e)};var b=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)>=0)return b(e.leftChild,r);var n=b(e.rightChild,r);return void 0!==n?n:e.key}};this.reverseUpperBound=function(e){return b(a,e)},this.union=function(e){var t=this;e.forEach((function(e){return t.insert(e)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return n(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){return r.insert(e)})),Object.freeze(this)}Object.freeze(s),r.default=s},{"../Base/TreeNode":25}],34:[function(e,t,r){function n(e){var t=this;void 0===e&&(e=[]);var r=0,n=[];this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,n.length=0},this.push=function(e){n.push(e),++r},this.pop=function(){n.pop(),r>0&&--r},this.top=function(){return n[r-1]},e.forEach((function(e){return t.push(e)})),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(n),r.default=n},{}],35:[function(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function a(e){var t=this;void 0===e&&(e=[]);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(e){a.forEach(e)},this.getElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");return a[e]},this.eraseElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");for(var t=e;t<r-1;++t)a[t]=a[t+1];this.popBack()},this.eraseElementByValue=function(e){var t=[];this.forEach((function(r){r!==e&&t.push(r)})),t.forEach((function(e,t){a[t]=e}));for(var n=t.length;r>n;)this.popBack()},this.pushBack=function(e){a.push(e),++r},this.popBack=function(){a.pop(),r>0&&--r},this.setElementByPos=function(e,t){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");a[e]=t},this.insert=function(e,t,n){if(void 0===n&&(n=1),e<0||e>r)throw new Error("pos must more than 0 and less than or equal to vector's size");a.splice.apply(a,i([e,0],o(new Array(n).fill(t)),!1)),r+=n},this.find=function(e){return a.includes(e)},this.reverse=function(){a.reverse()},this.unique=function(){var e,t=[];this.forEach((function(r,n){0!==n&&r===e||(t.push(r),e=r)})),t.forEach((function(e,t){a[t]=e}));for(var n=t.length;r>n;)this.popBack()},this.sort=function(e){a.sort(e)},this[Symbol.iterator]=function(){return function(){return n(this,(function(e){switch(e.label){case 0:return[5,s(a)];case 1:return[2,e.sent()]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(a),r.default=a},{}],36:[function(e,t,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 n=e("./Vector/Vector");r.Vector=n.default;var o=e("./Stack/Stack");r.Stack=o.default;var i=e("./Queue/Queue");r.Queue=i.default;var s=e("./LinkList/LinkList");r.LinkList=s.default;var a=e("./Deque/Deque");r.Deque=a.default;var c=e("./PriorityQueue/PriorityQueue");r.PriorityQueue=c.default;var l=e("./Set/Set");r.Set=l.default;var u=e("./Map/Map");r.Map=u.default;var h=e("./HashSet/HashSet");r.HashSet=h.default;var f=e("./HashMap/HashMap");r.HashMap=f.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(e,t,r){const n=e("yallist"),o=Symbol("max"),i=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),c=Symbol("maxAge"),l=Symbol("dispose"),u=Symbol("noDisposeOnSet"),h=Symbol("lruList"),f=Symbol("cache"),d=Symbol("updateAgeOnGet"),p=()=>1;class m{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[o]=e.max||1/0;const t=e.length||p;if(this[s]="function"!=typeof t?p:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[c]=e.maxAge||0,this[l]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[d]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[o]=e||1/0,v(this)}get max(){return this[o]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[c]=e,v(this)}get maxAge(){return this[c]}set lengthCalculator(e){"function"!=typeof e&&(e=p),e!==this[s]&&(this[s]=e,this[i]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[i]+=e.length}))),v(this)}get lengthCalculator(){return this[s]}get length(){return this[i]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let r=this[h].tail;null!==r;){const n=r.prev;C(this,e,r,t),r=n}}forEach(e,t){t=t||this;for(let r=this[h].head;null!==r;){const n=r.next;C(this,e,r,t),r=n}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[l]&&this[h]&&this[h].length&&this[h].forEach((e=>this[l](e.key,e.value))),this[f]=new Map,this[h]=new n,this[i]=0}dump(){return this[h].map((e=>!y(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,r){if((r=r||this[c])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,a=this[s](t,e);if(this[f].has(e)){if(a>this[o])return b(this,this[f].get(e)),!1;const s=this[f].get(e).value;return this[l]&&(this[u]||this[l](e,s.value)),s.now=n,s.maxAge=r,s.value=t,this[i]+=a-s.length,s.length=a,this.get(e),v(this),!0}const d=new w(e,t,a,n,r);return d.length>this[o]?(this[l]&&this[l](e,t),!1):(this[i]+=d.length,this[h].unshift(d),this[f].set(e,this[h].head),v(this),!0)}has(e){if(!this[f].has(e))return!1;const t=this[f].get(e).value;return!y(this,t)}get(e){return g(this,e,!0)}peek(e){return g(this,e,!1)}pop(){const e=this[h].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[f].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const n=e[r],o=n.e||0;if(0===o)this.set(n.k,n.v);else{const e=o-t;e>0&&this.set(n.k,n.v,e)}}}prune(){this[f].forEach(((e,t)=>g(this,t,!1)))}}const g=(e,t,r)=>{const n=e[f].get(t);if(n){const t=n.value;if(y(e,t)){if(b(e,n),!e[a])return}else r&&(e[d]&&(n.value.now=Date.now()),e[h].unshiftNode(n));return t.value}},y=(e,t)=>{if(!t||!t.maxAge&&!e[c])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[c]&&r>e[c]},v=e=>{if(e[i]>e[o])for(let t=e[h].tail;e[i]>e[o]&&null!==t;){const r=t.prev;b(e,t),t=r}},b=(e,t)=>{if(t){const r=t.value;e[l]&&e[l](r.key,r.value),e[i]-=r.length,e[f].delete(r.key),e[h].removeNode(t)}};class w{constructor(e,t,r,n,o){this.key=e,this.value=t,this.length=r,this.now=n,this.maxAge=o||0}}const C=(e,t,r,n)=>{let o=r.value;y(e,o)&&(b(e,r),e[a]||(o=void 0)),o&&t.call(n,o.value,o.key,e)};t.exports=m},{yallist:83}],38:[function(e,t,r){(function(e){(function(){const r=t.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 e in r.types){const t=r.types[e];r.codes[t]=e}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=e.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=e.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=e.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 e in r.properties){const t=r.properties[e];r.propertiesCodes[t]=e}function n(t){return[0,1,2].map((n=>[0,1].map((o=>[0,1].map((i=>{const s=e.alloc(1);return s.writeUInt8(r.codes[t]<<r.CMD_SHIFT|(o?r.DUP_MASK:0)|n<<r.QOS_SHIFT|i,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=n("publish"),r.SUBSCRIBE_HEADER=n("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=n("unsubscribe"),r.ACKS={unsuback:n("unsuback"),puback:n("puback"),pubcomp:n("pubcomp"),pubrel:n("pubrel"),pubrec:n("pubrec")},r.SUBACK_HEADER=e.from([r.codes.suback<<r.CMD_SHIFT]),r.VERSION3=e.from([3]),r.VERSION4=e.from([4]),r.VERSION5=e.from([5]),r.VERSION131=e.from([131]),r.VERSION132=e.from([132]),r.QOS=[0,1,2].map((t=>e.from([t]))),r.EMPTY={pingreq:e.from([r.codes.pingreq<<4,0]),pingresp:e.from([r.codes.pingresp<<4,0]),disconnect:e.from([r.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],39:[function(e,t,r){(function(r){(function(){const n=e("./writeToStream"),o=e("events");function i(e,t){const r=new s;return n(e,r,t),r.concat()}class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),n=this._array;let o,i=0;for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?t[o]=n[o].length:t[o]=r.byteLength(n[o]),e+=t[o];const s=r.allocUnsafe(e);for(o=0;o<n.length&&void 0!==n[o];o++)"string"!=typeof n[o]?(n[o].copy(s,i),i+=t[o]):(s.write(n[o],i),i+=t[o]);return s}}t.exports=i}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(e,t,r){r.parser=e("./parser").parser,r.generate=e("./generate"),r.writeToStream=e("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(e,t,r){(function(e){(function(){const r=65536,n={},o=e.isBuffer(e.from([1,2]).subarray(0,1));function i(t){const r=e.allocUnsafe(2);return r.writeUInt8(t>>8,0),r.writeUInt8(255&t,1),r}function s(){for(let e=0;e<r;e++)n[e]=i(e)}function a(t){const r=4;let n=0,i=0;const s=e.allocUnsafe(r);do{n=t%128|0,(t=t/128|0)>0&&(n|=128),s.writeUInt8(n,i++)}while(t>0&&i<r);return t>0&&(i=0),o?s.subarray(0,i):s.slice(0,i)}function c(t){const r=e.allocUnsafe(4);return r.writeUInt32BE(t,0),r}t.exports={cache:n,generateCache:s,generateNumber:i,genBufVariableByteInt:a,generate4ByteBuffer:c}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],42:[function(e,t,r){class n{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=n},{}],43:[function(e,t,r){const n=e("bl"),o=e("events"),i=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=n(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),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 e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!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"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,n;a("_parseConnect");const o={},i=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.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(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.properties=e)}const l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(i.clientId=l,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=e,a("_parseConnect: packet.will.topic: %s",i.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(n=this._parseString(),null===n)return this._emitError(new Error("Cannot parse username"));i.username=n,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));i.password=r}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,n,o,i,c,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),n=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:n},5===this.settings.protocolVersion?(l.nl=c,l.rap=i,l.rh=o):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const n=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",n),n}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");const t=4;let r,n=0,o=1,i=0,c=!1;const l=this._pos?this._pos:0;for(;n<t&&l+n<this._list.length;){if(r=this._list.readUInt8(l+n++),i+=o*(r&s.VARBYTEINT_MASK),o*=128,0==(r&s.VARBYTEINT_FIN_MASK)){c=!0;break}if(this._list.length<=n)break}return!c&&n===t&&this._list.length>=n&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=n),c=!!c&&(e?{bytes:n,value:i}:i),a("_parseVarByteNum: result: %o",c),c}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){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 e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t]);else{r[t]||(r[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else{const n=r[t][e.name];r[t][e.name]=[n],r[t][e.name].push(e.value)}else r[t][e.name]=e.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 i,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}t.exports=c},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(e,t,r){(function(r){(function(){const n=e("./constants"),o=r.allocUnsafe(0),i=r.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,c=e("debug")("mqtt-packet:writeToStream"),l=s.cache,u=s.generateNumber,h=s.generateCache,f=s.genBufVariableByteInt,d=s.generate4ByteBuffer;let p=B,m=!0;function g(e,t,r){switch(c("generate called"),t.cork&&(t.cork(),a(y,t)),m&&(m=!1,h()),c("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return v(e,t);case"connack":return b(e,t,r);case"publish":return w(e,t,r);case"puback":case"pubrec":case"pubrel":case"pubcomp":return C(e,t,r);case"subscribe":return _(e,t,r);case"suback":return k(e,t,r);case"unsubscribe":return S(e,t,r);case"unsuback":return E(e,t,r);case"pingreq":case"pingresp":return A(e,t);case"disconnect":return T(e,t,r);case"auth":return x(e,t,r);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}function v(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let l=i.clean;const u=i.keepalive||0,h=i.clientId||"",f=i.username,d=i.password,m=i.properties;void 0===l&&(l=!0);let g=0;if(!s||"string"!=typeof s&&!r.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof h||r.isBuffer(h))&&(h||a>=4)&&(h||l))g+=r.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*l==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=M(t,m);if(!y)return!1;g+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(g+=r.byteLength(c.topic)+2,g+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?g+=r.byteLength(c.payload):g+=c.payload.length}var v={};if(5===a){if(!(v=M(t,c.properties)))return!1;g+=v.length}}let b=!1;if(null!=f){if(!z(f))return t.emit("error",new Error("Invalid username")),!1;b=!0,g+=r.byteLength(f)+2}if(null!=d){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!z(d))return t.emit("error",new Error("Invalid password")),!1;g+=q(d)+2}t.write(n.CONNECT_HEADER),O(t,g),F(t,s),i.bridgeMode&&(a+=128),t.write(131===a?n.VERSION131:132===a?n.VERSION132:4===a?n.VERSION4:5===a?n.VERSION5:n.VERSION3);let w=0;return w|=null!=f?n.USERNAME_MASK:0,w|=null!=d?n.PASSWORD_MASK:0,w|=c&&c.retain?n.WILL_RETAIN_MASK:0,w|=c&&c.qos?c.qos<<n.WILL_QOS_SHIFT:0,w|=c?n.WILL_FLAG_MASK:0,w|=l?n.CLEAN_SESSION_MASK:0,t.write(r.from([w])),p(t,u),5===a&&y.write(),F(t,h),c&&(5===a&&v.write(),R(t,c.topic),F(t,c.payload)),null!=f&&F(t,f),null!=d&&F(t,d),!0}function b(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,l=a.properties;let u=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=M(t,l),!h)return!1;u+=h.length}return t.write(n.CONNACK_HEADER),O(t,u),t.write(a.sessionPresent?n.SESSIONPRESENT_HEADER:i),t.write(r.from([c])),null!=h&&h.write(),!0}function w(e,t,i){c("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},l=a.qos||0,u=a.retain?n.RETAIN_MASK:0,h=a.topic,f=a.payload||o,d=a.messageId,m=a.properties;let g=0;if("string"==typeof h)g+=r.byteLength(h)+2;else{if(!r.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;g+=h.length+2}if(r.isBuffer(f)?g+=f.length:g+=r.byteLength(f),l&&"number"!=typeof d)return t.emit("error",new Error("Invalid messageId")),!1;l&&(g+=2);let y=null;if(5===s){if(y=M(t,m),!y)return!1;g+=y.length}return t.write(n.PUBLISH_HEADER[l][a.dup?1:0][u?1:0]),O(t,g),p(t,q(h)),t.write(h),l>0&&p(t,d),null!=y&&y.write(),c("publish: payload: %o",f),t.write(f)}function C(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,l=s.dup&&"pubrel"===a?n.DUP_MASK:0;let u=0;const h=s.reasonCode,f=s.properties;let d=5===i?3:2;if("pubrel"===a&&(u=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof f){if(m=U(t,f,o,d),!m)return!1;d+=m.length}return t.write(n.ACKS[a][u][l][0]),O(t,d),p(t,c),5===i&&t.write(r.from([h])),null!==m&&m.write(),!0}function _(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?n.DUP_MASK:0,l=s.messageId,u=s.subscriptions,h=s.properties;let f=0;if("number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;f+=2;let d=null;if(5===i){if(d=M(t,h),!d)return!1;f+=d.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const n=u[e].topic,o=u[e].qos;if("string"!=typeof n)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(u[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(u[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const r=u[e].rh||0;if("number"!=typeof r||r>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}f+=r.byteLength(n)+2+1}c("subscribe: writing to stream: %o",n.SUBSCRIBE_HEADER),t.write(n.SUBSCRIBE_HEADER[1][a?1:0][0]),O(t,f),p(t,l),null!==d&&d.write();let m=!0;for(const e of u){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,l=e.rh;let u;R(t,o),u=n.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(u|=a?n.SUBSCRIBE_OPTIONS_NL:0,u|=c?n.SUBSCRIBE_OPTIONS_RAP:0,u|=l?n.SUBSCRIBE_OPTIONS_RH[l]:0),m=t.write(r.from([u]))}return m}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,l=s.properties;let u=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(u+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;u+=1}let h=null;if(5===i){if(h=U(t,l,o,u),!h)return!1;u+=h.length}return t.write(n.SUBACK_HEADER),O(t,u),p(t,a),null!==h&&h.write(),t.write(r.from(c))}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,l=s.unsubscriptions,u=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=r.byteLength(l[e])+2}let f=null;if(5===i){if(f=M(t,u),!f)return!1;h+=f.length}t.write(n.UNSUBSCRIBE_HEADER[1][c?1:0][0]),O(t,h),p(t,a),null!==f&&f.write();let d=!0;for(let e=0;e<l.length;e++)d=R(t,l[e]);return d}function E(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?n.DUP_MASK:0,l=s.granted,u=s.properties,h=s.cmd,f=0;let d=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),!1;d+=1}}let m=null;if(5===i){if(m=U(t,u,o,d),!m)return!1;d+=m.length}return t.write(n.ACKS[h][f][c][0]),O(t,d),p(t,a),null!==m&&m.write(),5===i&&t.write(r.from(l)),!0}function A(e,t,r){return t.write(n.EMPTY[e.cmd])}function T(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0,u=null;if(5===i){if(u=U(t,c,o,l),!u)return!1;l+=u.length}return t.write(r.from([n.codes.disconnect<<4])),O(t,l),5===i&&t.write(r.from([a])),null!==u&&u.write(),!0}function x(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const u=U(t,c,o,l);return!!u&&(l+=u.length,t.write(r.from([n.codes.auth<<4])),O(t,l),t.write(r.from([a])),null!==u&&u.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>p===B,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),p=B):(m=!1,p=N)}});const I={};function O(e,t){if(t>n.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let r=I[t];return r||(r=f(t),t<16384&&(I[t]=r)),c("writeVarByteInt: writing to stream: %o",r),e.write(r)}function R(e,t){const n=r.byteLength(t);return p(e,n),c("writeString: %s",t),e.write(t,"utf8")}function P(e,t,r){R(e,t),R(e,r)}function B(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",l[t]),e.write(l[t])}function N(e,t){const r=u(t);return c("writeNumberGenerated: %o",r),e.write(r)}function j(e,t){const r=d(t);return c("write4ByteNumber: %o",r),e.write(r)}function F(e,t){"string"==typeof t?R(e,t):t?(p(e,t.length),e.write(t)):p(e,0)}function M(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){D(e,{},0)}};let o=0;function i(t,o){let i=0;switch(n.propertiesTypes[t]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+r.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+r.byteLength(f(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3+r.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce(((e,t)=>{const n=o[t];return Array.isArray(n)?e+=n.reduce(((e,n)=>e+=3+r.byteLength(t.toString())+2+r.byteLength(n.toString())),0):e+=3+r.byteLength(t.toString())+2+r.byteLength(o[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${o}`)),!1}return i}if(t)for(const e in t){let r=0,n=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(n=i(e,s[t]),!n)return!1;r+=n}else{if(n=i(e,s),!n)return!1;r=n}if(!r)return!1;o+=r}return{length:r.byteLength(f(o))+o,write(){D(e,t,o)}}}function U(e,t,r,n){const o=["reasonString","userProperties"],i=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=M(e,t);if(i)for(;n+s.length>i;){const r=o.shift();if(!r||!t[r])return!1;delete t[r],s=M(e,t)}return s}function L(e,t,o){switch(n.propertiesTypes[t]){case"byte":e.write(r.from([n.properties[t]])),e.write(r.from([+o]));break;case"int8":e.write(r.from([n.properties[t]])),e.write(r.from([o]));break;case"binary":e.write(r.from([n.properties[t]])),F(e,o);break;case"int16":e.write(r.from([n.properties[t]])),p(e,o);break;case"int32":e.write(r.from([n.properties[t]])),j(e,o);break;case"var":e.write(r.from([n.properties[t]])),O(e,o);break;case"string":e.write(r.from([n.properties[t]])),R(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach((i=>{const s=o[i];Array.isArray(s)?s.forEach((o=>{e.write(r.from([n.properties[t]])),P(e,i.toString(),o.toString())})):(e.write(r.from([n.properties[t]])),P(e,i.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${o}`)),!1}}function D(e,t,r){O(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const n=t[r];if(Array.isArray(n))for(let t=0;t<n.length;t++)L(e,r,n[t]);else L(e,r,n)}}function q(e){return e?e instanceof r?e.length:r.byteLength(e):0}function z(e){return"string"==typeof e||e instanceof r}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(e,t,r){var n=1e3,o=60*n,i=60*o,s=24*i,a=7*s,c=365.25*s;function l(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*c;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*i;case"minutes":case"minute":case"mins":case"min":case"m":return r*o;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function u(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=n?Math.round(e/n)+"s":e+"ms"}function h(e){var t=Math.abs(e);return t>=s?f(e,t,s,"day"):t>=i?f(e,t,i,"hour"):t>=o?f(e,t,o,"minute"):t>=n?f(e,t,n,"second"):e+" ms"}function f(e,t,r,n){var o=t>=1.5*r;return Math.round(e/r)+" "+n+(o?"s":"")}t.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return l(e);if("number"===r&&isFinite(e))return t.long?h(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],46:[function(e,t,r){const n=e("./lib/number-allocator.js");t.exports.NumberAllocator=n},{"./lib/number-allocator.js":47}],47:[function(e,t,r){const n=e("js-sdsl").Set,o=e("debug")("number-allocator:trace"),i=e("debug")("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new n([],((e,t)=>e.compare(t))),o("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.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 o("alloc():empty"),null;const e=this.ss.front(),t=e.low;return t+1<=e.high?++e.low:this.ss.eraseElementByPos(0),o("alloc():"+t),t},a.prototype.use=function(e){const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.equals(t))return this.ss.eraseElementByValue(r),o("use():"+e),!0;if(r.low>e)return!1;if(r.low===e)return++r.low,o("use():"+e),!0;if(r.high===e)return--r.high,o("use():"+e),!0;const n=r.low;return r.low=e+1,this.ss.insert(new s(n,e-1)),o("use():"+e),!0}return o("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void i("free():"+e+" is out of range");const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.low<=e&&e<=r.high)return void i("free():"+e+" has already been vacant");if(r===this.ss.front())e+1===r.low?--r.low:this.ss.insert(t);else{const n=this.ss.reverseLowerBound(t);n.high+1===e?e+1===r.low?(this.ss.eraseElementByValue(n),r.low=n.low):n.high=e:e+1===r.low?r.low=e:this.ss.insert(t)}}else{if(r===this.ss.front())return void this.ss.insert(t);const n=this.ss.reverseLowerBound(t);n.high+1===e?n.high=e:this.ss.insert(t)}o("free():"+e)},a.prototype.clear=function(){o("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 e of this.ss)console.log(e)},t.exports=a},{debug:18,"js-sdsl":36}],48:[function(e,t,r){var n=e("wrappy");function o(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}t.exports=n(o),t.exports.strict=n(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},{wrappy:79}],49:[function(e,t,r){(function(e){(function(){function r(t,r,n,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,r)}));case 3:return e.nextTick((function(){t.call(null,r,n)}));case 4:return e.nextTick((function(){t.call(null,r,n,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:r}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:50}],50:[function(e,t,r){var n,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}function l(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var u,h=[],f=!1,d=-1;function p(){f&&u&&(f=!1,u.length?h=u.concat(h):d=-1,h.length&&m())}function m(){if(!f){var e=c(p);f=!0;for(var t=h.length;t;){for(u=h,h=[];++d<t;)u&&u[d].run();d=-1,t=h.length}u=null,f=!1,l(e)}}function g(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];h.push(new g(e,t)),1!==h.length||f||c(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],51:[function(e,t,r){(function(e){(function(){!function(n){var o="object"==typeof r&&r&&!r.nodeType&&r,i="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(n=s);var a,c,l=2147483647,u=36,h=1,f=26,d=38,p=700,m=72,g=128,y="-",v=/^xn--/,b=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=u-h,k=Math.floor,S=String.fromCharCode;function E(e){throw new RangeError(C[e])}function A(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function T(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+A((e=e.replace(w,".")).split("."),t).join(".")}function x(e){for(var t,r,n=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(r=e.charCodeAt(o++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),o--):n.push(t);return n}function I(e){return A(e,(function(e){var t="";return e>65535&&(t+=S((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=S(e)})).join("")}function O(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:u}function R(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,r){var n=0;for(e=r?k(e/p):e>>1,e+=k(e/t);e>_*f>>1;n+=u)e=k(e/_);return k(n+(_+1)*e/(e+d))}function B(e){var t,r,n,o,i,s,a,c,d,p,v=[],b=e.length,w=0,C=g,_=m;for((r=e.lastIndexOf(y))<0&&(r=0),n=0;n<r;++n)e.charCodeAt(n)>=128&&E("not-basic"),v.push(e.charCodeAt(n));for(o=r>0?r+1:0;o<b;){for(i=w,s=1,a=u;o>=b&&E("invalid-input"),((c=O(e.charCodeAt(o++)))>=u||c>k((l-w)/s))&&E("overflow"),w+=c*s,!(c<(d=a<=_?h:a>=_+f?f:a-_));a+=u)s>k(l/(p=u-d))&&E("overflow"),s*=p;_=P(w-i,t=v.length+1,0==i),k(w/t)>l-C&&E("overflow"),C+=k(w/t),w%=t,v.splice(w++,0,C)}return I(v)}function N(e){var t,r,n,o,i,s,a,c,d,p,v,b,w,C,_,A=[];for(b=(e=x(e)).length,t=g,r=0,i=m,s=0;s<b;++s)(v=e[s])<128&&A.push(S(v));for(n=o=A.length,o&&A.push(y);n<b;){for(a=l,s=0;s<b;++s)(v=e[s])>=t&&v<a&&(a=v);for(a-t>k((l-r)/(w=n+1))&&E("overflow"),r+=(a-t)*w,t=a,s=0;s<b;++s)if((v=e[s])<t&&++r>l&&E("overflow"),v==t){for(c=r,d=u;!(c<(p=d<=i?h:d>=i+f?f:d-i));d+=u)_=c-p,C=u-p,A.push(S(R(p+_%C,0))),c=k(_/C);A.push(S(R(c,0))),i=P(r,w,n==o),r=0,++n}++r,++t}return A.join("")}function j(e){return T(e,(function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e}))}function F(e){return T(e,(function(e){return b.test(e)?"xn--"+N(e):e}))}if(a={version:"1.4.1",ucs2:{decode:x,encode:I},decode:B,encode:N,toASCII:F,toUnicode:j},o&&i)if(t.exports==o)i.exports=a;else for(c in a)a.hasOwnProperty(c)&&(o[c]=a[c]);else n.punycode=a}(this)}).call(this)}).call(this,void 0!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],52:[function(e,t,r){function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,i){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var l=e.length;c>0&&l>c&&(l=c);for(var u=0;u<l;++u){var h,f,d,p,m=e[u].replace(a,"%20"),g=m.indexOf(r);g>=0?(h=m.substr(0,g),f=m.substr(g+1)):(h=m,f=""),d=decodeURIComponent(h),p=decodeURIComponent(f),n(s,d)?o(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],53:[function(e,t,r){var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(n(s))+r;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(n(e))})).join(t):a+encodeURIComponent(n(e[s]))})).join(t):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n<e.length;n++)r.push(t(e[n],n));return r}var s=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t}},{}],54:[function(e,t,r){r.decode=r.parse=e("./decode"),r.encode=r.stringify=e("./encode")},{"./decode":52,"./encode":53}],55:[function(e,t,r){function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var o={};function i(e,t,r){function i(e,r,n){return"string"==typeof t?t:t(e,r,n)}r||(r=Error);var s=function(e){function t(t,r,n){return e.call(this,i(t,r,n))||this}return n(t,e),t}(r);s.prototype.name=r.name,s.prototype.code=e,o[e]=s}function s(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function a(e,t,r){return e.substr(!r||r<0?0:+r,t.length)===t}function c(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function l(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,o;if("string"==typeof t&&a(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be",c(e," argument"))o="The ".concat(e," ").concat(n," ").concat(s(t,"type"));else{var i=l(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(i," ").concat(n," ").concat(s(t,"type"))}return o+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=o},{}],56:[function(e,t,r){(function(r){(function(){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=l;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(l,o);for(var s=n(i.prototype),a=0;a<s.length;a++){var c=s[a];l.prototype[c]||(l.prototype[c]=i.prototype[c])}function l(e){if(!(this instanceof l))return new l(e);o.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",u)))}function u(){this._writableState.ended||r.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(e,t,r){t.exports=o;var n=e("./_stream_transform");function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}e("inherits")(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":59,inherits:24}],58:[function(e,t,r){(function(r,n){(function(){var o;t.exports=x,x.ReadableState=T,e("events").EventEmitter;var i=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,c=n.Uint8Array||function(){};function l(e){return a.from(e)}function u(e){return a.isBuffer(e)||e instanceof c}var h,f=e("util");h=f&&f.debuglog?f.debuglog("stream"):function(){};var d,p,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),v=e("./internal/streams/state").getHighWaterMark,b=e("../errors").codes,w=b.ERR_INVALID_ARG_TYPE,C=b.ERR_STREAM_PUSH_AFTER_EOF,_=b.ERR_METHOD_NOT_IMPLEMENTED,k=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(x,s);var S=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function A(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}function T(t,r,n){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof n&&(n=r instanceof o),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v(this,t,"readableHighWaterMark",n),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!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=e("string_decoder/").StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function x(t){if(o=o||e("./_stream_duplex"),!(this instanceof x))return new x(t);var r=this instanceof o;this._readableState=new T(t,this,r),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function I(e,t,r,n,o){h("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,j(e,s);else if(o||(i=R(s,t)),i)S(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=l(t)),n)s.endEmitted?S(e,new k):O(e,s,t,!0);else if(s.ended)S(e,new C);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?O(e,s,t,!1):U(e,s)):O(e,s,t,!1)}else n||(s.reading=!1,U(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function O(e,t,r,n){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,n?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&F(e)),U(e,t)}function R(e,t){var r;return u(t)||"string"==typeof t||void 0===t||e.objectMode||(r=new w("chunk",["string","Buffer","Uint8Array"],t)),r}Object.defineProperty(x.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),x.prototype.destroy=y.destroy,x.prototype._undestroy=y.undestroy,x.prototype._destroy=function(e,t){t(e)},x.prototype.push=function(e,t){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof e&&((t=t||n.defaultEncoding)!==n.encoding&&(e=a.from(e,t),t=""),r=!0),I(this,e,t,!1,r)},x.prototype.unshift=function(e){return I(this,e,null,!0,!1)},x.prototype.isPaused=function(){return!1===this._readableState.flowing},x.prototype.setEncoding=function(t){d||(d=e("string_decoder/").StringDecoder);var r=new d(t);this._readableState.decoder=r,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,o="";null!==n;)o+=r.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};var P=1073741824;function B(e){return e>=P?e=P:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function N(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=B(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function j(e,t){if(h("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?F(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}function F(e){var t=e._readableState;h("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,r.nextTick(M,e))}function M(e){var t=e._readableState;h("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,V(e)}function U(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(L,e,t))}function L(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(h("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function D(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,V(e))}}function q(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function z(e){h("readable nexttick read 0"),e.read(0)}function $(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(H,e,t))}function H(e,t){h("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),V(e),t.flowing&&!t.reading&&e.read(0)}function V(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function W(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function K(e){var t=e._readableState;h("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,r.nextTick(Q,t,e))}function Q(e,t){if(h("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function J(e,t){for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}x.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?K(this):F(this),null;if(0===(e=N(e,t))&&t.ended)return 0===t.length&&K(this),null;var n,o=t.needReadable;return h("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&h("length less than watermark",o=!0),t.ended||t.reading?h("reading or ended",o=!1):o&&(h("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=N(r,t))),null===(n=e>0?W(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&K(this)),null!==n&&this.emit("data",n),n},x.prototype._read=function(e){S(this,new _("_read()"))},x.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===r.stdout||e===r.stderr?y:c;function a(e,t){h("onunpipe"),e===n&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,f())}function c(){h("onend"),e.end()}o.endEmitted?r.nextTick(s):n.once("end",s),e.on("unpipe",a);var l=D(n);e.on("drain",l);var u=!1;function f(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",p),e.removeListener("unpipe",a),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",d),u=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l()}function d(t){h("ondata");var r=e.write(t);h("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==J(o.pipes,e))&&!u&&(h("false write response, pause",o.awaitDrain),o.awaitDrain++),n.pause())}function p(t){h("onerror",t),y(),e.removeListener("error",p),0===i(e,"error")&&S(e,t)}function m(){e.removeListener("finish",g),y()}function g(){h("onfinish"),e.removeListener("close",m),y()}function y(){h("unpipe"),n.unpipe(e)}return n.on("data",d),A(e,"error",p),e.once("close",m),e.once("finish",g),e.emit("pipe",n),o.flowing||(h("pipe resume"),n.resume()),e},x.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)n[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=J(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},x.prototype.on=function(e,t){var n=s.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,h("on readable",o.length,o.reading),o.length?F(this):o.reading||r.nextTick(z,this))),n},x.prototype.addListener=x.prototype.on,x.prototype.removeListener=function(e,t){var n=s.prototype.removeListener.call(this,e,t);return"readable"===e&&r.nextTick(q,this),n},x.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||r.nextTick(q,this),t},x.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!e.readableListening,$(this,e)),e.paused=!1,this},x.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},x.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var o in e.on("end",(function(){if(h("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){h("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o||(r.objectMode||o&&o.length)&&(t.push(o)||(n=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var i=0;i<E.length;i++)e.on(E[i],this.emit.bind(this,E[i]));return this._read=function(t){h("wrapped _read",t),n&&(n=!1,e.resume())},this},"function"==typeof Symbol&&(x.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=e("./internal/streams/async_iterator")),p(this)}),Object.defineProperty(x.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(x.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(x.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),x._fromList=W,Object.defineProperty(x.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(x.from=function(t,r){return void 0===m&&(m=e("./internal/streams/from")),m(x,t,r)})}).call(this)}).call(this,e("_process"),void 0!==be?be:"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(e,t,r){t.exports=u;var n=e("../errors").codes,o=n.ERR_METHOD_NOT_IMPLEMENTED,i=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,c=e("./_stream_duplex");function l(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new i);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);c.call(this,e),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush((function(t,r){f(e,t,r)}))}function f(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(u,c),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,r){r(new o("_transform()"))},u.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var o=this._readableState;(n.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},u.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(e,t,r){(function(r,n){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){H(t,e)}}var i;t.exports=T,T.WritableState=A;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,l=n.Uint8Array||function(){};function u(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof l}var f,d=e("./internal/streams/destroy"),p=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,v=m.ERR_MULTIPLE_CALLBACK,b=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,C=m.ERR_STREAM_NULL_VALUES,_=m.ERR_STREAM_WRITE_AFTER_END,k=m.ERR_UNKNOWN_ENCODING,S=d.errorOrDestroy;function E(){}function A(t,r,n){i=i||e("./_stream_duplex"),t=t||{},"boolean"!=typeof n&&(n=r instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(this,t,"writableHighWaterMark",n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){j(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function T(t){var r=this instanceof(i=i||e("./_stream_duplex"));if(!r&&!f.call(T,this))return new T(t);this._writableState=new A(t,this,r),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function x(e,t){var n=new _;S(e,n),r.nextTick(t,n)}function I(e,t,n,o){var i;return null===n?i=new C:"string"==typeof n||t.objectMode||(i=new g("chunk",["string","Buffer"],n)),!i||(S(e,i),r.nextTick(o,i),!1)}function O(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,r)),t}function R(e,t,r,n,o,i){if(!r){var s=O(t,n,o);n!==s&&(r=!0,o="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:n,encoding:o,isBuf:r,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else P(e,t,!1,a,n,o,i);return c}function P(e,t,r,n,o,i,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):r?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function B(e,t,n,o,i){--t.pendingcb,n?(r.nextTick(i,o),r.nextTick(z,e,t),e._writableState.errorEmitted=!0,S(e,o)):(i(o),e._writableState.errorEmitted=!0,S(e,o),z(e,t))}function N(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function j(e,t){var n=e._writableState,o=n.sync,i=n.writecb;if("function"!=typeof i)throw new v;if(N(n),t)B(e,n,o,t,i);else{var s=L(n)||e.destroyed;s||n.corked||n.bufferProcessing||!n.bufferedRequest||U(e,n),o?r.nextTick(F,e,n,s,i):F(e,n,s,i)}}function F(e,t,r,n){r||M(e,t),t.pendingcb--,n(),z(e,t)}function M(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function U(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),s=t.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)i[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;i.allBuffers=c,P(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,u=r.encoding,h=r.callback;if(P(e,t,!1,t.objectMode?1:l.length,l,u,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function L(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function D(e,t){e._final((function(r){t.pendingcb--,r&&S(e,r),t.prefinished=!0,e.emit("prefinish"),z(e,t)}))}function q(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,r.nextTick(D,e,t)))}function z(e,t){var r=L(t);if(r&&(q(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}function $(e,t,n){t.ending=!0,z(e,t),n&&(t.finished?r.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function H(e,t,r){var n=e.entry;for(e.entry=null;n;){var o=n.callback;t.pendingcb--,o(r),n=n.next}t.corkedRequestsFree.next=e}e("inherits")(T,a),A.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(A.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===T&&e&&e._writableState instanceof A}})):f=function(e){return e instanceof this},T.prototype.pipe=function(){S(this,new b)},T.prototype.write=function(e,t,r){var n=this._writableState,o=!1,i=!n.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=u(e)),"function"==typeof t&&(r=t,t=null),i?t="buffer":t||(t=n.defaultEncoding),"function"!=typeof r&&(r=E),n.ending?x(this,r):(i||I(this,n,e,r))&&(n.pendingcb++,o=R(this,n,i,e,t,r)),o},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||U(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new k(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,r){r(new y("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,r){var n=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||$(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=d.destroy,T.prototype._undestroy=d.undestroy,T.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==be?be:"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(e,t,r){(function(r){(function(){var n;function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),h=Symbol("handlePromise"),f=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var r=e[f].read();null!==r&&(e[u]=null,e[s]=null,e[a]=null,t(d(r,!1)))}}function m(e){r.nextTick(p,e)}function g(e,t){return function(r,n){e.then((function(){t[l]?r(d(void 0,!0)):t[h](r,n)}),n)}}var y=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(n={get stream(){return this[f]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(d(void 0,!0));if(this[f].destroyed)return new Promise((function(t,n){r.nextTick((function(){e[c]?n(e[c]):t(d(void 0,!0))}))}));var n,o=this[u];if(o)n=new Promise(g(o,this));else{var i=this[f].read();if(null!==i)return Promise.resolve(d(i,!1));n=new Promise(this[h])}return this[u]=n,n}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var e=this;return new Promise((function(t,r){e[f].destroy(null,(function(e){e?r(e):t(d(void 0,!0))}))}))})),n),y),b=function(e){var t,r=Object.create(v,(o(t={},f,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var n=r[f].read();n?(r[u]=null,r[s]=null,r[a]=null,e(d(n,!1))):(r[s]=e,r[a]=t)},writable:!0}),t));return r[u]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[a];return null!==t&&(r[u]=null,r[s]=null,r[a]=null,t(e)),void(r[c]=e)}var n=r[s];null!==n&&(r[u]=null,r[s]=null,r[a]=null,n(d(void 0,!0))),r[l]=!0})),e.on("readable",m.bind(null,r)),r};t.exports=b}).call(this)}).call(this,e("_process"))},{"./end-of-stream":64,_process:50}],62:[function(e,t,r){function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}var l=e("buffer").Buffer,u=e("util").inspect,h=u&&u.custom||"inspect";function f(e,t,r){l.prototype.copy.call(e,t,r)}t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return l.alloc(0);for(var t=l.allocUnsafe(e>>>0),r=this.head,n=0;r;)f(r.data,t,n),n+=r.data.length,r=r.next;return t}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?n+=o:n+=o.slice(0,e),0==(e-=i)){i===o.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=l.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var o=r.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=o.slice(i));break}++n}return this.length-=n,t}},{key:h,value:function(e,t){return u(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:17,util:16}],63:[function(e,t,r){(function(e){(function(){function r(t,r){var i=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(r?r(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!r&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(o,i):(i._writableState.errorEmitted=!0,e.nextTick(n,i,t)):e.nextTick(n,i,t):r?(e.nextTick(o,i),r(t)):e.nextTick(o,i)})),this)}function n(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i(){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(e,t){e.emit("error",t)}function a(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:r,undestroy:i,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:50}],64:[function(e,t,r){var n=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function o(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];e.apply(this,n)}}}function i(){}function s(e){return e.setHeader&&"function"==typeof e.abort}function a(e,t,r){if("function"==typeof t)return a(e,null,t);t||(t={}),r=o(r||i);var c=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,u=function(){e.writable||f()},h=e._writableState&&e._writableState.finished,f=function(){l=!1,h=!0,c||r.call(e)},d=e._readableState&&e._readableState.endEmitted,p=function(){c=!1,d=!0,l||r.call(e)},m=function(t){r.call(e,t)},g=function(){var t;return c&&!d?(e._readableState&&e._readableState.ended||(t=new n),r.call(e,t)):l&&!h?(e._writableState&&e._writableState.ended||(t=new n),r.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return s(e)?(e.on("complete",f),e.on("abort",g),e.req?y():e.on("request",y)):l&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",p),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",f),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",p),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":55}],65:[function(e,t,r){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(e,t,r){var n;function o(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=e("../../../errors").codes,s=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function c(e){if(e)throw e}function l(e){return e.setHeader&&"function"==typeof e.abort}function u(t,r,i,s){s=o(s);var c=!1;t.on("close",(function(){c=!0})),void 0===n&&(n=e("./end-of-stream")),n(t,{readable:r,writable:i},(function(e){if(e)return s(e);c=!0,s()}));var u=!1;return function(e){if(!c&&!u)return u=!0,l(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function f(e,t){return e.pipe(t)}function d(e){return e.length?"function"!=typeof e[e.length-1]?c:e.pop():c}function p(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,o=d(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new s("streams");var i=t.map((function(e,r){var s=r<t.length-1;return u(e,s,r>0,(function(e){n||(n=e),e&&i.forEach(h),s||(i.forEach(h),o(n))}))}));return t.reduce(f)}t.exports=p},{"../../../errors":55,"./end-of-stream":64}],67:[function(e,t,r){var n=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function o(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}function i(e,t,r,i){var s=o(t,i,r);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new n(i?r:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}},{"../../../errors":55}],68:[function(e,t,r){t.exports=e("events").EventEmitter},{events:22}],69:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js"),r.finished=e("./lib/internal/streams/end-of-stream.js"),r.pipeline=e("./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(e,t,r){function n(e,t,r){var n=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=n._interval),n._interval&&clearInterval(n._interval),n._interval=setInterval(n._callback,e,n._args)},this.clear=function(){n._interval&&(clearInterval(n._interval),n._interval=void 0)},this.destroy=function(){n._interval&&clearInterval(n._interval),n._callback=void 0,n._interval=void 0,n._args=void 0}}function o(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new n(arguments[0],arguments[1],e)}t.exports=o},{}],71:[function(e,t,r){t.exports=e("./index.js")()},{"./index.js":72}],72:[function(e,t,r){(function(e){(function(){function r(t){return t instanceof e?e.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function n(e){return(e=e||{}).circles?o(e):e.proto?i:n;function t(e,t){for(var n=Object.keys(e),o=new Array(n.length),i=0;i<n.length;i++){var s=n[i],a=e[s];"object"!=typeof a||null===a?o[s]=a:a instanceof Date?o[s]=new Date(a):ArrayBuffer.isView(a)?o[s]=r(a):o[s]=t(a)}return o}function n(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,n);if(e instanceof Map)return new Map(t(Array.from(e),n));if(e instanceof Set)return new Set(t(Array.from(e),n));var o={};for(var i in e)if(!1!==Object.hasOwnProperty.call(e,i)){var s=e[i];"object"!=typeof s||null===s?o[i]=s:s instanceof Date?o[i]=new Date(s):s instanceof Map?o[i]=new Map(t(Array.from(s),n)):s instanceof Set?o[i]=new Set(t(Array.from(s),n)):ArrayBuffer.isView(s)?o[i]=r(s):o[i]=n(s)}return o}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,i);if(e instanceof Map)return new Map(t(Array.from(e),i));if(e instanceof Set)return new Set(t(Array.from(e),i));var n={};for(var o in e){var s=e[o];"object"!=typeof s||null===s?n[o]=s:s instanceof Date?n[o]=new Date(s):s instanceof Map?n[o]=new Map(t(Array.from(s),i)):s instanceof Set?n[o]=new Set(t(Array.from(s),i)):ArrayBuffer.isView(s)?n[o]=r(s):n[o]=i(s)}return n}}function o(e){var t=[],n=[];return e.proto?s:i;function o(e,o){for(var i=Object.keys(e),s=new Array(i.length),a=0;a<i.length;a++){var c=i[a],l=e[c];if("object"!=typeof l||null===l)s[c]=l;else if(l instanceof Date)s[c]=new Date(l);else if(ArrayBuffer.isView(l))s[c]=r(l);else{var u=t.indexOf(l);s[c]=-1!==u?n[u]:o(l)}}return s}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,i);if(e instanceof Map)return new Map(o(Array.from(e),i));if(e instanceof Set)return new Set(o(Array.from(e),i));var s={};for(var a in t.push(e),n.push(s),e)if(!1!==Object.hasOwnProperty.call(e,a)){var c=e[a];if("object"!=typeof c||null===c)s[a]=c;else if(c instanceof Date)s[a]=new Date(c);else if(c instanceof Map)s[a]=new Map(o(Array.from(c),i));else if(c instanceof Set)s[a]=new Set(o(Array.from(c),i));else if(ArrayBuffer.isView(c))s[a]=r(c);else{var l=t.indexOf(c);s[a]=-1!==l?n[l]:i(c)}}return t.pop(),n.pop(),s}function s(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,s);if(e instanceof Map)return new Map(o(Array.from(e),s));if(e instanceof Set)return new Set(o(Array.from(e),s));var i={};for(var a in t.push(e),n.push(i),e){var c=e[a];if("object"!=typeof c||null===c)i[a]=c;else if(c instanceof Date)i[a]=new Date(c);else if(c instanceof Map)i[a]=new Map(o(Array.from(c),s));else if(c instanceof Set)i[a]=new Set(o(Array.from(c),s));else if(ArrayBuffer.isView(c))i[a]=r(c);else{var l=t.indexOf(c);i[a]=-1!==l?n[l]:s(c)}}return t.pop(),n.pop(),i}}t.exports=n}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],73:[function(e,t,r){
|
|
5
5
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
6
|
-
var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(i(r,n),n.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:17}],74:[function(e,t,n){function r(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(o(t)):null}function o(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}t.exports=r},{}],75:[function(e,t,n){var r=e("safe-buffer").Buffer,o=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function s(e){var t=i(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=s(e),this.encoding){case"utf16le":this.text=d,this.end=m,t=4;break;case"utf8":this.fillLast=h,t=4;break;case"base64":this.text=g,this.end=y,t=3;break;default:return this.write=v,void(this.end=b)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function c(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e,t,n){var r=t.length-1;if(r<n)return 0;var o=c(t[r]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}function u(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}function h(e){var t=this.lastTotal-this.lastNeed,n=u(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function f(e,t){var n=l(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)}function p(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function d(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function g(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function y(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function v(e){return e.toString(this.encoding)}function b(e){return e&&e.length?this.write(e):""}n.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},a.prototype.end=p,a.prototype.text=f,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":73}],76:[function(e,t,n){var r=e("punycode"),o=e("./util");function i(){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}n.parse=w,n.resolve=_,n.resolveObject=k,n.format=C,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(l),h=["%","/","?",";","#"].concat(u),f=["/","?","#"],p=255,d=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");function w(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}function C(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function _(e,t){return w(e,!1,!0).resolve(t)}function k(e,t){return e?w(e,!1,!0).resolveObject(t):t}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",l=e.split(a),w=/\\/g;l[0]=l[0].replace(w,"/");var C=e=l.join(a);if(C=C.trim(),!n&&1===e.split("#").length){var _=c.exec(C);if(_)return this.path=C,this.href=C,this.pathname=_[1],_[2]?(this.search=_[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var k=s.exec(C);if(k){var S=(k=k[0]).toLowerCase();this.protocol=S,C=C.substr(k.length)}if(n||k||C.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===C.substr(0,2);!E||k&&y[k]||(C=C.substr(2),this.slashes=!0)}if(!y[k]&&(E||k&&!v[k])){for(var A,T,x=-1,I=0;I<f.length;I++)-1!==(O=C.indexOf(f[I]))&&(-1===x||O<x)&&(x=O);for(-1!==(T=-1===x?C.lastIndexOf("@"):C.lastIndexOf("@",x))&&(A=C.slice(0,T),C=C.slice(T+1),this.auth=decodeURIComponent(A)),x=-1,I=0;I<h.length;I++){var O;-1!==(O=C.indexOf(h[I]))&&(-1===x||O<x)&&(x=O)}-1===x&&(x=C.length),this.host=C.slice(0,x),C=C.slice(x),this.parseHost(),this.hostname=this.hostname||"";var R="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!R)for(var P=this.hostname.split(/\./),B=(I=0,P.length);I<B;I++){var F=P[I];if(F&&!F.match(d)){for(var N="",j=0,M=F.length;j<M;j++)F.charCodeAt(j)>127?N+="x":N+=F[j];if(!N.match(d)){var U=P.slice(0,I),L=P.slice(I+1),D=F.match(m);D&&(U.push(D[1]),L.unshift(D[2])),L.length&&(C="/"+L.join(".")+C),this.hostname=U.join(".");break}}}this.hostname.length>p?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+q,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==C[0]&&(C="/"+C))}if(!g[S])for(I=0,B=u.length;I<B;I++){var $=u[I];if(-1!==C.indexOf($)){var H=encodeURIComponent($);H===$&&(H=escape($)),C=C.split($).join(H)}}var V=C.indexOf("#");-1!==V&&(this.hash=C.substr(V),C=C.slice(0,V));var W=C.indexOf("?");if(-1!==W?(this.search=C.substr(W),this.query=C.substr(W+1),t&&(this.query=b.parse(this.query)),C=C.slice(0,W)):t&&(this.search="",this.query={}),C&&(this.pathname=C),v[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var K=this.search||"";this.path=q+K}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(w(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),l=0;l<c.length;l++){var u=c[l];"protocol"!==u&&(n[u]=e[u])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!v[e.protocol]){for(var h=Object.keys(e),f=0;f<h.length;f++){var p=h[f];n[p]=e[p]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),n.pathname=d.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",g=n.search||"";n.path=m+g}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),C=w||b||n.host&&e.pathname,_=C,k=n.pathname&&n.pathname.split("/")||[],S=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(S&&(n.hostname="",n.port=null,n.host&&(""===k[0]?k[0]=n.host:k.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),C=C&&(""===d[0]||""===k[0])),w)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,k=d;else if(d.length)k||(k=[]),k.pop(),k=k.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return S&&(n.hostname=n.host=k.shift(),(I=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=I.shift(),n.host=n.hostname=I.shift())),n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var E=k.slice(-1)[0],A=(n.host||e.host||k.length>1)&&("."===E||".."===E)||""===E,T=0,x=k.length;x>=0;x--)"."===(E=k[x])?k.splice(x,1):".."===E?(k.splice(x,1),T++):T&&(k.splice(x,1),T--);if(!C&&!_)for(;T--;T)k.unshift("..");!C||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),A&&"/"!==k.join("/").substr(-1)&&k.push("");var I,O=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(n.hostname=n.host=O?"":k.length?k.shift():"",(I=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=I.shift(),n.host=n.hostname=I.shift())),(C=C||n.host&&k.length)&&!O&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":77,punycode:51,querystring:54}],77:[function(e,t,n){t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],78:[function(e,t,n){(function(e){(function(){function n(e,t){if(r("noDeprecation"))return e;var n=!1;function o(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return o}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this)}).call(this,void 0!==de?de:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(e,t,n){function r(e,t){if(e&&t)return r(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach((function(e){r[e]=o[e]})),r}}t.exports=r},{}],80:[function(e,t,n){t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(e,t,n){t.exports=o;var r=Object.prototype.hasOwnProperty;function o(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e}},{}],82:[function(e,t,n){t.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},{}],83:[function(e,t,n){function r(e){var t=this;if(t instanceof r||(t=new r),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var n=0,o=arguments.length;n<o;n++)t.push(arguments[n]);return t}function o(e,t,n){var r=t===e.head?new a(n,null,t,e):new a(n,t,t.next,e);return null===r.next&&(e.tail=r),null===r.prev&&(e.head=r),e.length++,r}function i(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function s(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,n,r){if(!(this instanceof a))return new a(e,t,n,r);this.list=r,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,n?(n.prev=this,this.next=n):this.next=null}t.exports=r,r.Node=a,r.create=r,r.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),e.list.length--,e.next=null,e.prev=null,e.list=null,t},r.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},r.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},r.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},r.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},r.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},r.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},r.prototype.forEach=function(e,t){t=t||this;for(var n=this.head,r=0;null!==n;r++)e.call(t,n.value,r,this),n=n.next},r.prototype.forEachReverse=function(e,t){t=t||this;for(var n=this.tail,r=this.length-1;null!==n;r--)e.call(t,n.value,r,this),n=n.prev},r.prototype.get=function(e){for(var t=0,n=this.head;null!==n&&t<e;t++)n=n.next;if(t===e&&null!==n)return n.value},r.prototype.getReverse=function(e){for(var t=0,n=this.tail;null!==n&&t<e;t++)n=n.prev;if(t===e&&null!==n)return n.value},r.prototype.map=function(e,t){t=t||this;for(var n=new r,o=this.head;null!==o;)n.push(e.call(t,o.value,this)),o=o.next;return n},r.prototype.mapReverse=function(e,t){t=t||this;for(var n=new r,o=this.tail;null!==o;)n.push(e.call(t,o.value,this)),o=o.prev;return n},r.prototype.reduce=function(e,t){var n,r=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,n=this.head.value}for(var o=0;null!==r;o++)n=e(n,r.value,o),r=r.next;return n},r.prototype.reduceReverse=function(e,t){var n,r=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,n=this.tail.value}for(var o=this.length-1;null!==r;o--)n=e(n,r.value,o),r=r.prev;return n},r.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},r.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},r.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new r;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=0,i=this.head;null!==i&&o<e;o++)i=i.next;for(;null!==i&&o<t;o++,i=i.next)n.push(i.value);return n},r.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new r;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=this.length,i=this.tail;null!==i&&o>t;o--)i=i.prev;for(;null!==i&&o>e;o--,i=i.prev)n.push(i.value);return n},r.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,i=this.head;null!==i&&r<e;r++)i=i.next;var s=[];for(r=0;i&&r<t;r++)s.push(i.value),i=this.removeNode(i);for(null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev),r=0;r<n.length;r++)i=o(this,i,n[r]);return s},r.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r}return this.head=t,this.tail=e,this};try{e("./iterator.js")(r)}catch(e){}},{"./iterator.js":82}]},{},[12])(12);var qi=me(Di.exports);var zi;!function(e){e[e.IDENTIFIER_REJECTED=2]="IDENTIFIER_REJECTED",e[e.BAD_USERNAME_OR_PASSWORD=4]="BAD_USERNAME_OR_PASSWORD",e[e.NOT_AUTHORIZED=5]="NOT_AUTHORIZED"}(zi||(zi={}));const $i=e=>{let t,n=0,r=!0;return{connect:async function(o){return t&&(t.removeAllListeners(),t.end(!0)),t=qi.connect(e,function(e){return Object.assign({clean:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:0,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1}},e)}({username:o.userId,password:o.accessToken})),t.on("connect",(()=>{n=0,r=!0})),t.on("error",(e=>{switch(e.code){case 2:case 4:case 5:r=!1}})),t.on("close",(()=>{r&&setTimeout((()=>{n+=1,t.reconnect()}),1e3*2**(n>10?10:n))})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(r=!1,this.connected)return new Promise((e=>null==t?void 0:t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,n){null==t||t.on(e,n)},once(e,n){null==t||t.once(e,n)},off(e,n){void 0!==n?null==t||t.off(e,n):null==t||t.removeAllListeners(e)},removeAllListeners(){null==t||t.removeAllListeners()},subscribe(e,n){const r=(t,r)=>{if(t||128===r[0].qos){const r=t?new W(t.message,8e5,"error"):new Q(8e5,"error");console.error(`Failed to subscribe to topic ${e}`,r),null==n||n(r)}else console.log(`Subscribed to topic ${r[0].topic}`),null==n||n()};return t?t.subscribe(e,{qos:0},r):r(new Error("No connection to broker"),[]),()=>null==t?void 0:t.unsubscribe(e)},unsubscribe(e){null==t||t.unsubscribe(e)}}},Hi=async()=>{const e=X();return e.log("client/api/disconnectClient"),await new Promise((t=>{e.ws.once("disconnect",t),e.ws.disconnect(),e.mqtt.disconnect()})),e.emitter.all.clear(),e.ws.removeAllListeners(),e.mqtt.removeAllListeners(),e.userId=void 0,e.accessToken=void 0,!e.ws.connected},Vi=()=>`ascWebSdk#${Math.random().toString(16)}`,Wi=()=>{const e=(()=>{var e,t;return(null===(e=r.versions)||void 0===e?void 0:e.node)?r.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}},Ki=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],Qi=e=>{const t=X(),n=Ki.map((n=>oe(t,`client/onConnectionError(${n})`,n,(t=>{const r=(null==t?void 0:t.code)?new W(t.message,t.code,"fatal"):new J(n);e(r)}))));return()=>{n.forEach((e=>e()))}},Ji=e=>Qi((({code:t})=>{400312===t&&e()})),Yi={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,category:({categoryId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,poll:({pollId:e})=>e,reaction:({reactionId:e})=>e,stream:({streamId:e})=>e,follow:({from:e,to:t})=>`${e}#${t}`,followCount:({userId:e})=>e},Xi=e=>Yi[e],Gi={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",categories:"category",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",polls:"poll",reactions:"reaction",videoStreamings:"stream",follows:"follow",followCounts:"followCount"},Zi=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=Gi[e];if(!r)return;const o=Xi(r);n.forEach((e=>{Ue([r,"get",o(e)],e,t)}))}))},es=(e,t)=>{const n=X();return oe(n,e,e,(e=>{n.cache&&Zi(e),t(e.users[0])}))},ts=e=>es("user.deleted",e),ns=async e=>{const t=X();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};ns.locally=e=>{const t=X();return t.log("user/getUser.locally",e),t.cache&&Ne(["user","get",e])};const rs=async e=>{const t=X();t.log("user/getUsers",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/users/list",{params:{userIds:n}}),o=t.cache&&Date.now();return t.cache&&Zi(r,{cachedAt:o}),{data:r.users,cachedAt:o}};
|
|
6
|
+
var n=e("buffer"),o=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return o(e,t,r)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=n:(i(n,r),r.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=o(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},{buffer:17}],74:[function(e,t,r){function n(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(o(t)):null}function o(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}t.exports=n},{}],75:[function(e,t,r){var n=e("safe-buffer").Buffer,o=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function s(e){var t=i(e);if("string"!=typeof t&&(n.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=s(e),this.encoding){case"utf16le":this.text=p,this.end=m,t=4;break;case"utf8":this.fillLast=h,t=4;break;case"base64":this.text=g,this.end=y,t=3;break;default:return this.write=v,void(this.end=b)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function c(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e,t,r){var n=t.length-1;if(n<r)return 0;var o=c(t[n]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--n<r||-2===o?0:(o=c(t[n]))>=0?(o>0&&(e.lastNeed=o-2),o):--n<r||-2===o?0:(o=c(t[n]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}function u(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}function h(e){var t=this.lastTotal-this.lastNeed,r=u(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function f(e,t){var r=l(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function p(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function g(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function y(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function v(e){return e.toString(this.encoding)}function b(e){return e&&e.length?this.write(e):""}r.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},a.prototype.end=d,a.prototype.text=f,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":73}],76:[function(e,t,r){var n=e("punycode"),o=e("./util");function i(){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=_,r.resolveObject=k,r.format=C,r.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(l),h=["%","/","?",";","#"].concat(u),f=["/","?","#"],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},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");function w(e,t,r){if(e&&o.isObject(e)&&e instanceof i)return e;var n=new i;return n.parse(e,t,r),n}function C(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function _(e,t){return w(e,!1,!0).resolve(t)}function k(e,t){return e?w(e,!1,!0).resolveObject(t):t}i.prototype.parse=function(e,t,r){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",l=e.split(a),w=/\\/g;l[0]=l[0].replace(w,"/");var C=e=l.join(a);if(C=C.trim(),!r&&1===e.split("#").length){var _=c.exec(C);if(_)return this.path=C,this.href=C,this.pathname=_[1],_[2]?(this.search=_[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var k=s.exec(C);if(k){var S=(k=k[0]).toLowerCase();this.protocol=S,C=C.substr(k.length)}if(r||k||C.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===C.substr(0,2);!E||k&&y[k]||(C=C.substr(2),this.slashes=!0)}if(!y[k]&&(E||k&&!v[k])){for(var A,T,x=-1,I=0;I<f.length;I++)-1!==(O=C.indexOf(f[I]))&&(-1===x||O<x)&&(x=O);for(-1!==(T=-1===x?C.lastIndexOf("@"):C.lastIndexOf("@",x))&&(A=C.slice(0,T),C=C.slice(T+1),this.auth=decodeURIComponent(A)),x=-1,I=0;I<h.length;I++){var O;-1!==(O=C.indexOf(h[I]))&&(-1===x||O<x)&&(x=O)}-1===x&&(x=C.length),this.host=C.slice(0,x),C=C.slice(x),this.parseHost(),this.hostname=this.hostname||"";var R="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!R)for(var P=this.hostname.split(/\./),B=(I=0,P.length);I<B;I++){var N=P[I];if(N&&!N.match(p)){for(var j="",F=0,M=N.length;F<M;F++)N.charCodeAt(F)>127?j+="x":j+=N[F];if(!j.match(p)){var U=P.slice(0,I),L=P.slice(I+1),D=N.match(m);D&&(U.push(D[1]),L.unshift(D[2])),L.length&&(C="/"+L.join(".")+C),this.hostname=U.join(".");break}}}this.hostname.length>d?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=n.toASCII(this.hostname));var q=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+q,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==C[0]&&(C="/"+C))}if(!g[S])for(I=0,B=u.length;I<B;I++){var $=u[I];if(-1!==C.indexOf($)){var H=encodeURIComponent($);H===$&&(H=escape($)),C=C.split($).join(H)}}var V=C.indexOf("#");-1!==V&&(this.hash=C.substr(V),C=C.slice(0,V));var W=C.indexOf("?");if(-1!==W?(this.search=C.substr(W),this.query=C.substr(W+1),t&&(this.query=b.parse(this.query)),C=C.slice(0,W)):t&&(this.search="",this.query={}),C&&(this.pathname=C),v[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var K=this.search||"";this.path=q+K}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==i?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+n},i.prototype.resolve=function(e){return this.resolveObject(w(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var r=new i,n=Object.keys(this),s=0;s<n.length;s++){var a=n[s];r[a]=this[a]}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),l=0;l<c.length;l++){var u=c[l];"protocol"!==u&&(r[u]=e[u])}return v[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!v[e.protocol]){for(var h=Object.keys(e),f=0;f<h.length;f++){var d=h[f];r[d]=e[d]}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||y[e.protocol])r.pathname=e.pathname;else{for(var p=(e.pathname||"").split("/");p.length&&!(e.host=p.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),r.pathname=p.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var m=r.pathname||"",g=r.search||"";r.path=m+g}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var b=r.pathname&&"/"===r.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),C=w||b||r.host&&e.pathname,_=C,k=r.pathname&&r.pathname.split("/")||[],S=(p=e.pathname&&e.pathname.split("/")||[],r.protocol&&!v[r.protocol]);if(S&&(r.hostname="",r.port=null,r.host&&(""===k[0]?k[0]=r.host:k.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===p[0]?p[0]=e.host:p.unshift(e.host)),e.host=null),C=C&&(""===p[0]||""===k[0])),w)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,k=p;else if(p.length)k||(k=[]),k.pop(),k=k.concat(p),r.search=e.search,r.query=e.query;else if(!o.isNullOrUndefined(e.search))return S&&(r.hostname=r.host=k.shift(),(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),r.search=e.search,r.query=e.query,o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var E=k.slice(-1)[0],A=(r.host||e.host||k.length>1)&&("."===E||".."===E)||""===E,T=0,x=k.length;x>=0;x--)"."===(E=k[x])?k.splice(x,1):".."===E?(k.splice(x,1),T++):T&&(k.splice(x,1),T--);if(!C&&!_)for(;T--;T)k.unshift("..");!C||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),A&&"/"!==k.join("/").substr(-1)&&k.push("");var I,O=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(r.hostname=r.host=O?"":k.length?k.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),(C=C||r.host&&k.length)&&!O&&k.unshift(""),k.length?r.pathname=k.join("/"):(r.pathname=null,r.path=null),o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":77,punycode:51,querystring:54}],77:[function(e,t,r){t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],78:[function(e,t,r){(function(e){(function(){function r(e,t){if(n("noDeprecation"))return e;var r=!1;function o(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return o}function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=r}).call(this)}).call(this,void 0!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(e,t,r){function n(e,t){if(e&&t)return n(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){r[t]=e[t]})),r;function r(){for(var t=new Array(arguments.length),r=0;r<t.length;r++)t[r]=arguments[r];var n=e.apply(this,t),o=t[t.length-1];return"function"==typeof n&&n!==o&&Object.keys(o).forEach((function(e){n[e]=o[e]})),n}}t.exports=n},{}],80:[function(e,t,r){t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(e,t,r){t.exports=o;var n=Object.prototype.hasOwnProperty;function o(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var o in r)n.call(r,o)&&(e[o]=r[o])}return e}},{}],82:[function(e,t,r){t.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},{}],83:[function(e,t,r){function n(e){var t=this;if(t instanceof n||(t=new n),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,o=arguments.length;r<o;r++)t.push(arguments[r]);return t}function o(e,t,r){var n=t===e.head?new a(r,null,t,e):new a(r,t,t.next,e);return null===n.next&&(e.tail=n),null===n.prev&&(e.head=n),e.length++,n}function i(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function s(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,r,n){if(!(this instanceof a))return new a(e,t,r,n);this.list=n,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}t.exports=n,n.Node=a,n.create=n,n.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},n.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},n.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},n.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},n.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},n.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},n.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},n.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,n=0;null!==r;n++)e.call(t,r.value,n,this),r=r.next},n.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,n=this.length-1;null!==r;n--)e.call(t,r.value,n,this),r=r.prev},n.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},n.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},n.prototype.map=function(e,t){t=t||this;for(var r=new n,o=this.head;null!==o;)r.push(e.call(t,o.value,this)),o=o.next;return r},n.prototype.mapReverse=function(e,t){t=t||this;for(var r=new n,o=this.tail;null!==o;)r.push(e.call(t,o.value,this)),o=o.prev;return r},n.prototype.reduce=function(e,t){var r,n=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var o=0;null!==n;o++)r=e(r,n.value,o),n=n.next;return r},n.prototype.reduceReverse=function(e,t){var r,n=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var o=this.length-1;null!==n;o--)r=e(r,n.value,o),n=n.prev;return r},n.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},n.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},n.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=0,i=this.head;null!==i&&o<e;o++)i=i.next;for(;null!==i&&o<t;o++,i=i.next)r.push(i.value);return r},n.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new n;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=this.length,i=this.tail;null!==i&&o>t;o--)i=i.prev;for(;null!==i&&o>e;o--,i=i.prev)r.push(i.value);return r},n.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var n=0,i=this.head;null!==i&&n<e;n++)i=i.next;var s=[];for(n=0;i&&n<t;n++)s.push(i.value),i=this.removeNode(i);for(null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev),n=0;n<r.length;n++)i=o(this,i,r[n]);return s},n.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=t,this.tail=e,this};try{e("./iterator.js")(n)}catch(e){}},{"./iterator.js":82}]},{},[12])(12);var Wi=we(Vi.exports);var Ki;!function(e){e[e.IDENTIFIER_REJECTED=2]="IDENTIFIER_REJECTED",e[e.BAD_USERNAME_OR_PASSWORD=4]="BAD_USERNAME_OR_PASSWORD",e[e.NOT_AUTHORIZED=5]="NOT_AUTHORIZED"}(Ki||(Ki={}));const Qi=e=>{let t,r=0,n=!0;return{connect:async function(o){return t&&(t.removeAllListeners(),t.end(!0)),t=Wi.connect(e,function(e){return Object.assign({clean:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:0,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1}},e)}({username:o.userId,password:o.accessToken})),t.on("connect",(()=>{r=0,n=!0})),t.on("error",(e=>{switch(e.code){case 2:case 4:case 5:n=!1}})),t.on("close",(()=>{n&&setTimeout((()=>{r+=1,t.reconnect()}),1e3*2**(r>10?10:r))})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(n=!1,this.connected)return new Promise((e=>null==t?void 0:t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,r){null==t||t.on(e,r)},once(e,r){null==t||t.once(e,r)},off(e,r){void 0!==r?null==t||t.off(e,r):null==t||t.removeAllListeners(e)},removeAllListeners(){null==t||t.removeAllListeners()},subscribe(e,r){const n=(t,n)=>{if(t||128===n[0].qos){const n=t?new Y(t.message,8e5,"error"):new Z(8e5,"error");console.error(`Failed to subscribe to topic ${e}`,n),null==r||r(n)}else console.log(`Subscribed to topic ${n[0].topic}`),null==r||r()};return t?t.subscribe(e,{qos:0},n):n(new Error("No connection to broker"),[]),()=>null==t?void 0:t.unsubscribe(e)},unsubscribe(e){null==t||t.unsubscribe(e)}}},Ji=async()=>{const e=re();return e.log("client/api/disconnectClient"),await new Promise((t=>{e.ws.once("disconnect",t),e.ws.disconnect(),e.mqtt.disconnect()})),e.emitter.all.clear(),e.ws.removeAllListeners(),e.mqtt.removeAllListeners(),e.userId=void 0,e.accessToken=void 0,!e.ws.connected},Xi=()=>`ascWebSdk#${Math.random().toString(16)}`,Yi=()=>{const e=(()=>{var e,t;return(null===(e=n.versions)||void 0===e?void 0:e.node)?n.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}},Gi=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],Zi=e=>{const t=re(),r=Gi.map((r=>le(t,`client/onConnectionError(${r})`,r,(t=>{const n=(null==t?void 0:t.code)?new Y(t.message,t.code,"fatal"):new ee(r);e(n)}))));return()=>{r.forEach((e=>e()))}},es=e=>Zi((({code:t})=>{400312===t&&e()})),ts=(e={},t)=>{Object.entries(e).forEach((([e,r])=>{const n=q[e];if(!n)return;const o=U(n);r.forEach((e=>{$e([n,"get",o(e)],e,t)}))}))},rs=(e,t)=>{const r=re();return le(r,e,e,(e=>{r.cache&&ts(e),t(e.users[0])}))},ns=e=>rs("user.deleted",e),os=async e=>{const t=re();t.log("user/getUser",e);const{data:r}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{users:o}=r;return{data:o.find((t=>t.userId===e)),cachedAt:n}};os.locally=e=>{const t=re();return t.log("user/getUser.locally",e),t.cache&&De(["user","get",e])};const is=async e=>{const t=re();t.log("user/getUsers",e);const r=e.map((e=>encodeURIComponent(e))),{data:n}=await t.http.get("/api/v3/users/list",{params:{userIds:r}}),o=t.cache&&Date.now();return t.cache&&ts(n,{cachedAt:o}),{data:n.users,cachedAt:o}};
|
|
7
7
|
/*! *****************************************************************************
|
|
8
8
|
Copyright (c) Microsoft Corporation.
|
|
9
9
|
|
|
@@ -18,4 +18,4 @@ var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s
|
|
|
18
18
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
19
|
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
|
-
function os(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}rs.locally=e=>{var t;const n=X();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>Ne(["user","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const is=async(e={})=>{const t=X();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=os(e,["page","displayName","filter","sortBy"]),{data:a}=await t.http.get("/api/v3/users",{params:Object.assign(Object.assign({},s),{keyword:r,filter:o,sortBy:i,options:{token:F(n,"skiplimit")}})}),{paging:c}=a,l=os(a,["paging"]),{users:u}=l,h=t.cache&&Date.now();if(t.cache){Zi(l,{cachedAt:h});je(["user","query",e],{users:u.map(Xi("user")),paging:c})}return{data:u,cachedAt:h,prevPage:N(c.previous),nextPage:N(c.next)}};is.locally=(e={})=>{var t,n,r;const o=X();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=Ne(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>Ne(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],l=N(null==s?void 0:s.paging.previous),u=N(null==s?void 0:s.paging.next);return c.length>0&&c.length===(null===(r=null==s?void 0:s.users)||void 0===r?void 0:r.length)?{data:c,cachedAt:a,prevPage:l,nextPage:u}:void 0};const ss=e=>es("user.updated",e),as=e=>es("user.flagged",e),cs=e=>es("user.unflagged",e),ls=e=>es("user.flagCleared",e),us=async e=>{const t=X();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&Zi({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};us.locally=e=>{const t=X();if(t.log("file/getFile.locally",e),!t.cache)return;const n=Ne(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const hs=async e=>{const t=X();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=os(n,["page","displayName","sortBy"]),{data:a}=await t.http.get("/api/v3/roles",{params:Object.assign(Object.assign({},s),{keyword:o,sortBy:i,options:{token:F(r,"skiplimit")}})}),{paging:c}=a,l=os(a,["paging"]),{roles:u}=l,h=t.cache&&Date.now();t.cache&&Zi(l,{cachedAt:h});const f=N(c.next);return{data:u,cachedAt:h,prevPage:N(c.previous),nextPage:f}};hs.locally=e=>{X().log("role/queryRoles.locally",e)};const fs=async e=>{const t=X();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&Zi({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};fs.locally=e=>{const t=X();if(t.log("role/getRole.locally",e),!t.cache)return;const n=Ne(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ps=(e,t)=>{"message"===e?ie("v3.message.didUpdate",{messages:[t]}):"post"===e?ie("post.updated",{posts:[t]}):"comment"===e&&ie("comment.updated",{comments:[t]})},ds=async e=>{const t=X();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};ds.locally=e=>{const t=X();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=Ne(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ms=async e=>{const t=X();t.log("message/getMessages",e);const{data:n}=await t.http.get("/api/v3/messages/list",{params:{messageIds:e}}),r=t.cache&&Date.now();return t.cache&&Zi(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};ms.locally=e=>{var t;const n=X();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>Ne(["message","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const gs=async e=>{const t=X();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=os(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:F(n,"afterbefore")}})}),{paging:i}=o,s=os(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){Zi(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];je(e,{messages:a.map(Xi("message")),paging:i})}const l=N(i.next);return{data:a,cachedAt:c,prevPage:N(i.previous),nextPage:l}};gs.locally=e=>{var t,n;const r=X();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=os(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=Ne(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const l=a.messages.map((e=>Ne(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),u=N(null==a?void 0:a.paging.previous),h=N(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const ys=async e=>{const t=X();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};ys.optimistically=e=>{var t,n;const r=X();if(r.log("user/createMessage.locally",e),!r.cache)return;const o=Ne(["channel","get",e.channelId]);Ue(["channel","get",e.channelId],Object.assign(Object.assign({},null==o?void 0:o.data),{messageCount:(null!==(t=null==o?void 0:o.data.messageCount)&&void 0!==t?t:0)+1}));const i=Object.assign({messageId:Math.random().toString(16),userId:r.userId,channelSegment:(null!==(n=null==o?void 0:o.data.messageCount)&&void 0!==n?n:0)+1,createdAt:(new Date).toISOString()},e);return je(["message","get",i.messageId],i,{cachedAt:-1}),ie("v3.message.didCreate",{messages:[i]}),{data:i,cachedAt:-1}};const vs=async(e,t)=>{const n=X();n.log("user/updateMessage",t);const{data:r}=await n.http.put(`/api/v3/messages/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};vs.optimistically=(e,t)=>{const n=X();if(n.log("user/updateMessage",t),!n.cache)return;const r=Ne(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return Ue(["message","get",e],o,{cachedAt:-1}),ie("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const bs=async e=>{const t=X();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await ds(e)).data};bs.optimistically=e=>{X().log("message/deleteMessage",e);const t=Ne(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return Ue(["message","get",e],n,{cachedAt:-1}),ie("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const ws=async e=>{const t=X();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=os(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:F(n,"afterbeforeraw")}})}),{paging:i}=o,s=os(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){Zi(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];je(e,{posts:a.map(Xi("post")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};ws.locally=e=>{var t,n;const r=X();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=os(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=Ne(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const l=a.posts.map((e=>Ne(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const Cs=async e=>{const t=X();t.log("post/getPosts",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/posts/list",{params:{postIds:n}}),o=t.cache&&Date.now();return t.cache&&Zi(r,{cachedAt:o}),{data:r.posts,cachedAt:o}};Cs.locally=e=>{var t;const n=X();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>Ne(["post","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const _s=async e=>{const t=X();let n;t.log("post/getPost",e);try{n=(await t.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&Le(["post","get",e],!0),t}const r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{posts:o}=n;return{data:o.find((t=>t.postId===e)),cachedAt:r}};_s.locally=e=>{const t=X();if(t.log("post/getPost.locally",e),!t.cache)return;const n=Ne(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ks=async e=>{const t=X();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=os(n,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/communities",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:F(r,"skiplimit")}})}),{paging:c}=a,l=os(a,["paging"]),{communities:u}=l,h=t.cache&&Date.now();if(t.cache){Zi(l,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];je(e,{communities:u.map(Xi("community")),paging:c})}const f=N(c.next);return{data:u,cachedAt:h,prevPage:N(c.previous),nextPage:f}};ks.locally=e=>{X().log("community/queryCommunities.locally",e)};const Ss=async e=>{const t=X();t.log("community/getCommunities",e);const{data:n}=await t.http.get("/api/v3/communities/list",{params:{communityIds:e}}),r=t.cache&&Date.now();return t.cache&&Zi(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};Ss.locally=e=>{var t;const n=X();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>Ne(["community","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Es=async e=>{const t=X();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};Es.locally=e=>{const t=X();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=Ne(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const As=async e=>{const t=X();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=os(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:F(r,"skiplimit")}})}),{paging:a}=s,c=os(s,["paging"]),{communityUsers:l}=c,u=t.cache&&Date.now();t.cache&&Zi(c,{cachedAt:u});return{data:l,cachedAt:u,nextPage:N(a.next),prevPage:N(a.previous)}};As.locally=e=>{X().log("community/queryCommunityMembers",e)};const Ts=async e=>{const t=X();t.log("channel/getTopTrendingCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/top-trending",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){Zi(r,{cachedAt:i});je(["community","top-trending",{params:{options:{limit:n}}}],{communities:o.map(Xi("community"))})}return{data:o,cachedAt:i}};Ts.locally=e=>{var t,n;const r=X();if(r.log("community/getTopTrendingCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","top-trending",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=Ne(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>Ne(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const xs=async e=>{const t=X();t.log("channel/getRecommendedCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/recommended",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){Zi(r,{cachedAt:i});je(["community","recommended",{params:{options:{limit:n}}}],{communities:o.map(Xi("community"))})}return{data:o,cachedAt:i}};xs.locally=e=>{var t,n;const r=X();if(r.log("community/getRecommendedCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","recommended",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=Ne(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>Ne(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const Is=async e=>{const t=X();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=os(e,["page"]),{data:o}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:{token:F(n,"afterbefore")}})}),{paging:i}=o,s=os(o,["paging"]),{comments:a}=s,c=t.cache&&Date.now();if(t.cache){Zi(s,{cachedAt:c});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];je(e,{comments:a.map(Xi("comment")),paging:i})}const l=N(i.next);return{data:a,cachedAt:c,prevPage:N(i.previous),nextPage:l}};Is.locally=e=>{var t,n;const r=X();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=os(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=Ne(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const l=a.comments.map((e=>Ne(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),u=N(null==a?void 0:a.paging.previous),h=N(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const Os=async e=>{const t=X();t.log("comment/getComments",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/comments/list",{params:{commentIds:n}}),o=t.cache&&Date.now();return t.cache&&Zi(r,{cachedAt:o}),{data:r.comments,cachedAt:o}};Os.locally=e=>{var t;const n=X();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>Ne(["comment","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Rs=async e=>{const t=X();let n;t.log("comment/getComment",e);try{n=(await t.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&Le(["comment","get",e],!0),t}const r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{comments:o}=n;return{data:o.find((t=>t.commentId===e)),cachedAt:r}};Rs.locally=e=>{const t=X();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=Ne(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ps=async(e,t)=>{if("message"===e)return ds(t);if("post"===e)return _s(t);if("comment"===e)return Rs(t);throw new Error(`Incorrect referenceType: ${e}`)},Bs=(e,t)=>{var n,r;if(X().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=Ne(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=Ne(["comment","get",e.commentId]))||void 0===r?void 0:r.data,o=e}if(i&&i.myReactions)if("post.addReaction"===e||"comment.addReaction"===e){if(i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:[...i.myReactions,t.reactor.reactionName]})}else{if(!i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:i.myReactions.filter((e=>e!==t.reactor.reactionName))})}},Fs=async(e,t,n)=>{var r,o;const i=X();i.log("reaction/createReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.post("/api/v2/reactions",{referenceId:t,referenceType:e,reactionName:n});const s=await Ps(e,t);return ps(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};Fs.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=X();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=Ne([e,"get",t]);if(!(null==l?void 0:l.data)||(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:l.data.reactionsCount+1,myReactions:[...null!==(o=l.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)+1})});return Ue([e,"get",t],u,{cachedAt:-1}),ps(e,u),null!==(a=null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const Ns=async(e,t,n)=>{var r,o;const i=X();i.log("reaction/removeReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.delete("/api/v2/reactions",{data:{referenceId:t,referenceType:e,reactionName:n}});const s=await Ps(e,t);return ps(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};Ns.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=X();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=Ne([e,"get",t]);if(!(null==l?void 0:l.data)||!(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:Math.max(0,l.data.reactionsCount-1),myReactions:(null!==(o=l.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:Math.max(0,(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)-1)})});return Ue([e,"get",t],u,{cachedAt:-1}),ps(e,u),null!==(a=!(null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};const js=(e,t)=>{const n=X();return oe(n,e,e,(r=>{var o;if(n.cache){const{communities:n}=r,i=os(r,["communities"]);Zi(i),(null==n?void 0:n[0])&&!["post.updated"].includes(e)&&ie("community.updated",{communities:n});const s=Ne(["post","get",r.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=Fe(["post","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.targetId)===s.data.targetId}));"post.declined"===e&&(t=null==t?void 0:t.filter((({key:e})=>{var t;return"reviewing"===(null===(t=e[2])||void 0===t?void 0:t.feedType)}))),null==t||t.map((({key:e,data:t})=>Ue(e,t,{cachedAt:-1})))}t(s.data)}else t(r.posts[0])}))},Ms=e=>js("post.created",e),Us=e=>js("post.updated",e),Ls=e=>js("post.deleted",e),Ds=e=>js("post.approved",e),qs=e=>js("post.declined",e),zs=e=>js("post.flagged",e),$s=e=>js("post.unflagged",e),Hs=e=>{const t=X();return oe(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){Bs("post.addReaction",n);const t=os(n,["reactor"]);Zi(t);const r=Ne(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},Vs=e=>{const t=X();return oe(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){Bs("post.removeReaction",n);const t=os(n,["reactor"]);Zi(t);const r=Ne(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},Ws=(e,t)=>{const n=X();return oe(n,e,e,(r=>{var o;if(n.cache){Zi(r);const n=Ne(["comment","get",r.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=Fe(["comment","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.referenceId)===n.data.referenceId}));null==e||e.map((({key:e,data:t})=>Ue(e,t,{cachedAt:-1})))}t(n.data)}else t(r.comments[0])}))},Ks=e=>Ws("comment.created",e),Qs=e=>Ws("comment.updated",e),Js=e=>Ws("comment.deleted",e),Ys=e=>Ws("comment.flagged",e),Xs=e=>Ws("comment.unflagged",e),Gs=e=>{const t=X();return oe(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){Bs("comment.addReaction",n);const t=os(n,["reactor"]);Zi(t);const r=Ne(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},Zs=e=>{const t=X();return oe(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){Bs("comment.removeReaction",n);const t=os(n,["reactor"]);Zi(t);const r=Ne(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))};var ea={post:{domainName:"posts",eventName:"v3/post.isflagbyme",primaryKey:"postId"},comment:{domainName:"comments",eventName:"v3/comment.isflagbyme",primaryKey:"commentId"},message:{domainName:"messages",eventName:"v3/message.isFlaggedByMe",primaryKey:"messageId"},user:{domainName:"users",eventName:"user.isFlagByMe",primaryKey:"userId"}};const ta=async e=>{const t=X();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=os(n,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/channels",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:F(r,"skiplimit")}})}),{paging:c}=a,l=os(a,["paging"]),{channels:u}=l,h=t.cache&&Date.now();if(t.cache){Zi(l,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];je(e,{channels:u.map(Xi("channel")),paging:c})}const f=N(c.next);return{data:u,cachedAt:h,prevPage:N(c.previous),nextPage:f}};ta.locally=e=>{X().log("channel/queryChannels.locally",e)};const na=async e=>{const t=X();t.log("channel/getChannels",e);const n=e.map((e=>encodeURIComponent(e))),{data:r}=await t.http.get("/api/v3/channels/list",{params:{channelIds:n}}),o=t.cache&&Date.now();return t.cache&&Zi(r,{cachedAt:o}),{data:r.channels,cachedAt:o}};na.locally=e=>{var t;const n=X();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>Ne(["channel","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ra=async e=>{const t=X();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};ra.locally=e=>{const t=X();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=Ne(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const oa=async e=>{const t=X();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o,membership:i}=n,s=os(n,["page","channelId","membership"]),{data:a}=await t.http.get(`/api/v3/channels/${encodeURIComponent(o)}/users`,{params:Object.assign(Object.assign({},s),{filter:i,options:{token:F(r,"skiplimit")}})}),{paging:c}=a,l=os(a,["paging"]),{channelUsers:u}=l,h=t.cache&&Date.now();t.cache&&Zi(l);return{data:u,cachedAt:h,nextPage:N(c.next),prevPage:N(c.previous)}};oa.locally=e=>{X().log("channel/queryChannelMembers",e)};const ia=e=>{const t=X();return oe(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{Zi(t),e(t.channels[0])}))},sa=e=>{const t=X();return oe(t,"onChannelDeleted","v3.channel.didDelete",(t=>{Zi(t),e(t.channels[0])}))},aa=e=>{const t=X();return oe(t,"onChannelJoined","v3.channel.didJoin",(t=>{Zi(t),e(t.channels[0])}))},ca=e=>{const t=X();return oe(t,"onChannelLeft","v3.channel.didLeave",(t=>{Zi(t),e(t.channels[0])}))},la=e=>{const t=X();return oe(t,"onChannelMemberAdded","v3.channel.didAddUsers",(t=>{Zi(t),e(t.channels[0],t.channelUsers[0])}))},ua=e=>{const t=X();return oe(t,"onChannelMemberRemoved","v3.channel.didRemoveUsers",(t=>{Zi(t),e(t.channels[0],t.channelUsers[0])}))},ha=e=>{const t=X();return oe(t,"message/onMessageCreated","v3.message.didCreate",(t=>{Zi(t),e(t.messages[0])}))},fa=e=>{const t=X();return oe(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{Zi(t),e(t.messages[0])}))},pa=e=>{const t=X();return oe(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{Zi(t),e(t.messages[0])}))},da=(e,t)=>{const n=X();return oe(n,e,e,(e=>{if(n.cache){Zi(e);const n=Ne(["community","get",e.communities[0].communityId]);t(n.data)}else t(e.communities[0])}))};function ma(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function ga(e,t){return"community.joined"===e||"community.left"===e?t.communityUsers[0]:"community.userRemoved"===e?t.communityUsers.filter((e=>"none"===e.communityMembership))[0]:"community.userBanned"===e?t.communityUsers.filter((e=>"banned"===e.communityMembership))[0]:"community.userUnbanned"===e?t.communityUsers.filter((e=>!ma(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!ma(e,t,"ADD_COMMUNITY_USER")))[0]}const ya=(e,t)=>{const n=X();return oe(n,e,e,(r=>{if(n.cache){Zi(r);const n=Ne(["community","get",r.communities[0].communityId]),o=Ne(["communityUsers","get",Xi("communityUsers")(ga(e,r))]);t(n.data,o.data)}else t(r.communities[0],ga(e,r))}))},va=e=>da("community.updated",e),ba=e=>da("community.deleted",e),wa=e=>ya("community.joined",e),Ca=e=>ya("community.left",e),_a=e=>ya("community.userAdded",e),ka=e=>ya("community.userRemoved",e),Sa=e=>ya("community.userBanned",e),Ea=e=>ya("community.userUnbanned",e),Aa=async e=>{const t=X();t.log("category/queryCategories",e);const n=null!=e?e:{},{page:r={limit:10}}=n,o=os(n,["page"]),{data:i}=await t.http.get("/api/v3/community-categories",{params:Object.assign(Object.assign({},o),{options:{token:F(r,"skiplimit")}})}),{paging:s}=i,a=os(i,["paging"]),{categories:c}=a,l=t.cache&&Date.now();if(t.cache){Zi(a,{cachedAt:l});const e=["category","query",Object.assign(Object.assign({},o),{options:Object.assign({},r)})];je(e,{categories:c.map(Xi("category")),paging:s})}const u=N(s.next);return{data:c,cachedAt:l,prevPage:N(s.previous),nextPage:u}};Aa.locally=e=>{var t,n;const r=X();if(r.log("category/queryCategories.locally",e),!r.cache)return;const o=null!=e?e:{},{page:i={limit:10}}=o,s=os(o,["page"]),a=["category","query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(t=Ne(a))&&void 0!==t?t:{};if(!(null==c?void 0:c.categories.length))return;const u=c.categories.map((e=>Ne(["category","get",e]))).filter(Boolean).map((({data:e})=>e)),h=N(null==c?void 0:c.paging.previous),f=N(null==c?void 0:c.paging.next);return u.length===(null===(n=null==c?void 0:c.categories)||void 0===n?void 0:n.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const Ta=async e=>{const t=X();t.log("category/getCategory",e);const{data:n}=await t.http.get(`/api/v3/community-categories/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{categories:o}=n;return{data:o.find((t=>t.categoryId===e)),cachedAt:r}};Ta.locally=e=>{const t=X();if(t.log("category/getCategory.locally",e),!t.cache)return;const n=Ne(["category","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const xa=async e=>{const t=X();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{useCustomRanking:r,page:o}=n,i=os(n,["useCustomRanking","page"]),{data:s}=await t.http.get(r?"/api/v5/me/global-feeds":"/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},i),{options:{token:F(o,"skiplimit")}})}),{paging:a}=s,c=os(s,["paging"]),{posts:l}=c,u=t.cache&&Date.now();if(t.cache){Zi(c);const e=["globalFeed","query",Object.assign(Object.assign({},i),{useCustomRanking:r,options:Object.assign({},o)})];je(e,{posts:l.map(Xi("post")),paging:a})}const h=N(a.next);return{data:l,cachedAt:u,prevPage:N(a.previous),nextPage:h}};xa.locally=e=>{var t,n;const r=X();if(r.log("post/queryGlobalFeed.locally",e),!r.cache)return;const o=null!=e?e:{},{useCustomRanking:i,page:s}=o,a=os(o,["useCustomRanking","page"]),c=["globalFeed","query",Object.assign(Object.assign({},a),{useCustomRanking:i,options:Object.assign({},s)})],{data:l,cachedAt:u}=null!==(t=Ne(c))&&void 0!==t?t:{};if(!(null==l?void 0:l.posts.length))return;const h=l.posts.map((e=>Ne(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),f=N(null==l?void 0:l.paging.previous),p=N(null==l?void 0:l.paging.next);return h.length===(null===(n=null==l?void 0:l.posts)||void 0===n?void 0:n.length)?{data:h,cachedAt:u,prevPage:f,nextPage:p}:void 0};const Ia=async(e,t)=>{const n=X();n.log(`follow/queryF${e.substring(1)}`,t);const{userId:r,page:o}=t,i=os(t,["userId","page"]),{data:s}=await n.http.get(n.userId===r?`/api/v4/me/${e}`:`/api/v4/users/${r}/${e}`,{params:Object.assign(Object.assign({},i),{token:F(o,"skiplimit")})}),{paging:a}=s,c=os(s,["paging"]),{follows:l}=c,u=n.cache&&Date.now();if(n.cache){Zi(c,{cachedAt:u});const t=[e,"query",Object.assign(Object.assign({},i),{userId:r,options:Object.assign({},o)})];je(t,{follows:l.map(Xi("follow")),paging:a})}const h=N(a.next);return{data:l,cachedAt:u,prevPage:N(a.previous),nextPage:h}};Ia.locally=(e,t)=>{var n,r;const o=X();if(o.log(`follow/queryF${e.substring(1)}.locally`,t),!o.cache)return;const{page:i}=t,s=os(t,["page"]),a=[e,"query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(n=Ne(a))&&void 0!==n?n:{};if(!(null==c?void 0:c.follows.length))return;const u=c.follows.map((e=>Ne(["follow","get",e]))).filter(Boolean).map((({data:e})=>e)),h=N(null==c?void 0:c.paging.previous),f=N(null==c?void 0:c.paging.next);return u.length===(null===(r=null==c?void 0:c.follows)||void 0===r?void 0:r.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const Oa=async e=>Ia("followers",e);Oa.locally=e=>Ia.locally("followers",e);const Ra=async e=>Ia("following",e);Ra.locally=e=>Ia.locally("following",e);const Pa=e=>["followInfo","get",`${X().userId}#${e}`],Ba=async e=>{var t,n;const r=X();r.log("follow/getFollowInfo",e);const{data:o}=await r.http.get(r.userId===e?"/api/v4/me/followInfo":`/api/v4/users/${e}/followInfo`),i=r.cache&&Date.now(),s=Object.assign(Object.assign({},o.followCounts[0]),{status:null===(n=null===(t=o.follows)||void 0===t?void 0:t[0])||void 0===n?void 0:n.status});return r.cache&&je(Pa(e),s,{cachedAt:i}),{data:s,cachedAt:i}};Ba.locally=e=>{const t=X();if(t.log("follow/getFollowInfo.locally",e),!t.cache)return;const n=Ne(Pa(e));return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Fa=(e,t)=>{const n=X();return oe(n,e,e,(e=>{var r,o;if(n.cache){Zi({follows:[e]});[...null!==(r=Fe(["followers","query"]))&&void 0!==r?r:[],...null!==(o=Fe(["followings","query"]))&&void 0!==o?o:[]].filter((({key:t})=>t[2].userId===e.from||t[2].userId===e.to)).forEach((({key:e,data:t})=>Ue(e,t,{cachedAt:-1}))),t(e)}else t(e)}))},Na=e=>Fa("follow.created",e),ja=e=>Fa("follow.unfollowed",e),Ma=e=>Fa("follow.followerDeleted",e),Ua=e=>Fa("follow.requested",e),La=e=>Fa("follow.requestCanceled",e),Da=e=>Fa("follow.accepted",e),qa=e=>Fa("follow.requestDeclined",e),za=e=>{const t=async t=>{const[{data:n},{data:r}]=await Promise.all([Ba(t.from),Ba(t.to)]);e(n),e(r)},n=[Fa("follow.created",t),Fa("follow.requested",t),Fa("follow.accepted",t),Fa("follow.unfollowed",t),Fa("follow.requestCanceled",t),Fa("follow.requestDeclined",t),Fa("follow.followerDeleted",t)];return()=>{n.forEach((e=>e()))}},$a=async e=>{const t=X();t.log("poll/getPoll",e);const{data:n}=await t.http.get(`/api/v3/polls/${e}`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}};$a.locally=e=>{const t=X();if(t.log("poll/getPoll",e),!t.cache)return;const n=Ne(["poll","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ha=async e=>{const t=X();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};Ha.locally=e=>{const t=X();if(t.log("stream/getStream",e),!t.cache)return;const n=Ne(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Va=async e=>{const t=X();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=os(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:F(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,l=t.cache&&Date.now();t.cache&&Zi(a,{cachedAt:l});const u=N(s.next);return{data:c,cachedAt:l,prevPage:N(s.previous),nextPage:u}};Va.locally=e=>{X().log("stream/queryStreams.locally",e)};return e.API_REGIONS=Xe,e.VERSION=a,e.acceptFollower=async e=>{const t=X();t.log("follow/acceptFollower",e);const{data:n}=await t.http.post(`/api/v4/me/followers/${e}`);return t.cache&&Zi(n),ie("follow.accepted",n.follows[0]),!0},e.addChannelMembers=async(e,t)=>{const n=X();n.log("channel/addChannelMembers",e,t);const{data:r}=await n.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users`,{channelId:e,userIds:t});n.cache&&Zi(r),ie("v3.channel.didAddUsers",{channels:r.channels,channelUsers:r.channelUsers});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=X();r.log("channel/addChannelMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{channelId:e,role:t,userIds:n});r.cache&&Zi(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=X();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&Zi(r),ie("community.userAdded",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRoles=async(e,t,n)=>{const r=X();r.log("community/addCommunityMembersRoles",e,t,n);const{data:o}=await r.http.post(`/api/v4/communities/${e}/users/roles`,{communityId:e,roles:t,userIds:n});r.cache&&Zi(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&t.some((e=>n.roles.includes(e)))))},e.addReaction=Fs,e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=X();if(!r)return!1;n("cache/api/backupCache",{storageKey:e});const i=Object.fromEntries(Object.entries(r.data).filter((([e,n])=>t(n))));return!!Object.keys(i).length&&(await Oe.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.closePoll=async e=>{const t=X();t.log("user/closePoll",e);const{data:n}=await t.http.put(`/api/v3/polls/${encodeURIComponent(e)}`,{status:"closed"}),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}},e.connectClient=async e=>{var t;const n=X();n.log("client/api/connectClient",Object.assign({apiKey:n.apiKey},e)),null!==(t=e.deviceId)&&void 0!==t||(e.deviceId=Vi());const{accessToken:r,users:o}=await(async e=>{const t=X();t.log("client/api/getToken",e);const n=await Wi(),{data:r}=await t.http.post("/v1/device",Object.assign(Object.assign({},e),{deviceInfo:n}),{headers:{"X-API-Key":t.apiKey}});return r})(e);var i,s,a;n.http.defaults.headers.common.Authorization=`Bearer ${r}`,n.ws.io.opts.query={token:r},i=n.ws,s=n.emitter,te.forEach((e=>{i.on(e,(t=>s.emit(e,t)))})),await new Promise((e=>{n.ws.once("connect",e),n.ws.open()})),n.userId=e.userId,n.accessToken=r,a=o[0],se={_id:a._id,userId:a.userId,path:a.path},pe(ue());const c=[Ji((()=>{Hi(),c.forEach((e=>e()))})),ts((()=>null))];return n.ws.connected},e.createChannel=async e=>{const t=X();let n;t.log("user/createChannel",e),n="conversation"===(null==e?void 0:e.type)?await t.http.post("/api/v3/channels/conversation",Object.assign(Object.assign({},e),{isDistinct:!0})):await t.http.post("/api/v3/channels",e);const r=t.cache&&Date.now();t.cache&&Zi(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=Xe.SG,n="amity")=>{const r=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&!o,n=Ye(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(n);r("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiRegion:t});const i=An(Ze("http",t)),s=(e=>{const t=Li(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(Ze("http",t)),c=$i(Ze("mqtt",t)),l=re(),u={version:`${a}`,apiKey:e,log:r,http:i,ws:s,mqtt:c,emitter:l,use:()=>G(u)};try{X()}catch(e){G(u)}return u},e.createComment=async e=>{const t=X();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const o=await _s(e.referenceId);ie("post.updated",{posts:[o.data]}),ie("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=X();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r}),ie("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=X();if(n.log("file/createFile",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Zi({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createImage=async(e,t)=>{const n=X();if(n.log("file/createImage",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/images",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Zi({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createMessage=ys,e.createPoll=async e=>{const t=X();t.log("post/createPoll",e);const{data:n}=await t.http.post("/api/v3/polls",e),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{polls:o}=n;return{data:o[0],cachedAt:r}},e.createPost=async e=>{const t=X();t.log("post/createPost",e),e.dataType&&!["text","image","file","video"].includes(e.dataType)||delete e.dataType;const{data:n}=await t.http.post("/api/v4/posts",e),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r}),ie("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=z,e.createReport=async(e,t)=>{const n=X();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=ea[e],{data:o}=await n.http.post(`/api/v3/${r}/${encodeURIComponent(t)}/flag`);n.cache&&Zi(o);return ie("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=X();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.createUserToken=async(e,t,n)=>{const r=Vi(),o=await Wi(),i=An(Ze("http",t)),{data:s}=await i.post("/api/v3/sessions",Object.assign(Object.assign({},n),{deviceId:r,deviceInfo:Object.assign(Object.assign({},o),{model:"token management API on TS-SDK"})}),{headers:{"X-API-Key":e}});return{accessToken:s.accessToken}},e.createVideo=async(e,t)=>{const n=X();if(n.log("file/createVideo",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/videos",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Zi({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.declineFollower=async e=>{const t=X();t.log("follow/declineFollower",e);const{data:n}=await t.http.delete(`/api/v4/me/followers/${e}`);return t.cache&&Zi(n),ie("follow.requestDeclined",n.follows[0]),!0},e.deleteChannel=async e=>{const t=X();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await ra(e)).data},e.deleteComment=async(e,t=!1)=>{const n=X();n.log("comment/deleteComment",e);const r=await Rs(e);await n.http.delete(`/api/v4/comments/${encodeURIComponent(e)}`,{params:{commentId:e,permanent:t}});const o=Object.assign(Object.assign({},r.data),{isDeleted:!0}),i=await _s(r.data.referenceId);return ie("post.updated",{posts:[i.data]}),ie("comment.deleted",{comments:[o]}),t?setTimeout((()=>{Le(["comment","get",e],!0)}),0):Ue(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=X();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await Es(e);return ie("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=X();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),Le(["file","get",e],!0),{success:!0}},e.deleteMessage=bs,e.deletePoll=async e=>{const t=X();t.log("poll/deletePoll",e);const n=await $a(e),{data:r}=await t.http.delete(`/api/v3/polls/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Ue(["poll","get",e],i),o},e.deletePost=async(e,t=!1)=>{const n=X();n.log("post/deletePost",e);const r=await _s(e);if(await n.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await Es(r.data.targetId);ie("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return ie("post.deleted",{posts:[o]}),t?setTimeout((()=>{Le(["post","get",e],!0)}),0):Ue(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=X();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=ea[e],{data:o}=await n.http.delete(`/api/v3/${r}/${encodeURIComponent(t)}/unflag`);n.cache&&Zi(o);return ie("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=X();t.log("stream/deleteStream",e);const n=await Ha(e),{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Ue(["stream","get",e],i),o},e.disableCache=()=>{const e=X();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=Hi,e.disposeStream=async e=>{const t=X();t.log("stream/disposeStream",e);const{data:n}=await t.http.delete(`/api/v3/video-streaming/${e}/streaming-url`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=Le,e.enableCache=(e={},t)=>{const n=X();n.cache||(n.log("cache/api/enableCache"),n.cache={data:e,persistIf:t})},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=(e,t,n)=>void 0!==n?e.filter((e=>e[t]===n)):e,e.follow=async e=>{const t=X();t.log("follow/follow",e);const{data:n}=await t.http.post(`/api/v4/me/following/${e}`),r=t.cache&&Date.now();return t.cache&&Zi(n,{cachedAt:r}),ie("accepted"===n.follows[0].status?"follow.created":"follow.requested",n.follows[0]),{data:n.follows[0],cachedAt:r}},e.getActiveClient=X,e.getCategory=Ta,e.getChannel=ra,e.getChannels=na,e.getComment=Rs,e.getCommentTopic=({path:e})=>e,e.getComments=Os,e.getCommunities=Ss,e.getCommunity=Es,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>le(t,n),e.getFile=us,e.getFollowInfo=Ba,e.getMessage=ds,e.getMessages=ms,e.getMyFollowersTopic=()=>{const e=ae(),[t]=e.path.split("/user/");return`${t}/membership/${e._id}/+/+`},e.getMyFollowingsTopic=()=>{const e=ae(),[t]=e.path.split("/user/");return`${t}/membership/+/${e._id}/+`},e.getNetworkTopic=ue,e.getPoll=$a,e.getPost=_s,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=Cs,e.getRecommendedCommunities=xs,e.getRole=fs,e.getStream=Ha,e.getTopTrendingCommunities=Ts,e.getUser=ns,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>le(n===e.SubscriptionLevels.USER?t:t.replace(/^(\w*)/,"$1/social"),n),e.getUsers=rs,e.isAfterBefore=R,e.isAfterBeforeRaw=P,e.isCachable=D,e.isConnected=()=>{var e,t;const n=X();return n.log("client/api/isConnected",n),!!(n.userId&&(null===(t=null===(e=n.http.defaults.headers.common)||void 0===e?void 0:e.Authorization)||void 0===t?void 0:t.length)&&n.ws.connected)},e.isFetcher=M,e.isFresh=q,e.isLocal=e=>D(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=U,e.isOffline=L,e.isPaged=B,e.isReportedByMe=async(e,t)=>{var n,r;const o=X();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=ea[e],{result:a,isFlagByMe:c}=null!==(n=await(async(e,t,n)=>{const{ws:r}=e;return await new Promise(((e,o)=>{r.emit(t,n,(t=>{try{e(Sn(t))}catch(e){o(e)}}))}))})(o,i,{[s]:t}))&&void 0!==n?n:{};return null!==(r=null!=a?a:c)&&void 0!==r&&r},e.isSkipLimit=O,e.joinChannel=async e=>{const t=X();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&Zi(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=X();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r}),ie("community.joined",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=X();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&Zi(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=X();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&Zi(n,{cachedAt:r}),ie("community.left",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=Me,e.observeChannel=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeChannel(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},i=[];return i.push(ia((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),sa((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),aa((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),ca((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),la((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),ua((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),H(z(ra,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeChannel(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.observeComment=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observeComment(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.commentId)===e&&i(t,n)},a=[];return a.push(Qs((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Js((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Ys((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Xs((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Gs((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Zs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),H(z(Rs,e),(e=>(e.data||e.error)&&i(e,"onFetch")),$(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeComments(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.referenceId===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ks((e=>i(e,"onCreate"))),Qs((e=>i(e,"onUpdate"))),Js((e=>i(e,"onDelete"))),Ys((e=>i(e,"onFlagged"))),Xs((e=>i(e,"onUnflagged"))),Gs((e=>i(e,"onReactionAdded"))),Zs((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeCommunity(tmpid: ${r}) > listen`);const o=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},i=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.communityId)===e&&o(t,n)},s=[];return s.push(va((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),ba((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),wa((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),Ca((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),_a((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),ka((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),Sa((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),Ea((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),H(z(Es,e),(e=>(e.data||e.error)&&o(e,"onFetch"))),()=>{n(`observeCommunity(tmpid: ${r}) > dispose`),s.forEach((e=>e()))}},e.observeFile=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return H(z(us,e),(n=>n.data&&((n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}})(n,"onFetch"))),()=>{n(`observeFile(tmpid: ${r}) > dispose`)}},e.observeFollowInfo=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observeFollowInfo(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=[];return s.push(za((t=>((t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.userId)===e&&i(t,n)})({data:t,loading:!1,origin:"event"},"onUpdate")))),H(z(Ba,e),(e=>(e.data||e.error)&&i(e,"onFetch")),$(n)),()=>{r(`observeFollowInfo(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeFollowers=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeFollowers(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.from===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ua((e=>i(e,"onRequested"))),Da((e=>i(e,"onAccepted"))),qa((e=>i(e,"onDeclined"))),La((e=>i(e,"onCanceled"))),Na((e=>i(e,"onFollowed"))),ja((e=>i(e,"onUnfollowed"))),Ma((e=>i(e,"onDeleted")))),()=>{n(`observeFollowers(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeFollowings=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeFollowings(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.to===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ua((e=>i(e,"onRequested"))),Da((e=>i(e,"onAccepted"))),qa((e=>i(e,"onDeclined"))),La((e=>i(e,"onCanceled"))),Na((e=>i(e,"onFollowed"))),ja((e=>i(e,"onUnfollowed"))),Ma((e=>i(e,"onDeleted")))),()=>{n(`observeFollowings(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observeMessage(tmpid: ${o}) > listen`);const i=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.messageId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},s=[];return s.push(fa((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),pa((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&H(z(ds,e),(e=>e.data&&i(e,"onFetch")),$(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeMessages(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(n);null===(i=t.onEvent)||void 0===i||i.call(t,r,n),null===(s=t[r])||void 0===s||s.call(t,n)}};return o.push(ha((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),fa((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),pa((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),()=>{n(`observeMessages(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observePost=(e,t,n="cache_then_server")=>{const{log:r}=X(),o=Date.now();r(`observePost(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=(t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.postId)===e&&i(t,n)},a=[];return a.push(Us((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Ls((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Ds((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),qs((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),zs((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),$s((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Hs((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Vs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),H(z(_s,e),(e=>(e.data||e.error)&&i(e,"onFetch")),$(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observePosts(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(e.targetId===n.targetId&&e.targetType===n.targetType){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Ms((e=>i(e,"onCreate"))),Us((e=>i(e,"onUpdate"))),Ls((e=>i(e,"onDelete"))),Ds((e=>i(e,"onApproved"))),qs((e=>i(e,"onDeclined"))),zs((e=>i(e,"onFlagged"))),$s((e=>i(e,"onUnflagged"))),Hs((e=>i(e,"onReactionAdded"))),Vs((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=X(),r=Date.now();n(`observeUser(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.userId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},i=[];return i.push(ss((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),ts((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),as((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),cs((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),ls((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),H(z(ns,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=sa,e.onChannelJoined=aa,e.onChannelLeft=ca,e.onChannelMemberAdded=la,e.onChannelMemberRemoved=ua,e.onChannelUpdated=ia,e.onClientBanned=Ji,e.onClientDisconnected=e=>Qi((({code:t})=>{800211===t&&e()})),e.onCommentCreated=Ks,e.onCommentDeleted=Js,e.onCommentFlagged=Ys,e.onCommentReactionAdded=Gs,e.onCommentReactionRemoved=Zs,e.onCommentUnflagged=Xs,e.onCommentUpdated=Qs,e.onCommunityCreated=e=>da("community.created",e),e.onCommunityDeleted=ba,e.onCommunityJoined=wa,e.onCommunityLeft=Ca,e.onCommunityUpdated=va,e.onCommunityUserAdded=_a,e.onCommunityUserBanned=Sa,e.onCommunityUserRemoved=ka,e.onCommunityUserUnbanned=Ea,e.onConnectionError=Qi,e.onFollowInfoUpdated=za,e.onFollowRequestAccepted=Da,e.onFollowRequestCanceled=La,e.onFollowRequestDeclined=qa,e.onFollowerDeleted=Ma,e.onFollowerRequested=Ua,e.onMessageCreated=ha,e.onMessageDeleted=pa,e.onMessageUpdated=fa,e.onPostApproved=Ds,e.onPostCreated=Ms,e.onPostDeclined=qs,e.onPostDeleted=Ls,e.onPostFlagged=zs,e.onPostReactionAdded=Hs,e.onPostReactionRemoved=Vs,e.onPostUnflagged=$s,e.onPostUpdated=Us,e.onReactionRemoved=(e,t,n)=>{const r=r=>{Xi(e)(r)===t&&n(r)};if("message"===e){const e=X(),t=e=>{var t;const n=Ne(["message","get",e.messages[0].messageId]),o=(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.reactionsCount)!==e.messages[0].reactionsCount;Zi(e),o&&r(e.messages[0])};return oe(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?Vs(r):Zs(r)},e.onStreamRecorded=e=>{const t=X();return oe(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{Zi(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=X();return oe(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{Zi(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=X();return oe(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{Zi(t),e(t.videoStreamings[0])}))},e.onUserDeleted=ts,e.onUserFlagCleared=ls,e.onUserFlagged=as,e.onUserFollowed=Na,e.onUserUnflagged=cs,e.onUserUnfollowed=ja,e.onUserUpdated=ss,e.pullFromCache=Ne,e.pushToCache=je,e.queryCache=Fe,e.queryCategories=Aa,e.queryChannelMembers=oa,e.queryChannels=ta,e.queryComments=Is,e.queryCommunities=ks,e.queryCommunityMembers=As,e.queryFollowers=Oa,e.queryFollowings=Ra,e.queryGlobalFeed=xa,e.queryMessages=gs,e.queryOptions=$,e.queryPosts=ws,e.queryReactions=async e=>{const t=X();t.log("reaction/queryReactions",e);const n=null!=e?e:{},{page:r={limit:10}}=n,o=os(n,["page"]),{data:i}=await t.http.get("/api/v2/reactions",{params:Object.assign(Object.assign({},o),{options:{token:F(r,"skiplimit")}})}),{paging:s,results:a}=i,{reactions:c}=a,l=N(s.next);return{data:c,prevPage:N(s.previous),nextPage:l}},e.queryRoles=hs,e.queryStreams=Va,e.queryUsers=is,e.removeChannelMembers=async(e,t)=>{const n=X();n.log("channel/removeChannelMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users`,{data:{channelId:e,userIds:t}});n.cache&&Zi(r),ie("v3.channel.didRemoveUsers",{channels:r.channels,channelUsers:r.channelUsers});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=X();r.log("channel/removeChannelMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{data:{channelId:e,role:t,userIds:n}});r.cache&&Zi(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=X();n.log("community/removeCommunityMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/communities/${e}/users`,{data:{communityId:e,userIds:t}});n.cache&&Zi(r),ie("community.userRemoved",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRoles=async(e,t,n)=>{const r=X();r.log("community/removeCommunityMembersRoles",e,t,n);const{data:o}=await r.http.delete(`/api/v4/communities/${e}/users/roles`,{data:{communityId:e,roles:t,userIds:n}});r.cache&&Zi(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!t.some((e=>n.roles.includes(e)))))},e.removeReaction=Ns,e.restoreCache=async(e="amitySdk")=>{var t;const n=X();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await Oe.getItem(`${e}#${n.userId}`))&&void 0!==t?t:"{}";let o={};try{o=JSON.parse(r)}catch(e){}return n.cache.data=Object.assign(Object.assign({},o),n.cache.data),!0},e.runQuery=H,e.sortByChannelSegment=({channelSegment:e},{channelSegment:t})=>e-t,e.sortByDisplayName=({displayName:e},{displayName:t})=>e===t?0:e<t?-1:1,e.sortByFirstCreated=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),e.sortByLastActivity=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortByLastCreated=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortBySegmentNumber=({segmentNumber:e},{segmentNumber:t})=>e-t,e.subscribeTopic=pe,e.toPage=N,e.toPageRaw=j,e.toToken=F,e.unfollow=async e=>{const t=X();t.log("follow/unfollow",e);const{data:n}=await t.http.delete(`/api/v4/me/following/${e}`);return t.cache&&Zi(n),ie("follow.unfollowed",n.follows[0]),!0},e.updateChannel=async(e,t)=>{const n=X();n.log("channel/updateChannel",e,t);const{data:r}=await n.http.put(`/api/v3/channels/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=X();n.log("user/updateComment",t);const{data:r}=await n.http.put(`/api/v3/comments/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o}),ie("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=X();n.log("community/updateCommunity",e,t);const{data:r}=await n.http.put(`/api/v3/communities/${e}`,t),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o}),ie("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=vs,e.updatePost=async(e,t)=>{const n=X();n.log("user/updatePost",t);const{data:r}=await n.http.put(`/api/v4/posts/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o}),ie("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=X();n.log("stream/updateStream",e,t);const{data:r}=await n.http.put(`/api/v3/video-streaming/${e}`,t),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=X();n.log("user/updateUser",e,t);const{data:r}=await n.http.put("/api/v3/users/",Object.assign(Object.assign({userId:e},t),{createNewUserWhenNotFound:!1})),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=Ue,e.votePoll=async(e,t)=>{const n=X();n.log("user/votePoll",e);const{data:r}=await n.http.post(`/api/v3/polls/${encodeURIComponent(e)}/votes`,{pollId:e,answerIds:t}),o=n.cache&&Date.now();n.cache&&Zi(r,{cachedAt:o});const{polls:i}=r;return{data:i.find((t=>t.pollId===e)),cachedAt:o}},e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=X();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await Oe.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
21
|
+
function ss(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}is.locally=e=>{var t;const r=re();if(r.log("user/getUsers.locally",e),!r.cache)return;const n=e.map((e=>De(["user","get",e]))).filter(Boolean),o=n.map((({data:e})=>e)),i=null===(t=n.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==n?void 0:n.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const as=async(e={})=>{const t=re();t.log("user/queryUsers",e);const{page:r,displayName:n,filter:o="all",sortBy:i="displayName"}=e,s=ss(e,["page","displayName","filter","sortBy"]),{data:a}=await t.http.get("/api/v3/users",{params:Object.assign(Object.assign({},s),{keyword:n,filter:o,sortBy:i,options:{token:N(r,"skiplimit")}})}),{paging:c}=a,l=ss(a,["paging"]),{users:u}=l,h=t.cache&&Date.now();if(t.cache){ts(l,{cachedAt:h});qe(["user","query",e],{users:u.map(U("user")),paging:c})}return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:j(c.next)}};as.locally=(e={})=>{var t,r,n;const o=re();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=De(i))&&void 0!==t?t:{},c=null!==(r=null==s?void 0:s.users.map((e=>De(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==r?r:[],l=j(null==s?void 0:s.paging.previous),u=j(null==s?void 0:s.paging.next);return c.length>0&&c.length===(null===(n=null==s?void 0:s.users)||void 0===n?void 0:n.length)?{data:c,cachedAt:a,prevPage:l,nextPage:u}:void 0};const cs=e=>rs("user.updated",e),ls=e=>rs("user.flagged",e),us=e=>rs("user.unflagged",e),hs=e=>rs("user.flagCleared",e),fs=async e=>{const t=re();t.log("file/getFile",e);const{data:r}=await t.http.get(`/api/v3/files/${e}`),n=t.cache&&Date.now();return t.cache&&ts({files:[r]},{cachedAt:n}),{data:r,cachedAt:n}};fs.locally=e=>{const t=re();if(t.log("file/getFile.locally",e),!t.cache)return;const r=De(["file","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const ds=async e=>{const t=re();t.log("role/queryRoles",e);const r=null!=e?e:{},{page:n={limit:10},displayName:o,sortBy:i}=r,s=ss(r,["page","displayName","sortBy"]),{data:a}=await t.http.get("/api/v3/roles",{params:Object.assign(Object.assign({},s),{keyword:o,sortBy:i,options:{token:N(n,"skiplimit")}})}),{paging:c}=a,l=ss(a,["paging"]),{roles:u}=l,h=t.cache&&Date.now();t.cache&&ts(l,{cachedAt:h});const f=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:f}};ds.locally=e=>{re().log("role/queryRoles.locally",e)};const ps=async e=>{const t=re();t.log("role/getRole",e);const{data:r}=await t.http.get(`/api/v3/roles/${e}`),n=t.cache&&Date.now();return t.cache&&ts({roles:r},{cachedAt:n}),{data:r.find((t=>t.roleId===e)),cachedAt:n}};ps.locally=e=>{const t=re();if(t.log("role/getRole.locally",e),!t.cache)return;const r=De(["role","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const ms=(e,t)=>{"message"===e?ue("v3.message.didUpdate",{messages:[t]}):"post"===e?ue("post.updated",{posts:[t]}):"comment"===e&&ue("comment.updated",{comments:[t]})},gs=async e=>{const t=re();t.log("message/getMessage",e);const{data:r}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{messages:o}=r;return{data:o.find((t=>t.messageId===e)),cachedAt:n}};gs.locally=e=>{const t=re();if(t.log("message/getMessage.locally",e),!t.cache)return;const r=De(["message","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const ys=async e=>{const t=re();t.log("message/getMessages",e);const{data:r}=await t.http.get("/api/v3/messages/list",{params:{messageIds:e}}),n=t.cache&&Date.now();return t.cache&&ts(r,{cachedAt:n}),{data:r.messages,cachedAt:n}};ys.locally=e=>{var t;const r=re();if(r.log("message/getMessages.locally",e),!r.cache)return;const n=e.map((e=>De(["message","get",e]))).filter(Boolean),o=n.map((({data:e})=>e)),i=null===(t=n.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==n?void 0:n.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const vs=async e=>{const t=re();t.log("message/queryMessages",e);const{page:r={limit:10}}=e,n=ss(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},n),{options:{token:N(r,"afterbefore")}})}),{paging:i}=o,s=ss(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){ts(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},n),{options:Object.assign({},r)})];qe(e,{messages:a.map(U("message")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};vs.locally=e=>{var t,r;const n=re();if(n.log("message/queryMessages.locally",e),!n.cache)return;const{page:o={limit:10}}=e,i=ss(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=De(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const l=a.messages.map((e=>De(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(r=null==a?void 0:a.messages)||void 0===r?void 0:r.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};var bs={},ws={},Cs={};Object.defineProperty(Cs,"__esModule",{value:!0}),Cs.bytesToString=Cs.stringToBytes=Cs.NIL=Cs.X500=Cs.OID=Cs.URL=Cs.DNS=Cs.hexToByte=Cs.byteToHex=void 0;let _s=[],ks={};for(var Ss=0;Ss<256;Ss++)_s[Ss]=(Ss+256).toString(16).substr(1),ks[_s[Ss]]=Ss;Cs.byteToHex=_s,Cs.hexToByte=ks,Cs.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Cs.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",Cs.OID="6ba7b812-9dad-11d1-80b4-00c04fd430c8",Cs.X500="6ba7b814-9dad-11d1-80b4-00c04fd430c8",Cs.NIL="00000000-0000-0000-0000-000000000000";Cs.stringToBytes=e=>{e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t};Cs.bytesToString=e=>{const t=new Uint8Array(e,0,e.byteLength);return String.fromCharCode.apply(null,Array.from(t))},Object.defineProperty(ws,"__esModule",{value:!0}),ws.parse=void 0;const Es=Cs;ws.parse=(e,t,r)=>{let n=t&&r||0,o=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,(e=>(o<16&&t&&(t[n+o++]=Es.hexToByte[e]),"")));o<16;)t[n+o++]=0;return t};var As={};Object.defineProperty(As,"__esModule",{value:!0}),As.unparse=void 0;const Ts=Cs;As.unparse=(e,t)=>{let r=t||0,n=Ts.byteToHex;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]};var xs={},Is={};Object.defineProperty(Is,"__esModule",{value:!0});Is.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;var Os=be&&be.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(xs,"__esModule",{value:!0}),xs.validate=void 0;const Rs=Os(Is);xs.validate=e=>"string"==typeof e&&Rs.default.test(e);var Ps={};Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.version=void 0;const Bs=xs;Ps.version=e=>{if(!Bs.validate(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};var Ns={},js={};Object.defineProperty(js,"__esModule",{value:!0}),js.stringify=void 0;const Fs=xs,Ms=[];for(let e=0;e<256;++e)Ms.push((e+256).toString(16).substr(1));js.stringify=(e,t=0)=>{const r=(Ms[e[t+0]]+Ms[e[t+1]]+Ms[e[t+2]]+Ms[e[t+3]]+"-"+Ms[e[t+4]]+Ms[e[t+5]]+"-"+Ms[e[t+6]]+Ms[e[t+7]]+"-"+Ms[e[t+8]]+Ms[e[t+9]]+"-"+Ms[e[t+10]]+Ms[e[t+11]]+Ms[e[t+12]]+Ms[e[t+13]]+Ms[e[t+14]]+Ms[e[t+15]]).toLowerCase();if(!Fs.validate(r))throw TypeError("Stringified UUID is invalid");return r};var Us={};Object.defineProperty(Us,"__esModule",{value:!0}),Us.rng=void 0;Us.rng=()=>{let e=new Array(16);for(let t=0;t<16;t++)e[t]=255&256*Math.random()+0;return e},Object.defineProperty(Ns,"__esModule",{value:!0}),Ns.v1=void 0;const Ls=js,Ds=Us;let qs,zs,$s=0,Hs=0;Ns.v1=(e,t,r=0)=>{let n=t&&r||0;const o=t||new Uint8Array(16);let i=e&&e.node?e.node:qs,s=e&&e.clockseq?e.clockseq:zs;if(null==i||null==s){const t=e&&e.random?e.random:e&&e.rng?e.rng():Ds.rng();null==i&&(i=qs=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==s&&(s=zs=16383&(t[6]<<8|t[7]))}let a=e&&e.msecs?e.msecs:Date.now(),c=e&&e.nsecs?e.nsecs:Hs+1;const l=a-$s+(c-Hs)/1e4;if(l<0&&e&&!e.clockseq&&(s=s+1&16383),(l<0||a>$s)&&e&&!e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");$s=a,Hs=c,zs=s,a+=122192928e5;const u=(1e4*(268435455&a)+c)%4294967296;o[n++]=u>>>24&255,o[n++]=u>>>16&255,o[n++]=u>>>8&255,o[n++]=255&u;const h=a/4294967296*1e4&268435455;o[n++]=h>>>8&255,o[n++]=255&h,o[n++]=h>>>24&15|16,o[n++]=h>>>16&255,o[n++]=s>>>8|128,o[n++]=255&s;for(let e=0;e<6;++e)o[n+e]=i[e];return t||Ls.stringify(o)};var Vs={};Object.defineProperty(Vs,"__esModule",{value:!0}),Vs.v4=void 0;const Ws=As,Ks=Us;Vs.v4=(e,t,r)=>{let n=t&&r||0,o=Ks.rng();if(!e||e instanceof String||(e.random&&(o=e.random),e.rng&&(o=e.rng())),o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var i=0;i<16;i++)t[n+i]=o[i];return t||Ws.unparse(o)};var Qs={},Js={};Object.defineProperty(Js,"__esModule",{value:!0}),Js.v35=void 0;const Xs=js,Ys=ws,Gs=Cs;Js.v35=(e,t,r)=>(e,n,o,i=0)=>{if("string"==typeof e&&(e=Gs.stringToBytes(e)),"string"==typeof n&&(n=Ys.parse(n)),n&&16!==n.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let s=new Uint8Array(16+e.length);if(s.set(n),s.set(e,n.length),s=Gs.stringToBytes(r(Gs.bytesToString(s))),s[6]=15&s[6]|t,s[8]=63&s[8]|128,o)for(let e=0;e<16;++e)o[i+e]=s[e];return o||Xs.stringify(s)};var Zs={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.any_hmac_sha1=e.b64_hmac_sha1=e.hex_hmac_sha1=e.any_sha1=e.b64_sha1=e.hex_sha1=void 0;let t=0,r="";e.hex_sha1=e=>i(n(c(e))),e.default=e.hex_sha1;e.b64_sha1=e=>s(n(c(e)));e.any_sha1=(e,t)=>a(n(c(e)),t);e.hex_hmac_sha1=(e,t)=>i(o(c(e),c(t)));e.b64_hmac_sha1=(e,t)=>s(o(c(e),c(t)));e.any_hmac_sha1=(e,t,r)=>a(o(c(e),c(t)),r);const n=e=>u(h(l(e),8*e.length)),o=(e,t)=>{let r=l(e);r.length>16&&(r=h(r,8*e.length));let n=Array(16),o=Array(16);for(var i=0;i<16;i++)n[i]=909522486^r[i],o[i]=1549556828^r[i];var s=h(n.concat(l(t)),512+8*t.length);return u(h(o.concat(s),672))},i=e=>{for(var r,n=t?"0123456789ABCDEF":"0123456789abcdef",o="",i=0;i<e.length;i++)r=e.charCodeAt(i),o+=n.charAt(r>>>4&15)+n.charAt(15&r);return o},s=e=>{for(var t="",n=e.length,o=0;o<n;o+=3)for(var i=e.charCodeAt(o)<<16|(o+1<n?e.charCodeAt(o+1)<<8:0)|(o+2<n?e.charCodeAt(o+2):0),s=0;s<4;s++)8*o+6*s>8*e.length?t+=r:t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-s)&63);return t},a=(e,t)=>{var r,n,o,i,s=t.length,a=[],c=Array(Math.ceil(e.length/2));for(r=0;r<c.length;r++)c[r]=e.charCodeAt(2*r)<<8|e.charCodeAt(2*r+1);for(;c.length>0;){for(i=[],o=0,r=0;r<c.length;r++)o=(o<<16)+c[r],o-=(n=Math.floor(o/s))*s,(i.length>0||n>0)&&(i[i.length]=n);a[a.length]=o,c=i}var l="";for(r=a.length-1;r>=0;r--)l+=t.charAt(a[r]);var u=Math.ceil(8*e.length/(Math.log(t.length)/Math.log(2)));for(r=l.length;r<u;r++)l=t[0]+l;return l},c=e=>{for(var t,r,n="",o=-1;++o<e.length;)t=e.charCodeAt(o),r=o+1<e.length?e.charCodeAt(o+1):0,t>=55296&&t<=56319&&r>=56320&&r<=57343&&(t=65536+((1023&t)<<10)+(1023&r),o++),t<=127?n+=String.fromCharCode(t):t<=2047?n+=String.fromCharCode(192|t>>>6&31,128|63&t):t<=65535?n+=String.fromCharCode(224|t>>>12&15,128|t>>>6&63,128|63&t):t<=2097151&&(n+=String.fromCharCode(240|t>>>18&7,128|t>>>12&63,128|t>>>6&63,128|63&t));return n},l=e=>{for(var t=Array(e.length>>2),r=0;r<t.length;r++)t[r]=0;for(r=0;r<8*e.length;r+=8)t[r>>5]|=(255&e.charCodeAt(r/8))<<24-r%32;return t},u=e=>{for(var t="",r=0;r<32*e.length;r+=8)t+=String.fromCharCode(e[r>>5]>>>24-r%32&255);return t},h=(e,t)=>{e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var r=Array(80),n=1732584193,o=-271733879,i=-1732584194,s=271733878,a=-1009589776,c=0;c<e.length;c+=16){for(var l=n,u=o,h=i,g=s,y=a,v=0;v<80;v++){r[v]=v<16?e[c+v]:m(r[v-3]^r[v-8]^r[v-14]^r[v-16],1);let t=p(p(m(n,5),f(v,o,i,s)),p(p(a,r[v]),d(v)));a=s,s=i,i=m(o,30),o=n,n=t}n=p(n,l),o=p(o,u),i=p(i,h),s=p(s,g),a=p(a,y)}return[n,o,i,s,a]},f=(e,t,r,n)=>e<20?t&r|~t&n:e<40?t^r^n:e<60?t&r|t&n|r&n:t^r^n,d=e=>e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514,p=(e,t)=>{var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r},m=(e,t)=>e<<t|e>>>32-t}(Zs);var ea=be&&be.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.v5=void 0;const ta=Js,ra=ea(Zs);Qs.v5=ta.v35("v5",80,ra.default),Object.defineProperty(bs,"__esModule",{value:!0});const na=ws,oa=As,ia=xs,sa=Ps,aa=Ns,ca=Vs,la=Qs,ua=Cs;var ha=bs.default={parse:na.parse,unparse:oa.unparse,validate:ia.validate,version:sa.version,v1:aa.v1,v4:ca.v4,v5:la.v5,NIL:ua.NIL,DNS:ua.DNS,URL:ua.URL,OID:ua.OID,X500:ua.X500};const fa=async e=>{const t=re();t.log("user/createMessage",e);const{data:r}=await t.http.post("/api/v3/messages",e),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{messages:o}=r;return{data:o[0],cachedAt:n}};fa.optimistically=e=>{var t,r;const n=re();if(!n.cache)return;const o=Object.assign({messageId:ha.v4().toString()},e);n.log("user/createMessage.locally",o);const i=De(["channel","get",o.channelId]);$e(["channel","get",o.channelId],Object.assign(Object.assign({},null==i?void 0:i.data),{messageCount:(null!==(t=null==i?void 0:i.data.messageCount)&&void 0!==t?t:0)+1}));const s=(new Date).toISOString(),a=Object.assign({userId:n.userId,channelSegment:(null!==(r=null==i?void 0:i.data.messageCount)&&void 0!==r?r:0)+1,createdAt:s,updatedAt:s},o);return qe(["message","get",a.messageId],a,{cachedAt:-1}),ue("v3.message.didCreate",{messages:[a]}),{data:a,cachedAt:-1}};const da=async(e,t)=>{const r=re();r.log("user/updateMessage",t);const{data:n}=await r.http.put(`/api/v3/messages/${encodeURIComponent(e)}`,t),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o});const{messages:i}=n;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};da.optimistically=(e,t)=>{const r=re();if(r.log("user/updateMessage",t),!r.cache)return;const n=De(["message","get",e]);if(!n)return;const o=Object.assign(Object.assign(Object.assign({},n.data),t),{updatedAt:(new Date).toISOString()});return $e(["message","get",e],o,{cachedAt:-1}),ue("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const pa=async e=>{const t=re();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await gs(e)).data};pa.optimistically=e=>{re().log("message/deleteMessage",e);const t=De(["message","get",e]);if(!t)return;const r=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return $e(["message","get",e],r,{cachedAt:-1}),ue("v3.message.didDelete",{messages:[r]}),{data:r,cachedAt:-1}};const ma=async e=>{const t=re();t.log("post/queryPosts",e);const{page:r={limit:10}}=e,n=ss(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},n),{options:{token:N(r,"afterbeforeraw")}})}),{paging:i}=o,s=ss(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){ts(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},n),{options:Object.assign({},r)})];qe(e,{posts:a.map(U("post")),paging:i})}const l=F(i.next);return{data:a,cachedAt:c,prevPage:F(i.previous),nextPage:l}};ma.locally=e=>{var t,r;const n=re();if(n.log("post/queryPosts.locally",e),!n.cache)return;const{page:o={limit:10}}=e,i=ss(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=De(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const l=a.posts.map((e=>De(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),u=F(null==a?void 0:a.paging.previous),h=F(null==a?void 0:a.paging.next);return l.length===(null===(r=null==a?void 0:a.posts)||void 0===r?void 0:r.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const ga=async e=>{const t=re();t.log("post/getPosts",e);const r=e.map((e=>encodeURIComponent(e))),{data:n}=await t.http.get("/api/v3/posts/list",{params:{postIds:r}}),o=t.cache&&Date.now();return t.cache&&ts(n,{cachedAt:o}),{data:n.posts,cachedAt:o}};ga.locally=e=>{var t;const r=re();if(r.log("post/getPosts.locally",e),!r.cache)return;const n=e.map((e=>De(["post","get",e]))).filter(Boolean),o=n.map((({data:e})=>e)),i=null===(t=n.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==n?void 0:n.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ya=async e=>{const t=re();let r;t.log("post/getPost",e);try{r=(await t.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&He(["post","get",e],!0),t}const n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{posts:o}=r;return{data:o.find((t=>t.postId===e)),cachedAt:n}};ya.locally=e=>{const t=re();if(t.log("post/getPost.locally",e),!t.cache)return;const r=De(["post","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const va=async e=>{const t=re();t.log("channel/queryCommunities",e);const r=null!=e?e:{},{page:n,displayName:o,membership:i}=r,s=ss(r,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/communities",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:N(n,"skiplimit")}})}),{paging:c}=a,l=ss(a,["paging"]),{communities:u}=l,h=t.cache&&Date.now();if(t.cache){ts(l,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},n)})];qe(e,{communities:u.map(U("community")),paging:c})}const f=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:f}};va.locally=e=>{re().log("community/queryCommunities.locally",e)};const ba=async e=>{const t=re();t.log("community/getCommunities",e);const{data:r}=await t.http.get("/api/v3/communities/list",{params:{communityIds:e}}),n=t.cache&&Date.now();return t.cache&&ts(r,{cachedAt:n}),{data:r.communities,cachedAt:n}};ba.locally=e=>{var t;const r=re();if(r.log("community/getCommunities.locally",e),!r.cache)return;const n=e.map((e=>De(["community","get",e]))).filter(Boolean),o=n.map((({data:e})=>e)),i=null===(t=n.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==n?void 0:n.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const wa=async e=>{const t=re();t.log("community/getCommunity",e);const{data:r}=await t.http.get(`/api/v3/communities/${e}`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{communities:o}=r;return{data:o.find((t=>t.communityId===e)),cachedAt:n}};wa.locally=e=>{const t=re();if(t.log("community/getCommunity.locally",e),!t.cache)return;const r=De(["community","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const Ca=async e=>{const t=re();t.log("community/queryCommunityMembers",e);const r=null!=e?e:{},{page:n,communityId:o}=r,i=ss(r,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:N(n,"skiplimit")}})}),{paging:a}=s,c=ss(s,["paging"]),{communityUsers:l}=c,u=t.cache&&Date.now();t.cache&&ts(c,{cachedAt:u});return{data:l,cachedAt:u,nextPage:j(a.next),prevPage:j(a.previous)}};Ca.locally=e=>{re().log("community/queryCommunityMembers",e)};const _a=async e=>{const t=re();t.log("channel/getTopTrendingCommunities",e);const{limit:r=5}=null!=e?e:{},{data:n}=await t.http.get("/api/v3/communities/top-trending",{params:{options:{limit:r}}}),{communities:o}=n,i=t.cache&&Date.now();if(t.cache){ts(n,{cachedAt:i});qe(["community","top-trending",{params:{options:{limit:r}}}],{communities:o.map(U("community"))})}return{data:o,cachedAt:i}};_a.locally=e=>{var t,r;const n=re();if(n.log("community/getTopTrendingCommunities.locally",e),!n.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","top-trending",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=De(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>De(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(r=null==s?void 0:s.communities)||void 0===r?void 0:r.length)?{data:c,cachedAt:a}:void 0};const ka=async e=>{const t=re();t.log("channel/getRecommendedCommunities",e);const{limit:r=5}=null!=e?e:{},{data:n}=await t.http.get("/api/v3/communities/recommended",{params:{options:{limit:r}}}),{communities:o}=n,i=t.cache&&Date.now();if(t.cache){ts(n,{cachedAt:i});qe(["community","recommended",{params:{options:{limit:r}}}],{communities:o.map(U("community"))})}return{data:o,cachedAt:i}};ka.locally=e=>{var t,r;const n=re();if(n.log("community/getRecommendedCommunities.locally",e),!n.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","recommended",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=De(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>De(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(r=null==s?void 0:s.communities)||void 0===r?void 0:r.length)?{data:c,cachedAt:a}:void 0};const Sa=async e=>{const t=re();t.log("comment/queryComments",e);const{page:r={limit:10}}=e,n=ss(e,["page"]),o={type:n.sortBy?"pagination":void 0,token:N(r,n.sortBy?"skiplimit":"afterbefore")},{data:i}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},n),{options:o})}),{paging:s}=i,a=ss(i,["paging"]),{comments:c}=a,l=t.cache&&Date.now();if(t.cache){ts(a,{cachedAt:l});const e=["comment","query",Object.assign(Object.assign({},n),{options:Object.assign({},r)})];qe(e,{comments:c.map(U("comment")),paging:s})}const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};Sa.locally=e=>{var t,r;const n=re();if(n.log("comment/queryComments.locally",e),!n.cache)return;const{page:o={limit:10}}=e,i=ss(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=De(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const l=a.comments.map((e=>De(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(r=null==a?void 0:a.comments)||void 0===r?void 0:r.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const Ea=async e=>{const t=re();t.log("comment/getComments",e);const r=e.map((e=>encodeURIComponent(e))),{data:n}=await t.http.get("/api/v3/comments/list",{params:{commentIds:r}}),o=t.cache&&Date.now();return t.cache&&ts(n,{cachedAt:o}),{data:n.comments,cachedAt:o}};Ea.locally=e=>{var t;const r=re();if(r.log("comment/getComments.locally",e),!r.cache)return;const n=e.map((e=>De(["comment","get",e]))).filter(Boolean),o=n.map((({data:e})=>e)),i=null===(t=n.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==n?void 0:n.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Aa=async e=>{const t=re();let r;t.log("comment/getComment",e);try{r=(await t.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&He(["comment","get",e],!0),t}const n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{comments:o}=r;return{data:o.find((t=>t.commentId===e)),cachedAt:n}};Aa.locally=e=>{const t=re();if(t.log("comment/getComment.locally",e),!t.cache)return;const r=De(["comment","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const Ta=async(e,t)=>{if("message"===e)return gs(t);if("post"===e)return ya(t);if("comment"===e)return Aa(t);throw new Error(`Incorrect referenceType: ${e}`)},xa=(e,t)=>{var r,n;if(re().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(r=De(["post","get",e.postId]))||void 0===r?void 0:r.data,o=e}else{const e=t.comments[0];i=null===(n=De(["comment","get",e.commentId]))||void 0===n?void 0:n.data,o=e}if(i&&i.myReactions)if("post.addReaction"===e||"comment.addReaction"===e){if(i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:[...i.myReactions,t.reactor.reactionName]})}else{if(!i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:i.myReactions.filter((e=>e!==t.reactor.reactionName))})}},Ia=async(e,t,r)=>{var n,o;const i=re();i.log("reaction/createReaction",{referenceId:t,referenceType:e,reactionName:r}),await i.http.post("/api/v2/reactions",{referenceId:t,referenceType:e,reactionName:r});const s=await Ta(e,t);return ms(e,s.data),null!==(o=null===(n=s.data.myReactions)||void 0===n?void 0:n.includes(r))&&void 0!==o&&o};Ia.optimistically=(e,t,r)=>{var n,o,i,s,a;const c=re();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:r}),!c.cache)return;const l=De([e,"get",t]);if(!(null==l?void 0:l.data)||(null===(n=l.data.myReactions)||void 0===n?void 0:n.includes(r)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:l.data.reactionsCount+1,myReactions:[...null!==(o=l.data.myReactions)&&void 0!==o?o:[],r],reactions:Object.assign(Object.assign({},l.data.reactions),{[r]:(null!==(i=l.data.reactions[r])&&void 0!==i?i:0)+1})});return $e([e,"get",t],u,{cachedAt:-1}),ms(e,u),null!==(a=null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(r))&&void 0!==a&&a};const Oa=async(e,t,r)=>{var n,o;const i=re();i.log("reaction/removeReaction",{referenceId:t,referenceType:e,reactionName:r}),await i.http.delete("/api/v2/reactions",{data:{referenceId:t,referenceType:e,reactionName:r}});const s=await Ta(e,t);return ms(e,s.data),null!==(o=!(null===(n=s.data.myReactions)||void 0===n?void 0:n.includes(r)))&&void 0!==o&&o};Oa.optimistically=(e,t,r)=>{var n,o,i,s,a;const c=re();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:r}),!c.cache)return;const l=De([e,"get",t]);if(!(null==l?void 0:l.data)||!(null===(n=l.data.myReactions)||void 0===n?void 0:n.includes(r)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:Math.max(0,l.data.reactionsCount-1),myReactions:(null!==(o=l.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==r)),reactions:Object.assign(Object.assign({},l.data.reactions),{[r]:Math.max(0,(null!==(i=l.data.reactions[r])&&void 0!==i?i:0)-1)})});return $e([e,"get",t],u,{cachedAt:-1}),ms(e,u),null!==(a=!(null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(r)))&&void 0!==a&&a};const Ra=(e,t)=>{const r=re();return le(r,e,e,(n=>{var o;if(r.cache){const{communities:r}=n,i=ss(n,["communities"]);ts(i),(null==r?void 0:r[0])&&!["post.updated"].includes(e)&&ue("community.updated",{communities:r});const s=De(["post","get",n.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=Le(["post","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.targetId)===s.data.targetId}));"post.declined"===e&&(t=null==t?void 0:t.filter((({key:e})=>{var t;return"reviewing"===(null===(t=e[2])||void 0===t?void 0:t.feedType)}))),null==t||t.map((({key:e,data:t})=>$e(e,t,{cachedAt:-1})))}t(s.data)}else t(n.posts[0])}))},Pa=e=>Ra("post.created",e),Ba=e=>Ra("post.updated",e),Na=e=>Ra("post.deleted",e),ja=e=>Ra("post.approved",e),Fa=e=>Ra("post.declined",e),Ma=e=>Ra("post.flagged",e),Ua=e=>Ra("post.unflagged",e),La=e=>{const t=re();return le(t,"post.addReaction","post.addReaction",(r=>{if(t.cache){xa("post.addReaction",r);const t=ss(r,["reactor"]);ts(t);const n=De(["post","get",r.posts[0].postId]);e(n.data)}else e(r.posts[0])}))},Da=e=>{const t=re();return le(t,"post.removeReaction","post.removeReaction",(r=>{if(t.cache){xa("post.removeReaction",r);const t=ss(r,["reactor"]);ts(t);const n=De(["post","get",r.posts[0].postId]);e(n.data)}else e(r.posts[0])}))},qa=(e,t)=>{const r=re();return le(r,e,e,(n=>{var o;if(r.cache){ts(n);const r=De(["comment","get",n.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=Le(["comment","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.referenceId)===r.data.referenceId}));null==e||e.map((({key:e,data:t})=>$e(e,t,{cachedAt:-1})))}t(r.data)}else t(n.comments[0])}))},za=e=>qa("comment.created",e),$a=e=>qa("comment.updated",e),Ha=e=>qa("comment.deleted",e),Va=e=>qa("comment.flagged",e),Wa=e=>qa("comment.unflagged",e),Ka=e=>{const t=re();return le(t,"comment.addReaction","comment.addReaction",(r=>{if(t.cache){xa("comment.addReaction",r);const t=ss(r,["reactor"]);ts(t);const n=De(["comment","get",r.comments[0].commentId]);e(n.data)}else e(r.comments[0])}))},Qa=e=>{const t=re();return le(t,"comment.removeReaction","comment.removeReaction",(r=>{if(t.cache){xa("comment.removeReaction",r);const t=ss(r,["reactor"]);ts(t);const n=De(["comment","get",r.comments[0].commentId]);e(n.data)}else e(r.comments[0])}))};var Ja={post:{domainName:"posts",eventName:"v3/post.isflagbyme",primaryKey:"postId"},comment:{domainName:"comments",eventName:"v3/comment.isflagbyme",primaryKey:"commentId"},message:{domainName:"messages",eventName:"v3/message.isFlaggedByMe",primaryKey:"messageId"},user:{domainName:"users",eventName:"user.isFlagByMe",primaryKey:"userId"}};const Xa=async e=>{const t=re();t.log("channel/queryChannels",e);const r=null!=e?e:{},{page:n={limit:10},displayName:o,membership:i}=r,s=ss(r,["page","displayName","membership"]),{data:a}=await t.http.get("/api/v3/channels",{params:Object.assign(Object.assign({},s),{keyword:o,filter:i,options:{token:N(n,"skiplimit")}})}),{paging:c}=a,l=ss(a,["paging"]),{channels:u}=l,h=t.cache&&Date.now();if(t.cache){ts(l,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},n)})];qe(e,{channels:u.map(U("channel")),paging:c})}const f=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:f}};Xa.locally=e=>{re().log("channel/queryChannels.locally",e)};const Ya=async e=>{const t=re();t.log("channel/getChannels",e);const r=e.map((e=>encodeURIComponent(e))),{data:n}=await t.http.get("/api/v3/channels/list",{params:{channelIds:r}}),o=t.cache&&Date.now();return t.cache&&ts(n,{cachedAt:o}),{data:n.channels,cachedAt:o}};Ya.locally=e=>{var t;const r=re();if(r.log("channel/getChannels.locally",e),!r.cache)return;const n=e.map((e=>De(["channel","get",e]))).filter(Boolean),o=n.map((({data:e})=>e)),i=null===(t=n.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==n?void 0:n.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Ga=async e=>{const t=re();t.log("channel/getChannel",e);const{data:r}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{channels:o}=r;return{data:o.find((t=>t.channelId===e)),cachedAt:n}};Ga.locally=e=>{const t=re();if(t.log("channel/getChannel.locally",e),!t.cache)return;const r=De(["channel","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const Za=async e=>{const t=re();t.log("channel/queryChannelMembers",e);const r=null!=e?e:{},{page:n,channelId:o}=r,i=ss(r,["page","channelId"]),{data:s}=await t.http.get(`/api/v4/channels/${encodeURIComponent(o)}/users`,{params:Object.assign(Object.assign({},i),{options:{token:N(n,"skiplimit")}})}),{paging:a}=s,c=ss(s,["paging"]),{channelUsers:l}=c,u=t.cache&&Date.now();t.cache&&ts(c);return{data:l,cachedAt:u,nextPage:j(a.next),prevPage:j(a.previous)}};Za.locally=e=>{re().log("channel/queryChannelMembers",e)};const ec=e=>{const t=re();return le(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{ts(t),e(t.channels[0])}))},tc=e=>{const t=re();return le(t,"onChannelDeleted","v3.channel.didDelete",(t=>{ts(t),e(t.channels[0])}))},rc=e=>{const t=re();return le(t,"onChannelJoined","v3.channel.didJoin",(t=>{ts(t),e(t.channels[0])}))},nc=e=>{const t=re();return le(t,"onChannelLeft","v3.channel.didLeave",(t=>{ts(t),e(t.channels[0])}))},oc=e=>{const t=re();return le(t,"onChannelMemberAdded","v3.channel.didAddUsers",(t=>{ts(t),e(t.channels[0],t.channelUsers[0])}))},ic=e=>{const t=re();return le(t,"onChannelMemberRemoved","v3.channel.didRemoveUsers",(t=>{ts(t),e(t.channels[0],t.channelUsers[0])}))},sc=e=>{const t=re();return le(t,"message/onMessageCreated","v3.message.didCreate",(t=>{ts(t),e(t.messages[0])}))},ac=e=>{const t=re();return le(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{ts(t);const r=t.messages[0];(null==r?void 0:r.myReactions)||(e=>{const t=re(),r=De(["message","get",e.messageId]),n=(null==r?void 0:r.data.myReactions)||[];Object.assign(e,{myReactions:n});const o=null==e?void 0:e.latestReaction;o&&o.userId===t.userId&&("add"!==o.eventName||n.includes(o.reactionName)||Object.assign(e,{myReactions:[...n,o.reactionName]}),"remove"===o.eventName&&n.includes(o.reactionName)&&Object.assign(e,{myReactions:n.filter((e=>e!==o.reactionName))}))})(r),e(r)}))},cc=e=>{const t=re();return le(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{ts(t),e(t.messages[0])}))},lc=(e,t)=>{const r=re();return le(r,e,e,(e=>{if(r.cache){ts(e);const r=De(["community","get",e.communities[0].communityId]);t(r.data)}else t(e.communities[0])}))};function uc(e,t,r){return!!e.permissions.some((e=>e===r))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===r))}function hc(e,t){return"community.joined"===e||"community.left"===e?t.communityUsers[0]:"community.userRemoved"===e?t.communityUsers.filter((e=>"none"===e.communityMembership))[0]:"community.userBanned"===e?t.communityUsers.filter((e=>"banned"===e.communityMembership))[0]:"community.userUnbanned"===e?t.communityUsers.filter((e=>!uc(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!uc(e,t,"ADD_COMMUNITY_USER")))[0]}const fc=(e,t)=>{const r=re();return le(r,e,e,(n=>{if(r.cache){ts(n);const r=De(["community","get",n.communities[0].communityId]),o=De(["communityUsers","get",U("communityUsers")(hc(e,n))]);t(r.data,o.data)}else t(n.communities[0],hc(e,n))}))},dc=e=>lc("community.updated",e),pc=e=>lc("community.deleted",e),mc=e=>fc("community.joined",e),gc=e=>fc("community.left",e),yc=e=>fc("community.userAdded",e),vc=e=>fc("community.userRemoved",e),bc=e=>fc("community.userBanned",e),wc=e=>fc("community.userUnbanned",e),Cc=async e=>{const t=re();t.log("category/queryCategories",e);const r=null!=e?e:{},{page:n={limit:10}}=r,o=ss(r,["page"]),{data:i}=await t.http.get("/api/v3/community-categories",{params:Object.assign(Object.assign({},o),{options:{token:N(n,"skiplimit")}})}),{paging:s}=i,a=ss(i,["paging"]),{categories:c}=a,l=t.cache&&Date.now();if(t.cache){ts(a,{cachedAt:l});const e=["category","query",Object.assign(Object.assign({},o),{options:Object.assign({},n)})];qe(e,{categories:c.map(U("category")),paging:s})}const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};Cc.locally=e=>{var t,r;const n=re();if(n.log("category/queryCategories.locally",e),!n.cache)return;const o=null!=e?e:{},{page:i={limit:10}}=o,s=ss(o,["page"]),a=["category","query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(t=De(a))&&void 0!==t?t:{};if(!(null==c?void 0:c.categories.length))return;const u=c.categories.map((e=>De(["category","get",e]))).filter(Boolean).map((({data:e})=>e)),h=j(null==c?void 0:c.paging.previous),f=j(null==c?void 0:c.paging.next);return u.length===(null===(r=null==c?void 0:c.categories)||void 0===r?void 0:r.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const _c=async e=>{const t=re();t.log("category/getCategory",e);const{data:r}=await t.http.get(`/api/v3/community-categories/${encodeURIComponent(e)}`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{categories:o}=r;return{data:o.find((t=>t.categoryId===e)),cachedAt:n}};_c.locally=e=>{const t=re();if(t.log("category/getCategory.locally",e),!t.cache)return;const r=De(["category","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const kc=async e=>{const t=re();t.log("feed/queryGlobalFeed",e);const r=null!=e?e:{},{useCustomRanking:n,page:o}=r,i=ss(r,["useCustomRanking","page"]),{data:s}=await t.http.get(n?"/api/v5/me/global-feeds":"/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},i),{options:{token:N(o,"skiplimit")}})}),{paging:a}=s,c=ss(s,["paging"]),{posts:l}=c,u=t.cache&&Date.now();if(t.cache){ts(c);const e=["globalFeed","query",Object.assign(Object.assign({},i),{useCustomRanking:n,options:Object.assign({},o)})];qe(e,{posts:l.map(U("post")),paging:a})}const h=j(a.next);return{data:l,cachedAt:u,prevPage:j(a.previous),nextPage:h}};kc.locally=e=>{var t,r;const n=re();if(n.log("post/queryGlobalFeed.locally",e),!n.cache)return;const o=null!=e?e:{},{useCustomRanking:i,page:s}=o,a=ss(o,["useCustomRanking","page"]),c=["globalFeed","query",Object.assign(Object.assign({},a),{useCustomRanking:i,options:Object.assign({},s)})],{data:l,cachedAt:u}=null!==(t=De(c))&&void 0!==t?t:{};if(!(null==l?void 0:l.posts.length))return;const h=l.posts.map((e=>De(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),f=j(null==l?void 0:l.paging.previous),d=j(null==l?void 0:l.paging.next);return h.length===(null===(r=null==l?void 0:l.posts)||void 0===r?void 0:r.length)?{data:h,cachedAt:u,prevPage:f,nextPage:d}:void 0};const Sc=async(e,t)=>{const r=re();r.log(`follow/queryF${e.substring(1)}`,t);const{userId:n,page:o}=t,i=ss(t,["userId","page"]),{data:s}=await r.http.get(r.userId===n?`/api/v4/me/${e}`:`/api/v4/users/${n}/${e}`,{params:Object.assign(Object.assign({},i),{token:N(o,"skiplimit")})}),{paging:a}=s,c=ss(s,["paging"]),{follows:l}=c,u=r.cache&&Date.now();if(r.cache){ts(c,{cachedAt:u});const t=[e,"query",Object.assign(Object.assign({},i),{userId:n,options:Object.assign({},o)})];qe(t,{follows:l.map(U("follow")),paging:a})}const h=j(a.next);return{data:l,cachedAt:u,prevPage:j(a.previous),nextPage:h}};Sc.locally=(e,t)=>{var r,n;const o=re();if(o.log(`follow/queryF${e.substring(1)}.locally`,t),!o.cache)return;const{page:i}=t,s=ss(t,["page"]),a=[e,"query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(r=De(a))&&void 0!==r?r:{};if(!(null==c?void 0:c.follows.length))return;const u=c.follows.map((e=>De(["follow","get",e]))).filter(Boolean).map((({data:e})=>e)),h=j(null==c?void 0:c.paging.previous),f=j(null==c?void 0:c.paging.next);return u.length===(null===(n=null==c?void 0:c.follows)||void 0===n?void 0:n.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const Ec=async e=>Sc("followers",e);Ec.locally=e=>Sc.locally("followers",e);const Ac=async e=>Sc("following",e);Ac.locally=e=>Sc.locally("following",e);const Tc=e=>["followInfo","get",`${re().userId}#${e}`],xc=async e=>{var t,r;const n=re();n.log("follow/getFollowInfo",e);const{data:o}=await n.http.get(n.userId===e?"/api/v4/me/followInfo":`/api/v4/users/${e}/followInfo`),i=n.cache&&Date.now(),s=Object.assign(Object.assign({},o.followCounts[0]),{status:null===(r=null===(t=o.follows)||void 0===t?void 0:t[0])||void 0===r?void 0:r.status});return n.cache&&qe(Tc(e),s,{cachedAt:i}),{data:s,cachedAt:i}};xc.locally=e=>{const t=re();if(t.log("follow/getFollowInfo.locally",e),!t.cache)return;const r=De(Tc(e));return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const Ic=(e,t)=>{const r=re();return le(r,e,e,(e=>{var n,o;if(r.cache){ts({follows:[e]});[...null!==(n=Le(["followers","query"]))&&void 0!==n?n:[],...null!==(o=Le(["followings","query"]))&&void 0!==o?o:[]].filter((({key:t})=>t[2].userId===e.from||t[2].userId===e.to)).forEach((({key:e,data:t})=>$e(e,t,{cachedAt:-1}))),t(e)}else t(e)}))},Oc=e=>Ic("follow.created",e),Rc=e=>Ic("follow.unfollowed",e),Pc=e=>Ic("follow.followerDeleted",e),Bc=e=>Ic("follow.requested",e),Nc=e=>Ic("follow.requestCanceled",e),jc=e=>Ic("follow.accepted",e),Fc=e=>Ic("follow.requestDeclined",e),Mc=e=>{const t=async t=>{const[{data:r},{data:n}]=await Promise.all([xc(t.from),xc(t.to)]);e(r),e(n)},r=[Ic("follow.created",t),Ic("follow.requested",t),Ic("follow.accepted",t),Ic("follow.unfollowed",t),Ic("follow.requestCanceled",t),Ic("follow.requestDeclined",t),Ic("follow.followerDeleted",t)];return()=>{r.forEach((e=>e()))}},Uc=async e=>{const t=re();t.log("poll/getPoll",e);const{data:r}=await t.http.get(`/api/v3/polls/${e}`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{polls:o}=r;return{data:o.find((t=>t.pollId===e)),cachedAt:n}};Uc.locally=e=>{const t=re();if(t.log("poll/getPoll",e),!t.cache)return;const r=De(["poll","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const Lc=async e=>{const t=re();t.log("stream/getStream",e);const{data:r}=await t.http.get(`/api/v3/video-streaming/${e}`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{videoStreamings:o}=r;return{data:o.find((t=>t.streamId===e)),cachedAt:n}};Lc.locally=e=>{const t=re();if(t.log("stream/getStream",e),!t.cache)return;const r=De(["stream","get",e]);return r?{data:r.data,cachedAt:r.cachedAt}:void 0};const Dc=async e=>{const t=re();t.log("stream/queryStreams",e);const r=null!=e?e:{},{page:n}=r,o=ss(r,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:N(n,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,l=t.cache&&Date.now();t.cache&&ts(a,{cachedAt:l});const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};Dc.locally=e=>{re().log("stream/queryStreams.locally",e)};return e.API_REGIONS=rt,e.VERSION=a,e.acceptFollower=async e=>{const t=re();t.log("follow/acceptFollower",e);const{data:r}=await t.http.post(`/api/v4/me/followers/${e}`);return t.cache&&ts(r),ue("follow.accepted",r.follows[0]),!0},e.addChannelMembers=async(e,t)=>{const r=re();r.log("channel/addChannelMembers",e,t);const{data:n}=await r.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users`,{channelId:e,userIds:t});r.cache&&ts(n),ue("v3.channel.didAddUsers",{channels:n.channels,channelUsers:n.channelUsers});const{channelUsers:o}=n;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,r)=>{const n=re();n.log("channel/addChannelMembersRole",e,t,r);const{data:o}=await n.http.post(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{channelId:e,role:t,userIds:r});n.cache&&ts(o);const{channelUsers:i}=o;return!!i.find((r=>r.channelId===e&&r.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const r=re();r.log("community/addCommunityMembers",e,t);const{data:n}=await r.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});r.cache&&ts(n),ue("community.userAdded",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRoles=async(e,t,r)=>{const n=re();n.log("community/addCommunityMembersRoles",e,t,r);const{data:o}=await n.http.post(`/api/v4/communities/${e}/users/roles`,{communityId:e,roles:t,userIds:r});n.cache&&ts(o);const{communityUsers:i}=o;return!!i.find((r=>r.communityId===e&&t.some((e=>r.roles.includes(e)))))},e.addReaction=Ia,e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:r,cache:n,userId:o}=re();if(!n)return!1;r("cache/api/backupCache",{storageKey:e});const i=Object.fromEntries(Object.entries(n.data).filter((([e,r])=>t(r))));return!!Object.keys(i).length&&(await je.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.closePoll=async e=>{const t=re();t.log("user/closePoll",e);const{data:r}=await t.http.put(`/api/v3/polls/${encodeURIComponent(e)}`,{status:"closed"}),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{polls:o}=r;return{data:o.find((t=>t.pollId===e)),cachedAt:n}},e.connectClient=async(e,t)=>{var r;const n=re();n.log("client/api/connectClient",Object.assign({apiKey:n.apiKey},e)),null!==(r=e.deviceId)&&void 0!==r||(e.deviceId=Xi());const{accessToken:o,users:i}=await(async e=>{const t=re();t.log("client/api/getToken",e);const r=await Yi(),{data:n}=await t.http.post("/v1/device",Object.assign(Object.assign({},e),{deviceInfo:r}),{headers:{"X-API-Key":t.apiKey}});return n})(e);var s,a,c;n.http.defaults.headers.common.Authorization=`Bearer ${o}`,n.ws.io.opts.query={token:o},s=n.ws,a=n.emitter,se.forEach((e=>{s.on(e,(t=>a.emit(e,t)))})),await new Promise((e=>{n.ws.once("connect",e),n.ws.open()})),n.userId=e.userId,n.accessToken=o,c=i[0],he={_id:c._id,userId:c.userId,path:c.path},!0!==(null==t?void 0:t.disableRTE)&&ve(me());const l=[es((()=>{Ji(),l.forEach((e=>e()))})),ns((()=>null))];return n.ws.connected},e.createChannel=async e=>{const t=re();let r;t.log("user/createChannel",e),r="conversation"===(null==e?void 0:e.type)?await t.http.post("/api/v3/channels/conversation",Object.assign(Object.assign({},e),{isDistinct:!0})):await t.http.post("/api/v3/channels",e);const n=t.cache&&Date.now();t.cache&&ts(r.data,{cachedAt:n});const{channels:o}=r.data;return{data:o[0],cachedAt:n}},e.createClient=(e,t=rt.SG,r="amity")=>{const n=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&!o,r=tt(e),n=(e,...n)=>{t&&r(e,n)};return n.__instance__=r,n})(r);n("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiRegion:t});const i=Or(ot("http",t)),s=(e=>{const t=Hi(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(ot("http",t)),c=Qi(ot("mqtt",t)),l=ce(),u={version:`${a}`,apiKey:e,log:n,http:i,ws:s,mqtt:c,emitter:l,use:()=>ne(u)};try{re()}catch(e){ne(u)}return u},e.createComment=async e=>{const t=re();t.log("comment/createComment",e);const{data:r}=await t.http.post("/api/v3/comments",e),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const o=await ya(e.referenceId);ue("post.updated",{posts:[o.data]}),ue("comment.created",r);const{comments:i}=r;return{data:i[0],cachedAt:n}},e.createCommunity=async e=>{const t=re();t.log("user/createCommunity",e);const{data:r}=await t.http.post("/api/v3/communities/",e),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n}),ue("community.created",r);const{communities:o}=r;return{data:o[0],cachedAt:n}},e.createFile=async(e,t)=>{const r=re();if(r.log("file/createFile",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const n="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await r.http.post("/api/v4/files",e,{headers:n,onUploadProgress({loaded:e,total:r}){t&&t(Math.round(100*e/r))}}),i=r.cache&&Date.now();return r.cache&&ts({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createImage=async(e,t)=>{const r=re();if(r.log("file/createImage",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const n="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await r.http.post("/api/v4/images",e,{headers:n,onUploadProgress({loaded:e,total:r}){t&&t(Math.round(100*e/r))}}),i=r.cache&&Date.now();return r.cache&&ts({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createMessage=fa,e.createPoll=async e=>{const t=re();t.log("post/createPoll",e);const{data:r}=await t.http.post("/api/v3/polls",e),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{polls:o}=r;return{data:o[0],cachedAt:n}},e.createPost=async e=>{const t=re();t.log("post/createPost",e),e.dataType&&!["text","image","file","video"].includes(e.dataType)||delete e.dataType;const{data:r}=await t.http.post("/api/v4/posts",e),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n}),ue("post.created",r);const{posts:o}=r;return{data:o[0],cachedAt:n}},e.createQuery=K,e.createReport=async(e,t)=>{const r=re();r.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:n}=Ja[e],{data:o}=await r.http.post(`/api/v3/${n}/${encodeURIComponent(t)}/flag`);r.cache&&ts(o);return ue("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=re();t.log("stream/createStream",e);const{data:r}=await t.http.post("/api/v3/video-streaming",e),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{videoStreamings:o}=r;return{data:o[0],cachedAt:n}},e.createUserToken=async(e,t,r)=>{const n=Xi(),o=await Yi(),i=Or(ot("http",t)),{data:s}=await i.post("/api/v3/sessions",Object.assign(Object.assign({},r),{deviceId:n,deviceInfo:Object.assign(Object.assign({},o),{model:"token management API on TS-SDK"})}),{headers:{"X-API-Key":e}});return{accessToken:s.accessToken}},e.createVideo=async(e,t)=>{const r=re();if(r.log("file/createVideo",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const n="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await r.http.post("/api/v4/videos",e,{headers:n,onUploadProgress({loaded:e,total:r}){t&&t(Math.round(100*e/r))}}),i=r.cache&&Date.now();return r.cache&&ts({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.declineFollower=async e=>{const t=re();t.log("follow/declineFollower",e);const{data:r}=await t.http.delete(`/api/v4/me/followers/${e}`);return t.cache&&ts(r),ue("follow.requestDeclined",r.follows[0]),!0},e.deleteChannel=async e=>{const t=re();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await Ga(e)).data},e.deleteComment=async(e,t=!1)=>{const r=re();r.log("comment/deleteComment",e);const n=await Aa(e);await r.http.delete(`/api/v4/comments/${encodeURIComponent(e)}`,{params:{commentId:e,permanent:t}});const o=Object.assign(Object.assign({},n.data),{isDeleted:!0}),i=await ya(n.data.referenceId);return ue("post.updated",{posts:[i.data]}),ue("comment.deleted",{comments:[o]}),t?setTimeout((()=>{He(["comment","get",e],!0)}),0):$e(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=re();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const r=await wa(e);return ue("community.deleted",{communities:[r.data]}),r.data},e.deleteFile=async e=>{const t=re();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),He(["file","get",e],!0),{success:!0}},e.deleteMessage=pa,e.deletePoll=async e=>{const t=re();t.log("poll/deletePoll",e);const r=await Uc(e),{data:n}=await t.http.delete(`/api/v3/polls/${e}`),{success:o}=n,i=Object.assign(Object.assign({},r.data),{isDeleted:!0});return $e(["poll","get",e],i),o},e.deletePost=async(e,t=!1)=>{const r=re();r.log("post/deletePost",e);const n=await ya(e);if(await r.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===n.data.targetType){const e=await wa(n.data.targetId);ue("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},n.data),{isDeleted:!0});return ue("post.deleted",{posts:[o]}),t?setTimeout((()=>{He(["post","get",e],!0)}),0):$e(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const r=re();r.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:n}=Ja[e],{data:o}=await r.http.delete(`/api/v3/${n}/${encodeURIComponent(t)}/unflag`);r.cache&&ts(o);return ue("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=re();t.log("stream/deleteStream",e);const r=await Lc(e),{data:n}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=n,i=Object.assign(Object.assign({},r.data),{isDeleted:!0});return $e(["stream","get",e],i),o},e.disableCache=()=>{const e=re();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=Ji,e.disposeStream=async e=>{const t=re();t.log("stream/disposeStream",e);const{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}/streaming-url`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n});const{videoStreamings:o}=r;return{data:o.find((t=>t.streamId===e)),cachedAt:n}},e.dropFromCache=He,e.enableCache=(e={},t)=>{const r=re();r.cache||(r.log("cache/api/enableCache"),r.cache={data:e,persistIf:t})},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=(e,t,r)=>void 0!==r?e.filter((e=>e[t]===r)):e,e.follow=async e=>{const t=re();t.log("follow/follow",e);const{data:r}=await t.http.post(`/api/v4/me/following/${e}`),n=t.cache&&Date.now();return t.cache&&ts(r,{cachedAt:n}),ue("accepted"===r.follows[0].status?"follow.created":"follow.requested",r.follows[0]),{data:r.follows[0],cachedAt:n}},e.getActiveClient=re,e.getCategory=_c,e.getChannel=Ga,e.getChannels=Ya,e.getComment=Aa,e.getCommentTopic=({path:e})=>e,e.getComments=Ea,e.getCommunities=ba,e.getCommunity=wa,e.getCommunityTopic=({path:t},r=e.SubscriptionLevels.COMMUNITY)=>pe(t,r),e.getFile=fs,e.getFollowInfo=xc,e.getMessage=gs,e.getMessages=ys,e.getMyFollowersTopic=()=>{const e=fe(),[t]=e.path.split("/user/");return`${t}/membership/${e._id}/+/+`},e.getMyFollowingsTopic=()=>{const e=fe(),[t]=e.path.split("/user/");return`${t}/membership/+/${e._id}/+`},e.getNetworkTopic=me,e.getPoll=Uc,e.getPost=ya,e.getPostTopic=({path:t},r=e.SubscriptionLevels.POST)=>"comment"===r?`${t}/comment/+`:t,e.getPosts=ga,e.getRecommendedCommunities=ka,e.getRole=ps,e.getStream=Lc,e.getTopTrendingCommunities=_a,e.getUser=os,e.getUserTopic=({path:t},r=e.SubscriptionLevels.USER)=>pe(r===e.SubscriptionLevels.USER?t:t.replace(/^(\w*)/,"$1/social"),r),e.getUsers=is,e.isAfterBefore=R,e.isAfterBeforeRaw=P,e.isCachable=V,e.isConnected=()=>{var e,t;const r=re();return r.log("client/api/isConnected",r),!!(r.userId&&(null===(t=null===(e=r.http.defaults.headers.common)||void 0===e?void 0:e.Authorization)||void 0===t?void 0:t.length)&&r.ws.connected)},e.isFetcher=z,e.isFresh=W,e.isLocal=e=>V(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=$,e.isOffline=H,e.isPaged=B,e.isReportedByMe=async(e,t)=>{var r,n;const o=re();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=Ja[e],{result:a,isFlagByMe:c}=null!==(r=await(async(e,t,r)=>{const{ws:n}=e;return await new Promise(((e,o)=>{n.emit(t,r,(t=>{try{e(xr(t))}catch(e){o(e)}}))}))})(o,i,{[s]:t}))&&void 0!==r?r:{};return null!==(n=null!=a?a:c)&&void 0!==n&&n},e.isSkipLimit=O,e.joinChannel=async e=>{const t=re();t.log("channel/joinChannel",e);const{data:r}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&ts(r);const{channelUsers:n}=r;return!!n.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=re();t.log("community/joinCommunity",e);const{data:r}=await t.http.post(`/api/v3/communities/${e}/join`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n}),ue("community.joined",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=re();t.log("channel/leaveChannel",e);const{data:r}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&ts(r);const{channelUsers:n}=r;return!!n.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=re();t.log("community/leaveCommunity",e);const{data:r}=await t.http.delete(`/api/v3/communities/${e}/leave`),n=t.cache&&Date.now();t.cache&&ts(r,{cachedAt:n}),ue("community.left",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=ze,e.observeChannel=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeChannel(tmpid: ${n}) > listen`);const o=(r,n)=>{var o,i,s;if((null===(o=r.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(r);"onFetch"!==n&&(null===(i=t.onEvent)||void 0===i||i.call(t,n,r)),null===(s=t[n])||void 0===s||s.call(t,r)}},i=[];return i.push(ec((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),tc((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),rc((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),nc((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),oc((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),ic((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),J(K(Ga,e),(e=>e.data&&o(e,"onFetch"))),()=>{r(`observeChannel(tmpid: ${n}) > dispose`),i.forEach((e=>e()))}},e.observeComment=(e,t,r="cache_then_server")=>{const{log:n}=re(),o=Date.now();n(`observeComment(tmpid: ${o}) > listen`);const i=(e,r)=>{var n,o;if(t instanceof Function)return t(e);"onFetch"!==r&&(null===(n=t.onEvent)||void 0===n||n.call(t,r,e)),null===(o=t[r])||void 0===o||o.call(t,e)},s=(t,r)=>{var n;(null===(n=t.data)||void 0===n?void 0:n.commentId)===e&&i(t,r)},a=[];return a.push($a((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Ha((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Va((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Wa((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Ka((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Qa((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),J(K(Aa,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(r)),()=>{n(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeComments(tmpid: ${n}) > listen`);const o=[],i=(r,n)=>{var o,i;if(r.referenceId===e){if(t instanceof Function)return t(r);null===(o=t.onEvent)||void 0===o||o.call(t,n,r),null===(i=t[n])||void 0===i||i.call(t,r)}};return o.push(za((e=>i(e,"onCreate"))),$a((e=>i(e,"onUpdate"))),Ha((e=>i(e,"onDelete"))),Va((e=>i(e,"onFlagged"))),Wa((e=>i(e,"onUnflagged"))),Ka((e=>i(e,"onReactionAdded"))),Qa((e=>i(e,"onReactionRemoved")))),()=>{r(`observeComments(tmpid: ${n}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeCommunity(tmpid: ${n}) > listen`);const o=(e,r)=>{var n,o;if(t instanceof Function)return t(e);"onFetch"!==r&&(null===(n=t.onEvent)||void 0===n||n.call(t,r,e)),null===(o=t[r])||void 0===o||o.call(t,e)},i=(t,r)=>{var n;(null===(n=t.data)||void 0===n?void 0:n.communityId)===e&&o(t,r)},s=[];return s.push(dc((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),pc((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),mc((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),gc((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),yc((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),vc((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),bc((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),wc((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),J(K(wa,e),(e=>(e.data||e.error)&&o(e,"onFetch"))),()=>{r(`observeCommunity(tmpid: ${n}) > dispose`),s.forEach((e=>e()))}},e.observeFile=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeFile(tmpid: ${n}) > listen`);return J(K(fs,e),(r=>r.data&&((r,n)=>{var o,i,s;if((null===(o=r.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(r);"onFetch"!==n&&(null===(i=t.onEvent)||void 0===i||i.call(t,n,r)),null===(s=t[n])||void 0===s||s.call(t,r)}})(r,"onFetch"))),()=>{r(`observeFile(tmpid: ${n}) > dispose`)}},e.observeFollowInfo=(e,t,r="cache_then_server")=>{const{log:n}=re(),o=Date.now();n(`observeFollowInfo(tmpid: ${o}) > listen`);const i=(e,r)=>{var n,o;if(t instanceof Function)return t(e);"onFetch"!==r&&(null===(n=t.onEvent)||void 0===n||n.call(t,r,e)),null===(o=t[r])||void 0===o||o.call(t,e)},s=[];return s.push(Mc((t=>((t,r)=>{var n;(null===(n=t.data)||void 0===n?void 0:n.userId)===e&&i(t,r)})({data:t,loading:!1,origin:"event"},"onUpdate")))),J(K(xc,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(r)),()=>{n(`observeFollowInfo(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeFollowers=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeFollowers(tmpid: ${n}) > listen`);const o=[],i=(r,n)=>{var o,i;if(r.from===e){if(t instanceof Function)return t(r);null===(o=t.onEvent)||void 0===o||o.call(t,n,r),null===(i=t[n])||void 0===i||i.call(t,r)}};return o.push(Bc((e=>i(e,"onRequested"))),jc((e=>i(e,"onAccepted"))),Fc((e=>i(e,"onDeclined"))),Nc((e=>i(e,"onCanceled"))),Oc((e=>i(e,"onFollowed"))),Rc((e=>i(e,"onUnfollowed"))),Pc((e=>i(e,"onDeleted")))),()=>{r(`observeFollowers(tmpid: ${n}) > dispose`),o.forEach((e=>e()))}},e.observeFollowings=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeFollowings(tmpid: ${n}) > listen`);const o=[],i=(r,n)=>{var o,i;if(r.to===e){if(t instanceof Function)return t(r);null===(o=t.onEvent)||void 0===o||o.call(t,n,r),null===(i=t[n])||void 0===i||i.call(t,r)}};return o.push(Bc((e=>i(e,"onRequested"))),jc((e=>i(e,"onAccepted"))),Fc((e=>i(e,"onDeclined"))),Nc((e=>i(e,"onCanceled"))),Oc((e=>i(e,"onFollowed"))),Rc((e=>i(e,"onUnfollowed"))),Pc((e=>i(e,"onDeleted")))),()=>{r(`observeFollowings(tmpid: ${n}) > dispose`),o.forEach((e=>e()))}},e.observeMessage=(e,t,r="cache_then_server")=>{const{log:n}=re(),o=Date.now();n(`observeMessage(tmpid: ${o}) > listen`);const i=(r,n)=>{var o,i,s;if((null===(o=r.data)||void 0===o?void 0:o.messageId)===e){if(t instanceof Function)return t(r);"onFetch"!==n&&(null===(i=t.onEvent)||void 0===i||i.call(t,n,r)),null===(s=t[n])||void 0===s||s.call(t,r)}},s=[];return s.push(ac((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),cc((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==r&&J(K(gs,e),(e=>e.data&&i(e,"onFetch")),Q(r)),()=>{n(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeMessages(tmpid: ${n}) > listen`);const o=[],i=(r,n)=>{var o,i,s;if((null===(o=r.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(r);null===(i=t.onEvent)||void 0===i||i.call(t,n,r),null===(s=t[n])||void 0===s||s.call(t,r)}};return o.push(sc((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),ac((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),cc((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),()=>{r(`observeMessages(tmpid: ${n}) > dispose`),o.forEach((e=>e()))}},e.observePost=(e,t,r="cache_then_server")=>{const{log:n}=re(),o=Date.now();n(`observePost(tmpid: ${o}) > listen`);const i=(e,r)=>{var n,o;if(t instanceof Function)return t(e);"onFetch"!==r&&(null===(n=t.onEvent)||void 0===n||n.call(t,r,e)),null===(o=t[r])||void 0===o||o.call(t,e)},s=(t,r)=>{var n;(null===(n=t.data)||void 0===n?void 0:n.postId)===e&&i(t,r)},a=[];return a.push(Ba((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Na((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),ja((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),Fa((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),Ma((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Ua((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),La((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Da((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),J(K(ya,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(r)),()=>{n(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observePosts(tmpid: ${n}) > listen`);const o=[],i=(r,n)=>{var o,i;if(e.targetId===r.targetId&&e.targetType===r.targetType){if(t instanceof Function)return t(r);null===(o=t.onEvent)||void 0===o||o.call(t,n,r),null===(i=t[n])||void 0===i||i.call(t,r)}};return o.push(Pa((e=>i(e,"onCreate"))),Ba((e=>i(e,"onUpdate"))),Na((e=>i(e,"onDelete"))),ja((e=>i(e,"onApproved"))),Fa((e=>i(e,"onDeclined"))),Ma((e=>i(e,"onFlagged"))),Ua((e=>i(e,"onUnflagged"))),La((e=>i(e,"onReactionAdded"))),Da((e=>i(e,"onReactionRemoved")))),()=>{r(`observePosts(tmpid: ${n}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:r}=re(),n=Date.now();r(`observeUser(tmpid: ${n}) > listen`);const o=(r,n)=>{var o,i,s;if((null===(o=r.data)||void 0===o?void 0:o.userId)===e){if(t instanceof Function)return t(r);"onFetch"!==n&&(null===(i=t.onEvent)||void 0===i||i.call(t,n,r)),null===(s=t[n])||void 0===s||s.call(t,r)}},i=[];return i.push(cs((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),ns((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),ls((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),us((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),hs((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),J(K(os,e),(e=>e.data&&o(e,"onFetch"))),()=>{r(`observeUser(tmpid: ${n}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=tc,e.onChannelJoined=rc,e.onChannelLeft=nc,e.onChannelMemberAdded=oc,e.onChannelMemberRemoved=ic,e.onChannelUpdated=ec,e.onClientBanned=es,e.onClientDisconnected=e=>Zi((({code:t})=>{800211===t&&e()})),e.onCommentCreated=za,e.onCommentDeleted=Ha,e.onCommentFlagged=Va,e.onCommentReactionAdded=Ka,e.onCommentReactionRemoved=Qa,e.onCommentUnflagged=Wa,e.onCommentUpdated=$a,e.onCommunityCreated=e=>lc("community.created",e),e.onCommunityDeleted=pc,e.onCommunityJoined=mc,e.onCommunityLeft=gc,e.onCommunityUpdated=dc,e.onCommunityUserAdded=yc,e.onCommunityUserBanned=bc,e.onCommunityUserRemoved=vc,e.onCommunityUserUnbanned=wc,e.onConnectionError=Zi,e.onFollowInfoUpdated=Mc,e.onFollowRequestAccepted=jc,e.onFollowRequestCanceled=Nc,e.onFollowRequestDeclined=Fc,e.onFollowerDeleted=Pc,e.onFollowerRequested=Bc,e.onMessageCreated=sc,e.onMessageDeleted=cc,e.onMessageUpdated=ac,e.onPostApproved=ja,e.onPostCreated=Pa,e.onPostDeclined=Fa,e.onPostDeleted=Na,e.onPostFlagged=Ma,e.onPostReactionAdded=La,e.onPostReactionRemoved=Da,e.onPostUnflagged=Ua,e.onPostUpdated=Ba,e.onReactionRemoved=(e,t,r)=>{const n=n=>{U(e)(n)===t&&r(n)};if("message"===e){const e=re(),t=e=>{var t;const r=De(["message","get",e.messages[0].messageId]),o=(null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.reactionsCount)!==e.messages[0].reactionsCount;ts(e),o&&n(e.messages[0])};return le(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?Da(n):Qa(n)},e.onStreamRecorded=e=>{const t=re();return le(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{ts(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=re();return le(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{ts(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=re();return le(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{ts(t),e(t.videoStreamings[0])}))},e.onUserDeleted=ns,e.onUserFlagCleared=hs,e.onUserFlagged=ls,e.onUserFollowed=Oc,e.onUserUnflagged=us,e.onUserUnfollowed=Rc,e.onUserUpdated=cs,e.pullFromCache=De,e.pushToCache=qe,e.queryCache=Le,e.queryCategories=Cc,e.queryChannelMembers=Za,e.queryChannels=Xa,e.queryComments=Sa,e.queryCommunities=va,e.queryCommunityMembers=Ca,e.queryFollowers=Ec,e.queryFollowings=Ac,e.queryGlobalFeed=kc,e.queryMessages=vs,e.queryOptions=Q,e.queryPosts=ma,e.queryReactions=async e=>{const t=re();t.log("reaction/queryReactions",e);const r=null!=e?e:{},{page:n={limit:10}}=r,o=ss(r,["page"]),{data:i}=await t.http.get("/api/v2/reactions",{params:Object.assign(Object.assign({},o),{options:{token:N(n,"skiplimit")}})}),{paging:s,results:a}=i,{reactions:c}=a,l=j(s.next);return{data:c,prevPage:j(s.previous),nextPage:l}},e.queryRoles=ds,e.queryStreams=Dc,e.queryUsers=as,e.removeChannelMembers=async(e,t)=>{const r=re();r.log("channel/removeChannelMembers",e,t);const{data:n}=await r.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users`,{data:{channelId:e,userIds:t}});r.cache&&ts(n),ue("v3.channel.didRemoveUsers",{channels:n.channels,channelUsers:n.channelUsers});const{channelUsers:o}=n;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,r)=>{const n=re();n.log("channel/removeChannelMembersRole",e,t,r);const{data:o}=await n.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/users/roles`,{data:{channelId:e,role:t,userIds:r}});n.cache&&ts(o);const{channelUsers:i}=o;return!!i.find((r=>r.channelId===e&&!r.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const r=re();r.log("community/removeCommunityMembers",e,t);const{data:n}=await r.http.delete(`/api/v3/communities/${e}/users`,{data:{communityId:e,userIds:t}});r.cache&&ts(n),ue("community.userRemoved",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRoles=async(e,t,r)=>{const n=re();n.log("community/removeCommunityMembersRoles",e,t,r);const{data:o}=await n.http.delete(`/api/v4/communities/${e}/users/roles`,{data:{communityId:e,roles:t,userIds:r}});n.cache&&ts(o);const{communityUsers:i}=o;return!!i.find((r=>r.communityId===e&&!t.some((e=>r.roles.includes(e)))))},e.removeReaction=Oa,e.restoreCache=async(e="amitySdk")=>{var t;const r=re();if(!r.cache)return!1;r.log("cache/api/restoreCache",{storageKey:e});const n=null!==(t=await je.getItem(`${e}#${r.userId}`))&&void 0!==t?t:"{}";let o={};try{o=JSON.parse(n)}catch(e){}return r.cache.data=Object.assign(Object.assign({},o),r.cache.data),!0},e.runQuery=J,e.sortByChannelSegment=({channelSegment:e},{channelSegment:t})=>e-t,e.sortByDisplayName=({displayName:e},{displayName:t})=>e===t?0:e<t?-1:1,e.sortByFirstCreated=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),e.sortByLastActivity=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortByLastCreated=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortBySegmentNumber=({segmentNumber:e},{segmentNumber:t})=>e-t,e.subscribeTopic=ve,e.toPage=j,e.toPageRaw=F,e.toToken=N,e.unfollow=async e=>{const t=re();t.log("follow/unfollow",e);const{data:r}=await t.http.delete(`/api/v4/me/following/${e}`);return t.cache&&ts(r),ue("follow.unfollowed",r.follows[0]),!0},e.updateChannel=async(e,t)=>{const r=re();r.log("channel/updateChannel",e,t);const{data:n}=await r.http.put(`/api/v3/channels/${encodeURIComponent(e)}`,t),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o});const{channels:i}=n;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const r=re();r.log("user/updateComment",t);const{data:n}=await r.http.put(`/api/v3/comments/${encodeURIComponent(e)}`,t),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o}),ue("comment.updated",n);const{comments:i}=n;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const r=re();r.log("community/updateCommunity",e,t);const{data:n}=await r.http.put(`/api/v3/communities/${e}`,t),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o}),ue("community.updated",n);const{communities:i}=n;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=da,e.updatePost=async(e,t)=>{const r=re();r.log("user/updatePost",t);const{data:n}=await r.http.put(`/api/v4/posts/${encodeURIComponent(e)}`,t),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o}),ue("post.updated",n);const{posts:i}=n;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const r=re();r.log("stream/updateStream",e,t);const{data:n}=await r.http.put(`/api/v3/video-streaming/${e}`,t),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o});const{videoStreamings:i}=n;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const r=re();r.log("user/updateUser",e,t);const{data:n}=await r.http.put("/api/v3/users/",Object.assign(Object.assign({userId:e},t),{createNewUserWhenNotFound:!1})),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o});const{users:i}=n;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=$e,e.votePoll=async(e,t)=>{const r=re();r.log("user/votePoll",e);const{data:n}=await r.http.post(`/api/v3/polls/${encodeURIComponent(e)}/votes`,{pollId:e,answerIds:t}),o=r.cache&&Date.now();r.cache&&ts(n,{cachedAt:o});const{polls:i}=n;return{data:i.find((t=>t.pollId===e)),cachedAt:o}},e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:r,userId:n}=re();return!!r&&(t("cache/api/wipeCache",{storageKey:e}),r.data={},await je.setItem(`${e}#${n}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|