@amityco/ts-sdk 0.0.1-beta.12 → 0.0.1-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/domains/client.d.ts +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +2 -1
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +2 -2
- package/dist/@types/domains/file.d.ts.map +1 -1
- package/dist/@types/domains/partials.d.ts +10 -0
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +3 -2
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/client/api/disconnectClient.d.ts.map +1 -1
- package/dist/comment/api/createComment.d.ts +1 -1
- package/dist/comment/api/createComment.d.ts.map +1 -1
- package/dist/comment/api/updateComment.d.ts +1 -1
- package/dist/comment/api/updateComment.d.ts.map +1 -1
- package/dist/index.cjs.js +11 -11
- package/dist/index.esm.js +11 -11
- package/dist/index.umd.js +3 -3
- package/dist/post/api/createPost.d.ts +7 -3
- package/dist/post/api/createPost.d.ts.map +1 -1
- package/dist/post/api/updatePost.d.ts +1 -1
- package/dist/post/api/updatePost.d.ts.map +1 -1
- package/package.json +1 -1
- package/rollup.config.js +3 -0
- package/src/@types/domains/client.ts +1 -1
- package/src/@types/domains/comment.ts +3 -0
- package/src/@types/domains/file.ts +2 -1
- package/src/@types/domains/partials.ts +8 -0
- package/src/@types/domains/post.ts +4 -1
- package/src/client/api/connectClient.ts +1 -1
- package/src/client/api/disconnectClient.ts +0 -1
- package/src/comment/api/createComment.ts +1 -2
- package/src/comment/api/updateComment.ts +1 -1
- package/src/core/debug.ts +1 -1
- package/src/core/subscription.ts +4 -4
- package/src/post/api/createPost.ts +6 -4
- package/src/post/api/updatePost.ts +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var Amity=function(e){"use strict";var t;const n=null!==(t="v0.0.1-beta.12-umd")?t:"__dev__",r="function"==typeof atob,o="function"==typeof btoa,i="function"==typeof Buffer,s="function"==typeof TextDecoder?new TextDecoder:void 0,a="function"==typeof TextEncoder?new TextEncoder:void 0,c=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],u=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(c),l=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,h=String.fromCharCode.bind(String),p="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),f=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),d=o?e=>btoa(e):i?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+=c[t>>18&63]+c[t>>12&63]+c[t>>6&63]+c[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},m=i?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(h.apply(null,e.subarray(n,n+4096)));return d(t.join(""))},g=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?h(192|t>>>6)+h(128|63&t):h(224|t>>>12&15)+h(128|t>>>6&63)+h(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return h(240|t>>>18&7)+h(128|t>>>12&63)+h(128|t>>>6&63)+h(128|63&t)},y=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,b=i?e=>Buffer.from(e,"utf8").toString("base64"):a?e=>m(a.encode(e)):e=>d(e.replace(y,g)),v=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,w=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 h(55296+(t>>>10))+h(56320+(1023&t));case 3:return h((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return h((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},_=r?e=>atob(f(e)):i?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!l.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=u[e.charAt(i++)]<<18|u[e.charAt(i++)]<<12|(n=u[e.charAt(i++)])<<6|(r=u[e.charAt(i++)]),o+=64===n?h(t>>16&255):64===r?h(t>>16&255,t>>8&255):h(t>>16&255,t>>8&255,255&t);return o},C=i?e=>p(Buffer.from(e,"base64")):e=>p(_(e),(e=>e.charCodeAt(0))),S=i?e=>Buffer.from(e,"base64").toString("utf8"):s?e=>s.decode(C(e)):e=>_(e).replace(v,w),k=e=>S(f(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),E=e=>["skip","limit"].some((t=>t in e)),A=e=>["after","before","first","last"].some((t=>t in e)),I=e=>["after","before"].some((t=>t in e)),x=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),R=(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?isNaN(null==e?void 0:e.before)?isNaN(null==e?void 0:e.after)?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,(e=>"+"==e?"-":"_")).replace(/=+$/m,""))(b(e)):b(e))(JSON.stringify(r)):void 0},O=e=>{if(!e)return null;const t=JSON.parse(k(e));if(E(t))return{after:t.skip,limit:t.limit};if(A(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}return null},T=e=>{if(!e)return null;const t=JSON.parse(k(e));return I(t)?t:null},F=e=>"locally"in e,P=e=>"optimistically"in e,B=e=>F(e)||P(e),j=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),U=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},M=(e,...t)=>({func:e,args:t}),N=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},L=({func:e,args:t},n,r=N("cache_then_server"))=>{let o;if(B(e)&&0!==r.lifeSpan){try{o=P(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(D(void 0,{origin:"local",loading:!1,error:e}))}const i=j(o)&&U(o,r.lifeSpan);if(null==n||n(D(o,{origin:"local",loading:!(F(e)&&i)})),i)return}else null==n||n(D(void 0,{origin:"local",loading:!0}));e(...t).then((e=>{null==n||n(D(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(D(void 0,{origin:"server",loading:!1,error:e}))}))};function D(e,t){return x(e)||j(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class q 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,q)}}class $ extends q{constructor(e,t,n){super(e,t,n)}}class H extends q{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class W extends q{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let V=null;const z=()=>{if(!V)throw new q("There is no active client",8e5,"fatal");return V},K=e=>{V=e};var J="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Q(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}function Y(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.')}var X={exports:{}},G=1e3,Z=6e4,ee=60*Z,te=24*ee,ne=7*te,re=365.25*te,oe=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*re;case"weeks":case"week":case"w":return n*ne;case"days":case"day":case"d":return n*te;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ee;case"minutes":case"minute":case"mins":case"min":case"m":return n*Z;case"seconds":case"second":case"secs":case"sec":case"s":return n*G;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>=te)return ie(e,t,te,"day");if(t>=ee)return ie(e,t,ee,"hour");if(t>=Z)return ie(e,t,Z,"minute");if(t>=G)return ie(e,t,G,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=te)return Math.round(e/te)+"d";if(t>=ee)return Math.round(e/ee)+"h";if(t>=Z)return Math.round(e/Z)+"m";if(t>=G)return Math.round(e/G)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ie(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var se=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.substr(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=oe,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=se(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(X,X.exports);var ae=X.exports;const ce="sg";var ue;!function(e){e.HTTP="https://api.{region}.amity.co",e.MQTT="wss://sse.{region}.amity.co:443/mqtt"}(ue||(ue={}));const le=(e,t)=>e.replace("{region}",t);var he={exports:{}},pe=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)}},fe=pe,de=Object.prototype.toString;function me(e){return"[object Array]"===de.call(e)}function ge(e){return void 0===e}function ye(e){return null!==e&&"object"==typeof e}function be(e){if("[object Object]"!==de.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ve(e){return"[object Function]"===de.call(e)}function we(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),me(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 _e={isArray:me,isArrayBuffer:function(e){return"[object ArrayBuffer]"===de.call(e)},isBuffer:function(e){return null!==e&&!ge(e)&&null!==e.constructor&&!ge(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:ye,isPlainObject:be,isUndefined:ge,isDate:function(e){return"[object Date]"===de.call(e)},isFile:function(e){return"[object File]"===de.call(e)},isBlob:function(e){return"[object Blob]"===de.call(e)},isFunction:ve,isStream:function(e){return ye(e)&&ve(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:we,merge:function e(){var t={};function n(n,r){be(t[r])&&be(n)?t[r]=e(t[r],n):be(n)?t[r]=e({},n):me(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)we(arguments[r],n);return t},extend:function(e,t,n){return we(t,(function(t,r){e[r]=n&&"function"==typeof t?fe(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}},Ce=_e;function Se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ke=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(Ce.isURLSearchParams(t))r=t.toString();else{var o=[];Ce.forEach(t,(function(e,t){null!=e&&(Ce.isArray(e)?t+="[]":e=[e],Ce.forEach(e,(function(e){Ce.isDate(e)?e=e.toISOString():Ce.isObject(e)&&(e=JSON.stringify(e)),o.push(Se(t)+"="+Se(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Ee=_e;function Ae(){this.handlers=[]}Ae.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},Ae.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Ae.prototype.forEach=function(e){Ee.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Ie=Ae,xe=_e,Re=function(e){return!(!e||!e.__CANCEL__)},Oe=_e,Te=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},Fe=function(e,t,n,r,o){var i=new Error(e);return Te(i,t,n,r,o)},Pe=Fe,Be=_e,je=Be.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),Be.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),Be.isString(r)&&s.push("path="+r),Be.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(){}},Ue=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Me=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Ne=_e,Le=["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"],De=_e,qe=De.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=De.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},$e=_e,He=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(Pe("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},We=je,Ve=ke,ze=function(e,t){return e&&!Ue(t)?Me(e,t):t},Ke=function(e){var t,n,r,o={};return e?(Ne.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=Ne.trim(e.substr(0,r)).toLowerCase(),n=Ne.trim(e.substr(r+1)),t){if(o[t]&&Le.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},Je=qe,Qe=Fe,Ye=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;$e.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=ze(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),Ve(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?Ke(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};He(t,n,o),i=null}},i.onabort=function(){i&&(n(Qe("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(Qe("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(Qe(t,e,"ECONNABORTED",i)),i=null},$e.isStandardBrowserEnv()){var u=(e.withCredentials||Je(c))&&e.xsrfCookieName?We.read(e.xsrfCookieName):void 0;u&&(o[e.xsrfHeaderName]=u)}if("setRequestHeader"in i&&$e.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),$e.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)}))},Xe=_e,Ge=function(e,t){Oe.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},Ze={"Content-Type":"application/x-www-form-urlencoded"};function et(e,t){!Xe.isUndefined(e)&&Xe.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var tt,nt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(tt=Ye),tt),transformRequest:[function(e,t){return Ge(t,"Accept"),Ge(t,"Content-Type"),Xe.isFormData(e)||Xe.isArrayBuffer(e)||Xe.isBuffer(e)||Xe.isStream(e)||Xe.isFile(e)||Xe.isBlob(e)?e:Xe.isArrayBufferView(e)?e.buffer:Xe.isURLSearchParams(e)?(et(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Xe.isObject(e)?(et(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}};nt.headers={common:{Accept:"application/json, text/plain, */*"}},Xe.forEach(["delete","get","head"],(function(e){nt.headers[e]={}})),Xe.forEach(["post","put","patch"],(function(e){nt.headers[e]=Xe.merge(Ze)}));var rt=nt,ot=_e,it=function(e,t,n){return xe.forEach(n,(function(n){e=n(e,t)})),e},st=Re,at=rt;function ct(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var ut=_e,lt=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 ut.isPlainObject(e)&&ut.isPlainObject(t)?ut.merge(e,t):ut.isPlainObject(t)?ut.merge({},t):ut.isArray(t)?t.slice():t}function c(r){ut.isUndefined(t[r])?ut.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}ut.forEach(r,(function(e){ut.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),ut.forEach(o,c),ut.forEach(i,(function(r){ut.isUndefined(t[r])?ut.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),ut.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 u=r.concat(o).concat(i).concat(s),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===u.indexOf(e)}));return ut.forEach(l,c),n},ht=_e,pt=ke,ft=Ie,dt=function(e){return ct(e),e.headers=e.headers||{},e.data=it(e.data,e.headers,e.transformRequest),e.headers=ot.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ot.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||at.adapter)(e).then((function(t){return ct(e),t.data=it(t.data,t.headers,e.transformResponse),t}),(function(t){return st(t)||(ct(e),t&&t.response&&(t.response.data=it(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},mt=lt;function gt(e){this.defaults=e,this.interceptors={request:new ft,response:new ft}}gt.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=mt(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[dt,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},gt.prototype.getUri=function(e){return e=mt(this.defaults,e),pt(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ht.forEach(["delete","get","head","options"],(function(e){gt.prototype[e]=function(t,n){return this.request(mt(n||{},{method:e,url:t,data:(n||{}).data}))}})),ht.forEach(["post","put","patch"],(function(e){gt.prototype[e]=function(t,n,r){return this.request(mt(r||{},{method:e,url:t,data:n}))}}));var yt=gt;function bt(e){this.message=e}bt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},bt.prototype.__CANCEL__=!0;var vt=bt,wt=vt;function _t(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 wt(e),t(n.reason))}))}_t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},_t.source=function(){var e;return{token:new _t((function(t){e=t})),cancel:e}};var Ct=_t,St=_e,kt=pe,Et=yt,At=lt;function It(e){var t=new Et(e),n=kt(Et.prototype.request,t);return St.extend(n,Et.prototype,t),St.extend(n,t),n}var xt=It(rt);xt.Axios=Et,xt.create=function(e){return It(At(xt.defaults,e))},xt.Cancel=vt,xt.CancelToken=Ct,xt.isCancel=Re,xt.all=function(e){return Promise.all(e)},xt.spread=function(e){return function(t){return e.apply(null,t)}},xt.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},he.exports=xt,he.exports.default=xt;var Rt=he.exports,Ot={exports:{}};Ot.exports=Ft;var Tt=Ot.exports.HttpsAgent=Ft;function Ft(){}var Pt=Ot.exports;const Bt=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new H(e.code);if("error"===e.status)throw new $(e.message,e.code,"error")},jt=(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}`:jt(n,null!=t?t:e)})).join("&");var Ut={exports:{}},Mt=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Nt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Lt=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=Mt.exec(e||""),i={},s=14;s--;)i[Nt[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},Dt={exports:{}},qt={exports:{}},$t=1e3,Ht=60*$t,Wt=60*Ht,Vt=24*Wt,zt=365.25*Vt,Kt=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*zt;case"days":case"day":case"d":return n*Vt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Wt;case"minutes":case"minute":case"mins":case"min":case"m":return n*Ht;case"seconds":case"second":case"secs":case"sec":case"s":return n*$t;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 Jt(e,Vt,"day")||Jt(e,Wt,"hour")||Jt(e,Ht,"minute")||Jt(e,$t,"second")||e+" ms"}(e):function(e){if(e>=Vt)return Math.round(e/Vt)+"d";if(e>=Wt)return Math.round(e/Wt)+"h";if(e>=Ht)return Math.round(e/Ht)+"m";if(e>=$t)return Math.round(e/$t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Jt(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 u=o.log||t.log||console.log.bind(console);u.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=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(qt,qt.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=qt.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())}(Dt,Dt.exports);var Qt=Lt,Yt=Dt.exports("socket.io-client:url"),Xt=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)||(Yt("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),Yt("parse %s",e),n=Qt(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 Gt={},Zt={exports:{}},en={exports:{}};!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 u=o.log||t.log||console.log.bind(console);u.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=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(en,en.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=en.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())}(Zt,Zt.exports);var tn={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}}(tn);var nn={},rn={}.toString,on=Array.isArray||function(e){return"[object Array]"==rn.call(e)},sn=function(e){return an&&Buffer.isBuffer(e)||cn&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},an="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,cn="function"==typeof ArrayBuffer;var un=on,ln=sn,hn=Object.prototype.toString,pn="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===hn.call(Blob),fn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===hn.call(File);function dn(e,t){if(!e)return e;if(ln(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(un(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=dn(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=dn(e[i],t);return r}return e}function mn(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(un(e))for(var n=0;n<e.length;n++)e[n]=mn(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=mn(e[r],t);return e}nn.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=dn(n,t),r.attachments=t.length,{packet:r,buffers:t}},nn.reconstructPacket=function(e,t){return e.data=mn(e.data,t),e.attachments=void 0,e},nn.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(pn&&o instanceof Blob||fn&&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(un(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!ln(o))for(var u in o)e(o[u],u,o)}(r),n||t(r)},function(e){var t=Zt.exports("socket.io-parser"),n=tn.exports,r=nn,o=on,i=sn;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=u;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 u(){this.reconstructor=null}function l(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(u.prototype),u.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(","===(u=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 u;if(null==(u=n.charAt(r))||Number(u)!=u){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var l=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==l&&(i.type===e.ERROR||o(l))))return h("invalid payload");i.data=l}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new l(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))}},u.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},l.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},l.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(Gt);var gn={exports:{}},yn={},bn={exports:{}};try{bn.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){bn.exports=!1}var vn=bn.exports,wn=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||vn))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){}},_n={exports:{}},Cn={},Sn=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},kn={}.toString,En=Array.isArray||function(e){return"[object Array]"==kn.call(e)},An=Object.prototype.toString,In="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===An.call(Blob),xn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===An.call(File),Rn=function e(t){if(!t||"object"!=typeof t)return!1;if(En(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||In&&t instanceof Blob||xn&&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 On=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},Tn=function(e,t,n){var r=!1;return n=n||Fn,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 Fn(){}
|
|
1
|
+
var Amity=function(e){"use strict";var t;const n=null!==(t="v0.0.1-beta.13-umd")?t:"__dev__",r="function"==typeof atob,o="function"==typeof btoa,i="function"==typeof Buffer,s="function"==typeof TextDecoder?new TextDecoder:void 0,a="function"==typeof TextEncoder?new TextEncoder:void 0,c=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],u=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(c),l=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,h=String.fromCharCode.bind(String),p="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),f=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),d=o?e=>btoa(e):i?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+=c[t>>18&63]+c[t>>12&63]+c[t>>6&63]+c[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},m=i?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(h.apply(null,e.subarray(n,n+4096)));return d(t.join(""))},g=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?h(192|t>>>6)+h(128|63&t):h(224|t>>>12&15)+h(128|t>>>6&63)+h(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return h(240|t>>>18&7)+h(128|t>>>12&63)+h(128|t>>>6&63)+h(128|63&t)},y=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,b=i?e=>Buffer.from(e,"utf8").toString("base64"):a?e=>m(a.encode(e)):e=>d(e.replace(y,g)),v=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,w=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 h(55296+(t>>>10))+h(56320+(1023&t));case 3:return h((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return h((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},_=r?e=>atob(f(e)):i?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!l.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=u[e.charAt(i++)]<<18|u[e.charAt(i++)]<<12|(n=u[e.charAt(i++)])<<6|(r=u[e.charAt(i++)]),o+=64===n?h(t>>16&255):64===r?h(t>>16&255,t>>8&255):h(t>>16&255,t>>8&255,255&t);return o},C=i?e=>p(Buffer.from(e,"base64")):e=>p(_(e),(e=>e.charCodeAt(0))),S=i?e=>Buffer.from(e,"base64").toString("utf8"):s?e=>s.decode(C(e)):e=>_(e).replace(v,w),k=e=>S(f(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),E=e=>["skip","limit"].some((t=>t in e)),A=e=>["after","before","first","last"].some((t=>t in e)),I=e=>["after","before"].some((t=>t in e)),x=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),R=(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?isNaN(null==e?void 0:e.before)?isNaN(null==e?void 0:e.after)?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,(e=>"+"==e?"-":"_")).replace(/=+$/m,""))(b(e)):b(e))(JSON.stringify(r)):void 0},O=e=>{if(!e)return null;const t=JSON.parse(k(e));if(E(t))return{after:t.skip,limit:t.limit};if(A(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}return null},T=e=>{if(!e)return null;const t=JSON.parse(k(e));return I(t)?t:null},F=e=>"locally"in e,P=e=>"optimistically"in e,B=e=>F(e)||P(e),j=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),U=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},M=(e,...t)=>({func:e,args:t}),N=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},L=({func:e,args:t},n,r=N("cache_then_server"))=>{let o;if(B(e)&&0!==r.lifeSpan){try{o=P(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(D(void 0,{origin:"local",loading:!1,error:e}))}const i=j(o)&&U(o,r.lifeSpan);if(null==n||n(D(o,{origin:"local",loading:!(F(e)&&i)})),i)return}else null==n||n(D(void 0,{origin:"local",loading:!0}));e(...t).then((e=>{null==n||n(D(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(D(void 0,{origin:"server",loading:!1,error:e}))}))};function D(e,t){return x(e)||j(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class q 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,q)}}class $ extends q{constructor(e,t,n){super(e,t,n)}}class H extends q{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class W extends q{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let V=null;const z=()=>{if(!V)throw new q("There is no active client",8e5,"fatal");return V},K=e=>{V=e};var J="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Q(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}function Y(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.')}var X={exports:{}},G=1e3,Z=6e4,ee=60*Z,te=24*ee,ne=7*te,re=365.25*te,oe=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*re;case"weeks":case"week":case"w":return n*ne;case"days":case"day":case"d":return n*te;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ee;case"minutes":case"minute":case"mins":case"min":case"m":return n*Z;case"seconds":case"second":case"secs":case"sec":case"s":return n*G;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>=te)return ie(e,t,te,"day");if(t>=ee)return ie(e,t,ee,"hour");if(t>=Z)return ie(e,t,Z,"minute");if(t>=G)return ie(e,t,G,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=te)return Math.round(e/te)+"d";if(t>=ee)return Math.round(e/ee)+"h";if(t>=Z)return Math.round(e/Z)+"m";if(t>=G)return Math.round(e/G)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ie(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var se=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.substr(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=oe,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=se(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(X,X.exports);var ae=X.exports;const ce="sg";var ue;!function(e){e.HTTP="https://api.{region}.amity.co",e.MQTT="wss://sse.{region}.amity.co:443/mqtt"}(ue||(ue={}));const le=(e,t)=>e.replace("{region}",t);var he={exports:{}},pe=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)}},fe=pe,de=Object.prototype.toString;function me(e){return"[object Array]"===de.call(e)}function ge(e){return void 0===e}function ye(e){return null!==e&&"object"==typeof e}function be(e){if("[object Object]"!==de.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ve(e){return"[object Function]"===de.call(e)}function we(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),me(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 _e={isArray:me,isArrayBuffer:function(e){return"[object ArrayBuffer]"===de.call(e)},isBuffer:function(e){return null!==e&&!ge(e)&&null!==e.constructor&&!ge(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:ye,isPlainObject:be,isUndefined:ge,isDate:function(e){return"[object Date]"===de.call(e)},isFile:function(e){return"[object File]"===de.call(e)},isBlob:function(e){return"[object Blob]"===de.call(e)},isFunction:ve,isStream:function(e){return ye(e)&&ve(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:we,merge:function e(){var t={};function n(n,r){be(t[r])&&be(n)?t[r]=e(t[r],n):be(n)?t[r]=e({},n):me(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)we(arguments[r],n);return t},extend:function(e,t,n){return we(t,(function(t,r){e[r]=n&&"function"==typeof t?fe(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}},Ce=_e;function Se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ke=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(Ce.isURLSearchParams(t))r=t.toString();else{var o=[];Ce.forEach(t,(function(e,t){null!=e&&(Ce.isArray(e)?t+="[]":e=[e],Ce.forEach(e,(function(e){Ce.isDate(e)?e=e.toISOString():Ce.isObject(e)&&(e=JSON.stringify(e)),o.push(Se(t)+"="+Se(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Ee=_e;function Ae(){this.handlers=[]}Ae.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},Ae.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Ae.prototype.forEach=function(e){Ee.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Ie=Ae,xe=_e,Re=function(e){return!(!e||!e.__CANCEL__)},Oe=_e,Te=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},Fe=function(e,t,n,r,o){var i=new Error(e);return Te(i,t,n,r,o)},Pe=Fe,Be=_e,je=Be.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),Be.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),Be.isString(r)&&s.push("path="+r),Be.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(){}},Ue=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Me=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Ne=_e,Le=["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"],De=_e,qe=De.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=De.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},$e=_e,He=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(Pe("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},We=je,Ve=ke,ze=function(e,t){return e&&!Ue(t)?Me(e,t):t},Ke=function(e){var t,n,r,o={};return e?(Ne.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=Ne.trim(e.substr(0,r)).toLowerCase(),n=Ne.trim(e.substr(r+1)),t){if(o[t]&&Le.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},Je=qe,Qe=Fe,Ye=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;$e.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=ze(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),Ve(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?Ke(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};He(t,n,o),i=null}},i.onabort=function(){i&&(n(Qe("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(Qe("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(Qe(t,e,"ECONNABORTED",i)),i=null},$e.isStandardBrowserEnv()){var u=(e.withCredentials||Je(c))&&e.xsrfCookieName?We.read(e.xsrfCookieName):void 0;u&&(o[e.xsrfHeaderName]=u)}if("setRequestHeader"in i&&$e.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),$e.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)}))},Xe=_e,Ge=function(e,t){Oe.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},Ze={"Content-Type":"application/x-www-form-urlencoded"};function et(e,t){!Xe.isUndefined(e)&&Xe.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var tt,nt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(tt=Ye),tt),transformRequest:[function(e,t){return Ge(t,"Accept"),Ge(t,"Content-Type"),Xe.isFormData(e)||Xe.isArrayBuffer(e)||Xe.isBuffer(e)||Xe.isStream(e)||Xe.isFile(e)||Xe.isBlob(e)?e:Xe.isArrayBufferView(e)?e.buffer:Xe.isURLSearchParams(e)?(et(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Xe.isObject(e)?(et(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}};nt.headers={common:{Accept:"application/json, text/plain, */*"}},Xe.forEach(["delete","get","head"],(function(e){nt.headers[e]={}})),Xe.forEach(["post","put","patch"],(function(e){nt.headers[e]=Xe.merge(Ze)}));var rt=nt,ot=_e,it=function(e,t,n){return xe.forEach(n,(function(n){e=n(e,t)})),e},st=Re,at=rt;function ct(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var ut=_e,lt=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 ut.isPlainObject(e)&&ut.isPlainObject(t)?ut.merge(e,t):ut.isPlainObject(t)?ut.merge({},t):ut.isArray(t)?t.slice():t}function c(r){ut.isUndefined(t[r])?ut.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}ut.forEach(r,(function(e){ut.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),ut.forEach(o,c),ut.forEach(i,(function(r){ut.isUndefined(t[r])?ut.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),ut.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 u=r.concat(o).concat(i).concat(s),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===u.indexOf(e)}));return ut.forEach(l,c),n},ht=_e,pt=ke,ft=Ie,dt=function(e){return ct(e),e.headers=e.headers||{},e.data=it(e.data,e.headers,e.transformRequest),e.headers=ot.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ot.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||at.adapter)(e).then((function(t){return ct(e),t.data=it(t.data,t.headers,e.transformResponse),t}),(function(t){return st(t)||(ct(e),t&&t.response&&(t.response.data=it(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},mt=lt;function gt(e){this.defaults=e,this.interceptors={request:new ft,response:new ft}}gt.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=mt(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[dt,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},gt.prototype.getUri=function(e){return e=mt(this.defaults,e),pt(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ht.forEach(["delete","get","head","options"],(function(e){gt.prototype[e]=function(t,n){return this.request(mt(n||{},{method:e,url:t,data:(n||{}).data}))}})),ht.forEach(["post","put","patch"],(function(e){gt.prototype[e]=function(t,n,r){return this.request(mt(r||{},{method:e,url:t,data:n}))}}));var yt=gt;function bt(e){this.message=e}bt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},bt.prototype.__CANCEL__=!0;var vt=bt,wt=vt;function _t(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 wt(e),t(n.reason))}))}_t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},_t.source=function(){var e;return{token:new _t((function(t){e=t})),cancel:e}};var Ct=_t,St=_e,kt=pe,Et=yt,At=lt;function It(e){var t=new Et(e),n=kt(Et.prototype.request,t);return St.extend(n,Et.prototype,t),St.extend(n,t),n}var xt=It(rt);xt.Axios=Et,xt.create=function(e){return It(At(xt.defaults,e))},xt.Cancel=vt,xt.CancelToken=Ct,xt.isCancel=Re,xt.all=function(e){return Promise.all(e)},xt.spread=function(e){return function(t){return e.apply(null,t)}},xt.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},he.exports=xt,he.exports.default=xt;var Rt=he.exports,Ot={exports:{}};Ot.exports=Ft;var Tt=Ot.exports.HttpsAgent=Ft;function Ft(){}var Pt=Ot.exports;const Bt=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new H(e.code);if("error"===e.status)throw new $(e.message,e.code,"error")},jt=(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}`:jt(n,null!=t?t:e)})).join("&");var Ut={exports:{}},Mt=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Nt=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Lt=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=Mt.exec(e||""),i={},s=14;s--;)i[Nt[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},Dt={exports:{}},qt={exports:{}},$t=1e3,Ht=60*$t,Wt=60*Ht,Vt=24*Wt,zt=365.25*Vt,Kt=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*zt;case"days":case"day":case"d":return n*Vt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Wt;case"minutes":case"minute":case"mins":case"min":case"m":return n*Ht;case"seconds":case"second":case"secs":case"sec":case"s":return n*$t;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 Jt(e,Vt,"day")||Jt(e,Wt,"hour")||Jt(e,Ht,"minute")||Jt(e,$t,"second")||e+" ms"}(e):function(e){if(e>=Vt)return Math.round(e/Vt)+"d";if(e>=Wt)return Math.round(e/Wt)+"h";if(e>=Ht)return Math.round(e/Ht)+"m";if(e>=$t)return Math.round(e/$t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Jt(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 u=o.log||t.log||console.log.bind(console);u.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=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(qt,qt.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=qt.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())}(Dt,Dt.exports);var Qt=Lt,Yt=Dt.exports("socket.io-client:url"),Xt=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)||(Yt("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),Yt("parse %s",e),n=Qt(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 Gt={},Zt={exports:{}},en={exports:{}};!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 u=o.log||t.log||console.log.bind(console);u.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=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(en,en.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=en.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())}(Zt,Zt.exports);var tn={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}}(tn);var nn={},rn={}.toString,on=Array.isArray||function(e){return"[object Array]"==rn.call(e)},sn=function(e){return an&&Buffer.isBuffer(e)||cn&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},an="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,cn="function"==typeof ArrayBuffer;var un=on,ln=sn,hn=Object.prototype.toString,pn="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===hn.call(Blob),fn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===hn.call(File);function dn(e,t){if(!e)return e;if(ln(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(un(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=dn(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=dn(e[i],t);return r}return e}function mn(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(un(e))for(var n=0;n<e.length;n++)e[n]=mn(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=mn(e[r],t);return e}nn.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=dn(n,t),r.attachments=t.length,{packet:r,buffers:t}},nn.reconstructPacket=function(e,t){return e.data=mn(e.data,t),e.attachments=void 0,e},nn.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(pn&&o instanceof Blob||fn&&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(un(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!ln(o))for(var u in o)e(o[u],u,o)}(r),n||t(r)},function(e){var t=Zt.exports("socket.io-parser"),n=tn.exports,r=nn,o=on,i=sn;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=u;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 u(){this.reconstructor=null}function l(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(u.prototype),u.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(","===(u=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 u;if(null==(u=n.charAt(r))||Number(u)!=u){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var l=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==l&&(i.type===e.ERROR||o(l))))return h("invalid payload");i.data=l}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new l(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))}},u.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},l.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},l.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(Gt);var gn={exports:{}},yn={},bn={exports:{}};try{bn.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){bn.exports=!1}var vn=bn.exports,wn=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||vn))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){}},_n={exports:{}},Cn={},Sn=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},kn={}.toString,En=Array.isArray||function(e){return"[object Array]"==kn.call(e)},An=Object.prototype.toString,In="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===An.call(Blob),xn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===An.call(File),Rn=function e(t){if(!t||"object"!=typeof t)return!1;if(En(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||In&&t instanceof Blob||xn&&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 On=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},Tn=function(e,t,n){var r=!1;return n=n||Fn,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 Fn(){}
|
|
2
2
|
/*! https://mths.be/utf8js v2.1.2 by @mathias */var Pn,Bn,jn,Un=String.fromCharCode;function Mn(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 Nn(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 Ln(e,t){return Un(e>>t&63|128)}function Dn(e,t){if(0==(4294967168&e))return Un(e);var n="";return 0==(4294965248&e)?n=Un(e>>6&31|192):0==(4294901760&e)?(Nn(e,t)||(e=65533),n=Un(e>>12&15|224),n+=Ln(e,6)):0==(4292870144&e)&&(n=Un(e>>18&7|240),n+=Ln(e,12),n+=Ln(e,6)),n+=Un(63&e|128)}function qn(){if(jn>=Bn)throw Error("Invalid byte index");var e=255&Pn[jn];if(jn++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function $n(e){var t,n;if(jn>Bn)throw Error("Invalid byte index");if(jn==Bn)return!1;if(t=255&Pn[jn],jn++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|qn())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|qn()<<6|qn())>=2048)return Nn(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|qn()<<12|qn()<<6|qn())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var Hn={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Mn(e),o=r.length,i=-1,s="";++i<o;)s+=Dn(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;Pn=Mn(e),Bn=Pn.length,jn=0;for(var r,o=[];!1!==(r=$n(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>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),n=0;n<e.length;n++)t[e.charCodeAt(n)]=n;Wn.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},Wn.decode=function(e){var n,r,o,i,s,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var l=new ArrayBuffer(a),h=new Uint8Array(l);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[u++]=r<<2|o>>4,h[u++]=(15&o)<<4|i>>2,h[u++]=(3&i)<<6|63&s;return l}}();var Vn=void 0!==Vn?Vn:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,zn=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),Kn=zn&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),Jn=Vn&&Vn.prototype.append&&Vn.prototype.getBlob;function Qn(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 Yn(e,t){t=t||{};var n=new Vn;return Qn(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function Xn(e,t){return new Blob(Qn(e),t||{})}"undefined"!=typeof Blob&&(Yn.prototype=Blob.prototype,Xn.prototype=Blob.prototype);var Gn=zn?Kn?Blob:Xn:Jn?Yn:void 0;!function(e){var t,n=Sn,r=Rn,o=On,i=Tn,s=Hn;"undefined"!=typeof ArrayBuffer&&(t=Wn);var a="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),c="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),u=a||c;e.protocol=3;var l=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},h=n(l),p={type:"error",data:"parser error"},f=Gn;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]=l[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!==f&&i instanceof f)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(u)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]=l[t.type];var i=new f([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=l[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!==f&&t.data instanceof f){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 p;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 p;var i=t.charAt(0);return Number(i)==i&&h[i]?t.length>1?{type:h[i],data:t.substring(1)}:{type:h[i]}:p}i=new Uint8Array(t)[0];var a=o(t,1);return f&&"blob"===n&&(a=new f([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&&f&&(o=new f([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 f&&!u?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(p,0,1);for(var i,s,a="",c=0,u=t.length;c<u;c++){var l=t.charAt(c);if(":"===l){if(""===a||a!=(i=Number(a)))return r(p,0,1);if(a!=(s=t.substr(c+1,i)).length)return r(p,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),p.type===o.type&&p.data===o.data)return r(p,0,1);if(!1===r(o,c+i,u))return}c+=i,a=""}else a+=l}return""!==a?r(p,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,f){var a=new f([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new f(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],u="",l=1;255!==a[l];l++){if(u.length>310)return r(p,0,1);u+=a[l]}i=o(i,2+u.length),u=parseInt(u);var h=o(i,0,u);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var f=new Uint8Array(h);h="";for(l=0;l<f.length;l++)h+=String.fromCharCode(f[l])}s.push(h),i=o(i,u)}var d=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,d)}))}}(Cn);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 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}}(Zn);var er=Cn,tr=nr;function nr(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,Zn.exports)(nr.prototype),nr.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},nr.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},nr.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},nr.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},nr.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},nr.prototype.onData=function(e){var t=er.decodePacket(e,this.socket.binaryType);this.onPacket(t)},nr.prototype.onPacket=function(e){this.emit("packet",e)},nr.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var rr,or={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}},ir=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},sr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),ar={},cr=0,ur=0;function lr(e){var t="";do{t=sr[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function hr(){var e=lr(+new Date);return e!==rr?(cr=0,rr=e):e+"."+lr(cr++)}for(;ur<64;ur++)ar[sr[ur]]=ur;hr.encode=lr,hr.decode=function(e){var t=0;for(ur=0;ur<e.length;ur++)t=64*t+ar[e.charAt(ur)];return t};var pr=hr,fr={exports:{}},dr={exports:{}};!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 u=o.log||t.log||console.log.bind(console);u.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=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(dr,dr.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=dr.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())}(fr,fr.exports);var mr=tr,gr=or,yr=Cn,br=ir,vr=pr,wr=fr.exports("engine.io-client:polling"),_r=Sr,Cr=null!=new wn({xdomain:!1}).responseType;function Sr(e){var t=e&&e.forceBase64;Cr&&!t||(this.supportsBinary=!1),mr.call(this,e)}br(Sr,mr),Sr.prototype.name="polling",Sr.prototype.doOpen=function(){this.poll()},Sr.prototype.pause=function(e){var t=this;function n(){wr("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(wr("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){wr("pre-pause polling complete"),--r||n()}))),this.writable||(wr("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){wr("pre-pause writing complete"),--r||n()})))}else n()},Sr.prototype.poll=function(){wr("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},Sr.prototype.onData=function(e){var t=this;wr("polling got data %s",e);yr.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():wr('ignoring poll - transport state "%s"',this.readyState))},Sr.prototype.doClose=function(){var e=this;function t(){wr("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(wr("transport open - closing"),t()):(wr("transport not open - deferring close"),this.once("open",t))},Sr.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};yr.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},Sr.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=vr()),this.supportsBinary||e.sid||(e.b64=1),e=gr.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 kr=wn,Er=_r,Ar=Zn.exports,Ir=ir,xr=fr.exports("engine.io-client:polling-xhr");function Rr(){}function Or(e){if(Er.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 Tr(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(_n.exports=Or,_n.exports.Request=Tr,Ir(Or,Er),Or.prototype.supportsBinary=!0,Or.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 Tr(e)},Or.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},Or.prototype.doPoll=function(){xr("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},Ar(Tr.prototype),Tr.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 kr(e),n=this;try{xr("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))},xr("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Tr.requestsCount++,Tr.requests[this.index]=this)},Tr.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},Tr.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},Tr.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},Tr.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Rr:this.xhr.onreadystatechange=Rr,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Tr.requests[this.index],this.xhr=null}},Tr.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)},Tr.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},Tr.prototype.abort=function(){this.cleanup()},Tr.requestsCount=0,Tr.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Pr);else if("function"==typeof addEventListener){var Fr="onpagehide"in self?"pagehide":"unload";addEventListener(Fr,Pr,!1)}function Pr(){for(var e in Tr.requests)Tr.requests.hasOwnProperty(e)&&Tr.requests[e].abort()}var Br,jr=_r,Ur=qr,Mr=/\n/g,Nr=/\\n/g;function Lr(){}function Dr(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==J?J:{}}function qr(e){if(jr.call(this,e),this.query=this.query||{},!Br){var t=Dr();Br=t.___eio=t.___eio||[]}this.index=Br.length;var n=this;Br.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=Lr)}),!1)}ir(qr,jr),qr.prototype.supportsBinary=!1,qr.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),jr.prototype.doClose.call(this)},qr.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)},qr.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(Nr,"\\\n"),this.area.value=e.replace(Mr,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var $r,Hr,Wr=Q(Object.freeze({__proto__:null,default:{}})),Vr=tr,zr=Cn,Kr=or,Jr=ir,Qr=pr,Yr=fr.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)$r=WebSocket;else if("undefined"!=typeof self)$r=self.WebSocket||self.MozWebSocket;else try{Hr=Wr}catch(e){}var Xr=$r||Hr,Gr=Zr;function Zr(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=$r&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(Xr=Hr),Vr.call(this,e)}Jr(Zr,Vr),Zr.prototype.name="websocket",Zr.prototype.supportsBinary=!0,Zr.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 Xr(e,t):new Xr(e):new Xr(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()}},Zr.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)}},Zr.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){zr.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){Yr("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},Zr.prototype.onClose=function(){Vr.prototype.onClose.call(this)},Zr.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},Zr.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]=Qr()),this.supportsBinary||(e.b64=1),(e=Kr.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},Zr.prototype.check=function(){return!(!Xr||"__initialize"in Xr&&this.name===Zr.prototype.name)};var eo=wn,to=_n.exports,no=Ur,ro=Gr;yn.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 eo(e)&&!e.forceJSONP)return new to(e);if(!r)throw new Error("JSONP disabled");return new no(e)},yn.websocket=ro;var oo=[].indexOf,io=function(e,t){if(oo)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},so=yn,ao=Zn.exports,co=fr.exports("engine.io-client:socket"),uo=io,lo=Cn,ho=Lt,po=or,fo=mo;function mo(e,t){if(!(this instanceof mo))return new mo(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=ho(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=ho(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=po.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()}mo.priorWebsocketSuccess=!1,ao(mo.prototype),mo.protocol=lo.protocol,mo.Socket=mo,mo.Transport=tr,mo.transports=yn,mo.parser=Cn,mo.prototype.createTransport=function(e){co('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=lo.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new so[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})},mo.prototype.open=function(){var e;if(this.rememberUpgrade&&mo.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)},mo.prototype.setTransport=function(e){co("setting transport %s",e.name);var t=this;this.transport&&(co("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")}))},mo.prototype.probe=function(e){co('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||(co('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(co('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;mo.priorWebsocketSuccess="websocket"===t.name,co('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(co("changing transport and sending upgrade packet"),l(),r.setTransport(t),t.send([{type:"upgrade"}]),r.emit("upgrade",t),t=null,r.upgrading=!1,r.flush())}))}else{co('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,r.emit("upgradeError",i)}})))}function i(){n||(n=!0,l(),t.close(),t=null)}function s(n){var o=new Error("probe error: "+n);o.transport=t.name,i(),co('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 u(e){t&&e.name!==t.name&&(co('"%s" works - aborting "%s"',e.name,t.name),i())}function l(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),r.removeListener("close",c),r.removeListener("upgrading",u)}mo.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",u),t.open()},mo.prototype.onOpen=function(){if(co("socket open"),this.readyState="open",mo.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){co("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},mo.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(co('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 co('packet received with socket readyState "%s"',this.readyState)},mo.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))},mo.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)},mo.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){co("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},mo.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},mo.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},mo.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(co("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},mo.prototype.write=mo.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},mo.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()}},mo.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"),co("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},mo.prototype.onError=function(e){co("socket error %j",e),mo.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},mo.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){co('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}},mo.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~uo(this.transports,e[n])&&t.push(e[n]);return t},gn.exports=fo,gn.exports.parser=Cn;var go={exports:{}},yo={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}}(yo);var bo=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n};var vo=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var wo=[].slice,_o=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=wo.call(arguments,2);return function(){return t.apply(e,n.concat(wo.call(arguments)))}};!function(e,t){var n=Gt,r=yo.exports,o=bo,i=vo,s=_o,a=Dt.exports("socket.io-client:socket"),c=or,u=Rn;e.exports=p;var l={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 p(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(p.prototype),p.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"))]}},p.prototype.open=p.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},p.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},p.prototype.emit=function(e){if(l.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:u(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},p.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},p.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})},p.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},p.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)}},p.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)},p.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:u(i)?n.BINARY_ACK:n.ACK,id:e,data:i})}}},p.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)},p.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},p.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=[]},p.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},p.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)},p.prototype.close=p.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},p.prototype.compress=function(e){return this.flags.compress=e,this},p.prototype.binary=function(e){return this.flags.binary=e,this}}(go);var Co=So;function So(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}So.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)},So.prototype.reset=function(){this.attempts=0},So.prototype.setMin=function(e){this.ms=e},So.prototype.setMax=function(e){this.max=e},So.prototype.setJitter=function(e){this.jitter=e};var ko=gn.exports,Eo=go.exports,Ao=yo.exports,Io=Gt,xo=vo,Ro=_o,Oo=Dt.exports("socket.io-client:manager"),To=io,Fo=Co,Po=Object.prototype.hasOwnProperty,Bo=jo;function jo(e,t){if(!(this instanceof jo))return new jo(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 Fo({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||Io;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}jo.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)Po.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},jo.prototype.updateSocketIds=function(){for(var e in this.nsps)Po.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},jo.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Ao(jo.prototype),jo.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},jo.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},jo.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},jo.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},jo.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},jo.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},jo.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},jo.prototype.open=jo.prototype.connect=function(e,t){if(Oo("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Oo("opening %s",this.uri),this.engine=ko(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=xo(n,"open",(function(){r.onopen(),e&&e()})),i=xo(n,"error",(function(t){if(Oo("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;Oo("connect attempt will timeout after %d",s);var a=setTimeout((function(){Oo("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},jo.prototype.onopen=function(){Oo("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(xo(e,"data",Ro(this,"ondata"))),this.subs.push(xo(e,"ping",Ro(this,"onping"))),this.subs.push(xo(e,"pong",Ro(this,"onpong"))),this.subs.push(xo(e,"error",Ro(this,"onerror"))),this.subs.push(xo(e,"close",Ro(this,"onclose"))),this.subs.push(xo(this.decoder,"decoded",Ro(this,"ondecoded")))},jo.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},jo.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},jo.prototype.ondata=function(e){this.decoder.add(e)},jo.prototype.ondecoded=function(e){this.emit("packet",e)},jo.prototype.onerror=function(e){Oo("error",e),this.emitAll("error",e)},jo.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new Eo(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(){~To(r.connecting,n)||r.connecting.push(n)}return n},jo.prototype.destroy=function(e){var t=To(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},jo.prototype.packet=function(e){Oo("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()})))},jo.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},jo.prototype.cleanup=function(){Oo("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()},jo.prototype.close=jo.prototype.disconnect=function(){Oo("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},jo.prototype.onclose=function(e){Oo("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},jo.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Oo("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Oo("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Oo("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Oo("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Oo("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},jo.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=Xt,r=Gt,o=Bo,i=Dt.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,u=a.id,l=a.path,h=s[u]&&l in s[u].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),r=o(c,t)):(s[u]||(i("new io instance for %s",c),s[u]=o(c,t)),r=s[u]),a.query&&!t.query&&(t.query=a.query),r.socket(a.path,t)}t.protocol=r.protocol,t.connect=a,t.Manager=Bo,t.Socket=go.exports}(Ut,Ut.exports);var Uo=Ut.exports;var Mo={exports:{}};Mo.exports=function(){function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(!a&&Y)return Y(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return o(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var i=Y,s=0;s<r.length;s++)o(r[s]);return o}return e}()({1:[function(e,t,n){(function(n,r){(function(){var o=e("events").EventEmitter,i=e("./store"),s=e("mqtt-packet"),a=e("readable-stream").Writable,c=e("inherits"),u=e("reinterval"),l=e("./validations"),h=e("xtend"),p=e("debug")("mqttjs:client"),f=n?n.nextTick:function(e){setTimeout(e,0)},d=r.setImmediate||function(e){f(e)},m={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},g=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],y={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 b(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function v(e,t,n){p("sendPacket :: packet: %O",t),p("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),p("sendPacket :: writing to stream");var r=s.writeToStream(t,e.stream,e.options);p("sendPacket :: writeToStream result %s",r),!r&&n?(p("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(p("sendPacket :: invoking cb"),n())}function w(e){e&&(p("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 _(e){e&&(p("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 C(e,t,n,r){p("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,(function(o){if(o)return n&&n(o);r(),v(e,t,n)}))}function S(e){p("nop ::",e)}function k(e,t){var n,r=this;if(!(this instanceof k))return new k(e,t);for(n in this.options=t||{},m)void 0===this.options[n]?this.options[n]=m[n]:this.options[n]=t[n];p("MqttClient :: options.protocol",t.protocol),p("MqttClient :: options.protocolVersion",t.protocolVersion),p("MqttClient :: options.username",t.username),p("MqttClient :: options.keepalive",t.keepalive),p("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),p("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),this.options.clientId="string"==typeof t.clientId?t.clientId:b(),p("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,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.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this._firstConnection=!0,this.on("connect",(function(){var e=this.queue;function t(){var n=e.shift();p("deliver :: entry %o",n);var o=null;n&&(o=n.packet,p("deliver :: call _sendPacket for %o",o),r._sendPacket(o,(function(e){n.cb&&n.cb(e),t()})))}p("connect :: sending queued packets"),t()})),this.on("close",(function(){p("close :: connected set to `false`"),this.connected=!1,p("close :: clearing connackTimer"),clearTimeout(this.connackTimer),p("close :: clearing ping timer"),null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),p("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),p("MqttClient :: setting up stream"),this._setupStream()}c(k,o),k.prototype._setupStream=function(){var e,t=this,n=new a,r=s.parser(this.options),o=null,i=[];function c(){if(i.length)f(u);else{var e=o;o=null,e()}}function u(){p("work :: getting next packet in queue");var e=i.shift();if(e)p("work :: packet pulled from queue"),t._handlePacket(e,c);else{p("work :: no packets in queue");var n=o;o=null,p("work :: done flag is %s",!!n),n&&n()}}function l(e){p("streamErrorHandler :: error",e.message),g.includes(e.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",e)):S(e)}if(p("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),p("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){p("parser :: on packet push to packets array."),i.push(e)})),n._write=function(e,t,n){o=n,p("writable stream :: parsing buffer"),r.parse(e),u()},p("_setupStream :: pipe stream to writable stream"),this.stream.pipe(n),this.stream.on("error",l),this.stream.on("close",(function(){p("(%s)stream :: on close",t.options.clientId),_(t.outgoing),p("stream: emit close to MqttClient"),t.emit("close")})),p("_setupStream: sending packet `connect`"),(e=Object.create(this.options)).cmd="connect",v(this,e),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return t.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&v(this,h({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){p("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)}),this.options.connectTimeout)},k.prototype._handlePacket=function(e,t){var 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(p("_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"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},k.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},k.prototype.publish=function(e,t,n,r){var o;p("publish :: message `%s` to topic `%s`",t,e);var i=this.options;if("function"==typeof n&&(r=n,n=null),n=h({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(o={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},5===i.protocolVersion&&(o.properties=n.properties,(!i.properties&&o.properties&&o.properties.topicAlias||n.properties&&i.properties&&(n.properties.topicAlias&&i.properties.topicAliasMaximum&&n.properties.topicAlias>i.properties.topicAliasMaximum||!i.properties.topicAliasMaximum&&n.properties.topicAlias))&&delete o.properties.topicAlias),p("publish :: qos",n.qos),n.qos){case 1:case 2:this.outgoing[o.messageId]={volatile:!1,cb:r||S},this._storeProcessing?(p("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[o.messageId]=!1,this._storePacket(o,void 0,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,void 0,n.cbStorePut));break;default:this._storeProcessing?(p("_storeProcessing enabled"),this._storePacket(o,r,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,r,n.cbStorePut))}return this},k.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),n=0;n<arguments.length;n++)t[n]=arguments[n];var r,o=[],i=t.shift(),s=i.resubscribe,a=t.pop()||S,c=t.pop(),u=this,f=this.options.protocolVersion;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof a&&(c=a,a=S),null!==(r=l.validateTopics(i)))return d(a,new Error("Invalid topic "+r)),this;if(this._checkDisconnecting(a))return p("subscribe: discconecting true"),this;var m={qos:0};if(5===f&&(m.nl=!1,m.rap=!1,m.rh=0),c=h(m,c),Array.isArray(i)?i.forEach((function(e){if(p("subscribe: array topic %s",e),!u._resubscribeTopics.hasOwnProperty(e)||u._resubscribeTopics[e].qos<c.qos||s){var t={topic:e,qos:c.qos};5===f&&(t.nl=c.nl,t.rap=c.rap,t.rh=c.rh,t.properties=c.properties),p("subscribe: pushing topic `%s` and qos `%s` to subs list",t.topic,t.qos),o.push(t)}})):Object.keys(i).forEach((function(e){if(p("subscribe: object topic %s",e),!u._resubscribeTopics.hasOwnProperty(e)||u._resubscribeTopics[e].qos<i[e].qos||s){var t={topic:e,qos:i[e].qos};5===f&&(t.nl=i[e].nl,t.rap=i[e].rap,t.rh=i[e].rh,t.properties=c.properties),p("subscribe: pushing `%s` to subs list",t),o.push(t)}})),e={cmd:"subscribe",subscriptions:o,qos:1,retain:!1,dup:!1,messageId:this._nextId()},c.properties&&(e.properties=c.properties),o.length){if(this.options.resubscribe){p("subscribe :: resubscribe true");var g=[];o.forEach((function(e){if(u.options.reconnectPeriod>0){var t={qos:e.qos};5===f&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),u._resubscribeTopics[e.topic]=t,g.push(e.topic)}})),u.messageIdToTopic[e.messageId]=g}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var n=t.granted,r=0;r<n.length;r+=1)o[r].qos=n[r];a(e,o)}},p("subscribe :: call _sendPacket"),this._sendPacket(e),this}a(null,[])},k.prototype.unsubscribe=function(){for(var e={cmd:"unsubscribe",qos:1,messageId:this._nextId()},t=this,n=new Array(arguments.length),r=0;r<arguments.length;r++)n[r]=arguments[r];var o=n.shift(),i=n.pop()||S,s=n.pop();return"string"==typeof o&&(o=[o]),"function"!=typeof i&&(s=i,i=S),this._checkDisconnecting(i)||("string"==typeof o?e.unsubscriptions=[o]:Array.isArray(o)&&(e.unsubscriptions=o),this.options.resubscribe&&e.unsubscriptions.forEach((function(e){delete t._resubscribeTopics[e]})),"object"==typeof s&&s.properties&&(e.properties=s.properties),this.outgoing[e.messageId]={volatile:!0,cb:i},p("unsubscribe: call _sendPacket"),this._sendPacket(e)),this},k.prototype.end=function(e,t,n){var r=this;function o(){p("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(p("end :: closeStores: emitting end"),r.emit("end"),n){let r=e||t;p("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){p("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{p("end :: finish :: calling process.nextTick on closeStores"),f(o.bind(r))}),t)}return p("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||S,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=S))),"object"!=typeof t&&(n=t,t=null),p("end :: cb? %s",!!n),n=n||S,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(p("end :: (%s) :: immediately calling finish",r.options.clientId),i()),this)},k.prototype.removeOutgoingMessage=function(e){var 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},k.prototype.reconnect=function(e){p("client reconnect");var 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},k.prototype._reconnect=function(){p("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),p("client already connected. disconnecting first.")):(p("_reconnect: calling _setupStream"),this._setupStream())},k.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(p("_setupReconnect :: emit `offline` state"),this.emit("offline"),p("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),p("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){p("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):p("_setupReconnect :: doing nothing...")},k.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},k.prototype._cleanUp=function(e,t){var n=arguments[2];if(t&&(p("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),p("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&w(this.outgoing),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var r=h({cmd:"disconnect"},n);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(r,d.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(p("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(p("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(p("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},k.prototype._sendPacket=function(e,t,n){if(p("_sendPacket :: (%s) :: start",this.options.clientId),n=n||S,!this.connected)return p("_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 C(this,e,t,n);default:return void v(this,e,t)}switch(e.qos){case 2:case 1:C(this,e,t,n);break;default:v(this,e,t)}p("_sendPacket :: (%s) :: end",this.options.clientId)},k.prototype._storePacket=function(e,t,n){p("_storePacket :: packet: %o",e),p("_storePacket :: cb? %s",!!t),n=n||S,0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,(function(e){if(e)return t&&t(e);n()}))):t&&t(new Error("No connection to broker"))},k.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=u((function(){e._checkPing()}),1e3*this.options.keepalive))},k.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},k.prototype._checkPing=function(){p("_checkPing :: checking ping..."),this.pingResp?(p("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(p("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},k.prototype._handlePingresp=function(){this.pingResp=!0},k.prototype._handleConnack=function(e){p("_handleConnack");var t=this.options,n=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=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)),0===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){var r=new Error("Connection refused: "+y[n]);r.code=n,this.emit("error",r)}},k.prototype._handlePublish=function(e,t){p("_handlePublish: packet %o",e),t=void 0!==t?t:S;var n=e.topic.toString(),r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];switch(p("_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:p("_handlePublish: unknown QoS. Doing nothing.")}},k.prototype.handleMessage=function(e,t){t()},k.prototype._handleAck=function(e){var t,n=e.messageId,r=e.cmd,o=null,i=this.outgoing[n]?this.outgoing[n].cb:null,s=this;if(i){switch(p("_handleAck :: packet type",r),r){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+y[a])).code=a,i(t,e)),delete this.outgoing[n],this.outgoingStore.del(e,i);break;case"pubrec":o={cmd:"pubrel",qos:2,messageId:n};var c=e.reasonCode;c&&c>0&&16!==c?((t=new Error("Publish error: "+y[c])).code=c,i(t,e)):this._sendPacket(o);break;case"suback":delete this.outgoing[n];for(var u=0;u<e.granted.length;u++)if(0!=(128&e.granted[u])){var l=this.messageIdToTopic[n];l&&l.forEach((function(e){delete s._resubscribeTopics[e]}))}i(null,e);break;case"unsuback":delete this.outgoing[n],i(null);break;default:s.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else p("_handleAck :: Server sent an ack in error. Ignoring.")},k.prototype._handlePubrel=function(e,t){p("handling pubrel packet"),t=void 0!==t?t:S;var 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,S),r._sendPacket(o,t)})))}))},k.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},k.prototype._nextId=function(){var e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},k.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},k.prototype._resubscribe=function(e){p("_resubscribe");var t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!e.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){p("_resubscribe: protocolVersion 5");for(var n=0;n<t.length;n++){var r={};r[t[n]]=this._resubscribeTopics[t[n]],r.resubscribe=!0,this.subscribe(r,{properties:r[t[n]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},k.prototype._onConnect=function(e){if(this.disconnected)this.emit("connect",e);else{var t=this;this._setupPingTimer(),this._resubscribe(e),this.connected=!0,n()}function n(){var r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,o()}function s(){if(r){t._storeProcessing=!0;var e,n=r.read(1);n?t._packetIdsDuringStoreProcessing[n.messageId]?s():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(e=t.outgoing[n.messageId]?t.outgoing[n.messageId].cb:null,t.outgoing[n.messageId]={volatile:!1,cb:function(t,n){e&&e(t,n),s()}},t._packetIdsDuringStoreProcessing[n.messageId]=!0,t._sendPacket(n)):r.once("readable",s)}}t.once("close",i),r.on("error",(function(e){o(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){var r=!0;for(var s in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[s]){r=!1;break}r?(o(),t.removeListener("close",i),t.emit("connect",e)):n()})),s()}},t.exports=k}).call(this)}).call(this,e("_process"),void 0!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./store":7,"./validations":8,_process:32,debug:15,events:19,inherits:21,"mqtt-packet":24,"readable-stream":51,reinterval:52,xtend:61}],2:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify"),c=!1;function u(){var e=new s;return e._write=function(e,t,n){r.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){r.closeSocket({success:function(){e()}})},e}function l(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){var n="alis"===e.protocol?"wss":"ws",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(){c||(c=!0,r.onSocketOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onSocketMessage((function(e){if("string"==typeof e.data){var t=n.from(e.data,"base64");o.push(t)}else{var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),o.push(e)})),r.readAsArrayBuffer(e.data)}})),r.onSocketClose((function(){i.end(),i.destroy()})),r.onSocketError((function(e){i.destroy(e)})))}function f(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";l(t);var s=h(t,e);return(r=t.my).connectSocket({url:s,protocols:n}),o=u(),i=a.obj(),p(),i}t.exports=f}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],3:[function(e,t,n){var r=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){var n,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",n=t.port,i=t.hostname,o("port %d and host %s",n,i),r.createConnection(n,i)}t.exports=i},{debug:15,net:13}],4:[function(e,t,n){var r=e("tls"),o=e("debug")("mqttjs:tls");function i(e,t){var n;function i(r){t.rejectUnauthorized&&e.emit("error",r),n.end()}return t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.servername=t.host,t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized),(n=r.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",i)})),n.on("error",i),n}t.exports=i},{debug:15,tls:13}],5:[function(e,t,n){(function(n,r){(function(){const o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform;let c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const u=void 0!==n&&"browser"===n.title||"function"==typeof __webpack_require__;function l(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){let 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={}),u||"wss"!==e.protocol||c.forEach((function(n){e.hasOwnProperty(n)&&!e.wsOptions.hasOwnProperty(n)&&(t.wsOptions[n]=e[n])})),t}function p(e){let 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 f(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";let r=l(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");let n=h(t);const r=l(n,e);let s=f(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=p(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,u=!t.objectMode;let l=d(e,t),h=m(t,_,C);t.objectMode||(h._writev=w),h.on("close",(()=>{l.close()}));const f=void 0!==l.addEventListener;function m(e,t,n){let 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 b(e){n.destroy(e)}function v(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 _(e,t,n){l.bufferedAmount>o&&setTimeout(_,c,e,t,n),u&&"string"==typeof e&&(e=r.from(e,"utf8"));try{l.send(e)}catch(e){return n(e)}n()}function C(e){l.close(),e()}return l.readyState===l.OPEN?n=h:(n=n=s(void 0,void 0,t),t.objectMode||(n._writev=w),f?l.addEventListener("open",g):l.onopen=g),n.socket=l,f?(l.addEventListener("close",y),l.addEventListener("error",b),l.addEventListener("message",v)):(l.onclose=y,l.onerror=b,l.onmessage=v),n}t.exports=u?g:m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,debug:15,duplexify:17,"readable-stream":51,ws:60}],6:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify");function c(){var e=new s;return e._write=function(e,t,n){r.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){r.close({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function l(e,t){var n="wxs"===e.protocol?"wss":"ws",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 h(){r.onOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onMessage((function(e){var t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),o.push(t)})),r.onClose((function(){i.end(),i.destroy()})),r.onError((function(e){i.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.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);var s=l(t,e);r=wx.connectSocket({url:s,protocols:[n]}),o=c(),(i=a.obj())._destroy=function(e,t){r.close({success:function(){t&&t(e)}})};var p=i.destroy;return i.destroy=function(){i.destroy=p;var e=this;setTimeout((function(){r.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(i),h(),i}t.exports=p}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],7:[function(e,t,n){var 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(){var e=new o(i),t=!1,n=[],r=0;return this._inflights.forEach((function(e,t){n.push(e)})),e._read=function(){!t&&r<n.length?this.push(n[r++]):this.push(null)},e.destroy=function(){if(!t){var e=this;t=!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":51,xtend:61}],8:[function(e,t,n){function r(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],9:[function(e,t,n){(function(n){(function(){var r=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function u(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function l(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){var 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(u(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]){var o=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(e,t){return(!o||t%2!=0)&&"function"==typeof c[e]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function l(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);var h=new r(l,t);return h.on("error",(function(){})),h}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=l,t.exports.connect=l,t.exports.MqttClient=r,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":7,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:32,debug:15,url:56,xtend:61}],10:[function(e,t,n){n.byteLength=l,n.toByteArray=p,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 u(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 l(e){var t=u(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 p(e){var t,n,r=u(e),s=r[0],a=r[1],c=new i(h(e,s,a)),l=0,p=a>0?s-4:s;for(n=0;n<p;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[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c}function f(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(f(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},{}],11:[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,u=i&&t||0,l=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,u),u+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-l)return i?this._bufs[s[0]].copy(e,t,l,l+c):this._bufs[s[0]].slice(l,l+c);i||(e=r.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const n=this._bufs[t].length-l;if(!(c>n)){this._bufs[t].copy(e,u,l,l+c),u+=n;break}this._bufs[t].copy(e,u,l),u+=n,c-=n,l&&(l=0)}return e.length>u?e.slice(0,u):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:14}],12:[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":11,inherits:21,"readable-stream":51}],13:[function(e,t,n){},{}],14:[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 p(e,t);if(ArrayBuffer.isView(e))return f(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 u(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 l(e,t,n){return u(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 u(e),s(e<0?0:0|g(e))}function p(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|b(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function f(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):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(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 b(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 J(e).length;default:if(o)return r?-1:V(e).length;t=(""+t).toLowerCase(),o=!0}}function v(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 j(this,t,n);case"utf8":case"utf-8":return O(this,t,n);case"ascii":return P(this,t,n);case"latin1":case"binary":return B(this,t,n);case"base64":return R(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(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 _(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:C(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):C(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function C(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 u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=n;i<a;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,p=0;p<c;p++)if(u(e,i+p)!==u(t,p)){h=!1;break}if(h)return i}return-1}function S(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 k(e,t,n,r){return Q(V(t,e.length-n),e,n,r)}function E(e,t,n,r){return Q(z(t),e,n,r)}function A(e,t,n,r){return E(e,t,n,r)}function I(e,t,n,r){return Q(J(t),e,n,r)}function x(e,t,n,r){return Q(K(t,e.length-n),e,n,r)}function R(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,u=e[o],l=null,h=u>239?4:u>223?3:u>191?2:1;if(o+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=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&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=h}return F(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 l(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=b,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):v.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),u=this.slice(r,o),l=e.slice(t,n),h=0;h<c;++h)if(u[h]!==l[h]){i=u[h],s=l[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 _(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return _(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 S(this,e,t,n);case"utf8":case"utf-8":return k(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 I(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 T=4096;function F(e){var t=e.length;if(t<=T)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=T));return n}function P(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 B(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 j(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+=W(e[i]);return o}function U(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 N(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||N(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||N(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||N(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||N(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||N(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||N(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||N(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);N(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);N(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||N(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||N(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||N(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||N(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||N(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 $=/[^+/0-9A-Za-z-_]/g;function H(e){if((e=(e=e.split("=")[0]).trim().replace($,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function W(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 z(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 J(e){return t.toByteArray(H(e))}function Q(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":10,buffer:14,ieee754:20}],15:[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:u}=t.exports;u.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":16,_process:32}],16:[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=null;function i(...e){if(!i.enabled)return;const n=i,o=Number(new Date),s=o-(t||o);n.diff=s,n.prev=t,n.curr=o,t=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";a++;const i=r.formatters[o];if("function"==typeof i){const r=e[a];t=i.call(n,r),e.splice(a,1),a--}return t})),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return i.namespace=e,i.useColors=r.useColors(),i.color=r.selectColor(e),i.extend=o,i.destroy=r.destroy,Object.defineProperty(i,"enabled",{enumerable:!0,configurable:!1,get:()=>null===n?r.enabled(e):n,set:e=>{n=e}}),"function"==typeof r.init&&r.init(i),i}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.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 u(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.debug=r,r.default=r,r.coerce=u,r.disable=s,r.enable=i,r.enabled=a,r.humanize=e("ms"),r.destroy=l,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:29}],17:[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]),u=function(e,t){e._corked?e.once("uncork",t):t()},l=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(n){n?l(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},p=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},f=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=f),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?u(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"),u(this,(function(){p(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),u(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.write(c),o.Writable.prototype.end.call(this,n))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,"end-of-stream":18,inherits:21,"readable-stream":51,"stream-shift":54}],18:[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 u=e._writableState,l=e._readableState,h=t.readable||!1!==t.readable&&e.readable,p=t.writable||!1!==t.writable&&e.writable,f=!1,d=function(){e.writable||m()},m=function(){p=!1,h||c.call(e)},g=function(){h=!1,p||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},b=function(t){c.call(e,t)},v=function(){n.nextTick(w)},w=function(){if(!f)return(!h||l&&l.ended&&!l.destroyed)&&(!p||u&&u.ended&&!u.destroyed)?void 0:c.call(e,new Error("premature close"))},_=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",v),e.req?_():e.on("request",_)):p&&!u&&(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",b),e.on("close",v),function(){f=!0,e.removeListener("complete",m),e.removeListener("abort",v),e.removeListener("request",_),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",b),e.removeListener("close",v)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:32,once:30}],19:[function(e,t,n){var r=Object.create||k,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 u={};Object.defineProperty&&Object.defineProperty(u,"x",{value:0}),a=0===u.x}catch(e){a=!1}function l(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=C(e,r),i=0;i<r;++i)o[i].call(n)}function p(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=C(e,o),s=0;s<o;++s)i[s].call(n,r)}function f(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=C(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=C(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=C(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=l(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 b(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 v(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?S(o):C(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 _(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 C(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function S(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function k(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 l(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 u="function"==typeof n;switch(r=arguments.length){case 1:h(n,u,this);break;case 2:p(n,u,this,arguments[1]);break;case 3:f(n,u,this,arguments[1],arguments[2]);break;case 4:d(n,u,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,u,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,b(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,b(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():_(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 v(this,e,!0)},s.prototype.rawListeners=function(e){return v(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):[]}},{}],20:[function(e,t,n){
|
|
3
3
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
4
4
|
n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,u=c>>1,l=-7,h=n?o-1:0,p=n?-1:1,f=e[t+h];for(h+=p,i=f&(1<<-l)-1,f>>=-l,l+=a;l>0;i=256*i+e[t+h],h+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=p,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=u}return(f?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,u=8*i-o-1,l=(1<<u)-1,h=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=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=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?p/c:p*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):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+f]=255&a,f+=d,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;e[n+f]=255&s,f+=d,s/=256,u-=8);e[n+f-d]|=128*m}},{}],21:[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}}},{}],22:[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:14}],23:[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":28,buffer:14,events:19}],24:[function(e,t,n){n.parser=e("./parser").parser,n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":23,"./parser":27,"./writeToStream":28}],25:[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:14}],26:[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},{}],27:[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 u=this._parseString();if(null===u)return this._emitError(new Error("Packet too short"));if(i.clientId=u,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,u;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,u={topic:t,qos:r},5===this.settings.protocolVersion?(u.nl=c,u.rap=i,u.rh=o):this.settings.bridgeMode&&(u.rh=0,u.rap=!0,u.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",u),e.subscriptions.push(u)}}}_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 u=this._pos?this._pos:0;for(;r<t&&u+r<this._list.length;){if(n=this._list.readUInt8(u+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")),u&&(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":22,"./packet":26,bl:12,debug:15,events:19}],28:[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"),u=s.cache,l=s.generateNumber,h=s.generateCache,p=s.genBufVariableByteInt,f=s.generate4ByteBuffer;let d=P,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 b(e,t);case"connack":return v(e,t,n);case"publish":return w(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return _(e,t,n);case"subscribe":return C(e,t,n);case"suback":return S(e,t,n);case"unsubscribe":return k(e,t,n);case"unsuback":return E(e,t,n);case"pingreq":case"pingresp":return A(e,t);case"disconnect":return I(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 b(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let u=i.clean;const l=i.keepalive||0,h=i.clientId||"",p=i.username,f=i.password,m=i.properties;void 0===u&&(u=!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||u))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*u==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%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 b={};if(5===a){if(!(b=M(t,c.properties)))return!1;g+=b.length}}let v=!1;if(null!=p){if(!$(p))return t.emit("error",new Error("Invalid username")),!1;v=!0,g+=n.byteLength(p)+2}if(null!=f){if(!v)return t.emit("error",new Error("Username is required to use password")),!1;if(!$(f))return t.emit("error",new Error("Invalid password")),!1;g+=q(f)+2}t.write(r.CONNECT_HEADER),O(t,g),U(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!=p?r.USERNAME_MASK:0,w|=null!=f?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|=u?r.CLEAN_SESSION_MASK:0,t.write(n.from([w])),d(t,l),5===a&&y.write(),U(t,h),c&&(5===a&&b.write(),T(t,c.topic),U(t,c.payload)),null!=p&&U(t,p),null!=f&&U(t,f),!0}function v(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,u=a.properties;let l=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,u),!h)return!1;l+=h.length}return t.write(r.CONNACK_HEADER),O(t,l),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||{},u=a.qos||0,l=a.retain?r.RETAIN_MASK:0,h=a.topic,p=a.payload||o,f=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(p)?g+=p.length:g+=n.byteLength(p),u&&"number"!=typeof f)return t.emit("error",new Error("Invalid messageId")),!1;u&&(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[u][a.dup?1:0][l?1:0]),O(t,g),d(t,q(h)),t.write(h),u>0&&d(t,f),null!=y&&y.write(),c("publish: payload: %o",p),t.write(p)}function _(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,u=s.dup&&"pubrel"===a?r.DUP_MASK:0;let l=0;const h=s.reasonCode,p=s.properties;let f=5===i?3:2;if("pubrel"===a&&(l=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof p){if(m=N(t,p,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[a][l][u][0]),O(t,f),d(t,c),5===i&&t.write(n.from([h])),null!==m&&m.write(),!0}function C(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?r.DUP_MASK:0,u=s.messageId,l=s.subscriptions,h=s.properties;let p=0;if("number"!=typeof u)return t.emit("error",new Error("Invalid messageId")),!1;p+=2;let f=null;if(5===i){if(f=M(t,h),!f)return!1;p+=f.length}if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<l.length;e+=1){const r=l[e].topic,o=l[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(l[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(l[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=l[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=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,p),d(t,u),null!==f&&f.write();let m=!0;for(const e of l){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,u=e.rh;let l;T(t,o),l=r.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(l|=a?r.SUBSCRIBE_OPTIONS_NL:0,l|=c?r.SUBSCRIBE_OPTIONS_RAP:0,l|=u?r.SUBSCRIBE_OPTIONS_RH[u]:0),m=t.write(n.from([l]))}return m}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,u=s.properties;let l=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(l+=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;l+=1}let h=null;if(5===i){if(h=N(t,u,o,l),!h)return!1;l+=h.length}return t.write(r.SUBACK_HEADER),O(t,l),d(t,a),null!==h&&h.write(),t.write(n.from(c))}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,u=s.unsubscriptions,l=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<u.length;e+=1){if("string"!=typeof u[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=n.byteLength(u[e])+2}let p=null;if(5===i){if(p=M(t,l),!p)return!1;h+=p.length}t.write(r.UNSUBSCRIBE_HEADER[1][c?1:0][0]),O(t,h),d(t,a),null!==p&&p.write();let f=!0;for(let e=0;e<u.length;e++)f=T(t,u[e]);return f}function E(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,u=s.granted,l=s.properties,h=s.cmd,p=0;let f=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return t.emit("error",new Error("Invalid qos vector")),!1;f+=1}}let m=null;if(5===i){if(m=N(t,l,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[h][p][c][0]),O(t,f),d(t,a),null!==m&&m.write(),5===i&&t.write(n.from(u)),!0}function A(e,t,n){return t.write(r.EMPTY[e.cmd])}function I(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===i?1:0,l=null;if(5===i){if(l=N(t,c,o,u),!l)return!1;u+=l.length}return t.write(n.from([r.codes.disconnect<<4])),O(t,u),5===i&&t.write(n.from([a])),null!==l&&l.write(),!0}function x(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const l=N(t,c,o,u);return!!l&&(u+=l.length,t.write(n.from([r.codes.auth<<4])),O(t,u),t.write(n.from([a])),null!==l&&l.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>d===P,set(e){e?(u&&0!==Object.keys(u).length||(m=!0),d=P):(m=!1,d=B)}});const R={};function O(e,t){if(t>r.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=R[t];return n||(n=p(t),t<16384&&(R[t]=n)),c("writeVarByteInt: writing to stream: %o",n),e.write(n)}function T(e,t){const r=n.byteLength(t);return d(e,r),c("writeString: %s",t),e.write(t,"utf8")}function F(e,t,n){T(e,t),T(e,n)}function P(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",u[t]),e.write(u[t])}function B(e,t){const n=l(t);return c("writeNumberGenerated: %o",n),e.write(n)}function j(e,t){const n=f(t);return c("write4ByteNumber: %o",n),e.write(n)}function U(e,t){"string"==typeof t?T(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(p(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(p(o))+o,write(){D(e,t,o)}}}function N(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]])),U(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]])),j(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]])),T(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]])),F(e,i.toString(),o.toString())})):(e.write(n.from([r.properties[t]])),F(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 $(e){return"string"==typeof e||e instanceof n}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":22,"./numbers":25,buffer:14,debug:15,"process-nextick-args":31}],29:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,c=365.25*s;function u(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 l(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?p(e,t,s,"day"):t>=i?p(e,t,i,"hour"):t>=o?p(e,t,o,"minute"):t>=r?p(e,t,r,"second"):e+" ms"}function p(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 u(e);if("number"===n&&isFinite(e))return t.long?h(e):l(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],30:[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:59}],31:[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:32}],32:[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 u(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 l,h=[],p=!1,f=-1;function d(){p&&l&&(p=!1,l.length?h=l.concat(h):f=-1,h.length&&m())}function m(){if(!p){var e=c(d);p=!0;for(var t=h.length;t;){for(l=h,h=[];++f<t;)l&&l[f].run();f=-1,t=h.length}l=null,p=!1,u(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||p||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}},{}],33:[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,u=2147483647,l=36,h=1,p=26,f=38,d=700,m=72,g=128,y="-",b=/^xn--/,v=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=l-h,S=Math.floor,k=String.fromCharCode;function E(e){throw new RangeError(_[e])}function A(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function I(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 R(e){return A(e,(function(e){var t="";return e>65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)})).join("")}function O(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:l}function T(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function F(e,t,n){var r=0;for(e=n?S(e/d):e>>1,e+=S(e/t);e>C*p>>1;r+=l)e=S(e/C);return S(r+(C+1)*e/(e+f))}function P(e){var t,n,r,o,i,s,a,c,f,d,b=[],v=e.length,w=0,_=g,C=m;for((n=e.lastIndexOf(y))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&E("not-basic"),b.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<v;){for(i=w,s=1,a=l;o>=v&&E("invalid-input"),((c=O(e.charCodeAt(o++)))>=l||c>S((u-w)/s))&&E("overflow"),w+=c*s,!(c<(f=a<=C?h:a>=C+p?p:a-C));a+=l)s>S(u/(d=l-f))&&E("overflow"),s*=d;C=F(w-i,t=b.length+1,0==i),S(w/t)>u-_&&E("overflow"),_+=S(w/t),w%=t,b.splice(w++,0,_)}return R(b)}function B(e){var t,n,r,o,i,s,a,c,f,d,b,v,w,_,C,A=[];for(v=(e=x(e)).length,t=g,n=0,i=m,s=0;s<v;++s)(b=e[s])<128&&A.push(k(b));for(r=o=A.length,o&&A.push(y);r<v;){for(a=u,s=0;s<v;++s)(b=e[s])>=t&&b<a&&(a=b);for(a-t>S((u-n)/(w=r+1))&&E("overflow"),n+=(a-t)*w,t=a,s=0;s<v;++s)if((b=e[s])<t&&++n>u&&E("overflow"),b==t){for(c=n,f=l;!(c<(d=f<=i?h:f>=i+p?p:f-i));f+=l)C=c-d,_=l-d,A.push(k(T(d+C%_,0))),c=S(C/_);A.push(k(T(c,0))),i=F(n,w,r==o),n=0,++r}++n,++t}return A.join("")}function j(e){return I(e,(function(e){return b.test(e)?P(e.slice(4).toLowerCase()):e}))}function U(e){return I(e,(function(e){return v.test(e)?"xn--"+B(e):e}))}if(a={version:"1.4.1",ucs2:{decode:x,encode:R},decode:P,encode:B,toASCII:U,toUnicode:j},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!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],34:[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 u=e.length;c>0&&u>c&&(u=c);for(var l=0;l<u;++l){var h,p,f,d,m=e[l].replace(a,"%20"),g=m.indexOf(n);g>=0?(h=m.substr(0,g),p=m.substr(g+1)):(h=m,p=""),f=decodeURIComponent(h),d=decodeURIComponent(p),r(s,f)?o(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],35:[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}},{}],36:[function(e,t,n){n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":34,"./encode":35}],37:[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 u(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=u(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},{}],38:[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=u;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(u,o);for(var s=r(i.prototype),a=0;a<s.length;a++){var c=s[a];u.prototype[c]||(u.prototype[c]=i.prototype[c])}function u(e){if(!(this instanceof u))return new u(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",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(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":40,"./_stream_writable":42,_process:32,inherits:21}],39:[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":41,inherits:21}],40:[function(e,t,n){(function(n,r){(function(){var o;t.exports=x,x.ReadableState=I,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 u(e){return a.from(e)}function l(e){return a.isBuffer(e)||e instanceof c}var h,p=e("util");h=p&&p.debuglog?p.debuglog("stream"):function(){};var f,d,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),b=e("./internal/streams/state").getHighWaterMark,v=e("../errors").codes,w=v.ERR_INVALID_ARG_TYPE,_=v.ERR_STREAM_PUSH_AFTER_EOF,C=v.ERR_METHOD_NOT_IMPLEMENTED,S=v.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(x,s);var k=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 I(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=b(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&&(f||(f=e("string_decoder/").StringDecoder),this.decoder=new f(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 I(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 R(e,t,n,r,o){h("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,j(e,s);else if(o||(i=T(s,t)),i)k(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=u(t)),r)s.endEmitted?k(e,new S):O(e,s,t,!0);else if(s.ended)k(e,new _);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):N(e,s)):O(e,s,t,!1)}else r||(s.reading=!1,N(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&&U(e)),N(e,t)}function T(e,t){var n;return l(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),R(this,e,t,!1,n)},x.prototype.unshift=function(e){return R(this,e,null,!0,!1)},x.prototype.isPaused=function(){return!1===this._readableState.flowing},x.prototype.setEncoding=function(t){f||(f=e("string_decoder/").StringDecoder);var n=new f(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 F=1073741824;function P(e){return e>=F?e=F:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function B(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=P(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 n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?U(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}function U(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 N(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 $(e){h("readable nexttick read 0"),e.read(0)}function H(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(W,e,t))}function W(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 z(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(J,t,e))}function J(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 Q(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):U(this),null;if(0===(e=B(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=B(n,t))),null===(r=e>0?z(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){k(this,new C("_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,p())}function c(){h("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var u=D(r);e.on("drain",u);var l=!1;function p(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",u),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",f),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||u()}function f(t){h("ondata");var n=e.write(t);h("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==Q(o.pipes,e))&&!l&&(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")&&k(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",f),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=Q(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?U(this):o.reading||n.nextTick($,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,H(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=z,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!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/async_iterator":43,"./internal/streams/buffer_list":44,"./internal/streams/destroy":45,"./internal/streams/from":47,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,events:19,inherits:21,"string_decoder/":55,util:13}],41:[function(e,t,n){t.exports=l;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 u(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 l(e){if(!(this instanceof l))return new l(e);c.call(this,e),this._transformState={afterTransform:u.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?p(this,null,null):this._flush((function(t,n){p(e,t,n)}))}function p(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")(l,c),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,n){n(new o("_transform()"))},l.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},l.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))},l.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":37,"./_stream_duplex":38,inherits:21}],42:[function(e,t,n){(function(n,r){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){W(t,e)}}var i;t.exports=I,I.WritableState=A;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,u=r.Uint8Array||function(){};function l(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof u}var p,f=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,b=m.ERR_MULTIPLE_CALLBACK,v=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,_=m.ERR_STREAM_NULL_VALUES,C=m.ERR_STREAM_WRITE_AFTER_END,S=m.ERR_UNKNOWN_ENCODING,k=f.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){j(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 I(t){var n=this instanceof(i=i||e("./_stream_duplex"));if(!n&&!p.call(I,this))return new I(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 C;k(e,r),n.nextTick(t,r)}function R(e,t,r,o){var i;return null===r?i=new _:"string"==typeof r||t.objectMode||(i=new g("chunk",["string","Buffer"],r)),!i||(k(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 T(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 u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else F(e,t,!1,a,r,o,i);return c}function F(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 P(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick($,e,t),e._writableState.errorEmitted=!0,k(e,o)):(i(o),e._writableState.errorEmitted=!0,k(e,o),$(e,t))}function B(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function j(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new b;if(B(r),t)P(e,r,o,t,i);else{var s=L(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||N(e,r),o?n.nextTick(U,e,r,s,i):U(e,r,s,i)}}function U(e,t,n,r){n||M(e,t),t.pendingcb--,r(),$(e,t)}function M(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function N(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,F(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 u=n.chunk,l=n.encoding,h=n.callback;if(F(e,t,!1,t.objectMode?1:u.length,u,l,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&&k(e,n),t.prefinished=!0,e.emit("prefinish"),$(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 $(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 H(e,t,r){t.ending=!0,$(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function W(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")(I,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]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===I&&e&&e._writableState instanceof A}})):p=function(e){return e instanceof this},I.prototype.pipe=function(){k(this,new v)},I.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=l(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||R(this,r,e,n))&&(r.pendingcb++,o=T(this,r,i,e,t,n)),o},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||N(this,e))},I.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 S(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function(e,t,n){n(new y("_write()"))},I.prototype._writev=null,I.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||H(this,r,n),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),I.prototype.destroy=f.destroy,I.prototype._undestroy=f.undestroy,I.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/destroy":45,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,inherits:21,"util-deprecate":58}],43:[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"),u=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function f(e,t){return{value:e,done:t}}function d(e){var t=e[s];if(null!==t){var n=e[p].read();null!==n&&(e[l]=null,e[s]=null,e[a]=null,t(f(n,!1)))}}function m(e){n.nextTick(d,e)}function g(e,t){return function(n,r){e.then((function(){t[u]?n(f(void 0,!0)):t[h](n,r)}),r)}}var y=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((o(r={get stream(){return this[p]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[u])return Promise.resolve(f(void 0,!0));if(this[p].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[c]?r(e[c]):t(f(void 0,!0))}))}));var r,o=this[l];if(o)r=new Promise(g(o,this));else{var i=this[p].read();if(null!==i)return Promise.resolve(f(i,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var e=this;return new Promise((function(t,n){e[p].destroy(null,(function(e){e?n(e):t(f(void 0,!0))}))}))})),r),y),v=function(e){var t,n=Object.create(b,(o(t={},p,{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,u,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var r=n[p].read();r?(n[l]=null,n[s]=null,n[a]=null,e(f(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[l]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[l]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var r=n[s];null!==r&&(n[l]=null,n[s]=null,n[a]=null,r(f(void 0,!0))),n[u]=!0})),e.on("readable",m.bind(null,n)),n};t.exports=v}).call(this)}).call(this,e("_process"))},{"./end-of-stream":46,_process:32}],44:[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 u=e("buffer").Buffer,l=e("util").inspect,h=l&&l.custom||"inspect";function p(e,t,n){u.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 u.alloc(0);for(var t=u.allocUnsafe(e>>>0),n=this.head,r=0;n;)p(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=u.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 l(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:14,util:13}],45:[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:32}],46:[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,u=t.writable||!1!==t.writable&&e.writable,l=function(){e.writable||p()},h=e._writableState&&e._writableState.finished,p=function(){u=!1,h=!0,c||n.call(e)},f=e._readableState&&e._readableState.endEmitted,d=function(){c=!1,f=!0,u||n.call(e)},m=function(t){n.call(e,t)},g=function(){var t;return c&&!f?(e._readableState&&e._readableState.ended||(t=new r),n.call(e,t)):u&&!h?(e._writableState&&e._writableState.ended||(t=new r),n.call(e,t)):void 0},y=function(){e.req.on("finish",p)};return s(e)?(e.on("complete",p),e.on("abort",g),e.req?y():e.on("request",y)):u&&!e._writableState&&(e.on("end",l),e.on("close",l)),e.on("end",d),e.on("finish",p),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",p),e.removeListener("end",l),e.removeListener("close",l),e.removeListener("finish",p),e.removeListener("end",d),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":37}],47:[function(e,t,n){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],48:[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 u(e){return e.setHeader&&"function"==typeof e.abort}function l(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 l=!1;return function(e){if(!c&&!l)return l=!0,u(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function p(e,t){return e.pipe(t)}function f(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=f(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 l(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(h),s||(i.forEach(h),o(r))}))}));return t.reduce(p)}t.exports=d},{"../../../errors":37,"./end-of-stream":46}],49:[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":37}],50:[function(e,t,n){t.exports=e("events").EventEmitter},{events:19}],51:[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":38,"./lib/_stream_passthrough.js":39,"./lib/_stream_readable.js":40,"./lib/_stream_transform.js":41,"./lib/_stream_writable.js":42,"./lib/internal/streams/end-of-stream.js":46,"./lib/internal/streams/pipeline.js":48}],52:[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},{}],53:[function(e,t,n){
|
|
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:14}],54:[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},{}],55:[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=b,void(this.end=v)}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 u(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 l(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=l(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 p(e,t){var n=u(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 f(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 b(e){return e.toString(this.encoding)}function v(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=f,a.prototype.text=p,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":53}],56:[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=C,n.resolveObject=S,n.format=_,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(u),h=["%","/","?",";","#"].concat(l),p=["/","?","#"],f=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},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=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 _(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function C(e,t){return w(e,!1,!0).resolve(t)}function S(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("#")?"?":"#",u=e.split(a),w=/\\/g;u[0]=u[0].replace(w,"/");var _=e=u.join(a);if(_=_.trim(),!n&&1===e.split("#").length){var C=c.exec(_);if(C)return this.path=_,this.href=_,this.pathname=C[1],C[2]?(this.search=C[2],this.query=t?v.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var S=s.exec(_);if(S){var k=(S=S[0]).toLowerCase();this.protocol=k,_=_.substr(S.length)}if(n||S||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===_.substr(0,2);!E||S&&y[S]||(_=_.substr(2),this.slashes=!0)}if(!y[S]&&(E||S&&!b[S])){for(var A,I,x=-1,R=0;R<p.length;R++)-1!==(O=_.indexOf(p[R]))&&(-1===x||O<x)&&(x=O);for(-1!==(I=-1===x?_.lastIndexOf("@"):_.lastIndexOf("@",x))&&(A=_.slice(0,I),_=_.slice(I+1),this.auth=decodeURIComponent(A)),x=-1,R=0;R<h.length;R++){var O;-1!==(O=_.indexOf(h[R]))&&(-1===x||O<x)&&(x=O)}-1===x&&(x=_.length),this.host=_.slice(0,x),_=_.slice(x),this.parseHost(),this.hostname=this.hostname||"";var T="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!T)for(var F=this.hostname.split(/\./),P=(R=0,F.length);R<P;R++){var B=F[R];if(B&&!B.match(d)){for(var j="",U=0,M=B.length;U<M;U++)B.charCodeAt(U)>127?j+="x":j+=B[U];if(!j.match(d)){var N=F.slice(0,R),L=F.slice(R+1),D=B.match(m);D&&(N.push(D[1]),L.unshift(D[2])),L.length&&(_="/"+L.join(".")+_),this.hostname=N.join(".");break}}}this.hostname.length>f?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",$=this.hostname||"";this.host=$+q,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[k])for(R=0,P=l.length;R<P;R++){var H=l[R];if(-1!==_.indexOf(H)){var W=encodeURIComponent(H);W===H&&(W=escape(H)),_=_.split(H).join(W)}}var V=_.indexOf("#");-1!==V&&(this.hash=_.substr(V),_=_.slice(0,V));var z=_.indexOf("?");if(-1!==z?(this.search=_.substr(z),this.query=_.substr(z+1),t&&(this.query=v.parse(this.query)),_=_.slice(0,z)):t&&(this.search="",this.query={}),_&&(this.pathname=_),b[k]&&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=v.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||b[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),u=0;u<c.length;u++){var l=c[u];"protocol"!==l&&(n[l]=e[l])}return b[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!b[e.protocol]){for(var h=Object.keys(e),p=0;p<h.length;p++){var f=h[p];n[f]=e[f]}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 v=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=w||v||n.host&&e.pathname,C=_,S=n.pathname&&n.pathname.split("/")||[],k=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!b[n.protocol]);if(k&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.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),_=_&&(""===d[0]||""===S[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,S=d;else if(d.length)S||(S=[]),S.pop(),S=S.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return k&&(n.hostname=n.host=S.shift(),(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.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(!S.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var E=S.slice(-1)[0],A=(n.host||e.host||S.length>1)&&("."===E||".."===E)||""===E,I=0,x=S.length;x>=0;x--)"."===(E=S[x])?S.splice(x,1):".."===E?(S.splice(x,1),I++):I&&(S.splice(x,1),I--);if(!_&&!C)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),A&&"/"!==S.join("/").substr(-1)&&S.push("");var R,O=""===S[0]||S[0]&&"/"===S[0].charAt(0);return k&&(n.hostname=n.host=O?"":S.length?S.shift():"",(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift())),(_=_||n.host&&S.length)&&!O&&S.unshift(""),S.length?n.pathname=S.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":57,punycode:33,querystring:36}],57:[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}}},{}],58:[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!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],59:[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},{}],60:[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")}},{}],61:[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}},{}]},{},[9])(9);var No=Mo.exports;var Lo;!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"}(Lo||(Lo={}));const Do=e=>{let t,n=0,r=!0;const o=()=>{setTimeout((()=>{n+=1,t.reconnect()}),1e3*Math.pow(2,n>10?10:n))};return{connect:async function(i){return t&&(t.removeAllListeners(),t.end(!0)),t=No.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:i.userId,password:i.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&&o()})),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 q(t.message,8e5,"error"):new H(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)}}};const qo=["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"],$o=["connect","message","disconnect","error","close","end","reconnect"],Ho=()=>{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},Wo=(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)}},Vo=(e,t)=>{const{emitter:n}=z();setTimeout((()=>{n.emit(e,t)}),0)},zo=async()=>{const e=z();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.user=void 0,e.accessToken=void 0,!e.ws.connected},Ko=()=>{const e=(()=>{var e,t;return(null===(e=null===process||void 0===process?void 0:process.versions)||void 0===e?void 0:e.node)?process.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}},Jo=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],Qo=e=>{const t=z(),n=Jo.map((n=>Wo(t,`client/onConnectionError(${n})`,n,(t=>{const r=(null==t?void 0:t.code)?new q(t.message,t.code,"fatal"):new W(n);e(r)}))));return()=>{n.forEach((e=>e()))}},Yo=e=>Qo((({code:t})=>{400312===t&&e()}));var Xo;e.SubscriptionLevels=void 0,(Xo=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",Xo.POST="post",Xo.COMMENT="comment",Xo.POST_AND_COMMENT="post_and_comment",Xo.USER="user";const Go=({path: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}};let Zo,ei;const ti=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:ni}=Object.prototype,{propertyIsEnumerable:ri}=Object,oi=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),ii=J,si={concatArrays:!1,ignoreUndefined:!1},ai=e=>{const t=[];for(const n in e)ni.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)ri.call(e,r)&&t.push(r)}return t};function ci(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return ai(e).forEach((n=>{oi(t,n,ci(e[n]))})),t}(e):ti(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return ai(e).forEach((n=>{oi(t,n,ci(e[n]))})),t}(e):e}const ui=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?oi(e,n,li(e[n],t[n],r)):oi(e,n,ci(t[n])))})),e);function li(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++)ni.call(t,n)&&(i.push(String(n)),oi(r,o++,t===e?t[n]:ci(t[n])));r=ui(r,t,ai(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):ti(t)&&ti(e)?ui(e,t,ai(t),n):ci(t)}const hi=function(...e){const t=li(ci(si),this!==ii&&this||{},si);let n={_:{}};for(const r of e)if(void 0!==r){if(!ti(r))throw new TypeError("`"+r+"` is not an Option Object");n=li(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0}),pi=(e,t)=>new Promise(((n,r)=>{try{const r=e();t&&t(null,r),n(r)}catch(e){t&&t(e),r(e)}})),fi=(e,t,n)=>Promise.all(e).then((e=>{const r=n?n(e):null;return t&&t(null,r),Promise.resolve(r)}),(e=>(t&&t(e),Promise.reject(e))));class di{static getItem(e,t){return pi((()=>window.localStorage.getItem(e)),t)}static setItem(e,t,n){return pi((()=>{window.localStorage.setItem(e,t)}),n)}static removeItem(e,t){return pi((()=>window.localStorage.removeItem(e)),t)}static mergeItem(e,t,n){return pi((()=>{((e,t)=>{const n=window.localStorage.getItem(e),r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(hi(r,o));window.localStorage.setItem(e,i)})(e,t)}),n)}static clear(e){return pi((()=>{window.localStorage.clear()}),e)}static getAllKeys(e){return pi((()=>{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)}static flushGetRequests(){}static multiGet(e,t){const n=e.map((e=>di.getItem(e)));return fi(n,t,(t=>t.map(((t,n)=>[e[n],t]))))}static multiSet(e,t){const n=e.map((e=>di.setItem(e[0],e[1])));return fi(n,t)}static multiRemove(e,t){const n=e.map((e=>di.removeItem(e)));return fi(n,t)}static multiMerge(e,t){const n=e.map((e=>di.mergeItem(e[0],e[1])));return fi(n,t)}}const mi=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})),gi=e=>JSON.parse(e),yi=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>yi(e[n],t[n])))),bi=e=>{const{log:t,cache:n}=z();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=gi(t);return yi(e,n)})).map((e=>n.data[e]))},vi=e=>{const{log:t,cache:n}=z();if(!n)return;t("cache/api/pullFromCache",e);const r=mi(e);return n.data[r]?n.data[r]:void 0},wi=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=z();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=mi(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},_i=(e,t,n)=>{const{log:r,cache:o}=z();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=vi(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return wi(e,s,n),!0},Ci=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=z();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return vi(e)?_i(e,t,n):wi(e,t,n)},Si=(e,t=!1)=>{const{log:n,cache:r}=z();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>gi(e))).filter((t=>yi(e,t))).map((e=>Si(e,!0))).every((e=>e));const o=mi(e);return o in r.data&&(delete r.data[o],!0)},ki={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,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,stream:({streamId:e})=>e},Ei=e=>ki[e],Ai={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",videoStreamings:"stream"},Ii=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=Ai[e];if(!r)return;const o=Ei(r);n.forEach((e=>{Ci([r,"get",o(e)],e,t)}))}))},xi=async e=>{const t=z();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};xi.locally=e=>{const t=z();return t.log("user/getUser.locally",e),t.cache&&vi(["user","get",e])};const Ri=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.users,cachedAt:o}};
|
|
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:14}],54:[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},{}],55:[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=b,void(this.end=v)}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 u(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 l(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=l(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 p(e,t){var n=u(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 f(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 b(e){return e.toString(this.encoding)}function v(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=f,a.prototype.text=p,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":53}],56:[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=C,n.resolveObject=S,n.format=_,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(u),h=["%","/","?",";","#"].concat(l),p=["/","?","#"],f=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},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=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 _(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function C(e,t){return w(e,!1,!0).resolve(t)}function S(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("#")?"?":"#",u=e.split(a),w=/\\/g;u[0]=u[0].replace(w,"/");var _=e=u.join(a);if(_=_.trim(),!n&&1===e.split("#").length){var C=c.exec(_);if(C)return this.path=_,this.href=_,this.pathname=C[1],C[2]?(this.search=C[2],this.query=t?v.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var S=s.exec(_);if(S){var k=(S=S[0]).toLowerCase();this.protocol=k,_=_.substr(S.length)}if(n||S||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===_.substr(0,2);!E||S&&y[S]||(_=_.substr(2),this.slashes=!0)}if(!y[S]&&(E||S&&!b[S])){for(var A,I,x=-1,R=0;R<p.length;R++)-1!==(O=_.indexOf(p[R]))&&(-1===x||O<x)&&(x=O);for(-1!==(I=-1===x?_.lastIndexOf("@"):_.lastIndexOf("@",x))&&(A=_.slice(0,I),_=_.slice(I+1),this.auth=decodeURIComponent(A)),x=-1,R=0;R<h.length;R++){var O;-1!==(O=_.indexOf(h[R]))&&(-1===x||O<x)&&(x=O)}-1===x&&(x=_.length),this.host=_.slice(0,x),_=_.slice(x),this.parseHost(),this.hostname=this.hostname||"";var T="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!T)for(var F=this.hostname.split(/\./),P=(R=0,F.length);R<P;R++){var B=F[R];if(B&&!B.match(d)){for(var j="",U=0,M=B.length;U<M;U++)B.charCodeAt(U)>127?j+="x":j+=B[U];if(!j.match(d)){var N=F.slice(0,R),L=F.slice(R+1),D=B.match(m);D&&(N.push(D[1]),L.unshift(D[2])),L.length&&(_="/"+L.join(".")+_),this.hostname=N.join(".");break}}}this.hostname.length>f?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",$=this.hostname||"";this.host=$+q,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[k])for(R=0,P=l.length;R<P;R++){var H=l[R];if(-1!==_.indexOf(H)){var W=encodeURIComponent(H);W===H&&(W=escape(H)),_=_.split(H).join(W)}}var V=_.indexOf("#");-1!==V&&(this.hash=_.substr(V),_=_.slice(0,V));var z=_.indexOf("?");if(-1!==z?(this.search=_.substr(z),this.query=_.substr(z+1),t&&(this.query=v.parse(this.query)),_=_.slice(0,z)):t&&(this.search="",this.query={}),_&&(this.pathname=_),b[k]&&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=v.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||b[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),u=0;u<c.length;u++){var l=c[u];"protocol"!==l&&(n[l]=e[l])}return b[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!b[e.protocol]){for(var h=Object.keys(e),p=0;p<h.length;p++){var f=h[p];n[f]=e[f]}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 v=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=w||v||n.host&&e.pathname,C=_,S=n.pathname&&n.pathname.split("/")||[],k=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!b[n.protocol]);if(k&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.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),_=_&&(""===d[0]||""===S[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,S=d;else if(d.length)S||(S=[]),S.pop(),S=S.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return k&&(n.hostname=n.host=S.shift(),(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.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(!S.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var E=S.slice(-1)[0],A=(n.host||e.host||S.length>1)&&("."===E||".."===E)||""===E,I=0,x=S.length;x>=0;x--)"."===(E=S[x])?S.splice(x,1):".."===E?(S.splice(x,1),I++):I&&(S.splice(x,1),I--);if(!_&&!C)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),A&&"/"!==S.join("/").substr(-1)&&S.push("");var R,O=""===S[0]||S[0]&&"/"===S[0].charAt(0);return k&&(n.hostname=n.host=O?"":S.length?S.shift():"",(R=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=R.shift(),n.host=n.hostname=R.shift())),(_=_||n.host&&S.length)&&!O&&S.unshift(""),S.length?n.pathname=S.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":57,punycode:33,querystring:36}],57:[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}}},{}],58:[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!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],59:[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},{}],60:[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")}},{}],61:[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}},{}]},{},[9])(9);var No=Mo.exports;var Lo;!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"}(Lo||(Lo={}));const Do=e=>{let t,n=0,r=!0;const o=()=>{setTimeout((()=>{n+=1,t.reconnect()}),1e3*Math.pow(2,n>10?10:n))};return{connect:async function(i){return t&&(t.removeAllListeners(),t.end(!0)),t=No.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:i.userId,password:i.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&&o()})),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 q(t.message,8e5,"error"):new H(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)}}};const qo=["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"],$o=["connect","message","disconnect","error","close","end","reconnect"],Ho=()=>{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},Wo=(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)}},Vo=(e,t)=>{const{emitter:n}=z();setTimeout((()=>{n.emit(e,t)}),0)},zo=async()=>{const e=z();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},Ko=()=>{const e=(()=>{var e,t;return(null===(e=null===process||void 0===process?void 0:process.versions)||void 0===e?void 0:e.node)?process.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}},Jo=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],Qo=e=>{const t=z(),n=Jo.map((n=>Wo(t,`client/onConnectionError(${n})`,n,(t=>{const r=(null==t?void 0:t.code)?new q(t.message,t.code,"fatal"):new W(n);e(r)}))));return()=>{n.forEach((e=>e()))}},Yo=e=>Qo((({code:t})=>{400312===t&&e()}));var Xo;e.SubscriptionLevels=void 0,(Xo=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",Xo.POST="post",Xo.COMMENT="comment",Xo.POST_AND_COMMENT="post_and_comment",Xo.USER="user";const Go=({path: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}};let Zo,ei;const ti=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:ni}=Object.prototype,{propertyIsEnumerable:ri}=Object,oi=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),ii=J,si={concatArrays:!1,ignoreUndefined:!1},ai=e=>{const t=[];for(const n in e)ni.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)ri.call(e,r)&&t.push(r)}return t};function ci(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return ai(e).forEach((n=>{oi(t,n,ci(e[n]))})),t}(e):ti(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return ai(e).forEach((n=>{oi(t,n,ci(e[n]))})),t}(e):e}const ui=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?oi(e,n,li(e[n],t[n],r)):oi(e,n,ci(t[n])))})),e);function li(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++)ni.call(t,n)&&(i.push(String(n)),oi(r,o++,t===e?t[n]:ci(t[n])));r=ui(r,t,ai(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):ti(t)&&ti(e)?ui(e,t,ai(t),n):ci(t)}const hi=function(...e){const t=li(ci(si),this!==ii&&this||{},si);let n={_:{}};for(const r of e)if(void 0!==r){if(!ti(r))throw new TypeError("`"+r+"` is not an Option Object");n=li(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0}),pi=(e,t)=>new Promise(((n,r)=>{try{const r=e();t&&t(null,r),n(r)}catch(e){t&&t(e),r(e)}})),fi=(e,t,n)=>Promise.all(e).then((e=>{const r=n?n(e):null;return t&&t(null,r),Promise.resolve(r)}),(e=>(t&&t(e),Promise.reject(e))));class di{static getItem(e,t){return pi((()=>window.localStorage.getItem(e)),t)}static setItem(e,t,n){return pi((()=>{window.localStorage.setItem(e,t)}),n)}static removeItem(e,t){return pi((()=>window.localStorage.removeItem(e)),t)}static mergeItem(e,t,n){return pi((()=>{((e,t)=>{const n=window.localStorage.getItem(e),r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(hi(r,o));window.localStorage.setItem(e,i)})(e,t)}),n)}static clear(e){return pi((()=>{window.localStorage.clear()}),e)}static getAllKeys(e){return pi((()=>{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)}static flushGetRequests(){}static multiGet(e,t){const n=e.map((e=>di.getItem(e)));return fi(n,t,(t=>t.map(((t,n)=>[e[n],t]))))}static multiSet(e,t){const n=e.map((e=>di.setItem(e[0],e[1])));return fi(n,t)}static multiRemove(e,t){const n=e.map((e=>di.removeItem(e)));return fi(n,t)}static multiMerge(e,t){const n=e.map((e=>di.mergeItem(e[0],e[1])));return fi(n,t)}}const mi=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})),gi=e=>JSON.parse(e),yi=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>yi(e[n],t[n])))),bi=e=>{const{log:t,cache:n}=z();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=gi(t);return yi(e,n)})).map((e=>n.data[e]))},vi=e=>{const{log:t,cache:n}=z();if(!n)return;t("cache/api/pullFromCache",e);const r=mi(e);return n.data[r]?n.data[r]:void 0},wi=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=z();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=mi(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},_i=(e,t,n)=>{const{log:r,cache:o}=z();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=vi(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return wi(e,s,n),!0},Ci=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=z();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return vi(e)?_i(e,t,n):wi(e,t,n)},Si=(e,t=!1)=>{const{log:n,cache:r}=z();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>gi(e))).filter((t=>yi(e,t))).map((e=>Si(e,!0))).every((e=>e));const o=mi(e);return o in r.data&&(delete r.data[o],!0)},ki={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,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,stream:({streamId:e})=>e},Ei=e=>ki[e],Ai={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",videoStreamings:"stream"},Ii=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=Ai[e];if(!r)return;const o=Ei(r);n.forEach((e=>{Ci([r,"get",o(e)],e,t)}))}))},xi=async e=>{const t=z();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};xi.locally=e=>{const t=z();return t.log("user/getUser.locally",e),t.cache&&vi(["user","get",e])};const Ri=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.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 Oi(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}Ri.locally=e=>{var t;const n=z();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Ti=async(e={})=>{const t=z();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=Oi(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:R(n,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{users:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});wi(["user","query",e],{users:l.map(Ei("user")),paging:c})}return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:O(c.next)}};Ti.locally=(e={})=>{var t,n,r;const o=z();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=vi(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>vi(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],u=O(null==s?void 0:s.paging.previous),l=O(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:u,nextPage:l}:void 0};const Fi=(e,t)=>{const n=z();return Wo(n,e,e,(e=>{n.cache&&Ii(e),t(e.users[0])}))},Pi=e=>Fi("user.updated",e),Bi=e=>Fi("user.flagged",e),ji=e=>Fi("user.unflagged",e),Ui=e=>Fi("user.flagCleared",e),Mi=async e=>{const t=z();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&Ii({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};Mi.locally=e=>{const t=z();if(t.log("file/getFile.locally",e),!t.cache)return;const n=vi(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ni=async e=>{const t=z();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{roles:l}=u,h=t.cache&&Date.now();t.cache&&Ii(u,{cachedAt:h});const p=O(c.next);return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:p}};Ni.locally=e=>{z().log("role/queryRoles.locally",e)};const Li=async e=>{const t=z();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&Ii({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};Li.locally=e=>{const t=z();if(t.log("role/getRole.locally",e),!t.cache)return;const n=vi(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Di=(e,t)=>{"message"===e?Vo("v3.message.didUpdate",{messages:[t]}):"post"===e?Vo("post.updated",{posts:[t]}):"comment"===e&&Vo("comment.updated",{comments:[t]})},qi=async e=>{const t=z();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};qi.locally=e=>{const t=z();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=vi(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const $i=async e=>{const t=z();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&&Ii(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};$i.locally=e=>{var t;const n=z();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Hi=async e=>{const t=z();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=Oi(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:R(n,"afterbefore")}})}),{paging:i}=o,s=Oi(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{messages:a.map(Ei("message")),paging:i})}const u=O(i.next);return{data:a,cachedAt:c,prevPage:O(i.previous),nextPage:u}};Hi.locally=e=>{var t,n;const r=z();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Oi(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const u=a.messages.map((e=>vi(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),l=O(null==a?void 0:a.paging.previous),h=O(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const Wi=async e=>{const t=z();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};Wi.optimistically=e=>{var t,n;const r=z();if(r.log("user/createMessage.locally",e),!r.cache)return;const o=vi(["channel","get",e.channelId]);Ci(["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 wi(["message","get",i.messageId],i,{cachedAt:-1}),Vo("v3.message.didCreate",{messages:[i]}),{data:i,cachedAt:-1}};const Vi=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};Vi.optimistically=(e,t)=>{const n=z();if(n.log("user/updateMessage",t),!n.cache)return;const r=vi(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return Ci(["message","get",e],o,{cachedAt:-1}),Vo("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const zi=async e=>{const t=z();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await qi(e)).data};zi.optimistically=e=>{z().log("message/deleteMessage",e);const t=vi(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return Ci(["message","get",e],n,{cachedAt:-1}),Vo("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const Ki=async e=>{const t=z();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=Oi(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:R(n,"afterbeforeraw")}})}),{paging:i}=o,s=Oi(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{posts:a.map(Ei("post")),paging:i})}const u=T(i.next);return{data:a,cachedAt:c,prevPage:T(i.previous),nextPage:u}};Ki.locally=e=>{var t,n;const r=z();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Oi(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const u=a.posts.map((e=>vi(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),l=T(null==a?void 0:a.paging.previous),h=T(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const Ji=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.posts,cachedAt:o}};Ji.locally=e=>{var t;const n=z();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Qi=async e=>{var t;const n=z();let r;n.log("post/getPost",e);try{r=(await n.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Si(["post","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}};Qi.locally=e=>{const t=z();if(t.log("post/getPost.locally",e),!t.cache)return;const n=vi(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Yi=async e=>{const t=z();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{communities:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];wi(e,{communities:l.map(Ei("community")),paging:c})}const p=O(c.next);return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:p}};Yi.locally=e=>{z().log("community/queryCommunities.locally",e)};const Xi=async e=>{const t=z();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&&Ii(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};Xi.locally=e=>{var t;const n=z();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Gi=async e=>{const t=z();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};Gi.locally=e=>{const t=z();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=vi(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Zi=async e=>{const t=z();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=Oi(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:R(r,"skiplimit")}})}),{paging:a}=s,c=Oi(s,["paging"]),{communityUsers:u}=c,l=t.cache&&Date.now();t.cache&&Ii(c,{cachedAt:l});return{data:u,nextPage:O(a.next),prevPage:O(a.previous)}};Zi.locally=e=>{z().log("community/queryCommunityMembers",e)};const es=async e=>{const t=z();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=Oi(e,["page"]),{data:o}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:{token:R(n,"afterbefore")}})}),{paging:i}=o,s=Oi(o,["paging"]),{comments:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{comments:a.map(Ei("comment")),paging:i})}const u=O(i.next);return{data:a,cachedAt:c,prevPage:O(i.previous),nextPage:u}};es.locally=e=>{var t,n;const r=z();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Oi(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const u=a.comments.map((e=>vi(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),l=O(null==a?void 0:a.paging.previous),h=O(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const ts=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.comments,cachedAt:o}};ts.locally=e=>{var t;const n=z();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 ns=async e=>{var t;const n=z();let r;n.log("comment/getComment",e);try{r=(await n.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Si(["comment","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}};ns.locally=e=>{const t=z();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=vi(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const rs=async(e,t)=>{if("message"===e)return qi(t);if("post"===e)return Qi(t);if("comment"===e)return ns(t);throw new Error(`Incorrect referenceType: ${e}`)},os=(e,t)=>{var n,r;if(z().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=vi(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=vi(["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))})}},is=async(e,t,n)=>{var r,o;const i=z();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 rs(e,t);return Di(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};is.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=z();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const u=vi([e,"get",t]);if(!(null==u?void 0:u.data)||(null===(r=u.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const l=Object.assign(Object.assign({},u.data),{reactionsCount:u.data.reactionsCount+1,myReactions:[...null!==(o=u.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},u.data.reactions),{[n]:(null!==(i=u.data.reactions[n])&&void 0!==i?i:0)+1})});return Ci([e,"get",t],l,{cachedAt:-1}),Di(e,l),null!==(a=null===(s=null==l?void 0:l.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const ss=async(e,t,n)=>{var r,o;const i=z();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 rs(e,t);return Di(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};ss.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=z();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const u=vi([e,"get",t]);if(!(null==u?void 0:u.data)||!(null===(r=u.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const l=Object.assign(Object.assign({},u.data),{reactionsCount:Math.max(0,u.data.reactionsCount-1),myReactions:(null!==(o=u.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},u.data.reactions),{[n]:Math.max(0,(null!==(i=u.data.reactions[n])&&void 0!==i?i:0)-1)})});return Ci([e,"get",t],l,{cachedAt:-1}),Di(e,l),null!==(a=!(null===(s=null==l?void 0:l.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};const as=(e,t)=>{const n=z();return Wo(n,e,e,(r=>{var o;if(n.cache){const{communities:n}=r,i=Oi(r,["communities"]);Ii(i),(null==n?void 0:n[0])&&!["post.updated"].includes(e)&&Vo("community.updated",{communities:n});const s=vi(["post","get",r.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=bi(["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})=>Ci(e,t,{cachedAt:-1})))}t(s.data)}else t(r.posts[0])}))},cs=e=>as("post.created",e),us=e=>as("post.updated",e),ls=e=>as("post.deleted",e),hs=e=>as("post.approved",e),ps=e=>as("post.declined",e),fs=e=>as("post.flagged",e),ds=e=>as("post.unflagged",e),ms=e=>{const t=z();return Wo(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){os("post.addReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},gs=e=>{const t=z();return Wo(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){os("post.removeReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},ys=(e,t)=>{const n=z();return Wo(n,e,e,(r=>{var o;if(n.cache){Ii(r);const n=vi(["comment","get",r.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=bi(["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})=>Ci(e,t,{cachedAt:-1})))}t(n.data)}else t(r.comments[0])}))},bs=e=>ys("comment.created",e),vs=e=>ys("comment.updated",e),ws=e=>ys("comment.deleted",e),_s=e=>ys("comment.flagged",e),Cs=e=>ys("comment.unflagged",e),Ss=e=>{const t=z();return Wo(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){os("comment.addReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},ks=e=>{const t=z();return Wo(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){os("comment.removeReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))};var Es={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 As=async e=>{const t=z();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{channels:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];wi(e,{channels:l.map(Ei("channel")),paging:c})}const p=O(c.next);return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:p}};As.locally=e=>{z().log("channel/queryChannels.locally",e)};const Is=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.channels,cachedAt:o}};Is.locally=e=>{var t;const n=z();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 xs=async e=>{const t=z();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};xs.locally=e=>{const t=z();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=vi(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Rs=async e=>{const t=z();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o,membership:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{channelUsers:l}=u;t.cache&&Ii(u);return{data:l,nextPage:O(c.next),prevPage:O(c.previous)}};Rs.locally=e=>{z().log("channel/queryChannelMembers",e)};const Os=e=>{const t=z();return Wo(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{Ii(t),e(t.channels[0])}))},Ts=e=>{const t=z();return Wo(t,"onChannelDeleted","v3.channel.didDelete",(t=>{Ii(t),e(t.channels[0])}))},Fs=e=>{const t=z();return Wo(t,"onChannelJoined","v3.channel.didJoin",(t=>{Ii(t),e(t.channels[0])}))},Ps=e=>{const t=z();return Wo(t,"onChannelLeft","v3.channel.didLeave",(t=>{Ii(t),e(t.channels[0])}))},Bs=e=>{const t=z();return Wo(t,"onMemberAdded","v3.channel.didAddUsers",(t=>{Ii(t),e(t.channels[0])}))},js=e=>{const t=z();return Wo(t,"onMemberRemoved","v3.channel.didRemoveUsers",(t=>{Ii(t),e(t.channels[0])}))},Us=e=>{const t=z();return Wo(t,"message/onMessageCreated","v3.message.didCreate",(t=>{Ii(t),e(t.messages[0])}))},Ms=e=>{const t=z();return Wo(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{Ii(t),e(t.messages[0])}))},Ns=e=>{const t=z();return Wo(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{Ii(t),e(t.messages[0])}))},Ls=(e,t)=>{const n=z();return Wo(n,e,e,(e=>{if(n.cache){Ii(e);const n=vi(["community","get",e.communities[0].communityId]);t(n.data)}else t(e.communities[0])}))};function Ds(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function qs(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=>!Ds(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!Ds(e,t,"ADD_COMMUNITY_USER")))[0]}const $s=(e,t)=>{const n=z();return Wo(n,e,e,(r=>{if(n.cache){Ii(r);const n=vi(["community","get",r.communities[0].communityId]),o=vi(["communityUsers","get",Ei("communityUsers")(qs(e,r))]);t(n.data,o.data)}else t(r.communities[0],qs(e,r))}))},Hs=e=>Ls("community.updated",e),Ws=e=>Ls("community.deleted",e),Vs=e=>$s("community.joined",e),zs=e=>$s("community.left",e),Ks=e=>$s("community.userAdded",e),Js=e=>$s("community.userRemoved",e),Qs=e=>$s("community.userBanned",e),Ys=e=>$s("community.userUnbanned",e),Xs=async e=>{const t=z();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};Xs.locally=e=>{const t=z();if(t.log("stream/getStream",e),!t.cache)return;const n=vi(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Gs=async e=>{const t=z();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=Oi(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:R(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,u=t.cache&&Date.now();t.cache&&Ii(a,{cachedAt:u});const l=O(s.next);return{data:c,cachedAt:u,prevPage:O(s.previous),nextPage:l}};Gs.locally=e=>{z().log("stream/queryStreams.locally",e)};return e.VERSION=n,e.addChannelMembers=async(e,t)=>{const n=z();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&&Ii(r),Vo("v3.channel.didAddUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=z();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&&Ii(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=z();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&Ii(r),Vo("community.userAdded",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRole=async(e,t,n)=>{const r=z();r.log("community/addCommunityMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/communities/${e}/users/roles`,{communityId:e,role:t,userIds:n});r.cache&&Ii(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&n.roles.includes(t)))},e.addReaction=is,e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=z();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 di.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.connectClient=async e=>{var t,n;const r=z();r.log("client/api/connectClient",Object.assign({apiKey:r.apiKey},e)),null!==(t=e.displayName)&&void 0!==t||(e.displayName=e.userId),null!==(n=e.deviceId)&&void 0!==n||(e.deviceId=`ascWebSdk#${Math.random().toString(16)}`);const{accessToken:o,users:i}=await(async e=>{const t=z();t.log("client/api/getToken",e);const n=await Ko(),{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 s,a;r.http.defaults.headers.common.Authorization=`Bearer ${o}`,r.ws.io.opts.query={token:o},s=r.ws,a=r.emitter,qo.forEach((e=>{s.on(e,(t=>a.emit(e,t)))})),await new Promise((e=>{r.ws.once("connect",e),r.ws.open()}));const c=Yo((()=>{zo(),c()}));return r.userId=e.userId,r.user=i[0],r.accessToken=o,r.ws.connected},e.createChannel=async e=>{const t=z();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&&Ii(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=ce,r="amity")=>{const o=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&"production"!==process.env.NODE_ENV,n=ae(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(r);o("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiEndpoint:t});const i=(e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Rt.create({baseURL:e,httpAgent:new Pt(t),httpsAgent:new Tt(t),paramsSerializer:jt});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&&Bt(n.data)})),n})(le(ue.HTTP,t)),s=(e=>{const t=Uo(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(le(ue.HTTP,t)),a=Do(le(ue.MQTT,t)),c=Ho(),u={version:`${n}`,apiKey:e,log:o,http:i,ws:s,mqtt:a,emitter:c,use:()=>K(u)};try{z()}catch(e){K(u)}return u},e.createComment=async e=>{const t=z();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const o=await Qi(e.referenceId);Vo("post.updated",{posts:[o.data]}),Vo("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=z();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),Vo("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=z();if(n.log("file/createFile",e),!e.getAll("file").length)throw new Error("The formData object must have a `file` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v3/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Ii({files:o},{cachedAt:i}),{data:o[0],cachedAt:i}},e.createMessage=Wi,e.createPost=async e=>{const t=z();t.log("post/createPost",e),e.dataType&&!["text","image","file"].includes(e.dataType)||delete e.dataType;const{data:n}=await t.http.post("/api/v3/posts",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),Vo("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=M,e.createReport=async(e,t)=>{const n=z();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=Es[e],{data:o}=await n.http.post(`/api/v3/${r}/${encodeURIComponent(t)}/flag`);n.cache&&Ii(o);return Vo("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=z();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.deleteChannel=async e=>{const t=z();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await xs(e)).data},e.deleteComment=async(e,t=!1)=>{const n=z();n.log("comment/deleteComment",e);const r=await ns(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 Qi(r.data.referenceId);return Vo("post.updated",{posts:[i.data]}),Vo("comment.deleted",{comments:[o]}),t?setTimeout((()=>{Si(["comment","get",e],!0)}),0):Ci(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=z();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await Gi(e);return Vo("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=z();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),Si(["file","get",e],!0),{success:!0}},e.deleteMessage=zi,e.deletePost=async(e,t=!1)=>{const n=z();n.log("post/deletePost",e);let r=await Qi(e);if(await n.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await Gi(r.data.targetId);Vo("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return Vo("post.deleted",{posts:[o]}),t?setTimeout((()=>{Si(["post","get",e],!0)}),0):Ci(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=z();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=Es[e],{data:o}=await n.http.delete(`/api/v3/${r}/${encodeURIComponent(t)}/unflag`);n.cache&&Ii(o);return Vo("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=z();t.log("stream/deleteStream",e);let n=await Xs(e);const{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Ci(["stream","get",e],i),o},e.disableCache=()=>{const e=z();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=zo,e.disposeStream=async e=>{const t=z();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&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=Si,e.enableCache=(e={},t)=>{const n=z();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.getActiveClient=z,e.getChannel=xs,e.getChannels=Is,e.getComment=ns,e.getCommentTopic=({path:e})=>e,e.getComments=ts,e.getCommunities=Xi,e.getCommunity=Gi,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>Go({path:t},n),e.getFile=Mi,e.getMessage=qi,e.getMessages=$i,e.getPost=Qi,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=Ji,e.getRole=Li,e.getStream=Xs,e.getUser=xi,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>Go({path:t},n),e.getUsers=Ri,e.isAfterBefore=A,e.isAfterBeforeRaw=I,e.isCachable=j,e.isConnected=()=>{var e,t;const n=z();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=F,e.isFresh=U,e.isLocal=e=>j(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=P,e.isOffline=B,e.isPaged=x,e.isReportedByMe=async(e,t)=>{var n,r;const o=z();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=Es[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(Bt(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=E,e.joinChannel=async e=>{const t=z();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&Ii(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=z();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),Vo("community.joined",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=z();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&Ii(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=z();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),Vo("community.left",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=_i,e.observeChannel=(e,t)=>{const{log:n}=z(),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(Os((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),Ts((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),Fs((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),Ps((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),Bs((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),js((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),L(M(xs,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}=z(),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(vs((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),ws((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),_s((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Cs((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Ss((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),ks((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),L(M(ns,e),(e=>(e.data||e.error)&&i(e,"onFetch")),N(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=z(),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(bs((e=>i(e,"onCreate"))),vs((e=>i(e,"onUpdate"))),ws((e=>i(e,"onDelete"))),_s((e=>i(e,"onFlagged"))),Cs((e=>i(e,"onUnflagged"))),Ss((e=>i(e,"onReactionAdded"))),ks((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=z(),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(Hs((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ws((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),Vs((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),zs((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),Ks((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),Js((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),Qs((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),Ys((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),L(M(Gi,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}=z(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return L(M(Mi,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.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=z(),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(Ms((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ns((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&L(M(qi,e),(e=>e.data&&i(e,"onFetch")),N(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=z(),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(Us((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),Ms((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ns((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}=z(),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"))),hs((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),ps((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),fs((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),ds((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),ms((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),gs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),L(M(Qi,e),(e=>(e.data||e.error)&&i(e,"onFetch")),N(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=z(),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(cs((e=>i(e,"onCreate"))),us((e=>i(e,"onUpdate"))),ls((e=>i(e,"onDelete"))),hs((e=>i(e,"onApproved"))),ps((e=>i(e,"onDeclined"))),fs((e=>i(e,"onFlagged"))),ds((e=>i(e,"onUnflagged"))),ms((e=>i(e,"onReactionAdded"))),gs((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=z(),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(Pi((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),Bi((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),ji((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),Ui((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),L(M(xi,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=Ts,e.onChannelJoined=Fs,e.onChannelLeft=Ps,e.onChannelUpdated=Os,e.onClientBanned=Yo,e.onClientDisconnected=e=>Qo((({code:t})=>{800211===t&&e()})),e.onCommentCreated=bs,e.onCommentDeleted=ws,e.onCommentFlagged=_s,e.onCommentReactionAdded=Ss,e.onCommentReactionRemoved=ks,e.onCommentUnflagged=Cs,e.onCommentUpdated=vs,e.onCommunityCreated=e=>Ls("community.created",e),e.onCommunityDeleted=Ws,e.onCommunityJoined=Vs,e.onCommunityLeft=zs,e.onCommunityUpdated=Hs,e.onCommunityUserAdded=Ks,e.onCommunityUserBanned=Qs,e.onCommunityUserRemoved=Js,e.onCommunityUserUnbanned=Ys,e.onConnectionError=Qo,e.onMemberAdded=Bs,e.onMemberRemoved=js,e.onMessageCreated=Us,e.onMessageDeleted=Ns,e.onMessageUpdated=Ms,e.onPostApproved=hs,e.onPostCreated=cs,e.onPostDeclined=ps,e.onPostDeleted=ls,e.onPostFlagged=fs,e.onPostReactionAdded=ms,e.onPostReactionRemoved=gs,e.onPostUnflagged=ds,e.onPostUpdated=us,e.onReactionRemoved=(e,t,n)=>{const r=r=>{Ei(e)(r)===t&&n(r)};if("message"===e){const e=z(),t=e=>{var t;const n=vi(["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;Ii(e),o&&r(e.messages[0])};return Wo(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?gs(r):ks(r)},e.onStreamRecorded=e=>{const t=z();return Wo(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=z();return Wo(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=z();return Wo(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onUserFlagCleared=Ui,e.onUserFlagged=Bi,e.onUserUnflagged=ji,e.onUserUpdated=Pi,e.pullFromCache=vi,e.pushToCache=wi,e.queryCache=bi,e.queryChannelMembers=Rs,e.queryChannels=As,e.queryComments=es,e.queryCommunities=Yi,e.queryCommunityMembers=Zi,e.queryGlobalFeed=async e=>{const t=z();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{page:r}=n,o=Oi(n,["page"]),{data:i}=await t.http.get("/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},o),{options:{token:R(r,"skiplimit")}})}),{paging:s}=i,a=Oi(i,["paging"]),{posts:c}=a;t.cache&&Ii(a);const u=O(s.next);return{data:c,prevPage:O(s.previous),nextPage:u}},e.queryMessages=Hi,e.queryOptions=N,e.queryPosts=Ki,e.queryRoles=Ni,e.queryStreams=Gs,e.queryUsers=Ti,e.removeChannelMembers=async(e,t)=>{const n=z();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&&Ii(r),Vo("v3.channel.didRemoveUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=z();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&&Ii(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=z();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&&Ii(r),Vo("community.userRemoved",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRole=async(e,t,n)=>{const r=z();r.log("community/removeCommunityMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/communities/${e}/users/roles`,{data:{communityId:e,role:t,userIds:n}});r.cache&&Ii(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!n.roles.includes(t)))},e.removeReaction=ss,e.restoreCache=async(e="amitySdk")=>{var t;const n=z();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await di.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=L,e.sliceByPaging=(e,t,n)=>{if(console.log("slice by paging",n),!n)return t.slice();let r,o=0;n.after?(o=n.after,r=o+n.limit):n.before&&(r=n.before+1,o=r>n.limit?r-n.limit:0);const i=t.slice(o,r);return i.length===n.limit?i:void 0},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=function(e,t){const{mqtt:n,emitter:r,accessToken:o,user:i}=z();return Zo===o&&ei===i._id||(Zo=o,ei=i._id,n.connect({accessToken:o,userId:i._id}),((e,t)=>{$o.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)},e.toPage=O,e.toPageRaw=T,e.toToken=R,e.updateChannel=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o}),Vo("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o}),Vo("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=Vi,e.updatePost=async(e,t)=>{const n=z();n.log("user/updatePost",t);const{data:r}=await n.http.put(`/api/v3/posts/${encodeURIComponent(e)}`,t),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o}),Vo("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=Ci,e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=z();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await di.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
21
|
+
function Oi(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}Ri.locally=e=>{var t;const n=z();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Ti=async(e={})=>{const t=z();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=Oi(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:R(n,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{users:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});wi(["user","query",e],{users:l.map(Ei("user")),paging:c})}return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:O(c.next)}};Ti.locally=(e={})=>{var t,n,r;const o=z();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=vi(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>vi(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],u=O(null==s?void 0:s.paging.previous),l=O(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:u,nextPage:l}:void 0};const Fi=(e,t)=>{const n=z();return Wo(n,e,e,(e=>{n.cache&&Ii(e),t(e.users[0])}))},Pi=e=>Fi("user.updated",e),Bi=e=>Fi("user.flagged",e),ji=e=>Fi("user.unflagged",e),Ui=e=>Fi("user.flagCleared",e),Mi=async e=>{const t=z();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&Ii({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};Mi.locally=e=>{const t=z();if(t.log("file/getFile.locally",e),!t.cache)return;const n=vi(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ni=async e=>{const t=z();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{roles:l}=u,h=t.cache&&Date.now();t.cache&&Ii(u,{cachedAt:h});const p=O(c.next);return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:p}};Ni.locally=e=>{z().log("role/queryRoles.locally",e)};const Li=async e=>{const t=z();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&Ii({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};Li.locally=e=>{const t=z();if(t.log("role/getRole.locally",e),!t.cache)return;const n=vi(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Di=(e,t)=>{"message"===e?Vo("v3.message.didUpdate",{messages:[t]}):"post"===e?Vo("post.updated",{posts:[t]}):"comment"===e&&Vo("comment.updated",{comments:[t]})},qi=async e=>{const t=z();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};qi.locally=e=>{const t=z();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=vi(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const $i=async e=>{const t=z();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&&Ii(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};$i.locally=e=>{var t;const n=z();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Hi=async e=>{const t=z();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=Oi(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:R(n,"afterbefore")}})}),{paging:i}=o,s=Oi(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{messages:a.map(Ei("message")),paging:i})}const u=O(i.next);return{data:a,cachedAt:c,prevPage:O(i.previous),nextPage:u}};Hi.locally=e=>{var t,n;const r=z();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Oi(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const u=a.messages.map((e=>vi(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),l=O(null==a?void 0:a.paging.previous),h=O(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const Wi=async e=>{const t=z();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};Wi.optimistically=e=>{var t,n;const r=z();if(r.log("user/createMessage.locally",e),!r.cache)return;const o=vi(["channel","get",e.channelId]);Ci(["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 wi(["message","get",i.messageId],i,{cachedAt:-1}),Vo("v3.message.didCreate",{messages:[i]}),{data:i,cachedAt:-1}};const Vi=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};Vi.optimistically=(e,t)=>{const n=z();if(n.log("user/updateMessage",t),!n.cache)return;const r=vi(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return Ci(["message","get",e],o,{cachedAt:-1}),Vo("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const zi=async e=>{const t=z();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await qi(e)).data};zi.optimistically=e=>{z().log("message/deleteMessage",e);const t=vi(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return Ci(["message","get",e],n,{cachedAt:-1}),Vo("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const Ki=async e=>{const t=z();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=Oi(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:R(n,"afterbeforeraw")}})}),{paging:i}=o,s=Oi(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{posts:a.map(Ei("post")),paging:i})}const u=T(i.next);return{data:a,cachedAt:c,prevPage:T(i.previous),nextPage:u}};Ki.locally=e=>{var t,n;const r=z();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Oi(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const u=a.posts.map((e=>vi(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),l=T(null==a?void 0:a.paging.previous),h=T(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const Ji=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.posts,cachedAt:o}};Ji.locally=e=>{var t;const n=z();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Qi=async e=>{var t;const n=z();let r;n.log("post/getPost",e);try{r=(await n.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Si(["post","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}};Qi.locally=e=>{const t=z();if(t.log("post/getPost.locally",e),!t.cache)return;const n=vi(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Yi=async e=>{const t=z();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{communities:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];wi(e,{communities:l.map(Ei("community")),paging:c})}const p=O(c.next);return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:p}};Yi.locally=e=>{z().log("community/queryCommunities.locally",e)};const Xi=async e=>{const t=z();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&&Ii(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};Xi.locally=e=>{var t;const n=z();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 Gi=async e=>{const t=z();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};Gi.locally=e=>{const t=z();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=vi(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Zi=async e=>{const t=z();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=Oi(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:R(r,"skiplimit")}})}),{paging:a}=s,c=Oi(s,["paging"]),{communityUsers:u}=c,l=t.cache&&Date.now();t.cache&&Ii(c,{cachedAt:l});return{data:u,nextPage:O(a.next),prevPage:O(a.previous)}};Zi.locally=e=>{z().log("community/queryCommunityMembers",e)};const es=async e=>{const t=z();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=Oi(e,["page"]),{data:o}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:{token:R(n,"afterbefore")}})}),{paging:i}=o,s=Oi(o,["paging"]),{comments:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{comments:a.map(Ei("comment")),paging:i})}const u=O(i.next);return{data:a,cachedAt:c,prevPage:O(i.previous),nextPage:u}};es.locally=e=>{var t,n;const r=z();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Oi(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const u=a.comments.map((e=>vi(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),l=O(null==a?void 0:a.paging.previous),h=O(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const ts=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.comments,cachedAt:o}};ts.locally=e=>{var t;const n=z();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 ns=async e=>{var t;const n=z();let r;n.log("comment/getComment",e);try{r=(await n.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Si(["comment","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}};ns.locally=e=>{const t=z();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=vi(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const rs=async(e,t)=>{if("message"===e)return qi(t);if("post"===e)return Qi(t);if("comment"===e)return ns(t);throw new Error(`Incorrect referenceType: ${e}`)},os=(e,t)=>{var n,r;if(z().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=vi(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=vi(["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))})}},is=async(e,t,n)=>{var r,o;const i=z();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 rs(e,t);return Di(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};is.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=z();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const u=vi([e,"get",t]);if(!(null==u?void 0:u.data)||(null===(r=u.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const l=Object.assign(Object.assign({},u.data),{reactionsCount:u.data.reactionsCount+1,myReactions:[...null!==(o=u.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},u.data.reactions),{[n]:(null!==(i=u.data.reactions[n])&&void 0!==i?i:0)+1})});return Ci([e,"get",t],l,{cachedAt:-1}),Di(e,l),null!==(a=null===(s=null==l?void 0:l.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const ss=async(e,t,n)=>{var r,o;const i=z();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 rs(e,t);return Di(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};ss.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=z();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const u=vi([e,"get",t]);if(!(null==u?void 0:u.data)||!(null===(r=u.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const l=Object.assign(Object.assign({},u.data),{reactionsCount:Math.max(0,u.data.reactionsCount-1),myReactions:(null!==(o=u.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},u.data.reactions),{[n]:Math.max(0,(null!==(i=u.data.reactions[n])&&void 0!==i?i:0)-1)})});return Ci([e,"get",t],l,{cachedAt:-1}),Di(e,l),null!==(a=!(null===(s=null==l?void 0:l.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};const as=(e,t)=>{const n=z();return Wo(n,e,e,(r=>{var o;if(n.cache){const{communities:n}=r,i=Oi(r,["communities"]);Ii(i),(null==n?void 0:n[0])&&!["post.updated"].includes(e)&&Vo("community.updated",{communities:n});const s=vi(["post","get",r.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=bi(["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})=>Ci(e,t,{cachedAt:-1})))}t(s.data)}else t(r.posts[0])}))},cs=e=>as("post.created",e),us=e=>as("post.updated",e),ls=e=>as("post.deleted",e),hs=e=>as("post.approved",e),ps=e=>as("post.declined",e),fs=e=>as("post.flagged",e),ds=e=>as("post.unflagged",e),ms=e=>{const t=z();return Wo(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){os("post.addReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},gs=e=>{const t=z();return Wo(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){os("post.removeReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},ys=(e,t)=>{const n=z();return Wo(n,e,e,(r=>{var o;if(n.cache){Ii(r);const n=vi(["comment","get",r.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=bi(["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})=>Ci(e,t,{cachedAt:-1})))}t(n.data)}else t(r.comments[0])}))},bs=e=>ys("comment.created",e),vs=e=>ys("comment.updated",e),ws=e=>ys("comment.deleted",e),_s=e=>ys("comment.flagged",e),Cs=e=>ys("comment.unflagged",e),Ss=e=>{const t=z();return Wo(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){os("comment.addReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},ks=e=>{const t=z();return Wo(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){os("comment.removeReaction",n);const t=Oi(n,["reactor"]);Ii(t);const r=vi(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))};var Es={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 As=async e=>{const t=z();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{channels:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];wi(e,{channels:l.map(Ei("channel")),paging:c})}const p=O(c.next);return{data:l,cachedAt:h,prevPage:O(c.previous),nextPage:p}};As.locally=e=>{z().log("channel/queryChannels.locally",e)};const Is=async e=>{const t=z();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&&Ii(r,{cachedAt:o}),{data:r.channels,cachedAt:o}};Is.locally=e=>{var t;const n=z();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>vi(["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 xs=async e=>{const t=z();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};xs.locally=e=>{const t=z();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=vi(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Rs=async e=>{const t=z();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o,membership:i}=n,s=Oi(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:R(r,"skiplimit")}})}),{paging:c}=a,u=Oi(a,["paging"]),{channelUsers:l}=u;t.cache&&Ii(u);return{data:l,nextPage:O(c.next),prevPage:O(c.previous)}};Rs.locally=e=>{z().log("channel/queryChannelMembers",e)};const Os=e=>{const t=z();return Wo(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{Ii(t),e(t.channels[0])}))},Ts=e=>{const t=z();return Wo(t,"onChannelDeleted","v3.channel.didDelete",(t=>{Ii(t),e(t.channels[0])}))},Fs=e=>{const t=z();return Wo(t,"onChannelJoined","v3.channel.didJoin",(t=>{Ii(t),e(t.channels[0])}))},Ps=e=>{const t=z();return Wo(t,"onChannelLeft","v3.channel.didLeave",(t=>{Ii(t),e(t.channels[0])}))},Bs=e=>{const t=z();return Wo(t,"onMemberAdded","v3.channel.didAddUsers",(t=>{Ii(t),e(t.channels[0])}))},js=e=>{const t=z();return Wo(t,"onMemberRemoved","v3.channel.didRemoveUsers",(t=>{Ii(t),e(t.channels[0])}))},Us=e=>{const t=z();return Wo(t,"message/onMessageCreated","v3.message.didCreate",(t=>{Ii(t),e(t.messages[0])}))},Ms=e=>{const t=z();return Wo(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{Ii(t),e(t.messages[0])}))},Ns=e=>{const t=z();return Wo(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{Ii(t),e(t.messages[0])}))},Ls=(e,t)=>{const n=z();return Wo(n,e,e,(e=>{if(n.cache){Ii(e);const n=vi(["community","get",e.communities[0].communityId]);t(n.data)}else t(e.communities[0])}))};function Ds(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function qs(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=>!Ds(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!Ds(e,t,"ADD_COMMUNITY_USER")))[0]}const $s=(e,t)=>{const n=z();return Wo(n,e,e,(r=>{if(n.cache){Ii(r);const n=vi(["community","get",r.communities[0].communityId]),o=vi(["communityUsers","get",Ei("communityUsers")(qs(e,r))]);t(n.data,o.data)}else t(r.communities[0],qs(e,r))}))},Hs=e=>Ls("community.updated",e),Ws=e=>Ls("community.deleted",e),Vs=e=>$s("community.joined",e),zs=e=>$s("community.left",e),Ks=e=>$s("community.userAdded",e),Js=e=>$s("community.userRemoved",e),Qs=e=>$s("community.userBanned",e),Ys=e=>$s("community.userUnbanned",e),Xs=async e=>{const t=z();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};Xs.locally=e=>{const t=z();if(t.log("stream/getStream",e),!t.cache)return;const n=vi(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Gs=async e=>{const t=z();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=Oi(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:R(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,u=t.cache&&Date.now();t.cache&&Ii(a,{cachedAt:u});const l=O(s.next);return{data:c,cachedAt:u,prevPage:O(s.previous),nextPage:l}};Gs.locally=e=>{z().log("stream/queryStreams.locally",e)};return e.VERSION=n,e.addChannelMembers=async(e,t)=>{const n=z();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&&Ii(r),Vo("v3.channel.didAddUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=z();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&&Ii(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=z();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&Ii(r),Vo("community.userAdded",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRole=async(e,t,n)=>{const r=z();r.log("community/addCommunityMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/communities/${e}/users/roles`,{communityId:e,role:t,userIds:n});r.cache&&Ii(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&n.roles.includes(t)))},e.addReaction=is,e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=z();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 di.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.connectClient=async e=>{var t,n;const r=z();r.log("client/api/connectClient",Object.assign({apiKey:r.apiKey},e)),null!==(t=e.displayName)&&void 0!==t||(e.displayName=e.userId),null!==(n=e.deviceId)&&void 0!==n||(e.deviceId=`ascWebSdk#${Math.random().toString(16)}`);const{accessToken:o,users:i}=await(async e=>{const t=z();t.log("client/api/getToken",e);const n=await Ko(),{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 s,a;r.http.defaults.headers.common.Authorization=`Bearer ${o}`,r.ws.io.opts.query={token:o},s=r.ws,a=r.emitter,qo.forEach((e=>{s.on(e,(t=>a.emit(e,t)))})),await new Promise((e=>{r.ws.once("connect",e),r.ws.open()}));const c=Yo((()=>{zo(),c()}));return r.userId=e.userId,r._internalUserId=i[0]._id,r.accessToken=o,r.ws.connected},e.createChannel=async e=>{const t=z();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&&Ii(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=ce,r="amity")=>{const o=(e=>{var t;const n=`${null==e?void 0:e.trim()}`.length>0&&"production"!==(null===(t=null===process||void 0===process?void 0:process.env)||void 0===t?void 0:t.NODE_ENV),r=ae(e),o=(e,...t)=>{n&&r(e,t)};return o.__instance__=r,o})(r);o("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiEndpoint:t});const i=(e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Rt.create({baseURL:e,httpAgent:new Pt(t),httpsAgent:new Tt(t),paramsSerializer:jt});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&&Bt(n.data)})),n})(le(ue.HTTP,t)),s=(e=>{const t=Uo(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(le(ue.HTTP,t)),a=Do(le(ue.MQTT,t)),c=Ho(),u={version:`${n}`,apiKey:e,log:o,http:i,ws:s,mqtt:a,emitter:c,use:()=>K(u)};try{z()}catch(e){K(u)}return u},e.createComment=async e=>{const t=z();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const o=await Qi(e.referenceId);Vo("post.updated",{posts:[o.data]}),Vo("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=z();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),Vo("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=z();if(n.log("file/createFile",e),!e.getAll("file").length)throw new Error("The formData object must have a `file` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v3/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Ii({files:o},{cachedAt:i}),{data:o[0],cachedAt:i}},e.createMessage=Wi,e.createPost=async e=>{const t=z();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&&Ii(n,{cachedAt:r}),Vo("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=M,e.createReport=async(e,t)=>{const n=z();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=Es[e],{data:o}=await n.http.post(`/api/v3/${r}/${encodeURIComponent(t)}/flag`);n.cache&&Ii(o);return Vo("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=z();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.deleteChannel=async e=>{const t=z();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await xs(e)).data},e.deleteComment=async(e,t=!1)=>{const n=z();n.log("comment/deleteComment",e);const r=await ns(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 Qi(r.data.referenceId);return Vo("post.updated",{posts:[i.data]}),Vo("comment.deleted",{comments:[o]}),t?setTimeout((()=>{Si(["comment","get",e],!0)}),0):Ci(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=z();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await Gi(e);return Vo("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=z();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),Si(["file","get",e],!0),{success:!0}},e.deleteMessage=zi,e.deletePost=async(e,t=!1)=>{const n=z();n.log("post/deletePost",e);let r=await Qi(e);if(await n.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await Gi(r.data.targetId);Vo("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return Vo("post.deleted",{posts:[o]}),t?setTimeout((()=>{Si(["post","get",e],!0)}),0):Ci(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=z();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=Es[e],{data:o}=await n.http.delete(`/api/v3/${r}/${encodeURIComponent(t)}/unflag`);n.cache&&Ii(o);return Vo("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=z();t.log("stream/deleteStream",e);let n=await Xs(e);const{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Ci(["stream","get",e],i),o},e.disableCache=()=>{const e=z();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=zo,e.disposeStream=async e=>{const t=z();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&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=Si,e.enableCache=(e={},t)=>{const n=z();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.getActiveClient=z,e.getChannel=xs,e.getChannels=Is,e.getComment=ns,e.getCommentTopic=({path:e})=>e,e.getComments=ts,e.getCommunities=Xi,e.getCommunity=Gi,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>Go({path:t},n),e.getFile=Mi,e.getMessage=qi,e.getMessages=$i,e.getPost=Qi,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=Ji,e.getRole=Li,e.getStream=Xs,e.getUser=xi,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>Go({path:t},n),e.getUsers=Ri,e.isAfterBefore=A,e.isAfterBeforeRaw=I,e.isCachable=j,e.isConnected=()=>{var e,t;const n=z();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=F,e.isFresh=U,e.isLocal=e=>j(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=P,e.isOffline=B,e.isPaged=x,e.isReportedByMe=async(e,t)=>{var n,r;const o=z();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=Es[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(Bt(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=E,e.joinChannel=async e=>{const t=z();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&Ii(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=z();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),Vo("community.joined",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=z();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&Ii(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=z();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),Vo("community.left",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=_i,e.observeChannel=(e,t)=>{const{log:n}=z(),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(Os((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),Ts((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),Fs((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),Ps((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),Bs((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),js((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),L(M(xs,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}=z(),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(vs((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),ws((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),_s((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Cs((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Ss((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),ks((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),L(M(ns,e),(e=>(e.data||e.error)&&i(e,"onFetch")),N(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=z(),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(bs((e=>i(e,"onCreate"))),vs((e=>i(e,"onUpdate"))),ws((e=>i(e,"onDelete"))),_s((e=>i(e,"onFlagged"))),Cs((e=>i(e,"onUnflagged"))),Ss((e=>i(e,"onReactionAdded"))),ks((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=z(),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(Hs((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ws((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),Vs((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),zs((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),Ks((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),Js((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),Qs((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),Ys((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),L(M(Gi,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}=z(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return L(M(Mi,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.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=z(),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(Ms((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ns((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&L(M(qi,e),(e=>e.data&&i(e,"onFetch")),N(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=z(),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(Us((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),Ms((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ns((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}=z(),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"))),hs((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),ps((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),fs((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),ds((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),ms((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),gs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),L(M(Qi,e),(e=>(e.data||e.error)&&i(e,"onFetch")),N(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=z(),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(cs((e=>i(e,"onCreate"))),us((e=>i(e,"onUpdate"))),ls((e=>i(e,"onDelete"))),hs((e=>i(e,"onApproved"))),ps((e=>i(e,"onDeclined"))),fs((e=>i(e,"onFlagged"))),ds((e=>i(e,"onUnflagged"))),ms((e=>i(e,"onReactionAdded"))),gs((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=z(),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(Pi((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),Bi((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),ji((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),Ui((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),L(M(xi,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=Ts,e.onChannelJoined=Fs,e.onChannelLeft=Ps,e.onChannelUpdated=Os,e.onClientBanned=Yo,e.onClientDisconnected=e=>Qo((({code:t})=>{800211===t&&e()})),e.onCommentCreated=bs,e.onCommentDeleted=ws,e.onCommentFlagged=_s,e.onCommentReactionAdded=Ss,e.onCommentReactionRemoved=ks,e.onCommentUnflagged=Cs,e.onCommentUpdated=vs,e.onCommunityCreated=e=>Ls("community.created",e),e.onCommunityDeleted=Ws,e.onCommunityJoined=Vs,e.onCommunityLeft=zs,e.onCommunityUpdated=Hs,e.onCommunityUserAdded=Ks,e.onCommunityUserBanned=Qs,e.onCommunityUserRemoved=Js,e.onCommunityUserUnbanned=Ys,e.onConnectionError=Qo,e.onMemberAdded=Bs,e.onMemberRemoved=js,e.onMessageCreated=Us,e.onMessageDeleted=Ns,e.onMessageUpdated=Ms,e.onPostApproved=hs,e.onPostCreated=cs,e.onPostDeclined=ps,e.onPostDeleted=ls,e.onPostFlagged=fs,e.onPostReactionAdded=ms,e.onPostReactionRemoved=gs,e.onPostUnflagged=ds,e.onPostUpdated=us,e.onReactionRemoved=(e,t,n)=>{const r=r=>{Ei(e)(r)===t&&n(r)};if("message"===e){const e=z(),t=e=>{var t;const n=vi(["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;Ii(e),o&&r(e.messages[0])};return Wo(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?gs(r):ks(r)},e.onStreamRecorded=e=>{const t=z();return Wo(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=z();return Wo(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=z();return Wo(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onUserFlagCleared=Ui,e.onUserFlagged=Bi,e.onUserUnflagged=ji,e.onUserUpdated=Pi,e.pullFromCache=vi,e.pushToCache=wi,e.queryCache=bi,e.queryChannelMembers=Rs,e.queryChannels=As,e.queryComments=es,e.queryCommunities=Yi,e.queryCommunityMembers=Zi,e.queryGlobalFeed=async e=>{const t=z();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{page:r}=n,o=Oi(n,["page"]),{data:i}=await t.http.get("/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},o),{options:{token:R(r,"skiplimit")}})}),{paging:s}=i,a=Oi(i,["paging"]),{posts:c}=a;t.cache&&Ii(a);const u=O(s.next);return{data:c,prevPage:O(s.previous),nextPage:u}},e.queryMessages=Hi,e.queryOptions=N,e.queryPosts=Ki,e.queryRoles=Ni,e.queryStreams=Gs,e.queryUsers=Ti,e.removeChannelMembers=async(e,t)=>{const n=z();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&&Ii(r),Vo("v3.channel.didRemoveUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=z();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&&Ii(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=z();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&&Ii(r),Vo("community.userRemoved",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRole=async(e,t,n)=>{const r=z();r.log("community/removeCommunityMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/communities/${e}/users/roles`,{data:{communityId:e,role:t,userIds:n}});r.cache&&Ii(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!n.roles.includes(t)))},e.removeReaction=ss,e.restoreCache=async(e="amitySdk")=>{var t;const n=z();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await di.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=L,e.sliceByPaging=(e,t,n)=>{if(console.log("slice by paging",n),!n)return t.slice();let r,o=0;n.after?(o=n.after,r=o+n.limit):n.before&&(r=n.before+1,o=r>n.limit?r-n.limit:0);const i=t.slice(o,r);return i.length===n.limit?i:void 0},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=function(e,t){const{mqtt:n,emitter:r,accessToken:o,_internalUserId:i}=z();return Zo===o&&ei===i||(Zo=o,ei=i,n.connect({accessToken:Zo,userId:ei}),((e,t)=>{$o.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)},e.toPage=O,e.toPageRaw=T,e.toToken=R,e.updateChannel=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o}),Vo("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o}),Vo("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=Vi,e.updatePost=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o}),Vo("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=z();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&&Ii(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=Ci,e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=z();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await di.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|