@amityco/ts-sdk 0.0.1-e32b438.0 → 0.0.1-e556efe.0

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.
Files changed (130) hide show
  1. package/.eslintrc.json +4 -1
  2. package/dist/@types/core/events.d.ts +7 -7
  3. package/dist/@types/core/events.d.ts.map +1 -1
  4. package/dist/@types/core/live.d.ts +23 -0
  5. package/dist/@types/core/live.d.ts.map +1 -0
  6. package/dist/@types/core/paging.d.ts +1 -1
  7. package/dist/@types/core/paging.d.ts.map +1 -1
  8. package/dist/@types/core/payload.d.ts +3 -5
  9. package/dist/@types/core/payload.d.ts.map +1 -1
  10. package/dist/@types/domains/comment.d.ts +14 -0
  11. package/dist/@types/domains/comment.d.ts.map +1 -1
  12. package/dist/@types/domains/follow.d.ts +2 -1
  13. package/dist/@types/domains/follow.d.ts.map +1 -1
  14. package/dist/@types/domains/post.d.ts +17 -0
  15. package/dist/@types/domains/post.d.ts.map +1 -1
  16. package/dist/@types/domains/reaction.d.ts +10 -0
  17. package/dist/@types/domains/reaction.d.ts.map +1 -1
  18. package/dist/@types/index.d.ts +1 -0
  19. package/dist/@types/index.d.ts.map +1 -1
  20. package/dist/channel/api/banChannelMembers.d.ts +16 -0
  21. package/dist/channel/api/banChannelMembers.d.ts.map +1 -0
  22. package/dist/channel/api/index.d.ts +2 -0
  23. package/dist/channel/api/index.d.ts.map +1 -1
  24. package/dist/channel/api/unbanChannelMembers.d.ts +16 -0
  25. package/dist/channel/api/unbanChannelMembers.d.ts.map +1 -0
  26. package/dist/comment/api/queryComments.d.ts +1 -9
  27. package/dist/comment/api/queryComments.d.ts.map +1 -1
  28. package/dist/comment/observers/index.d.ts +1 -0
  29. package/dist/comment/observers/index.d.ts.map +1 -1
  30. package/dist/comment/observers/liveComments.d.ts +22 -0
  31. package/dist/comment/observers/liveComments.d.ts.map +1 -0
  32. package/dist/comment/observers/observeComments.d.ts.map +1 -1
  33. package/dist/core/query/query.d.ts.map +1 -1
  34. package/dist/core/tests/query/filtering.test.d.ts +2 -0
  35. package/dist/core/tests/query/filtering.test.d.ts.map +1 -0
  36. package/dist/core/tests/query/query.test.d.ts +2 -0
  37. package/dist/core/tests/query/query.test.d.ts.map +1 -0
  38. package/dist/follow/api/follow.d.ts.map +1 -1
  39. package/dist/follow/api/getFollowInfo.d.ts.map +1 -1
  40. package/dist/follow/api/queryFollowers.d.ts +4 -4
  41. package/dist/follow/api/queryFollowers.d.ts.map +1 -1
  42. package/dist/follow/api/queryFollowings.d.ts +4 -4
  43. package/dist/follow/api/queryFollowings.d.ts.map +1 -1
  44. package/dist/follow/api/utils.d.ts +4 -4
  45. package/dist/follow/api/utils.d.ts.map +1 -1
  46. package/dist/follow/events/utils.d.ts.map +1 -1
  47. package/dist/index.cjs.js +561 -23
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.esm.js +554 -24
  51. package/dist/index.umd.js +4 -4
  52. package/dist/post/api/queryPosts.d.ts +1 -12
  53. package/dist/post/api/queryPosts.d.ts.map +1 -1
  54. package/dist/post/observers/index.d.ts +1 -0
  55. package/dist/post/observers/index.d.ts.map +1 -1
  56. package/dist/post/observers/livePosts.d.ts +22 -0
  57. package/dist/post/observers/livePosts.d.ts.map +1 -0
  58. package/dist/post/observers/observePosts.d.ts.map +1 -1
  59. package/dist/post/tests/api/getPost.test.d.ts +2 -0
  60. package/dist/post/tests/api/getPost.test.d.ts.map +1 -0
  61. package/dist/post/tests/api/queryPosts.test.d.ts +2 -0
  62. package/dist/post/tests/api/queryPosts.test.d.ts.map +1 -0
  63. package/dist/reaction/api/queryReactions.d.ts +1 -6
  64. package/dist/reaction/api/queryReactions.d.ts.map +1 -1
  65. package/dist/reaction/events/index.d.ts +3 -0
  66. package/dist/reaction/events/index.d.ts.map +1 -1
  67. package/dist/reaction/events/onReactorAdded.d.ts +19 -0
  68. package/dist/reaction/events/onReactorAdded.d.ts.map +1 -0
  69. package/dist/reaction/events/onReactorRemoved.d.ts +19 -0
  70. package/dist/reaction/events/onReactorRemoved.d.ts.map +1 -0
  71. package/dist/reaction/observers/index.d.ts +2 -0
  72. package/dist/reaction/observers/index.d.ts.map +1 -0
  73. package/dist/reaction/observers/liveReactions.d.ts +22 -0
  74. package/dist/reaction/observers/liveReactions.d.ts.map +1 -0
  75. package/dist/utils/constants.d.ts +3 -0
  76. package/dist/utils/constants.d.ts.map +1 -0
  77. package/dist/utils/tests/client.d.ts +3 -0
  78. package/dist/utils/tests/client.d.ts.map +1 -0
  79. package/dist/utils/tests/dummy.d.ts +8 -0
  80. package/dist/utils/tests/dummy.d.ts.map +1 -0
  81. package/dist/utils/tests/index.d.ts +3 -0
  82. package/dist/utils/tests/index.d.ts.map +1 -0
  83. package/jest.config.ts +15 -0
  84. package/package.json +10 -3
  85. package/src/@types/core/events.ts +7 -7
  86. package/src/@types/core/live.ts +28 -0
  87. package/src/@types/core/paging.ts +1 -1
  88. package/src/@types/core/payload.ts +5 -6
  89. package/src/@types/domains/comment.ts +31 -0
  90. package/src/@types/domains/follow.ts +3 -1
  91. package/src/@types/domains/post.ts +37 -0
  92. package/src/@types/domains/reaction.ts +17 -0
  93. package/src/@types/index.ts +1 -0
  94. package/src/channel/api/banChannelMembers.ts +41 -0
  95. package/src/channel/api/index.ts +3 -0
  96. package/src/channel/api/unbanChannelMembers.ts +41 -0
  97. package/src/comment/api/queryComments.ts +3 -9
  98. package/src/comment/observers/index.ts +1 -0
  99. package/src/comment/observers/liveComments.ts +172 -0
  100. package/src/comment/observers/observeComments.ts +1 -11
  101. package/src/core/query/query.ts +15 -2
  102. package/src/core/tests/query/filtering.test.ts +11 -0
  103. package/src/core/tests/query/query.test.ts +19 -0
  104. package/src/follow/api/acceptFollower.ts +1 -1
  105. package/src/follow/api/declineFollower.ts +1 -1
  106. package/src/follow/api/follow.ts +1 -4
  107. package/src/follow/api/getFollowInfo.ts +8 -5
  108. package/src/follow/api/queryFollowers.ts +5 -4
  109. package/src/follow/api/queryFollowings.ts +5 -4
  110. package/src/follow/api/unfollow.ts +1 -1
  111. package/src/follow/api/utils.ts +10 -10
  112. package/src/follow/events/utils.ts +9 -6
  113. package/src/index.ts +1 -0
  114. package/src/post/api/queryPosts.ts +3 -12
  115. package/src/post/observers/index.ts +1 -0
  116. package/src/post/observers/livePosts.ts +170 -0
  117. package/src/post/observers/observePosts.ts +1 -13
  118. package/src/post/tests/api/getPost.test.ts +88 -0
  119. package/src/post/tests/api/queryPosts.test.ts +23 -0
  120. package/src/reaction/api/queryReactions.ts +14 -14
  121. package/src/reaction/events/index.ts +4 -0
  122. package/src/reaction/events/onReactorAdded.ts +80 -0
  123. package/src/reaction/events/onReactorRemoved.ts +85 -0
  124. package/src/reaction/observers/index.ts +1 -0
  125. package/src/reaction/observers/liveReactions.ts +142 -0
  126. package/src/utils/constants.ts +2 -0
  127. package/src/utils/tests/client.ts +5 -0
  128. package/src/utils/tests/dummy.ts +7 -0
  129. package/src/utils/tests/index.ts +2 -0
  130. package/tsconfig.json +23 -22
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
- var Amity=function(e){"use strict";var t;const n="object"==typeof globalThis?globalThis:"object"==typeof global?global:window,{process:r={}}=n,o="production"===(null===(t=r.env)||void 0===t?void 0:t.NODE_ENV);var i,s;const a=null!==(s=null===(i=r.env)||void 0===i?void 0:i.VERSION)&&void 0!==s?s:"__dev__",c="function"==typeof atob,l="function"==typeof btoa,u="function"==typeof Buffer,h="function"==typeof TextDecoder?new TextDecoder:void 0,f="function"==typeof TextEncoder?new TextEncoder:void 0,d=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),p=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(d),m=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,g=String.fromCharCode.bind(String),y="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),v=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),b=l?e=>btoa(e):u?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,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+=d[t>>18&63]+d[t>>12&63]+d[t>>6&63]+d[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},w=u?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(g.apply(null,e.subarray(n,n+4096)));return b(t.join(""))},C=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?g(192|t>>>6)+g(128|63&t):g(224|t>>>12&15)+g(128|t>>>6&63)+g(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return g(240|t>>>18&7)+g(128|t>>>12&63)+g(128|t>>>6&63)+g(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,k=u?e=>Buffer.from(e,"utf8").toString("base64"):f?e=>w(f.encode(e)):e=>b(e.replace(_,C)),S=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,E=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return g(55296+(t>>>10))+g(56320+(1023&t));case 3:return g((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return g((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},A=c?e=>atob(v(e)):u?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!m.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,o="";for(let i=0;i<e.length;)t=p[e.charAt(i++)]<<18|p[e.charAt(i++)]<<12|(n=p[e.charAt(i++)])<<6|(r=p[e.charAt(i++)]),o+=64===n?g(t>>16&255):64===r?g(t>>16&255,t>>8&255):g(t>>16&255,t>>8&255,255&t);return o},T=u?e=>y(Buffer.from(e,"base64")):e=>y(A(e),(e=>e.charCodeAt(0))),x=u?e=>Buffer.from(e,"base64").toString("utf8"):h?e=>h.decode(T(e)):e=>A(e).replace(S,E),I=e=>x(v(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),O=e=>["skip","limit"].some((t=>t in e)),R=e=>["after","before","first","last","limit"].some((t=>t in e)),P=e=>"limit"in e,B=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),N=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t&&R(e)?Number.isNaN(Number(null==e?void 0:e.before))?Number.isNaN(Number(null==e?void 0:e.after))?Number.isNaN(Number(null==e?void 0:e.limit))||(r={last:e.limit}):r={after:e.after,first:e.limit}:r={before:e.before,last:e.limit}:"afterbeforeraw"===t&&(r=e),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(k(e)):k(e))(JSON.stringify(r)):void 0},F=e=>{if(!e)return;const t=JSON.parse(I(e));if(O(t))return{after:t.skip,limit:t.limit};if(R(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}},j=e=>{if(!e)return;const t=JSON.parse(I(e));return P(t)?t:void 0},M={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,category:({categoryId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,poll:({pollId:e})=>e,reaction:({reactionId:e})=>e,stream:({streamId:e})=>e,follow:({from:e,to:t})=>`${e}#${t}`,followCount:({userId:e})=>e},U=e=>M[e],L={file:["fileId","attributes"],user:["userId","avatarFileId"],role:["roleId"],channel:["channelId","rateLimit"],channelUsers:["channelId","userId","membership"],message:["messageId"],community:["communityId","onlyAdminCanPost"],category:["categoryId"],communityUsers:["userId","communityId","communityMembership"],post:["postId","feedId"],comment:["commentId","referenceId"],poll:["pollId"],reaction:["reactionId"],stream:["streamId"],follow:["from","to"],followCount:["userId","followerCount"]},D=e=>{var t;return null===(t=Object.entries(L).find((([t,n])=>((e,t)=>{const n=Object.keys(e);return t.every((e=>n.includes(e)))})(e,n))))||void 0===t?void 0:t[0]},q={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",categories:"category",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",polls:"poll",reactions:"reaction",videoStreamings:"stream",follows:"follow",followCounts:"followCount"},z=e=>"locally"in e,$=e=>"optimistically"in e,H=e=>z(e)||$(e),V=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),W=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},K=(e,...t)=>({func:e,args:t}),Q=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},J=({func:e,args:t},n,r=Q("cache_then_server"))=>{let o;if(H(e)&&0!==r.lifeSpan){try{o=$(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(X(void 0,{origin:"local",loading:!1,error:e}))}const i=V(o)&&W(o,r.lifeSpan);if(null==n||n(X(o,{origin:"local",loading:!(z(e)&&i)})),i)return}else null==n||n(X(void 0,{origin:"local",loading:!0}));let i=t;if($(e)){const e=o&&o.data&&(e=>{var t;const n=D(e);if(n)return null===(t=L[n])||void 0===t?void 0:t[0]})(o.data);i=e?[...t,{[e]:o.data[e]}]:t}e(...i).then((e=>{null==n||n(X(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(X(void 0,{origin:"server",loading:!1,error:e}))}))};function X(e,t){return B(e)||V(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class Y extends Error{constructor(e,t,n){super(`Amity SDK (${t}): ${e}`),this.code=t,this.level=n,this.type="ASC",this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,Y)}}class G extends Y{constructor(e,t,n){super(e,t,n)}}class Z extends Y{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class ee extends Y{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let te=null;const ne=()=>{if(!te)throw new Y("There is no active client",8e5,"fatal");return te},re=e=>{te=e};let oe,ie=[];const se=["disconnected","error","connect_error","reconnect_error","reconnect_failed","v3.channel.didUpdate","v3.channel.didUpdate","v3.channel.didJoin","v3.channel.didLeave","v3.channel.didAddUsers","v3.channel.didRemoveUsers","v3.channel.didBan","v3.channel.didUnban","v3.message.didCreate","v3.message.didUpdate","v3.message.didDelete"],ae=["connect","message","disconnect","error","close","end","reconnect"],ce=()=>{return{all:e=e||new Map,on:function(t,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},le=(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)}},ue=(e,t)=>{const{emitter:n}=ne();var r;r=()=>{n.emit(e,t)},clearTimeout(oe),ie.push(r),oe=setTimeout((()=>{ie.forEach((e=>e())),ie=[]}),0)};let he=null;const fe=()=>{if(!he)throw new Y("Connect client first",8e5,"fatal");return he};var de;e.SubscriptionLevels=void 0,(de=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",de.POST="post",de.COMMENT="comment",de.POST_AND_COMMENT="post_and_comment",de.USER="user";const pe=(e,t)=>{switch(t){case"post":return`${e}/post/+`;case"comment":return`${e}/post/+/comment/+`;case"post_and_comment":return`${e}/post/#`;default:return e}},me=()=>{const e=fe(),[t]=e.path.split("/user/");return t};let ge,ye;function ve(e,t){const{mqtt:n,emitter:r,accessToken:o}=ne(),i=fe();return ge===o&&ye===i._id||(ge=o,ye=i._id,n.connect({accessToken:ge,userId:ye}),((e,t)=>{ae.forEach((n=>{e.on(n,((...e)=>t.emit(n,1===e.length?e[0]:e)))})),e.on("message",((e,n)=>{const r=JSON.parse(n.toString());t.emit(r.eventType,r.data)}))})(n,r)),n.subscribe(e,t)}var be="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ce(e){var t=e.default;if("function"==typeof t){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}const _e=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:ke}=Object.prototype,{propertyIsEnumerable:Se}=Object,Ee=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),Ae=be,Te={concatArrays:!1,ignoreUndefined:!1},xe=e=>{const t=[];for(const n in e)ke.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)Se.call(e,r)&&t.push(r)}return t};function Ie(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return xe(e).forEach((n=>{Ee(t,n,Ie(e[n]))})),t}(e):_e(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return xe(e).forEach((n=>{Ee(t,n,Ie(e[n]))})),t}(e):e}const Oe=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?Ee(e,n,Re(e[n],t[n],r)):Ee(e,n,Ie(t[n])))})),e);function Re(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++)ke.call(t,n)&&(i.push(String(n)),Ee(r,o++,t===e?t[n]:Ie(t[n])));r=Oe(r,t,xe(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):_e(t)&&_e(e)?Oe(e,t,xe(t),n):Ie(t)}const Pe=function(...e){const t=Re(Ie(Te),this!==Ae&&this||{},Te);let n={_:{}};for(const r of e)if(void 0!==r){if(!_e(r))throw new TypeError("`"+r+"` is not an Option Object");n=Re(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0});function Be(e,t){return new Promise(((n,r)=>{try{const r=e();null==t||t(null,r),n(r)}catch(e){null==t||t(e),r(e)}}))}function Ne(e,t,n){return Promise.all(e).then((e=>{var r;const o=null!==(r=null==n?void 0:n(e))&&void 0!==r?r:null;return null==t||t(null,o),Promise.resolve(o)}),(e=>(null==t||t(e),Promise.reject(e))))}const Fe={getItem:(e,t)=>Be((()=>window.localStorage.getItem(e)),t),setItem:(e,t,n)=>Be((()=>window.localStorage.setItem(e,t)),n),removeItem:(e,t)=>Be((()=>window.localStorage.removeItem(e)),t),mergeItem:(e,t,n)=>Be((()=>function(e,t){const n=window.localStorage.getItem(e);if(n){const r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(Pe(r,o));window.localStorage.setItem(e,i)}else window.localStorage.setItem(e,t)}(e,t)),n),clear:e=>Be((()=>window.localStorage.clear()),e),getAllKeys:e=>Be((()=>{const e=window.localStorage.length,t=[];for(let n=0;n<e;n+=1){const e=window.localStorage.key(n)||"";t.push(e)}return t}),e),flushGetRequests:()=>{},multiGet:(e,t)=>Ne(e.map((e=>Fe.getItem(e))),t,(t=>t.map(((t,n)=>[e[n],t])))),multiSet:(e,t)=>Ne(e.map((e=>Fe.setItem(e[0],e[1]))),t),multiRemove:(e,t)=>Ne(e.map((e=>Fe.removeItem(e))),t),multiMerge:(e,t)=>Ne(e.map((e=>{var t,n;return null!==(t=null===(n=Fe.mergeItem)||void 0===n?void 0:n.call(Fe,e[0],e[1]))&&void 0!==t?t:Promise.reject("Not implemented")})),t)},je=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})),Me=e=>JSON.parse(e),Ue=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>Ue(e[n],t[n])))),Le=e=>{const{log:t,cache:n}=ne();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=Me(t);return Ue(e,n)})).map((e=>n.data[e]))},De=e=>{const{log:t,cache:n}=ne();if(!n)return;t("cache/api/pullFromCache",e);const r=je(e);return n.data[r]?n.data[r]:void 0},qe=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=ne();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=je(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},ze=(e,t,n)=>{const{log:r,cache:o}=ne();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=De(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return qe(e,s,n),!0},$e=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=ne();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return De(e)?ze(e,t,n):qe(e,t,n)},He=(e,t=!1)=>{const{log:n,cache:r}=ne();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>Me(e))).filter((t=>Ue(e,t))).map((e=>He(e,!0))).every((e=>e));const o=je(e);return o in r.data&&(delete r.data[o],!0)};var Ve,We,Ke={exports:{}};function Qe(){if(We)return Ve;We=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function s(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return Ve=function(a,c){c=c||{};var l=typeof a;if("string"===l&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===l&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=r)return s(o,i,r,"day");if(i>=n)return s(o,i,n,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))},Ve}var Je=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Qe(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Je(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ke,Ke.exports);var Xe=Ke.exports;const Ye={EU:"eu",SG:"sg",US:"us"},Ge={http:"https://api.{region}.amity.co",mqtt:"wss://sse.{region}.amity.co:443/mqtt"};function Ze(e,t){return Ge[e].replace("{region}",t)}var et={exports:{}},tt={exports:{}},nt=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)}},rt=nt,ot=Object.prototype.toString;function it(e){return"[object Array]"===ot.call(e)}function st(e){return void 0===e}function at(e){return null!==e&&"object"==typeof e}function ct(e){if("[object Object]"!==ot.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function lt(e){return"[object Function]"===ot.call(e)}function ut(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),it(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 ht={isArray:it,isArrayBuffer:function(e){return"[object ArrayBuffer]"===ot.call(e)},isBuffer:function(e){return null!==e&&!st(e)&&null!==e.constructor&&!st(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:at,isPlainObject:ct,isUndefined:st,isDate:function(e){return"[object Date]"===ot.call(e)},isFile:function(e){return"[object File]"===ot.call(e)},isBlob:function(e){return"[object Blob]"===ot.call(e)},isFunction:lt,isStream:function(e){return at(e)&&lt(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:ut,merge:function e(){var t={};function n(n,r){ct(t[r])&&ct(n)?t[r]=e(t[r],n):ct(n)?t[r]=e({},n):it(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)ut(arguments[r],n);return t},extend:function(e,t,n){return ut(t,(function(t,r){e[r]=n&&"function"==typeof t?rt(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}},ft=ht;function dt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var pt=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(ft.isURLSearchParams(t))r=t.toString();else{var o=[];ft.forEach(t,(function(e,t){null!=e&&(ft.isArray(e)?t+="[]":e=[e],ft.forEach(e,(function(e){ft.isDate(e)?e=e.toISOString():ft.isObject(e)&&(e=JSON.stringify(e)),o.push(dt(t)+"="+dt(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},mt=ht;function gt(){this.handlers=[]}gt.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},gt.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},gt.prototype.forEach=function(e){mt.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var yt,vt,bt=gt,wt=ht;function Ct(){return vt?yt:(vt=1,yt=function(e){return!(!e||!e.__CANCEL__)})}var _t,kt,St,Et,At,Tt,xt,It,Ot,Rt,Pt,Bt,Nt,Ft,jt,Mt,Ut,Lt,Dt,qt,zt=ht;function $t(){return kt?_t:(kt=1,_t=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})}function Ht(){if(Et)return St;Et=1;var e=$t();return St=function(t,n,r,o,i){var s=new Error(t);return e(s,n,r,o,i)}}function Vt(){if(Tt)return At;Tt=1;var e=Ht();return At=function(t,n,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?n(e("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}}function Wt(){if(It)return xt;It=1;var e=ht;return xt=e.isStandardBrowserEnv()?{write:function(t,n,r,o,i,s){var a=[];a.push(t+"="+encodeURIComponent(n)),e.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),e.isString(o)&&a.push("path="+o),e.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.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(){}}}function Kt(){return Rt||(Rt=1,Ot=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}),Ot}function Qt(){return Bt?Pt:(Bt=1,Pt=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e})}function Jt(){if(Ft)return Nt;Ft=1;var e=Kt(),t=Qt();return Nt=function(n,r){return n&&!e(r)?t(n,r):r}}function Xt(){if(Mt)return jt;Mt=1;var e=ht,t=["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"];return jt=function(n){var r,o,i,s={};return n?(e.forEach(n.split("\n"),(function(n){if(i=n.indexOf(":"),r=e.trim(n.substr(0,i)).toLowerCase(),o=e.trim(n.substr(i+1)),r){if(s[r]&&t.indexOf(r)>=0)return;s[r]="set-cookie"===r?(s[r]?s[r]:[]).concat([o]):s[r]?s[r]+", "+o:o}})),s):s},jt}function Yt(){if(Lt)return Ut;Lt=1;var e=ht;return Ut=e.isStandardBrowserEnv()?function(){var t,n=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var t=e;return n&&(r.setAttribute("href",t),t=r.href),r.setAttribute("href",t),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=o(window.location.href),function(n){var r=e.isString(n)?o(n):n;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},Ut}function Gt(){if(qt)return Dt;qt=1;var e=ht,t=Vt(),n=Wt(),r=pt,o=Jt(),i=Xt(),s=Yt(),a=Ht();return Dt=function(c){return new Promise((function(l,u){var h=c.data,f=c.headers;e.isFormData(h)&&delete f["Content-Type"];var d=new XMLHttpRequest;if(c.auth){var p=c.auth.username||"",m=c.auth.password?unescape(encodeURIComponent(c.auth.password)):"";f.Authorization="Basic "+btoa(p+":"+m)}var g=o(c.baseURL,c.url);if(d.open(c.method.toUpperCase(),r(g,c.params,c.paramsSerializer),!0),d.timeout=c.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var e="getAllResponseHeaders"in d?i(d.getAllResponseHeaders()):null,n={data:c.responseType&&"text"!==c.responseType?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:e,config:c,request:d};t(l,u,n),d=null}},d.onabort=function(){d&&(u(a("Request aborted",c,"ECONNABORTED",d)),d=null)},d.onerror=function(){u(a("Network Error",c,null,d)),d=null},d.ontimeout=function(){var e="timeout of "+c.timeout+"ms exceeded";c.timeoutErrorMessage&&(e=c.timeoutErrorMessage),u(a(e,c,"ECONNABORTED",d)),d=null},e.isStandardBrowserEnv()){var y=(c.withCredentials||s(g))&&c.xsrfCookieName?n.read(c.xsrfCookieName):void 0;y&&(f[c.xsrfHeaderName]=y)}if("setRequestHeader"in d&&e.forEach(f,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete f[t]:d.setRequestHeader(t,e)})),e.isUndefined(c.withCredentials)||(d.withCredentials=!!c.withCredentials),c.responseType)try{d.responseType=c.responseType}catch(e){if("json"!==c.responseType)throw e}"function"==typeof c.onDownloadProgress&&d.addEventListener("progress",c.onDownloadProgress),"function"==typeof c.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",c.onUploadProgress),c.cancelToken&&c.cancelToken.promise.then((function(e){d&&(d.abort(),u(e),d=null)})),h||(h=null),d.send(h)}))}}var Zt=ht,en=function(e,t){zt.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},tn={"Content-Type":"application/x-www-form-urlencoded"};function nn(e,t){!Zt.isUndefined(e)&&Zt.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var rn,on={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(rn=Gt()),rn),transformRequest:[function(e,t){return en(t,"Accept"),en(t,"Content-Type"),Zt.isFormData(e)||Zt.isArrayBuffer(e)||Zt.isBuffer(e)||Zt.isStream(e)||Zt.isFile(e)||Zt.isBlob(e)?e:Zt.isArrayBufferView(e)?e.buffer:Zt.isURLSearchParams(e)?(nn(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Zt.isObject(e)?(nn(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}};on.headers={common:{Accept:"application/json, text/plain, */*"}},Zt.forEach(["delete","get","head"],(function(e){on.headers[e]={}})),Zt.forEach(["post","put","patch"],(function(e){on.headers[e]=Zt.merge(tn)}));var sn=on,an=ht,cn=function(e,t,n){return wt.forEach(n,(function(n){e=n(e,t)})),e},ln=Ct(),un=sn;function hn(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var fn,dn,pn,mn,gn,yn,vn,bn,wn=ht,Cn=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 wn.isPlainObject(e)&&wn.isPlainObject(t)?wn.merge(e,t):wn.isPlainObject(t)?wn.merge({},t):wn.isArray(t)?t.slice():t}function c(r){wn.isUndefined(t[r])?wn.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}wn.forEach(r,(function(e){wn.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),wn.forEach(o,c),wn.forEach(i,(function(r){wn.isUndefined(t[r])?wn.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),wn.forEach(s,(function(r){r in t?n[r]=a(e[r],t[r]):r in e&&(n[r]=a(void 0,e[r]))}));var l=r.concat(o).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return wn.forEach(u,c),n},_n=ht,kn=pt,Sn=bt,En=function(e){return hn(e),e.headers=e.headers||{},e.data=cn(e.data,e.headers,e.transformRequest),e.headers=an.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),an.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||un.adapter)(e).then((function(t){return hn(e),t.data=cn(t.data,t.headers,e.transformResponse),t}),(function(t){return ln(t)||(hn(e),t&&t.response&&(t.response.data=cn(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},An=Cn;function Tn(e){this.defaults=e,this.interceptors={request:new Sn,response:new Sn}}function xn(){if(dn)return fn;function e(e){this.message=e}return dn=1,e.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},e.prototype.__CANCEL__=!0,fn=e}Tn.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=An(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[En,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},Tn.prototype.getUri=function(e){return e=An(this.defaults,e),kn(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},_n.forEach(["delete","get","head","options"],(function(e){Tn.prototype[e]=function(t,n){return this.request(An(n||{},{method:e,url:t,data:(n||{}).data}))}})),_n.forEach(["post","put","patch"],(function(e){Tn.prototype[e]=function(t,n,r){return this.request(An(r||{},{method:e,url:t,data:n}))}}));var In=ht,On=nt,Rn=Tn,Pn=Cn;function Bn(e){var t=new Rn(e),n=On(Rn.prototype.request,t);return In.extend(n,Rn.prototype,t),In.extend(n,t),n}var Nn=Bn(sn);Nn.Axios=Rn,Nn.create=function(e){return Bn(Pn(Nn.defaults,e))},Nn.Cancel=xn(),Nn.CancelToken=function(){if(mn)return pn;mn=1;var e=xn();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(e){n=e}));var r=this;t((function(t){r.reason||(r.reason=new e(t),n(r.reason))}))}return 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}},pn=t}(),Nn.isCancel=Ct(),Nn.all=function(e){return Promise.all(e)},Nn.spread=yn?gn:(yn=1,gn=function(e){return function(t){return e.apply(null,t)}}),Nn.isAxiosError=bn?vn:(bn=1,vn=function(e){return"object"==typeof e&&!0===e.isAxiosError}),tt.exports=Nn,tt.exports.default=Nn,et.exports=tt.exports;var Fn=we(et.exports),jn={exports:{}};jn.exports=Un;var Mn=jn.exports.HttpsAgent=Un;function Un(){}const Ln=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new Z(e.code);if("error"===e.status)throw new G(e.message,e.code,"error")},Dn=(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}`:Dn(n,null!=t?t:e)})).join("&"),qn=e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Fn.create({baseURL:e,httpAgent:new jn.exports(t),httpsAgent:new Mn(t),paramsSerializer:Dn});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&&Ln(n.data)})),n};var zn={exports:{}},$n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Hn=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Vn=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,i,s=$n.exec(e||""),a={},c=14;c--;)a[Hn[c]]=s[c]||"";return-1!=n&&-1!=r&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(e,t){var n=/\/{2,9}/g,r=t.replace(n,"/").split("/");"/"!=t.substr(0,1)&&0!==t.length||r.splice(0,1);"/"==t.substr(t.length-1,1)&&r.splice(r.length-1,1);return r}(0,a.path),a.queryKey=(o=a.query,i={},o.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(i[t]=n)})),i),a};var Wn={exports:{}},Kn={exports:{}},Qn=1e3,Jn=6e4,Xn=60*Jn,Yn=24*Xn,Gn=365.25*Yn,Zn=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*Gn;case"days":case"day":case"d":return n*Yn;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Xn;case"minutes":case"minute":case"mins":case"min":case"m":return n*Jn;case"seconds":case"second":case"secs":case"sec":case"s":return n*Qn;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 er(e,Yn,"day")||er(e,Xn,"hour")||er(e,Jn,"minute")||er(e,Qn,"second")||e+" ms"}(e):function(e){if(e>=Yn)return Math.round(e/Yn)+"d";if(e>=Xn)return Math.round(e/Xn)+"h";if(e>=Jn)return Math.round(e/Jn)+"m";if(e>=Qn)return Math.round(e/Qn)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function er(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Zn,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Kn,Kn.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=Kn.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())}(Wn,Wn.exports);var tr=Vn,nr=Wn.exports("socket.io-client:url"),rr=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)||(nr("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),nr("parse %s",e),n=tr(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 or={},ir={exports:{}},sr={exports:{}},ar=1e3,cr=6e4,lr=60*cr,ur=24*lr,hr=365.25*ur,fr=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*hr;case"days":case"day":case"d":return n*ur;case"hours":case"hour":case"hrs":case"hr":case"h":return n*lr;case"minutes":case"minute":case"mins":case"min":case"m":return n*cr;case"seconds":case"second":case"secs":case"sec":case"s":return n*ar;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 dr(e,ur,"day")||dr(e,lr,"hour")||dr(e,cr,"minute")||dr(e,ar,"second")||e+" ms"}(e):function(e){if(e>=ur)return Math.round(e/ur)+"d";if(e>=lr)return Math.round(e/lr)+"h";if(e>=cr)return Math.round(e/cr)+"m";if(e>=ar)return Math.round(e/ar)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function dr(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=fr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(sr,sr.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=sr.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())}(ir,ir.exports);var pr={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}}(pr);var mr={},gr={}.toString,yr=Array.isArray||function(e){return"[object Array]"==gr.call(e)},vr=function(e){return br&&Buffer.isBuffer(e)||wr&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},br="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,wr="function"==typeof ArrayBuffer;var Cr=yr,_r=vr,kr=Object.prototype.toString,Sr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===kr.call(Blob),Er="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===kr.call(File);function Ar(e,t){if(!e)return e;if(_r(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Cr(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=Ar(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=Ar(e[i],t);return r}return e}function Tr(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(Cr(e))for(var n=0;n<e.length;n++)e[n]=Tr(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=Tr(e[r],t);return e}mr.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=Ar(n,t),r.attachments=t.length,{packet:r,buffers:t}},mr.reconstructPacket=function(e,t){return e.data=Tr(e.data,t),e.attachments=void 0,e},mr.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(Sr&&o instanceof Blob||Er&&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(Cr(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!_r(o))for(var l in o)e(o[l],l,o)}(r),n||t(r)},function(e){var t=ir.exports("socket.io-parser"),n=pr.exports,r=mr,o=yr,i=vr;function s(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=s,e.Decoder=l;var a=e.ERROR+'"encode error"';function c(n){var r=""+n.type;if(e.BINARY_EVENT!==n.type&&e.BINARY_ACK!==n.type||(r+=n.attachments+"-"),n.nsp&&"/"!==n.nsp&&(r+=n.nsp+","),null!=n.id&&(r+=n.id),null!=n.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(n.data);if(!1===o)return a;r+=o}return t("encoded %j as %s",n,r),r}function l(){this.reconstructor=null}function u(e){this.reconPack=e,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}s.prototype.encode=function(n,o){(t("encoding packet %j",n),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type)?function(e,t){function n(e){var n=r.deconstructPacket(e),o=c(n.packet),i=n.buffers;i.unshift(o),t(i)}r.removeBlobs(e,n)}(n,o):o([c(n)])},n(l.prototype),l.prototype.add=function(n){var r;if("string"==typeof n)r=function(n){var r=0,i={type:Number(n.charAt(0))};if(null==e.types[i.type])return h("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s=r+1;"-"!==n.charAt(++r)&&r!=n.length;);var a=n.substring(s,r);if(a!=Number(a)||"-"!==n.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(a)}if("/"===n.charAt(r+1)){for(s=r+1;++r;){if(","===(l=n.charAt(r)))break;if(r===n.length)break}i.nsp=n.substring(s,r)}else i.nsp="/";var c=n.charAt(r+1);if(""!==c&&Number(c)==c){for(s=r+1;++r;){var l;if(null==(l=n.charAt(r))||Number(l)!=l){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==u&&(i.type===e.ERROR||o(u))))return h("invalid payload");i.data=u}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new u(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!i(n)&&!n.base64)throw new Error("Unknown type: "+n);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(n))&&(this.reconstructor=null,this.emit("decoded",r))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},u.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=r.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},u.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(or);var xr={exports:{}},Ir={},Or={exports:{}};try{Or.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){Or.exports=!1}var Rr,Pr,Br,Nr,Fr="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")(),jr=Or.exports,Mr=Fr,Ur=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||jr))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&r)return new XDomainRequest}catch(e){}if(!t)try{return new(Mr[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},Lr={exports:{}},Dr={},qr=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t};function zr(){if(Nr)return Br;Nr=1;var e=function(){if(Pr)return Rr;Pr=1;var e={}.toString;return Rr=Array.isArray||function(t){return"[object Array]"==e.call(t)}}(),t=Object.prototype.toString,n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===t.call(Blob),r="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===t.call(File);return Br=function t(o){if(!o||"object"!=typeof o)return!1;if(e(o)){for(var i=0,s=o.length;i<s;i++)if(t(o[i]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(o)||"function"==typeof ArrayBuffer&&o instanceof ArrayBuffer||n&&o instanceof Blob||r&&o instanceof File)return!0;if(o.toJSON&&"function"==typeof o.toJSON&&1===arguments.length)return t(o.toJSON(),!0);for(var a in o)if(Object.prototype.hasOwnProperty.call(o,a)&&t(o[a]))return!0;return!1},Br}var $r=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},Hr=function(e,t,n){var r=!1;return n=n||Vr,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 Vr(){}
2
- /*! https://mths.be/utf8js v2.1.2 by @mathias */var Wr,Kr,Qr,Jr=String.fromCharCode;function Xr(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 Yr(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 Gr(e,t){return Jr(e>>t&63|128)}function Zr(e,t){if(0==(4294967168&e))return Jr(e);var n="";return 0==(4294965248&e)?n=Jr(e>>6&31|192):0==(4294901760&e)?(Yr(e,t)||(e=65533),n=Jr(e>>12&15|224),n+=Gr(e,6)):0==(4292870144&e)&&(n=Jr(e>>18&7|240),n+=Gr(e,12),n+=Gr(e,6)),n+=Jr(63&e|128)}function eo(){if(Qr>=Kr)throw Error("Invalid byte index");var e=255&Wr[Qr];if(Qr++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function to(e){var t,n;if(Qr>Kr)throw Error("Invalid byte index");if(Qr==Kr)return!1;if(t=255&Wr[Qr],Qr++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|eo())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|eo()<<6|eo())>=2048)return Yr(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|eo()<<12|eo()<<6|eo())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var no,ro,oo,io,so,ao={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Xr(e),o=r.length,i=-1,s="";++i<o;)s+=Zr(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;Wr=Xr(e),Kr=Wr.length,Qr=0;for(var r,o=[];!1!==(r=to(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=Jr((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Jr(t);return o}(o)}},co={};function lo(){if(oo)return ro;oo=1;var e=void 0!==e?e:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,t=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),n=t&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),r=e&&e.prototype.append&&e.prototype.getBlob;function o(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 i(t,n){n=n||{};var r=new e;return o(t).forEach((function(e){r.append(e)})),n.type?r.getBlob(n.type):r.getBlob()}function s(e,t){return new Blob(o(e),t||{})}return"undefined"!=typeof Blob&&(i.prototype=Blob.prototype,s.prototype=Blob.prototype),ro=t?n?Blob:s:r?i:void 0}function uo(){if(so)return io;so=1;var e=Dr;function t(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.withCredentials=e.withCredentials,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}return io=t,(0,pr.exports)(t.prototype),t.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},t.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},t.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},t.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},t.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},t.prototype.onData=function(t){var n=e.decodePacket(t,this.socket.binaryType);this.onPacket(n)},t.prototype.onPacket=function(e){this.emit("packet",e)},t.prototype.onClose=function(){this.readyState="closed",this.emit("close")},io}!function(e){var t,n,r=qr,o=zr(),i=$r,s=Hr,a=ao;"undefined"!=typeof ArrayBuffer&&(no||(no=1,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",co.encode=function(e){var t,r=new Uint8Array(e),o=r.length,i="";for(t=0;t<o;t+=3)i+=n[r[t]>>2],i+=n[(3&r[t])<<4|r[t+1]>>4],i+=n[(15&r[t+1])<<2|r[t+2]>>6],i+=n[63&r[t+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},co.decode=function(e){var t,r,o,i,s,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),h=new Uint8Array(u);for(t=0;t<c;t+=4)r=n.indexOf(e[t]),o=n.indexOf(e[t+1]),i=n.indexOf(e[t+2]),s=n.indexOf(e[t+3]),h[l++]=r<<2|o>>4,h[l++]=(15&o)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return u}),t=co);var c="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),l="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),u=c||l;e.protocol=3;var h=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},f=r(h),d={type:"error",data:"parser error"},p=lo();function m(e,t,n){for(var r=new Array(e.length),o=s(e.length,n),i=function(e,n,o){t(n,(function(t,n){r[e]=n,o(t,r)}))},a=0;a<e.length;a++)i(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]=h[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}(t,n,o);if(void 0!==p&&i instanceof p)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(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]=h[t.type];var i=new p([o.buffer,t.data]);return r(i)}(t,n,o);if(i&&i.base64)return function(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}(t,o);var s=h[t.type];return void 0!==t.data&&(s+=r?a.encode(String(t.data),{strict:!1}):String(t.data)),o(""+s)},e.encodeBase64Packet=function(t,n){var r,o="b"+e.packets[t.type];if(void 0!==p&&t.data instanceof p){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(t.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];r=String.fromCharCode.apply(null,a)}return o+=btoa(r),n(o)},e.decodePacket=function(t,n,r){if(void 0===t)return d;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&!1===(t=function(e){try{e=a.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return d;var o=t.charAt(0);return Number(o)==o&&f[o]?t.length>1?{type:f[o],data:t.substring(1)}:{type:f[o]}:d}o=new Uint8Array(t)[0];var s=i(t,1);return p&&"blob"===n&&(s=new p([s])),{type:f[o],data:s}},e.decodeBase64Packet=function(e,n){var r=f[e.charAt(0)];if(!t)return{type:r,data:{base64:!0,data:e.substr(1)}};var o=t.decode(e.substr(1));return"blob"===n&&p&&(o=new p([o])),{type:r,data:o}},e.encodePayload=function(t,n,r){"function"==typeof n&&(r=n,n=null);var i=o(t);if(n&&i)return p&&!u?e.encodePayloadAsBlob(t,r):e.encodePayloadAsArrayBuffer(t,r);if(!t.length)return r("0:");m(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 r(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(d,0,1);for(var i,s,a="",c=0,l=t.length;c<l;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return r(d,0,1);if(a!=(s=t.substr(c+1,i)).length)return r(d,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),d.type===o.type&&d.data===o.data)return r(d,0,1);if(!1===r(o,c+i,l))return}c+=i,a=""}else a+=u}return""!==a?r(d,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){if(!t.length)return n(new ArrayBuffer(0));m(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){m(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);e=r.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,p){var a=new p([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new p(t))}))},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var o=t,s=[];o.byteLength>0;){for(var a=new Uint8Array(o),c=0===a[0],l="",u=1;255!==a[u];u++){if(l.length>310)return r(d,0,1);l+=a[u]}o=i(o,2+l.length),l=parseInt(l);var h=i(o,0,l);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var f=new Uint8Array(h);h="";for(u=0;u<f.length;u++)h+=String.fromCharCode(f[u])}s.push(h),o=i(o,l)}var p=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,p)}))}}(Dr);var ho,fo={};function po(){return ho||(ho=1,fo.encode=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},fo.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}),fo}var mo,go=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},yo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),vo={},bo=0,wo=0;function Co(e){var t="";do{t=yo[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function _o(){var e=Co(+new Date);return e!==mo?(bo=0,mo=e):e+"."+Co(bo++)}for(;wo<64;wo++)vo[yo[wo]]=wo;_o.encode=Co,_o.decode=function(e){var t=0;for(wo=0;wo<e.length;wo++)t=64*t+vo[e.charAt(wo)];return t};var ko=_o,So={exports:{}},Eo={exports:{}},Ao=1e3,To=60*Ao,xo=60*To,Io=24*xo,Oo=365.25*Io,Ro=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*Oo;case"days":case"day":case"d":return n*Io;case"hours":case"hour":case"hrs":case"hr":case"h":return n*xo;case"minutes":case"minute":case"mins":case"min":case"m":return n*To;case"seconds":case"second":case"secs":case"sec":case"s":return n*Ao;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 Po(e,Io,"day")||Po(e,xo,"hour")||Po(e,To,"minute")||Po(e,Ao,"second")||e+" ms"}(e):function(e){if(e>=Io)return Math.round(e/Io)+"d";if(e>=xo)return Math.round(e/xo)+"h";if(e>=To)return Math.round(e/To)+"m";if(e>=Ao)return Math.round(e/Ao)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Po(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Ro,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Eo,Eo.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=Eo.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())}(So,So.exports);var Bo=uo(),No=po(),Fo=Dr,jo=go,Mo=ko,Uo=So.exports("engine.io-client:polling"),Lo=qo,Do=null!=new Ur({xdomain:!1}).responseType;function qo(e){var t=e&&e.forceBase64;Do&&!t||(this.supportsBinary=!1),Bo.call(this,e)}jo(qo,Bo),qo.prototype.name="polling",qo.prototype.doOpen=function(){this.poll()},qo.prototype.pause=function(e){var t=this;function n(){Uo("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(Uo("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){Uo("pre-pause polling complete"),--r||n()}))),this.writable||(Uo("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){Uo("pre-pause writing complete"),--r||n()})))}else n()},qo.prototype.poll=function(){Uo("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},qo.prototype.onData=function(e){var t=this;Uo("polling got data %s",e);Fo.decodePayload(e,this.socket.binaryType,(function(e,n,r){if("opening"===t.readyState&&"open"===e.type&&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():Uo('ignoring poll - transport state "%s"',this.readyState))},qo.prototype.doClose=function(){var e=this;function t(){Uo("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Uo("transport open - closing"),t()):(Uo("transport not open - deferring close"),this.once("open",t))},qo.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};Fo.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},qo.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=Mo()),this.supportsBinary||e.sid||(e.b64=1),e=No.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 zo=Ur,$o=Lo,Ho=pr.exports,Vo=go,Wo=So.exports("engine.io-client:polling-xhr"),Ko=Fr;function Qo(){}function Jo(e){if($o.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 Xo(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.withCredentials=e.withCredentials,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(Lr.exports=Jo,Lr.exports.Request=Xo,Vo(Jo,$o),Jo.prototype.supportsBinary=!0,Jo.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.withCredentials=this.withCredentials,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 Xo(e)},Jo.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},Jo.prototype.doPoll=function(){Wo("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},Ho(Xo.prototype),Xo.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 zo(e),n=this;try{Wo("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=this.withCredentials),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||"application/octet-stream; charset=UTF-8"===e)&&(t.responseType="arraybuffer")}catch(e){}4===t.readyState&&(200===t.status||1223===t.status?n.onLoad():setTimeout((function(){n.onError("number"==typeof t.status?t.status:0)}),0))},Wo("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Xo.requestsCount++,Xo.requests[this.index]=this)},Xo.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},Xo.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},Xo.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},Xo.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Qo:this.xhr.onreadystatechange=Qo,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Xo.requests[this.index],this.xhr=null}},Xo.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch(e){}e=("application/octet-stream"===t||"application/octet-stream; charset=UTF-8"===t)&&this.xhr.response||this.xhr.responseText}catch(e){this.onError(e)}null!=e&&this.onData(e)},Xo.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},Xo.prototype.abort=function(){this.cleanup()},Xo.requestsCount=0,Xo.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Yo);else if("function"==typeof addEventListener){addEventListener("onpagehide"in Ko?"pagehide":"unload",Yo,!1)}function Yo(){for(var e in Xo.requests)Xo.requests.hasOwnProperty(e)&&Xo.requests[e].abort()}var Go,Zo=Lo,ei=Fr,ti=ii,ni=/\n/g,ri=/\\n/g;function oi(){}function ii(e){Zo.call(this,e),this.query=this.query||{},Go||(Go=ei.___eio=ei.___eio||[]),this.index=Go.length;var t=this;Go.push((function(e){t.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){t.script&&(t.script.onerror=oi)}),!1)}go(ii,Zo),ii.prototype.supportsBinary=!1,ii.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),Zo.prototype.doClose.call(this)},ii.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)},ii.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(ri,"\\\n"),this.area.value=e.replace(ni,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var si,ai,ci=Ce(Object.freeze({__proto__:null,default:{}})),li=uo(),ui=Dr,hi=po(),fi=go,di=ko,pi=So.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket?si=WebSocket:"undefined"!=typeof self&&(si=self.WebSocket||self.MozWebSocket),"undefined"==typeof window)try{ai=ci}catch(e){}var mi=si||ai,gi=yi;function yi(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=si&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(mi=ai),li.call(this,e)}fi(yi,li),yi.prototype.name="websocket",yi.prototype.supportsBinary=!0,yi.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,n={};this.isReactNative||(n.agent=this.agent,n.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 mi(e,t):new mi(e):new mi(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()}},yi.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)}},yi.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){ui.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){pi("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},yi.prototype.onClose=function(){li.prototype.onClose.call(this)},yi.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},yi.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]=di()),this.supportsBinary||(e.b64=1),(e=hi.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},yi.prototype.check=function(){return!(!mi||"__initialize"in mi&&this.name===yi.prototype.name)};var vi=Ur,bi=Lr.exports,wi=ti,Ci=gi;Ir.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 vi(e)&&!e.forceJSONP)return new bi(e);if(!r)throw new Error("JSONP disabled");return new wi(e)},Ir.websocket=Ci;var _i=[].indexOf,ki=function(e,t){if(_i)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},Si=Ir,Ei=pr.exports,Ai=So.exports("engine.io-client:socket"),Ti=ki,xi=Dr,Ii=Vn,Oi=po(),Ri=Pi;function Pi(e,t){if(!(this instanceof Pi))return new Pi(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=Ii(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=Ii(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=Oi.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.withCredentials=!1!==t.withCredentials,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||void 0,this.key=t.key||void 0,this.passphrase=t.passphrase||void 0,this.cert=t.cert||void 0,this.ca=t.ca||void 0,this.ciphers=t.ciphers||void 0,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()}Pi.priorWebsocketSuccess=!1,Ei(Pi.prototype),Pi.protocol=xi.protocol,Pi.Socket=Pi,Pi.Transport=uo(),Pi.transports=Ir,Pi.parser=Dr,Pi.prototype.createTransport=function(e){Ai('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=xi.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new Si[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,withCredentials:n.withCredentials||this.withCredentials,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})},Pi.prototype.open=function(){var e;if(this.rememberUpgrade&&Pi.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)},Pi.prototype.setTransport=function(e){Ai("setting transport %s",e.name);var t=this;this.transport&&(Ai("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")}))},Pi.prototype.probe=function(e){Ai('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||(Ai('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(Ai('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;Pi.priorWebsocketSuccess="websocket"===t.name,Ai('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(Ai("changing transport and sending upgrade packet"),u(),r.setTransport(t),t.send([{type:"upgrade"}]),r.emit("upgrade",t),t=null,r.upgrading=!1,r.flush())}))}else{Ai('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,r.emit("upgradeError",i)}})))}function i(){n||(n=!0,u(),t.close(),t=null)}function s(n){var o=new Error("probe error: "+n);o.transport=t.name,i(),Ai('probe transport "%s" failed because of error: %s',e,n),r.emit("upgradeError",o)}function a(){s("transport closed")}function c(){s("socket closed")}function l(e){t&&e.name!==t.name&&(Ai('"%s" works - aborting "%s"',e.name,t.name),i())}function u(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),r.removeListener("close",c),r.removeListener("upgrading",l)}Pi.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()},Pi.prototype.onOpen=function(){if(Ai("socket open"),this.readyState="open",Pi.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){Ai("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},Pi.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(Ai('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 Ai('packet received with socket readyState "%s"',this.readyState)},Pi.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))},Pi.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)},Pi.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){Ai("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},Pi.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},Pi.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},Pi.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(Ai("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},Pi.prototype.write=Pi.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},Pi.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()}},Pi.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"),Ai("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},Pi.prototype.onError=function(e){Ai("socket error %j",e),Pi.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},Pi.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){Ai('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}},Pi.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~Ti(this.transports,e[n])&&t.push(e[n]);return t},function(e){e.exports=Ri,e.exports.parser=Dr}(xr);var Bi,Ni,Fi={exports:{}};var ji=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var Mi,Ui=[].slice,Li=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=Ui.call(arguments,2);return function(){return t.apply(e,n.concat(Ui.call(arguments)))}};function Di(){return Mi||(Mi=1,function(e,t){var n=or,r=pr.exports,o=(Ni||(Ni=1,Bi=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n}),Bi),i=ji,s=Li,a=Wn.exports("socket.io-client:socket"),c=po(),l=zr();e.exports=f;var u={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},h=r.prototype.emit;function f(e,t,n){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}r(f.prototype),f.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[i(e,"open",s(this,"onopen")),i(e,"packet",s(this,"onpacket")),i(e,"close",s(this,"onclose"))]}},f.prototype.open=f.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.reconnecting||this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},f.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},f.prototype.emit=function(e){if(u.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:l(t))?n.BINARY_EVENT:n.EVENT,data:t,options:{}};return r.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=t.pop(),r.id=this.ids++),this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this},f.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},f.prototype.onopen=function(){if(a("transport is open - connecting"),"/"!==this.nsp)if(this.query){var e="object"==typeof this.query?c.encode(this.query):this.query;a("sending connect packet with query %s",e),this.packet({type:n.CONNECT,query:e})}else this.packet({type:n.CONNECT})},f.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},f.prototype.onpacket=function(e){var t=e.nsp===this.nsp,r=e.type===n.ERROR&&"/"===e.nsp;if(t||r)switch(e.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(e);break;case n.ACK:case n.BINARY_ACK:this.onack(e);break;case n.DISCONNECT:this.ondisconnect();break;case n.ERROR:this.emit("error",e.data)}},f.prototype.onevent=function(e){var t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?h.apply(this,t):this.receiveBuffer.push(t)},f.prototype.ack=function(e){var t=this,r=!1;return function(){if(!r){r=!0;var i=o(arguments);a("sending ack %j",i),t.packet({type:l(i)?n.BINARY_ACK:n.ACK,id:e,data:i})}}},f.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)},f.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emit("connect")},f.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)h.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},f.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},f.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},f.prototype.close=f.prototype.disconnect=function(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:n.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},f.prototype.compress=function(e){return this.flags.compress=e,this},f.prototype.binary=function(e){return this.flags.binary=e,this}}(Fi)),Fi.exports}var qi=zi;function zi(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}zi.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)},zi.prototype.reset=function(){this.attempts=0},zi.prototype.setMin=function(e){this.ms=e},zi.prototype.setMax=function(e){this.max=e},zi.prototype.setJitter=function(e){this.jitter=e};var $i=xr.exports,Hi=Di(),Vi=pr.exports,Wi=or,Ki=ji,Qi=Li,Ji=Wn.exports("socket.io-client:manager"),Xi=ki,Yi=qi,Gi=Object.prototype.hasOwnProperty,Zi=es;function es(e,t){if(!(this instanceof es))return new es(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 Yi({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||Wi;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}es.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)Gi.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},es.prototype.updateSocketIds=function(){for(var e in this.nsps)Gi.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},es.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Vi(es.prototype),es.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},es.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},es.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},es.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},es.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},es.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},es.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},es.prototype.open=es.prototype.connect=function(e,t){if(Ji("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Ji("opening %s",this.uri),this.engine=$i(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=Ki(n,"open",(function(){r.onopen(),e&&e()})),i=Ki(n,"error",(function(t){if(Ji("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;Ji("connect attempt will timeout after %d",s),0===s&&o.destroy();var a=setTimeout((function(){Ji("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},es.prototype.onopen=function(){Ji("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(Ki(e,"data",Qi(this,"ondata"))),this.subs.push(Ki(e,"ping",Qi(this,"onping"))),this.subs.push(Ki(e,"pong",Qi(this,"onpong"))),this.subs.push(Ki(e,"error",Qi(this,"onerror"))),this.subs.push(Ki(e,"close",Qi(this,"onclose"))),this.subs.push(Ki(this.decoder,"decoded",Qi(this,"ondecoded")))},es.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},es.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},es.prototype.ondata=function(e){this.decoder.add(e)},es.prototype.ondecoded=function(e){this.emit("packet",e)},es.prototype.onerror=function(e){Ji("error",e),this.emitAll("error",e)},es.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new Hi(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(){~Xi(r.connecting,n)||r.connecting.push(n)}return n},es.prototype.destroy=function(e){var t=Xi(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},es.prototype.packet=function(e){Ji("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()})))},es.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},es.prototype.cleanup=function(){Ji("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()},es.prototype.close=es.prototype.disconnect=function(){Ji("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},es.prototype.onclose=function(e){Ji("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},es.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Ji("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Ji("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Ji("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Ji("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Ji("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},es.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=rr,r=or,o=Zi,i=Wn.exports("socket.io-client");e.exports=t=a;var s=t.managers={};function a(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,a=n(e),c=a.source,l=a.id,u=a.path,h=s[l]&&u in s[l].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),r=o(c,t)):(s[l]||(i("new io instance for %s",c),s[l]=o(c,t)),r=s[l]),a.query&&!t.query&&(t.query=a.query),r.socket(a.path,t)}t.protocol=r.protocol,t.connect=a,t.Manager=Zi,t.Socket=Di()}(zn,zn.exports);var ts=zn.exports;function ns(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 rs={exports:{}};!function(e,t){e.exports=function(){function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(!a&&ns)return ns(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,(function(e){return o(t[s][1][e]||e)}),l,l.exports,e,t,n,r)}return n[s].exports}for(var i=ns,s=0;s<r.length;s++)o(r[s]);return o}return e}()({1:[function(e,t,n){(function(n,r){(function(){const o=e("events").EventEmitter,i=e("./store"),s=e("./topic-alias-recv"),a=e("./topic-alias-send"),c=e("mqtt-packet"),l=e("./default-message-id-provider"),u=e("readable-stream").Writable,h=e("inherits"),f=e("reinterval"),d=e("rfdc/default"),p=e("./validations"),m=e("xtend"),g=e("debug")("mqttjs:client"),y=n?n.nextTick:function(e){setTimeout(e,0)},v=r.setImmediate||function(e){y(e)},b={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},w=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],C={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function _(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function k(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let n;t.properties&&(n=t.properties.topicAlias);const r=t.topic.toString();if(e.topicAliasSend)if(n){if(0!==r.length&&(g("applyTopicAlias :: register topic: %s - alias: %d",r,n),!e.topicAliasSend.put(r,n)))return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",r,n),new Error("Sending Topic Alias out of range")}else 0!==r.length&&(e.options.autoAssignTopicAlias?(n=e.topicAliasSend.getAliasByTopic(r),n?(t.topic="",t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",r,n)):(n=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(r,n),t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto assign topic: %s - alias: %d",r,n))):e.options.autoUseTopicAlias&&(n=e.topicAliasSend.getAliasByTopic(r),n&&(t.topic="",t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto use topic: %s - alias: %d",r,n))));else if(n)return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",r,n),new Error("Sending Topic Alias out of range")}}function S(e,t){let n;t.properties&&(n=t.properties.topicAlias);let r=t.topic.toString();if(0===r.length){if(void 0===n)return new Error("Unregistered Topic Alias");if(r=e.topicAliasSend.getTopicByAlias(n),void 0===r)return new Error("Unregistered Topic Alias");t.topic=r}n&&delete t.properties.topicAlias}function E(e,t,n){g("sendPacket :: packet: %O",t),g("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),g("sendPacket :: writing to stream");const r=c.writeToStream(t,e.stream,e.options);g("sendPacket :: writeToStream result %s",r),!r&&n&&n!==I?(g("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(g("sendPacket :: invoking cb"),n())}function A(e){e&&(g("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function T(e){e&&(g("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function x(e,t,n,r){g("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let o,i=t;if("publish"===i.cmd&&(i=d(t),o=S(e,i),o))return n&&n(o);e.outgoingStore.put(i,(function(o){if(o)return n&&n(o);r(),E(e,t,n)}))}function I(e){g("nop ::",e)}function O(e,t){let n;const r=this;if(!(this instanceof O))return new O(e,t);for(n in this.options=t||{},b)void 0===this.options[n]?this.options[n]=b[n]:this.options[n]=t[n];g("MqttClient :: options.protocol",t.protocol),g("MqttClient :: options.protocolVersion",t.protocolVersion),g("MqttClient :: options.username",t.username),g("MqttClient :: options.keepalive",t.keepalive),g("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),g("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),g("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:_(),g("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new l:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new i,this.incomingStore=t.incomingStore||new i,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?g("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;function t(){const n=e.shift();g("deliver :: entry %o",n);let o=null;if(!n)return void r._resubscribe();o=n.packet,g("deliver :: call _sendPacket for %o",o);let i=!0;o.messageId&&0!==o.messageId&&(r.messageIdProvider.register(o.messageId)||(i=!1)),i?r._sendPacket(o,(function(e){n.cb&&n.cb(e),t()})):(g("messageId: %d has already used. The message is skipped and removed.",o.messageId),t())}g("connect :: sending queued packets"),t()})),this.on("close",(function(){g("close :: connected set to `false`"),this.connected=!1,g("close :: clearing connackTimer"),clearTimeout(this.connackTimer),g("close :: clearing ping timer"),null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),g("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),g("MqttClient :: setting up stream"),this._setupStream()}h(O,o),O.prototype._setupStream=function(){const e=this,t=new u,n=c.parser(this.options);let r=null;const o=[];function i(){if(o.length)y(s);else{const e=r;r=null,e()}}function s(){g("work :: getting next packet in queue");const t=o.shift();if(t)g("work :: packet pulled from queue"),e._handlePacket(t,i);else{g("work :: no packets in queue");const e=r;r=null,g("work :: done flag is %s",!!e),e&&e()}}function a(t){g("streamErrorHandler :: error",t.message),w.includes(t.code)?(g("streamErrorHandler :: emitting error"),e.emit("error",t)):I(t)}g("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),g("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),n.on("packet",(function(e){g("parser :: on packet push to packets array."),o.push(e)})),t._write=function(e,t,o){r=o,g("writable stream :: parsing buffer"),n.parse(e),s()},g("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",a),this.stream.on("close",(function(){g("(%s)stream :: on close",e.options.clientId),T(e.outgoing),g("stream: emit close to MqttClient"),e.emit("close")})),g("_setupStream: sending packet `connect`");const l=Object.create(this.options);if(l.cmd="connect",this.topicAliasRecv&&(l.properties||(l.properties={}),this.topicAliasRecv&&(l.properties.topicAliasMaximum=this.topicAliasRecv.max)),E(this,l),n.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&E(this,m({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){g("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)}),this.options.connectTimeout)},O.prototype._handlePacket=function(e,t){const n=this.options;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(g("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},O.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==I?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},O.prototype.publish=function(e,t,n,r){g("publish :: message `%s` to topic `%s`",t,e);const o=this.options;if("function"==typeof n&&(r=n,n=null),n=m({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;const i=this,s=function(){let s=0;if((1===n.qos||2===n.qos)&&(s=i._nextId(),null===s))return g("No messageId left"),!1;const a={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:s,dup:n.dup};switch(5===o.protocolVersion&&(a.properties=n.properties),g("publish :: qos",n.qos),n.qos){case 1:case 2:i.outgoing[a.messageId]={volatile:!1,cb:r||I},g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,void 0,n.cbStorePut);break;default:g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,r,n.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:n.cbStorePut,callback:r}),this},O.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const n=[];let r=t.shift();const o=r.resubscribe;let i=t.pop()||I,s=t.pop();const a=this.options.protocolVersion;delete r.resubscribe,"string"==typeof r&&(r=[r]),"function"!=typeof i&&(s=i,i=I);const c=p.validateTopics(r);if(null!==c)return v(i,new Error("Invalid topic "+c)),this;if(this._checkDisconnecting(i))return g("subscribe: discconecting true"),this;const l={qos:0};if(5===a&&(l.nl=!1,l.rap=!1,l.rh=0),s=m(l,s),Array.isArray(r)?r.forEach((function(t){if(g("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||o){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),g("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),n.push(e)}})):Object.keys(r).forEach((function(t){if(g("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<r[t].qos||o){const e={topic:t,qos:r[t].qos};5===a&&(e.nl=r[t].nl,e.rap=r[t].rap,e.rh=r[t].rh,e.properties=s.properties),g("subscribe: pushing `%s` to subs list",e),n.push(e)}})),!n.length)return i(null,[]),this;const u=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const r={cmd:"subscribe",subscriptions:n,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(r.properties=s.properties),e.options.resubscribe){g("subscribe :: resubscribe true");const t=[];n.forEach((function(n){if(e.options.reconnectPeriod>0){const r={qos:n.qos};5===a&&(r.nl=n.nl||!1,r.rap=n.rap||!1,r.rh=n.rh||0,r.properties=n.properties),e._resubscribeTopics[n.topic]=r,t.push(n.topic)}})),e.messageIdToTopic[r.messageId]=t}return e.outgoing[r.messageId]={volatile:!0,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)n[t].qos=e[t]}i(e,n)}},g("subscribe :: call _sendPacket"),e._sendPacket(r),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!u())&&this._storeProcessingQueue.push({invoke:u,callback:i}),this},O.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let n=t.shift(),r=t.pop()||I,o=t.pop();"string"==typeof n&&(n=[n]),"function"!=typeof r&&(o=r,r=I);const i=p.validateTopics(n);if(null!==i)return v(r,new Error("Invalid topic "+i)),this;if(e._checkDisconnecting(r))return this;const s=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const i={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof n?i.unsubscriptions=[n]:Array.isArray(n)&&(i.unsubscriptions=n),e.options.resubscribe&&i.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t]})),"object"==typeof o&&o.properties&&(i.properties=o.properties),e.outgoing[i.messageId]={volatile:!0,cb:r},g("unsubscribe: call _sendPacket"),e._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:r}),this},O.prototype.end=function(e,t,n){const r=this;function o(){g("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(g("end :: closeStores: emitting end"),r.emit("end"),n){const r=e||t;g("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){g("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{g("end :: finish :: calling process.nextTick on closeStores"),y(o.bind(r))}),t)}return g("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||I,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=I))),"object"!=typeof t&&(n=t,t=null),g("end :: cb? %s",!!n),n=n||I,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(g("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(g("end :: (%s) :: immediately calling finish",r.options.clientId),i()),this)},O.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},O.prototype.reconnect=function(e){g("client reconnect");const t=this,n=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new i,t.outgoingStore=t.options.outgoingStore||new i,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},O.prototype._reconnect=function(){g("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),g("client already connected. disconnecting first.")):(g("_reconnect: calling _setupStream"),this._setupStream())},O.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(g("_setupReconnect :: emit `offline` state"),this.emit("offline"),g("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),g("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){g("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):g("_setupReconnect :: doing nothing...")},O.prototype._clearReconnect=function(){g("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},O.prototype._cleanUp=function(e,t){const n=arguments[2];if(t&&(g("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),g("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&A(this.outgoing),g("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=m({cmd:"disconnect"},n);g("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,v.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(g("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(g("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(g("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},O.prototype._sendPacket=function(e,t,n){g("_sendPacket :: (%s) :: start",this.options.clientId),n=n||I,t=t||I;const r=k(this,e);if(r)t(r);else{if(!this.connected)return"auth"===e.cmd?(this._shiftPingInterval(),void E(this,e,t)):(g("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,n));switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void x(this,e,t,n);default:return void E(this,e,t)}switch(e.qos){case 2:case 1:x(this,e,t,n);break;default:E(this,e,t)}g("_sendPacket :: (%s) :: end",this.options.clientId)}},O.prototype._storePacket=function(e,t,n){g("_storePacket :: packet: %o",e),g("_storePacket :: cb? %s",!!t),n=n||I;let r=e;if("publish"===r.cmd){r=d(e);const n=S(this,r);if(n)return t&&t(n)}0===(r.qos||0)&&this.queueQoSZero||"publish"!==r.cmd?this.queue.push({packet:r,cb:t}):r.qos>0?(t=this.outgoing[r.messageId]?this.outgoing[r.messageId].cb:null,this.outgoingStore.put(r,(function(e){if(e)return t&&t(e);n()}))):t&&t(new Error("No connection to broker"))},O.prototype._setupPingTimer=function(){g("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=f((function(){e._checkPing()}),1e3*this.options.keepalive))},O.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},O.prototype._checkPing=function(){g("_checkPing :: checking ping..."),this.pingResp?(g("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(g("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},O.prototype._handlePingresp=function(){this.pingResp=!0},O.prototype._handleConnack=function(e){g("_handleConnack");const t=this.options,n=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(0===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){const e=new Error("Connection refused: "+C[n]);e.code=n,this.emit("error",e)}},O.prototype._handleAuth=function(e){const t=this.options.protocolVersion,n=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=n,void this.emit("error",e)}const r=this;this.handleAuth(e,(function(e,t){if(e)r.emit("error",e);else if(24===n)r.reconnecting=!1,r._sendPacket(t);else{const t=new Error("Connection refused: "+C[n]);e.code=n,r.emit("error",t)}}))},O.prototype.handleAuth=function(e,t){t()},O.prototype._handlePublish=function(e,t){g("_handlePublish: packet %o",e),t=void 0!==t?t:I;let n=e.topic.toString();const r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===n.length){if(!(t>0&&t<=65535))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return g("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));n=e,g("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",n,t)}}else{if(!this.topicAliasRecv.put(n,t))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));g("_handlePublish :: registered topic: %s - alias: %d",n,t)}}switch(g("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(n,r,e,(function(n,r){return n instanceof Error||(r=n,n=null),n?s.emit("error",n):-1===c.indexOf(r)?s.emit("error",new Error("Wrong reason code for pubrec")):void(r?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:r},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(n,r,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",n,r,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},t)})))}));break;case 0:this.emit("message",n,r,e),this.handleMessage(e,t);break;default:g("_handlePublish: unknown QoS. Doing nothing.")}},O.prototype.handleMessage=function(e,t){t()},O.prototype._handleAck=function(e){const t=e.messageId,n=e.cmd;let r=null;const o=this.outgoing[t]?this.outgoing[t].cb:null,i=this;let s;if(o){switch(g("_handleAck :: packet type",n),n){case"pubcomp":case"puback":{const n=e.reasonCode;n&&n>0&&16!==n&&(s=new Error("Publish error: "+C[n]),s.code=n,o(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,o),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case"pubrec":{r={cmd:"pubrel",qos:2,messageId:t};const n=e.reasonCode;n&&n>0&&16!==n?(s=new Error("Publish error: "+C[n]),s.code=n,o(s,e)):this._sendPacket(r);break}case"suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let n=0;n<e.granted.length;n++)if(0!=(128&e.granted[n])){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete i._resubscribeTopics[e]}))}this._invokeStoreProcessingQueue(),o(null,e);break;case"unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),o(null);break;default:i.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else g("_handleAck :: Server sent an ack in error. Ignoring.")},O.prototype._handlePubrel=function(e,t){g("handling pubrel packet"),t=void 0!==t?t:I;const n=e.messageId,r=this,o={cmd:"pubcomp",messageId:n};r.incomingStore.get(e,(function(e,n){e?r._sendPacket(o,t):(r.emit("message",n.topic,n.payload,n),r.handleMessage(n,(function(e){if(e)return t(e);r.incomingStore.del(n,I),r._sendPacket(o,t)})))}))},O.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},O.prototype._nextId=function(){return this.messageIdProvider.allocate()},O.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},O.prototype._resubscribe=function(){g("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){g("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const n={};n[e[t]]=this._resubscribeTopics[e[t]],n.resubscribe=!0,this.subscribe(n,{properties:n[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},O.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;function n(){let r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,t._flushStoreProcessingQueue(),o()}function s(){if(!r)return;t._storeProcessing=!0;const e=r.read(1);let n;e?t._packetIdsDuringStoreProcessing[e.messageId]?s():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(n=t.outgoing[e.messageId]?t.outgoing[e.messageId].cb:null,t.outgoing[e.messageId]={volatile:!1,cb:function(e,t){n&&n(e,t),s()}},t._packetIdsDuringStoreProcessing[e.messageId]=!0,t.messageIdProvider.register(e.messageId)?t._sendPacket(e):g("messageId: %d has already used.",e.messageId)):r.once("readable",s)}t.once("close",i),r.on("error",(function(e){o(),t._flushStoreProcessingQueue(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){let r=!0;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){r=!1;break}r?(o(),t.removeListener("close",i),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):n()})),s()}this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,n()},O.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},O.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},O.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},t.exports=O}).call(this)}).call(this,e("_process"),void 0!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(e,t,n){const{Buffer:r}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c,l=!1;function u(){const e=new o;return e._write=function(e,t,n){s.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){s.closeSocket({success:function(){e()}})},e}function h(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function f(e,t){const n="alis"===e.protocol?"wss":"ws";let r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function d(){l||(l=!0,s.onSocketOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=r.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?r.from(e):r.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((function(){c.end(),c.destroy()})),s.onSocketError((function(e){c.destroy(e)})))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";h(t);const r=f(t,e);return s=t.my,s.connectSocket({url:r,protocols:n}),a=u(),c=i.obj(),d(),c}t.exports=p},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(e,t,n){const r=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const n=t.port,i=t.hostname;return o("port %d and host %s",n,i),r.createConnection(n,i)}t.exports=i},{debug:18,net:16}],4:[function(e,t,n){const r=e("tls"),o=e("net"),i=e("debug")("mqttjs:tls");function s(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===o.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,i("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const n=r.connect(t);function s(r){t.rejectUnauthorized&&e.emit("error",r),n.end()}return n.on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",s)})),n.on("error",s),n}t.exports=s},{debug:18,net:16,tls:16}],5:[function(e,t,n){(function(n){(function(){const{Buffer:r}=e("buffer"),o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform,c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],l=void 0!==n&&"browser"===n.title||"function"==typeof __webpack_require__;function u(e,t){let n=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function h(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),l||"wss"!==e.protocol||c.forEach((function(n){Object.prototype.hasOwnProperty.call(e,n)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,n)&&(t.wsOptions[n]=e[n])})),t}function f(e){const t=h(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}function d(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 p(e,t){const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",r=u(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");const n=h(t),r=u(n,e),s=d(e,r,n),a=o.createWebSocketStream(s,n.wsOptions);return a.url=r,s.on("close",(()=>{a.destroy()})),a}function g(e,t){let n;i("browserStreamBuilder");const o=f(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,l=!t.objectMode,u=p(e,t),h=m(t,C,_);t.objectMode||(h._writev=w),h.on("close",(()=>{u.close()}));const d=void 0!==u.addEventListener;function m(e,t,n){const r=new a({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}function g(){n.setReadable(h),n.setWritable(h),n.emit("connect")}function y(){n.end(),n.destroy()}function v(e){n.destroy(e)}function b(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),h.push(t)}function w(e,t){const n=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?n[t]=r.from(e[t],"utf8"):n[t]=e[t].chunk;this._write(r.concat(n),"binary",t)}function C(e,t,n){u.bufferedAmount>o&&setTimeout(C,c,e,t,n),l&&"string"==typeof e&&(e=r.from(e,"utf8"));try{u.send(e)}catch(e){return n(e)}n()}function _(e){u.close(),e()}return u.readyState===u.OPEN?n=h:(n=n=s(void 0,void 0,t),t.objectMode||(n._writev=w),d?u.addEventListener("open",g):u.onopen=g),n.socket=u,d?(u.addEventListener("close",y),u.addEventListener("error",v),u.addEventListener("message",b)):(u.onclose=y,u.onerror=v,u.onmessage=b),n}t.exports=l?g:m}).call(this)}).call(this,e("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(e,t,n){const{Buffer:r}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c;function l(){const e=new o;return e._write=function(e,t,n){s.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){s.close({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){const n="wxs"===e.protocol?"wss":"ws";let r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function f(){s.onOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),a.push(t)})),s.onClose((function(){c.end(),c.destroy()})),s.onError((function(e){c.destroy(new Error(e.errMsg))}))}function d(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);const r=h(t,e);s=wx.connectSocket({url:r,protocols:[n]}),a=l(),c=i.obj(),c._destroy=function(e,t){s.close({success:function(){t&&t(e)}})};const o=c.destroy;return c.destroy=function(){c.destroy=o;const e=this;setTimeout((function(){s.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(c),f(),c}t.exports=d},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(e,t,n){function r(){if(!(this instanceof r))return new r;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}r.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},r.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},r.prototype.register=function(e){return!0},r.prototype.deallocate=function(e){},r.prototype.clear=function(){},t.exports=r},{}],8:[function(e,t,n){const r=e("xtend"),o=e("readable-stream").Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=r(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new o(i),t=[];let n=!1,r=0;return this._inflights.forEach((function(e,n){t.push(e)})),e._read=function(){!n&&r<t.length?this.push(t[r++]):this.push(null)},e.destroy=function(){if(n)return;const e=this;n=!0,setTimeout((function(){e.emit("close")}),0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=a},{"readable-stream":69,xtend:81}],9:[function(e,t,n){function r(e){if(!(this instanceof r))return new r(e);this.aliasToTopic={},this.max=e}r.prototype.put=function(e,t){return!(0===t||t>this.max||(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,0))},r.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},r.prototype.clear=function(){this.aliasToTopic={}},t.exports=r},{}],10:[function(e,t,n){const r=e("lru-cache"),o=e("number-allocator").NumberAllocator;function i(e){if(!(this instanceof i))return new i(e);e>0&&(this.aliasToTopic=new r({max:e}),this.topicToAlias={},this.numberAllocator=new o(1,e),this.max=e,this.length=0)}i.prototype.put=function(e,t){if(0===t||t>this.max)return!1;const n=this.aliasToTopic.get(t);return n&&delete this.topicToAlias[n],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},i.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},i.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},i.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},i.prototype.getLruAlias=function(){const e=this.numberAllocator.firstVacant();return e||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},t.exports=i},{"lru-cache":37,"number-allocator":46}],11:[function(e,t,n){function r(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(let t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],12:[function(e,t,n){(function(n){(function(){const r=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function l(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function u(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const n=i.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=s(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(l(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!c[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,n){return(!e||n%2!=0)&&"function"==typeof c[t]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function n(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a("calling streambuilder for",t.protocol),c[t.protocol](e,t)}t.protocol&&(t.defaultProtocol=t.protocol);const o=new r(n,t);return o.on("error",(function(){})),o}void 0!==n&&"browser"!==n.title||"function"!=typeof __webpack_require__?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=u,t.exports.connect=u,t.exports.MqttClient=r,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":8,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:50,debug:18,url:76,xtend:81}],13:[function(e,t,n){n.byteLength=u,n.toByteArray=f,n.fromByteArray=m;for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r}function h(e,t,n){return 3*(t+n)/4-n}function f(e){var t,n,r=l(e),s=r[0],a=r[1],c=new i(h(e,s,a)),u=0,f=a>0?s-4:s;for(n=0;n<f;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[u++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c}function d(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function p(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(d(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(p(e,a,a+s>c?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],14:[function(e,t,n){const{Buffer:r}=e("buffer"),o=Symbol.for("BufferList");function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},i.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},i.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,n,o){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof o||o>this.length)&&(o=this.length),n>=this.length)return e||r.alloc(0);if(o<=0)return e||r.alloc(0);const i=!!e,s=this._offset(n),a=o-n;let c=a,l=i&&t||0,u=s[1];if(0===n&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-u)return i?this._bufs[s[0]].copy(e,t,u,u+c):this._bufs[s[0]].slice(u,u+c);i||(e=r.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const n=this._bufs[t].length-u;if(!(c>n)){this._bufs[t].copy(e,l,u,u+c),l+=n;break}this._bufs[t].copy(e,l,u),l+=n,c-=n,u&&(u=0)}return e.length>l?e.slice(0,l):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),o=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,r[1]),0!==n[1]&&(o[0]=o[0].slice(n[1])),this._new(o)},i.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(r.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(r.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const t=this._bufs[i];for(;s<t.length;)if(t.length-s>=e.length){const n=t.indexOf(e,s);if(-1!==n)return this._reverseOffset([i,n]);s=t.length-e.length+1}else{const t=this._reverseOffset([i,s]);if(this._match(t,e))return t;s++}s=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let n=0;n<t.length;n++)if(this.get(e+n)!==t[n])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){null===e[t]?i.prototype[t]=function(e,n){return this.slice(e,e+n)[t](0,n)}:i.prototype[t]=function(n=0){return this.slice(n,n+e[t])[t](0)}}(t)}(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return null!=e&&e[o]},t.exports=i},{buffer:17}],15:[function(e,t,n){const r=e("readable-stream").Duplex,o=e("inherits"),i=e("./BufferList");function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}i._init.call(this,e),r.call(this)}o(s,r),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){r.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof i||s.isBufferList(e)},s.isBufferList=i.isBufferList,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(e,t,n){},{}],17:[function(e,t,n){(function(t){(function(){var t=e("base64-js"),r=e("ieee754");n.Buffer=a,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return f(e,t);if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return p(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return a.from(r,t,n);var o=m(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e,t,n){return l(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}function h(e){return l(e),s(e<0?0:0|g(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|v(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function d(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 p(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||Y(e.length)?s(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Q(e).length;default:if(o)return r?-1:V(e).length;t=(""+t).toLowerCase(),o=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return F(this,t,n);case"utf8":case"utf-8":return O(this,t,n);case"ascii":return B(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function C(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Y(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:_(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):_(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(i=n;i<a;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,f=0;f<c;f++)if(l(e,i+f)!==l(t,f)){h=!1;break}if(h)return i}return-1}function k(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(Y(a))return s;e[n+s]=a}return s}function S(e,t,n,r){return J(V(t,e.length-n),e,n,r)}function E(e,t,n,r){return J(W(t),e,n,r)}function A(e,t,n,r){return E(e,t,n,r)}function T(e,t,n,r){return J(Q(t),e,n,r)}function x(e,t,n,r){return J(K(t,e.length-n),e,n,r)}function I(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function O(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,l=e[o],u=null,h=l>239?4:l>223?3:l>191?2:1;if(o+h<=n)switch(h){case 1:l<128&&(u=l);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&l)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=h}return P(r)}n.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,n){return c(e,t,n)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,n){return u(e,t,n)},a.allocUnsafe=function(e){return h(e)},a.allocUnsafeSlow=function(e){return h(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var 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(X(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},a.byteLength=v,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?O(this,0,e):b.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,o){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),l=this.slice(r,o),u=e.slice(t,n),h=0;h<c;++h)if(l[h]!==u[h]){i=l[h],s=u[h];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return k(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return E(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return T(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function P(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=R));return n}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function N(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 F(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=H(e[i]);return o}function j(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function M(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,n,r,o,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function L(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function D(e,t,n,o,i){return t=+t,n>>>=0,i||L(e,t,n,4),r.write(e,t,n,o,23,4),n+4}function q(e,t,n,o,i){return t=+t,n>>>=0,i||L(e,t,n,8),r.write(e,t,n,o,52,8),n+8}a.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return r.__proto__=a.prototype,r},a.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},a.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},a.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||U(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||U(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);U(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);U(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,n){return D(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return D(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var i=o-1;i>=0;--i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var o=e.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,r),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=s[i%c]}return this};var z=/[^+/0-9A-Za-z-_]/g;function $(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function V(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function W(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function K(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}function Q(e){return t.toByteArray($(e))}function J(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(e,t,n){(function(r){(function(){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}function s(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}n.formatArgs=i,n.save=s,n.load=a,n.useColors=o,n.storage=c(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":19,_process:50}],19:[function(e,t,n){function r(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let t,n,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(t||o);n.diff=i,n.prev=t,n.curr=o,t=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";s++;const i=r.formatters[o];if("function"==typeof i){const r=e[s];t=i.call(n,r),e.splice(s,1),s--}return t})),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return a.namespace=e,a.useColors=r.useColors(),a.color=r.selectColor(e),a.extend=o,a.destroy=r.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==r.namespaces&&(n=r.namespaces,i=r.enabled(e)),i),set:e=>{s=e}}),"function"==typeof r.init&&r.init(a),a}function o(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function i(e){let t;r.save(e),r.namespaces=e,r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...r.names.map(c),...r.skips.map(c).map((e=>"-"+e))].join(",");return r.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1}function c(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=i,r.enabled=a,r.humanize=e("ms"),r.destroy=u,Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}t.exports=r},{ms:45}],20:[function(e,t,n){(function(n,r){(function(){var o=e("readable-stream"),i=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},u=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(n){n?u(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},f=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},d=function(){},p=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:p(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=d),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},m.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},m.prototype._write=function(e,t,n){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,n)):e===c?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:this.destroyed||n()):n()},m.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){f(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)}))}))},m.prototype.end=function(e,t,n){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(c),o.Writable.prototype.end.call(this,n))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:50,buffer:17,"end-of-stream":21,inherits:24,"readable-stream":69,"stream-shift":74}],21:[function(e,t,n){(function(n){(function(){var r=e("once"),o=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},s=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,c){if("function"==typeof t)return a(e,null,t);t||(t={}),c=r(c||o);var l=e._writableState,u=e._readableState,h=t.readable||!1!==t.readable&&e.readable,f=t.writable||!1!==t.writable&&e.writable,d=!1,p=function(){e.writable||m()},m=function(){f=!1,h||c.call(e)},g=function(){h=!1,f||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},v=function(t){c.call(e,t)},b=function(){n.nextTick(w)},w=function(){if(!d)return(!h||u&&u.ended&&!u.destroyed)&&(!f||l&&l.ended&&!l.destroyed)?void 0:c.call(e,new Error("premature close"))},C=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",b),e.req?C():e.on("request",C)):f&&!l&&(e.on("end",p),e.on("close",p)),s(e)&&e.on("exit",y),e.on("end",g),e.on("finish",m),!1!==t.error&&e.on("error",v),e.on("close",b),function(){d=!0,e.removeListener("complete",m),e.removeListener("abort",b),e.removeListener("request",C),e.req&&e.req.removeListener("finish",m),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",m),e.removeListener("exit",y),e.removeListener("end",g),e.removeListener("error",v),e.removeListener("close",b)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:50,once:48}],22:[function(e,t,n){var r=Object.create||S,o=Object.keys||E,i=Function.prototype.bind||A;function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,n){if(t)e.call(n);else for(var r=e.length,o=_(e,r),i=0;i<r;++i)o[i].call(n)}function f(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].call(n,r)}function d(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=_(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function p(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=_(e,s),c=0;c<s;++c)a[c].call(n,r,o,i)}function m(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].apply(n,r)}function g(e,t,n,o){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[n,a]:[a,n]:o?a.unshift(n):a.push(n),!a.warned&&(i=u(e))&&i>0&&a.length>i){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function v(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=i.call(y,r);return o.listener=n,r.wrapFn=o,o}function b(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?k(o):_(o,o.length):[]}function w(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function C(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}function _(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function k(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function S(e){var t=function(){};return t.prototype=e,new t}function E(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t);return t}function A(e){var t=this;return function(){return t.apply(e,arguments)}}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:h(n,l,this);break;case 2:f(n,l,this,arguments[1]);break;case 3:d(n,l,this,arguments[1],arguments[2]);break;case 4:p(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];m(n,l,this,o)}return!0},s.prototype.addListener=function(e,t){return g(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return g(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,v(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,v(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():C(n,i),1===n.length&&(o[e]=n[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,i;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=o(n);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return b(this,e,!0)},s.prototype.rawListeners=function(e){return b(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},s.prototype.listenerCount=w,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(e,t,n){
1
+ var Amity=function(e){"use strict";var t;const n="object"==typeof globalThis?globalThis:"object"==typeof global?global:window,{process:r={}}=n,o="production"===(null===(t=r.env)||void 0===t?void 0:t.NODE_ENV);var i,s;const a=null!==(s=null===(i=r.env)||void 0===i?void 0:i.VERSION)&&void 0!==s?s:"__dev__",c="function"==typeof atob,l="function"==typeof btoa,u="function"==typeof Buffer,h="function"==typeof TextDecoder?new TextDecoder:void 0,f="function"==typeof TextEncoder?new TextEncoder:void 0,d=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),p=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(d),m=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,g=String.fromCharCode.bind(String),y="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),v=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),b=l?e=>btoa(e):u?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,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+=d[t>>18&63]+d[t>>12&63]+d[t>>6&63]+d[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},w=u?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(g.apply(null,e.subarray(n,n+4096)));return b(t.join(""))},C=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?g(192|t>>>6)+g(128|63&t):g(224|t>>>12&15)+g(128|t>>>6&63)+g(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return g(240|t>>>18&7)+g(128|t>>>12&63)+g(128|t>>>6&63)+g(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,k=u?e=>Buffer.from(e,"utf8").toString("base64"):f?e=>w(f.encode(e)):e=>b(e.replace(_,C)),S=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,A=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return g(55296+(t>>>10))+g(56320+(1023&t));case 3:return g((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return g((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},E=c?e=>atob(v(e)):u?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!m.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,o="";for(let i=0;i<e.length;)t=p[e.charAt(i++)]<<18|p[e.charAt(i++)]<<12|(n=p[e.charAt(i++)])<<6|(r=p[e.charAt(i++)]),o+=64===n?g(t>>16&255):64===r?g(t>>16&255,t>>8&255):g(t>>16&255,t>>8&255,255&t);return o},T=u?e=>y(Buffer.from(e,"base64")):e=>y(E(e),(e=>e.charCodeAt(0))),I=u?e=>Buffer.from(e,"base64").toString("utf8"):h?e=>h.decode(T(e)):e=>E(e).replace(S,A),x=e=>I(v(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),O=e=>["skip","limit"].some((t=>t in e)),R=e=>["after","before","first","last","limit"].some((t=>t in e)),P=e=>"limit"in e,B=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),N=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t&&R(e)?Number.isNaN(Number(null==e?void 0:e.before))?Number.isNaN(Number(null==e?void 0:e.after))?Number.isNaN(Number(null==e?void 0:e.limit))||(r={last:e.limit}):r={after:e.after,first:e.limit}:r={before:e.before,last:e.limit}:"afterbeforeraw"===t&&(r=e),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")))(k(e)):k(e))(JSON.stringify(r)):void 0},j=e=>{if(!e)return;const t=JSON.parse(x(e));if(O(t))return{after:t.skip,limit:t.limit};if(R(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}},F=e=>{if(!e)return;const t=JSON.parse(x(e));return P(t)?t:void 0},M={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,category:({categoryId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,poll:({pollId:e})=>e,reaction:({reactionId:e})=>e,stream:({streamId:e})=>e,follow:({from:e,to:t})=>`${e}#${t}`,followCount:({userId:e})=>e},U=e=>M[e],D={file:["fileId","attributes"],user:["userId","avatarFileId"],role:["roleId"],channel:["channelId","rateLimit"],channelUsers:["channelId","userId","membership"],message:["messageId"],community:["communityId","onlyAdminCanPost"],category:["categoryId"],communityUsers:["userId","communityId","communityMembership"],post:["postId","feedId"],comment:["commentId","referenceId"],poll:["pollId"],reaction:["reactionId"],stream:["streamId"],follow:["from","to"],followCount:["userId","followerCount"]},L=e=>{var t;return null===(t=Object.entries(D).find((([t,n])=>((e,t)=>{const n=Object.keys(e);return t.every((e=>n.includes(e)))})(e,n))))||void 0===t?void 0:t[0]},q={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",categories:"category",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",polls:"poll",reactions:"reaction",videoStreamings:"stream",follows:"follow",followCounts:"followCount"},z=e=>"locally"in e,$=e=>"optimistically"in e,H=e=>z(e)||$(e),V=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),W=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},K=(e,...t)=>({func:e,args:t}),Q=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},J=({func:e,args:t},n,r=Q("cache_then_server"))=>{let o;if(H(e)&&0!==r.lifeSpan){try{o=$(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(X(void 0,{origin:"local",loading:!1,error:e}))}const i=V(o)&&W(o,r.lifeSpan);if(null==n||n(X(o,{origin:"local",loading:!(z(e)&&i)})),i)return}else null==n||n(X(void 0,{origin:"local",loading:!0}));let i=t;if($(e)){const e=o&&o.data&&(e=>{var t;const n=L(e);if(n)return null===(t=D[n])||void 0===t?void 0:t[0]})(o.data);e&&"string"!=typeof t[0]&&(i=[Object.assign(Object.assign({},t[0]),{[e]:o.data[e]})])}e(...i).then((e=>{null==n||n(X(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(X(void 0,{origin:"server",loading:!1,error:e}))}))};function X(e,t){return B(e)||V(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}const Y=(e,t,n)=>void 0!==n?e.filter((e=>e[t]===n)):e,G=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),Z=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf();class ee 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,ee)}}class te extends ee{constructor(e,t,n){super(e,t,n)}}class ne extends ee{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class re extends ee{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let oe=null;const ie=()=>{if(!oe)throw new ee("There is no active client",8e5,"fatal");return oe},se=e=>{oe=e};let ae,ce=[];const le=["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"],ue=["connect","message","disconnect","error","close","end","reconnect"],he=()=>{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},fe=(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)}},de=(e,t)=>{const{emitter:n}=ie();var r;r=()=>{n.emit(e,t)},clearTimeout(ae),ce.push(r),ae=setTimeout((()=>{ce.forEach((e=>e())),ce=[]}),0)};let pe=null;const me=()=>{if(!pe)throw new ee("Connect client first",8e5,"fatal");return pe};var ge;e.SubscriptionLevels=void 0,(ge=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",ge.POST="post",ge.COMMENT="comment",ge.POST_AND_COMMENT="post_and_comment",ge.USER="user";const ye=(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}},ve=()=>{const e=me(),[t]=e.path.split("/user/");return t};let be,we;function Ce(e,t){const{mqtt:n,emitter:r,accessToken:o}=ie(),i=me();return be===o&&we===i._id||(be=o,we=i._id,n.connect({accessToken:be,userId:we}),((e,t)=>{ue.forEach((n=>{e.on(n,((...e)=>t.emit(n,1===e.length?e[0]:e)))})),e.on("message",((e,n)=>{const r=JSON.parse(n.toString());t.emit(r.eventType,r.data)}))})(n,r)),n.subscribe(e,t)}var _e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ke(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Se(e){var t=e.default;if("function"==typeof t){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}const Ae=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:Ee}=Object.prototype,{propertyIsEnumerable:Te}=Object,Ie=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),xe=_e,Oe={concatArrays:!1,ignoreUndefined:!1},Re=e=>{const t=[];for(const n in e)Ee.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)Te.call(e,r)&&t.push(r)}return t};function Pe(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return Re(e).forEach((n=>{Ie(t,n,Pe(e[n]))})),t}(e):Ae(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return Re(e).forEach((n=>{Ie(t,n,Pe(e[n]))})),t}(e):e}const Be=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?Ie(e,n,Ne(e[n],t[n],r)):Ie(e,n,Pe(t[n])))})),e);function Ne(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++)Ee.call(t,n)&&(i.push(String(n)),Ie(r,o++,t===e?t[n]:Pe(t[n])));r=Be(r,t,Re(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):Ae(t)&&Ae(e)?Be(e,t,Re(t),n):Pe(t)}const je=function(...e){const t=Ne(Pe(Oe),this!==xe&&this||{},Oe);let n={_:{}};for(const r of e)if(void 0!==r){if(!Ae(r))throw new TypeError("`"+r+"` is not an Option Object");n=Ne(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0});function Fe(e,t){return new Promise(((n,r)=>{try{const r=e();null==t||t(null,r),n(r)}catch(e){null==t||t(e),r(e)}}))}function Me(e,t,n){return Promise.all(e).then((e=>{var r;const o=null!==(r=null==n?void 0:n(e))&&void 0!==r?r:null;return null==t||t(null,o),Promise.resolve(o)}),(e=>(null==t||t(e),Promise.reject(e))))}const Ue={getItem:(e,t)=>Fe((()=>window.localStorage.getItem(e)),t),setItem:(e,t,n)=>Fe((()=>window.localStorage.setItem(e,t)),n),removeItem:(e,t)=>Fe((()=>window.localStorage.removeItem(e)),t),mergeItem:(e,t,n)=>Fe((()=>function(e,t){const n=window.localStorage.getItem(e);if(n){const r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(je(r,o));window.localStorage.setItem(e,i)}else window.localStorage.setItem(e,t)}(e,t)),n),clear:e=>Fe((()=>window.localStorage.clear()),e),getAllKeys:e=>Fe((()=>{const e=window.localStorage.length,t=[];for(let n=0;n<e;n+=1){const e=window.localStorage.key(n)||"";t.push(e)}return t}),e),flushGetRequests:()=>{},multiGet:(e,t)=>Me(e.map((e=>Ue.getItem(e))),t,(t=>t.map(((t,n)=>[e[n],t])))),multiSet:(e,t)=>Me(e.map((e=>Ue.setItem(e[0],e[1]))),t),multiRemove:(e,t)=>Me(e.map((e=>Ue.removeItem(e))),t),multiMerge:(e,t)=>Me(e.map((e=>Ue.mergeItem(e[0],e[1]))),t)},De=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})),Le=e=>JSON.parse(e),qe=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>qe(e[n],t[n])))),ze=e=>{const{log:t,cache:n}=ie();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=Le(t);return qe(e,n)})).map((e=>n.data[e]))},$e=e=>{const{log:t,cache:n}=ie();if(!n)return;t("cache/api/pullFromCache",e);const r=De(e);return n.data[r]?n.data[r]:void 0},He=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=ie();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=De(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},Ve=(e,t,n)=>{const{log:r,cache:o}=ie();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=$e(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return He(e,s,n),!0},We=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=ie();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return $e(e)?Ve(e,t,n):He(e,t,n)},Ke=(e,t=!1)=>{const{log:n,cache:r}=ie();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>Le(e))).filter((t=>qe(e,t))).map((e=>Ke(e,!0))).every((e=>e));const o=De(e);return o in r.data&&(delete r.data[o],!0)};var Qe,Je,Xe={exports:{}};function Ye(){if(Je)return Qe;Je=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function s(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return Qe=function(a,c){c=c||{};var l=typeof a;if("string"===l&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===l&&isFinite(a))return c.long?function(o){var i=Math.abs(o);if(i>=r)return s(o,i,r,"day");if(i>=n)return s(o,i,n,"hour");if(i>=t)return s(o,i,t,"minute");if(i>=e)return s(o,i,e,"second");return o+" ms"}(a):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))},Qe}var Ge=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Ye(),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=Ge(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Xe,Xe.exports);var Ze=Xe.exports;const et={EU:"eu",SG:"sg",US:"us"},tt={http:"https://api.{region}.amity.co",mqtt:"wss://sse.{region}.amity.co:443/mqtt"};function nt(e,t){return tt[e].replace("{region}",t)}var rt={exports:{}},ot={exports:{}},it=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)}},st=it,at=Object.prototype.toString;function ct(e){return"[object Array]"===at.call(e)}function lt(e){return void 0===e}function ut(e){return null!==e&&"object"==typeof e}function ht(e){if("[object Object]"!==at.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ft(e){return"[object Function]"===at.call(e)}function dt(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),ct(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 pt={isArray:ct,isArrayBuffer:function(e){return"[object ArrayBuffer]"===at.call(e)},isBuffer:function(e){return null!==e&&!lt(e)&&null!==e.constructor&&!lt(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:ut,isPlainObject:ht,isUndefined:lt,isDate:function(e){return"[object Date]"===at.call(e)},isFile:function(e){return"[object File]"===at.call(e)},isBlob:function(e){return"[object Blob]"===at.call(e)},isFunction:ft,isStream:function(e){return ut(e)&&ft(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:dt,merge:function e(){var t={};function n(n,r){ht(t[r])&&ht(n)?t[r]=e(t[r],n):ht(n)?t[r]=e({},n):ct(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)dt(arguments[r],n);return t},extend:function(e,t,n){return dt(t,(function(t,r){e[r]=n&&"function"==typeof t?st(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}},mt=pt;function gt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var yt=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(mt.isURLSearchParams(t))r=t.toString();else{var o=[];mt.forEach(t,(function(e,t){null!=e&&(mt.isArray(e)?t+="[]":e=[e],mt.forEach(e,(function(e){mt.isDate(e)?e=e.toISOString():mt.isObject(e)&&(e=JSON.stringify(e)),o.push(gt(t)+"="+gt(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},vt=pt;function bt(){this.handlers=[]}bt.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},bt.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},bt.prototype.forEach=function(e){vt.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var wt,Ct,_t=bt,kt=pt;function St(){return Ct?wt:(Ct=1,wt=function(e){return!(!e||!e.__CANCEL__)})}var At,Et,Tt,It,xt,Ot,Rt,Pt,Bt,Nt,jt,Ft,Mt,Ut,Dt,Lt,qt,zt,$t,Ht,Vt=pt;function Wt(){return Et?At:(Et=1,At=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})}function Kt(){if(It)return Tt;It=1;var e=Wt();return Tt=function(t,n,r,o,i){var s=new Error(t);return e(s,n,r,o,i)}}function Qt(){if(Ot)return xt;Ot=1;var e=Kt();return xt=function(t,n,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?n(e("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}}function Jt(){if(Pt)return Rt;Pt=1;var e=pt;return Rt=e.isStandardBrowserEnv()?{write:function(t,n,r,o,i,s){var a=[];a.push(t+"="+encodeURIComponent(n)),e.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),e.isString(o)&&a.push("path="+o),e.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.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(){}}}function Xt(){return Nt||(Nt=1,Bt=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}),Bt}function Yt(){return Ft?jt:(Ft=1,jt=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e})}function Gt(){if(Ut)return Mt;Ut=1;var e=Xt(),t=Yt();return Mt=function(n,r){return n&&!e(r)?t(n,r):r}}function Zt(){if(Lt)return Dt;Lt=1;var e=pt,t=["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"];return Dt=function(n){var r,o,i,s={};return n?(e.forEach(n.split("\n"),(function(n){if(i=n.indexOf(":"),r=e.trim(n.substr(0,i)).toLowerCase(),o=e.trim(n.substr(i+1)),r){if(s[r]&&t.indexOf(r)>=0)return;s[r]="set-cookie"===r?(s[r]?s[r]:[]).concat([o]):s[r]?s[r]+", "+o:o}})),s):s},Dt}function en(){if(zt)return qt;zt=1;var e=pt;return qt=e.isStandardBrowserEnv()?function(){var t,n=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var t=e;return n&&(r.setAttribute("href",t),t=r.href),r.setAttribute("href",t),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=o(window.location.href),function(n){var r=e.isString(n)?o(n):n;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0},qt}function tn(){if(Ht)return $t;Ht=1;var e=pt,t=Qt(),n=Jt(),r=yt,o=Gt(),i=Zt(),s=en(),a=Kt();return $t=function(c){return new Promise((function(l,u){var h=c.data,f=c.headers;e.isFormData(h)&&delete f["Content-Type"];var d=new XMLHttpRequest;if(c.auth){var p=c.auth.username||"",m=c.auth.password?unescape(encodeURIComponent(c.auth.password)):"";f.Authorization="Basic "+btoa(p+":"+m)}var g=o(c.baseURL,c.url);if(d.open(c.method.toUpperCase(),r(g,c.params,c.paramsSerializer),!0),d.timeout=c.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var e="getAllResponseHeaders"in d?i(d.getAllResponseHeaders()):null,n={data:c.responseType&&"text"!==c.responseType?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:e,config:c,request:d};t(l,u,n),d=null}},d.onabort=function(){d&&(u(a("Request aborted",c,"ECONNABORTED",d)),d=null)},d.onerror=function(){u(a("Network Error",c,null,d)),d=null},d.ontimeout=function(){var e="timeout of "+c.timeout+"ms exceeded";c.timeoutErrorMessage&&(e=c.timeoutErrorMessage),u(a(e,c,"ECONNABORTED",d)),d=null},e.isStandardBrowserEnv()){var y=(c.withCredentials||s(g))&&c.xsrfCookieName?n.read(c.xsrfCookieName):void 0;y&&(f[c.xsrfHeaderName]=y)}if("setRequestHeader"in d&&e.forEach(f,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete f[t]:d.setRequestHeader(t,e)})),e.isUndefined(c.withCredentials)||(d.withCredentials=!!c.withCredentials),c.responseType)try{d.responseType=c.responseType}catch(e){if("json"!==c.responseType)throw e}"function"==typeof c.onDownloadProgress&&d.addEventListener("progress",c.onDownloadProgress),"function"==typeof c.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",c.onUploadProgress),c.cancelToken&&c.cancelToken.promise.then((function(e){d&&(d.abort(),u(e),d=null)})),h||(h=null),d.send(h)}))}}var nn=pt,rn=function(e,t){Vt.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},on={"Content-Type":"application/x-www-form-urlencoded"};function sn(e,t){!nn.isUndefined(e)&&nn.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var an,cn={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(an=tn()),an),transformRequest:[function(e,t){return rn(t,"Accept"),rn(t,"Content-Type"),nn.isFormData(e)||nn.isArrayBuffer(e)||nn.isBuffer(e)||nn.isStream(e)||nn.isFile(e)||nn.isBlob(e)?e:nn.isArrayBufferView(e)?e.buffer:nn.isURLSearchParams(e)?(sn(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):nn.isObject(e)?(sn(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}};cn.headers={common:{Accept:"application/json, text/plain, */*"}},nn.forEach(["delete","get","head"],(function(e){cn.headers[e]={}})),nn.forEach(["post","put","patch"],(function(e){cn.headers[e]=nn.merge(on)}));var ln=cn,un=pt,hn=function(e,t,n){return kt.forEach(n,(function(n){e=n(e,t)})),e},fn=St(),dn=ln;function pn(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var mn,gn,yn,vn,bn,wn,Cn,_n,kn=pt,Sn=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 kn.isPlainObject(e)&&kn.isPlainObject(t)?kn.merge(e,t):kn.isPlainObject(t)?kn.merge({},t):kn.isArray(t)?t.slice():t}function c(r){kn.isUndefined(t[r])?kn.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}kn.forEach(r,(function(e){kn.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),kn.forEach(o,c),kn.forEach(i,(function(r){kn.isUndefined(t[r])?kn.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),kn.forEach(s,(function(r){r in t?n[r]=a(e[r],t[r]):r in e&&(n[r]=a(void 0,e[r]))}));var l=r.concat(o).concat(i).concat(s),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return kn.forEach(u,c),n},An=pt,En=yt,Tn=_t,In=function(e){return pn(e),e.headers=e.headers||{},e.data=hn(e.data,e.headers,e.transformRequest),e.headers=un.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),un.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||dn.adapter)(e).then((function(t){return pn(e),t.data=hn(t.data,t.headers,e.transformResponse),t}),(function(t){return fn(t)||(pn(e),t&&t.response&&(t.response.data=hn(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},xn=Sn;function On(e){this.defaults=e,this.interceptors={request:new Tn,response:new Tn}}function Rn(){if(gn)return mn;function e(e){this.message=e}return gn=1,e.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},e.prototype.__CANCEL__=!0,mn=e}On.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=xn(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[In,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},On.prototype.getUri=function(e){return e=xn(this.defaults,e),En(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},An.forEach(["delete","get","head","options"],(function(e){On.prototype[e]=function(t,n){return this.request(xn(n||{},{method:e,url:t,data:(n||{}).data}))}})),An.forEach(["post","put","patch"],(function(e){On.prototype[e]=function(t,n,r){return this.request(xn(r||{},{method:e,url:t,data:n}))}}));var Pn=pt,Bn=it,Nn=On,jn=Sn;function Fn(e){var t=new Nn(e),n=Bn(Nn.prototype.request,t);return Pn.extend(n,Nn.prototype,t),Pn.extend(n,t),n}var Mn=Fn(ln);Mn.Axios=Nn,Mn.create=function(e){return Fn(jn(Mn.defaults,e))},Mn.Cancel=Rn(),Mn.CancelToken=function(){if(vn)return yn;vn=1;var e=Rn();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(e){n=e}));var r=this;t((function(t){r.reason||(r.reason=new e(t),n(r.reason))}))}return 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}},yn=t}(),Mn.isCancel=St(),Mn.all=function(e){return Promise.all(e)},Mn.spread=wn?bn:(wn=1,bn=function(e){return function(t){return e.apply(null,t)}}),Mn.isAxiosError=_n?Cn:(_n=1,Cn=function(e){return"object"==typeof e&&!0===e.isAxiosError}),ot.exports=Mn,ot.exports.default=Mn,rt.exports=ot.exports;var Un=ke(rt.exports),Dn={exports:{}};Dn.exports=qn;var Ln=Dn.exports.HttpsAgent=qn;function qn(){}const zn=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new ne(e.code);if("error"===e.status)throw new te(e.message,e.code,"error")},$n=(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}`:$n(n,null!=t?t:e)})).join("&"),Hn=e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Un.create({baseURL:e,httpAgent:new Dn.exports(t),httpsAgent:new Ln(t),paramsSerializer:$n});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&&zn(n.data)})),n};var Vn={exports:{}},Wn=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Kn=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Qn=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=Wn.exec(e||""),i={},s=14;s--;)i[Kn[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},Jn={exports:{}},Xn={exports:{}},Yn=1e3,Gn=6e4,Zn=60*Gn,er=24*Zn,tr=365.25*er,nr=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*tr;case"days":case"day":case"d":return n*er;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Zn;case"minutes":case"minute":case"mins":case"min":case"m":return n*Gn;case"seconds":case"second":case"secs":case"sec":case"s":return n*Yn;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 rr(e,er,"day")||rr(e,Zn,"hour")||rr(e,Gn,"minute")||rr(e,Yn,"second")||e+" ms"}(e):function(e){if(e>=er)return Math.round(e/er)+"d";if(e>=Zn)return Math.round(e/Zn)+"h";if(e>=Gn)return Math.round(e/Gn)+"m";if(e>=Yn)return Math.round(e/Yn)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function rr(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=nr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(Xn,Xn.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=Xn.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())}(Jn,Jn.exports);var or=Qn,ir=Jn.exports("socket.io-client:url"),sr=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)||(ir("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),ir("parse %s",e),n=or(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 ar={},cr={exports:{}},lr={exports:{}},ur=1e3,hr=6e4,fr=60*hr,dr=24*fr,pr=365.25*dr,mr=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*pr;case"days":case"day":case"d":return n*dr;case"hours":case"hour":case"hrs":case"hr":case"h":return n*fr;case"minutes":case"minute":case"mins":case"min":case"m":return n*hr;case"seconds":case"second":case"secs":case"sec":case"s":return n*ur;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 gr(e,dr,"day")||gr(e,fr,"hour")||gr(e,hr,"minute")||gr(e,ur,"second")||e+" ms"}(e):function(e){if(e>=dr)return Math.round(e/dr)+"d";if(e>=fr)return Math.round(e/fr)+"h";if(e>=hr)return Math.round(e/hr)+"m";if(e>=ur)return Math.round(e/ur)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function gr(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=mr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(lr,lr.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=lr.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())}(cr,cr.exports);var yr={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 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}}(yr);var vr={},br={}.toString,wr=Array.isArray||function(e){return"[object Array]"==br.call(e)},Cr=function(e){return _r&&Buffer.isBuffer(e)||kr&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},_r="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,kr="function"==typeof ArrayBuffer;var Sr=wr,Ar=Cr,Er=Object.prototype.toString,Tr="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Er.call(Blob),Ir="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Er.call(File);function xr(e,t){if(!e)return e;if(Ar(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(Sr(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=xr(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=xr(e[i],t);return r}return e}function Or(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(Sr(e))for(var n=0;n<e.length;n++)e[n]=Or(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=Or(e[r],t);return e}vr.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=xr(n,t),r.attachments=t.length,{packet:r,buffers:t}},vr.reconstructPacket=function(e,t){return e.data=Or(e.data,t),e.attachments=void 0,e},vr.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(Tr&&o instanceof Blob||Ir&&o instanceof File){n++;var a=new FileReader;a.onload=function(){s?s[i]=this.result:r=this.result,--n||t(r)},a.readAsArrayBuffer(o)}else if(Sr(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!Ar(o))for(var l in o)e(o[l],l,o)}(r),n||t(r)},function(e){var t=cr.exports("socket.io-parser"),n=yr.exports,r=vr,o=wr,i=Cr;function s(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=s,e.Decoder=l;var a=e.ERROR+'"encode error"';function c(n){var r=""+n.type;if(e.BINARY_EVENT!==n.type&&e.BINARY_ACK!==n.type||(r+=n.attachments+"-"),n.nsp&&"/"!==n.nsp&&(r+=n.nsp+","),null!=n.id&&(r+=n.id),null!=n.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(n.data);if(!1===o)return a;r+=o}return t("encoded %j as %s",n,r),r}function l(){this.reconstructor=null}function u(e){this.reconPack=e,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}s.prototype.encode=function(n,o){(t("encoding packet %j",n),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type)?function(e,t){function n(e){var n=r.deconstructPacket(e),o=c(n.packet),i=n.buffers;i.unshift(o),t(i)}r.removeBlobs(e,n)}(n,o):o([c(n)])},n(l.prototype),l.prototype.add=function(n){var r;if("string"==typeof n)r=function(n){var r=0,i={type:Number(n.charAt(0))};if(null==e.types[i.type])return h("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s=r+1;"-"!==n.charAt(++r)&&r!=n.length;);var a=n.substring(s,r);if(a!=Number(a)||"-"!==n.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(a)}if("/"===n.charAt(r+1)){for(s=r+1;++r;){if(","===(l=n.charAt(r)))break;if(r===n.length)break}i.nsp=n.substring(s,r)}else i.nsp="/";var c=n.charAt(r+1);if(""!==c&&Number(c)==c){for(s=r+1;++r;){var l;if(null==(l=n.charAt(r))||Number(l)!=l){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==u&&(i.type===e.ERROR||o(u))))return h("invalid payload");i.data=u}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new u(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!i(n)&&!n.base64)throw new Error("Unknown type: "+n);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(n))&&(this.reconstructor=null,this.emit("decoded",r))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},u.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=r.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},u.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(ar);var Rr={exports:{}},Pr={},Br={exports:{}};try{Br.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){Br.exports=!1}var Nr,jr,Fr,Mr,Ur=Br.exports,Dr=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Ur))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){}},Lr={exports:{}},qr={},zr=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t};function $r(){if(Mr)return Fr;Mr=1;var e=function(){if(jr)return Nr;jr=1;var e={}.toString;return Nr=Array.isArray||function(t){return"[object Array]"==e.call(t)}}(),t=Object.prototype.toString,n="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===t.call(Blob),r="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===t.call(File);return Fr=function t(o){if(!o||"object"!=typeof o)return!1;if(e(o)){for(var i=0,s=o.length;i<s;i++)if(t(o[i]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(o)||"function"==typeof ArrayBuffer&&o instanceof ArrayBuffer||n&&o instanceof Blob||r&&o instanceof File)return!0;if(o.toJSON&&"function"==typeof o.toJSON&&1===arguments.length)return t(o.toJSON(),!0);for(var a in o)if(Object.prototype.hasOwnProperty.call(o,a)&&t(o[a]))return!0;return!1},Fr}var Hr=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},Vr=function(e,t,n){var r=!1;return n=n||Wr,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 Wr(){}
2
+ /*! https://mths.be/utf8js v2.1.2 by @mathias */var Kr,Qr,Jr,Xr=String.fromCharCode;function Yr(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 Gr(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 Zr(e,t){return Xr(e>>t&63|128)}function eo(e,t){if(0==(4294967168&e))return Xr(e);var n="";return 0==(4294965248&e)?n=Xr(e>>6&31|192):0==(4294901760&e)?(Gr(e,t)||(e=65533),n=Xr(e>>12&15|224),n+=Zr(e,6)):0==(4292870144&e)&&(n=Xr(e>>18&7|240),n+=Zr(e,12),n+=Zr(e,6)),n+=Xr(63&e|128)}function to(){if(Jr>=Qr)throw Error("Invalid byte index");var e=255&Kr[Jr];if(Jr++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function no(e){var t,n;if(Jr>Qr)throw Error("Invalid byte index");if(Jr==Qr)return!1;if(t=255&Kr[Jr],Jr++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|to())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|to()<<6|to())>=2048)return Gr(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|to()<<12|to()<<6|to())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var ro,oo,io,so={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Yr(e),o=r.length,i=-1,s="";++i<o;)s+=eo(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;Kr=Yr(e),Qr=Kr.length,Jr=0;for(var r,o=[];!1!==(r=no(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=Xr((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Xr(t);return o}(o)}},ao={};function co(){if(io)return oo;io=1;var e=void 0!==e?e:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,t=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),n=t&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),r=e&&e.prototype.append&&e.prototype.getBlob;function o(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 i(t,n){n=n||{};var r=new e;return o(t).forEach((function(e){r.append(e)})),n.type?r.getBlob(n.type):r.getBlob()}function s(e,t){return new Blob(o(e),t||{})}return"undefined"!=typeof Blob&&(i.prototype=Blob.prototype,s.prototype=Blob.prototype),oo=t?n?Blob:s:r?i:void 0}!function(e){var t,n=zr,r=$r(),o=Hr,i=Vr,s=so;"undefined"!=typeof ArrayBuffer&&(ro||(ro=1,function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=new Uint8Array(256),n=0;n<e.length;n++)t[e.charCodeAt(n)]=n;ao.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},ao.decode=function(e){var n,r,o,i,s,a=.75*e.length,c=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),h=new Uint8Array(u);for(n=0;n<c;n+=4)r=t[e.charCodeAt(n)],o=t[e.charCodeAt(n+1)],i=t[e.charCodeAt(n+2)],s=t[e.charCodeAt(n+3)],h[l++]=r<<2|o>>4,h[l++]=(15&o)<<4|i>>2,h[l++]=(3&i)<<6|63&s;return u}}()),t=ao);var a="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),c="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),l=a||c;e.protocol=3;var u=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},h=n(u),f={type:"error",data:"parser error"},d=co();function p(e,t,n){for(var r=new Array(e.length),o=i(e.length,n),s=function(e,n,o){t(n,(function(t,n){r[e]=n,o(t,r)}))},a=0;a<e.length;a++)s(a,e[a],o)}e.encodePacket=function(t,n,r,o){"function"==typeof n&&(o=n,n=!1),"function"==typeof r&&(o=r,r=null);var i=void 0===t.data?void 0:t.data.buffer||t.data;if("undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=u[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}(t,n,o);if(void 0!==d&&i instanceof d)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(l)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=new FileReader;return o.onload=function(){e.encodePacket({type:t.type,data:o.result},n,!0,r)},o.readAsArrayBuffer(t.data)}(t,n,r);var o=new Uint8Array(1);o[0]=u[t.type];var i=new d([o.buffer,t.data]);return r(i)}(t,n,o);if(i&&i.base64)return function(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}(t,o);var a=u[t.type];return void 0!==t.data&&(a+=r?s.encode(String(t.data),{strict:!1}):String(t.data)),o(""+a)},e.encodeBase64Packet=function(t,n){var r,o="b"+e.packets[t.type];if(void 0!==d&&t.data instanceof d){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(t.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];r=String.fromCharCode.apply(null,a)}return o+=btoa(r),n(o)},e.decodePacket=function(t,n,r){if(void 0===t)return f;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&!1===(t=function(e){try{e=s.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return f;var i=t.charAt(0);return Number(i)==i&&h[i]?t.length>1?{type:h[i],data:t.substring(1)}:{type:h[i]}:f}i=new Uint8Array(t)[0];var a=o(t,1);return d&&"blob"===n&&(a=new d([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&&d&&(o=new d([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 d&&!l?e.encodePayloadAsBlob(t,o):e.encodePayloadAsArrayBuffer(t,o);if(!t.length)return o("0:");p(t,(function(t,r){e.encodePacket(t,!!i&&n,!1,(function(e){r(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return o(t.join(""))}))},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);var o;if("function"==typeof n&&(r=n,n=null),""===t)return r(f,0,1);for(var i,s,a="",c=0,l=t.length;c<l;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return r(f,0,1);if(a!=(s=t.substr(c+1,i)).length)return r(f,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),f.type===o.type&&f.data===o.data)return r(f,0,1);if(!1===r(o,c+i,l))return}c+=i,a=""}else a+=u}return""!==a?r(f,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){if(!t.length)return n(new ArrayBuffer(0));p(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){p(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,d){var a=new d([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new d(t))}))},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var i=t,s=[];i.byteLength>0;){for(var a=new Uint8Array(i),c=0===a[0],l="",u=1;255!==a[u];u++){if(l.length>310)return r(f,0,1);l+=a[u]}i=o(i,2+l.length),l=parseInt(l);var h=o(i,0,l);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var d=new Uint8Array(h);h="";for(u=0;u<d.length;u++)h+=String.fromCharCode(d[u])}s.push(h),i=o(i,l)}var p=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,p)}))}}(qr);var lo,uo,ho={exports:{}};function fo(){if(uo)return lo;uo=1;var e=qr;function t(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}return lo=t,(0,ho.exports)(t.prototype),t.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},t.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},t.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},t.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},t.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},t.prototype.onData=function(t){var n=e.decodePacket(t,this.socket.binaryType);this.onPacket(n)},t.prototype.onPacket=function(e){this.emit("packet",e)},t.prototype.onClose=function(){this.readyState="closed",this.emit("close")},lo}!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}}(ho);var po,mo={};function go(){return po||(po=1,mo.encode=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},mo.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}),mo}var yo,vo=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},bo="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),wo={},Co=0,_o=0;function ko(e){var t="";do{t=bo[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function So(){var e=ko(+new Date);return e!==yo?(Co=0,yo=e):e+"."+ko(Co++)}for(;_o<64;_o++)wo[bo[_o]]=_o;So.encode=ko,So.decode=function(e){var t=0;for(_o=0;_o<e.length;_o++)t=64*t+wo[e.charAt(_o)];return t};var Ao=So,Eo={exports:{}},To={exports:{}},Io=1e3,xo=60*Io,Oo=60*xo,Ro=24*Oo,Po=365.25*Ro,Bo=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*Po;case"days":case"day":case"d":return n*Ro;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Oo;case"minutes":case"minute":case"mins":case"min":case"m":return n*xo;case"seconds":case"second":case"secs":case"sec":case"s":return n*Io;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 No(e,Ro,"day")||No(e,Oo,"hour")||No(e,xo,"minute")||No(e,Io,"second")||e+" ms"}(e):function(e){if(e>=Ro)return Math.round(e/Ro)+"d";if(e>=Oo)return Math.round(e/Oo)+"h";if(e>=xo)return Math.round(e/xo)+"m";if(e>=Io)return Math.round(e/Io)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function No(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Bo,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(To,To.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=To.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())}(Eo,Eo.exports);var jo=fo(),Fo=go(),Mo=qr,Uo=vo,Do=Ao,Lo=Eo.exports("engine.io-client:polling"),qo=$o,zo=null!=new Dr({xdomain:!1}).responseType;function $o(e){var t=e&&e.forceBase64;zo&&!t||(this.supportsBinary=!1),jo.call(this,e)}Uo($o,jo),$o.prototype.name="polling",$o.prototype.doOpen=function(){this.poll()},$o.prototype.pause=function(e){var t=this;function n(){Lo("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(Lo("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){Lo("pre-pause polling complete"),--r||n()}))),this.writable||(Lo("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){Lo("pre-pause writing complete"),--r||n()})))}else n()},$o.prototype.poll=function(){Lo("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},$o.prototype.onData=function(e){var t=this;Lo("polling got data %s",e);Mo.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():Lo('ignoring poll - transport state "%s"',this.readyState))},$o.prototype.doClose=function(){var e=this;function t(){Lo("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Lo("transport open - closing"),t()):(Lo("transport not open - deferring close"),this.once("open",t))},$o.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};Mo.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},$o.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=Do()),this.supportsBinary||e.sid||(e.b64=1),e=Fo.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 Ho=Dr,Vo=qo,Wo=ho.exports,Ko=vo,Qo=Eo.exports("engine.io-client:polling-xhr");function Jo(){}function Xo(e){if(Vo.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 Yo(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(Lr.exports=Xo,Lr.exports.Request=Yo,Ko(Xo,Vo),Xo.prototype.supportsBinary=!0,Xo.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 Yo(e)},Xo.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},Xo.prototype.doPoll=function(){Qo("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},Wo(Yo.prototype),Yo.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 Ho(e),n=this;try{Qo("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))},Qo("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Yo.requestsCount++,Yo.requests[this.index]=this)},Yo.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},Yo.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},Yo.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},Yo.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Jo:this.xhr.onreadystatechange=Jo,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Yo.requests[this.index],this.xhr=null}},Yo.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)},Yo.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},Yo.prototype.abort=function(){this.cleanup()},Yo.requestsCount=0,Yo.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Zo);else if("function"==typeof addEventListener){var Go="onpagehide"in self?"pagehide":"unload";addEventListener(Go,Zo,!1)}function Zo(){for(var e in Yo.requests)Yo.requests.hasOwnProperty(e)&&Yo.requests[e].abort()}var ei,ti=qo,ni=ai,ri=/\n/g,oi=/\\n/g;function ii(){}function si(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==_e?_e:{}}function ai(e){if(ti.call(this,e),this.query=this.query||{},!ei){var t=si();ei=t.___eio=t.___eio||[]}this.index=ei.length;var n=this;ei.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=ii)}),!1)}vo(ai,ti),ai.prototype.supportsBinary=!1,ai.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),ti.prototype.doClose.call(this)},ai.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)},ai.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(oi,"\\\n"),this.area.value=e.replace(ri,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var ci,li,ui=Se(Object.freeze({__proto__:null,default:{}})),hi=fo(),fi=qr,di=go(),pi=vo,mi=Ao,gi=Eo.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)ci=WebSocket;else if("undefined"!=typeof self)ci=self.WebSocket||self.MozWebSocket;else try{li=ui}catch(e){}var yi=ci||li,vi=bi;function bi(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=ci&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(yi=li),hi.call(this,e)}pi(bi,hi),bi.prototype.name="websocket",bi.prototype.supportsBinary=!0,bi.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 yi(e,t):new yi(e):new yi(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()}},bi.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)}},bi.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){fi.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){gi("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},bi.prototype.onClose=function(){hi.prototype.onClose.call(this)},bi.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},bi.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]=mi()),this.supportsBinary||(e.b64=1),(e=di.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},bi.prototype.check=function(){return!(!yi||"__initialize"in yi&&this.name===bi.prototype.name)};var wi=Dr,Ci=Lr.exports,_i=ni,ki=vi;Pr.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 wi(e)&&!e.forceJSONP)return new Ci(e);if(!r)throw new Error("JSONP disabled");return new _i(e)},Pr.websocket=ki;var Si=[].indexOf,Ai=function(e,t){if(Si)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},Ei=Pr,Ti=ho.exports,Ii=Eo.exports("engine.io-client:socket"),xi=Ai,Oi=qr,Ri=Qn,Pi=go(),Bi=Ni;function Ni(e,t){if(!(this instanceof Ni))return new Ni(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=Ri(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=Ri(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=Pi.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()}Ni.priorWebsocketSuccess=!1,Ti(Ni.prototype),Ni.protocol=Oi.protocol,Ni.Socket=Ni,Ni.Transport=fo(),Ni.transports=Pr,Ni.parser=qr,Ni.prototype.createTransport=function(e){Ii('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=Oi.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new Ei[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})},Ni.prototype.open=function(){var e;if(this.rememberUpgrade&&Ni.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)},Ni.prototype.setTransport=function(e){Ii("setting transport %s",e.name);var t=this;this.transport&&(Ii("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")}))},Ni.prototype.probe=function(e){Ii('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||(Ii('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(Ii('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;Ni.priorWebsocketSuccess="websocket"===t.name,Ii('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(Ii("changing transport and sending upgrade packet"),u(),r.setTransport(t),t.send([{type:"upgrade"}]),r.emit("upgrade",t),t=null,r.upgrading=!1,r.flush())}))}else{Ii('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,r.emit("upgradeError",i)}})))}function i(){n||(n=!0,u(),t.close(),t=null)}function s(n){var o=new Error("probe error: "+n);o.transport=t.name,i(),Ii('probe transport "%s" failed because of error: %s',e,n),r.emit("upgradeError",o)}function a(){s("transport closed")}function c(){s("socket closed")}function l(e){t&&e.name!==t.name&&(Ii('"%s" works - aborting "%s"',e.name,t.name),i())}function u(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),r.removeListener("close",c),r.removeListener("upgrading",l)}Ni.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()},Ni.prototype.onOpen=function(){if(Ii("socket open"),this.readyState="open",Ni.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){Ii("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},Ni.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(Ii('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 Ii('packet received with socket readyState "%s"',this.readyState)},Ni.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))},Ni.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)},Ni.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){Ii("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},Ni.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},Ni.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},Ni.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(Ii("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},Ni.prototype.write=Ni.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},Ni.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()}},Ni.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"),Ii("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},Ni.prototype.onError=function(e){Ii("socket error %j",e),Ni.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},Ni.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){Ii('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}},Ni.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~xi(this.transports,e[n])&&t.push(e[n]);return t},function(e){e.exports=Bi,e.exports.parser=qr}(Rr);var ji,Fi,Mi={exports:{}},Ui={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}}(Ui);var Di=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var Li,qi=[].slice,zi=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=qi.call(arguments,2);return function(){return t.apply(e,n.concat(qi.call(arguments)))}};function $i(){return Li||(Li=1,function(e,t){var n=ar,r=Ui.exports,o=(Fi||(Fi=1,ji=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n}),ji),i=Di,s=zi,a=Jn.exports("socket.io-client:socket"),c=go(),l=$r();e.exports=f;var u={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},h=r.prototype.emit;function f(e,t,n){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}r(f.prototype),f.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[i(e,"open",s(this,"onopen")),i(e,"packet",s(this,"onpacket")),i(e,"close",s(this,"onclose"))]}},f.prototype.open=f.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},f.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},f.prototype.emit=function(e){if(u.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:l(t))?n.BINARY_EVENT:n.EVENT,data:t,options:{}};return r.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=t.pop(),r.id=this.ids++),this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this},f.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},f.prototype.onopen=function(){if(a("transport is open - connecting"),"/"!==this.nsp)if(this.query){var e="object"==typeof this.query?c.encode(this.query):this.query;a("sending connect packet with query %s",e),this.packet({type:n.CONNECT,query:e})}else this.packet({type:n.CONNECT})},f.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},f.prototype.onpacket=function(e){var t=e.nsp===this.nsp,r=e.type===n.ERROR&&"/"===e.nsp;if(t||r)switch(e.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(e);break;case n.ACK:case n.BINARY_ACK:this.onack(e);break;case n.DISCONNECT:this.ondisconnect();break;case n.ERROR:this.emit("error",e.data)}},f.prototype.onevent=function(e){var t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?h.apply(this,t):this.receiveBuffer.push(t)},f.prototype.ack=function(e){var t=this,r=!1;return function(){if(!r){r=!0;var i=o(arguments);a("sending ack %j",i),t.packet({type:l(i)?n.BINARY_ACK:n.ACK,id:e,data:i})}}},f.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)},f.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},f.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)h.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},f.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},f.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},f.prototype.close=f.prototype.disconnect=function(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:n.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},f.prototype.compress=function(e){return this.flags.compress=e,this},f.prototype.binary=function(e){return this.flags.binary=e,this}}(Mi)),Mi.exports}var Hi=Vi;function Vi(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}Vi.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)},Vi.prototype.reset=function(){this.attempts=0},Vi.prototype.setMin=function(e){this.ms=e},Vi.prototype.setMax=function(e){this.max=e},Vi.prototype.setJitter=function(e){this.jitter=e};var Wi=Rr.exports,Ki=$i(),Qi=Ui.exports,Ji=ar,Xi=Di,Yi=zi,Gi=Jn.exports("socket.io-client:manager"),Zi=Ai,es=Hi,ts=Object.prototype.hasOwnProperty,ns=rs;function rs(e,t){if(!(this instanceof rs))return new rs(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 es({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||Ji;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}rs.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)ts.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},rs.prototype.updateSocketIds=function(){for(var e in this.nsps)ts.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},rs.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Qi(rs.prototype),rs.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},rs.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},rs.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},rs.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},rs.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},rs.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},rs.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},rs.prototype.open=rs.prototype.connect=function(e,t){if(Gi("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Gi("opening %s",this.uri),this.engine=Wi(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=Xi(n,"open",(function(){r.onopen(),e&&e()})),i=Xi(n,"error",(function(t){if(Gi("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;Gi("connect attempt will timeout after %d",s);var a=setTimeout((function(){Gi("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},rs.prototype.onopen=function(){Gi("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(Xi(e,"data",Yi(this,"ondata"))),this.subs.push(Xi(e,"ping",Yi(this,"onping"))),this.subs.push(Xi(e,"pong",Yi(this,"onpong"))),this.subs.push(Xi(e,"error",Yi(this,"onerror"))),this.subs.push(Xi(e,"close",Yi(this,"onclose"))),this.subs.push(Xi(this.decoder,"decoded",Yi(this,"ondecoded")))},rs.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},rs.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},rs.prototype.ondata=function(e){this.decoder.add(e)},rs.prototype.ondecoded=function(e){this.emit("packet",e)},rs.prototype.onerror=function(e){Gi("error",e),this.emitAll("error",e)},rs.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new Ki(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(){~Zi(r.connecting,n)||r.connecting.push(n)}return n},rs.prototype.destroy=function(e){var t=Zi(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},rs.prototype.packet=function(e){Gi("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()})))},rs.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},rs.prototype.cleanup=function(){Gi("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()},rs.prototype.close=rs.prototype.disconnect=function(){Gi("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},rs.prototype.onclose=function(e){Gi("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},rs.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Gi("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Gi("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Gi("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Gi("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Gi("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},rs.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=sr,r=ar,o=ns,i=Jn.exports("socket.io-client");e.exports=t=a;var s=t.managers={};function a(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,a=n(e),c=a.source,l=a.id,u=a.path,h=s[l]&&u in s[l].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),r=o(c,t)):(s[l]||(i("new io instance for %s",c),s[l]=o(c,t)),r=s[l]),a.query&&!t.query&&(t.query=a.query),r.socket(a.path,t)}t.protocol=r.protocol,t.connect=a,t.Manager=ns,t.Socket=$i()}(Vn,Vn.exports);var os=Vn.exports;function is(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 ss={exports:{}};!function(e,t){e.exports=function(){function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(!a&&is)return is(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[s]={exports:{}};t[s][0].call(l.exports,(function(e){return o(t[s][1][e]||e)}),l,l.exports,e,t,n,r)}return n[s].exports}for(var i=is,s=0;s<r.length;s++)o(r[s]);return o}return e}()({1:[function(e,t,n){(function(n,r){(function(){const o=e("events").EventEmitter,i=e("./store"),s=e("./topic-alias-recv"),a=e("./topic-alias-send"),c=e("mqtt-packet"),l=e("./default-message-id-provider"),u=e("readable-stream").Writable,h=e("inherits"),f=e("reinterval"),d=e("rfdc/default"),p=e("./validations"),m=e("xtend"),g=e("debug")("mqttjs:client"),y=n?n.nextTick:function(e){setTimeout(e,0)},v=r.setImmediate||function(e){y(e)},b={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},w=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],C={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function _(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function k(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let n;t.properties&&(n=t.properties.topicAlias);const r=t.topic.toString();if(e.topicAliasSend)if(n){if(0!==r.length&&(g("applyTopicAlias :: register topic: %s - alias: %d",r,n),!e.topicAliasSend.put(r,n)))return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",r,n),new Error("Sending Topic Alias out of range")}else 0!==r.length&&(e.options.autoAssignTopicAlias?(n=e.topicAliasSend.getAliasByTopic(r),n?(t.topic="",t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",r,n)):(n=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(r,n),t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto assign topic: %s - alias: %d",r,n))):e.options.autoUseTopicAlias&&(n=e.topicAliasSend.getAliasByTopic(r),n&&(t.topic="",t.properties={...t.properties,topicAlias:n},g("applyTopicAlias :: auto use topic: %s - alias: %d",r,n))));else if(n)return g("applyTopicAlias :: error out of range. topic: %s - alias: %d",r,n),new Error("Sending Topic Alias out of range")}}function S(e,t){let n;t.properties&&(n=t.properties.topicAlias);let r=t.topic.toString();if(0===r.length){if(void 0===n)return new Error("Unregistered Topic Alias");if(r=e.topicAliasSend.getTopicByAlias(n),void 0===r)return new Error("Unregistered Topic Alias");t.topic=r}n&&delete t.properties.topicAlias}function A(e,t,n){g("sendPacket :: packet: %O",t),g("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),g("sendPacket :: writing to stream");const r=c.writeToStream(t,e.stream,e.options);g("sendPacket :: writeToStream result %s",r),!r&&n&&n!==x?(g("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(g("sendPacket :: invoking cb"),n())}function E(e){e&&(g("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function T(e){e&&(g("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function I(e,t,n,r){g("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let o,i=t;if("publish"===i.cmd&&(i=d(t),o=S(e,i),o))return n&&n(o);e.outgoingStore.put(i,(function(o){if(o)return n&&n(o);r(),A(e,t,n)}))}function x(e){g("nop ::",e)}function O(e,t){let n;const r=this;if(!(this instanceof O))return new O(e,t);for(n in this.options=t||{},b)void 0===this.options[n]?this.options[n]=b[n]:this.options[n]=t[n];g("MqttClient :: options.protocol",t.protocol),g("MqttClient :: options.protocolVersion",t.protocolVersion),g("MqttClient :: options.username",t.username),g("MqttClient :: options.keepalive",t.keepalive),g("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),g("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),g("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:_(),g("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new l:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new i,this.incomingStore=t.incomingStore||new i,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?g("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;function t(){const n=e.shift();g("deliver :: entry %o",n);let o=null;if(!n)return void r._resubscribe();o=n.packet,g("deliver :: call _sendPacket for %o",o);let i=!0;o.messageId&&0!==o.messageId&&(r.messageIdProvider.register(o.messageId)||(i=!1)),i?r._sendPacket(o,(function(e){n.cb&&n.cb(e),t()})):(g("messageId: %d has already used. The message is skipped and removed.",o.messageId),t())}g("connect :: sending queued packets"),t()})),this.on("close",(function(){g("close :: connected set to `false`"),this.connected=!1,g("close :: clearing connackTimer"),clearTimeout(this.connackTimer),g("close :: clearing ping timer"),null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),g("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),g("MqttClient :: setting up stream"),this._setupStream()}h(O,o),O.prototype._setupStream=function(){const e=this,t=new u,n=c.parser(this.options);let r=null;const o=[];function i(){if(o.length)y(s);else{const e=r;r=null,e()}}function s(){g("work :: getting next packet in queue");const t=o.shift();if(t)g("work :: packet pulled from queue"),e._handlePacket(t,i);else{g("work :: no packets in queue");const e=r;r=null,g("work :: done flag is %s",!!e),e&&e()}}function a(t){g("streamErrorHandler :: error",t.message),w.includes(t.code)?(g("streamErrorHandler :: emitting error"),e.emit("error",t)):x(t)}g("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),g("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),n.on("packet",(function(e){g("parser :: on packet push to packets array."),o.push(e)})),t._write=function(e,t,o){r=o,g("writable stream :: parsing buffer"),n.parse(e),s()},g("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",a),this.stream.on("close",(function(){g("(%s)stream :: on close",e.options.clientId),T(e.outgoing),g("stream: emit close to MqttClient"),e.emit("close")})),g("_setupStream: sending packet `connect`");const l=Object.create(this.options);if(l.cmd="connect",this.topicAliasRecv&&(l.properties||(l.properties={}),this.topicAliasRecv&&(l.properties.topicAliasMaximum=this.topicAliasRecv.max)),A(this,l),n.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&A(this,m({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){g("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)}),this.options.connectTimeout)},O.prototype._handlePacket=function(e,t){const n=this.options;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(g("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},O.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==x?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},O.prototype.publish=function(e,t,n,r){g("publish :: message `%s` to topic `%s`",t,e);const o=this.options;if("function"==typeof n&&(r=n,n=null),n=m({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;const i=this,s=function(){let s=0;if((1===n.qos||2===n.qos)&&(s=i._nextId(),null===s))return g("No messageId left"),!1;const a={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:s,dup:n.dup};switch(5===o.protocolVersion&&(a.properties=n.properties),g("publish :: qos",n.qos),n.qos){case 1:case 2:i.outgoing[a.messageId]={volatile:!1,cb:r||x},g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,void 0,n.cbStorePut);break;default:g("MqttClient:publish: packet cmd: %s",a.cmd),i._sendPacket(a,r,n.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:n.cbStorePut,callback:r}),this},O.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const n=[];let r=t.shift();const o=r.resubscribe;let i=t.pop()||x,s=t.pop();const a=this.options.protocolVersion;delete r.resubscribe,"string"==typeof r&&(r=[r]),"function"!=typeof i&&(s=i,i=x);const c=p.validateTopics(r);if(null!==c)return v(i,new Error("Invalid topic "+c)),this;if(this._checkDisconnecting(i))return g("subscribe: discconecting true"),this;const l={qos:0};if(5===a&&(l.nl=!1,l.rap=!1,l.rh=0),s=m(l,s),Array.isArray(r)?r.forEach((function(t){if(g("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||o){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),g("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),n.push(e)}})):Object.keys(r).forEach((function(t){if(g("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<r[t].qos||o){const e={topic:t,qos:r[t].qos};5===a&&(e.nl=r[t].nl,e.rap=r[t].rap,e.rh=r[t].rh,e.properties=s.properties),g("subscribe: pushing `%s` to subs list",e),n.push(e)}})),!n.length)return i(null,[]),this;const u=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const r={cmd:"subscribe",subscriptions:n,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(r.properties=s.properties),e.options.resubscribe){g("subscribe :: resubscribe true");const t=[];n.forEach((function(n){if(e.options.reconnectPeriod>0){const r={qos:n.qos};5===a&&(r.nl=n.nl||!1,r.rap=n.rap||!1,r.rh=n.rh||0,r.properties=n.properties),e._resubscribeTopics[n.topic]=r,t.push(n.topic)}})),e.messageIdToTopic[r.messageId]=t}return e.outgoing[r.messageId]={volatile:!0,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)n[t].qos=e[t]}i(e,n)}},g("subscribe :: call _sendPacket"),e._sendPacket(r),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!u())&&this._storeProcessingQueue.push({invoke:u,callback:i}),this},O.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let n=t.shift(),r=t.pop()||x,o=t.pop();"string"==typeof n&&(n=[n]),"function"!=typeof r&&(o=r,r=x);const i=p.validateTopics(n);if(null!==i)return v(r,new Error("Invalid topic "+i)),this;if(e._checkDisconnecting(r))return this;const s=function(){const t=e._nextId();if(null===t)return g("No messageId left"),!1;const i={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof n?i.unsubscriptions=[n]:Array.isArray(n)&&(i.unsubscriptions=n),e.options.resubscribe&&i.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t]})),"object"==typeof o&&o.properties&&(i.properties=o.properties),e.outgoing[i.messageId]={volatile:!0,cb:r},g("unsubscribe: call _sendPacket"),e._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:r}),this},O.prototype.end=function(e,t,n){const r=this;function o(){g("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(g("end :: closeStores: emitting end"),r.emit("end"),n){const r=e||t;g("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){g("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{g("end :: finish :: calling process.nextTick on closeStores"),y(o.bind(r))}),t)}return g("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||x,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=x))),"object"!=typeof t&&(n=t,t=null),g("end :: cb? %s",!!n),n=n||x,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(g("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(g("end :: (%s) :: immediately calling finish",r.options.clientId),i()),this)},O.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},O.prototype.reconnect=function(e){g("client reconnect");const t=this,n=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new i,t.outgoingStore=t.options.outgoingStore||new i,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},O.prototype._reconnect=function(){g("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),g("client already connected. disconnecting first.")):(g("_reconnect: calling _setupStream"),this._setupStream())},O.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(g("_setupReconnect :: emit `offline` state"),this.emit("offline"),g("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),g("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){g("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):g("_setupReconnect :: doing nothing...")},O.prototype._clearReconnect=function(){g("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},O.prototype._cleanUp=function(e,t){const n=arguments[2];if(t&&(g("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),g("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&E(this.outgoing),g("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=m({cmd:"disconnect"},n);g("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,v.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(g("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(g("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(g("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},O.prototype._sendPacket=function(e,t,n){g("_sendPacket :: (%s) :: start",this.options.clientId),n=n||x,t=t||x;const r=k(this,e);if(r)t(r);else{if(!this.connected)return"auth"===e.cmd?(this._shiftPingInterval(),void A(this,e,t)):(g("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,n));switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void I(this,e,t,n);default:return void A(this,e,t)}switch(e.qos){case 2:case 1:I(this,e,t,n);break;default:A(this,e,t)}g("_sendPacket :: (%s) :: end",this.options.clientId)}},O.prototype._storePacket=function(e,t,n){g("_storePacket :: packet: %o",e),g("_storePacket :: cb? %s",!!t),n=n||x;let r=e;if("publish"===r.cmd){r=d(e);const n=S(this,r);if(n)return t&&t(n)}0===(r.qos||0)&&this.queueQoSZero||"publish"!==r.cmd?this.queue.push({packet:r,cb:t}):r.qos>0?(t=this.outgoing[r.messageId]?this.outgoing[r.messageId].cb:null,this.outgoingStore.put(r,(function(e){if(e)return t&&t(e);n()}))):t&&t(new Error("No connection to broker"))},O.prototype._setupPingTimer=function(){g("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=f((function(){e._checkPing()}),1e3*this.options.keepalive))},O.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},O.prototype._checkPing=function(){g("_checkPing :: checking ping..."),this.pingResp?(g("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(g("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},O.prototype._handlePingresp=function(){this.pingResp=!0},O.prototype._handleConnack=function(e){g("_handleConnack");const t=this.options,n=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(0===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){const e=new Error("Connection refused: "+C[n]);e.code=n,this.emit("error",e)}},O.prototype._handleAuth=function(e){const t=this.options.protocolVersion,n=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=n,void this.emit("error",e)}const r=this;this.handleAuth(e,(function(e,t){if(e)r.emit("error",e);else if(24===n)r.reconnecting=!1,r._sendPacket(t);else{const t=new Error("Connection refused: "+C[n]);e.code=n,r.emit("error",t)}}))},O.prototype.handleAuth=function(e,t){t()},O.prototype._handlePublish=function(e,t){g("_handlePublish: packet %o",e),t=void 0!==t?t:x;let n=e.topic.toString();const r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===n.length){if(!(t>0&&t<=65535))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return g("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));n=e,g("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",n,t)}}else{if(!this.topicAliasRecv.put(n,t))return g("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));g("_handlePublish :: registered topic: %s - alias: %d",n,t)}}switch(g("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(n,r,e,(function(n,r){return n instanceof Error||(r=n,n=null),n?s.emit("error",n):-1===c.indexOf(r)?s.emit("error",new Error("Wrong reason code for pubrec")):void(r?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:r},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(n,r,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",n,r,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},t)})))}));break;case 0:this.emit("message",n,r,e),this.handleMessage(e,t);break;default:g("_handlePublish: unknown QoS. Doing nothing.")}},O.prototype.handleMessage=function(e,t){t()},O.prototype._handleAck=function(e){const t=e.messageId,n=e.cmd;let r=null;const o=this.outgoing[t]?this.outgoing[t].cb:null,i=this;let s;if(o){switch(g("_handleAck :: packet type",n),n){case"pubcomp":case"puback":{const n=e.reasonCode;n&&n>0&&16!==n&&(s=new Error("Publish error: "+C[n]),s.code=n,o(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,o),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case"pubrec":{r={cmd:"pubrel",qos:2,messageId:t};const n=e.reasonCode;n&&n>0&&16!==n?(s=new Error("Publish error: "+C[n]),s.code=n,o(s,e)):this._sendPacket(r);break}case"suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let n=0;n<e.granted.length;n++)if(0!=(128&e.granted[n])){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete i._resubscribeTopics[e]}))}this._invokeStoreProcessingQueue(),o(null,e);break;case"unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),o(null);break;default:i.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else g("_handleAck :: Server sent an ack in error. Ignoring.")},O.prototype._handlePubrel=function(e,t){g("handling pubrel packet"),t=void 0!==t?t:x;const n=e.messageId,r=this,o={cmd:"pubcomp",messageId:n};r.incomingStore.get(e,(function(e,n){e?r._sendPacket(o,t):(r.emit("message",n.topic,n.payload,n),r.handleMessage(n,(function(e){if(e)return t(e);r.incomingStore.del(n,x),r._sendPacket(o,t)})))}))},O.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},O.prototype._nextId=function(){return this.messageIdProvider.allocate()},O.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},O.prototype._resubscribe=function(){g("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){g("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const n={};n[e[t]]=this._resubscribeTopics[e[t]],n.resubscribe=!0,this.subscribe(n,{properties:n[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},O.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;function n(){let r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,t._flushStoreProcessingQueue(),o()}function s(){if(!r)return;t._storeProcessing=!0;const e=r.read(1);let n;e?t._packetIdsDuringStoreProcessing[e.messageId]?s():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(n=t.outgoing[e.messageId]?t.outgoing[e.messageId].cb:null,t.outgoing[e.messageId]={volatile:!1,cb:function(e,t){n&&n(e,t),s()}},t._packetIdsDuringStoreProcessing[e.messageId]=!0,t.messageIdProvider.register(e.messageId)?t._sendPacket(e):g("messageId: %d has already used.",e.messageId)):r.once("readable",s)}t.once("close",i),r.on("error",(function(e){o(),t._flushStoreProcessingQueue(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){let r=!0;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){r=!1;break}r?(o(),t.removeListener("close",i),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):n()})),s()}this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,n()},O.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},O.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},O.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},t.exports=O}).call(this)}).call(this,e("_process"),void 0!==_e?_e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(e,t,n){const{Buffer:r}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c,l=!1;function u(){const e=new o;return e._write=function(e,t,n){s.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){s.closeSocket({success:function(){e()}})},e}function h(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function f(e,t){const n="alis"===e.protocol?"wss":"ws";let r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function d(){l||(l=!0,s.onSocketOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=r.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?r.from(e):r.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((function(){c.end(),c.destroy()})),s.onSocketError((function(e){c.destroy(e)})))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";h(t);const r=f(t,e);return s=t.my,s.connectSocket({url:r,protocols:n}),a=u(),c=i.obj(),d(),c}t.exports=p},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(e,t,n){const r=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const n=t.port,i=t.hostname;return o("port %d and host %s",n,i),r.createConnection(n,i)}t.exports=i},{debug:18,net:16}],4:[function(e,t,n){const r=e("tls"),o=e("net"),i=e("debug")("mqttjs:tls");function s(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===o.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,i("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const n=r.connect(t);function s(r){t.rejectUnauthorized&&e.emit("error",r),n.end()}return n.on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",s)})),n.on("error",s),n}t.exports=s},{debug:18,net:16,tls:16}],5:[function(e,t,n){(function(n){(function(){const{Buffer:r}=e("buffer"),o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform,c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],l=void 0!==n&&"browser"===n.title||"function"==typeof __webpack_require__;function u(e,t){let n=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function h(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),l||"wss"!==e.protocol||c.forEach((function(n){Object.prototype.hasOwnProperty.call(e,n)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,n)&&(t.wsOptions[n]=e[n])})),t}function f(e){const t=h(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}function d(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 p(e,t){const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",r=u(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");const n=h(t),r=u(n,e),s=d(e,r,n),a=o.createWebSocketStream(s,n.wsOptions);return a.url=r,s.on("close",(()=>{a.destroy()})),a}function g(e,t){let n;i("browserStreamBuilder");const o=f(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,l=!t.objectMode,u=p(e,t),h=m(t,C,_);t.objectMode||(h._writev=w),h.on("close",(()=>{u.close()}));const d=void 0!==u.addEventListener;function m(e,t,n){const r=new a({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}function g(){n.setReadable(h),n.setWritable(h),n.emit("connect")}function y(){n.end(),n.destroy()}function v(e){n.destroy(e)}function b(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),h.push(t)}function w(e,t){const n=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?n[t]=r.from(e[t],"utf8"):n[t]=e[t].chunk;this._write(r.concat(n),"binary",t)}function C(e,t,n){u.bufferedAmount>o&&setTimeout(C,c,e,t,n),l&&"string"==typeof e&&(e=r.from(e,"utf8"));try{u.send(e)}catch(e){return n(e)}n()}function _(e){u.close(),e()}return u.readyState===u.OPEN?n=h:(n=n=s(void 0,void 0,t),t.objectMode||(n._writev=w),d?u.addEventListener("open",g):u.onopen=g),n.socket=u,d?(u.addEventListener("close",y),u.addEventListener("error",v),u.addEventListener("message",b)):(u.onclose=y,u.onerror=v,u.onmessage=b),n}t.exports=l?g:m}).call(this)}).call(this,e("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(e,t,n){const{Buffer:r}=e("buffer"),o=e("readable-stream").Transform,i=e("duplexify");let s,a,c;function l(){const e=new o;return e._write=function(e,t,n){s.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){s.close({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){const n="wxs"===e.protocol?"wss":"ws";let r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function f(){s.onOpen((function(){c.setReadable(a),c.setWritable(a),c.emit("connect")})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),a.push(t)})),s.onClose((function(){c.end(),c.destroy()})),s.onError((function(e){c.destroy(new Error(e.errMsg))}))}function d(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);const r=h(t,e);s=wx.connectSocket({url:r,protocols:[n]}),a=l(),c=i.obj(),c._destroy=function(e,t){s.close({success:function(){t&&t(e)}})};const o=c.destroy;return c.destroy=function(){c.destroy=o;const e=this;setTimeout((function(){s.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(c),f(),c}t.exports=d},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(e,t,n){function r(){if(!(this instanceof r))return new r;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}r.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},r.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},r.prototype.register=function(e){return!0},r.prototype.deallocate=function(e){},r.prototype.clear=function(){},t.exports=r},{}],8:[function(e,t,n){const r=e("xtend"),o=e("readable-stream").Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=r(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new o(i),t=[];let n=!1,r=0;return this._inflights.forEach((function(e,n){t.push(e)})),e._read=function(){!n&&r<t.length?this.push(t[r++]):this.push(null)},e.destroy=function(){if(n)return;const e=this;n=!0,setTimeout((function(){e.emit("close")}),0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=a},{"readable-stream":69,xtend:81}],9:[function(e,t,n){function r(e){if(!(this instanceof r))return new r(e);this.aliasToTopic={},this.max=e}r.prototype.put=function(e,t){return!(0===t||t>this.max||(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,0))},r.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},r.prototype.clear=function(){this.aliasToTopic={}},t.exports=r},{}],10:[function(e,t,n){const r=e("lru-cache"),o=e("number-allocator").NumberAllocator;function i(e){if(!(this instanceof i))return new i(e);e>0&&(this.aliasToTopic=new r({max:e}),this.topicToAlias={},this.numberAllocator=new o(1,e),this.max=e,this.length=0)}i.prototype.put=function(e,t){if(0===t||t>this.max)return!1;const n=this.aliasToTopic.get(t);return n&&delete this.topicToAlias[n],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},i.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},i.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},i.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},i.prototype.getLruAlias=function(){const e=this.numberAllocator.firstVacant();return e||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},t.exports=i},{"lru-cache":37,"number-allocator":46}],11:[function(e,t,n){function r(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(let t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],12:[function(e,t,n){(function(n){(function(){const r=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function l(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function u(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const n=i.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=s(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(l(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!c[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,n){return(!e||n%2!=0)&&"function"==typeof c[t]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function n(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a("calling streambuilder for",t.protocol),c[t.protocol](e,t)}t.protocol&&(t.defaultProtocol=t.protocol);const o=new r(n,t);return o.on("error",(function(){})),o}void 0!==n&&"browser"!==n.title||"function"!=typeof __webpack_require__?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=u,t.exports.connect=u,t.exports.MqttClient=r,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":8,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:50,debug:18,url:76,xtend:81}],13:[function(e,t,n){n.byteLength=u,n.toByteArray=f,n.fromByteArray=m;for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e){var t=l(e),n=t[0],r=t[1];return 3*(n+r)/4-r}function h(e,t,n){return 3*(t+n)/4-n}function f(e){var t,n,r=l(e),s=r[0],a=r[1],c=new i(h(e,s,a)),u=0,f=a>0?s-4:s;for(n=0;n<f;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[u++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c}function d(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function p(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(d(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(p(e,a,a+s>c?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],14:[function(e,t,n){const{Buffer:r}=e("buffer"),o=Symbol.for("BufferList");function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},i.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},i.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,n,o){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof o||o>this.length)&&(o=this.length),n>=this.length)return e||r.alloc(0);if(o<=0)return e||r.alloc(0);const i=!!e,s=this._offset(n),a=o-n;let c=a,l=i&&t||0,u=s[1];if(0===n&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,l),l+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-u)return i?this._bufs[s[0]].copy(e,t,u,u+c):this._bufs[s[0]].slice(u,u+c);i||(e=r.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const n=this._bufs[t].length-u;if(!(c>n)){this._bufs[t].copy(e,l,u,u+c),l+=n;break}this._bufs[t].copy(e,l,u),l+=n,c-=n,u&&(u=0)}return e.length>l?e.slice(0,l):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),o=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,r[1]),0!==n[1]&&(o[0]=o[0].slice(n[1])),this._new(o)},i.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(r.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(r.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const t=this._bufs[i];for(;s<t.length;)if(t.length-s>=e.length){const n=t.indexOf(e,s);if(-1!==n)return this._reverseOffset([i,n]);s=t.length-e.length+1}else{const t=this._reverseOffset([i,s]);if(this._match(t,e))return t;s++}s=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let n=0;n<t.length;n++)if(this.get(e+n)!==t[n])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){null===e[t]?i.prototype[t]=function(e,n){return this.slice(e,e+n)[t](0,n)}:i.prototype[t]=function(n=0){return this.slice(n,n+e[t])[t](0)}}(t)}(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return null!=e&&e[o]},t.exports=i},{buffer:17}],15:[function(e,t,n){const r=e("readable-stream").Duplex,o=e("inherits"),i=e("./BufferList");function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}i._init.call(this,e),r.call(this)}o(s,r),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){r.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof i||s.isBufferList(e)},s.isBufferList=i.isBufferList,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(e,t,n){},{}],17:[function(e,t,n){(function(t){(function(){var t=e("base64-js"),r=e("ieee754");n.Buffer=a,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return f(e,t);if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return p(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return a.from(r,t,n);var o=m(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e,t,n){return l(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}function h(e){return l(e),s(e<0?0:0|g(e))}function f(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|v(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function d(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 p(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||Y(e.length)?s(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Q(e).length;default:if(o)return r?-1:V(e).length;t=(""+t).toLowerCase(),o=!0}}function b(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,n);case"utf8":case"utf-8":return O(this,t,n);case"ascii":return B(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return x(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function C(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Y(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:_(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):_(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function _(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var u=-1;for(i=n;i<a;i++)if(l(e,i)===l(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,f=0;f<c;f++)if(l(e,i+f)!==l(t,f)){h=!1;break}if(h)return i}return-1}function k(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(Y(a))return s;e[n+s]=a}return s}function S(e,t,n,r){return J(V(t,e.length-n),e,n,r)}function A(e,t,n,r){return J(W(t),e,n,r)}function E(e,t,n,r){return A(e,t,n,r)}function T(e,t,n,r){return J(Q(t),e,n,r)}function I(e,t,n,r){return J(K(t,e.length-n),e,n,r)}function x(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function O(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,l=e[o],u=null,h=l>239?4:l>223?3:l>191?2:1;if(o+h<=n)switch(h){case 1:l<128&&(u=l);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&l)<<6|63&i)>127&&(u=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&l)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,h=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=h}return P(r)}n.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,n){return c(e,t,n)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,n){return u(e,t,n)},a.allocUnsafe=function(e){return h(e)},a.allocUnsafeSlow=function(e){return h(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var 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(X(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},a.byteLength=v,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?O(this,0,e):b.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,o){if(X(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),l=this.slice(r,o),u=e.slice(t,n),h=0;h<c;++h)if(l[h]!==u[h]){i=l[h],s=u[h];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return C(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return k(this,e,t,n);case"utf8":case"utf-8":return S(this,e,t,n);case"ascii":return A(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return T(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function P(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=R));return n}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function N(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+=H(e[i]);return o}function F(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function M(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,n,r,o,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function D(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 L(e,t,n,o,i){return t=+t,n>>>=0,i||D(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||D(e,t,n,8),r.write(e,t,n,o,52,8),n+8}a.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return r.__proto__=a.prototype,r},a.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},a.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},a.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||M(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),r.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||U(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||U(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,255,0),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);U(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var o=Math.pow(2,8*n-1);U(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},a.prototype.writeFloatLE=function(e,t,n){return L(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return L(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return q(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return q(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(!a.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var i=o-1;i>=0;--i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var o=e.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=a.isBuffer(e)?e:a.from(e,r),c=s.length;if(0===c)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<n-t;++i)this[i+t]=s[i%c]}return this};var z=/[^+/0-9A-Za-z-_]/g;function $(e){if((e=(e=e.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function H(e){return e<16?"0"+e.toString(16):e.toString(16)}function V(e,t){var n;t=t||1/0;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function W(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function K(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}function Q(e){return t.toByteArray($(e))}function J(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function Y(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(e,t,n){(function(r){(function(){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}function s(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}n.formatArgs=i,n.save=s,n.load=a,n.useColors=o,n.storage=c(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":19,_process:50}],19:[function(e,t,n){function r(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let t,n,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(t||o);n.diff=i,n.prev=t,n.curr=o,t=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";s++;const i=r.formatters[o];if("function"==typeof i){const r=e[s];t=i.call(n,r),e.splice(s,1),s--}return t})),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return a.namespace=e,a.useColors=r.useColors(),a.color=r.selectColor(e),a.extend=o,a.destroy=r.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==r.namespaces&&(n=r.namespaces,i=r.enabled(e)),i),set:e=>{s=e}}),"function"==typeof r.init&&r.init(a),a}function o(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function i(e){let t;r.save(e),r.namespaces=e,r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...r.names.map(c),...r.skips.map(c).map((e=>"-"+e))].join(",");return r.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1}function c(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=i,r.enabled=a,r.humanize=e("ms"),r.destroy=u,Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}t.exports=r},{ms:45}],20:[function(e,t,n){(function(n,r){(function(){var o=e("readable-stream"),i=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),l=function(e,t){e._corked?e.once("uncork",t):t()},u=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(n){n?u(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},f=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},d=function(){},p=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:p(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=d),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},m.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},m.prototype._write=function(e,t,n){if(!this.destroyed)return this._corked?l(this,this._write.bind(this,e,t,n)):e===c?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:this.destroyed||n()):n()},m.prototype._finish=function(e){var t=this;this.emit("preend"),l(this,(function(){f(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),l(t,e)}))}))},m.prototype.end=function(e,t,n){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(c),o.Writable.prototype.end.call(this,n))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:50,buffer:17,"end-of-stream":21,inherits:24,"readable-stream":69,"stream-shift":74}],21:[function(e,t,n){(function(n){(function(){var r=e("once"),o=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},s=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,c){if("function"==typeof t)return a(e,null,t);t||(t={}),c=r(c||o);var l=e._writableState,u=e._readableState,h=t.readable||!1!==t.readable&&e.readable,f=t.writable||!1!==t.writable&&e.writable,d=!1,p=function(){e.writable||m()},m=function(){f=!1,h||c.call(e)},g=function(){h=!1,f||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},v=function(t){c.call(e,t)},b=function(){n.nextTick(w)},w=function(){if(!d)return(!h||u&&u.ended&&!u.destroyed)&&(!f||l&&l.ended&&!l.destroyed)?void 0:c.call(e,new Error("premature close"))},C=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",b),e.req?C():e.on("request",C)):f&&!l&&(e.on("end",p),e.on("close",p)),s(e)&&e.on("exit",y),e.on("end",g),e.on("finish",m),!1!==t.error&&e.on("error",v),e.on("close",b),function(){d=!0,e.removeListener("complete",m),e.removeListener("abort",b),e.removeListener("request",C),e.req&&e.req.removeListener("finish",m),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",m),e.removeListener("exit",y),e.removeListener("end",g),e.removeListener("error",v),e.removeListener("close",b)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:50,once:48}],22:[function(e,t,n){var r=Object.create||S,o=Object.keys||A,i=Function.prototype.bind||E;function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,n){if(t)e.call(n);else for(var r=e.length,o=_(e,r),i=0;i<r;++i)o[i].call(n)}function f(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].call(n,r)}function d(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=_(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function p(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=_(e,s),c=0;c<s;++c)a[c].call(n,r,o,i)}function m(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=_(e,o),s=0;s<o;++s)i[s].apply(n,r)}function g(e,t,n,o){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[n,a]:[a,n]:o?a.unshift(n):a.push(n),!a.warned&&(i=u(e))&&i>0&&a.length>i){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function v(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=i.call(y,r);return o.listener=n,r.wrapFn=o,o}function b(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?k(o):_(o,o.length):[]}function w(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function C(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}function _(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function k(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function S(e){var t=function(){};return t.prototype=e,new t}function A(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t);return t}function E(e){var t=this;return function(){return t.apply(e,arguments)}}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(n=s[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:h(n,l,this);break;case 2:f(n,l,this,arguments[1]);break;case 3:d(n,l,this,arguments[1],arguments[2]);break;case 4:p(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];m(n,l,this,o)}return!0},s.prototype.addListener=function(e,t){return g(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return g(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,v(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,v(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():C(n,i),1===n.length&&(o[e]=n[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,i;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=o(n);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return b(this,e,!0)},s.prototype.rawListeners=function(e){return b(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},s.prototype.listenerCount=w,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(e,t,n){
3
3
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
4
- n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,l=c>>1,u=-7,h=n?o-1:0,f=n?-1:1,d=e[t+h];for(h+=f,i=d&(1<<-u)-1,d>>=-u,u+=a;u>0;i=256*i+e[t+h],h+=f,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+e[t+h],h+=f,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),i-=l}return(d?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[n+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;e[n+d]=255&s,d+=p,s/=256,l-=8);e[n+d-p]|=128*m}},{}],24:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],25:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=e,this.value=t}return e.prototype.rotateLeft=function(){var e=this.parent,t=this.brother,n=this.leftChild,r=this.rightChild;if(!r)throw new Error("unknown error");var o=r.leftChild,i=r.rightChild;return e&&(e.leftChild===this?e.leftChild=r:e.rightChild===this&&(e.rightChild=r)),r.parent=e,r.brother=t,r.leftChild=this,r.rightChild=i,t&&(t.brother=r),this.parent=r,this.brother=i,this.leftChild=n,this.rightChild=o,i&&(i.parent=r,i.brother=this),n&&(n.parent=this,n.brother=o),o&&(o.parent=this,o.brother=n),r},e.prototype.rotateRight=function(){var e=this.parent,t=this.brother,n=this.leftChild;if(!n)throw new Error("unknown error");var r=this.rightChild,o=n.leftChild,i=n.rightChild;return e&&(e.leftChild===this?e.leftChild=n:e.rightChild===this&&(e.rightChild=n)),n.parent=e,n.brother=t,n.leftChild=o,n.rightChild=this,t&&(t.brother=n),o&&(o.parent=n,o.brother=this),this.parent=n,this.brother=o,this.leftChild=i,this.rightChild=r,i&&(i.parent=this,i.brother=r),r&&(r.parent=this,r.brother=i),n},e.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},e.TreeNodeColorType={red:!0,black:!1},e}();Object.freeze(r),n.default=r},{}],26:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};function o(e){var t=this;void 0===e&&(e=[]);var n=[],i=0,s=0,a=0,c=0,l=0,u=0;this.size=function(){return u},this.empty=function(){return 0===u},this.clear=function(){i=a=s=c=l=u=0,f.call(this,o.bucketSize),u=0},this.front=function(){return n[i][s]},this.back=function(){return n[a][c]},this.forEach=function(e){if(!this.empty()){var t=0;if(i!==a){for(l=s;l<o.bucketSize;++l)e(n[i][l],t++);for(l=i+1;l<a;++l)for(var r=0;r<o.bucketSize;++r)e(n[l][r],t++);for(l=0;l<=c;++l)e(n[a][l],t++)}else for(var l=s;l<=c;++l)e(n[i][l],t++)}};var h=function(e){var t=i*o.bucketSize+s,n=t+e,r=a*o.bucketSize+c;if(n<t||n>r)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(n/o.bucketSize),curNodePointerIndex:n%o.bucketSize}};this.getElementByPos=function(e){var t=h(e),r=t.curNodeBucketIndex,o=t.curNodePointerIndex;return n[r][o]},this.eraseElementByPos=function(e){var t=this;if(e<0||e>u)throw new Error("pos should more than 0 and less than queue's size");if(0===e)this.popFront();else if(e===this.size())this.popBack();else{for(var n=[],r=e+1;r<u;++r)n.push(this.getElementByPos(r));this.cut(e),this.popBack(),n.forEach((function(e){return t.pushBack(e)}))}},this.eraseElementByValue=function(e){if(!this.empty()){var t=[];this.forEach((function(n){n!==e&&t.push(n)}));for(var n=t.length,r=0;r<n;++r)this.setElementByPos(r,t[r]);this.cut(n-1)}};var f=function(e){for(var t=[],r=e*o.sigma,h=Math.max(Math.ceil(r/o.bucketSize),2),f=0;f<h;++f)t.push(new Array(o.bucketSize));var d=Math.ceil(e/o.bucketSize),p=Math.floor(h/2)-Math.floor(d/2),m=p,g=0;if(this.size())for(f=0;f<d;++f){for(var y=0;y<o.bucketSize;++y)if(t[p+f][y]=this.front(),this.popFront(),this.empty()){m=p+f,g=y;break}if(this.empty())break}n=t,i=p,s=0,a=m,c=g,l=h,u=e};this.pushBack=function(e){this.empty()||(a===l-1&&c===o.bucketSize-1&&f.call(this,this.size()),c<o.bucketSize-1?++c:a<l-1&&(++a,c=0)),++u,n[a][c]=e},this.popBack=function(){this.empty()||(1!==this.size()&&(c>0?--c:i<a&&(--a,c=o.bucketSize-1)),u>0&&--u)},this.setElementByPos=function(e,t){var r=h(e),o=r.curNodeBucketIndex,i=r.curNodePointerIndex;n[o][i]=t},this.insert=function(e,t,n){var r=this;if(void 0===n&&(n=1),0===e)for(;n--;)this.pushFront(t);else if(e===this.size())for(;n--;)this.pushBack(t);else{for(var o=[],i=e;i<u;++i)o.push(this.getElementByPos(i));for(this.cut(e-1),i=0;i<n;++i)this.pushBack(t);o.forEach((function(e){return r.pushBack(e)}))}},this.find=function(e){if(i===a){for(var t=s;t<=c;++t)if(n[i][t]===e)return!0;return!1}for(t=s;t<o.bucketSize;++t)if(n[i][t]===e)return!0;for(t=i+1;t<a;++t)for(var r=0;r<o.bucketSize;++r)if(n[t][r]===e)return!0;for(t=0;t<=c;++t)if(n[a][t]===e)return!0;return!1},this.reverse=function(){for(var e=0,t=u-1;e<t;){var n=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,n),++e,--t}},this.unique=function(){if(!this.empty()){var e=[],t=this.front();this.forEach((function(n,r){0!==r&&n===t||(e.push(n),t=n)}));for(var n=0;n<u;++n)this.setElementByPos(n,e[n]);this.cut(e.length-1)}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);for(var n=0;n<u;++n)this.setElementByPos(n,t[n])},this.pushFront=function(e){this.empty()||(0===i&&0===s&&f.call(this,this.size()),s>0?--s:i>0&&(--i,s=o.bucketSize-1)),++u,n[i][s]=e},this.popFront=function(){this.empty()||(1!==this.size()&&(s<o.bucketSize-1?++s:i<a&&(++i,s=0)),u>0&&--u)},this.shrinkToFit=function(){var e=this,t=[];this.forEach((function(e){t.push(e)}));var r=t.length;n=[];for(var i=Math.ceil(r/o.bucketSize),s=0;s<i;++s)n.push(new Array(o.bucketSize));this.clear(),t.forEach((function(t){return e.pushBack(t)}))},this.cut=function(e){if(e<0)this.clear();else{var t=h(e),n=t.curNodeBucketIndex,r=t.curNodePointerIndex;a=n,c=r,u=e+1}},this[Symbol.iterator]=function(){return function(){var e,t;return r(this,(function(r){switch(r.label){case 0:if(0===u)return[2];if(i!==a)return[3,5];t=s,r.label=1;case 1:return t<=c?[4,n[i][t]]:[3,4];case 2:r.sent(),r.label=3;case 3:return++t,[3,1];case 4:return[2];case 5:t=s,r.label=6;case 6:return t<o.bucketSize?[4,n[i][t]]:[3,9];case 7:r.sent(),r.label=8;case 8:return++t,[3,6];case 9:t=i+1,r.label=10;case 10:if(!(t<a))return[3,15];e=0,r.label=11;case 11:return e<o.bucketSize?[4,n[t][e]]:[3,14];case 12:r.sent(),r.label=13;case 13:return++e,[3,11];case 14:return++t,[3,10];case 15:t=0,r.label=16;case 16:return t<=c?[4,n[a][t]]:[3,19];case 17:r.sent(),r.label=18;case 18:return++t,[3,16];case 19:return[2]}}))}()},function(){var r=o.bucketSize;e.size?r=e.size():e.length&&(r=e.length);var s=r*o.sigma;l=Math.ceil(s/o.bucketSize),l=Math.max(l,3);for(var c=0;c<l;++c)n.push(new Array(o.bucketSize));var u=Math.ceil(r/o.bucketSize);i=Math.floor(l/2)-Math.floor(u/2),a=i,e.forEach((function(e){return t.pushBack(e)}))}(),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),o.sigma=3,o.bucketSize=5e3,Object.freeze(o),n.default=o},{}],27:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../LinkList/LinkList"),s=e("../Map/Map");function a(e,t,n){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),n=n||function(e){var t,n,r=0,i="";if("number"==typeof e)r=((r=Math.floor(e))<<5)-r,r&=r;else{i="string"!=typeof e?JSON.stringify(e):e;try{for(var s=o(i),a=s.next();!a.done;a=s.next())r=(r<<5)-r+a.value.charCodeAt(0),r&=r}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}return r^=r>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(n){n.forEach((function(n){e(n,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(r,o){if(!r.empty()){if(r instanceof i.default&&1===r.size()){var c=r.front(),l=c.key,f=c.value;t[n(l)&h-1]=new i.default([{key:l,value:f}])}else if(r instanceof s.default){var d=new i.default,p=new i.default;r.forEach((function(t){0==(n(t.key)&e)?d.pushBack(t):p.pushBack(t)})),d.size()>a.untreeifyThreshold?t[o]=new s.default(d):d.size()&&(t[o]=d),p.size()>a.untreeifyThreshold?t[o+e]=new s.default(p):p.size()&&(t[o+e]=p)}else{var m=new i.default,g=new i.default;r.forEach((function(t){0==(n(t.key)&e)?m.pushBack(t):g.pushBack(t)})),m.size()&&(t[o]=m),g.size()&&(t[o+e]=g)}u[o].clear()}})),u=t}};this.setElement=function(e,t){var r,c;if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=t){var d=n(e)&h-1;if(u[d]){var p=u[d].size();if(u[d]instanceof i.default){try{for(var m=o(u[d]),g=m.next();!g.done;g=m.next()){var y=g.value;if(y.key===e)return void(y.value=t)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(c=m.return)&&c.call(m)}finally{if(r)throw r.error}}u[d].pushBack({key:e,value:t}),u[d].size()>=a.treeifyThreshold&&(u[d]=new s.default(u[d]))}else u[d].setElement(e,t);var v=u[d].size();l+=v-p}else++l,u[d]=new i.default([{key:e,value:t}]);l>h*a.sigma&&f.call(this,h)}else this.eraseElementByKey(e)},this.getElementByKey=function(e){var t,r,i=n(e)&h-1;if(u[i]){if(u[i]instanceof s.default)return u[i].getElementByKey(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next()){var l=c.value;if(l.key===e)return l.value}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},this.eraseElementByKey=function(e){var t,r,c=n(e)&h-1;if(u[c]){var f=u[c].size();if(u[c]instanceof s.default)u[c].eraseElementByKey(e),u[c].size()<=a.untreeifyThreshold&&(u[c]=new i.default(u[c]));else{var d=-1;try{for(var p=o(u[c]),m=p.next();!m.done;m=p.next()){var g=m.value;if(++d,g.key===e){u[c].eraseElementByPos(d);break}}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}}var y=u[c].size();l+=y-f}},this.find=function(e){var t,r,i=n(e)&h-1;if(!u[i])return!1;if(u[i]instanceof s.default)return u[i].find(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next())if(c.value.key===e)return!0}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return!1},this[Symbol.iterator]=function(){return function(){var e,t,n,i,s,a;return r(this,(function(r){switch(r.label){case 0:e=0,r.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];r.label=2;case 2:r.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),n=t.next(),r.label=3;case 3:return n.done?[3,6]:[4,n.value];case 4:r.sent(),r.label=5;case 5:return n=t.next(),[3,3];case 6:return[3,9];case 7:return i=r.sent(),s={error:i},[3,9];case 8:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){var t=e.key,n=e.value;return c.setElement(t,n)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),n.default=a},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Set/Set"),s=e("../LinkList/LinkList");function a(e,t,n){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),n=n||function(e){var t=0,n="";if("number"==typeof e)t=((t=Math.floor(e))<<5)-t,t&=t;else{n="string"!=typeof e?JSON.stringify(e):e;for(var r=0;r<n.length;r++)t=(t<<5)-t+n.charCodeAt(r),t&=t}return t^=t>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(n){n.forEach((function(n){e(n,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(r,o){if(!r.empty()){if(r instanceof s.default&&1===r.size()){var c=r.front();if(void 0===c)throw new Error("unknown error");t[n(c)&h-1]=new s.default([c])}else if(r instanceof i.default){var l=new s.default,f=new s.default;r.forEach((function(t){0==(n(t)&e)?l.pushBack(t):f.pushBack(t)})),l.size()>a.untreeifyThreshold?t[o]=new i.default(l):l.size()&&(t[o]=l),f.size()>a.untreeifyThreshold?t[o+e]=new i.default(f):f.size()&&(t[o+e]=f)}else{var d=new s.default,p=new s.default;r.forEach((function(t){0==(n(t)&e)?d.pushBack(t):p.pushBack(t)})),d.size()&&(t[o]=d),p.size()&&(t[o+e]=p)}u[o].clear()}})),u=t}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var t=n(e)&h-1;if(u[t]){var r=u[t].size();if(u[t]instanceof s.default){if(u[t].find(e))return;u[t].pushBack(e),u[t].size()>=a.treeifyThreshold&&(u[t]=new i.default(u[t]))}else u[t].insert(e);var o=u[t].size();l+=o-r}else u[t]=new s.default([e]),++l;l>h*a.sigma&&f.call(this,h)},this.eraseElementByValue=function(e){var t=n(e)&h-1;if(u[t]){var r=u[t].size();u[t].eraseElementByValue(e),u[t]instanceof i.default&&u[t].size()<=a.untreeifyThreshold&&(u[t]=new s.default(u[t]));var o=u[t].size();l+=o-r}},this.find=function(e){var t=n(e)&h-1;return!!u[t]&&u[t].find(e)},this[Symbol.iterator]=function(){return function(){var e,t,n,i,s,a;return r(this,(function(r){switch(r.label){case 0:e=0,r.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];r.label=2;case 2:r.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),n=t.next(),r.label=3;case 3:return n.done?[3,6]:[4,n.value];case 4:r.sent(),r.label=5;case 5:return n=t.next(),[3,3];case 6:return[3,9];case 7:return i=r.sent(),s={error:i},[3,9];case 8:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){return c.insert(e)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),n.default=a},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e}return e}();function i(e){var t=this;void 0===e&&(e=[]);var n=0,i=void 0,s=void 0;this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){i=s=void 0,n=0},this.front=function(){return null==i?void 0:i.value},this.back=function(){return null==s?void 0:s.value},this.forEach=function(e){for(var t=i,n=0;t;){if(void 0===t.value)throw new Error("unknown error");e(t.value,n++),t=t.next}},this.getElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more then 0 and less then the list length");for(var t=i;e--&&t;)t=t.next;if(!t||void 0===t.value)throw new Error("unknown error");return t.value},this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("erase pos must more then 0 and less then the list length");if(0===e)this.popFront();else if(e===n-1)this.popBack();else{for(var t=i;e--;){if(!(null==t?void 0:t.next))throw new Error("unknown error");t=t.next}if(!t||!t.pre||!t.next)throw new Error("unknown error");var r=t.pre,o=t.next;o.pre=r,r.next=o,n>0&&--n}},this.eraseElementByValue=function(e){for(;i&&i.value===e;)this.popFront();for(;s&&s.value===e;)this.popBack();if(i)for(var t=i;t;){if(t.value===e){var r=t.pre,o=t.next;o&&(o.pre=r),r&&(r.next=o),n>0&&--n}t=t.next}},this.pushBack=function(e){if(null==e)throw new Error("you can't push null or undefined here");++n;var t=new o(e);s?(s.next=t,t.pre=s,s=t):i=s=t},this.popBack=function(){s&&(n>0&&--n,s&&(i===s?i=s=void 0:(s=s.pre)&&(s.next=void 0)))},this.setElementByPos=function(e,t){if(null==t)throw new Error("you can't set null or undefined here");if(e<0||e>=n)throw new Error("pos must more then 0 and less then the list length");for(var r=i;e--;){if(!r)throw new Error("unknown error");r=r.next}r&&(r.value=t)},this.insert=function(e,t,r){if(void 0===r&&(r=1),null==t)throw new Error("you can't insert null or undefined here");if(e<0||e>n)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(r<0)throw new Error("insert size must more than 0");if(0===e)for(;r--;)this.pushFront(t);else if(e===n)for(;r--;)this.pushBack(t);else{for(var s=i,a=1;a<e;++a){if(!(null==s?void 0:s.next))throw new Error("unknown error");s=null==s?void 0:s.next}if(!s)throw new Error("unknown error");var c=s.next;for(n+=r;r--;)s.next=new o(t),s.next.pre=s,s=s.next;s.next=c,c&&(c.pre=s)}},this.find=function(e){for(var t=i;t;){if(t.value===e)return!0;t=t.next}return!1},this.reverse=function(){for(var e=i,t=s,r=0;e&&t&&2*r<n;){var o=e.value;e.value=t.value,t.value=o,e=e.next,t=t.pre,++r}},this.unique=function(){for(var e=i;e;){for(var t=e;t&&t.next&&t.value===t.next.value;)t=t.next,n>0&&--n;e.next=t.next,e.next&&(e.next.pre=e),e=e.next}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);var n=i;t.forEach((function(e){n&&(n.value=e,n=n.next)}))},this.pushFront=function(e){if(null==e)throw new Error("you can't push null or undefined here");++n;var t=new o(e);i?(t.next=i,i.pre=t,i=t):i=s=t},this.popFront=function(){i&&(n>0&&--n,i&&(i===s?i=s=void 0:(i=i.next)&&(i.pre=void 0)))},this.merge=function(e){var t=this,r=i;e.forEach((function(e){for(;r&&void 0!==r.value&&r.value<=e;)r=r.next;if(void 0===r)t.pushBack(e),r=s;else if(r===i)t.pushFront(e),r=i;else{++n;var a=r.pre;a&&(a.next=new o(e),a.next.pre=a,a.next.next=r,r&&(r.pre=a.next))}}))},this[Symbol.iterator]=function(){return function(){var e;return r(this,(function(t){switch(t.label){case 0:e=i,t.label=1;case 1:if(void 0===e)return[3,3];if(!e.value)throw new Error("unknown error");return[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.freeze(i),n.default=i},{}],30:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var n=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=a.value=void 0,a.leftChild=a.rightChild=a.brother=void 0};var c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty()){var e=c(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.back=function(){if(!this.empty()){var e=l(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.forEach=function(e){var t,n,r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,r++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,n;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===e)return a;++r}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw new Error("unknown Error")};var u=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value){var r=t(e.key,n);return 0===r?{key:e.key,value:e.value}:r<0?u(e.rightChild,n):u(e.leftChild,n)||{key:e.key,value:e.value}}};this.lowerBound=function(e){return u(a,e)};var h=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,n)<=0?h(e.rightChild,n):h(e.leftChild,n)||{key:e.key,value:e.value}};this.upperBound=function(e){return h(a,e)};var f=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value){var r=t(e.key,n);return 0===r?{key:e.key,value:e.value}:r>0?f(e.leftChild,n):f(e.rightChild,n)||{key:e.key,value:e.value}}};this.reverseLowerBound=function(e){return f(a,e)};var d=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,n)>=0?d(e.leftChild,n):d(e.rightChild,n)||{key:e.key,value:e.value}};this.reverseUpperBound=function(e){return d(a,e)};var p=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var n=e.brother;if(!n)throw new Error("unknown error");if(e===t.leftChild)if(n.color===i.default.TreeNodeColorType.red){n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var r=t.rotateLeft();a===t&&(a=r),p(e)}else n.color===i.default.TreeNodeColorType.black&&(n.rightChild&&n.rightChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=t.rotateLeft(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||!n.leftChild||n.leftChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,p(t)):(n.color=i.default.TreeNodeColorType.red,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=n.rotateRight(),a===n&&(a=r),p(e)));else e===t.rightChild&&(n.color===i.default.TreeNodeColorType.red?(n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,r=t.rotateRight(),a===t&&(a=r),p(e)):n.color===i.default.TreeNodeColorType.black&&(n.leftChild&&n.leftChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=t.rotateRight(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||!n.rightChild||n.rightChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,p(t)):(n.color=i.default.TreeNodeColorType.red,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=n.rotateLeft(),a===n&&(a=r),p(e))))}else e.color=i.default.TreeNodeColorType.black},m=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var n=e.key;e.key=t.key,t.key=n;var r=e.value;e.value=t.value,t.value=r,e=t}t.leftChild&&(t=l(t.leftChild),n=e.key,e.key=t.key,t.key=n,r=e.value,e.value=t.value,t.value=r,e=t)}p(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},g=function(e,t){return!(!e||void 0===e.key)&&(!!g(e.leftChild,t)||!!t(e)||g(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;g(a,(function(n){return e===t?(m(n),!0):(++t,!1)}))},this.eraseElementByKey=function(e){if(!this.empty()){var n=b(a,e);void 0!==n&&void 0!==n.key&&0===t(n.key,e)&&m(n)}};var y=function(e,n){if(!e||void 0===e.key)throw new Error("unknown error");var r=t(n,e.key);return r<0?e.leftChild?y(e.leftChild,n):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):r>0?e.rightChild?y(e.rightChild,n):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},v=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var n=t.brother,r=t.parent;if(!r)throw new Error("unknown error");if(n&&n.color===i.default.TreeNodeColorType.red)n.color=t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,v(r);else if(!n||n.color===i.default.TreeNodeColorType.black)if(t===r.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red;var o=r.rotateRight();r===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),r===a&&(a=o),v(t));else t===r.rightChild&&(e===t.leftChild?(o=t.rotateRight(),r===a&&(a=o),v(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,o=r.rotateLeft(),r===a&&(a=o)))}};this.setElement=function(e,n){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=n){if(this.empty())return++s,a.key=e,a.value=n,void(a.color=i.default.TreeNodeColorType.black);var r=y(a,e);void 0===r.key||0!==t(r.key,e)?(++s,r.key=e,r.value=n,v(r),a.color=i.default.TreeNodeColorType.black):r.value=n}else this.eraseElementByKey(e)};var b=function(e,n){if(e&&void 0!==e.key){var r=t(n,e.key);return r<0?b(e.leftChild,n):r>0?b(e.rightChild,n):e}};this.find=function(e){return!!b(a,e)},this.getElementByKey=function(e){var t=b(a,e);if(void 0===(null==t?void 0:t.key)||void 0===(null==t?void 0:t.value))throw new Error("unknown error");return t.value},this.union=function(e){var t=this;e.forEach((function(e){var n=e.key,r=e.value;return t.setElement(n,r)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return r(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key&&void 0!==e.value?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,{key:e.key,value:e.value}];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){var t=e.key,r=e.value;return n.setElement(t,r)})),Object.freeze(this)}Object.freeze(s),n.default=s},{"../Base/TreeNode":25}],31:[function(e,t,n){function r(e,t){void 0===e&&(e=[]),t=t||function(e,t){return e>t?-1:e<t?1:0};var n=[];e.forEach((function(e){return n.push(e)}));var r=n.length,o=function(e,t){if(e<0||e>=r)throw new Error("unknown error");if(t<0||t>=r)throw new Error("unknown error");var o=n[e];n[e]=n[t],n[t]=o},i=function(e){if(e<0||e>=r)throw new Error("unknown error");var i=2*e+1,s=2*e+2;i<r&&t(n[e],n[i])>0&&o(e,i),s<r&&t(n[e],n[s])>0&&o(e,s)};!function(){for(var e=Math.floor((r-1)/2);e>=0;--e)for(var i=e,s=2*i+1;s<r;){var a=s+1,c=s;if(a<r&&t(n[s],n[a])>0&&(c=a),t(n[i],n[c])<=0)break;o(i,c),s=2*(i=c)+1}}(),this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,n.length=0},this.push=function(e){if(n.push(e),1!=++r)for(var o=r-1;o>0;){var s=Math.floor((o-1)/2);if(t(n[s],e)<=0)break;i(s),o=s}},this.pop=function(){if(!this.empty())if(1!==this.size()){var e=n[r-1];--r;for(var o=0;o<this.size();){var i=2*o+1,s=2*o+2;if(i>=this.size())break;var a=i;if(s<this.size()&&t(n[i],n[s])>0&&(a=s),t(n[a],e)>=0)break;n[o]=n[a],o=a}n[o]=e}else--r},this.top=function(){return n[0]},Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],32:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var r=e("../LinkList/LinkList");function o(e){void 0===e&&(e=[]);var t=new r.default(e);this.size=function(){return t.size()},this.empty=function(){return t.empty()},this.clear=function(){t.clear()},this.push=function(e){t.pushBack(e)},this.pop=function(){t.popFront()},this.front=function(){return t.front()},Object.freeze(this)}Object.freeze(o),n.default=o},{"../LinkList/LinkList":29}],33:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var n=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=void 0,a.leftChild=a.rightChild=a.brother=a.parent=void 0,a.color=i.default.TreeNodeColorType.black};var c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty())return c(a).key},this.back=function(){if(!this.empty())return l(a).key},this.forEach=function(e){var t,n,r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,r++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,n;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===e)return a;++r}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw new Error("unknown error")};var u=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var n=e.brother;if(!n)throw new Error("unknown error");if(e===t.leftChild)if(n.color===i.default.TreeNodeColorType.red){n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var r=t.rotateLeft();a===t&&(a=r),u(e)}else n.color===i.default.TreeNodeColorType.black&&(n.rightChild&&n.rightChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=t.rotateLeft(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||!n.leftChild||n.leftChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,u(t)):(n.color=i.default.TreeNodeColorType.red,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=n.rotateRight(),a===n&&(a=r),u(e)));else e===t.rightChild&&(n.color===i.default.TreeNodeColorType.red?(n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,r=t.rotateRight(),a===t&&(a=r),u(e)):n.color===i.default.TreeNodeColorType.black&&(n.leftChild&&n.leftChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=t.rotateRight(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||!n.rightChild||n.rightChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,u(t)):(n.color=i.default.TreeNodeColorType.red,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=n.rotateLeft(),a===n&&(a=r),u(e))))}else e.color=i.default.TreeNodeColorType.black},h=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var n=e.key;e.key=t.key,t.key=n,e=t}t.leftChild&&(t=l(t.leftChild),n=e.key,e.key=t.key,t.key=n,e=t)}u(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},f=function(e,t){return!(!e||void 0===e.key)&&(!!f(e.leftChild,t)||!!t(e)||f(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;f(a,(function(n){return e===t?(h(n),!0):(++t,!1)}))},this.eraseElementByValue=function(e){if(!this.empty()){var n=m(a,e);void 0!==n&&void 0!==n.key&&0===t(n.key,e)&&h(n)}};var d=function(e,n){if(!e||void 0===e.key)throw new Error("unknown error");var r=t(n,e.key);return r<0?e.leftChild?d(e.leftChild,n):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):r>0?e.rightChild?d(e.rightChild,n):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},p=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var n=t.brother,r=t.parent;if(!r)throw new Error("unknown error");if(n&&n.color===i.default.TreeNodeColorType.red)n.color=t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,p(r);else if(!n||n.color===i.default.TreeNodeColorType.black)if(t===r.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red;var o=r.rotateRight();r===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),r===a&&(a=o),p(t));else t===r.rightChild&&(e===t.leftChild?(o=t.rotateRight(),r===a&&(a=o),p(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,o=r.rotateLeft(),r===a&&(a=o)))}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++s,a.key=e,void(a.color=i.default.TreeNodeColorType.black);var n=d(a,e);void 0!==n.key&&0===t(n.key,e)||(++s,n.key=e,p(n),a.color=i.default.TreeNodeColorType.black)};var m=function(e,n){if(e&&void 0!==e.key){var r=t(n,e.key);return r<0?m(e.leftChild,n):r>0?m(e.rightChild,n):e}};this.find=function(e){var n=m(a,e);return void 0!==n&&void 0!==n.key&&0===t(n.key,e)};var g=function(e,n){if(e&&void 0!==e.key){var r=t(e.key,n);if(0===r)return e.key;if(r<0)return g(e.rightChild,n);var o=g(e.leftChild,n);return void 0!==o?o:e.key}};this.lowerBound=function(e){return g(a,e)};var y=function(e,n){if(e&&void 0!==e.key){if(t(e.key,n)<=0)return y(e.rightChild,n);var r=y(e.leftChild,n);return void 0!==r?r:e.key}};this.upperBound=function(e){return y(a,e)};var v=function(e,n){if(e&&void 0!==e.key){var r=t(e.key,n);if(0===r)return e.key;if(r>0)return v(e.leftChild,n);var o=v(e.rightChild,n);return void 0!==o?o:e.key}};this.reverseLowerBound=function(e){return v(a,e)};var b=function(e,n){if(e&&void 0!==e.key){if(t(e.key,n)>=0)return b(e.leftChild,n);var r=b(e.rightChild,n);return void 0!==r?r:e.key}};this.reverseUpperBound=function(e){return b(a,e)},this.union=function(e){var t=this;e.forEach((function(e){return t.insert(e)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return r(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){return n.insert(e)})),Object.freeze(this)}Object.freeze(s),n.default=s},{"../Base/TreeNode":25}],34:[function(e,t,n){function r(e){var t=this;void 0===e&&(e=[]);var n=0,r=[];this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,r.length=0},this.push=function(e){r.push(e),++n},this.pop=function(){r.pop(),n>0&&--n},this.top=function(){return r[n-1]},e.forEach((function(e){return t.push(e)})),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],35:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function a(e){var t=this;void 0===e&&(e=[]);var n=0,a=[];this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,a.length=0},this.front=function(){if(!this.empty())return a[0]},this.back=function(){if(!this.empty())return a[n-1]},this.forEach=function(e){a.forEach(e)},this.getElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");return a[e]},this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");for(var t=e;t<n-1;++t)a[t]=a[t+1];this.popBack()},this.eraseElementByValue=function(e){var t=[];this.forEach((function(n){n!==e&&t.push(n)})),t.forEach((function(e,t){a[t]=e}));for(var r=t.length;n>r;)this.popBack()},this.pushBack=function(e){a.push(e),++n},this.popBack=function(){a.pop(),n>0&&--n},this.setElementByPos=function(e,t){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");a[e]=t},this.insert=function(e,t,r){if(void 0===r&&(r=1),e<0||e>n)throw new Error("pos must more than 0 and less than or equal to vector's size");a.splice.apply(a,i([e,0],o(new Array(r).fill(t)),!1)),n+=r},this.find=function(e){return a.includes(e)},this.reverse=function(){a.reverse()},this.unique=function(){var e,t=[];this.forEach((function(n,r){0!==r&&n===e||(t.push(n),e=n)})),t.forEach((function(e,t){a[t]=e}));for(var r=t.length;n>r;)this.popBack()},this.sort=function(e){a.sort(e)},this[Symbol.iterator]=function(){return function(){return r(this,(function(e){switch(e.label){case 0:return[5,s(a)];case 1:return[2,e.sent()]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(a),n.default=a},{}],36:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.HashMap=n.HashSet=n.Map=n.Set=n.PriorityQueue=n.Deque=n.LinkList=n.Queue=n.Stack=n.Vector=void 0;var r=e("./Vector/Vector");n.Vector=r.default;var o=e("./Stack/Stack");n.Stack=o.default;var i=e("./Queue/Queue");n.Queue=i.default;var s=e("./LinkList/LinkList");n.LinkList=s.default;var a=e("./Deque/Deque");n.Deque=a.default;var c=e("./PriorityQueue/PriorityQueue");n.PriorityQueue=c.default;var l=e("./Set/Set");n.Set=l.default;var u=e("./Map/Map");n.Map=u.default;var h=e("./HashSet/HashSet");n.HashSet=h.default;var f=e("./HashMap/HashMap");n.HashMap=f.default},{"./Deque/Deque":26,"./HashMap/HashMap":27,"./HashSet/HashSet":28,"./LinkList/LinkList":29,"./Map/Map":30,"./PriorityQueue/PriorityQueue":31,"./Queue/Queue":32,"./Set/Set":33,"./Stack/Stack":34,"./Vector/Vector":35}],37:[function(e,t,n){const r=e("yallist"),o=Symbol("max"),i=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),c=Symbol("maxAge"),l=Symbol("dispose"),u=Symbol("noDisposeOnSet"),h=Symbol("lruList"),f=Symbol("cache"),d=Symbol("updateAgeOnGet"),p=()=>1;class m{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[o]=e.max||1/0;const t=e.length||p;if(this[s]="function"!=typeof t?p:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[c]=e.maxAge||0,this[l]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[d]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[o]=e||1/0,v(this)}get max(){return this[o]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[c]=e,v(this)}get maxAge(){return this[c]}set lengthCalculator(e){"function"!=typeof e&&(e=p),e!==this[s]&&(this[s]=e,this[i]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[i]+=e.length}))),v(this)}get lengthCalculator(){return this[s]}get length(){return this[i]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let n=this[h].tail;null!==n;){const r=n.prev;C(this,e,n,t),n=r}}forEach(e,t){t=t||this;for(let n=this[h].head;null!==n;){const r=n.next;C(this,e,n,t),n=r}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[l]&&this[h]&&this[h].length&&this[h].forEach((e=>this[l](e.key,e.value))),this[f]=new Map,this[h]=new r,this[i]=0}dump(){return this[h].map((e=>!y(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,n){if((n=n||this[c])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const r=n?Date.now():0,a=this[s](t,e);if(this[f].has(e)){if(a>this[o])return b(this,this[f].get(e)),!1;const s=this[f].get(e).value;return this[l]&&(this[u]||this[l](e,s.value)),s.now=r,s.maxAge=n,s.value=t,this[i]+=a-s.length,s.length=a,this.get(e),v(this),!0}const d=new w(e,t,a,r,n);return d.length>this[o]?(this[l]&&this[l](e,t),!1):(this[i]+=d.length,this[h].unshift(d),this[f].set(e,this[h].head),v(this),!0)}has(e){if(!this[f].has(e))return!1;const t=this[f].get(e).value;return!y(this,t)}get(e){return g(this,e,!0)}peek(e){return g(this,e,!1)}pop(){const e=this[h].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[f].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const r=e[n],o=r.e||0;if(0===o)this.set(r.k,r.v);else{const e=o-t;e>0&&this.set(r.k,r.v,e)}}}prune(){this[f].forEach(((e,t)=>g(this,t,!1)))}}const g=(e,t,n)=>{const r=e[f].get(t);if(r){const t=r.value;if(y(e,t)){if(b(e,r),!e[a])return}else n&&(e[d]&&(r.value.now=Date.now()),e[h].unshiftNode(r));return t.value}},y=(e,t)=>{if(!t||!t.maxAge&&!e[c])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[c]&&n>e[c]},v=e=>{if(e[i]>e[o])for(let t=e[h].tail;e[i]>e[o]&&null!==t;){const n=t.prev;b(e,t),t=n}},b=(e,t)=>{if(t){const n=t.value;e[l]&&e[l](n.key,n.value),e[i]-=n.length,e[f].delete(n.key),e[h].removeNode(t)}};class w{constructor(e,t,n,r,o){this.key=e,this.value=t,this.length=n,this.now=r,this.maxAge=o||0}}const C=(e,t,n,r)=>{let o=n.value;y(e,o)&&(b(e,n),e[a]||(o=void 0)),o&&t.call(r,o.value,o.key,e)};t.exports=m},{yallist:83}],38:[function(e,t,n){(function(e){(function(){const n=t.exports;n.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=e.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=e.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=e.from([n.codes.connect<<n.CMD_SHIFT]),n.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function r(t){return[0,1,2].map((r=>[0,1].map((o=>[0,1].map((i=>{const s=e.alloc(1);return s.writeUInt8(n.codes[t]<<n.CMD_SHIFT|(o?n.DUP_MASK:0)|r<<n.QOS_SHIFT|i,0,!0),s}))))))}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=e.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=e.from([3]),n.VERSION4=e.from([4]),n.VERSION5=e.from([5]),n.VERSION131=e.from([131]),n.VERSION132=e.from([132]),n.QOS=[0,1,2].map((t=>e.from([t]))),n.EMPTY={pingreq:e.from([n.codes.pingreq<<4,0]),pingresp:e.from([n.codes.pingresp<<4,0]),disconnect:e.from([n.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],39:[function(e,t,n){(function(n){(function(){const r=e("./writeToStream"),o=e("events");function i(e,t){const n=new s;return r(e,n,t),n.concat()}class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),r=this._array;let o,i=0;for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?t[o]=r[o].length:t[o]=n.byteLength(r[o]),e+=t[o];const s=n.allocUnsafe(e);for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?(r[o].copy(s,i),i+=t[o]):(s.write(r[o],i),i+=t[o]);return s}}t.exports=i}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(e,t,n){n.parser=e("./parser").parser,n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(e,t,n){(function(e){(function(){const n=65536,r={},o=e.isBuffer(e.from([1,2]).subarray(0,1));function i(t){const n=e.allocUnsafe(2);return n.writeUInt8(t>>8,0),n.writeUInt8(255&t,1),n}function s(){for(let e=0;e<n;e++)r[e]=i(e)}function a(t){const n=4;let r=0,i=0;const s=e.allocUnsafe(n);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),s.writeUInt8(r,i++)}while(t>0&&i<n);return t>0&&(i=0),o?s.subarray(0,i):s.slice(0,i)}function c(t){const n=e.allocUnsafe(4);return n.writeUInt32BE(t,0),n}t.exports={cache:r,generateCache:s,generateNumber:i,genBufVariableByteInt:a,generate4ByteBuffer:c}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],42:[function(e,t,n){class r{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=r},{}],43:[function(e,t,n){const r=e("bl"),o=e("events"),i=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;a("_parseConnect");const o={},i=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.properties=e)}const l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(i.clientId=l,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=e,a("_parseConnect: packet.will.topic: %s",i.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));i.username=r,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));i.password=n}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,n,r,o,i,c,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=0!=(n>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(n>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=n>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:r},5===this.settings.protocolVersion?(l.nl=c,l.rap=i,l.rh=o):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,a("_parseString: result: %s",r),r}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");const t=4;let n,r=0,o=1,i=0,c=!1;const l=this._pos?this._pos:0;for(;r<t&&l+r<this._list.length;){if(n=this._list.readUInt8(l+r++),i+=o*(n&s.VARBYTEINT_MASK),o*=128,0==(n&s.VARBYTEINT_FIN_MASK)){c=!0;break}if(this._list.length<=r)break}return!c&&r===t&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=r),c=!!c&&(e?{bytes:r,value:i}:i),a("_parseVarByteNum: result: %o",c),c}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(s.propertiesTypes[t]))):n[t]=this._parseByType(s.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new i,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}t.exports=c},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(e,t,n){(function(n){(function(){const r=e("./constants"),o=n.allocUnsafe(0),i=n.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,c=e("debug")("mqtt-packet:writeToStream"),l=s.cache,u=s.generateNumber,h=s.generateCache,f=s.genBufVariableByteInt,d=s.generate4ByteBuffer;let p=B,m=!0;function g(e,t,n){switch(c("generate called"),t.cork&&(t.cork(),a(y,t)),m&&(m=!1,h()),c("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return v(e,t);case"connack":return b(e,t,n);case"publish":return w(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return C(e,t,n);case"subscribe":return _(e,t,n);case"suback":return k(e,t,n);case"unsubscribe":return S(e,t,n);case"unsuback":return E(e,t,n);case"pingreq":case"pingresp":return A(e,t);case"disconnect":return T(e,t,n);case"auth":return x(e,t,n);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}function v(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let l=i.clean;const u=i.keepalive||0,h=i.clientId||"",f=i.username,d=i.password,m=i.properties;void 0===l&&(l=!0);let g=0;if(!s||"string"!=typeof s&&!n.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof h||n.isBuffer(h))&&(h||a>=4)&&(h||l))g+=n.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*l==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=M(t,m);if(!y)return!1;g+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(g+=n.byteLength(c.topic)+2,g+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?g+=n.byteLength(c.payload):g+=c.payload.length}var v={};if(5===a){if(!(v=M(t,c.properties)))return!1;g+=v.length}}let b=!1;if(null!=f){if(!z(f))return t.emit("error",new Error("Invalid username")),!1;b=!0,g+=n.byteLength(f)+2}if(null!=d){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!z(d))return t.emit("error",new Error("Invalid password")),!1;g+=q(d)+2}t.write(r.CONNECT_HEADER),O(t,g),j(t,s),i.bridgeMode&&(a+=128),t.write(131===a?r.VERSION131:132===a?r.VERSION132:4===a?r.VERSION4:5===a?r.VERSION5:r.VERSION3);let w=0;return w|=null!=f?r.USERNAME_MASK:0,w|=null!=d?r.PASSWORD_MASK:0,w|=c&&c.retain?r.WILL_RETAIN_MASK:0,w|=c&&c.qos?c.qos<<r.WILL_QOS_SHIFT:0,w|=c?r.WILL_FLAG_MASK:0,w|=l?r.CLEAN_SESSION_MASK:0,t.write(n.from([w])),p(t,u),5===a&&y.write(),j(t,h),c&&(5===a&&v.write(),R(t,c.topic),j(t,c.payload)),null!=f&&j(t,f),null!=d&&j(t,d),!0}function b(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,l=a.properties;let u=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=M(t,l),!h)return!1;u+=h.length}return t.write(r.CONNACK_HEADER),O(t,u),t.write(a.sessionPresent?r.SESSIONPRESENT_HEADER:i),t.write(n.from([c])),null!=h&&h.write(),!0}function w(e,t,i){c("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},l=a.qos||0,u=a.retain?r.RETAIN_MASK:0,h=a.topic,f=a.payload||o,d=a.messageId,m=a.properties;let g=0;if("string"==typeof h)g+=n.byteLength(h)+2;else{if(!n.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;g+=h.length+2}if(n.isBuffer(f)?g+=f.length:g+=n.byteLength(f),l&&"number"!=typeof d)return t.emit("error",new Error("Invalid messageId")),!1;l&&(g+=2);let y=null;if(5===s){if(y=M(t,m),!y)return!1;g+=y.length}return t.write(r.PUBLISH_HEADER[l][a.dup?1:0][u?1:0]),O(t,g),p(t,q(h)),t.write(h),l>0&&p(t,d),null!=y&&y.write(),c("publish: payload: %o",f),t.write(f)}function C(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,l=s.dup&&"pubrel"===a?r.DUP_MASK:0;let u=0;const h=s.reasonCode,f=s.properties;let d=5===i?3:2;if("pubrel"===a&&(u=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof f){if(m=U(t,f,o,d),!m)return!1;d+=m.length}return t.write(r.ACKS[a][u][l][0]),O(t,d),p(t,c),5===i&&t.write(n.from([h])),null!==m&&m.write(),!0}function _(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?r.DUP_MASK:0,l=s.messageId,u=s.subscriptions,h=s.properties;let f=0;if("number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;f+=2;let d=null;if(5===i){if(d=M(t,h),!d)return!1;f+=d.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const r=u[e].topic,o=u[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(u[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(u[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=u[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}f+=n.byteLength(r)+2+1}c("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),t.write(r.SUBSCRIBE_HEADER[1][a?1:0][0]),O(t,f),p(t,l),null!==d&&d.write();let m=!0;for(const e of u){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,l=e.rh;let u;R(t,o),u=r.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(u|=a?r.SUBSCRIBE_OPTIONS_NL:0,u|=c?r.SUBSCRIBE_OPTIONS_RAP:0,u|=l?r.SUBSCRIBE_OPTIONS_RH[l]:0),m=t.write(n.from([u]))}return m}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,l=s.properties;let u=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(u+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;u+=1}let h=null;if(5===i){if(h=U(t,l,o,u),!h)return!1;u+=h.length}return t.write(r.SUBACK_HEADER),O(t,u),p(t,a),null!==h&&h.write(),t.write(n.from(c))}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.unsubscriptions,u=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=n.byteLength(l[e])+2}let f=null;if(5===i){if(f=M(t,u),!f)return!1;h+=f.length}t.write(r.UNSUBSCRIBE_HEADER[1][c?1:0][0]),O(t,h),p(t,a),null!==f&&f.write();let d=!0;for(let e=0;e<l.length;e++)d=R(t,l[e]);return d}function E(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.granted,u=s.properties,h=s.cmd,f=0;let d=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),!1;d+=1}}let m=null;if(5===i){if(m=U(t,u,o,d),!m)return!1;d+=m.length}return t.write(r.ACKS[h][f][c][0]),O(t,d),p(t,a),null!==m&&m.write(),5===i&&t.write(n.from(l)),!0}function A(e,t,n){return t.write(r.EMPTY[e.cmd])}function T(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0,u=null;if(5===i){if(u=U(t,c,o,l),!u)return!1;l+=u.length}return t.write(n.from([r.codes.disconnect<<4])),O(t,l),5===i&&t.write(n.from([a])),null!==u&&u.write(),!0}function x(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const u=U(t,c,o,l);return!!u&&(l+=u.length,t.write(n.from([r.codes.auth<<4])),O(t,l),t.write(n.from([a])),null!==u&&u.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>p===B,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),p=B):(m=!1,p=N)}});const I={};function O(e,t){if(t>r.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=I[t];return n||(n=f(t),t<16384&&(I[t]=n)),c("writeVarByteInt: writing to stream: %o",n),e.write(n)}function R(e,t){const r=n.byteLength(t);return p(e,r),c("writeString: %s",t),e.write(t,"utf8")}function P(e,t,n){R(e,t),R(e,n)}function B(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",l[t]),e.write(l[t])}function N(e,t){const n=u(t);return c("writeNumberGenerated: %o",n),e.write(n)}function F(e,t){const n=d(t);return c("write4ByteNumber: %o",n),e.write(n)}function j(e,t){"string"==typeof t?R(e,t):t?(p(e,t.length),e.write(t)):p(e,0)}function M(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){D(e,{},0)}};let o=0;function i(t,o){let i=0;switch(r.propertiesTypes[t]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(f(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3+n.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce(((e,t)=>{const r=o[t];return Array.isArray(r)?e+=r.reduce(((e,r)=>e+=3+n.byteLength(t.toString())+2+n.byteLength(r.toString())),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(o[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${o}`)),!1}return i}if(t)for(const e in t){let n=0,r=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(r=i(e,s[t]),!r)return!1;n+=r}else{if(r=i(e,s),!r)return!1;n=r}if(!n)return!1;o+=n}return{length:n.byteLength(f(o))+o,write(){D(e,t,o)}}}function U(e,t,n,r){const o=["reasonString","userProperties"],i=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0;let s=M(e,t);if(i)for(;r+s.length>i;){const n=o.shift();if(!n||!t[n])return!1;delete t[n],s=M(e,t)}return s}function L(e,t,o){switch(r.propertiesTypes[t]){case"byte":e.write(n.from([r.properties[t]])),e.write(n.from([+o]));break;case"int8":e.write(n.from([r.properties[t]])),e.write(n.from([o]));break;case"binary":e.write(n.from([r.properties[t]])),j(e,o);break;case"int16":e.write(n.from([r.properties[t]])),p(e,o);break;case"int32":e.write(n.from([r.properties[t]])),F(e,o);break;case"var":e.write(n.from([r.properties[t]])),O(e,o);break;case"string":e.write(n.from([r.properties[t]])),R(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach((i=>{const s=o[i];Array.isArray(s)?s.forEach((o=>{e.write(n.from([r.properties[t]])),P(e,i.toString(),o.toString())})):(e.write(n.from([r.properties[t]])),P(e,i.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${o}`)),!1}}function D(e,t,n){O(e,n);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&null!==t[n]){const r=t[n];if(Array.isArray(r))for(let t=0;t<r.length;t++)L(e,n,r[t]);else L(e,n,r)}}function q(e){return e?e instanceof n?e.length:n.byteLength(e):0}function z(e){return"string"==typeof e||e instanceof n}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,c=365.25*s;function l(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function u(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}function h(e){var t=Math.abs(e);return t>=s?f(e,t,s,"day"):t>=i?f(e,t,i,"hour"):t>=o?f(e,t,o,"minute"):t>=r?f(e,t,r,"second"):e+" ms"}function f(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return l(e);if("number"===n&&isFinite(e))return t.long?h(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],46:[function(e,t,n){const r=e("./lib/number-allocator.js");t.exports.NumberAllocator=r},{"./lib/number-allocator.js":47}],47:[function(e,t,n){const r=e("js-sdsl").Set,o=e("debug")("number-allocator:trace"),i=e("debug")("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new r([],((e,t)=>e.compare(t))),o("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return o("alloc():empty"),null;const e=this.ss.front(),t=e.low;return t+1<=e.high?++e.low:this.ss.eraseElementByPos(0),o("alloc():"+t),t},a.prototype.use=function(e){const t=new s(e,e),n=this.ss.lowerBound(t);if(n){if(n.equals(t))return this.ss.eraseElementByValue(n),o("use():"+e),!0;if(n.low>e)return!1;if(n.low===e)return++n.low,o("use():"+e),!0;if(n.high===e)return--n.high,o("use():"+e),!0;const r=n.low;return n.low=e+1,this.ss.insert(new s(r,e-1)),o("use():"+e),!0}return o("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void i("free():"+e+" is out of range");const t=new s(e,e),n=this.ss.lowerBound(t);if(n){if(n.low<=e&&e<=n.high)return void i("free():"+e+" has already been vacant");if(n===this.ss.front())e+1===n.low?--n.low:this.ss.insert(t);else{const r=this.ss.reverseLowerBound(t);r.high+1===e?e+1===n.low?(this.ss.eraseElementByValue(r),n.low=r.low):r.high=e:e+1===n.low?n.low=e:this.ss.insert(t)}}else{if(n===this.ss.front())return void this.ss.insert(t);const r=this.ss.reverseLowerBound(t);r.high+1===e?r.high=e:this.ss.insert(t)}o("free():"+e)},a.prototype.clear=function(){o("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e)},t.exports=a},{debug:18,"js-sdsl":36}],48:[function(e,t,n){var r=e("wrappy");function o(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(o),t.exports.strict=r(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},{wrappy:79}],49:[function(e,t,n){(function(e){(function(){function n(t,n,r,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,n)}));case 3:return e.nextTick((function(){t.call(null,n,r)}));case 4:return e.nextTick((function(){t.call(null,n,r,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:n}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:50}],50:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function l(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var u,h=[],f=!1,d=-1;function p(){f&&u&&(f=!1,u.length?h=u.concat(h):d=-1,h.length&&m())}function m(){if(!f){var e=c(p);f=!0;for(var t=h.length;t;){for(u=h,h=[];++d<t;)u&&u[d].run();d=-1,t=h.length}u=null,f=!1,l(e)}}function g(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new g(e,t)),1!==h.length||f||c(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],51:[function(e,t,n){(function(e){(function(){!function(r){var o="object"==typeof n&&n&&!n.nodeType&&n,i="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,c,l=2147483647,u=36,h=1,f=26,d=38,p=700,m=72,g=128,y="-",v=/^xn--/,b=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=u-h,k=Math.floor,S=String.fromCharCode;function E(e){throw new RangeError(C[e])}function A(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function T(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+A((e=e.replace(w,".")).split("."),t).join(".")}function x(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function I(e){return A(e,(function(e){var t="";return e>65535&&(t+=S((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=S(e)})).join("")}function O(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:u}function R(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,n){var r=0;for(e=n?k(e/p):e>>1,e+=k(e/t);e>_*f>>1;r+=u)e=k(e/_);return k(r+(_+1)*e/(e+d))}function B(e){var t,n,r,o,i,s,a,c,d,p,v=[],b=e.length,w=0,C=g,_=m;for((n=e.lastIndexOf(y))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&E("not-basic"),v.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<b;){for(i=w,s=1,a=u;o>=b&&E("invalid-input"),((c=O(e.charCodeAt(o++)))>=u||c>k((l-w)/s))&&E("overflow"),w+=c*s,!(c<(d=a<=_?h:a>=_+f?f:a-_));a+=u)s>k(l/(p=u-d))&&E("overflow"),s*=p;_=P(w-i,t=v.length+1,0==i),k(w/t)>l-C&&E("overflow"),C+=k(w/t),w%=t,v.splice(w++,0,C)}return I(v)}function N(e){var t,n,r,o,i,s,a,c,d,p,v,b,w,C,_,A=[];for(b=(e=x(e)).length,t=g,n=0,i=m,s=0;s<b;++s)(v=e[s])<128&&A.push(S(v));for(r=o=A.length,o&&A.push(y);r<b;){for(a=l,s=0;s<b;++s)(v=e[s])>=t&&v<a&&(a=v);for(a-t>k((l-n)/(w=r+1))&&E("overflow"),n+=(a-t)*w,t=a,s=0;s<b;++s)if((v=e[s])<t&&++n>l&&E("overflow"),v==t){for(c=n,d=u;!(c<(p=d<=i?h:d>=i+f?f:d-i));d+=u)_=c-p,C=u-p,A.push(S(R(p+_%C,0))),c=k(_/C);A.push(S(R(c,0))),i=P(n,w,r==o),n=0,++r}++n,++t}return A.join("")}function F(e){return T(e,(function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e}))}function j(e){return T(e,(function(e){return b.test(e)?"xn--"+N(e):e}))}if(a={version:"1.4.1",ucs2:{decode:x,encode:I},decode:B,encode:N,toASCII:j,toUnicode:F},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!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],52:[function(e,t,n){function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var l=e.length;c>0&&l>c&&(l=c);for(var u=0;u<l;++u){var h,f,d,p,m=e[u].replace(a,"%20"),g=m.indexOf(n);g>=0?(h=m.substr(0,g),f=m.substr(g+1)):(h=m,f=""),d=decodeURIComponent(h),p=decodeURIComponent(f),r(s,d)?o(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],53:[function(e,t,n){var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],54:[function(e,t,n){n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":52,"./encode":53}],55:[function(e,t,n){function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var o={};function i(e,t,n){function i(e,n,r){return"string"==typeof t?t:t(e,n,r)}n||(n=Error);var s=function(e){function t(t,n,r){return e.call(this,i(t,n,r))||this}return r(t,e),t}(n);s.prototype.name=n.name,s.prototype.code=e,o[e]=s}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function c(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function l(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o;if("string"==typeof t&&a(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",c(e," argument"))o="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var i=l(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(i," ").concat(r," ").concat(s(t,"type"))}return o+=". Received type ".concat(typeof n)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=o},{}],56:[function(e,t,n){(function(n){(function(){var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(l,o);for(var s=r(i.prototype),a=0;a<s.length;a++){var c=s[a];l.prototype[c]||(l.prototype[c]=i.prototype[c])}function l(e){if(!(this instanceof l))return new l(e);o.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",u)))}function u(){this._writableState.ended||n.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}e("inherits")(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":59,inherits:24}],58:[function(e,t,n){(function(n,r){(function(){var o;t.exports=x,x.ReadableState=T,e("events").EventEmitter;var i=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,c=r.Uint8Array||function(){};function l(e){return a.from(e)}function u(e){return a.isBuffer(e)||e instanceof c}var h,f=e("util");h=f&&f.debuglog?f.debuglog("stream"):function(){};var d,p,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),v=e("./internal/streams/state").getHighWaterMark,b=e("../errors").codes,w=b.ERR_INVALID_ARG_TYPE,C=b.ERR_STREAM_PUSH_AFTER_EOF,_=b.ERR_METHOD_NOT_IMPLEMENTED,k=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(x,s);var S=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function A(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function T(t,n,r){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof o),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v(this,t,"readableHighWaterMark",r),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=e("string_decoder/").StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function x(t){if(o=o||e("./_stream_duplex"),!(this instanceof x))return new x(t);var n=this instanceof o;this._readableState=new T(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function I(e,t,n,r,o){h("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,F(e,s);else if(o||(i=R(s,t)),i)S(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=l(t)),r)s.endEmitted?S(e,new k):O(e,s,t,!0);else if(s.ended)S(e,new C);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?O(e,s,t,!1):U(e,s)):O(e,s,t,!1)}else r||(s.reading=!1,U(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function O(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&j(e)),U(e,t)}function R(e,t){var n;return u(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new w("chunk",["string","Buffer","Uint8Array"],t)),n}Object.defineProperty(x.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),x.prototype.destroy=y.destroy,x.prototype._undestroy=y.undestroy,x.prototype._destroy=function(e,t){t(e)},x.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=a.from(e,t),t=""),n=!0),I(this,e,t,!1,n)},x.prototype.unshift=function(e){return I(this,e,null,!0,!1)},x.prototype.isPaused=function(){return!1===this._readableState.flowing},x.prototype.setEncoding=function(t){d||(d=e("string_decoder/").StringDecoder);var n=new d(t);this._readableState.decoder=n,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,o="";null!==r;)o+=n.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};var P=1073741824;function B(e){return e>=P?e=P:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function N(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=B(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function F(e,t){if(h("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?j(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}function j(e){var t=e._readableState;h("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(M,e))}function M(e){var t=e._readableState;h("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,V(e)}function U(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(L,e,t))}function L(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(h("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function D(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,V(e))}}function q(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function z(e){h("readable nexttick read 0"),e.read(0)}function $(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(H,e,t))}function H(e,t){h("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),V(e),t.flowing&&!t.reading&&e.read(0)}function V(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function W(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function K(e){var t=e._readableState;h("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(Q,t,e))}function Q(e,t){if(h("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function J(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}x.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?K(this):j(this),null;if(0===(e=N(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=N(n,t))),null===(r=e>0?W(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&K(this)),null!==r&&this.emit("data",r),r},x.prototype._read=function(e){S(this,new _("_read()"))},x.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?y:c;function a(e,t){h("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,f())}function c(){h("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=D(r);e.on("drain",l);var u=!1;function f(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",p),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",d),u=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l()}function d(t){h("ondata");var n=e.write(t);h("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==J(o.pipes,e))&&!u&&(h("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function p(t){h("onerror",t),y(),e.removeListener("error",p),0===i(e,"error")&&S(e,t)}function m(){e.removeListener("finish",g),y()}function g(){h("onfinish"),e.removeListener("close",m),y()}function y(){h("unpipe"),r.unpipe(e)}return r.on("data",d),A(e,"error",p),e.once("close",m),e.once("finish",g),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},x.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=J(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},x.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,h("on readable",o.length,o.reading),o.length?j(this):o.reading||n.nextTick(z,this))),r},x.prototype.addListener=x.prototype.on,x.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(q,this),r},x.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(q,this),t},x.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!e.readableListening,$(this,e)),e.paused=!1,this},x.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},x.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var o in e.on("end",(function(){if(h("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){h("wrapped data"),n.decoder&&(o=n.decoder.write(o)),n.objectMode&&null==o||(n.objectMode||o&&o.length)&&(t.push(o)||(r=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var i=0;i<E.length;i++)e.on(E[i],this.emit.bind(this,E[i]));return this._read=function(t){h("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(x.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=e("./internal/streams/async_iterator")),p(this)}),Object.defineProperty(x.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(x.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(x.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),x._fromList=W,Object.defineProperty(x.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(x.from=function(t,n){return void 0===m&&(m=e("./internal/streams/from")),m(x,t,n)})}).call(this)}).call(this,e("_process"),void 0!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/async_iterator":61,"./internal/streams/buffer_list":62,"./internal/streams/destroy":63,"./internal/streams/from":65,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,events:22,inherits:24,"string_decoder/":75,util:16}],59:[function(e,t,n){t.exports=u;var r=e("../errors").codes,o=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=e("./_stream_duplex");function l(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);c.call(this,e),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush((function(t,n){f(e,t,n)}))}function f(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(u,c),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,n){n(new o("_transform()"))},u.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},u.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(e,t,n){(function(n,r){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){H(t,e)}}var i;t.exports=T,T.WritableState=A;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,l=r.Uint8Array||function(){};function u(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof l}var f,d=e("./internal/streams/destroy"),p=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,v=m.ERR_MULTIPLE_CALLBACK,b=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,C=m.ERR_STREAM_NULL_VALUES,_=m.ERR_STREAM_WRITE_AFTER_END,k=m.ERR_UNKNOWN_ENCODING,S=d.errorOrDestroy;function E(){}function A(t,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=p(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){F(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function T(t){var n=this instanceof(i=i||e("./_stream_duplex"));if(!n&&!f.call(T,this))return new T(t);this._writableState=new A(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function x(e,t){var r=new _;S(e,r),n.nextTick(t,r)}function I(e,t,r,o){var i;return null===r?i=new C:"string"==typeof r||t.objectMode||(i=new g("chunk",["string","Buffer"],r)),!i||(S(e,i),n.nextTick(o,i),!1)}function O(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,n)),t}function R(e,t,n,r,o,i){if(!n){var s=O(t,r,o);r!==s&&(n=!0,o="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else P(e,t,!1,a,r,o,i);return c}function P(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function B(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(z,e,t),e._writableState.errorEmitted=!0,S(e,o)):(i(o),e._writableState.errorEmitted=!0,S(e,o),z(e,t))}function N(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function F(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new v;if(N(r),t)B(e,r,o,t,i);else{var s=L(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||U(e,r),o?n.nextTick(j,e,r,s,i):j(e,r,s,i)}}function j(e,t,n,r){n||M(e,t),t.pendingcb--,r(),z(e,t)}function M(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function U(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),s=t.corkedRequestsFree;s.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,P(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,h=n.callback;if(P(e,t,!1,t.objectMode?1:l.length,l,u,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function L(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function D(e,t){e._final((function(n){t.pendingcb--,n&&S(e,n),t.prefinished=!0,e.emit("prefinish"),z(e,t)}))}function q(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(D,e,t)))}function z(e,t){var n=L(t);if(n&&(q(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function $(e,t,r){t.ending=!0,z(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function H(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}e("inherits")(T,a),A.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(A.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===T&&e&&e._writableState instanceof A}})):f=function(e){return e instanceof this},T.prototype.pipe=function(){S(this,new b)},T.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=u(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=E),r.ending?x(this,n):(i||I(this,r,e,n))&&(r.pendingcb++,o=R(this,r,i,e,t,n)),o},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||U(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new k(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,n){n(new y("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||$(this,r,n),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=d.destroy,T.prototype._undestroy=d.undestroy,T.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/destroy":63,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,inherits:24,"util-deprecate":78}],61:[function(e,t,n){(function(n){(function(){var r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),h=Symbol("handlePromise"),f=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var n=e[f].read();null!==n&&(e[u]=null,e[s]=null,e[a]=null,t(d(n,!1)))}}function m(e){n.nextTick(p,e)}function g(e,t){return function(n,r){e.then((function(){t[l]?n(d(void 0,!0)):t[h](n,r)}),r)}}var y=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(r={get stream(){return this[f]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(d(void 0,!0));if(this[f].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[c]?r(e[c]):t(d(void 0,!0))}))}));var r,o=this[u];if(o)r=new Promise(g(o,this));else{var i=this[f].read();if(null!==i)return Promise.resolve(d(i,!1));r=new Promise(this[h])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var e=this;return new Promise((function(t,n){e[f].destroy(null,(function(e){e?n(e):t(d(void 0,!0))}))}))})),r),y),b=function(e){var t,n=Object.create(v,(o(t={},f,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var r=n[f].read();r?(n[u]=null,n[s]=null,n[a]=null,e(d(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[u]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[u]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var r=n[s];null!==r&&(n[u]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[l]=!0})),e.on("readable",m.bind(null,n)),n};t.exports=b}).call(this)}).call(this,e("_process"))},{"./end-of-stream":64,_process:50}],62:[function(e,t,n){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}var l=e("buffer").Buffer,u=e("util").inspect,h=u&&u.custom||"inspect";function f(e,t,n){l.prototype.copy.call(e,t,n)}t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return l.alloc(0);for(var t=l.allocUnsafe(e>>>0),n=this.head,r=0;n;)f(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?r+=o:r+=o.slice(0,e),0==(e-=i)){i===o.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=l.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(i));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return u(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:17,util:16}],63:[function(e,t,n){(function(e){(function(){function n(t,n){var i=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(n?n(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!n&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(o,i):(i._writableState.errorEmitted=!0,e.nextTick(r,i,t)):e.nextTick(r,i,t):n?(e.nextTick(o,i),n(t)):e.nextTick(o,i)})),this)}function r(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function s(e,t){e.emit("error",t)}function a(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:n,undestroy:i,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:50}],64:[function(e,t,n){var r=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function o(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];e.apply(this,r)}}}function i(){}function s(e){return e.setHeader&&"function"==typeof e.abort}function a(e,t,n){if("function"==typeof t)return a(e,null,t);t||(t={}),n=o(n||i);var c=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,u=function(){e.writable||f()},h=e._writableState&&e._writableState.finished,f=function(){l=!1,h=!0,c||n.call(e)},d=e._readableState&&e._readableState.endEmitted,p=function(){c=!1,d=!0,l||n.call(e)},m=function(t){n.call(e,t)},g=function(){var t;return c&&!d?(e._readableState&&e._readableState.ended||(t=new r),n.call(e,t)):l&&!h?(e._writableState&&e._writableState.ended||(t=new r),n.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return s(e)?(e.on("complete",f),e.on("abort",g),e.req?y():e.on("request",y)):l&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",p),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",f),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",p),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":55}],65:[function(e,t,n){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(e,t,n){var r;function o(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=e("../../../errors").codes,s=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function c(e){if(e)throw e}function l(e){return e.setHeader&&"function"==typeof e.abort}function u(t,n,i,s){s=o(s);var c=!1;t.on("close",(function(){c=!0})),void 0===r&&(r=e("./end-of-stream")),r(t,{readable:n,writable:i},(function(e){if(e)return s(e);c=!0,s()}));var u=!1;return function(e){if(!c&&!u)return u=!0,l(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function f(e,t){return e.pipe(t)}function d(e){return e.length?"function"!=typeof e[e.length-1]?c:e.pop():c}function p(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=d(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new s("streams");var i=t.map((function(e,n){var s=n<t.length-1;return u(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(h),s||(i.forEach(h),o(r))}))}));return t.reduce(f)}t.exports=p},{"../../../errors":55,"./end-of-stream":64}],67:[function(e,t,n){var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function o(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}function i(e,t,n,i){var s=o(t,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}},{"../../../errors":55}],68:[function(e,t,n){t.exports=e("events").EventEmitter},{events:22}],69:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":56,"./lib/_stream_passthrough.js":57,"./lib/_stream_readable.js":58,"./lib/_stream_transform.js":59,"./lib/_stream_writable.js":60,"./lib/internal/streams/end-of-stream.js":64,"./lib/internal/streams/pipeline.js":66}],70:[function(e,t,n){function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}function o(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new r(arguments[0],arguments[1],e)}t.exports=o},{}],71:[function(e,t,n){t.exports=e("./index.js")()},{"./index.js":72}],72:[function(e,t,n){(function(e){(function(){function n(t){return t instanceof e?e.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function r(e){return(e=e||{}).circles?o(e):e.proto?i:r;function t(e,t){for(var r=Object.keys(e),o=new Array(r.length),i=0;i<r.length;i++){var s=r[i],a=e[s];"object"!=typeof a||null===a?o[s]=a:a instanceof Date?o[s]=new Date(a):ArrayBuffer.isView(a)?o[s]=n(a):o[s]=t(a)}return o}function r(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,r);if(e instanceof Map)return new Map(t(Array.from(e),r));if(e instanceof Set)return new Set(t(Array.from(e),r));var o={};for(var i in e)if(!1!==Object.hasOwnProperty.call(e,i)){var s=e[i];"object"!=typeof s||null===s?o[i]=s:s instanceof Date?o[i]=new Date(s):s instanceof Map?o[i]=new Map(t(Array.from(s),r)):s instanceof Set?o[i]=new Set(t(Array.from(s),r)):ArrayBuffer.isView(s)?o[i]=n(s):o[i]=r(s)}return o}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,i);if(e instanceof Map)return new Map(t(Array.from(e),i));if(e instanceof Set)return new Set(t(Array.from(e),i));var r={};for(var o in e){var s=e[o];"object"!=typeof s||null===s?r[o]=s:s instanceof Date?r[o]=new Date(s):s instanceof Map?r[o]=new Map(t(Array.from(s),i)):s instanceof Set?r[o]=new Set(t(Array.from(s),i)):ArrayBuffer.isView(s)?r[o]=n(s):r[o]=i(s)}return r}}function o(e){var t=[],r=[];return e.proto?s:i;function o(e,o){for(var i=Object.keys(e),s=new Array(i.length),a=0;a<i.length;a++){var c=i[a],l=e[c];if("object"!=typeof l||null===l)s[c]=l;else if(l instanceof Date)s[c]=new Date(l);else if(ArrayBuffer.isView(l))s[c]=n(l);else{var u=t.indexOf(l);s[c]=-1!==u?r[u]:o(l)}}return s}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,i);if(e instanceof Map)return new Map(o(Array.from(e),i));if(e instanceof Set)return new Set(o(Array.from(e),i));var s={};for(var a in t.push(e),r.push(s),e)if(!1!==Object.hasOwnProperty.call(e,a)){var c=e[a];if("object"!=typeof c||null===c)s[a]=c;else if(c instanceof Date)s[a]=new Date(c);else if(c instanceof Map)s[a]=new Map(o(Array.from(c),i));else if(c instanceof Set)s[a]=new Set(o(Array.from(c),i));else if(ArrayBuffer.isView(c))s[a]=n(c);else{var l=t.indexOf(c);s[a]=-1!==l?r[l]:i(c)}}return t.pop(),r.pop(),s}function s(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,s);if(e instanceof Map)return new Map(o(Array.from(e),s));if(e instanceof Set)return new Set(o(Array.from(e),s));var i={};for(var a in t.push(e),r.push(i),e){var c=e[a];if("object"!=typeof c||null===c)i[a]=c;else if(c instanceof Date)i[a]=new Date(c);else if(c instanceof Map)i[a]=new Map(o(Array.from(c),s));else if(c instanceof Set)i[a]=new Set(o(Array.from(c),s));else if(ArrayBuffer.isView(c))i[a]=n(c);else{var l=t.indexOf(c);i[a]=-1!==l?r[l]:s(c)}}return t.pop(),r.pop(),i}}t.exports=r}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],73:[function(e,t,n){
4
+ n.read=function(e,t,n,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,l=c>>1,u=-7,h=n?o-1:0,f=n?-1:1,d=e[t+h];for(h+=f,i=d&(1<<-u)-1,d>>=-u,u+=a;u>0;i=256*i+e[t+h],h+=f,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=256*s+e[t+h],h+=f,u-=8);if(0===i)i=1-l;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),i-=l}return(d?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,l=8*i-o-1,u=(1<<l)-1,h=u>>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[n+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,l+=o;l>0;e[n+d]=255&s,d+=p,s/=256,l-=8);e[n+d-p]|=128*m}},{}],24:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],25:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var r=function(){function e(e,t){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=e,this.value=t}return e.prototype.rotateLeft=function(){var e=this.parent,t=this.brother,n=this.leftChild,r=this.rightChild;if(!r)throw new Error("unknown error");var o=r.leftChild,i=r.rightChild;return e&&(e.leftChild===this?e.leftChild=r:e.rightChild===this&&(e.rightChild=r)),r.parent=e,r.brother=t,r.leftChild=this,r.rightChild=i,t&&(t.brother=r),this.parent=r,this.brother=i,this.leftChild=n,this.rightChild=o,i&&(i.parent=r,i.brother=this),n&&(n.parent=this,n.brother=o),o&&(o.parent=this,o.brother=n),r},e.prototype.rotateRight=function(){var e=this.parent,t=this.brother,n=this.leftChild;if(!n)throw new Error("unknown error");var r=this.rightChild,o=n.leftChild,i=n.rightChild;return e&&(e.leftChild===this?e.leftChild=n:e.rightChild===this&&(e.rightChild=n)),n.parent=e,n.brother=t,n.leftChild=o,n.rightChild=this,t&&(t.brother=n),o&&(o.parent=n,o.brother=this),this.parent=n,this.brother=o,this.leftChild=i,this.rightChild=r,i&&(i.parent=this,i.brother=r),r&&(r.parent=this,r.brother=i),n},e.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},e.TreeNodeColorType={red:!0,black:!1},e}();Object.freeze(r),n.default=r},{}],26:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};function o(e){var t=this;void 0===e&&(e=[]);var n=[],i=0,s=0,a=0,c=0,l=0,u=0;this.size=function(){return u},this.empty=function(){return 0===u},this.clear=function(){i=a=s=c=l=u=0,f.call(this,o.bucketSize),u=0},this.front=function(){return n[i][s]},this.back=function(){return n[a][c]},this.forEach=function(e){if(!this.empty()){var t=0;if(i!==a){for(l=s;l<o.bucketSize;++l)e(n[i][l],t++);for(l=i+1;l<a;++l)for(var r=0;r<o.bucketSize;++r)e(n[l][r],t++);for(l=0;l<=c;++l)e(n[a][l],t++)}else for(var l=s;l<=c;++l)e(n[i][l],t++)}};var h=function(e){var t=i*o.bucketSize+s,n=t+e,r=a*o.bucketSize+c;if(n<t||n>r)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(n/o.bucketSize),curNodePointerIndex:n%o.bucketSize}};this.getElementByPos=function(e){var t=h(e),r=t.curNodeBucketIndex,o=t.curNodePointerIndex;return n[r][o]},this.eraseElementByPos=function(e){var t=this;if(e<0||e>u)throw new Error("pos should more than 0 and less than queue's size");if(0===e)this.popFront();else if(e===this.size())this.popBack();else{for(var n=[],r=e+1;r<u;++r)n.push(this.getElementByPos(r));this.cut(e),this.popBack(),n.forEach((function(e){return t.pushBack(e)}))}},this.eraseElementByValue=function(e){if(!this.empty()){var t=[];this.forEach((function(n){n!==e&&t.push(n)}));for(var n=t.length,r=0;r<n;++r)this.setElementByPos(r,t[r]);this.cut(n-1)}};var f=function(e){for(var t=[],r=e*o.sigma,h=Math.max(Math.ceil(r/o.bucketSize),2),f=0;f<h;++f)t.push(new Array(o.bucketSize));var d=Math.ceil(e/o.bucketSize),p=Math.floor(h/2)-Math.floor(d/2),m=p,g=0;if(this.size())for(f=0;f<d;++f){for(var y=0;y<o.bucketSize;++y)if(t[p+f][y]=this.front(),this.popFront(),this.empty()){m=p+f,g=y;break}if(this.empty())break}n=t,i=p,s=0,a=m,c=g,l=h,u=e};this.pushBack=function(e){this.empty()||(a===l-1&&c===o.bucketSize-1&&f.call(this,this.size()),c<o.bucketSize-1?++c:a<l-1&&(++a,c=0)),++u,n[a][c]=e},this.popBack=function(){this.empty()||(1!==this.size()&&(c>0?--c:i<a&&(--a,c=o.bucketSize-1)),u>0&&--u)},this.setElementByPos=function(e,t){var r=h(e),o=r.curNodeBucketIndex,i=r.curNodePointerIndex;n[o][i]=t},this.insert=function(e,t,n){var r=this;if(void 0===n&&(n=1),0===e)for(;n--;)this.pushFront(t);else if(e===this.size())for(;n--;)this.pushBack(t);else{for(var o=[],i=e;i<u;++i)o.push(this.getElementByPos(i));for(this.cut(e-1),i=0;i<n;++i)this.pushBack(t);o.forEach((function(e){return r.pushBack(e)}))}},this.find=function(e){if(i===a){for(var t=s;t<=c;++t)if(n[i][t]===e)return!0;return!1}for(t=s;t<o.bucketSize;++t)if(n[i][t]===e)return!0;for(t=i+1;t<a;++t)for(var r=0;r<o.bucketSize;++r)if(n[t][r]===e)return!0;for(t=0;t<=c;++t)if(n[a][t]===e)return!0;return!1},this.reverse=function(){for(var e=0,t=u-1;e<t;){var n=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,n),++e,--t}},this.unique=function(){if(!this.empty()){var e=[],t=this.front();this.forEach((function(n,r){0!==r&&n===t||(e.push(n),t=n)}));for(var n=0;n<u;++n)this.setElementByPos(n,e[n]);this.cut(e.length-1)}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);for(var n=0;n<u;++n)this.setElementByPos(n,t[n])},this.pushFront=function(e){this.empty()||(0===i&&0===s&&f.call(this,this.size()),s>0?--s:i>0&&(--i,s=o.bucketSize-1)),++u,n[i][s]=e},this.popFront=function(){this.empty()||(1!==this.size()&&(s<o.bucketSize-1?++s:i<a&&(++i,s=0)),u>0&&--u)},this.shrinkToFit=function(){var e=this,t=[];this.forEach((function(e){t.push(e)}));var r=t.length;n=[];for(var i=Math.ceil(r/o.bucketSize),s=0;s<i;++s)n.push(new Array(o.bucketSize));this.clear(),t.forEach((function(t){return e.pushBack(t)}))},this.cut=function(e){if(e<0)this.clear();else{var t=h(e),n=t.curNodeBucketIndex,r=t.curNodePointerIndex;a=n,c=r,u=e+1}},this[Symbol.iterator]=function(){return function(){var e,t;return r(this,(function(r){switch(r.label){case 0:if(0===u)return[2];if(i!==a)return[3,5];t=s,r.label=1;case 1:return t<=c?[4,n[i][t]]:[3,4];case 2:r.sent(),r.label=3;case 3:return++t,[3,1];case 4:return[2];case 5:t=s,r.label=6;case 6:return t<o.bucketSize?[4,n[i][t]]:[3,9];case 7:r.sent(),r.label=8;case 8:return++t,[3,6];case 9:t=i+1,r.label=10;case 10:if(!(t<a))return[3,15];e=0,r.label=11;case 11:return e<o.bucketSize?[4,n[t][e]]:[3,14];case 12:r.sent(),r.label=13;case 13:return++e,[3,11];case 14:return++t,[3,10];case 15:t=0,r.label=16;case 16:return t<=c?[4,n[a][t]]:[3,19];case 17:r.sent(),r.label=18;case 18:return++t,[3,16];case 19:return[2]}}))}()},function(){var r=o.bucketSize;e.size?r=e.size():e.length&&(r=e.length);var s=r*o.sigma;l=Math.ceil(s/o.bucketSize),l=Math.max(l,3);for(var c=0;c<l;++c)n.push(new Array(o.bucketSize));var u=Math.ceil(r/o.bucketSize);i=Math.floor(l/2)-Math.floor(u/2),a=i,e.forEach((function(e){return t.pushBack(e)}))}(),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),o.sigma=3,o.bucketSize=5e3,Object.freeze(o),n.default=o},{}],27:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../LinkList/LinkList"),s=e("../Map/Map");function a(e,t,n){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),n=n||function(e){var t,n,r=0,i="";if("number"==typeof e)r=((r=Math.floor(e))<<5)-r,r&=r;else{i="string"!=typeof e?JSON.stringify(e):e;try{for(var s=o(i),a=s.next();!a.done;a=s.next())r=(r<<5)-r+a.value.charCodeAt(0),r&=r}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}}return r^=r>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(n){n.forEach((function(n){e(n,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(r,o){if(!r.empty()){if(r instanceof i.default&&1===r.size()){var c=r.front(),l=c.key,f=c.value;t[n(l)&h-1]=new i.default([{key:l,value:f}])}else if(r instanceof s.default){var d=new i.default,p=new i.default;r.forEach((function(t){0==(n(t.key)&e)?d.pushBack(t):p.pushBack(t)})),d.size()>a.untreeifyThreshold?t[o]=new s.default(d):d.size()&&(t[o]=d),p.size()>a.untreeifyThreshold?t[o+e]=new s.default(p):p.size()&&(t[o+e]=p)}else{var m=new i.default,g=new i.default;r.forEach((function(t){0==(n(t.key)&e)?m.pushBack(t):g.pushBack(t)})),m.size()&&(t[o]=m),g.size()&&(t[o+e]=g)}u[o].clear()}})),u=t}};this.setElement=function(e,t){var r,c;if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=t){var d=n(e)&h-1;if(u[d]){var p=u[d].size();if(u[d]instanceof i.default){try{for(var m=o(u[d]),g=m.next();!g.done;g=m.next()){var y=g.value;if(y.key===e)return void(y.value=t)}}catch(e){r={error:e}}finally{try{g&&!g.done&&(c=m.return)&&c.call(m)}finally{if(r)throw r.error}}u[d].pushBack({key:e,value:t}),u[d].size()>=a.treeifyThreshold&&(u[d]=new s.default(u[d]))}else u[d].setElement(e,t);var v=u[d].size();l+=v-p}else++l,u[d]=new i.default([{key:e,value:t}]);l>h*a.sigma&&f.call(this,h)}else this.eraseElementByKey(e)},this.getElementByKey=function(e){var t,r,i=n(e)&h-1;if(u[i]){if(u[i]instanceof s.default)return u[i].getElementByKey(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next()){var l=c.value;if(l.key===e)return l.value}}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}},this.eraseElementByKey=function(e){var t,r,c=n(e)&h-1;if(u[c]){var f=u[c].size();if(u[c]instanceof s.default)u[c].eraseElementByKey(e),u[c].size()<=a.untreeifyThreshold&&(u[c]=new i.default(u[c]));else{var d=-1;try{for(var p=o(u[c]),m=p.next();!m.done;m=p.next()){var g=m.value;if(++d,g.key===e){u[c].eraseElementByPos(d);break}}}catch(e){t={error:e}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(t)throw t.error}}}var y=u[c].size();l+=y-f}},this.find=function(e){var t,r,i=n(e)&h-1;if(!u[i])return!1;if(u[i]instanceof s.default)return u[i].find(e);try{for(var a=o(u[i]),c=a.next();!c.done;c=a.next())if(c.value.key===e)return!0}catch(e){t={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return!1},this[Symbol.iterator]=function(){return function(){var e,t,n,i,s,a;return r(this,(function(r){switch(r.label){case 0:e=0,r.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];r.label=2;case 2:r.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),n=t.next(),r.label=3;case 3:return n.done?[3,6]:[4,n.value];case 4:r.sent(),r.label=5;case 5:return n=t.next(),[3,3];case 6:return[3,9];case 7:return i=r.sent(),s={error:i},[3,9];case 8:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){var t=e.key,n=e.value;return c.setElement(t,n)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),n.default=a},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Set/Set"),s=e("../LinkList/LinkList");function a(e,t,n){var c=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),n=n||function(e){var t=0,n="";if("number"==typeof e)t=((t=Math.floor(e))<<5)-t,t&=t;else{n="string"!=typeof e?JSON.stringify(e):e;for(var r=0;r<n.length;r++)t=(t<<5)-t+n.charCodeAt(r),t&=t}return t^=t>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var l=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return l},this.empty=function(){return 0===l},this.clear=function(){l=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(n){n.forEach((function(n){e(n,t++)}))}))};var f=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(r,o){if(!r.empty()){if(r instanceof s.default&&1===r.size()){var c=r.front();if(void 0===c)throw new Error("unknown error");t[n(c)&h-1]=new s.default([c])}else if(r instanceof i.default){var l=new s.default,f=new s.default;r.forEach((function(t){0==(n(t)&e)?l.pushBack(t):f.pushBack(t)})),l.size()>a.untreeifyThreshold?t[o]=new i.default(l):l.size()&&(t[o]=l),f.size()>a.untreeifyThreshold?t[o+e]=new i.default(f):f.size()&&(t[o+e]=f)}else{var d=new s.default,p=new s.default;r.forEach((function(t){0==(n(t)&e)?d.pushBack(t):p.pushBack(t)})),d.size()&&(t[o]=d),p.size()&&(t[o+e]=p)}u[o].clear()}})),u=t}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var t=n(e)&h-1;if(u[t]){var r=u[t].size();if(u[t]instanceof s.default){if(u[t].find(e))return;u[t].pushBack(e),u[t].size()>=a.treeifyThreshold&&(u[t]=new i.default(u[t]))}else u[t].insert(e);var o=u[t].size();l+=o-r}else u[t]=new s.default([e]),++l;l>h*a.sigma&&f.call(this,h)},this.eraseElementByValue=function(e){var t=n(e)&h-1;if(u[t]){var r=u[t].size();u[t].eraseElementByValue(e),u[t]instanceof i.default&&u[t].size()<=a.untreeifyThreshold&&(u[t]=new s.default(u[t]));var o=u[t].size();l+=o-r}},this.find=function(e){var t=n(e)&h-1;return!!u[t]&&u[t].find(e)},this[Symbol.iterator]=function(){return function(){var e,t,n,i,s,a;return r(this,(function(r){switch(r.label){case 0:e=0,r.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];r.label=2;case 2:r.trys.push([2,7,8,9]),s=void 0,t=o(u[e]),n=t.next(),r.label=3;case 3:return n.done?[3,6]:[4,n.value];case 4:r.sent(),r.label=5;case 5:return n=t.next(),[3,3];case 6:return[3,9];case 7:return i=r.sent(),s={error:i},[3,9];case 8:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){return c.insert(e)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),n.default=a},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}};Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e}return e}();function i(e){var t=this;void 0===e&&(e=[]);var n=0,i=void 0,s=void 0;this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){i=s=void 0,n=0},this.front=function(){return null==i?void 0:i.value},this.back=function(){return null==s?void 0:s.value},this.forEach=function(e){for(var t=i,n=0;t;){if(void 0===t.value)throw new Error("unknown error");e(t.value,n++),t=t.next}},this.getElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more then 0 and less then the list length");for(var t=i;e--&&t;)t=t.next;if(!t||void 0===t.value)throw new Error("unknown error");return t.value},this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("erase pos must more then 0 and less then the list length");if(0===e)this.popFront();else if(e===n-1)this.popBack();else{for(var t=i;e--;){if(!(null==t?void 0:t.next))throw new Error("unknown error");t=t.next}if(!t||!t.pre||!t.next)throw new Error("unknown error");var r=t.pre,o=t.next;o.pre=r,r.next=o,n>0&&--n}},this.eraseElementByValue=function(e){for(;i&&i.value===e;)this.popFront();for(;s&&s.value===e;)this.popBack();if(i)for(var t=i;t;){if(t.value===e){var r=t.pre,o=t.next;o&&(o.pre=r),r&&(r.next=o),n>0&&--n}t=t.next}},this.pushBack=function(e){if(null==e)throw new Error("you can't push null or undefined here");++n;var t=new o(e);s?(s.next=t,t.pre=s,s=t):i=s=t},this.popBack=function(){s&&(n>0&&--n,s&&(i===s?i=s=void 0:(s=s.pre)&&(s.next=void 0)))},this.setElementByPos=function(e,t){if(null==t)throw new Error("you can't set null or undefined here");if(e<0||e>=n)throw new Error("pos must more then 0 and less then the list length");for(var r=i;e--;){if(!r)throw new Error("unknown error");r=r.next}r&&(r.value=t)},this.insert=function(e,t,r){if(void 0===r&&(r=1),null==t)throw new Error("you can't insert null or undefined here");if(e<0||e>n)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(r<0)throw new Error("insert size must more than 0");if(0===e)for(;r--;)this.pushFront(t);else if(e===n)for(;r--;)this.pushBack(t);else{for(var s=i,a=1;a<e;++a){if(!(null==s?void 0:s.next))throw new Error("unknown error");s=null==s?void 0:s.next}if(!s)throw new Error("unknown error");var c=s.next;for(n+=r;r--;)s.next=new o(t),s.next.pre=s,s=s.next;s.next=c,c&&(c.pre=s)}},this.find=function(e){for(var t=i;t;){if(t.value===e)return!0;t=t.next}return!1},this.reverse=function(){for(var e=i,t=s,r=0;e&&t&&2*r<n;){var o=e.value;e.value=t.value,t.value=o,e=e.next,t=t.pre,++r}},this.unique=function(){for(var e=i;e;){for(var t=e;t&&t.next&&t.value===t.next.value;)t=t.next,n>0&&--n;e.next=t.next,e.next&&(e.next.pre=e),e=e.next}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);var n=i;t.forEach((function(e){n&&(n.value=e,n=n.next)}))},this.pushFront=function(e){if(null==e)throw new Error("you can't push null or undefined here");++n;var t=new o(e);i?(t.next=i,i.pre=t,i=t):i=s=t},this.popFront=function(){i&&(n>0&&--n,i&&(i===s?i=s=void 0:(i=i.next)&&(i.pre=void 0)))},this.merge=function(e){var t=this,r=i;e.forEach((function(e){for(;r&&void 0!==r.value&&r.value<=e;)r=r.next;if(void 0===r)t.pushBack(e),r=s;else if(r===i)t.pushFront(e),r=i;else{++n;var a=r.pre;a&&(a.next=new o(e),a.next.pre=a,a.next.next=r,r&&(r.pre=a.next))}}))},this[Symbol.iterator]=function(){return function(){var e;return r(this,(function(t){switch(t.label){case 0:e=i,t.label=1;case 1:if(void 0===e)return[3,3];if(!e.value)throw new Error("unknown error");return[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.freeze(i),n.default=i},{}],30:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var n=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=a.value=void 0,a.leftChild=a.rightChild=a.brother=void 0};var c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty()){var e=c(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.back=function(){if(!this.empty()){var e=l(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.forEach=function(e){var t,n,r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,r++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,n;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===e)return a;++r}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw new Error("unknown Error")};var u=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value){var r=t(e.key,n);return 0===r?{key:e.key,value:e.value}:r<0?u(e.rightChild,n):u(e.leftChild,n)||{key:e.key,value:e.value}}};this.lowerBound=function(e){return u(a,e)};var h=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,n)<=0?h(e.rightChild,n):h(e.leftChild,n)||{key:e.key,value:e.value}};this.upperBound=function(e){return h(a,e)};var f=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value){var r=t(e.key,n);return 0===r?{key:e.key,value:e.value}:r>0?f(e.leftChild,n):f(e.rightChild,n)||{key:e.key,value:e.value}}};this.reverseLowerBound=function(e){return f(a,e)};var d=function(e,n){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,n)>=0?d(e.leftChild,n):d(e.rightChild,n)||{key:e.key,value:e.value}};this.reverseUpperBound=function(e){return d(a,e)};var p=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var n=e.brother;if(!n)throw new Error("unknown error");if(e===t.leftChild)if(n.color===i.default.TreeNodeColorType.red){n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var r=t.rotateLeft();a===t&&(a=r),p(e)}else n.color===i.default.TreeNodeColorType.black&&(n.rightChild&&n.rightChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=t.rotateLeft(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||!n.leftChild||n.leftChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,p(t)):(n.color=i.default.TreeNodeColorType.red,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=n.rotateRight(),a===n&&(a=r),p(e)));else e===t.rightChild&&(n.color===i.default.TreeNodeColorType.red?(n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,r=t.rotateRight(),a===t&&(a=r),p(e)):n.color===i.default.TreeNodeColorType.black&&(n.leftChild&&n.leftChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=t.rotateRight(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||!n.rightChild||n.rightChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,p(t)):(n.color=i.default.TreeNodeColorType.red,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=n.rotateLeft(),a===n&&(a=r),p(e))))}else e.color=i.default.TreeNodeColorType.black},m=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var n=e.key;e.key=t.key,t.key=n;var r=e.value;e.value=t.value,t.value=r,e=t}t.leftChild&&(t=l(t.leftChild),n=e.key,e.key=t.key,t.key=n,r=e.value,e.value=t.value,t.value=r,e=t)}p(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},g=function(e,t){return!(!e||void 0===e.key)&&(!!g(e.leftChild,t)||!!t(e)||g(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;g(a,(function(n){return e===t?(m(n),!0):(++t,!1)}))},this.eraseElementByKey=function(e){if(!this.empty()){var n=b(a,e);void 0!==n&&void 0!==n.key&&0===t(n.key,e)&&m(n)}};var y=function(e,n){if(!e||void 0===e.key)throw new Error("unknown error");var r=t(n,e.key);return r<0?e.leftChild?y(e.leftChild,n):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):r>0?e.rightChild?y(e.rightChild,n):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},v=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var n=t.brother,r=t.parent;if(!r)throw new Error("unknown error");if(n&&n.color===i.default.TreeNodeColorType.red)n.color=t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,v(r);else if(!n||n.color===i.default.TreeNodeColorType.black)if(t===r.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red;var o=r.rotateRight();r===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),r===a&&(a=o),v(t));else t===r.rightChild&&(e===t.leftChild?(o=t.rotateRight(),r===a&&(a=o),v(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,o=r.rotateLeft(),r===a&&(a=o)))}};this.setElement=function(e,n){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=n){if(this.empty())return++s,a.key=e,a.value=n,void(a.color=i.default.TreeNodeColorType.black);var r=y(a,e);void 0===r.key||0!==t(r.key,e)?(++s,r.key=e,r.value=n,v(r),a.color=i.default.TreeNodeColorType.black):r.value=n}else this.eraseElementByKey(e)};var b=function(e,n){if(e&&void 0!==e.key){var r=t(n,e.key);return r<0?b(e.leftChild,n):r>0?b(e.rightChild,n):e}};this.find=function(e){return!!b(a,e)},this.getElementByKey=function(e){var t=b(a,e);if(void 0===(null==t?void 0:t.key)||void 0===(null==t?void 0:t.value))throw new Error("unknown error");return t.value},this.union=function(e){var t=this;e.forEach((function(e){var n=e.key,r=e.value;return t.setElement(n,r)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return r(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key&&void 0!==e.value?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,{key:e.key,value:e.value}];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){var t=e.key,r=e.value;return n.setElement(t,r)})),Object.freeze(this)}Object.freeze(s),n.default=s},{"../Base/TreeNode":25}],31:[function(e,t,n){function r(e,t){void 0===e&&(e=[]),t=t||function(e,t){return e>t?-1:e<t?1:0};var n=[];e.forEach((function(e){return n.push(e)}));var r=n.length,o=function(e,t){if(e<0||e>=r)throw new Error("unknown error");if(t<0||t>=r)throw new Error("unknown error");var o=n[e];n[e]=n[t],n[t]=o},i=function(e){if(e<0||e>=r)throw new Error("unknown error");var i=2*e+1,s=2*e+2;i<r&&t(n[e],n[i])>0&&o(e,i),s<r&&t(n[e],n[s])>0&&o(e,s)};!function(){for(var e=Math.floor((r-1)/2);e>=0;--e)for(var i=e,s=2*i+1;s<r;){var a=s+1,c=s;if(a<r&&t(n[s],n[a])>0&&(c=a),t(n[i],n[c])<=0)break;o(i,c),s=2*(i=c)+1}}(),this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,n.length=0},this.push=function(e){if(n.push(e),1!=++r)for(var o=r-1;o>0;){var s=Math.floor((o-1)/2);if(t(n[s],e)<=0)break;i(s),o=s}},this.pop=function(){if(!this.empty())if(1!==this.size()){var e=n[r-1];--r;for(var o=0;o<this.size();){var i=2*o+1,s=2*o+2;if(i>=this.size())break;var a=i;if(s<this.size()&&t(n[i],n[s])>0&&(a=s),t(n[a],e)>=0)break;n[o]=n[a],o=a}n[o]=e}else--r},this.top=function(){return n[0]},Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],32:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0});var r=e("../LinkList/LinkList");function o(e){void 0===e&&(e=[]);var t=new r.default(e);this.size=function(){return t.size()},this.empty=function(){return t.empty()},this.clear=function(){t.clear()},this.push=function(e){t.pushBack(e)},this.pop=function(){t.popFront()},this.front=function(){return t.front()},Object.freeze(this)}Object.freeze(o),n.default=o},{"../LinkList/LinkList":29}],33:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var i=e("../Base/TreeNode");function s(e,t){var n=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new i.default;a.color=i.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=void 0,a.leftChild=a.rightChild=a.brother=a.parent=void 0,a.color=i.default.TreeNodeColorType.black};var c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?c(e.leftChild):e},l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?l(e.rightChild):e};this.front=function(){if(!this.empty())return c(a).key},this.back=function(){if(!this.empty())return l(a).key},this.forEach=function(e){var t,n,r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next())e(s.value,r++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,n;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var r=0;try{for(var i=o(this),s=i.next();!s.done;s=i.next()){var a=s.value;if(r===e)return a;++r}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw new Error("unknown error")};var u=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==i.default.TreeNodeColorType.red){var n=e.brother;if(!n)throw new Error("unknown error");if(e===t.leftChild)if(n.color===i.default.TreeNodeColorType.red){n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red;var r=t.rotateLeft();a===t&&(a=r),u(e)}else n.color===i.default.TreeNodeColorType.black&&(n.rightChild&&n.rightChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=t.rotateLeft(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||!n.leftChild||n.leftChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,u(t)):(n.color=i.default.TreeNodeColorType.red,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=n.rotateRight(),a===n&&(a=r),u(e)));else e===t.rightChild&&(n.color===i.default.TreeNodeColorType.red?(n.color=i.default.TreeNodeColorType.black,t.color=i.default.TreeNodeColorType.red,r=t.rotateRight(),a===t&&(a=r),u(e)):n.color===i.default.TreeNodeColorType.black&&(n.leftChild&&n.leftChild.color===i.default.TreeNodeColorType.red?(n.color=t.color,t.color=i.default.TreeNodeColorType.black,n.leftChild&&(n.leftChild.color=i.default.TreeNodeColorType.black),r=t.rotateRight(),a===t&&(a=r),e.color=i.default.TreeNodeColorType.black):n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||!n.rightChild||n.rightChild.color!==i.default.TreeNodeColorType.red?n.leftChild&&n.leftChild.color!==i.default.TreeNodeColorType.black||n.rightChild&&n.rightChild.color!==i.default.TreeNodeColorType.black||(n.color=i.default.TreeNodeColorType.red,u(t)):(n.color=i.default.TreeNodeColorType.red,n.rightChild&&(n.rightChild.color=i.default.TreeNodeColorType.black),r=n.rotateLeft(),a===n&&(a=r),u(e))))}else e.color=i.default.TreeNodeColorType.black},h=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=c(t.rightChild);var n=e.key;e.key=t.key,t.key=n,e=t}t.leftChild&&(t=l(t.leftChild),n=e.key,e.key=t.key,t.key=n,e=t)}u(t),t&&t.remove(),--s,a.color=i.default.TreeNodeColorType.black},f=function(e,t){return!(!e||void 0===e.key)&&(!!f(e.leftChild,t)||!!t(e)||f(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;f(a,(function(n){return e===t?(h(n),!0):(++t,!1)}))},this.eraseElementByValue=function(e){if(!this.empty()){var n=m(a,e);void 0!==n&&void 0!==n.key&&0===t(n.key,e)&&h(n)}};var d=function(e,n){if(!e||void 0===e.key)throw new Error("unknown error");var r=t(n,e.key);return r<0?e.leftChild?d(e.leftChild,n):(e.leftChild=new i.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):r>0?e.rightChild?d(e.rightChild,n):(e.rightChild=new i.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},p=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==i.default.TreeNodeColorType.black&&t.color===i.default.TreeNodeColorType.red){var n=t.brother,r=t.parent;if(!r)throw new Error("unknown error");if(n&&n.color===i.default.TreeNodeColorType.red)n.color=t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,p(r);else if(!n||n.color===i.default.TreeNodeColorType.black)if(t===r.leftChild)if(e===t.leftChild){t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red;var o=r.rotateRight();r===a&&(a=o)}else e===t.rightChild&&(o=t.rotateLeft(),r===a&&(a=o),p(t));else t===r.rightChild&&(e===t.leftChild?(o=t.rotateRight(),r===a&&(a=o),p(t)):e===t.rightChild&&(t.color=i.default.TreeNodeColorType.black,r.color=i.default.TreeNodeColorType.red,o=r.rotateLeft(),r===a&&(a=o)))}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++s,a.key=e,void(a.color=i.default.TreeNodeColorType.black);var n=d(a,e);void 0!==n.key&&0===t(n.key,e)||(++s,n.key=e,p(n),a.color=i.default.TreeNodeColorType.black)};var m=function(e,n){if(e&&void 0!==e.key){var r=t(n,e.key);return r<0?m(e.leftChild,n):r>0?m(e.rightChild,n):e}};this.find=function(e){var n=m(a,e);return void 0!==n&&void 0!==n.key&&0===t(n.key,e)};var g=function(e,n){if(e&&void 0!==e.key){var r=t(e.key,n);if(0===r)return e.key;if(r<0)return g(e.rightChild,n);var o=g(e.leftChild,n);return void 0!==o?o:e.key}};this.lowerBound=function(e){return g(a,e)};var y=function(e,n){if(e&&void 0!==e.key){if(t(e.key,n)<=0)return y(e.rightChild,n);var r=y(e.leftChild,n);return void 0!==r?r:e.key}};this.upperBound=function(e){return y(a,e)};var v=function(e,n){if(e&&void 0!==e.key){var r=t(e.key,n);if(0===r)return e.key;if(r>0)return v(e.leftChild,n);var o=v(e.rightChild,n);return void 0!==o?o:e.key}};this.reverseLowerBound=function(e){return v(a,e)};var b=function(e,n){if(e&&void 0!==e.key){if(t(e.key,n)>=0)return b(e.leftChild,n);var r=b(e.rightChild,n);return void 0!==r?r:e.key}};this.reverseUpperBound=function(e){return b(a,e)},this.union=function(e){var t=this;e.forEach((function(e){return t.insert(e)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var w=function(e){return r(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key?[5,o(w(e.leftChild))]:[2];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,o(w(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return w(a)},e.forEach((function(e){return n.insert(e)})),Object.freeze(this)}Object.freeze(s),n.default=s},{"../Base/TreeNode":25}],34:[function(e,t,n){function r(e){var t=this;void 0===e&&(e=[]);var n=0,r=[];this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,r.length=0},this.push=function(e){r.push(e),++n},this.pop=function(){r.pop(),n>0&&--n},this.top=function(){return r[n-1]},e.forEach((function(e){return t.push(e)})),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(r),n.default=r},{}],35:[function(e,t,n){var r=this&&this.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(e){return function(t){return c([e,t])}}function c(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},o=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function a(e){var t=this;void 0===e&&(e=[]);var n=0,a=[];this.size=function(){return n},this.empty=function(){return 0===n},this.clear=function(){n=0,a.length=0},this.front=function(){if(!this.empty())return a[0]},this.back=function(){if(!this.empty())return a[n-1]},this.forEach=function(e){a.forEach(e)},this.getElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");return a[e]},this.eraseElementByPos=function(e){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");for(var t=e;t<n-1;++t)a[t]=a[t+1];this.popBack()},this.eraseElementByValue=function(e){var t=[];this.forEach((function(n){n!==e&&t.push(n)})),t.forEach((function(e,t){a[t]=e}));for(var r=t.length;n>r;)this.popBack()},this.pushBack=function(e){a.push(e),++n},this.popBack=function(){a.pop(),n>0&&--n},this.setElementByPos=function(e,t){if(e<0||e>=n)throw new Error("pos must more than 0 and less than vector's size");a[e]=t},this.insert=function(e,t,r){if(void 0===r&&(r=1),e<0||e>n)throw new Error("pos must more than 0 and less than or equal to vector's size");a.splice.apply(a,i([e,0],o(new Array(r).fill(t)),!1)),n+=r},this.find=function(e){return a.includes(e)},this.reverse=function(){a.reverse()},this.unique=function(){var e,t=[];this.forEach((function(n,r){0!==r&&n===e||(t.push(n),e=n)})),t.forEach((function(e,t){a[t]=e}));for(var r=t.length;n>r;)this.popBack()},this.sort=function(e){a.sort(e)},this[Symbol.iterator]=function(){return function(){return r(this,(function(e){switch(e.label){case 0:return[5,s(a)];case 1:return[2,e.sent()]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.defineProperty(n,"__esModule",{value:!0}),Object.freeze(a),n.default=a},{}],36:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.HashMap=n.HashSet=n.Map=n.Set=n.PriorityQueue=n.Deque=n.LinkList=n.Queue=n.Stack=n.Vector=void 0;var r=e("./Vector/Vector");n.Vector=r.default;var o=e("./Stack/Stack");n.Stack=o.default;var i=e("./Queue/Queue");n.Queue=i.default;var s=e("./LinkList/LinkList");n.LinkList=s.default;var a=e("./Deque/Deque");n.Deque=a.default;var c=e("./PriorityQueue/PriorityQueue");n.PriorityQueue=c.default;var l=e("./Set/Set");n.Set=l.default;var u=e("./Map/Map");n.Map=u.default;var h=e("./HashSet/HashSet");n.HashSet=h.default;var f=e("./HashMap/HashMap");n.HashMap=f.default},{"./Deque/Deque":26,"./HashMap/HashMap":27,"./HashSet/HashSet":28,"./LinkList/LinkList":29,"./Map/Map":30,"./PriorityQueue/PriorityQueue":31,"./Queue/Queue":32,"./Set/Set":33,"./Stack/Stack":34,"./Vector/Vector":35}],37:[function(e,t,n){const r=e("yallist"),o=Symbol("max"),i=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),c=Symbol("maxAge"),l=Symbol("dispose"),u=Symbol("noDisposeOnSet"),h=Symbol("lruList"),f=Symbol("cache"),d=Symbol("updateAgeOnGet"),p=()=>1;class m{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[o]=e.max||1/0;const t=e.length||p;if(this[s]="function"!=typeof t?p:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[c]=e.maxAge||0,this[l]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[d]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[o]=e||1/0,v(this)}get max(){return this[o]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[c]=e,v(this)}get maxAge(){return this[c]}set lengthCalculator(e){"function"!=typeof e&&(e=p),e!==this[s]&&(this[s]=e,this[i]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[i]+=e.length}))),v(this)}get lengthCalculator(){return this[s]}get length(){return this[i]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let n=this[h].tail;null!==n;){const r=n.prev;C(this,e,n,t),n=r}}forEach(e,t){t=t||this;for(let n=this[h].head;null!==n;){const r=n.next;C(this,e,n,t),n=r}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[l]&&this[h]&&this[h].length&&this[h].forEach((e=>this[l](e.key,e.value))),this[f]=new Map,this[h]=new r,this[i]=0}dump(){return this[h].map((e=>!y(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,n){if((n=n||this[c])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");const r=n?Date.now():0,a=this[s](t,e);if(this[f].has(e)){if(a>this[o])return b(this,this[f].get(e)),!1;const s=this[f].get(e).value;return this[l]&&(this[u]||this[l](e,s.value)),s.now=r,s.maxAge=n,s.value=t,this[i]+=a-s.length,s.length=a,this.get(e),v(this),!0}const d=new w(e,t,a,r,n);return d.length>this[o]?(this[l]&&this[l](e,t),!1):(this[i]+=d.length,this[h].unshift(d),this[f].set(e,this[h].head),v(this),!0)}has(e){if(!this[f].has(e))return!1;const t=this[f].get(e).value;return!y(this,t)}get(e){return g(this,e,!0)}peek(e){return g(this,e,!1)}pop(){const e=this[h].tail;return e?(b(this,e),e.value):null}del(e){b(this,this[f].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const r=e[n],o=r.e||0;if(0===o)this.set(r.k,r.v);else{const e=o-t;e>0&&this.set(r.k,r.v,e)}}}prune(){this[f].forEach(((e,t)=>g(this,t,!1)))}}const g=(e,t,n)=>{const r=e[f].get(t);if(r){const t=r.value;if(y(e,t)){if(b(e,r),!e[a])return}else n&&(e[d]&&(r.value.now=Date.now()),e[h].unshiftNode(r));return t.value}},y=(e,t)=>{if(!t||!t.maxAge&&!e[c])return!1;const n=Date.now()-t.now;return t.maxAge?n>t.maxAge:e[c]&&n>e[c]},v=e=>{if(e[i]>e[o])for(let t=e[h].tail;e[i]>e[o]&&null!==t;){const n=t.prev;b(e,t),t=n}},b=(e,t)=>{if(t){const n=t.value;e[l]&&e[l](n.key,n.value),e[i]-=n.length,e[f].delete(n.key),e[h].removeNode(t)}};class w{constructor(e,t,n,r,o){this.key=e,this.value=t,this.length=n,this.now=r,this.maxAge=o||0}}const C=(e,t,n,r)=>{let o=n.value;y(e,o)&&(b(e,n),e[a]||(o=void 0)),o&&t.call(r,o.value,o.key,e)};t.exports=m},{yallist:83}],38:[function(e,t,n){(function(e){(function(){const n=t.exports;n.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=e.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=e.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=e.from([n.codes.connect<<n.CMD_SHIFT]),n.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function r(t){return[0,1,2].map((r=>[0,1].map((o=>[0,1].map((i=>{const s=e.alloc(1);return s.writeUInt8(n.codes[t]<<n.CMD_SHIFT|(o?n.DUP_MASK:0)|r<<n.QOS_SHIFT|i,0,!0),s}))))))}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=e.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=e.from([3]),n.VERSION4=e.from([4]),n.VERSION5=e.from([5]),n.VERSION131=e.from([131]),n.VERSION132=e.from([132]),n.QOS=[0,1,2].map((t=>e.from([t]))),n.EMPTY={pingreq:e.from([n.codes.pingreq<<4,0]),pingresp:e.from([n.codes.pingresp<<4,0]),disconnect:e.from([n.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],39:[function(e,t,n){(function(n){(function(){const r=e("./writeToStream"),o=e("events");function i(e,t){const n=new s;return r(e,n,t),n.concat()}class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),r=this._array;let o,i=0;for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?t[o]=r[o].length:t[o]=n.byteLength(r[o]),e+=t[o];const s=n.allocUnsafe(e);for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?(r[o].copy(s,i),i+=t[o]):(s.write(r[o],i),i+=t[o]);return s}}t.exports=i}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(e,t,n){n.parser=e("./parser").parser,n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(e,t,n){(function(e){(function(){const n=65536,r={},o=e.isBuffer(e.from([1,2]).subarray(0,1));function i(t){const n=e.allocUnsafe(2);return n.writeUInt8(t>>8,0),n.writeUInt8(255&t,1),n}function s(){for(let e=0;e<n;e++)r[e]=i(e)}function a(t){const n=4;let r=0,i=0;const s=e.allocUnsafe(n);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),s.writeUInt8(r,i++)}while(t>0&&i<n);return t>0&&(i=0),o?s.subarray(0,i):s.slice(0,i)}function c(t){const n=e.allocUnsafe(4);return n.writeUInt32BE(t,0),n}t.exports={cache:r,generateCache:s,generateNumber:i,genBufVariableByteInt:a,generate4ByteBuffer:c}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],42:[function(e,t,n){class r{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=r},{}],43:[function(e,t,n){const r=e("bl"),o=e("events"),i=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;a("_parseConnect");const o={},i=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.properties=e)}const l=this._parseString();if(null===l)return this._emitError(new Error("Packet too short"));if(i.clientId=l,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=e,a("_parseConnect: packet.will.topic: %s",i.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));i.username=r,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));i.password=n}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,n,r,o,i,c,l;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=0!=(n>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(n>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=n>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,l={topic:t,qos:r},5===this.settings.protocolVersion?(l.nl=c,l.rap=i,l.rh=o):this.settings.bridgeMode&&(l.rh=0,l.rap=!0,l.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",l),e.subscriptions.push(l)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,a("_parseString: result: %s",r),r}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");const t=4;let n,r=0,o=1,i=0,c=!1;const l=this._pos?this._pos:0;for(;r<t&&l+r<this._list.length;){if(n=this._list.readUInt8(l+r++),i+=o*(n&s.VARBYTEINT_MASK),o*=128,0==(n&s.VARBYTEINT_FIN_MASK)){c=!0;break}if(this._list.length<=r)break}return!c&&r===t&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=r),c=!!c&&(e?{bytes:r,value:i}:i),a("_parseVarByteNum: result: %o",c),c}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(s.propertiesTypes[t]))):n[t]=this._parseByType(s.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new i,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}t.exports=c},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(e,t,n){(function(n){(function(){const r=e("./constants"),o=n.allocUnsafe(0),i=n.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,c=e("debug")("mqtt-packet:writeToStream"),l=s.cache,u=s.generateNumber,h=s.generateCache,f=s.genBufVariableByteInt,d=s.generate4ByteBuffer;let p=B,m=!0;function g(e,t,n){switch(c("generate called"),t.cork&&(t.cork(),a(y,t)),m&&(m=!1,h()),c("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return v(e,t);case"connack":return b(e,t,n);case"publish":return w(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return C(e,t,n);case"subscribe":return _(e,t,n);case"suback":return k(e,t,n);case"unsubscribe":return S(e,t,n);case"unsuback":return A(e,t,n);case"pingreq":case"pingresp":return E(e,t);case"disconnect":return T(e,t,n);case"auth":return I(e,t,n);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}function v(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let l=i.clean;const u=i.keepalive||0,h=i.clientId||"",f=i.username,d=i.password,m=i.properties;void 0===l&&(l=!0);let g=0;if(!s||"string"!=typeof s&&!n.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof h||n.isBuffer(h))&&(h||a>=4)&&(h||l))g+=n.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*l==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=M(t,m);if(!y)return!1;g+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(g+=n.byteLength(c.topic)+2,g+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?g+=n.byteLength(c.payload):g+=c.payload.length}var v={};if(5===a){if(!(v=M(t,c.properties)))return!1;g+=v.length}}let b=!1;if(null!=f){if(!z(f))return t.emit("error",new Error("Invalid username")),!1;b=!0,g+=n.byteLength(f)+2}if(null!=d){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!z(d))return t.emit("error",new Error("Invalid password")),!1;g+=q(d)+2}t.write(r.CONNECT_HEADER),O(t,g),F(t,s),i.bridgeMode&&(a+=128),t.write(131===a?r.VERSION131:132===a?r.VERSION132:4===a?r.VERSION4:5===a?r.VERSION5:r.VERSION3);let w=0;return w|=null!=f?r.USERNAME_MASK:0,w|=null!=d?r.PASSWORD_MASK:0,w|=c&&c.retain?r.WILL_RETAIN_MASK:0,w|=c&&c.qos?c.qos<<r.WILL_QOS_SHIFT:0,w|=c?r.WILL_FLAG_MASK:0,w|=l?r.CLEAN_SESSION_MASK:0,t.write(n.from([w])),p(t,u),5===a&&y.write(),F(t,h),c&&(5===a&&v.write(),R(t,c.topic),F(t,c.payload)),null!=f&&F(t,f),null!=d&&F(t,d),!0}function b(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,l=a.properties;let u=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=M(t,l),!h)return!1;u+=h.length}return t.write(r.CONNACK_HEADER),O(t,u),t.write(a.sessionPresent?r.SESSIONPRESENT_HEADER:i),t.write(n.from([c])),null!=h&&h.write(),!0}function w(e,t,i){c("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},l=a.qos||0,u=a.retain?r.RETAIN_MASK:0,h=a.topic,f=a.payload||o,d=a.messageId,m=a.properties;let g=0;if("string"==typeof h)g+=n.byteLength(h)+2;else{if(!n.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;g+=h.length+2}if(n.isBuffer(f)?g+=f.length:g+=n.byteLength(f),l&&"number"!=typeof d)return t.emit("error",new Error("Invalid messageId")),!1;l&&(g+=2);let y=null;if(5===s){if(y=M(t,m),!y)return!1;g+=y.length}return t.write(r.PUBLISH_HEADER[l][a.dup?1:0][u?1:0]),O(t,g),p(t,q(h)),t.write(h),l>0&&p(t,d),null!=y&&y.write(),c("publish: payload: %o",f),t.write(f)}function C(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,l=s.dup&&"pubrel"===a?r.DUP_MASK:0;let u=0;const h=s.reasonCode,f=s.properties;let d=5===i?3:2;if("pubrel"===a&&(u=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof f){if(m=U(t,f,o,d),!m)return!1;d+=m.length}return t.write(r.ACKS[a][u][l][0]),O(t,d),p(t,c),5===i&&t.write(n.from([h])),null!==m&&m.write(),!0}function _(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?r.DUP_MASK:0,l=s.messageId,u=s.subscriptions,h=s.properties;let f=0;if("number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;f+=2;let d=null;if(5===i){if(d=M(t,h),!d)return!1;f+=d.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const r=u[e].topic,o=u[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(u[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(u[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=u[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}f+=n.byteLength(r)+2+1}c("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),t.write(r.SUBSCRIBE_HEADER[1][a?1:0][0]),O(t,f),p(t,l),null!==d&&d.write();let m=!0;for(const e of u){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,l=e.rh;let u;R(t,o),u=r.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(u|=a?r.SUBSCRIBE_OPTIONS_NL:0,u|=c?r.SUBSCRIBE_OPTIONS_RAP:0,u|=l?r.SUBSCRIBE_OPTIONS_RH[l]:0),m=t.write(n.from([u]))}return m}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,l=s.properties;let u=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(u+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;u+=1}let h=null;if(5===i){if(h=U(t,l,o,u),!h)return!1;u+=h.length}return t.write(r.SUBACK_HEADER),O(t,u),p(t,a),null!==h&&h.write(),t.write(n.from(c))}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.unsubscriptions,u=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<l.length;e+=1){if("string"!=typeof l[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=n.byteLength(l[e])+2}let f=null;if(5===i){if(f=M(t,u),!f)return!1;h+=f.length}t.write(r.UNSUBSCRIBE_HEADER[1][c?1:0][0]),O(t,h),p(t,a),null!==f&&f.write();let d=!0;for(let e=0;e<l.length;e++)d=R(t,l[e]);return d}function A(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,l=s.granted,u=s.properties,h=s.cmd,f=0;let d=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),!1;d+=1}}let m=null;if(5===i){if(m=U(t,u,o,d),!m)return!1;d+=m.length}return t.write(r.ACKS[h][f][c][0]),O(t,d),p(t,a),null!==m&&m.write(),5===i&&t.write(n.from(l)),!0}function E(e,t,n){return t.write(r.EMPTY[e.cmd])}function T(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0,u=null;if(5===i){if(u=U(t,c,o,l),!u)return!1;l+=u.length}return t.write(n.from([r.codes.disconnect<<4])),O(t,l),5===i&&t.write(n.from([a])),null!==u&&u.write(),!0}function I(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let l=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const u=U(t,c,o,l);return!!u&&(l+=u.length,t.write(n.from([r.codes.auth<<4])),O(t,l),t.write(n.from([a])),null!==u&&u.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>p===B,set(e){e?(l&&0!==Object.keys(l).length||(m=!0),p=B):(m=!1,p=N)}});const x={};function O(e,t){if(t>r.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=x[t];return n||(n=f(t),t<16384&&(x[t]=n)),c("writeVarByteInt: writing to stream: %o",n),e.write(n)}function R(e,t){const r=n.byteLength(t);return p(e,r),c("writeString: %s",t),e.write(t,"utf8")}function P(e,t,n){R(e,t),R(e,n)}function B(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",l[t]),e.write(l[t])}function N(e,t){const n=u(t);return c("writeNumberGenerated: %o",n),e.write(n)}function j(e,t){const n=d(t);return c("write4ByteNumber: %o",n),e.write(n)}function F(e,t){"string"==typeof t?R(e,t):t?(p(e,t.length),e.write(t)):p(e,0)}function M(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){L(e,{},0)}};let o=0;function i(t,o){let i=0;switch(r.propertiesTypes[t]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(f(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3+n.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce(((e,t)=>{const r=o[t];return Array.isArray(r)?e+=r.reduce(((e,r)=>e+=3+n.byteLength(t.toString())+2+n.byteLength(r.toString())),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(o[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${o}`)),!1}return i}if(t)for(const e in t){let n=0,r=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(r=i(e,s[t]),!r)return!1;n+=r}else{if(r=i(e,s),!r)return!1;n=r}if(!n)return!1;o+=n}return{length:n.byteLength(f(o))+o,write(){L(e,t,o)}}}function U(e,t,n,r){const o=["reasonString","userProperties"],i=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0;let s=M(e,t);if(i)for(;r+s.length>i;){const n=o.shift();if(!n||!t[n])return!1;delete t[n],s=M(e,t)}return s}function D(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]])),F(e,o);break;case"int16":e.write(n.from([r.properties[t]])),p(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]])),R(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach((i=>{const s=o[i];Array.isArray(s)?s.forEach((o=>{e.write(n.from([r.properties[t]])),P(e,i.toString(),o.toString())})):(e.write(n.from([r.properties[t]])),P(e,i.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${o}`)),!1}}function L(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++)D(e,n,r[t]);else D(e,n,r)}}function q(e){return e?e instanceof n?e.length:n.byteLength(e):0}function z(e){return"string"==typeof e||e instanceof n}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,c=365.25*s;function l(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function u(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}function h(e){var t=Math.abs(e);return t>=s?f(e,t,s,"day"):t>=i?f(e,t,i,"hour"):t>=o?f(e,t,o,"minute"):t>=r?f(e,t,r,"second"):e+" ms"}function f(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return l(e);if("number"===n&&isFinite(e))return t.long?h(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],46:[function(e,t,n){const r=e("./lib/number-allocator.js");t.exports.NumberAllocator=r},{"./lib/number-allocator.js":47}],47:[function(e,t,n){const r=e("js-sdsl").Set,o=e("debug")("number-allocator:trace"),i=e("debug")("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new r([],((e,t)=>e.compare(t))),o("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return o("alloc():empty"),null;const e=this.ss.front(),t=e.low;return t+1<=e.high?++e.low:this.ss.eraseElementByPos(0),o("alloc():"+t),t},a.prototype.use=function(e){const t=new s(e,e),n=this.ss.lowerBound(t);if(n){if(n.equals(t))return this.ss.eraseElementByValue(n),o("use():"+e),!0;if(n.low>e)return!1;if(n.low===e)return++n.low,o("use():"+e),!0;if(n.high===e)return--n.high,o("use():"+e),!0;const r=n.low;return n.low=e+1,this.ss.insert(new s(r,e-1)),o("use():"+e),!0}return o("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void i("free():"+e+" is out of range");const t=new s(e,e),n=this.ss.lowerBound(t);if(n){if(n.low<=e&&e<=n.high)return void i("free():"+e+" has already been vacant");if(n===this.ss.front())e+1===n.low?--n.low:this.ss.insert(t);else{const r=this.ss.reverseLowerBound(t);r.high+1===e?e+1===n.low?(this.ss.eraseElementByValue(r),n.low=r.low):r.high=e:e+1===n.low?n.low=e:this.ss.insert(t)}}else{if(n===this.ss.front())return void this.ss.insert(t);const r=this.ss.reverseLowerBound(t);r.high+1===e?r.high=e:this.ss.insert(t)}o("free():"+e)},a.prototype.clear=function(){o("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e)},t.exports=a},{debug:18,"js-sdsl":36}],48:[function(e,t,n){var r=e("wrappy");function o(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(o),t.exports.strict=r(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},{wrappy:79}],49:[function(e,t,n){(function(e){(function(){function n(t,n,r,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,n)}));case 3:return e.nextTick((function(){t.call(null,n,r)}));case 4:return e.nextTick((function(){t.call(null,n,r,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:n}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:50}],50:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function l(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var u,h=[],f=!1,d=-1;function p(){f&&u&&(f=!1,u.length?h=u.concat(h):d=-1,h.length&&m())}function m(){if(!f){var e=c(p);f=!0;for(var t=h.length;t;){for(u=h,h=[];++d<t;)u&&u[d].run();d=-1,t=h.length}u=null,f=!1,l(e)}}function g(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new g(e,t)),1!==h.length||f||c(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],51:[function(e,t,n){(function(e){(function(){!function(r){var o="object"==typeof n&&n&&!n.nodeType&&n,i="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,c,l=2147483647,u=36,h=1,f=26,d=38,p=700,m=72,g=128,y="-",v=/^xn--/,b=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,C={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_=u-h,k=Math.floor,S=String.fromCharCode;function A(e){throw new RangeError(C[e])}function E(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function T(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+E((e=e.replace(w,".")).split("."),t).join(".")}function I(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 x(e){return E(e,(function(e){var t="";return e>65535&&(t+=S((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=S(e)})).join("")}function O(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:u}function R(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,n){var r=0;for(e=n?k(e/p):e>>1,e+=k(e/t);e>_*f>>1;r+=u)e=k(e/_);return k(r+(_+1)*e/(e+d))}function B(e){var t,n,r,o,i,s,a,c,d,p,v=[],b=e.length,w=0,C=g,_=m;for((n=e.lastIndexOf(y))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&A("not-basic"),v.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<b;){for(i=w,s=1,a=u;o>=b&&A("invalid-input"),((c=O(e.charCodeAt(o++)))>=u||c>k((l-w)/s))&&A("overflow"),w+=c*s,!(c<(d=a<=_?h:a>=_+f?f:a-_));a+=u)s>k(l/(p=u-d))&&A("overflow"),s*=p;_=P(w-i,t=v.length+1,0==i),k(w/t)>l-C&&A("overflow"),C+=k(w/t),w%=t,v.splice(w++,0,C)}return x(v)}function N(e){var t,n,r,o,i,s,a,c,d,p,v,b,w,C,_,E=[];for(b=(e=I(e)).length,t=g,n=0,i=m,s=0;s<b;++s)(v=e[s])<128&&E.push(S(v));for(r=o=E.length,o&&E.push(y);r<b;){for(a=l,s=0;s<b;++s)(v=e[s])>=t&&v<a&&(a=v);for(a-t>k((l-n)/(w=r+1))&&A("overflow"),n+=(a-t)*w,t=a,s=0;s<b;++s)if((v=e[s])<t&&++n>l&&A("overflow"),v==t){for(c=n,d=u;!(c<(p=d<=i?h:d>=i+f?f:d-i));d+=u)_=c-p,C=u-p,E.push(S(R(p+_%C,0))),c=k(_/C);E.push(S(R(c,0))),i=P(n,w,r==o),n=0,++r}++n,++t}return E.join("")}function j(e){return T(e,(function(e){return v.test(e)?B(e.slice(4).toLowerCase()):e}))}function F(e){return T(e,(function(e){return b.test(e)?"xn--"+N(e):e}))}if(a={version:"1.4.1",ucs2:{decode:I,encode:x},decode:B,encode:N,toASCII:F,toUnicode:j},o&&i)if(t.exports==o)i.exports=a;else for(c in a)a.hasOwnProperty(c)&&(o[c]=a[c]);else r.punycode=a}(this)}).call(this)}).call(this,void 0!==_e?_e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],52:[function(e,t,n){function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var l=e.length;c>0&&l>c&&(l=c);for(var u=0;u<l;++u){var h,f,d,p,m=e[u].replace(a,"%20"),g=m.indexOf(n);g>=0?(h=m.substr(0,g),f=m.substr(g+1)):(h=m,f=""),d=decodeURIComponent(h),p=decodeURIComponent(f),r(s,d)?o(s[d])?s[d].push(p):s[d]=[s[d],p]:s[d]=p}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],53:[function(e,t,n){var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],54:[function(e,t,n){n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":52,"./encode":53}],55:[function(e,t,n){function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var o={};function i(e,t,n){function i(e,n,r){return"string"==typeof t?t:t(e,n,r)}n||(n=Error);var s=function(e){function t(t,n,r){return e.call(this,i(t,n,r))||this}return r(t,e),t}(n);s.prototype.name=n.name,s.prototype.code=e,o[e]=s}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function c(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function l(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o;if("string"==typeof t&&a(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",c(e," argument"))o="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var i=l(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(i," ").concat(r," ").concat(s(t,"type"))}return o+=". Received type ".concat(typeof n)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=o},{}],56:[function(e,t,n){(function(n){(function(){var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=l;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(l,o);for(var s=r(i.prototype),a=0;a<s.length;a++){var c=s[a];l.prototype[c]||(l.prototype[c]=i.prototype[c])}function l(e){if(!(this instanceof l))return new l(e);o.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",u)))}function u(){this._writableState.ended||n.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}e("inherits")(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":59,inherits:24}],58:[function(e,t,n){(function(n,r){(function(){var o;t.exports=I,I.ReadableState=T,e("events").EventEmitter;var i=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,c=r.Uint8Array||function(){};function l(e){return a.from(e)}function u(e){return a.isBuffer(e)||e instanceof c}var h,f=e("util");h=f&&f.debuglog?f.debuglog("stream"):function(){};var d,p,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),v=e("./internal/streams/state").getHighWaterMark,b=e("../errors").codes,w=b.ERR_INVALID_ARG_TYPE,C=b.ERR_STREAM_PUSH_AFTER_EOF,_=b.ERR_METHOD_NOT_IMPLEMENTED,k=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(I,s);var S=y.errorOrDestroy,A=["error","close","destroy","pause","resume"];function E(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function T(t,n,r){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof o),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=v(this,t,"readableHighWaterMark",r),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(d||(d=e("string_decoder/").StringDecoder),this.decoder=new d(t.encoding),this.encoding=t.encoding)}function I(t){if(o=o||e("./_stream_duplex"),!(this instanceof I))return new I(t);var n=this instanceof o;this._readableState=new T(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function x(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=R(s,t)),i)S(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=l(t)),r)s.endEmitted?S(e,new k):O(e,s,t,!0);else if(s.ended)S(e,new C);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?O(e,s,t,!1):U(e,s)):O(e,s,t,!1)}else r||(s.reading=!1,U(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function O(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&F(e)),U(e,t)}function R(e,t){var n;return u(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new w("chunk",["string","Buffer","Uint8Array"],t)),n}Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),I.prototype.destroy=y.destroy,I.prototype._undestroy=y.undestroy,I.prototype._destroy=function(e,t){t(e)},I.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),x(this,e,t,!1,n)},I.prototype.unshift=function(e){return x(this,e,null,!0,!1)},I.prototype.isPaused=function(){return!1===this._readableState.flowing},I.prototype.setEncoding=function(t){d||(d=e("string_decoder/").StringDecoder);var n=new d(t);this._readableState.decoder=n,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,o="";null!==r;)o+=n.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};var P=1073741824;function B(e){return e>=P?e=P:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function N(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=B(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function j(e,t){if(h("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?F(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}function F(e){var t=e._readableState;h("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(M,e))}function M(e){var t=e._readableState;h("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,V(e)}function U(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(D,e,t))}function D(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 L(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,V(e))}}function q(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function z(e){h("readable nexttick read 0"),e.read(0)}function $(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(H,e,t))}function H(e,t){h("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),V(e),t.flowing&&!t.reading&&e.read(0)}function V(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function W(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function K(e){var t=e._readableState;h("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(Q,t,e))}function Q(e,t){if(h("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function J(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}I.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):F(this),null;if(0===(e=N(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=N(n,t))),null===(r=e>0?W(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&K(this)),null!==r&&this.emit("data",r),r},I.prototype._read=function(e){S(this,new _("_read()"))},I.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?y:c;function a(e,t){h("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,f())}function c(){h("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var l=L(r);e.on("drain",l);var u=!1;function f(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",l),e.removeListener("error",p),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",d),u=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l()}function d(t){h("ondata");var n=e.write(t);h("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==J(o.pipes,e))&&!u&&(h("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function p(t){h("onerror",t),y(),e.removeListener("error",p),0===i(e,"error")&&S(e,t)}function m(){e.removeListener("finish",g),y()}function g(){h("onfinish"),e.removeListener("close",m),y()}function y(){h("unpipe"),r.unpipe(e)}return r.on("data",d),E(e,"error",p),e.once("close",m),e.once("finish",g),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},I.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=J(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},I.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?F(this):o.reading||n.nextTick(z,this))),r},I.prototype.addListener=I.prototype.on,I.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(q,this),r},I.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(q,this),t},I.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!e.readableListening,$(this,e)),e.paused=!1,this},I.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},I.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<A.length;i++)e.on(A[i],this.emit.bind(this,A[i]));return this._read=function(t){h("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(I.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=e("./internal/streams/async_iterator")),p(this)}),Object.defineProperty(I.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(I.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(I.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),I._fromList=W,Object.defineProperty(I.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(I.from=function(t,n){return void 0===m&&(m=e("./internal/streams/from")),m(I,t,n)})}).call(this)}).call(this,e("_process"),void 0!==_e?_e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/async_iterator":61,"./internal/streams/buffer_list":62,"./internal/streams/destroy":63,"./internal/streams/from":65,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,events:22,inherits:24,"string_decoder/":75,util:16}],59:[function(e,t,n){t.exports=u;var r=e("../errors").codes,o=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=e("./_stream_duplex");function l(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);c.call(this,e),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush((function(t,n){f(e,t,n)}))}function f(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(u,c),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,n){n(new o("_transform()"))},u.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},u.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(e,t,n){(function(n,r){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){H(t,e)}}var i;t.exports=T,T.WritableState=E;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,l=r.Uint8Array||function(){};function u(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof l}var f,d=e("./internal/streams/destroy"),p=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,v=m.ERR_MULTIPLE_CALLBACK,b=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,C=m.ERR_STREAM_NULL_VALUES,_=m.ERR_STREAM_WRITE_AFTER_END,k=m.ERR_UNKNOWN_ENCODING,S=d.errorOrDestroy;function A(){}function E(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=p(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 T(t){var n=this instanceof(i=i||e("./_stream_duplex"));if(!n&&!f.call(T,this))return new T(t);this._writableState=new E(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 I(e,t){var r=new _;S(e,r),n.nextTick(t,r)}function x(e,t,r,o){var i;return null===r?i=new C:"string"==typeof r||t.objectMode||(i=new g("chunk",["string","Buffer"],r)),!i||(S(e,i),n.nextTick(o,i),!1)}function O(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,n)),t}function R(e,t,n,r,o,i){if(!n){var s=O(t,r,o);r!==s&&(n=!0,o="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else P(e,t,!1,a,r,o,i);return c}function P(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function B(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(z,e,t),e._writableState.errorEmitted=!0,S(e,o)):(i(o),e._writableState.errorEmitted=!0,S(e,o),z(e,t))}function N(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 v;if(N(r),t)B(e,r,o,t,i);else{var s=D(r)||e.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||U(e,r),o?n.nextTick(F,e,r,s,i):F(e,r,s,i)}}function F(e,t,n,r){n||M(e,t),t.pendingcb--,r(),z(e,t)}function M(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function U(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),s=t.corkedRequestsFree;s.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,P(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,h=n.callback;if(P(e,t,!1,t.objectMode?1:l.length,l,u,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function D(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function L(e,t){e._final((function(n){t.pendingcb--,n&&S(e,n),t.prefinished=!0,e.emit("prefinish"),z(e,t)}))}function q(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(L,e,t)))}function z(e,t){var n=D(t);if(n&&(q(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function $(e,t,r){t.ending=!0,z(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function H(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}e("inherits")(T,a),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(f=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(e){return!!f.call(this,e)||this===T&&e&&e._writableState instanceof E}})):f=function(e){return e instanceof this},T.prototype.pipe=function(){S(this,new b)},T.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=u(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=A),r.ending?I(this,n):(i||x(this,r,e,n))&&(r.pendingcb++,o=R(this,r,i,e,t,n)),o},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||U(this,e))},T.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new k(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(e,t,n){n(new y("_write()"))},T.prototype._writev=null,T.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||$(this,r,n),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),T.prototype.destroy=d.destroy,T.prototype._undestroy=d.undestroy,T.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==_e?_e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/destroy":63,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,inherits:24,"util-deprecate":78}],61:[function(e,t,n){(function(n){(function(){var r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),h=Symbol("handlePromise"),f=Symbol("stream");function d(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var n=e[f].read();null!==n&&(e[u]=null,e[s]=null,e[a]=null,t(d(n,!1)))}}function m(e){n.nextTick(p,e)}function g(e,t){return function(n,r){e.then((function(){t[l]?n(d(void 0,!0)):t[h](n,r)}),r)}}var y=Object.getPrototypeOf((function(){})),v=Object.setPrototypeOf((o(r={get stream(){return this[f]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(d(void 0,!0));if(this[f].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[c]?r(e[c]):t(d(void 0,!0))}))}));var r,o=this[u];if(o)r=new Promise(g(o,this));else{var i=this[f].read();if(null!==i)return Promise.resolve(d(i,!1));r=new Promise(this[h])}return this[u]=r,r}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var e=this;return new Promise((function(t,n){e[f].destroy(null,(function(e){e?n(e):t(d(void 0,!0))}))}))})),r),y),b=function(e){var t,n=Object.create(v,(o(t={},f,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,l,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var r=n[f].read();r?(n[u]=null,n[s]=null,n[a]=null,e(d(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[u]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[u]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var r=n[s];null!==r&&(n[u]=null,n[s]=null,n[a]=null,r(d(void 0,!0))),n[l]=!0})),e.on("readable",m.bind(null,n)),n};t.exports=b}).call(this)}).call(this,e("_process"))},{"./end-of-stream":64,_process:50}],62:[function(e,t,n){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}var l=e("buffer").Buffer,u=e("util").inspect,h=u&&u.custom||"inspect";function f(e,t,n){l.prototype.copy.call(e,t,n)}t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return l.alloc(0);for(var t=l.allocUnsafe(e>>>0),n=this.head,r=0;n;)f(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?r+=o:r+=o.slice(0,e),0==(e-=i)){i===o.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=l.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(i));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return u(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:17,util:16}],63:[function(e,t,n){(function(e){(function(){function n(t,n){var i=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(n?n(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!n&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(o,i):(i._writableState.errorEmitted=!0,e.nextTick(r,i,t)):e.nextTick(r,i,t):n?(e.nextTick(o,i),n(t)):e.nextTick(o,i)})),this)}function r(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function s(e,t){e.emit("error",t)}function a(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:n,undestroy:i,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:50}],64:[function(e,t,n){var r=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function o(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];e.apply(this,r)}}}function i(){}function s(e){return e.setHeader&&"function"==typeof e.abort}function a(e,t,n){if("function"==typeof t)return a(e,null,t);t||(t={}),n=o(n||i);var c=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,u=function(){e.writable||f()},h=e._writableState&&e._writableState.finished,f=function(){l=!1,h=!0,c||n.call(e)},d=e._readableState&&e._readableState.endEmitted,p=function(){c=!1,d=!0,l||n.call(e)},m=function(t){n.call(e,t)},g=function(){var t;return c&&!d?(e._readableState&&e._readableState.ended||(t=new r),n.call(e,t)):l&&!h?(e._writableState&&e._writableState.ended||(t=new r),n.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return s(e)?(e.on("complete",f),e.on("abort",g),e.req?y():e.on("request",y)):l&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",p),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",f),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("end",p),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":55}],65:[function(e,t,n){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(e,t,n){var r;function o(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=e("../../../errors").codes,s=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function c(e){if(e)throw e}function l(e){return e.setHeader&&"function"==typeof e.abort}function u(t,n,i,s){s=o(s);var c=!1;t.on("close",(function(){c=!0})),void 0===r&&(r=e("./end-of-stream")),r(t,{readable:n,writable:i},(function(e){if(e)return s(e);c=!0,s()}));var u=!1;return function(e){if(!c&&!u)return u=!0,l(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function f(e,t){return e.pipe(t)}function d(e){return e.length?"function"!=typeof e[e.length-1]?c:e.pop():c}function p(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=d(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new s("streams");var i=t.map((function(e,n){var s=n<t.length-1;return u(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(h),s||(i.forEach(h),o(r))}))}));return t.reduce(f)}t.exports=p},{"../../../errors":55,"./end-of-stream":64}],67:[function(e,t,n){var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function o(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}function i(e,t,n,i){var s=o(t,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}},{"../../../errors":55}],68:[function(e,t,n){t.exports=e("events").EventEmitter},{events:22}],69:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":56,"./lib/_stream_passthrough.js":57,"./lib/_stream_readable.js":58,"./lib/_stream_transform.js":59,"./lib/_stream_writable.js":60,"./lib/internal/streams/end-of-stream.js":64,"./lib/internal/streams/pipeline.js":66}],70:[function(e,t,n){function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}function o(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new r(arguments[0],arguments[1],e)}t.exports=o},{}],71:[function(e,t,n){t.exports=e("./index.js")()},{"./index.js":72}],72:[function(e,t,n){(function(e){(function(){function n(t){return t instanceof e?e.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function r(e){return(e=e||{}).circles?o(e):e.proto?i:r;function t(e,t){for(var r=Object.keys(e),o=new Array(r.length),i=0;i<r.length;i++){var s=r[i],a=e[s];"object"!=typeof a||null===a?o[s]=a:a instanceof Date?o[s]=new Date(a):ArrayBuffer.isView(a)?o[s]=n(a):o[s]=t(a)}return o}function r(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,r);if(e instanceof Map)return new Map(t(Array.from(e),r));if(e instanceof Set)return new Set(t(Array.from(e),r));var o={};for(var i in e)if(!1!==Object.hasOwnProperty.call(e,i)){var s=e[i];"object"!=typeof s||null===s?o[i]=s:s instanceof Date?o[i]=new Date(s):s instanceof Map?o[i]=new Map(t(Array.from(s),r)):s instanceof Set?o[i]=new Set(t(Array.from(s),r)):ArrayBuffer.isView(s)?o[i]=n(s):o[i]=r(s)}return o}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return t(e,i);if(e instanceof Map)return new Map(t(Array.from(e),i));if(e instanceof Set)return new Set(t(Array.from(e),i));var r={};for(var o in e){var s=e[o];"object"!=typeof s||null===s?r[o]=s:s instanceof Date?r[o]=new Date(s):s instanceof Map?r[o]=new Map(t(Array.from(s),i)):s instanceof Set?r[o]=new Set(t(Array.from(s),i)):ArrayBuffer.isView(s)?r[o]=n(s):r[o]=i(s)}return r}}function o(e){var t=[],r=[];return e.proto?s:i;function o(e,o){for(var i=Object.keys(e),s=new Array(i.length),a=0;a<i.length;a++){var c=i[a],l=e[c];if("object"!=typeof l||null===l)s[c]=l;else if(l instanceof Date)s[c]=new Date(l);else if(ArrayBuffer.isView(l))s[c]=n(l);else{var u=t.indexOf(l);s[c]=-1!==u?r[u]:o(l)}}return s}function i(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,i);if(e instanceof Map)return new Map(o(Array.from(e),i));if(e instanceof Set)return new Set(o(Array.from(e),i));var s={};for(var a in t.push(e),r.push(s),e)if(!1!==Object.hasOwnProperty.call(e,a)){var c=e[a];if("object"!=typeof c||null===c)s[a]=c;else if(c instanceof Date)s[a]=new Date(c);else if(c instanceof Map)s[a]=new Map(o(Array.from(c),i));else if(c instanceof Set)s[a]=new Set(o(Array.from(c),i));else if(ArrayBuffer.isView(c))s[a]=n(c);else{var l=t.indexOf(c);s[a]=-1!==l?r[l]:i(c)}}return t.pop(),r.pop(),s}function s(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return o(e,s);if(e instanceof Map)return new Map(o(Array.from(e),s));if(e instanceof Set)return new Set(o(Array.from(e),s));var i={};for(var a in t.push(e),r.push(i),e){var c=e[a];if("object"!=typeof c||null===c)i[a]=c;else if(c instanceof Date)i[a]=new Date(c);else if(c instanceof Map)i[a]=new Map(o(Array.from(c),s));else if(c instanceof Set)i[a]=new Set(o(Array.from(c),s));else if(ArrayBuffer.isView(c))i[a]=n(c);else{var l=t.indexOf(c);i[a]=-1!==l?r[l]:s(c)}}return t.pop(),r.pop(),i}}t.exports=r}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],73:[function(e,t,n){
5
5
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
6
- var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(i(r,n),n.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:17}],74:[function(e,t,n){function r(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(o(t)):null}function o(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}t.exports=r},{}],75:[function(e,t,n){var r=e("safe-buffer").Buffer,o=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function s(e){var t=i(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=s(e),this.encoding){case"utf16le":this.text=p,this.end=m,t=4;break;case"utf8":this.fillLast=h,t=4;break;case"base64":this.text=g,this.end=y,t=3;break;default:return this.write=v,void(this.end=b)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function c(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e,t,n){var r=t.length-1;if(r<n)return 0;var o=c(t[r]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}function u(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}function h(e){var t=this.lastTotal-this.lastNeed,n=u(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function f(e,t){var n=l(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function p(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function g(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function y(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function v(e){return e.toString(this.encoding)}function b(e){return e&&e.length?this.write(e):""}n.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},a.prototype.end=d,a.prototype.text=f,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":73}],76:[function(e,t,n){var r=e("punycode"),o=e("./util");function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}n.parse=w,n.resolve=_,n.resolveObject=k,n.format=C,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(l),h=["%","/","?",";","#"].concat(u),f=["/","?","#"],d=255,p=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");function w(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}function C(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function _(e,t){return w(e,!1,!0).resolve(t)}function k(e,t){return e?w(e,!1,!0).resolveObject(t):t}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",l=e.split(a),w=/\\/g;l[0]=l[0].replace(w,"/");var C=e=l.join(a);if(C=C.trim(),!n&&1===e.split("#").length){var _=c.exec(C);if(_)return this.path=C,this.href=C,this.pathname=_[1],_[2]?(this.search=_[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var k=s.exec(C);if(k){var S=(k=k[0]).toLowerCase();this.protocol=S,C=C.substr(k.length)}if(n||k||C.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===C.substr(0,2);!E||k&&y[k]||(C=C.substr(2),this.slashes=!0)}if(!y[k]&&(E||k&&!v[k])){for(var A,T,x=-1,I=0;I<f.length;I++)-1!==(O=C.indexOf(f[I]))&&(-1===x||O<x)&&(x=O);for(-1!==(T=-1===x?C.lastIndexOf("@"):C.lastIndexOf("@",x))&&(A=C.slice(0,T),C=C.slice(T+1),this.auth=decodeURIComponent(A)),x=-1,I=0;I<h.length;I++){var O;-1!==(O=C.indexOf(h[I]))&&(-1===x||O<x)&&(x=O)}-1===x&&(x=C.length),this.host=C.slice(0,x),C=C.slice(x),this.parseHost(),this.hostname=this.hostname||"";var R="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!R)for(var P=this.hostname.split(/\./),B=(I=0,P.length);I<B;I++){var N=P[I];if(N&&!N.match(p)){for(var F="",j=0,M=N.length;j<M;j++)N.charCodeAt(j)>127?F+="x":F+=N[j];if(!F.match(p)){var U=P.slice(0,I),L=P.slice(I+1),D=N.match(m);D&&(U.push(D[1]),L.unshift(D[2])),L.length&&(C="/"+L.join(".")+C),this.hostname=U.join(".");break}}}this.hostname.length>d?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+q,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==C[0]&&(C="/"+C))}if(!g[S])for(I=0,B=u.length;I<B;I++){var $=u[I];if(-1!==C.indexOf($)){var H=encodeURIComponent($);H===$&&(H=escape($)),C=C.split($).join(H)}}var V=C.indexOf("#");-1!==V&&(this.hash=C.substr(V),C=C.slice(0,V));var W=C.indexOf("?");if(-1!==W?(this.search=C.substr(W),this.query=C.substr(W+1),t&&(this.query=b.parse(this.query)),C=C.slice(0,W)):t&&(this.search="",this.query={}),C&&(this.pathname=C),v[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var K=this.search||"";this.path=q+K}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(w(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),l=0;l<c.length;l++){var u=c[l];"protocol"!==u&&(n[u]=e[u])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!v[e.protocol]){for(var h=Object.keys(e),f=0;f<h.length;f++){var d=h[f];n[d]=e[d]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var p=(e.pathname||"").split("/");p.length&&!(e.host=p.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),n.pathname=p.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",g=n.search||"";n.path=m+g}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),C=w||b||n.host&&e.pathname,_=C,k=n.pathname&&n.pathname.split("/")||[],S=(p=e.pathname&&e.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(S&&(n.hostname="",n.port=null,n.host&&(""===k[0]?k[0]=n.host:k.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===p[0]?p[0]=e.host:p.unshift(e.host)),e.host=null),C=C&&(""===p[0]||""===k[0])),w)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,k=p;else if(p.length)k||(k=[]),k.pop(),k=k.concat(p),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return S&&(n.hostname=n.host=k.shift(),(I=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=I.shift(),n.host=n.hostname=I.shift())),n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var E=k.slice(-1)[0],A=(n.host||e.host||k.length>1)&&("."===E||".."===E)||""===E,T=0,x=k.length;x>=0;x--)"."===(E=k[x])?k.splice(x,1):".."===E?(k.splice(x,1),T++):T&&(k.splice(x,1),T--);if(!C&&!_)for(;T--;T)k.unshift("..");!C||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),A&&"/"!==k.join("/").substr(-1)&&k.push("");var I,O=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(n.hostname=n.host=O?"":k.length?k.shift():"",(I=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=I.shift(),n.host=n.hostname=I.shift())),(C=C||n.host&&k.length)&&!O&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":77,punycode:51,querystring:54}],77:[function(e,t,n){t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],78:[function(e,t,n){(function(e){(function(){function n(e,t){if(r("noDeprecation"))return e;var n=!1;function o(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return o}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this)}).call(this,void 0!==be?be:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(e,t,n){function r(e,t){if(e&&t)return r(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach((function(e){r[e]=o[e]})),r}}t.exports=r},{}],80:[function(e,t,n){t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(e,t,n){t.exports=o;var r=Object.prototype.hasOwnProperty;function o(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e}},{}],82:[function(e,t,n){t.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},{}],83:[function(e,t,n){function r(e){var t=this;if(t instanceof r||(t=new r),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var n=0,o=arguments.length;n<o;n++)t.push(arguments[n]);return t}function o(e,t,n){var r=t===e.head?new a(n,null,t,e):new a(n,t,t.next,e);return null===r.next&&(e.tail=r),null===r.prev&&(e.head=r),e.length++,r}function i(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function s(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,n,r){if(!(this instanceof a))return new a(e,t,n,r);this.list=r,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,n?(n.prev=this,this.next=n):this.next=null}t.exports=r,r.Node=a,r.create=r,r.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),e.list.length--,e.next=null,e.prev=null,e.list=null,t},r.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},r.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},r.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},r.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},r.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},r.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},r.prototype.forEach=function(e,t){t=t||this;for(var n=this.head,r=0;null!==n;r++)e.call(t,n.value,r,this),n=n.next},r.prototype.forEachReverse=function(e,t){t=t||this;for(var n=this.tail,r=this.length-1;null!==n;r--)e.call(t,n.value,r,this),n=n.prev},r.prototype.get=function(e){for(var t=0,n=this.head;null!==n&&t<e;t++)n=n.next;if(t===e&&null!==n)return n.value},r.prototype.getReverse=function(e){for(var t=0,n=this.tail;null!==n&&t<e;t++)n=n.prev;if(t===e&&null!==n)return n.value},r.prototype.map=function(e,t){t=t||this;for(var n=new r,o=this.head;null!==o;)n.push(e.call(t,o.value,this)),o=o.next;return n},r.prototype.mapReverse=function(e,t){t=t||this;for(var n=new r,o=this.tail;null!==o;)n.push(e.call(t,o.value,this)),o=o.prev;return n},r.prototype.reduce=function(e,t){var n,r=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,n=this.head.value}for(var o=0;null!==r;o++)n=e(n,r.value,o),r=r.next;return n},r.prototype.reduceReverse=function(e,t){var n,r=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,n=this.tail.value}for(var o=this.length-1;null!==r;o--)n=e(n,r.value,o),r=r.prev;return n},r.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},r.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},r.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new r;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=0,i=this.head;null!==i&&o<e;o++)i=i.next;for(;null!==i&&o<t;o++,i=i.next)n.push(i.value);return n},r.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new r;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=this.length,i=this.tail;null!==i&&o>t;o--)i=i.prev;for(;null!==i&&o>e;o--,i=i.prev)n.push(i.value);return n},r.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,i=this.head;null!==i&&r<e;r++)i=i.next;var s=[];for(r=0;i&&r<t;r++)s.push(i.value),i=this.removeNode(i);for(null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev),r=0;r<n.length;r++)i=o(this,i,n[r]);return s},r.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r}return this.head=t,this.tail=e,this};try{e("./iterator.js")(r)}catch(e){}},{"./iterator.js":82}]},{},[12])(12)}(rs);var os=we(rs.exports);var is;!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"}(is||(is={}));const ss=e=>{let t,n=0,r=!0;return{connect:async function(o){return t&&(t.removeAllListeners(),t.end(!0)),t=os.connect(e,function(e){return Object.assign({clean:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:0,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1}},e)}({username:o.userId,password:o.accessToken})),t.on("connect",(()=>{n=0,r=!0})),t.on("error",(e=>{switch(e.code){case 2:case 4:case 5:r=!1}})),t.on("close",(()=>{r&&setTimeout((()=>{n+=1,t.reconnect()}),1e3*2**(n>10?10:n))})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(r=!1,this.connected)return new Promise((e=>null==t?void 0:t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,n){null==t||t.on(e,n)},once(e,n){null==t||t.once(e,n)},off(e,n){void 0!==n?null==t||t.off(e,n):null==t||t.removeAllListeners(e)},removeAllListeners(){null==t||t.removeAllListeners()},subscribe(e,n){const r=(t,r)=>{if(t||128===r[0].qos){const r=t?new Y(t.message,8e5,"error"):new Z(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)}}},as=async()=>{const e=ne();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},cs=()=>`ascWebSdk#${Math.random().toString(16)}`,ls=()=>{const e=(()=>{var e,t;return(null===(e=r.versions)||void 0===e?void 0:e.node)?r.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}},us=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],hs=e=>{const t=ne(),n=us.map((n=>le(t,`client/onConnectionError(${n})`,n,(t=>{const r=(null==t?void 0:t.code)?new Y(t.message,t.code,"fatal"):new ee(n);e(r)}))));return()=>{n.forEach((e=>e()))}},fs=e=>hs((({code:t})=>{400312===t&&e()})),ds=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=q[e];if(!r)return;const o=U(r);n.forEach((e=>{$e([r,"get",o(e)],e,t)}))}))},ps=(e,t)=>{const n=ne();return le(n,e,e,(e=>{n.cache&&ds(e),t(e.users[0])}))},ms=e=>ps("user.deleted",e),gs=async e=>{const t=ne();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};gs.locally=e=>{const t=ne();return t.log("user/getUser.locally",e),t.cache&&De(["user","get",e])};const ys=async e=>{const t=ne();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&&ds(r,{cachedAt:o}),{data:r.users,cachedAt:o}};function vs(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}ys.locally=e=>{var t;const n=ne();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>De(["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 bs=async(e={})=>{const t=ne();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=vs(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:N(n,"skiplimit")}})}),{paging:c}=a,l=vs(a,["paging"]),{users:u}=l,h=t.cache&&Date.now();if(t.cache){ds(l,{cachedAt:h});qe(["user","query",e],{users:u.map(U("user")),paging:c})}return{data:u,cachedAt:h,prevPage:F(c.previous),nextPage:F(c.next)}};bs.locally=(e={})=>{var t,n,r;const o=ne();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=De(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>De(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],l=F(null==s?void 0:s.paging.previous),u=F(null==s?void 0:s.paging.next);return c.length>0&&c.length===(null===(r=null==s?void 0:s.users)||void 0===r?void 0:r.length)?{data:c,cachedAt:a,prevPage:l,nextPage:u}:void 0};const ws=e=>ps("user.updated",e),Cs=e=>ps("user.flagged",e),_s=e=>ps("user.unflagged",e),ks=e=>ps("user.flagCleared",e),Ss=async e=>{const t=ne();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&ds({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};Ss.locally=e=>{const t=ne();if(t.log("file/getFile.locally",e),!t.cache)return;const n=De(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Es=async e=>{const t=ne();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=vs(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:N(r,"skiplimit")}})}),{paging:c}=a,l=vs(a,["paging"]),{roles:u}=l,h=t.cache&&Date.now();t.cache&&ds(l,{cachedAt:h});const f=F(c.next);return{data:u,cachedAt:h,prevPage:F(c.previous),nextPage:f}};Es.locally=e=>{ne().log("role/queryRoles.locally",e)};const As=async e=>{const t=ne();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&ds({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};As.locally=e=>{const t=ne();if(t.log("role/getRole.locally",e),!t.cache)return;const n=De(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ts=(e,t)=>{"message"===e?ue("v3.message.didUpdate",{messages:[t]}):"post"===e?ue("post.updated",{posts:[t]}):"comment"===e&&ue("comment.updated",{comments:[t]})},xs=async e=>{const t=ne();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};xs.locally=e=>{const t=ne();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=De(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Is=async e=>{const t=ne();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&&ds(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};Is.locally=e=>{var t;const n=ne();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>De(["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 Os=async e=>{const t=ne();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=vs(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:N(n,"afterbefore")}})}),{paging:i}=o,s=vs(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){ds(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];qe(e,{messages:a.map(U("message")),paging:i})}const l=F(i.next);return{data:a,cachedAt:c,prevPage:F(i.previous),nextPage:l}};Os.locally=e=>{var t,n;const r=ne();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=vs(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=De(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const l=a.messages.map((e=>De(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),u=F(null==a?void 0:a.paging.previous),h=F(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};var Rs={},Ps={},Bs={};Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.bytesToString=Bs.stringToBytes=Bs.NIL=Bs.X500=Bs.OID=Bs.URL=Bs.DNS=Bs.hexToByte=Bs.byteToHex=void 0;let Ns=[],Fs={};for(var js=0;js<256;js++)Ns[js]=(js+256).toString(16).substr(1),Fs[Ns[js]]=js;Bs.byteToHex=Ns,Bs.hexToByte=Fs,Bs.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Bs.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",Bs.OID="6ba7b812-9dad-11d1-80b4-00c04fd430c8",Bs.X500="6ba7b814-9dad-11d1-80b4-00c04fd430c8",Bs.NIL="00000000-0000-0000-0000-000000000000";Bs.stringToBytes=e=>{e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t};Bs.bytesToString=e=>{const t=new Uint8Array(e,0,e.byteLength);return String.fromCharCode.apply(null,Array.from(t))},Object.defineProperty(Ps,"__esModule",{value:!0}),Ps.parse=void 0;const Ms=Bs;Ps.parse=(e,t,n)=>{let r=t&&n||0,o=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,(e=>(o<16&&t&&(t[r+o++]=Ms.hexToByte[e]),"")));o<16;)t[r+o++]=0;return t};var Us={};Object.defineProperty(Us,"__esModule",{value:!0}),Us.unparse=void 0;const Ls=Bs;Us.unparse=(e,t)=>{let n=t||0,r=Ls.byteToHex;return r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]};var Ds={},qs={};Object.defineProperty(qs,"__esModule",{value:!0});qs.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;var zs=be&&be.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.validate=void 0;const $s=zs(qs);Ds.validate=e=>"string"==typeof e&&$s.default.test(e);var Hs={};Object.defineProperty(Hs,"__esModule",{value:!0}),Hs.version=void 0;const Vs=Ds;Hs.version=e=>{if(!Vs.validate(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};var Ws={},Ks={};Object.defineProperty(Ks,"__esModule",{value:!0}),Ks.stringify=void 0;const Qs=Ds,Js=[];for(let e=0;e<256;++e)Js.push((e+256).toString(16).substr(1));Ks.stringify=(e,t=0)=>{const n=(Js[e[t+0]]+Js[e[t+1]]+Js[e[t+2]]+Js[e[t+3]]+"-"+Js[e[t+4]]+Js[e[t+5]]+"-"+Js[e[t+6]]+Js[e[t+7]]+"-"+Js[e[t+8]]+Js[e[t+9]]+"-"+Js[e[t+10]]+Js[e[t+11]]+Js[e[t+12]]+Js[e[t+13]]+Js[e[t+14]]+Js[e[t+15]]).toLowerCase();if(!Qs.validate(n))throw TypeError("Stringified UUID is invalid");return n};var Xs={};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.rng=void 0;Xs.rng=()=>{let e=new Array(16);for(let t=0;t<16;t++)e[t]=255&256*Math.random()+0;return e},Object.defineProperty(Ws,"__esModule",{value:!0}),Ws.v1=void 0;const Ys=Ks,Gs=Xs;let Zs,ea,ta=0,na=0;Ws.v1=(e,t,n=0)=>{let r=t&&n||0;const o=t||new Uint8Array(16);let i=e&&e.node?e.node:Zs,s=e&&e.clockseq?e.clockseq:ea;if(null==i||null==s){const t=e&&e.random?e.random:e&&e.rng?e.rng():Gs.rng();null==i&&(i=Zs=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==s&&(s=ea=16383&(t[6]<<8|t[7]))}let a=e&&e.msecs?e.msecs:Date.now(),c=e&&e.nsecs?e.nsecs:na+1;const l=a-ta+(c-na)/1e4;if(l<0&&e&&!e.clockseq&&(s=s+1&16383),(l<0||a>ta)&&e&&!e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ta=a,na=c,ea=s,a+=122192928e5;const u=(1e4*(268435455&a)+c)%4294967296;o[r++]=u>>>24&255,o[r++]=u>>>16&255,o[r++]=u>>>8&255,o[r++]=255&u;const h=a/4294967296*1e4&268435455;o[r++]=h>>>8&255,o[r++]=255&h,o[r++]=h>>>24&15|16,o[r++]=h>>>16&255,o[r++]=s>>>8|128,o[r++]=255&s;for(let e=0;e<6;++e)o[r+e]=i[e];return t||Ys.stringify(o)};var ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.v4=void 0;const oa=Us,ia=Xs;ra.v4=(e,t,n)=>{let r=t&&n||0,o=ia.rng();if(!e||e instanceof String||(e.random&&(o=e.random),e.rng&&(o=e.rng())),o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var i=0;i<16;i++)t[r+i]=o[i];return t||oa.unparse(o)};var sa={},aa={};Object.defineProperty(aa,"__esModule",{value:!0}),aa.v35=void 0;const ca=Ks,la=Ps,ua=Bs;aa.v35=(e,t,n)=>(e,r,o,i=0)=>{if("string"==typeof e&&(e=ua.stringToBytes(e)),"string"==typeof r&&(r=la.parse(r)),r&&16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let s=new Uint8Array(16+e.length);if(s.set(r),s.set(e,r.length),s=ua.stringToBytes(n(ua.bytesToString(s))),s[6]=15&s[6]|t,s[8]=63&s[8]|128,o)for(let e=0;e<16;++e)o[i+e]=s[e];return o||ca.stringify(s)};var ha={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.any_hmac_sha1=e.b64_hmac_sha1=e.hex_hmac_sha1=e.any_sha1=e.b64_sha1=e.hex_sha1=void 0;let t=0,n="";e.hex_sha1=e=>i(r(c(e))),e.default=e.hex_sha1;e.b64_sha1=e=>s(r(c(e)));e.any_sha1=(e,t)=>a(r(c(e)),t);e.hex_hmac_sha1=(e,t)=>i(o(c(e),c(t)));e.b64_hmac_sha1=(e,t)=>s(o(c(e),c(t)));e.any_hmac_sha1=(e,t,n)=>a(o(c(e),c(t)),n);const r=e=>u(h(l(e),8*e.length)),o=(e,t)=>{let n=l(e);n.length>16&&(n=h(n,8*e.length));let r=Array(16),o=Array(16);for(var i=0;i<16;i++)r[i]=909522486^n[i],o[i]=1549556828^n[i];var s=h(r.concat(l(t)),512+8*t.length);return u(h(o.concat(s),672))},i=e=>{for(var n,r=t?"0123456789ABCDEF":"0123456789abcdef",o="",i=0;i<e.length;i++)n=e.charCodeAt(i),o+=r.charAt(n>>>4&15)+r.charAt(15&n);return o},s=e=>{for(var t="",r=e.length,o=0;o<r;o+=3)for(var i=e.charCodeAt(o)<<16|(o+1<r?e.charCodeAt(o+1)<<8:0)|(o+2<r?e.charCodeAt(o+2):0),s=0;s<4;s++)8*o+6*s>8*e.length?t+=n:t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-s)&63);return t},a=(e,t)=>{var n,r,o,i,s=t.length,a=[],c=Array(Math.ceil(e.length/2));for(n=0;n<c.length;n++)c[n]=e.charCodeAt(2*n)<<8|e.charCodeAt(2*n+1);for(;c.length>0;){for(i=[],o=0,n=0;n<c.length;n++)o=(o<<16)+c[n],o-=(r=Math.floor(o/s))*s,(i.length>0||r>0)&&(i[i.length]=r);a[a.length]=o,c=i}var l="";for(n=a.length-1;n>=0;n--)l+=t.charAt(a[n]);var u=Math.ceil(8*e.length/(Math.log(t.length)/Math.log(2)));for(n=l.length;n<u;n++)l=t[0]+l;return l},c=e=>{for(var t,n,r="",o=-1;++o<e.length;)t=e.charCodeAt(o),n=o+1<e.length?e.charCodeAt(o+1):0,t>=55296&&t<=56319&&n>=56320&&n<=57343&&(t=65536+((1023&t)<<10)+(1023&n),o++),t<=127?r+=String.fromCharCode(t):t<=2047?r+=String.fromCharCode(192|t>>>6&31,128|63&t):t<=65535?r+=String.fromCharCode(224|t>>>12&15,128|t>>>6&63,128|63&t):t<=2097151&&(r+=String.fromCharCode(240|t>>>18&7,128|t>>>12&63,128|t>>>6&63,128|63&t));return r},l=e=>{for(var t=Array(e.length>>2),n=0;n<t.length;n++)t[n]=0;for(n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t},u=e=>{for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t},h=(e,t)=>{e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n=Array(80),r=1732584193,o=-271733879,i=-1732584194,s=271733878,a=-1009589776,c=0;c<e.length;c+=16){for(var l=r,u=o,h=i,g=s,y=a,v=0;v<80;v++){n[v]=v<16?e[c+v]:m(n[v-3]^n[v-8]^n[v-14]^n[v-16],1);let t=p(p(m(r,5),f(v,o,i,s)),p(p(a,n[v]),d(v)));a=s,s=i,i=m(o,30),o=r,r=t}r=p(r,l),o=p(o,u),i=p(i,h),s=p(s,g),a=p(a,y)}return[r,o,i,s,a]},f=(e,t,n,r)=>e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r,d=e=>e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514,p=(e,t)=>{var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},m=(e,t)=>e<<t|e>>>32-t}(ha);var fa=be&&be.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(sa,"__esModule",{value:!0}),sa.v5=void 0;const da=aa,pa=fa(ha);sa.v5=da.v35("v5",80,pa.default),Object.defineProperty(Rs,"__esModule",{value:!0});const ma=Ps,ga=Us,ya=Ds,va=Hs,ba=Ws,wa=ra,Ca=sa,_a=Bs;var ka=Rs.default={parse:ma.parse,unparse:ga.unparse,validate:ya.validate,version:va.version,v1:ba.v1,v4:wa.v4,v5:Ca.v5,NIL:_a.NIL,DNS:_a.DNS,URL:_a.URL,OID:_a.OID,X500:_a.X500};const Sa=async e=>{const t=ne();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};Sa.optimistically=e=>{var t,n;const r=ne();if(!r.cache)return;const o=Object.assign({messageId:ka.v4().toString()},e);r.log("user/createMessage.locally",o);const i=De(["channel","get",o.channelId]);$e(["channel","get",o.channelId],Object.assign(Object.assign({},null==i?void 0:i.data),{messageCount:(null!==(t=null==i?void 0:i.data.messageCount)&&void 0!==t?t:0)+1}));const s=(new Date).toISOString(),a=Object.assign({userId:r.userId,channelSegment:(null!==(n=null==i?void 0:i.data.messageCount)&&void 0!==n?n:0)+1,createdAt:s,updatedAt:s},o);return qe(["message","get",a.messageId],a,{cachedAt:-1}),ue("v3.message.didCreate",{messages:[a]}),{data:a,cachedAt:-1}};const Ea=async(e,t)=>{const n=ne();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&&ds(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};Ea.optimistically=(e,t)=>{const n=ne();if(n.log("user/updateMessage",t),!n.cache)return;const r=De(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return $e(["message","get",e],o,{cachedAt:-1}),ue("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const Aa=async e=>{const t=ne();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await xs(e)).data};Aa.optimistically=e=>{ne().log("message/deleteMessage",e);const t=De(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return $e(["message","get",e],n,{cachedAt:-1}),ue("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const Ta=async e=>{const t=ne();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=vs(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:N(n,"afterbeforeraw")}})}),{paging:i}=o,s=vs(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){ds(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];qe(e,{posts:a.map(U("post")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};Ta.locally=e=>{var t,n;const r=ne();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=vs(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=De(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const l=a.posts.map((e=>De(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const xa=async e=>{const t=ne();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&&ds(r,{cachedAt:o}),{data:r.posts,cachedAt:o}};xa.locally=e=>{var t;const n=ne();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>De(["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 Ia=async e=>{const t=ne();let n;t.log("post/getPost",e);try{n=(await t.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&He(["post","get",e],!0),t}const r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{posts:o}=n;return{data:o.find((t=>t.postId===e)),cachedAt:r}};Ia.locally=e=>{const t=ne();if(t.log("post/getPost.locally",e),!t.cache)return;const n=De(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Oa=async e=>{const t=ne();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=vs(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:N(r,"skiplimit")}})}),{paging:c}=a,l=vs(a,["paging"]),{communities:u}=l,h=t.cache&&Date.now();if(t.cache){ds(l,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];qe(e,{communities:u.map(U("community")),paging:c})}const f=F(c.next);return{data:u,cachedAt:h,prevPage:F(c.previous),nextPage:f}};Oa.locally=e=>{ne().log("community/queryCommunities.locally",e)};const Ra=async e=>{const t=ne();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&&ds(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};Ra.locally=e=>{var t;const n=ne();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>De(["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 Pa=async e=>{const t=ne();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};Pa.locally=e=>{const t=ne();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=De(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ba=async e=>{const t=ne();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=vs(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:N(r,"skiplimit")}})}),{paging:a}=s,c=vs(s,["paging"]),{communityUsers:l}=c,u=t.cache&&Date.now();t.cache&&ds(c,{cachedAt:u});return{data:l,cachedAt:u,nextPage:F(a.next),prevPage:F(a.previous)}};Ba.locally=e=>{ne().log("community/queryCommunityMembers",e)};const Na=async e=>{const t=ne();t.log("channel/getTopTrendingCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/top-trending",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){ds(r,{cachedAt:i});qe(["community","top-trending",{params:{options:{limit:n}}}],{communities:o.map(U("community"))})}return{data:o,cachedAt:i}};Na.locally=e=>{var t,n;const r=ne();if(r.log("community/getTopTrendingCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","top-trending",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=De(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>De(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const Fa=async e=>{const t=ne();t.log("channel/getRecommendedCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/recommended",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){ds(r,{cachedAt:i});qe(["community","recommended",{params:{options:{limit:n}}}],{communities:o.map(U("community"))})}return{data:o,cachedAt:i}};Fa.locally=e=>{var t,n;const r=ne();if(r.log("community/getRecommendedCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","recommended",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=De(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>De(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const ja=async e=>{const t=ne();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=vs(e,["page"]),o={type:r.sortBy?"pagination":void 0,token:N(n,r.sortBy?"skiplimit":"afterbefore")},{data:i}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:o})}),{paging:s}=i,a=vs(i,["paging"]),{comments:c}=a,l=t.cache&&Date.now();if(t.cache){ds(a,{cachedAt:l});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];qe(e,{comments:c.map(U("comment")),paging:s})}const u=F(s.next);return{data:c,cachedAt:l,prevPage:F(s.previous),nextPage:u}};ja.locally=e=>{var t,n;const r=ne();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=vs(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=De(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const l=a.comments.map((e=>De(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),u=F(null==a?void 0:a.paging.previous),h=F(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const Ma=async e=>{const t=ne();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&&ds(r,{cachedAt:o}),{data:r.comments,cachedAt:o}};Ma.locally=e=>{var t;const n=ne();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>De(["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 Ua=async e=>{const t=ne();let n;t.log("comment/getComment",e);try{n=(await t.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&He(["comment","get",e],!0),t}const r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{comments:o}=n;return{data:o.find((t=>t.commentId===e)),cachedAt:r}};Ua.locally=e=>{const t=ne();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=De(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const La=async(e,t)=>{if("message"===e)return xs(t);if("post"===e)return Ia(t);if("comment"===e)return Ua(t);throw new Error(`Incorrect referenceType: ${e}`)},Da=(e,t)=>{var n,r;if(ne().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=De(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=De(["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))})}},qa=async(e,t,n)=>{var r,o;const i=ne();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 La(e,t);return Ts(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};qa.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=ne();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=De([e,"get",t]);if(!(null==l?void 0:l.data)||(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:l.data.reactionsCount+1,myReactions:[...null!==(o=l.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)+1})});return $e([e,"get",t],u,{cachedAt:-1}),Ts(e,u),null!==(a=null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const za=async(e,t,n)=>{var r,o;const i=ne();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 La(e,t);return Ts(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};za.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=ne();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=De([e,"get",t]);if(!(null==l?void 0:l.data)||!(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:Math.max(0,l.data.reactionsCount-1),myReactions:(null!==(o=l.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:Math.max(0,(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)-1)})});return $e([e,"get",t],u,{cachedAt:-1}),Ts(e,u),null!==(a=!(null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};const $a=(e,t)=>{const n=ne();return le(n,e,e,(r=>{var o;if(n.cache){const{communities:n}=r,i=vs(r,["communities"]);ds(i),(null==n?void 0:n[0])&&!["post.updated"].includes(e)&&ue("community.updated",{communities:n});const s=De(["post","get",r.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=Le(["post","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.targetId)===s.data.targetId}));"post.declined"===e&&(t=null==t?void 0:t.filter((({key:e})=>{var t;return"reviewing"===(null===(t=e[2])||void 0===t?void 0:t.feedType)}))),null==t||t.map((({key:e,data:t})=>$e(e,t,{cachedAt:-1})))}t(s.data)}else t(r.posts[0])}))},Ha=e=>$a("post.created",e),Va=e=>$a("post.updated",e),Wa=e=>$a("post.deleted",e),Ka=e=>$a("post.approved",e),Qa=e=>$a("post.declined",e),Ja=e=>$a("post.flagged",e),Xa=e=>$a("post.unflagged",e),Ya=e=>{const t=ne();return le(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){Da("post.addReaction",n);const t=vs(n,["reactor"]);ds(t);const r=De(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},Ga=e=>{const t=ne();return le(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){Da("post.removeReaction",n);const t=vs(n,["reactor"]);ds(t);const r=De(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},Za=(e,t)=>{const n=ne();return le(n,e,e,(r=>{var o;if(n.cache){ds(r);const n=De(["comment","get",r.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=Le(["comment","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.referenceId)===n.data.referenceId}));null==e||e.map((({key:e,data:t})=>$e(e,t,{cachedAt:-1})))}t(n.data)}else t(r.comments[0])}))},ec=e=>Za("comment.created",e),tc=e=>Za("comment.updated",e),nc=e=>Za("comment.deleted",e),rc=e=>Za("comment.flagged",e),oc=e=>Za("comment.unflagged",e),ic=e=>{const t=ne();return le(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){Da("comment.addReaction",n);const t=vs(n,["reactor"]);ds(t);const r=De(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},sc=e=>{const t=ne();return le(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){Da("comment.removeReaction",n);const t=vs(n,["reactor"]);ds(t);const r=De(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))};var ac={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 cc=async e=>{const t=ne();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=vs(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:N(r,"skiplimit")}})}),{paging:c}=a,l=vs(a,["paging"]),{channels:u}=l,h=t.cache&&Date.now();if(t.cache){ds(l,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];qe(e,{channels:u.map(U("channel")),paging:c})}const f=F(c.next);return{data:u,cachedAt:h,prevPage:F(c.previous),nextPage:f}};cc.locally=e=>{ne().log("channel/queryChannels.locally",e)};const lc=async e=>{const t=ne();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&&ds(r,{cachedAt:o}),{data:r.channels,cachedAt:o}};lc.locally=e=>{var t;const n=ne();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>De(["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 uc=async e=>{const t=ne();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};uc.locally=e=>{const t=ne();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=De(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const hc=async e=>{const t=ne();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o}=n,i=vs(n,["page","channelId"]),{data:s}=await t.http.get(`/api/v4/channels/${encodeURIComponent(o)}/users`,{params:Object.assign(Object.assign({},i),{options:{token:N(r,"skiplimit")}})}),{paging:a}=s,c=vs(s,["paging"]),{channelUsers:l}=c,u=t.cache&&Date.now();t.cache&&ds(c);return{data:l,cachedAt:u,nextPage:F(a.next),prevPage:F(a.previous)}};hc.locally=e=>{ne().log("channel/queryChannelMembers",e)};const fc=e=>{const t=ne();return le(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{ds(t),e(t.channels[0])}))},dc=e=>{const t=ne();return le(t,"onChannelDeleted","v3.channel.didDelete",(t=>{ds(t),e(t.channels[0])}))},pc=e=>{const t=ne();return le(t,"onChannelJoined","v3.channel.didJoin",(t=>{ds(t),e(t.channels[0])}))},mc=e=>{const t=ne();return le(t,"onChannelLeft","v3.channel.didLeave",(t=>{ds(t),e(t.channels[0])}))},gc=e=>{const t=ne();return le(t,"onChannelMemberAdded","v3.channel.didAddUsers",(t=>{ds(t),e(t.channels[0],t.channelUsers[0])}))},yc=e=>{const t=ne();return le(t,"onChannelMemberRemoved","v3.channel.didRemoveUsers",(t=>{ds(t),e(t.channels[0],t.channelUsers[0])}))},vc=e=>{const t=ne();return le(t,"message/onMessageCreated","v3.message.didCreate",(t=>{ds(t),e(t.messages[0])}))},bc=e=>{const t=ne();return le(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{ds(t);const n=t.messages[0];(null==n?void 0:n.myReactions)||(e=>{const t=ne(),n=De(["message","get",e.messageId]),r=(null==n?void 0:n.data.myReactions)||[];Object.assign(e,{myReactions:r});const o=null==e?void 0:e.latestReaction;o&&o.userId===t.userId&&("add"!==o.eventName||r.includes(o.reactionName)||Object.assign(e,{myReactions:[...r,o.reactionName]}),"remove"===o.eventName&&r.includes(o.reactionName)&&Object.assign(e,{myReactions:r.filter((e=>e!==o.reactionName))}))})(n),e(n)}))},wc=e=>{const t=ne();return le(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{ds(t),e(t.messages[0])}))},Cc=(e,t)=>{const n=ne();return le(n,e,e,(e=>{if(n.cache){ds(e);const n=De(["community","get",e.communities[0].communityId]);t(n.data)}else t(e.communities[0])}))};function _c(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function kc(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=>!_c(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!_c(e,t,"ADD_COMMUNITY_USER")))[0]}const Sc=(e,t)=>{const n=ne();return le(n,e,e,(r=>{if(n.cache){ds(r);const n=De(["community","get",r.communities[0].communityId]),o=De(["communityUsers","get",U("communityUsers")(kc(e,r))]);t(n.data,o.data)}else t(r.communities[0],kc(e,r))}))},Ec=e=>Cc("community.updated",e),Ac=e=>Cc("community.deleted",e),Tc=e=>Sc("community.joined",e),xc=e=>Sc("community.left",e),Ic=e=>Sc("community.userAdded",e),Oc=e=>Sc("community.userRemoved",e),Rc=e=>Sc("community.userBanned",e),Pc=e=>Sc("community.userUnbanned",e),Bc=async e=>{const t=ne();t.log("category/queryCategories",e);const n=null!=e?e:{},{page:r={limit:10}}=n,o=vs(n,["page"]),{data:i}=await t.http.get("/api/v3/community-categories",{params:Object.assign(Object.assign({},o),{options:{token:N(r,"skiplimit")}})}),{paging:s}=i,a=vs(i,["paging"]),{categories:c}=a,l=t.cache&&Date.now();if(t.cache){ds(a,{cachedAt:l});const e=["category","query",Object.assign(Object.assign({},o),{options:Object.assign({},r)})];qe(e,{categories:c.map(U("category")),paging:s})}const u=F(s.next);return{data:c,cachedAt:l,prevPage:F(s.previous),nextPage:u}};Bc.locally=e=>{var t,n;const r=ne();if(r.log("category/queryCategories.locally",e),!r.cache)return;const o=null!=e?e:{},{page:i={limit:10}}=o,s=vs(o,["page"]),a=["category","query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(t=De(a))&&void 0!==t?t:{};if(!(null==c?void 0:c.categories.length))return;const u=c.categories.map((e=>De(["category","get",e]))).filter(Boolean).map((({data:e})=>e)),h=F(null==c?void 0:c.paging.previous),f=F(null==c?void 0:c.paging.next);return u.length===(null===(n=null==c?void 0:c.categories)||void 0===n?void 0:n.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const Nc=async e=>{const t=ne();t.log("category/getCategory",e);const{data:n}=await t.http.get(`/api/v3/community-categories/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{categories:o}=n;return{data:o.find((t=>t.categoryId===e)),cachedAt:r}};Nc.locally=e=>{const t=ne();if(t.log("category/getCategory.locally",e),!t.cache)return;const n=De(["category","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Fc=async e=>{const t=ne();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{useCustomRanking:r,page:o}=n,i=vs(n,["useCustomRanking","page"]),{data:s}=await t.http.get(r?"/api/v5/me/global-feeds":"/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},i),{options:{token:N(o,"skiplimit")}})}),{paging:a}=s,c=vs(s,["paging"]),{posts:l}=c,u=t.cache&&Date.now();if(t.cache){ds(c);const e=["globalFeed","query",Object.assign(Object.assign({},i),{useCustomRanking:r,options:Object.assign({},o)})];qe(e,{posts:l.map(U("post")),paging:a})}const h=F(a.next);return{data:l,cachedAt:u,prevPage:F(a.previous),nextPage:h}};Fc.locally=e=>{var t,n;const r=ne();if(r.log("post/queryGlobalFeed.locally",e),!r.cache)return;const o=null!=e?e:{},{useCustomRanking:i,page:s}=o,a=vs(o,["useCustomRanking","page"]),c=["globalFeed","query",Object.assign(Object.assign({},a),{useCustomRanking:i,options:Object.assign({},s)})],{data:l,cachedAt:u}=null!==(t=De(c))&&void 0!==t?t:{};if(!(null==l?void 0:l.posts.length))return;const h=l.posts.map((e=>De(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),f=F(null==l?void 0:l.paging.previous),d=F(null==l?void 0:l.paging.next);return h.length===(null===(n=null==l?void 0:l.posts)||void 0===n?void 0:n.length)?{data:h,cachedAt:u,prevPage:f,nextPage:d}:void 0};const jc=async(e,t)=>{const n=ne();n.log(`follow/queryF${e.substring(1)}`,t);const{userId:r,page:o}=t,i=vs(t,["userId","page"]),{data:s}=await n.http.get(n.userId===r?`/api/v4/me/${e}`:`/api/v4/users/${r}/${e}`,{params:Object.assign(Object.assign({},i),{token:N(o,"skiplimit")})}),{paging:a}=s,c=vs(s,["paging"]),{follows:l}=c,u=n.cache&&Date.now();if(n.cache){ds(c,{cachedAt:u});const t=[e,"query",Object.assign(Object.assign({},i),{userId:r,options:Object.assign({},o)})];qe(t,{follows:l.map(U("follow")),paging:a})}const h=F(a.next);return{data:l,cachedAt:u,prevPage:F(a.previous),nextPage:h}};jc.locally=(e,t)=>{var n,r;const o=ne();if(o.log(`follow/queryF${e.substring(1)}.locally`,t),!o.cache)return;const{page:i}=t,s=vs(t,["page"]),a=[e,"query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(n=De(a))&&void 0!==n?n:{};if(!(null==c?void 0:c.follows.length))return;const u=c.follows.map((e=>De(["follow","get",e]))).filter(Boolean).map((({data:e})=>e)),h=F(null==c?void 0:c.paging.previous),f=F(null==c?void 0:c.paging.next);return u.length===(null===(r=null==c?void 0:c.follows)||void 0===r?void 0:r.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const Mc=async e=>jc("followers",e);Mc.locally=e=>jc.locally("followers",e);const Uc=async e=>jc("following",e);Uc.locally=e=>jc.locally("following",e);const Lc=e=>["followInfo","get",`${ne().userId}#${e}`],Dc=async e=>{var t,n;const r=ne();r.log("follow/getFollowInfo",e);const{data:o}=await r.http.get(r.userId===e?"/api/v4/me/followInfo":`/api/v4/users/${e}/followInfo`),i=r.cache&&Date.now(),s=Object.assign(Object.assign({},o.followCounts[0]),{status:null===(n=null===(t=o.follows)||void 0===t?void 0:t[0])||void 0===n?void 0:n.status});return r.cache&&qe(Lc(e),s,{cachedAt:i}),{data:s,cachedAt:i}};Dc.locally=e=>{const t=ne();if(t.log("follow/getFollowInfo.locally",e),!t.cache)return;const n=De(Lc(e));return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const qc=(e,t)=>{const n=ne();return le(n,e,e,(e=>{var r,o;if(n.cache){ds({follows:[e]});[...null!==(r=Le(["followers","query"]))&&void 0!==r?r:[],...null!==(o=Le(["followings","query"]))&&void 0!==o?o:[]].filter((({key:t})=>t[2].userId===e.from||t[2].userId===e.to)).forEach((({key:e,data:t})=>$e(e,t,{cachedAt:-1}))),t(e)}else t(e)}))},zc=e=>qc("follow.created",e),$c=e=>qc("follow.unfollowed",e),Hc=e=>qc("follow.followerDeleted",e),Vc=e=>qc("follow.requested",e),Wc=e=>qc("follow.requestCanceled",e),Kc=e=>qc("follow.accepted",e),Qc=e=>qc("follow.requestDeclined",e),Jc=e=>{const t=async t=>{const[{data:n},{data:r}]=await Promise.all([Dc(t.from),Dc(t.to)]);e(n),e(r)},n=[qc("follow.created",t),qc("follow.requested",t),qc("follow.accepted",t),qc("follow.unfollowed",t),qc("follow.requestCanceled",t),qc("follow.requestDeclined",t),qc("follow.followerDeleted",t)];return()=>{n.forEach((e=>e()))}},Xc=async e=>{const t=ne();t.log("poll/getPoll",e);const{data:n}=await t.http.get(`/api/v3/polls/${e}`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}};Xc.locally=e=>{const t=ne();if(t.log("poll/getPoll",e),!t.cache)return;const n=De(["poll","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Yc=e=>{const t=ne();return le(t,"poll/onPollUpdated","poll.updated",(n=>{t.cache&&ds(n),e(n.polls[0])}))},Gc=e=>{const t=ne();return le(t,"poll/onPollDeleted","poll.deleted",(n=>{t.cache&&ds(n),e(n.polls[0])}))},Zc=async e=>{const t=ne();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};Zc.locally=e=>{const t=ne();if(t.log("stream/getStream",e),!t.cache)return;const n=De(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const el=async e=>{const t=ne();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=vs(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:N(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,l=t.cache&&Date.now();t.cache&&ds(a,{cachedAt:l});const u=F(s.next);return{data:c,cachedAt:l,prevPage:F(s.previous),nextPage:u}};el.locally=e=>{ne().log("stream/queryStreams.locally",e)};return e.API_REGIONS=Ye,e.VERSION=a,e.acceptFollower=async e=>{const t=ne();t.log("follow/acceptFollower",e);const{data:n}=await t.http.post(`/api/v4/me/followers/${e}`);return t.cache&&ds(n),ue("follow.accepted",n.follows[0]),!0},e.addChannelMembers=async(e,t)=>{const n=ne();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&&ds(r),ue("v3.channel.didAddUsers",{channels:r.channels,channelUsers:r.channelUsers});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=ne();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&&ds(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=ne();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&ds(r),ue("community.userAdded",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRoles=async(e,t,n)=>{const r=ne();r.log("community/addCommunityMembersRoles",e,t,n);const{data:o}=await r.http.post(`/api/v4/communities/${e}/users/roles`,{communityId:e,roles:t,userIds:n});r.cache&&ds(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&t.some((e=>n.roles.includes(e)))))},e.addReaction=qa,e.approvePost=async e=>{var t;const n=ne();n.log("post/approvePost",e);const{data:r}=await n.http.post(`/api/v3/posts/${encodeURIComponent(e)}/approve`),o=n.cache&&Date.now();if(n.cache&&ds(r,{cachedAt:o}),"community"===r.posts[0].targetType){const e=null===(t=r.communities)||void 0===t?void 0:t[0];ue("community.updated",{communities:[e]})}return ue("post.approved",{posts:[r.posts[0]]}),{data:r.posts.find((t=>t.postId===e)),cachedAt:o}},e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=ne();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 Fe.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.closePoll=async e=>{const t=ne();t.log("user/closePoll",e);const{data:n}=await t.http.put(`/api/v3/polls/${encodeURIComponent(e)}`,{status:"closed"}),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r}),ue("poll.updated",n);const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}},e.connectClient=async(e,t)=>{var n;const r=ne();r.log("client/api/connectClient",Object.assign({apiKey:r.apiKey},e)),null!==(n=e.deviceId)&&void 0!==n||(e.deviceId=cs());const{accessToken:o,users:i}=await(async e=>{const t=ne();t.log("client/api/getToken",e);const n=await ls(),{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,c;r.http.defaults.headers.common.Authorization=`Bearer ${o}`,r.ws.io.opts.query={token:o},s=r.ws,a=r.emitter,se.forEach((e=>{s.on(e,(t=>a.emit(e,t)))})),await new Promise((e=>{r.ws.once("connect",e),r.ws.open()})),r.userId=e.userId,r.accessToken=o,c=i[0],he={_id:c._id,userId:c.userId,path:c.path},!0!==(null==t?void 0:t.disableRTE)&&ve(me());const l=[fs((()=>{as(),l.forEach((e=>e()))})),ms((()=>null))];return r.ws.connected},e.createChannel=async e=>{const t=ne();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&&ds(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=Ye.SG,n="amity")=>{const r=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&!o,n=Xe(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(n);r("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiRegion:t});const i=qn(Ze("http",t)),s=(e=>{const t=ts(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(Ze("http",t)),c=ss(Ze("mqtt",t)),l=ce(),u={version:`${a}`,apiKey:e,log:r,http:i,ws:s,mqtt:c,emitter:l,use:()=>re(u)};try{ne()}catch(e){re(u)}return u},e.createComment=async e=>{const t=ne();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const o=await Ia(e.referenceId);ue("post.updated",{posts:[o.data]}),ue("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=ne();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r}),ue("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=ne();if(n.log("file/createFile",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&ds({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createImage=async(e,t)=>{const n=ne();if(n.log("file/createImage",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/images",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&ds({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createMessage=Sa,e.createPoll=async e=>{const t=ne();t.log("post/createPoll",e);const{data:n}=await t.http.post("/api/v3/polls",e),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{polls:o}=n;return{data:o[0],cachedAt:r}},e.createPost=async e=>{const t=ne();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&&ds(n,{cachedAt:r}),ue("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=K,e.createReport=async(e,t)=>{const n=ne();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=ac[e],{data:o}=await n.http.post("/api/"+("user"===e?`v4/me/flags/${encodeURIComponent(t)}`:`v3/${r}/${encodeURIComponent(t)}/flag`));n.cache&&ds(o);return ue("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=ne();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.createUserToken=async(e,t,n)=>{const r=cs(),o=await ls(),i=qn(Ze("http",t)),{data:s}=await i.post("/api/v3/sessions",Object.assign(Object.assign({},n),{deviceId:r,deviceInfo:Object.assign(Object.assign({},o),{model:"token management API on TS-SDK"})}),{headers:{"X-API-Key":e}});return{accessToken:s.accessToken}},e.createVideo=async(e,t)=>{const n=ne();if(n.log("file/createVideo",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/videos",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&ds({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.declineFollower=async e=>{const t=ne();t.log("follow/declineFollower",e);const{data:n}=await t.http.delete(`/api/v4/me/followers/${e}`);return t.cache&&ds(n),ue("follow.requestDeclined",n.follows[0]),!0},e.declinePost=async e=>{var t;const n=ne();n.log("post/declinePost",e);const{data:r}=await n.http.post(`/api/v3/posts/${encodeURIComponent(e)}/decline`),o=n.cache&&Date.now();if(n.cache&&ds(r,{cachedAt:o}),"community"===r.posts[0].targetType){const e=null===(t=r.communities)||void 0===t?void 0:t[0];ue("community.updated",{communities:[e]})}return ue("post.declined",{posts:[r.posts[0]]}),{data:r.posts.find((t=>t.postId===e)),cachedAt:o}},e.deleteChannel=async e=>{const t=ne();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await uc(e)).data},e.deleteComment=async(e,t=!1)=>{const n=ne();n.log("comment/deleteComment",e);const r=await Ua(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 Ia(r.data.referenceId);return ue("post.updated",{posts:[i.data]}),ue("comment.deleted",{comments:[o]}),t?setTimeout((()=>{He(["comment","get",e],!0)}),0):$e(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=ne();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await Pa(e);return ue("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=ne();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),He(["file","get",e],!0),{success:!0}},e.deleteMessage=Aa,e.deletePoll=async e=>{const t=ne();t.log("poll/deletePoll",e);const n=await Xc(e),{data:r}=await t.http.delete(`/api/v3/polls/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return $e(["poll","get",e],i),ue("poll.deleted",{polls:[i],users:[]}),o},e.deletePost=async(e,t=!1)=>{const n=ne();n.log("post/deletePost",e);const r=await Ia(e);if(await n.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await Pa(r.data.targetId);ue("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return ue("post.deleted",{posts:[o]}),t?setTimeout((()=>{He(["post","get",e],!0)}),0):$e(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=ne();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=ac[e],{data:o}=await n.http.delete("/api/"+("user"===e?`v4/me/flags/${encodeURIComponent(t)}`:`v3/${r}/${encodeURIComponent(t)}/unflag`));n.cache&&ds(o);return ue("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=ne();t.log("stream/deleteStream",e);const n=await Zc(e),{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return $e(["stream","get",e],i),o},e.disableCache=()=>{const e=ne();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=as,e.disposeStream=async e=>{const t=ne();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&&ds(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=He,e.enableCache=(e={},t)=>{const n=ne();n.cache||(n.log("cache/api/enableCache"),n.cache={data:e,persistIf:t})},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=(e,t,n)=>void 0!==n?e.filter((e=>e[t]===n)):e,e.follow=async e=>{const t=ne();t.log("follow/follow",e);const{data:n}=await t.http.post(`/api/v4/me/following/${e}`),r=t.cache&&Date.now();return t.cache&&ds(n,{cachedAt:r}),ue("accepted"===n.follows[0].status?"follow.created":"follow.requested",n.follows[0]),{data:n.follows[0],cachedAt:r}},e.getActiveClient=ne,e.getCategory=Nc,e.getChannel=uc,e.getChannels=lc,e.getComment=Ua,e.getCommentTopic=({path:e})=>e,e.getComments=Ma,e.getCommunities=Ra,e.getCommunity=Pa,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>pe(t,n),e.getFile=Ss,e.getFollowInfo=Dc,e.getMessage=xs,e.getMessages=Is,e.getMyFollowersTopic=()=>{const e=fe(),[t]=e.path.split("/user/");return`${t}/membership/${e._id}/+/+`},e.getMyFollowingsTopic=()=>{const e=fe(),[t]=e.path.split("/user/");return`${t}/membership/+/${e._id}/+`},e.getNetworkTopic=me,e.getPoll=Xc,e.getPost=Ia,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=xa,e.getRecommendedCommunities=Fa,e.getRole=As,e.getStream=Zc,e.getTopTrendingCommunities=Na,e.getUser=gs,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>pe(n===e.SubscriptionLevels.USER?t:t.replace(/^(\w*)/,"$1/social"),n),e.getUsers=ys,e.isAfterBefore=R,e.isAfterBeforeRaw=P,e.isCachable=V,e.isConnected=()=>{var e,t;const n=ne();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=z,e.isFresh=W,e.isLocal=e=>V(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=$,e.isOffline=H,e.isPaged=B,e.isReportedByMe=async(e,t)=>{var n,r;const o=ne();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=ac[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(Ln(t))}catch(e){o(e)}}))}))})(o,i,{[s]:t}))&&void 0!==n?n:{};return null!==(r=null!=a?a:c)&&void 0!==r&&r},e.isSkipLimit=O,e.joinChannel=async e=>{const t=ne();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&ds(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=ne();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r}),ue("community.joined",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=ne();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&ds(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=ne();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&ds(n,{cachedAt:r}),ue("community.left",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=ze,e.observeChannel=(e,t)=>{const{log:n}=ne(),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(fc((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),dc((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),pc((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),mc((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),gc((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),yc((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),J(K(uc,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}=ne(),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(tc((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),nc((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),rc((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),oc((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),ic((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),sc((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),J(K(Ua,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=ne(),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(ec((e=>i(e,"onCreate"))),tc((e=>i(e,"onUpdate"))),nc((e=>i(e,"onDelete"))),rc((e=>i(e,"onFlagged"))),oc((e=>i(e,"onUnflagged"))),ic((e=>i(e,"onReactionAdded"))),sc((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=ne(),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(Ec((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ac((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),Tc((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),xc((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),Ic((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),Oc((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),Rc((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),Pc((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),J(K(Pa,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}=ne(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return J(K(Ss,e),(n=>n.data&&((n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}})(n,"onFetch"))),()=>{n(`observeFile(tmpid: ${r}) > dispose`)}},e.observeFollowInfo=(e,t,n="cache_then_server")=>{const{log:r}=ne(),o=Date.now();r(`observeFollowInfo(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=[];return s.push(Jc((t=>((t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.userId)===e&&i(t,n)})({data:t,loading:!1,origin:"event"},"onUpdate")))),J(K(Dc,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observeFollowInfo(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeFollowers=(e,t)=>{const{log:n}=ne(),r=Date.now();n(`observeFollowers(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.from===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Vc((e=>i(e,"onRequested"))),Kc((e=>i(e,"onAccepted"))),Qc((e=>i(e,"onDeclined"))),Wc((e=>i(e,"onCanceled"))),zc((e=>i(e,"onFollowed"))),$c((e=>i(e,"onUnfollowed"))),Hc((e=>i(e,"onDeleted")))),()=>{n(`observeFollowers(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeFollowings=(e,t)=>{const{log:n}=ne(),r=Date.now();n(`observeFollowings(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.to===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Vc((e=>i(e,"onRequested"))),Kc((e=>i(e,"onAccepted"))),Qc((e=>i(e,"onDeclined"))),Wc((e=>i(e,"onCanceled"))),zc((e=>i(e,"onFollowed"))),$c((e=>i(e,"onUnfollowed"))),Hc((e=>i(e,"onDeleted")))),()=>{n(`observeFollowings(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=ne(),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(bc((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),wc((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&J(K(xs,e),(e=>e.data&&i(e,"onFetch")),Q(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=ne(),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(vc((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),bc((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),wc((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),()=>{n(`observeMessages(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observePoll=(e,t,n="cache_then_server")=>{const{log:r}=ne(),o=Date.now();r(`observePoll(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.pollId)===e&&i(t,n)},a=[];return a.push(Yc((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Gc((e=>s({data:e,loading:!1,origin:"event"},"onDelete")))),J(K(Xc,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observePoll(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePost=(e,t,n="cache_then_server")=>{const{log:r}=ne(),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(Va((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Wa((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Ka((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),Qa((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),Ja((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),Xa((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Ya((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),Ga((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),J(K(Ia,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=ne(),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(Ha((e=>i(e,"onCreate"))),Va((e=>i(e,"onUpdate"))),Wa((e=>i(e,"onDelete"))),Ka((e=>i(e,"onApproved"))),Qa((e=>i(e,"onDeclined"))),Ja((e=>i(e,"onFlagged"))),Xa((e=>i(e,"onUnflagged"))),Ya((e=>i(e,"onReactionAdded"))),Ga((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=ne(),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(ws((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),ms((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),Cs((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),_s((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),ks((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),J(K(gs,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=dc,e.onChannelJoined=pc,e.onChannelLeft=mc,e.onChannelMemberAdded=gc,e.onChannelMemberRemoved=yc,e.onChannelUpdated=fc,e.onClientBanned=fs,e.onClientDisconnected=e=>hs((({code:t})=>{800211===t&&e()})),e.onCommentCreated=ec,e.onCommentDeleted=nc,e.onCommentFlagged=rc,e.onCommentReactionAdded=ic,e.onCommentReactionRemoved=sc,e.onCommentUnflagged=oc,e.onCommentUpdated=tc,e.onCommunityCreated=e=>Cc("community.created",e),e.onCommunityDeleted=Ac,e.onCommunityJoined=Tc,e.onCommunityLeft=xc,e.onCommunityUpdated=Ec,e.onCommunityUserAdded=Ic,e.onCommunityUserBanned=Rc,e.onCommunityUserRemoved=Oc,e.onCommunityUserUnbanned=Pc,e.onConnectionError=hs,e.onFollowInfoUpdated=Jc,e.onFollowRequestAccepted=Kc,e.onFollowRequestCanceled=Wc,e.onFollowRequestDeclined=Qc,e.onFollowerDeleted=Hc,e.onFollowerRequested=Vc,e.onMessageCreated=vc,e.onMessageDeleted=wc,e.onMessageUpdated=bc,e.onPollDeleted=Gc,e.onPollUpdated=Yc,e.onPostApproved=Ka,e.onPostCreated=Ha,e.onPostDeclined=Qa,e.onPostDeleted=Wa,e.onPostFlagged=Ja,e.onPostReactionAdded=Ya,e.onPostReactionRemoved=Ga,e.onPostUnflagged=Xa,e.onPostUpdated=Va,e.onReactionRemoved=(e,t,n)=>{const r=r=>{U(e)(r)===t&&n(r)};if("message"===e){const e=ne(),t=e=>{var t;const n=De(["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;ds(e),o&&r(e.messages[0])};return le(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?Ga(r):sc(r)},e.onStreamRecorded=e=>{const t=ne();return le(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{ds(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=ne();return le(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{ds(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=ne();return le(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{ds(t),e(t.videoStreamings[0])}))},e.onUserDeleted=ms,e.onUserFlagCleared=ks,e.onUserFlagged=Cs,e.onUserFollowed=zc,e.onUserUnflagged=_s,e.onUserUnfollowed=$c,e.onUserUpdated=ws,e.pullFromCache=De,e.pushToCache=qe,e.queryCache=Le,e.queryCategories=Bc,e.queryChannelMembers=hc,e.queryChannels=cc,e.queryComments=ja,e.queryCommunities=Oa,e.queryCommunityMembers=Ba,e.queryFollowers=Mc,e.queryFollowings=Uc,e.queryGlobalFeed=Fc,e.queryMessages=Os,e.queryOptions=Q,e.queryPosts=Ta,e.queryReactions=async e=>{const t=ne();t.log("reaction/queryReactions",e);const n=null!=e?e:{},{page:r={limit:10}}=n,o=vs(n,["page"]),{data:i}=await t.http.get("/api/v2/reactions",{params:Object.assign(Object.assign({},o),{options:{token:N(r,"skiplimit")}})}),{paging:s,results:a}=i,{reactions:c}=a,l=F(s.next);return{data:c,prevPage:F(s.previous),nextPage:l}},e.queryRoles=Es,e.queryStreams=el,e.queryUsers=bs,e.removeChannelMembers=async(e,t)=>{const n=ne();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&&ds(r),ue("v3.channel.didRemoveUsers",{channels:r.channels,channelUsers:r.channelUsers});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=ne();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&&ds(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=ne();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&&ds(r),ue("community.userRemoved",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRoles=async(e,t,n)=>{const r=ne();r.log("community/removeCommunityMembersRoles",e,t,n);const{data:o}=await r.http.delete(`/api/v4/communities/${e}/users/roles`,{data:{communityId:e,roles:t,userIds:n}});r.cache&&ds(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!t.some((e=>n.roles.includes(e)))))},e.removeReaction=za,e.restoreCache=async(e="amitySdk")=>{var t;const n=ne();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await Fe.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=J,e.sortByChannelSegment=({channelSegment:e},{channelSegment:t})=>e-t,e.sortByDisplayName=({displayName:e},{displayName:t})=>e===t?0:e<t?-1:1,e.sortByFirstCreated=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),e.sortByLastActivity=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortByLastCreated=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortBySegmentNumber=({segmentNumber:e},{segmentNumber:t})=>e-t,e.subscribeTopic=ve,e.toPage=F,e.toPageRaw=j,e.toToken=N,e.unfollow=async e=>{const t=ne();t.log("follow/unfollow",e);const{data:n}=await t.http.delete(`/api/v4/me/following/${e}`);return t.cache&&ds(n),ue("follow.unfollowed",n.follows[0]),!0},e.updateChannel=async(e,t)=>{const n=ne();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&&ds(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=ne();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&&ds(r,{cachedAt:o}),ue("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=ne();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&&ds(r,{cachedAt:o}),ue("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=Ea,e.updatePost=async(e,t)=>{const n=ne();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&&ds(r,{cachedAt:o}),ue("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=ne();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&&ds(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=ne();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&&ds(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=$e,e.votePoll=async(e,t)=>{const n=ne();n.log("user/votePoll",e);const{data:r}=await n.http.post(`/api/v3/polls/${encodeURIComponent(e)}/votes`,{pollId:e,answerIds:t}),o=n.cache&&Date.now();n.cache&&ds(r,{cachedAt:o});const{polls:i}=r;return ue("poll.updated",r),{data:i.find((t=>t.pollId===e)),cachedAt:o}},e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=ne();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await Fe.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
6
+ var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(i(r,n),n.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:17}],74:[function(e,t,n){function r(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(o(t)):null}function o(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}t.exports=r},{}],75:[function(e,t,n){var r=e("safe-buffer").Buffer,o=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function s(e){var t=i(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=s(e),this.encoding){case"utf16le":this.text=p,this.end=m,t=4;break;case"utf8":this.fillLast=h,t=4;break;case"base64":this.text=g,this.end=y,t=3;break;default:return this.write=v,void(this.end=b)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function c(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function l(e,t,n){var r=t.length-1;if(r<n)return 0;var o=c(t[r]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}function u(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}function h(e){var t=this.lastTotal-this.lastNeed,n=u(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function f(e,t){var n=l(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function p(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function g(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function y(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function v(e){return e.toString(this.encoding)}function b(e){return e&&e.length?this.write(e):""}n.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},a.prototype.end=d,a.prototype.text=f,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":73}],76:[function(e,t,n){var r=e("punycode"),o=e("./util");function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}n.parse=w,n.resolve=_,n.resolveObject=k,n.format=C,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(l),h=["%","/","?",";","#"].concat(u),f=["/","?","#"],d=255,p=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=e("querystring");function w(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}function C(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function _(e,t){return w(e,!1,!0).resolve(t)}function k(e,t){return e?w(e,!1,!0).resolveObject(t):t}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",l=e.split(a),w=/\\/g;l[0]=l[0].replace(w,"/");var C=e=l.join(a);if(C=C.trim(),!n&&1===e.split("#").length){var _=c.exec(C);if(_)return this.path=C,this.href=C,this.pathname=_[1],_[2]?(this.search=_[2],this.query=t?b.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var k=s.exec(C);if(k){var S=(k=k[0]).toLowerCase();this.protocol=S,C=C.substr(k.length)}if(n||k||C.match(/^\/\/[^@\/]+@[^@\/]+/)){var A="//"===C.substr(0,2);!A||k&&y[k]||(C=C.substr(2),this.slashes=!0)}if(!y[k]&&(A||k&&!v[k])){for(var E,T,I=-1,x=0;x<f.length;x++)-1!==(O=C.indexOf(f[x]))&&(-1===I||O<I)&&(I=O);for(-1!==(T=-1===I?C.lastIndexOf("@"):C.lastIndexOf("@",I))&&(E=C.slice(0,T),C=C.slice(T+1),this.auth=decodeURIComponent(E)),I=-1,x=0;x<h.length;x++){var O;-1!==(O=C.indexOf(h[x]))&&(-1===I||O<I)&&(I=O)}-1===I&&(I=C.length),this.host=C.slice(0,I),C=C.slice(I),this.parseHost(),this.hostname=this.hostname||"";var R="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!R)for(var P=this.hostname.split(/\./),B=(x=0,P.length);x<B;x++){var N=P[x];if(N&&!N.match(p)){for(var j="",F=0,M=N.length;F<M;F++)N.charCodeAt(F)>127?j+="x":j+=N[F];if(!j.match(p)){var U=P.slice(0,x),D=P.slice(x+1),L=N.match(m);L&&(U.push(L[1]),D.unshift(L[2])),D.length&&(C="/"+D.join(".")+C),this.hostname=U.join(".");break}}}this.hostname.length>d?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",z=this.hostname||"";this.host=z+q,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==C[0]&&(C="/"+C))}if(!g[S])for(x=0,B=u.length;x<B;x++){var $=u[x];if(-1!==C.indexOf($)){var H=encodeURIComponent($);H===$&&(H=escape($)),C=C.split($).join(H)}}var V=C.indexOf("#");-1!==V&&(this.hash=C.substr(V),C=C.slice(0,V));var W=C.indexOf("?");if(-1!==W?(this.search=C.substr(W),this.query=C.substr(W+1),t&&(this.query=b.parse(this.query)),C=C.slice(0,W)):t&&(this.search="",this.query={}),C&&(this.pathname=C),v[S]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var K=this.search||"";this.path=q+K}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=b.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||v[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(w(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),l=0;l<c.length;l++){var u=c[l];"protocol"!==u&&(n[u]=e[u])}return v[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!v[e.protocol]){for(var h=Object.keys(e),f=0;f<h.length;f++){var d=h[f];n[d]=e[d]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var p=(e.pathname||"").split("/");p.length&&!(e.host=p.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),n.pathname=p.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",g=n.search||"";n.path=m+g}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var b=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),C=w||b||n.host&&e.pathname,_=C,k=n.pathname&&n.pathname.split("/")||[],S=(p=e.pathname&&e.pathname.split("/")||[],n.protocol&&!v[n.protocol]);if(S&&(n.hostname="",n.port=null,n.host&&(""===k[0]?k[0]=n.host:k.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===p[0]?p[0]=e.host:p.unshift(e.host)),e.host=null),C=C&&(""===p[0]||""===k[0])),w)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,k=p;else if(p.length)k||(k=[]),k.pop(),k=k.concat(p),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return S&&(n.hostname=n.host=k.shift(),(x=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=x.shift(),n.host=n.hostname=x.shift())),n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var A=k.slice(-1)[0],E=(n.host||e.host||k.length>1)&&("."===A||".."===A)||""===A,T=0,I=k.length;I>=0;I--)"."===(A=k[I])?k.splice(I,1):".."===A?(k.splice(I,1),T++):T&&(k.splice(I,1),T--);if(!C&&!_)for(;T--;T)k.unshift("..");!C||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),E&&"/"!==k.join("/").substr(-1)&&k.push("");var x,O=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(n.hostname=n.host=O?"":k.length?k.shift():"",(x=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=x.shift(),n.host=n.hostname=x.shift())),(C=C||n.host&&k.length)&&!O&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":77,punycode:51,querystring:54}],77:[function(e,t,n){t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],78:[function(e,t,n){(function(e){(function(){function n(e,t){if(r("noDeprecation"))return e;var n=!1;function o(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return o}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this)}).call(this,void 0!==_e?_e:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(e,t,n){function r(e,t){if(e&&t)return r(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach((function(e){r[e]=o[e]})),r}}t.exports=r},{}],80:[function(e,t,n){t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(e,t,n){t.exports=o;var r=Object.prototype.hasOwnProperty;function o(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e}},{}],82:[function(e,t,n){t.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},{}],83:[function(e,t,n){function r(e){var t=this;if(t instanceof r||(t=new r),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var n=0,o=arguments.length;n<o;n++)t.push(arguments[n]);return t}function o(e,t,n){var r=t===e.head?new a(n,null,t,e):new a(n,t,t.next,e);return null===r.next&&(e.tail=r),null===r.prev&&(e.head=r),e.length++,r}function i(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function s(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,n,r){if(!(this instanceof a))return new a(e,t,n,r);this.list=r,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,n?(n.prev=this,this.next=n):this.next=null}t.exports=r,r.Node=a,r.create=r,r.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,n=e.prev;return t&&(t.prev=n),n&&(n.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=n),e.list.length--,e.next=null,e.prev=null,e.list=null,t},r.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},r.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},r.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)i(this,arguments[e]);return this.length},r.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},r.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},r.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},r.prototype.forEach=function(e,t){t=t||this;for(var n=this.head,r=0;null!==n;r++)e.call(t,n.value,r,this),n=n.next},r.prototype.forEachReverse=function(e,t){t=t||this;for(var n=this.tail,r=this.length-1;null!==n;r--)e.call(t,n.value,r,this),n=n.prev},r.prototype.get=function(e){for(var t=0,n=this.head;null!==n&&t<e;t++)n=n.next;if(t===e&&null!==n)return n.value},r.prototype.getReverse=function(e){for(var t=0,n=this.tail;null!==n&&t<e;t++)n=n.prev;if(t===e&&null!==n)return n.value},r.prototype.map=function(e,t){t=t||this;for(var n=new r,o=this.head;null!==o;)n.push(e.call(t,o.value,this)),o=o.next;return n},r.prototype.mapReverse=function(e,t){t=t||this;for(var n=new r,o=this.tail;null!==o;)n.push(e.call(t,o.value,this)),o=o.prev;return n},r.prototype.reduce=function(e,t){var n,r=this.head;if(arguments.length>1)n=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,n=this.head.value}for(var o=0;null!==r;o++)n=e(n,r.value,o),r=r.next;return n},r.prototype.reduceReverse=function(e,t){var n,r=this.tail;if(arguments.length>1)n=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,n=this.tail.value}for(var o=this.length-1;null!==r;o--)n=e(n,r.value,o),r=r.prev;return n},r.prototype.toArray=function(){for(var e=new Array(this.length),t=0,n=this.head;null!==n;t++)e[t]=n.value,n=n.next;return e},r.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,n=this.tail;null!==n;t++)e[t]=n.value,n=n.prev;return e},r.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new r;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=0,i=this.head;null!==i&&o<e;o++)i=i.next;for(;null!==i&&o<t;o++,i=i.next)n.push(i.value);return n},r.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var n=new r;if(t<e||t<0)return n;e<0&&(e=0),t>this.length&&(t=this.length);for(var o=this.length,i=this.tail;null!==i&&o>t;o--)i=i.prev;for(;null!==i&&o>e;o--,i=i.prev)n.push(i.value);return n},r.prototype.splice=function(e,t,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var r=0,i=this.head;null!==i&&r<e;r++)i=i.next;var s=[];for(r=0;i&&r<t;r++)s.push(i.value),i=this.removeNode(i);for(null===i&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev),r=0;r<n.length;r++)i=o(this,i,n[r]);return s},r.prototype.reverse=function(){for(var e=this.head,t=this.tail,n=e;null!==n;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r}return this.head=t,this.tail=e,this};try{e("./iterator.js")(r)}catch(e){}},{"./iterator.js":82}]},{},[12])(12)}(ss);var as=ke(ss.exports);var cs;!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"}(cs||(cs={}));const ls=e=>{let t,n=0,r=!0;return{connect:async function(o){return t&&(t.removeAllListeners(),t.end(!0)),t=as.connect(e,function(e){return Object.assign({clean:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:0,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1}},e)}({username:o.userId,password:o.accessToken})),t.on("connect",(()=>{n=0,r=!0})),t.on("error",(e=>{switch(e.code){case 2:case 4:case 5:r=!1}})),t.on("close",(()=>{r&&setTimeout((()=>{n+=1,t.reconnect()}),1e3*2**(n>10?10:n))})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(r=!1,this.connected)return new Promise((e=>null==t?void 0:t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,n){null==t||t.on(e,n)},once(e,n){null==t||t.once(e,n)},off(e,n){void 0!==n?null==t||t.off(e,n):null==t||t.removeAllListeners(e)},removeAllListeners(){null==t||t.removeAllListeners()},subscribe(e,n){const r=(t,r)=>{if(t||128===r[0].qos){const r=t?new ee(t.message,8e5,"error"):new ne(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)}}},us=async()=>{const e=ie();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},hs=()=>`ascWebSdk#${Math.random().toString(16)}`,fs=()=>{const e=(()=>{var e,t;return(null===(e=r.versions)||void 0===e?void 0:e.node)?r.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}},ds=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],ps=e=>{const t=ie(),n=ds.map((n=>fe(t,`client/onConnectionError(${n})`,n,(t=>{const r=(null==t?void 0:t.code)?new ee(t.message,t.code,"fatal"):new re(n);e(r)}))));return()=>{n.forEach((e=>e()))}},ms=e=>ps((({code:t})=>{400312===t&&e()})),gs=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=q[e];if(!r)return;const o=U(r);n.forEach((e=>{We([r,"get",o(e)],e,t)}))}))},ys=(e,t)=>{const n=ie();return fe(n,e,e,(e=>{n.cache&&gs(e),t(e.users[0])}))},vs=e=>ys("user.deleted",e),bs=async e=>{const t=ie();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};bs.locally=e=>{const t=ie();return t.log("user/getUser.locally",e),t.cache&&$e(["user","get",e])};const ws=async e=>{const t=ie();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&&gs(r,{cachedAt:o}),{data:r.users,cachedAt:o}};function Cs(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}ws.locally=e=>{var t;const n=ie();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>$e(["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 _s=async(e={})=>{const t=ie();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=Cs(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:N(n,"skiplimit")}})}),{paging:c}=a,l=Cs(a,["paging"]),{users:u}=l,h=t.cache&&Date.now();if(t.cache){gs(l,{cachedAt:h});He(["user","query",e],{users:u.map(U("user")),paging:c})}return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:j(c.next)}};_s.locally=(e={})=>{var t,n,r;const o=ie();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=$e(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>$e(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],l=j(null==s?void 0:s.paging.previous),u=j(null==s?void 0:s.paging.next);return c.length>0&&c.length===(null===(r=null==s?void 0:s.users)||void 0===r?void 0:r.length)?{data:c,cachedAt:a,prevPage:l,nextPage:u}:void 0};const ks=e=>ys("user.updated",e),Ss=e=>ys("user.flagged",e),As=e=>ys("user.unflagged",e),Es=e=>ys("user.flagCleared",e),Ts=async e=>{const t=ie();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&gs({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};Ts.locally=e=>{const t=ie();if(t.log("file/getFile.locally",e),!t.cache)return;const n=$e(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Is=async e=>{const t=ie();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=Cs(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:N(r,"skiplimit")}})}),{paging:c}=a,l=Cs(a,["paging"]),{roles:u}=l,h=t.cache&&Date.now();t.cache&&gs(l,{cachedAt:h});const f=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:f}};Is.locally=e=>{ie().log("role/queryRoles.locally",e)};const xs=async e=>{const t=ie();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&gs({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};xs.locally=e=>{const t=ie();if(t.log("role/getRole.locally",e),!t.cache)return;const n=$e(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Os=(e,t)=>{"message"===e?de("v3.message.didUpdate",{messages:[t]}):"post"===e?de("post.updated",{posts:[t]}):"comment"===e&&de("comment.updated",{comments:[t]})},Rs=async e=>{const t=ie();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};Rs.locally=e=>{const t=ie();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=$e(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ps=async e=>{const t=ie();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&&gs(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};Ps.locally=e=>{var t;const n=ie();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>$e(["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 Bs=async e=>{const t=ie();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=Cs(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:N(n,"afterbefore")}})}),{paging:i}=o,s=Cs(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){gs(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];He(e,{messages:a.map(U("message")),paging:i})}const l=j(i.next);return{data:a,cachedAt:c,prevPage:j(i.previous),nextPage:l}};Bs.locally=e=>{var t,n;const r=ie();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Cs(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=$e(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const l=a.messages.map((e=>$e(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};var Ns={},js={},Fs={};Object.defineProperty(Fs,"__esModule",{value:!0}),Fs.bytesToString=Fs.stringToBytes=Fs.NIL=Fs.X500=Fs.OID=Fs.URL=Fs.DNS=Fs.hexToByte=Fs.byteToHex=void 0;let Ms=[],Us={};for(var Ds=0;Ds<256;Ds++)Ms[Ds]=(Ds+256).toString(16).substr(1),Us[Ms[Ds]]=Ds;Fs.byteToHex=Ms,Fs.hexToByte=Us,Fs.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Fs.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",Fs.OID="6ba7b812-9dad-11d1-80b4-00c04fd430c8",Fs.X500="6ba7b814-9dad-11d1-80b4-00c04fd430c8",Fs.NIL="00000000-0000-0000-0000-000000000000";Fs.stringToBytes=e=>{e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t};Fs.bytesToString=e=>{const t=new Uint8Array(e,0,e.byteLength);return String.fromCharCode.apply(null,Array.from(t))},Object.defineProperty(js,"__esModule",{value:!0}),js.parse=void 0;const Ls=Fs;js.parse=(e,t,n)=>{let r=t&&n||0,o=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,(e=>(o<16&&t&&(t[r+o++]=Ls.hexToByte[e]),"")));o<16;)t[r+o++]=0;return t};var qs={};Object.defineProperty(qs,"__esModule",{value:!0}),qs.unparse=void 0;const zs=Fs;qs.unparse=(e,t)=>{let n=t||0,r=zs.byteToHex;return r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+"-"+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]+r[e[n++]]};var $s={},Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});Hs.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;var Vs=_e&&_e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($s,"__esModule",{value:!0}),$s.validate=void 0;const Ws=Vs(Hs);$s.validate=e=>"string"==typeof e&&Ws.default.test(e);var Ks={};Object.defineProperty(Ks,"__esModule",{value:!0}),Ks.version=void 0;const Qs=$s;Ks.version=e=>{if(!Qs.validate(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};var Js={},Xs={};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.stringify=void 0;const Ys=$s,Gs=[];for(let e=0;e<256;++e)Gs.push((e+256).toString(16).substr(1));Xs.stringify=(e,t=0)=>{const n=(Gs[e[t+0]]+Gs[e[t+1]]+Gs[e[t+2]]+Gs[e[t+3]]+"-"+Gs[e[t+4]]+Gs[e[t+5]]+"-"+Gs[e[t+6]]+Gs[e[t+7]]+"-"+Gs[e[t+8]]+Gs[e[t+9]]+"-"+Gs[e[t+10]]+Gs[e[t+11]]+Gs[e[t+12]]+Gs[e[t+13]]+Gs[e[t+14]]+Gs[e[t+15]]).toLowerCase();if(!Ys.validate(n))throw TypeError("Stringified UUID is invalid");return n};var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.rng=void 0;Zs.rng=()=>{let e=new Array(16);for(let t=0;t<16;t++)e[t]=255&256*Math.random()+0;return e},Object.defineProperty(Js,"__esModule",{value:!0}),Js.v1=void 0;const ea=Xs,ta=Zs;let na,ra,oa=0,ia=0;Js.v1=(e,t,n=0)=>{let r=t&&n||0;const o=t||new Uint8Array(16);let i=e&&e.node?e.node:na,s=e&&e.clockseq?e.clockseq:ra;if(null==i||null==s){const t=e&&e.random?e.random:e&&e.rng?e.rng():ta.rng();null==i&&(i=na=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==s&&(s=ra=16383&(t[6]<<8|t[7]))}let a=e&&e.msecs?e.msecs:Date.now(),c=e&&e.nsecs?e.nsecs:ia+1;const l=a-oa+(c-ia)/1e4;if(l<0&&e&&!e.clockseq&&(s=s+1&16383),(l<0||a>oa)&&e&&!e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");oa=a,ia=c,ra=s,a+=122192928e5;const u=(1e4*(268435455&a)+c)%4294967296;o[r++]=u>>>24&255,o[r++]=u>>>16&255,o[r++]=u>>>8&255,o[r++]=255&u;const h=a/4294967296*1e4&268435455;o[r++]=h>>>8&255,o[r++]=255&h,o[r++]=h>>>24&15|16,o[r++]=h>>>16&255,o[r++]=s>>>8|128,o[r++]=255&s;for(let e=0;e<6;++e)o[r+e]=i[e];return t||ea.stringify(o)};var sa={};Object.defineProperty(sa,"__esModule",{value:!0}),sa.v4=void 0;const aa=qs,ca=Zs;sa.v4=(e,t,n)=>{let r=t&&n||0,o=ca.rng();if(!e||e instanceof String||(e.random&&(o=e.random),e.rng&&(o=e.rng())),o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var i=0;i<16;i++)t[r+i]=o[i];return t||aa.unparse(o)};var la={},ua={};Object.defineProperty(ua,"__esModule",{value:!0}),ua.v35=void 0;const ha=Xs,fa=js,da=Fs;ua.v35=(e,t,n)=>(e,r,o,i=0)=>{if("string"==typeof e&&(e=da.stringToBytes(e)),"string"==typeof r&&(r=fa.parse(r)),r&&16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let s=new Uint8Array(16+e.length);if(s.set(r),s.set(e,r.length),s=da.stringToBytes(n(da.bytesToString(s))),s[6]=15&s[6]|t,s[8]=63&s[8]|128,o)for(let e=0;e<16;++e)o[i+e]=s[e];return o||ha.stringify(s)};var pa={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.any_hmac_sha1=e.b64_hmac_sha1=e.hex_hmac_sha1=e.any_sha1=e.b64_sha1=e.hex_sha1=void 0;let t=0,n="";e.hex_sha1=e=>i(r(c(e))),e.default=e.hex_sha1;e.b64_sha1=e=>s(r(c(e)));e.any_sha1=(e,t)=>a(r(c(e)),t);e.hex_hmac_sha1=(e,t)=>i(o(c(e),c(t)));e.b64_hmac_sha1=(e,t)=>s(o(c(e),c(t)));e.any_hmac_sha1=(e,t,n)=>a(o(c(e),c(t)),n);const r=e=>u(h(l(e),8*e.length)),o=(e,t)=>{let n=l(e);n.length>16&&(n=h(n,8*e.length));let r=Array(16),o=Array(16);for(var i=0;i<16;i++)r[i]=909522486^n[i],o[i]=1549556828^n[i];var s=h(r.concat(l(t)),512+8*t.length);return u(h(o.concat(s),672))},i=e=>{for(var n,r=t?"0123456789ABCDEF":"0123456789abcdef",o="",i=0;i<e.length;i++)n=e.charCodeAt(i),o+=r.charAt(n>>>4&15)+r.charAt(15&n);return o},s=e=>{for(var t="",r=e.length,o=0;o<r;o+=3)for(var i=e.charCodeAt(o)<<16|(o+1<r?e.charCodeAt(o+1)<<8:0)|(o+2<r?e.charCodeAt(o+2):0),s=0;s<4;s++)8*o+6*s>8*e.length?t+=n:t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>>6*(3-s)&63);return t},a=(e,t)=>{var n,r,o,i,s=t.length,a=[],c=Array(Math.ceil(e.length/2));for(n=0;n<c.length;n++)c[n]=e.charCodeAt(2*n)<<8|e.charCodeAt(2*n+1);for(;c.length>0;){for(i=[],o=0,n=0;n<c.length;n++)o=(o<<16)+c[n],o-=(r=Math.floor(o/s))*s,(i.length>0||r>0)&&(i[i.length]=r);a[a.length]=o,c=i}var l="";for(n=a.length-1;n>=0;n--)l+=t.charAt(a[n]);var u=Math.ceil(8*e.length/(Math.log(t.length)/Math.log(2)));for(n=l.length;n<u;n++)l=t[0]+l;return l},c=e=>{for(var t,n,r="",o=-1;++o<e.length;)t=e.charCodeAt(o),n=o+1<e.length?e.charCodeAt(o+1):0,t>=55296&&t<=56319&&n>=56320&&n<=57343&&(t=65536+((1023&t)<<10)+(1023&n),o++),t<=127?r+=String.fromCharCode(t):t<=2047?r+=String.fromCharCode(192|t>>>6&31,128|63&t):t<=65535?r+=String.fromCharCode(224|t>>>12&15,128|t>>>6&63,128|63&t):t<=2097151&&(r+=String.fromCharCode(240|t>>>18&7,128|t>>>12&63,128|t>>>6&63,128|63&t));return r},l=e=>{for(var t=Array(e.length>>2),n=0;n<t.length;n++)t[n]=0;for(n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t},u=e=>{for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t},h=(e,t)=>{e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n=Array(80),r=1732584193,o=-271733879,i=-1732584194,s=271733878,a=-1009589776,c=0;c<e.length;c+=16){for(var l=r,u=o,h=i,g=s,y=a,v=0;v<80;v++){n[v]=v<16?e[c+v]:m(n[v-3]^n[v-8]^n[v-14]^n[v-16],1);let t=p(p(m(r,5),f(v,o,i,s)),p(p(a,n[v]),d(v)));a=s,s=i,i=m(o,30),o=r,r=t}r=p(r,l),o=p(o,u),i=p(i,h),s=p(s,g),a=p(a,y)}return[r,o,i,s,a]},f=(e,t,n,r)=>e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r,d=e=>e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514,p=(e,t)=>{var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},m=(e,t)=>e<<t|e>>>32-t}(pa);var ma=_e&&_e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(la,"__esModule",{value:!0}),la.v5=void 0;const ga=ua,ya=ma(pa);la.v5=ga.v35("v5",80,ya.default),Object.defineProperty(Ns,"__esModule",{value:!0});const va=js,ba=qs,wa=$s,Ca=Ks,_a=Js,ka=sa,Sa=la,Aa=Fs;var Ea=Ns.default={parse:va.parse,unparse:ba.unparse,validate:wa.validate,version:Ca.version,v1:_a.v1,v4:ka.v4,v5:Sa.v5,NIL:Aa.NIL,DNS:Aa.DNS,URL:Aa.URL,OID:Aa.OID,X500:Aa.X500};const Ta=async e=>{const t=ie();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};Ta.optimistically=e=>{var t,n;const r=ie();if(!r.cache)return;const o=Object.assign({messageId:Ea.v4().toString()},e);r.log("user/createMessage.locally",o);const i=$e(["channel","get",o.channelId]);We(["channel","get",o.channelId],Object.assign(Object.assign({},null==i?void 0:i.data),{messageCount:(null!==(t=null==i?void 0:i.data.messageCount)&&void 0!==t?t:0)+1}));const s=(new Date).toISOString(),a=Object.assign({userId:r.userId,channelSegment:(null!==(n=null==i?void 0:i.data.messageCount)&&void 0!==n?n:0)+1,createdAt:s,updatedAt:s},o);return He(["message","get",a.messageId],a,{cachedAt:-1}),de("v3.message.didCreate",{messages:[a]}),{data:a,cachedAt:-1}};const Ia=async(e,t)=>{const n=ie();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&&gs(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};Ia.optimistically=(e,t)=>{const n=ie();if(n.log("user/updateMessage",t),!n.cache)return;const r=$e(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return We(["message","get",e],o,{cachedAt:-1}),de("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const xa=async e=>{const t=ie();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${encodeURIComponent(e)}`);return(await Rs(e)).data};xa.optimistically=e=>{ie().log("message/deleteMessage",e);const t=$e(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return We(["message","get",e],n,{cachedAt:-1}),de("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const Oa=async e=>{const t=ie();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=Cs(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:N(n,"afterbeforeraw")}})}),{paging:i}=o,s=Cs(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){gs(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];He(e,{posts:a.map(U("post")),paging:i})}const l=F(i.next);return{data:a,cachedAt:c,prevPage:F(i.previous),nextPage:l}};Oa.locally=e=>{var t,n;const r=ie();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Cs(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=$e(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const l=a.posts.map((e=>$e(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),u=F(null==a?void 0:a.paging.previous),h=F(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const Ra=async e=>{const t=ie();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&&gs(r,{cachedAt:o}),{data:r.posts,cachedAt:o}};Ra.locally=e=>{var t;const n=ie();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>$e(["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 Pa=async e=>{const t=ie();let n;t.log("post/getPost",e);try{n=(await t.http.get(`/api/v3/posts/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&Ke(["post","get",e],!0),t}const r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{posts:o}=n;return{data:o.find((t=>t.postId===e)),cachedAt:r}};Pa.locally=e=>{const t=ie();if(t.log("post/getPost.locally",e),!t.cache)return;const n=$e(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ba=async e=>{const t=ie();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=Cs(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:N(r,"skiplimit")}})}),{paging:c}=a,l=Cs(a,["paging"]),{communities:u}=l,h=t.cache&&Date.now();if(t.cache){gs(l,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];He(e,{communities:u.map(U("community")),paging:c})}const f=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:f}};Ba.locally=e=>{ie().log("community/queryCommunities.locally",e)};const Na=async e=>{const t=ie();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&&gs(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};Na.locally=e=>{var t;const n=ie();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>$e(["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 ja=async e=>{const t=ie();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};ja.locally=e=>{const t=ie();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=$e(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Fa=async e=>{const t=ie();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=Cs(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:N(r,"skiplimit")}})}),{paging:a}=s,c=Cs(s,["paging"]),{communityUsers:l}=c,u=t.cache&&Date.now();t.cache&&gs(c,{cachedAt:u});return{data:l,cachedAt:u,nextPage:j(a.next),prevPage:j(a.previous)}};Fa.locally=e=>{ie().log("community/queryCommunityMembers",e)};const Ma=async e=>{const t=ie();t.log("channel/getTopTrendingCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/top-trending",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){gs(r,{cachedAt:i});He(["community","top-trending",{params:{options:{limit:n}}}],{communities:o.map(U("community"))})}return{data:o,cachedAt:i}};Ma.locally=e=>{var t,n;const r=ie();if(r.log("community/getTopTrendingCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","top-trending",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=$e(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>$e(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const Ua=async e=>{const t=ie();t.log("channel/getRecommendedCommunities",e);const{limit:n=5}=null!=e?e:{},{data:r}=await t.http.get("/api/v3/communities/recommended",{params:{options:{limit:n}}}),{communities:o}=r,i=t.cache&&Date.now();if(t.cache){gs(r,{cachedAt:i});He(["community","recommended",{params:{options:{limit:n}}}],{communities:o.map(U("community"))})}return{data:o,cachedAt:i}};Ua.locally=e=>{var t,n;const r=ie();if(r.log("community/getRecommendedCommunities.locally",e),!r.cache)return;const{limit:o=5}=null!=e?e:{},i=["community","recommended",{params:{options:{limit:o}}}],{data:s,cachedAt:a}=null!==(t=$e(i))&&void 0!==t?t:{};if(!(null==s?void 0:s.communities.length))return;const c=s.communities.map((e=>$e(["community","get",e]))).filter(Boolean).map((({data:e})=>e));return c.length===(null===(n=null==s?void 0:s.communities)||void 0===n?void 0:n.length)?{data:c,cachedAt:a}:void 0};const Da=async e=>{const t=ie();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=Cs(e,["page"]),o={type:r.sortBy?"pagination":void 0,token:N(n,r.sortBy?"skiplimit":"afterbefore")},{data:i}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:o})}),{paging:s}=i,a=Cs(i,["paging"]),{comments:c}=a,l=t.cache&&Date.now();if(t.cache){gs(a,{cachedAt:l});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];He(e,{comments:c.map(U("comment")),paging:s})}const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};Da.locally=e=>{var t,n;const r=ie();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Cs(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=$e(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const l=a.comments.map((e=>$e(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),u=j(null==a?void 0:a.paging.previous),h=j(null==a?void 0:a.paging.next);return l.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:l,cachedAt:c,prevPage:u,nextPage:h}:void 0};const La=async e=>{const t=ie();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&&gs(r,{cachedAt:o}),{data:r.comments,cachedAt:o}};La.locally=e=>{var t;const n=ie();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>$e(["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 qa=async e=>{const t=ie();let n;t.log("comment/getComment",e);try{n=(await t.http.get(`/api/v3/comments/${encodeURIComponent(e)}`)).data}catch(t){throw 400400===(null==t?void 0:t.code)&&Ke(["comment","get",e],!0),t}const r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{comments:o}=n;return{data:o.find((t=>t.commentId===e)),cachedAt:r}};qa.locally=e=>{const t=ie();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=$e(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const za=async(e,t)=>{if("message"===e)return Rs(t);if("post"===e)return Pa(t);if("comment"===e)return qa(t);throw new Error(`Incorrect referenceType: ${e}`)},$a=(e,t)=>{var n,r;if(ie().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=$e(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=$e(["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))})}},Ha=async(e,t,n)=>{var r,o;const i=ie();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 za(e,t);return Os(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};Ha.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=ie();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=$e([e,"get",t]);if(!(null==l?void 0:l.data)||(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:l.data.reactionsCount+1,myReactions:[...null!==(o=l.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)+1})});return We([e,"get",t],u,{cachedAt:-1}),Os(e,u),null!==(a=null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const Va=async(e,t,n)=>{var r,o;const i=ie();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 za(e,t);return Os(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};Va.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=ie();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const l=$e([e,"get",t]);if(!(null==l?void 0:l.data)||!(null===(r=l.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const u=Object.assign(Object.assign({},l.data),{reactionsCount:Math.max(0,l.data.reactionsCount-1),myReactions:(null!==(o=l.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},l.data.reactions),{[n]:Math.max(0,(null!==(i=l.data.reactions[n])&&void 0!==i?i:0)-1)})});return We([e,"get",t],u,{cachedAt:-1}),Os(e,u),null!==(a=!(null===(s=null==u?void 0:u.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};const Wa=async e=>{const t=ie();t.log("reaction/queryReactions",e);const n=null!=e?e:{},{page:r={limit:10}}=n,o=Cs(n,["page"]),{data:i}=await t.http.get("/api/v3/reactions",{params:Object.assign(Object.assign({},o),{options:{token:N(r,"afterbeforeraw")}})}),{paging:s}=i,a=Cs(i,["paging"]),{reactions:c}=a;gs(Object.assign(Object.assign({},a),{reactions:c[0].reactors}));const l=F(s.next);return{data:c,prevPage:F(s.previous),nextPage:l}},Ka=(e,t)=>{const n=ie();return fe(n,e,e,(r=>{var o;if(n.cache){const{communities:n}=r,i=Cs(r,["communities"]);gs(i),(null==n?void 0:n[0])&&!["post.updated"].includes(e)&&de("community.updated",{communities:n});const s=$e(["post","get",r.posts[0].postId]);if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=ze(["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})=>We(e,t,{cachedAt:-1})))}t(s.data)}else t(r.posts[0])}))},Qa=e=>Ka("post.created",e),Ja=e=>Ka("post.updated",e),Xa=e=>Ka("post.deleted",e),Ya=e=>Ka("post.approved",e),Ga=e=>Ka("post.declined",e),Za=e=>Ka("post.flagged",e),ec=e=>Ka("post.unflagged",e),tc=e=>{const t=ie();return fe(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){$a("post.addReaction",n);const t=Cs(n,["reactor"]);gs(t);const r=$e(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},nc=e=>{const t=ie();return fe(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){$a("post.removeReaction",n);const t=Cs(n,["reactor"]);gs(t);const r=$e(["post","get",n.posts[0].postId]);e(r.data)}else e(n.posts[0])}))},rc=(e,t)=>{const n=ie();return fe(n,e,e,(r=>{var o;if(n.cache){gs(r);const n=$e(["comment","get",r.comments[0].commentId]);if(["comment.created"].includes(e)){const e=null===(o=ze(["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})=>We(e,t,{cachedAt:-1})))}t(n.data)}else t(r.comments[0])}))},oc=e=>rc("comment.created",e),ic=e=>rc("comment.updated",e),sc=e=>rc("comment.deleted",e),ac=e=>rc("comment.flagged",e),cc=e=>rc("comment.unflagged",e),lc=e=>{const t=ie();return fe(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){$a("comment.addReaction",n);const t=Cs(n,["reactor"]);gs(t);const r=$e(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},uc=e=>{const t=ie();return fe(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){$a("comment.removeReaction",n);const t=Cs(n,["reactor"]);gs(t);const r=$e(["comment","get",n.comments[0].commentId]);e(r.data)}else e(n.comments[0])}))},hc=(e,t,n)=>{const r=ie(),o=(r,o,i)=>{r===e&&o===t&&n(i)};if("message"===e){const e=e=>{if(!e.messages[0].latestReaction)return;const t=e.messages[0].latestReaction,{eventName:n,referenceId:r,referenceType:i,userDisplayName:s}=t,a=Cs(t,["eventName","referenceId","referenceType","userDisplayName"]);"add"===n&&(gs(e),gs({reactions:[a]}),o("message",e.messages[0].messageId,a))};return fe(r,"reaction/onReactorAdded","v3.message.didUpdate",e)}if("post"===e){return fe(r,"post.addReaction","post.addReaction",(e=>{const{reactor:t}=e,n=Cs(e,["reactor"]);gs(n),gs({reactions:[t]}),o("post",e.posts[0].postId,t)}))}return fe(r,"comment.addReaction","comment.addReaction",(e=>{const{reactor:t}=e,n=Cs(e,["reactor"]);gs(n),gs({reactions:[t]}),o("comment",e.comments[0].commentId,t)}))},fc=(e,t,n)=>{const r=ie(),o=(r,o,i)=>{r===e&&o===t&&n(i)};if("message"===e){const e=e=>{if(!e.messages[0].latestReaction)return;const t=e.messages[0].latestReaction,{eventName:n,referenceId:r,referenceType:i}=t,s=Cs(t,["eventName","referenceId","referenceType"]);"remove"===n&&(gs(e),gs({reactions:[s]}),o("message",e.messages[0].messageId,s))};return fe(r,"reaction/onReactorRemoved","v3.message.didUpdate",e)}if("post"===e){return fe(r,"post.removeReaction","post.removeReaction",(e=>{const{reactor:t}=e,n=Cs(e,["reactor"]);gs(n),gs({reactions:[t]}),o("post",e.posts[0].postId,t)}))}return fe(r,"comment.removeReaction","comment.removeReaction",(e=>{const{reactor:t}=e,n=Cs(e,["reactor"]);gs(n),gs({reactions:[t]}),o("comment",e.comments[0].commentId,t)}))},dc="cache_then_server";var pc={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 mc=async e=>{const t=ie();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=Cs(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:N(r,"skiplimit")}})}),{paging:c}=a,l=Cs(a,["paging"]),{channels:u}=l,h=t.cache&&Date.now();if(t.cache){gs(l,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];He(e,{channels:u.map(U("channel")),paging:c})}const f=j(c.next);return{data:u,cachedAt:h,prevPage:j(c.previous),nextPage:f}};mc.locally=e=>{ie().log("channel/queryChannels.locally",e)};const gc=async e=>{const t=ie();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&&gs(r,{cachedAt:o}),{data:r.channels,cachedAt:o}};gc.locally=e=>{var t;const n=ie();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>$e(["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 yc=async e=>{const t=ie();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};yc.locally=e=>{const t=ie();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=$e(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const vc=async e=>{const t=ie();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o}=n,i=Cs(n,["page","channelId"]),{data:s}=await t.http.get(`/api/v4/channels/${encodeURIComponent(o)}/users`,{params:Object.assign(Object.assign({},i),{options:{token:N(r,"skiplimit")}})}),{paging:a}=s,c=Cs(s,["paging"]),{channelUsers:l}=c,u=t.cache&&Date.now();t.cache&&gs(c);return{data:l,cachedAt:u,nextPage:j(a.next),prevPage:j(a.previous)}};vc.locally=e=>{ie().log("channel/queryChannelMembers",e)};const bc=e=>{const t=ie();return fe(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{gs(t),e(t.channels[0])}))},wc=e=>{const t=ie();return fe(t,"onChannelDeleted","v3.channel.didDelete",(t=>{gs(t),e(t.channels[0])}))},Cc=e=>{const t=ie();return fe(t,"onChannelJoined","v3.channel.didJoin",(t=>{gs(t),e(t.channels[0])}))},_c=e=>{const t=ie();return fe(t,"onChannelLeft","v3.channel.didLeave",(t=>{gs(t),e(t.channels[0])}))},kc=e=>{const t=ie();return fe(t,"onChannelMemberAdded","v3.channel.didAddUsers",(t=>{gs(t),e(t.channels[0],t.channelUsers[0])}))},Sc=e=>{const t=ie();return fe(t,"onChannelMemberRemoved","v3.channel.didRemoveUsers",(t=>{gs(t),e(t.channels[0],t.channelUsers[0])}))},Ac=e=>{const t=ie();return fe(t,"message/onMessageCreated","v3.message.didCreate",(t=>{gs(t),e(t.messages[0])}))},Ec=e=>{const t=ie();return fe(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{gs(t);const n=t.messages[0];(null==n?void 0:n.myReactions)||(e=>{const t=ie(),n=$e(["message","get",e.messageId]),r=(null==n?void 0:n.data.myReactions)||[];Object.assign(e,{myReactions:r});const o=null==e?void 0:e.latestReaction;o&&o.userId===t.userId&&("add"!==o.eventName||r.includes(o.reactionName)||Object.assign(e,{myReactions:[...r,o.reactionName]}),"remove"===o.eventName&&r.includes(o.reactionName)&&Object.assign(e,{myReactions:r.filter((e=>e!==o.reactionName))}))})(n),e(n)}))},Tc=e=>{const t=ie();return fe(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{gs(t),e(t.messages[0])}))},Ic=(e,t)=>{const n=ie();return fe(n,e,e,(e=>{if(n.cache){gs(e);const n=$e(["community","get",e.communities[0].communityId]);t(n.data)}else t(e.communities[0])}))};function xc(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function Oc(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=>!xc(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!xc(e,t,"ADD_COMMUNITY_USER")))[0]}const Rc=(e,t)=>{const n=ie();return fe(n,e,e,(r=>{if(n.cache){gs(r);const n=$e(["community","get",r.communities[0].communityId]),o=$e(["communityUsers","get",U("communityUsers")(Oc(e,r))]);t(n.data,o.data)}else t(r.communities[0],Oc(e,r))}))},Pc=e=>Ic("community.updated",e),Bc=e=>Ic("community.deleted",e),Nc=e=>Rc("community.joined",e),jc=e=>Rc("community.left",e),Fc=e=>Rc("community.userAdded",e),Mc=e=>Rc("community.userRemoved",e),Uc=e=>Rc("community.userBanned",e),Dc=e=>Rc("community.userUnbanned",e),Lc=async e=>{const t=ie();t.log("category/queryCategories",e);const n=null!=e?e:{},{page:r={limit:10}}=n,o=Cs(n,["page"]),{data:i}=await t.http.get("/api/v3/community-categories",{params:Object.assign(Object.assign({},o),{options:{token:N(r,"skiplimit")}})}),{paging:s}=i,a=Cs(i,["paging"]),{categories:c}=a,l=t.cache&&Date.now();if(t.cache){gs(a,{cachedAt:l});const e=["category","query",Object.assign(Object.assign({},o),{options:Object.assign({},r)})];He(e,{categories:c.map(U("category")),paging:s})}const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};Lc.locally=e=>{var t,n;const r=ie();if(r.log("category/queryCategories.locally",e),!r.cache)return;const o=null!=e?e:{},{page:i={limit:10}}=o,s=Cs(o,["page"]),a=["category","query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(t=$e(a))&&void 0!==t?t:{};if(!(null==c?void 0:c.categories.length))return;const u=c.categories.map((e=>$e(["category","get",e]))).filter(Boolean).map((({data:e})=>e)),h=j(null==c?void 0:c.paging.previous),f=j(null==c?void 0:c.paging.next);return u.length===(null===(n=null==c?void 0:c.categories)||void 0===n?void 0:n.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const qc=async e=>{const t=ie();t.log("category/getCategory",e);const{data:n}=await t.http.get(`/api/v3/community-categories/${encodeURIComponent(e)}`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{categories:o}=n;return{data:o.find((t=>t.categoryId===e)),cachedAt:r}};qc.locally=e=>{const t=ie();if(t.log("category/getCategory.locally",e),!t.cache)return;const n=$e(["category","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const zc=async e=>{const t=ie();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{useCustomRanking:r,page:o}=n,i=Cs(n,["useCustomRanking","page"]),{data:s}=await t.http.get(r?"/api/v5/me/global-feeds":"/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},i),{options:{token:N(o,"skiplimit")}})}),{paging:a}=s,c=Cs(s,["paging"]),{posts:l}=c,u=t.cache&&Date.now();if(t.cache){gs(c);const e=["globalFeed","query",Object.assign(Object.assign({},i),{useCustomRanking:r,options:Object.assign({},o)})];He(e,{posts:l.map(U("post")),paging:a})}const h=j(a.next);return{data:l,cachedAt:u,prevPage:j(a.previous),nextPage:h}};zc.locally=e=>{var t,n;const r=ie();if(r.log("post/queryGlobalFeed.locally",e),!r.cache)return;const o=null!=e?e:{},{useCustomRanking:i,page:s}=o,a=Cs(o,["useCustomRanking","page"]),c=["globalFeed","query",Object.assign(Object.assign({},a),{useCustomRanking:i,options:Object.assign({},s)})],{data:l,cachedAt:u}=null!==(t=$e(c))&&void 0!==t?t:{};if(!(null==l?void 0:l.posts.length))return;const h=l.posts.map((e=>$e(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),f=j(null==l?void 0:l.paging.previous),d=j(null==l?void 0:l.paging.next);return h.length===(null===(n=null==l?void 0:l.posts)||void 0===n?void 0:n.length)?{data:h,cachedAt:u,prevPage:f,nextPage:d}:void 0};const $c=async(e,t)=>{const n=ie();n.log(`follow/queryF${e.substring(1)}`,t);const{userId:r,page:o}=t,i=Cs(t,["userId","page"]),{data:s}=await n.http.get(n.userId===r?`/api/v4/me/${e}`:`/api/v4/users/${r}/${e}`,{params:Object.assign(Object.assign({},i),{token:N(o,"afterbeforeraw")})}),{paging:a}=s,c=Cs(s,["paging"]),{follows:l}=c,u=n.cache&&Date.now();if(n.cache){gs(c,{cachedAt:u});const t=[e,"query",Object.assign(Object.assign({},i),{userId:r,options:Object.assign({},o)})];He(t,{follows:l.map(U("follow")),paging:a})}const h=F(a.next);return{data:l,cachedAt:u,prevPage:F(a.previous),nextPage:h}};$c.locally=(e,t)=>{var n,r;const o=ie();if(o.log(`follow/queryF${e.substring(1)}.locally`,t),!o.cache)return;const{page:i}=t,s=Cs(t,["page"]),a=[e,"query",Object.assign(Object.assign({},s),{options:Object.assign({},i)})],{data:c,cachedAt:l}=null!==(n=$e(a))&&void 0!==n?n:{};if(!(null==c?void 0:c.follows.length))return;const u=c.follows.map((e=>$e(["follow","get",e]))).filter(Boolean).map((({data:e})=>e)),h=F(null==c?void 0:c.paging.previous),f=F(null==c?void 0:c.paging.next);return u.length===(null===(r=null==c?void 0:c.follows)||void 0===r?void 0:r.length)?{data:u,cachedAt:l,prevPage:h,nextPage:f}:void 0};const Hc=async e=>$c("followers",e);Hc.locally=e=>$c.locally("followers",e);const Vc=async e=>$c("following",e);Vc.locally=e=>$c.locally("following",e);const Wc=e=>["followInfo","get",`${ie().userId}#${e}`],Kc=async e=>{var t,n;const r=ie();r.log("follow/getFollowInfo",e);const{data:o}=await r.http.get(r.userId===e?"/api/v4/me/followInfo":`/api/v4/users/${e}/followInfo`),i=r.cache&&Date.now(),s="follows"in o?Object.assign(Object.assign({},o.followCounts[0]),{status:null===(n=null===(t=o.follows)||void 0===t?void 0:t[0])||void 0===n?void 0:n.status}):o.followCounts[0];return r.cache&&He(Wc(e),s,{cachedAt:i}),{data:s,cachedAt:i}};Kc.locally=e=>{const t=ie();if(t.log("follow/getFollowInfo.locally",e),!t.cache)return;const n=$e(Wc(e));return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Qc=(e,t)=>{const n=ie();return fe(n,e,e,(e=>{var r,o;if(n.cache){gs(e);[...null!==(r=ze(["followers","query"]))&&void 0!==r?r:[],...null!==(o=ze(["followings","query"]))&&void 0!==o?o:[]].filter((({key:t})=>t[2].userId===e.follows[0].from||t[2].userId===e.follows[0].to)).forEach((({key:e,data:t})=>We(e,t,{cachedAt:-1}))),t(e.follows[0])}else t(e.follows[0])}))},Jc=e=>Qc("follow.created",e),Xc=e=>Qc("follow.unfollowed",e),Yc=e=>Qc("follow.followerDeleted",e),Gc=e=>Qc("follow.requested",e),Zc=e=>Qc("follow.requestCanceled",e),el=e=>Qc("follow.accepted",e),tl=e=>Qc("follow.requestDeclined",e),nl=e=>{const t=async t=>{const[{data:n},{data:r}]=await Promise.all([Kc(t.from),Kc(t.to)]);e(n),e(r)},n=[Qc("follow.created",t),Qc("follow.requested",t),Qc("follow.accepted",t),Qc("follow.unfollowed",t),Qc("follow.requestCanceled",t),Qc("follow.requestDeclined",t),Qc("follow.followerDeleted",t)];return()=>{n.forEach((e=>e()))}},rl=async e=>{const t=ie();t.log("poll/getPoll",e);const{data:n}=await t.http.get(`/api/v3/polls/${e}`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}};rl.locally=e=>{const t=ie();if(t.log("poll/getPoll",e),!t.cache)return;const n=$e(["poll","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ol=e=>{const t=ie();return fe(t,"poll/onPollUpdated","poll.updated",(n=>{t.cache&&gs(n),e(n.polls[0])}))},il=e=>{const t=ie();return fe(t,"poll/onPollDeleted","poll.deleted",(n=>{t.cache&&gs(n),e(n.polls[0])}))},sl=async e=>{const t=ie();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};sl.locally=e=>{const t=ie();if(t.log("stream/getStream",e),!t.cache)return;const n=$e(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const al=async e=>{const t=ie();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=Cs(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:N(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,l=t.cache&&Date.now();t.cache&&gs(a,{cachedAt:l});const u=j(s.next);return{data:c,cachedAt:l,prevPage:j(s.previous),nextPage:u}};al.locally=e=>{ie().log("stream/queryStreams.locally",e)};return e.API_REGIONS=et,e.VERSION=a,e.acceptFollower=async e=>{const t=ie();t.log("follow/acceptFollower",e);const{data:n}=await t.http.post(`/api/v4/me/followers/${e}`);return t.cache&&gs(n),de("follow.accepted",n),!0},e.addChannelMembers=async(e,t)=>{const n=ie();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&&gs(r),de("v3.channel.didAddUsers",{channels:r.channels,channelUsers:r.channelUsers});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=ie();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&&gs(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=ie();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&gs(r),de("community.userAdded",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRoles=async(e,t,n)=>{const r=ie();r.log("community/addCommunityMembersRoles",e,t,n);const{data:o}=await r.http.post(`/api/v4/communities/${e}/users/roles`,{communityId:e,roles:t,userIds:n});r.cache&&gs(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&t.some((e=>n.roles.includes(e)))))},e.addReaction=Ha,e.approvePost=async e=>{var t;const n=ie();n.log("post/approvePost",e);const{data:r}=await n.http.post(`/api/v3/posts/${encodeURIComponent(e)}/approve`),o=n.cache&&Date.now();if(n.cache&&gs(r,{cachedAt:o}),"community"===r.posts[0].targetType){const e=null===(t=r.communities)||void 0===t?void 0:t[0];de("community.updated",{communities:[e]})}return de("post.approved",{posts:[r.posts[0]]}),{data:r.posts.find((t=>t.postId===e)),cachedAt:o}},e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=ie();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 Ue.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.banChannelMembers=async(e,t)=>{const n=ie();n.log("channel/banChannelMembers",{userIds:t,channelId:e});const r=await n.http.put(`/api/v3/channels/${e}/users/ban`,{userIds:t}),o=n.cache&&Date.now();n.cache&&gs(r.data,{cachedAt:o});const{channelUsers:i}=r.data;return{data:null==i?void 0:i.filter((e=>"banned"===e.membership)),cachedAt:o}},e.closePoll=async e=>{const t=ie();t.log("user/closePoll",e);const{data:n}=await t.http.put(`/api/v3/polls/${encodeURIComponent(e)}`,{status:"closed"}),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r}),de("poll.updated",n);const{polls:o}=n;return{data:o.find((t=>t.pollId===e)),cachedAt:r}},e.connectClient=async(e,t)=>{var n;const r=ie();r.log("client/api/connectClient",Object.assign({apiKey:r.apiKey},e)),null!==(n=e.deviceId)&&void 0!==n||(e.deviceId=hs());const{accessToken:o,users:i}=await(async e=>{const t=ie();t.log("client/api/getToken",e);const n=await fs(),{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,c;r.http.defaults.headers.common.Authorization=`Bearer ${o}`,r.ws.io.opts.query={token:o},s=r.ws,a=r.emitter,le.forEach((e=>{s.on(e,(t=>a.emit(e,t)))})),await new Promise((e=>{r.ws.once("connect",e),r.ws.open()})),r.userId=e.userId,r.accessToken=o,c=i[0],pe={_id:c._id,userId:c.userId,path:c.path},!0!==(null==t?void 0:t.disableRTE)&&Ce(ve());const l=[ms((()=>{us(),l.forEach((e=>e()))})),vs((()=>null))];return r.ws.connected},e.createChannel=async e=>{const t=ie();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&&gs(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=et.SG,n="amity")=>{const r=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&!o,n=Ze(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(n);r("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiRegion:t});const i=Hn(nt("http",t)),s=(e=>{const t=os(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(nt("http",t)),c=ls(nt("mqtt",t)),l=he(),u={version:`${a}`,apiKey:e,log:r,http:i,ws:s,mqtt:c,emitter:l,use:()=>se(u)};try{ie()}catch(e){se(u)}return u},e.createComment=async e=>{const t=ie();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const o=await Pa(e.referenceId);de("post.updated",{posts:[o.data]}),de("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=ie();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r}),de("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=ie();if(n.log("file/createFile",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&gs({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createImage=async(e,t)=>{const n=ie();if(n.log("file/createImage",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/images",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&gs({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.createMessage=Ta,e.createPoll=async e=>{const t=ie();t.log("post/createPoll",e);const{data:n}=await t.http.post("/api/v3/polls",e),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{polls:o}=n;return{data:o[0],cachedAt:r}},e.createPost=async e=>{const t=ie();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&&gs(n,{cachedAt:r}),de("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=K,e.createReport=async(e,t)=>{const n=ie();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=pc[e],{data:o}=await n.http.post("/api/"+("user"===e?`v4/me/flags/${encodeURIComponent(t)}`:`v3/${r}/${encodeURIComponent(t)}/flag`));n.cache&&gs(o);return de("message"===e?"v3.message.didUpdate":`${e}.flagged`,o),!!o},e.createStream=async e=>{const t=ie();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.createUserToken=async(e,t,n)=>{const r=hs(),o=await fs(),i=Hn(nt("http",t)),{data:s}=await i.post("/api/v3/sessions",Object.assign(Object.assign({},n),{deviceId:r,deviceInfo:Object.assign(Object.assign({},o),{model:"token management API on TS-SDK"})}),{headers:{"X-API-Key":e}});return{accessToken:s.accessToken}},e.createVideo=async(e,t)=>{const n=ie();if(n.log("file/createVideo",e),!e.getAll("files").length)throw new Error("The formData object must have a `files` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v4/videos",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&gs({files:o},{cachedAt:i}),{data:o,cachedAt:i}},e.declineFollower=async e=>{const t=ie();t.log("follow/declineFollower",e);const{data:n}=await t.http.delete(`/api/v4/me/followers/${e}`);return t.cache&&gs(n),de("follow.requestDeclined",n),!0},e.declinePost=async e=>{var t;const n=ie();n.log("post/declinePost",e);const{data:r}=await n.http.post(`/api/v3/posts/${encodeURIComponent(e)}/decline`),o=n.cache&&Date.now();if(n.cache&&gs(r,{cachedAt:o}),"community"===r.posts[0].targetType){const e=null===(t=r.communities)||void 0===t?void 0:t[0];de("community.updated",{communities:[e]})}return de("post.declined",{posts:[r.posts[0]]}),{data:r.posts.find((t=>t.postId===e)),cachedAt:o}},e.deleteChannel=async e=>{const t=ie();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}`);return(await yc(e)).data},e.deleteComment=async(e,t=!1)=>{const n=ie();n.log("comment/deleteComment",e);const r=await qa(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 Pa(r.data.referenceId);return de("post.updated",{posts:[i.data]}),de("comment.deleted",{comments:[o]}),t?setTimeout((()=>{Ke(["comment","get",e],!0)}),0):We(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=ie();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await ja(e);return de("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=ie();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),Ke(["file","get",e],!0),{success:!0}},e.deleteMessage=xa,e.deletePoll=async e=>{const t=ie();t.log("poll/deletePoll",e);const n=await rl(e),{data:r}=await t.http.delete(`/api/v3/polls/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return We(["poll","get",e],i),de("poll.deleted",{polls:[i],users:[]}),o},e.deletePost=async(e,t=!1)=>{const n=ie();n.log("post/deletePost",e);const r=await Pa(e);if(await n.http.delete(`/api/v4/posts/${encodeURIComponent(e)}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await ja(r.data.targetId);de("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return de("post.deleted",{posts:[o]}),t?setTimeout((()=>{Ke(["post","get",e],!0)}),0):We(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=ie();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=pc[e],{data:o}=await n.http.delete("/api/"+("user"===e?`v4/me/flags/${encodeURIComponent(t)}`:`v3/${r}/${encodeURIComponent(t)}/unflag`));n.cache&&gs(o);return de("message"===e?"v3.message.didUpdate":`${e}.unflagged`,o),!!o},e.deleteStream=async e=>{const t=ie();t.log("stream/deleteStream",e);const n=await sl(e),{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return We(["stream","get",e],i),o},e.disableCache=()=>{const e=ie();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=us,e.disposeStream=async e=>{const t=ie();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&&gs(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=Ke,e.enableCache=(e={},t)=>{const n=ie();n.cache||(n.log("cache/api/enableCache"),n.cache={data:e,persistIf:t})},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=Y,e.follow=async e=>{const t=ie();t.log("follow/follow",e);const{data:n}=await t.http.post(`/api/v4/me/following/${e}`),r=t.cache&&Date.now();return t.cache&&gs(n,{cachedAt:r}),de("accepted"===n.follows[0].status?"follow.created":"follow.requested",n),{data:n.follows[0],cachedAt:r}},e.getActiveClient=ie,e.getCategory=qc,e.getChannel=yc,e.getChannels=gc,e.getComment=qa,e.getCommentTopic=({path:e})=>e,e.getComments=La,e.getCommunities=Na,e.getCommunity=ja,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>ye(t,n),e.getFile=Ts,e.getFollowInfo=Kc,e.getMessage=Rs,e.getMessages=Ps,e.getMyFollowersTopic=()=>{const e=me(),[t]=e.path.split("/user/");return`${t}/membership/${e._id}/+/+`},e.getMyFollowingsTopic=()=>{const e=me(),[t]=e.path.split("/user/");return`${t}/membership/+/${e._id}/+`},e.getNetworkTopic=ve,e.getPoll=rl,e.getPost=Pa,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=Ra,e.getRecommendedCommunities=Ua,e.getRole=xs,e.getStream=sl,e.getTopTrendingCommunities=Ma,e.getUser=bs,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>ye(n===e.SubscriptionLevels.USER?t:t.replace(/^(\w*)/,"$1/social"),n),e.getUsers=ws,e.isAfterBefore=R,e.isAfterBeforeRaw=P,e.isCachable=V,e.isConnected=()=>{var e,t;const n=ie();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=z,e.isFresh=W,e.isLocal=e=>V(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=$,e.isOffline=H,e.isPaged=B,e.isReportedByMe=async(e,t)=>{var n,r;const o=ie();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=pc[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(zn(t))}catch(e){o(e)}}))}))})(o,i,{[s]:t}))&&void 0!==n?n:{};return null!==(r=null!=a?a:c)&&void 0!==r&&r},e.isSkipLimit=O,e.joinChannel=async e=>{const t=ie();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${encodeURIComponent(e)}/join`);t.cache&&gs(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=ie();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r}),de("community.joined",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=ie();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${encodeURIComponent(e)}/leave`);t.cache&&gs(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=ie();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&gs(n,{cachedAt:r}),de("community.left",n);const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.liveComments=(e,t,n)=>{const{log:r,cache:o}=ie();o||console.log("For using Live Collection feature you need to enable Cache!");const i=Date.now();r(`liveComments(tmpid: ${i}) > listen`);const{limit:s}=e,a=Cs(e,["limit"]),c=null!=s?s:5,{policy:l=dc}=null!=n?n:{},u=[],h=["comment","collection",{referenceId:e.referenceType,referenceType:e.referenceId}],f=n=>{var r,o;let i=null!==(r=n.data.map((e=>$e(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==r?r:[];i=Y(i,"isDeleted",e.isDeleted);const s=e.sortBy?e.sortBy:"lastCreated";i=i.sort("lastCreated"===s?Z:G),t({onNextPage:p,data:i,hasNextPage:!!(null===(o=n.params)||void 0===o?void 0:o.page),loading:n.loading,error:n.error})},d=(t,n)=>{var r;const o=null===(r=$e(h))||void 0===r?void 0:r.data;e.referenceId===t.referenceId&&e.referenceType===t.referenceType&&o&&("onCreate"===n?o.data=[...new Set([t.commentId,...o.data])]:"onDelete"===n&&(o.data=o.data.filter((e=>e!==t.commentId))),He(h,o),f(o))},p=()=>{var e,t,n,r,o;const i=null===(e=$e(h))||void 0===e?void 0:e.data,s=null!==(t=null==i?void 0:i.data)&&void 0!==t?t:[];if(s.length>0&&!(null===(n=null==i?void 0:i.params)||void 0===n?void 0:n.page))return;const u=K(Da,Object.assign(Object.assign({},a),{page:null!==(o=null===(r=null==i?void 0:i.params)||void 0===r?void 0:r.page)&&void 0!==o?o:{limit:c}}));J(u,(({data:e,error:t,loading:n,prevPage:r,nextPage:o})=>{const i={loading:n,error:t,params:{page:a.sortBy?o:r},data:s};e&&(i.data=[...new Set([...s,...e.map(U("comment"))])]),He(h,i),f(i)}),Q(l))};return u.push(oc((e=>d(e,"onCreate"))),ic((e=>d(e,"onUpdate"))),sc((e=>d(e,"onDelete"))),ac((e=>d(e,"onFlagged"))),cc((e=>d(e,"onUnflagged"))),lc((e=>d(e,"onReactionAdded"))),uc((e=>d(e,"onReactionRemoved")))),p(),()=>{r(`liveComments(tmpid: ${i}) > dispose`),u.forEach((e=>e()))}},e.livePosts=(e,t,n)=>{const{log:r,cache:o}=ie();o||console.log("For using Live Collection feature you need to enable Cache!");const i=Date.now();r(`livePosts(tmpid: ${i}) > listen`);const{limit:s}=e,a=Cs(e,["limit"]),c=null!=s?s:5,{policy:l=dc}=null!=n?n:{},u=[],h=["post","collection",{targetId:e.targetId,targetType:e.targetType}],f=n=>{var r,o;let i=null!==(r=n.data.map((e=>$e(["post","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==r?r:[];i=Y(i,"isDeleted",e.isDeleted);const s=e.sortBy?e.sortBy:"lastCreated";i=i.sort("lastCreated"===s?Z:G),t({onNextPage:p,data:i,hasNextPage:!!(null===(o=n.params)||void 0===o?void 0:o.page),loading:n.loading,error:n.error})},d=(t,n)=>{var r;const o=null===(r=$e(h))||void 0===r?void 0:r.data;e.targetId===t.targetId&&e.targetType===t.targetType&&o&&("onCreate"===n?o.data=[...new Set([t.postId,...o.data])]:["onDelete","onDeclined"].includes(n)&&(o.data=o.data.filter((e=>e!==t.postId))),He(h,o),f(o))},p=()=>{var e,t,n,r,o;const i=null===(e=$e(h))||void 0===e?void 0:e.data,s=null!==(t=null==i?void 0:i.data)&&void 0!==t?t:[];if(s.length>0&&!(null===(n=null==i?void 0:i.params)||void 0===n?void 0:n.page))return;const u=K(Oa,Object.assign(Object.assign({},a),{page:null!==(o=null===(r=null==i?void 0:i.params)||void 0===r?void 0:r.page)&&void 0!==o?o:{limit:c}}));J(u,(({data:e,error:t,loading:n,nextPage:r})=>{const o={loading:n,error:t,params:{page:r},data:s};e&&(o.data=[...new Set([...s,...e.map(U("post"))])]),He(h,o),f(o)}),Q(l))};return u.push(Qa((e=>d(e,"onCreate"))),Ya((e=>d(e,"onApproved"))),Ga((e=>d(e,"onDeclined"))),Xa((e=>d(e,"onDelete"))),Ja((e=>d(e,"onUpdate"))),Za((e=>d(e,"onFlagged"))),ec((e=>d(e,"onUnflagged"))),tc((e=>d(e,"onReactionAdded"))),nc((e=>d(e,"onReactionRemoved")))),p(),()=>{r(`livePosts(tmpid: ${i}) > dispose`),u.forEach((e=>e()))}},e.liveReactions=(e,t,n)=>{const{log:r,cache:o}=ie();o||console.log("For using Live Collection feature you need to enable Cache!");const i=Date.now();r(`liveReactions(tmpid: ${i}) > listen`);const{limit:s}=e,a=Cs(e,["limit"]),c=null!=s?s:5,{policy:l=dc}=null!=n?n:{},u=[],h=["reaction","collection",{referenceId:e.referenceId,referenceType:e.referenceType}],f=e=>{var n,r;const o=null!==(n=e.data.map((e=>$e(["reaction","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[];t({onNextPage:p,data:o,hasNextPage:!!(null===(r=e.params)||void 0===r?void 0:r.page),loading:e.loading,error:e.error})},d=(e,t)=>{var n;const r=null===(n=$e(h))||void 0===n?void 0:n.data;r&&("onAdded"===t?r.data=[...new Set([e.reactionId,...r.data])]:"onRemoved"===t&&(r.data=r.data.filter((t=>t!==e.reactionId))),He(h,r),f(r))},p=()=>{var e,t,n,r,o;const i=null===(e=$e(h))||void 0===e?void 0:e.data,s=null!==(t=null==i?void 0:i.data)&&void 0!==t?t:[];if(s.length>0&&!(null===(n=null==i?void 0:i.params)||void 0===n?void 0:n.page))return;const u=K(Wa,Object.assign(Object.assign({},a),{page:null!==(o=null===(r=null==i?void 0:i.params)||void 0===r?void 0:r.page)&&void 0!==o?o:{limit:c}}));J(u,(({data:e,error:t,loading:n,nextPage:r})=>{const o={loading:n,error:t,params:{page:r},data:s};e&&(o.data=[...new Set([...s,...e[0].reactors.map(U("reaction"))])]),He(h,o),f(o)}),Q(l))};return u.push(hc(a.referenceType,a.referenceId,(e=>d(e,"onAdded"))),fc(a.referenceType,a.referenceId,(e=>d(e,"onRemoved")))),p(),()=>{r(`liveReactions(tmpid: ${i}) > dispose`),u.forEach((e=>e()))}},e.mergeInCache=Ve,e.observeChannel=(e,t)=>{const{log:n}=ie(),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(bc((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),wc((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),Cc((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),_c((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),kc((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),Sc((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),J(K(yc,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}=ie(),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(ic((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),sc((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),ac((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),cc((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),lc((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),uc((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),J(K(qa,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=ie(),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(oc((e=>i(e,"onCreate"))),ic((e=>i(e,"onUpdate"))),sc((e=>i(e,"onDelete"))),ac((e=>i(e,"onFlagged"))),cc((e=>i(e,"onUnflagged"))),lc((e=>i(e,"onReactionAdded"))),uc((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=ie(),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(Pc((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Bc((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),Nc((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),jc((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),Fc((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),Mc((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),Uc((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),Dc((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),J(K(ja,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}=ie(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return J(K(Ts,e),(n=>n.data&&((n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}})(n,"onFetch"))),()=>{n(`observeFile(tmpid: ${r}) > dispose`)}},e.observeFollowInfo=(e,t,n="cache_then_server")=>{const{log:r}=ie(),o=Date.now();r(`observeFollowInfo(tmpid: ${o}) > listen`);const i=(e,n)=>{var r,o;if(t instanceof Function)return t(e);"onFetch"!==n&&(null===(r=t.onEvent)||void 0===r||r.call(t,n,e)),null===(o=t[n])||void 0===o||o.call(t,e)},s=[];return s.push(nl((t=>((t,n)=>{var r;(null===(r=t.data)||void 0===r?void 0:r.userId)===e&&i(t,n)})({data:t,loading:!1,origin:"event"},"onUpdate")))),J(K(Kc,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observeFollowInfo(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeFollowers=(e,t)=>{const{log:n}=ie(),r=Date.now();n(`observeFollowers(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.from===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Gc((e=>i(e,"onRequested"))),el((e=>i(e,"onAccepted"))),tl((e=>i(e,"onDeclined"))),Zc((e=>i(e,"onCanceled"))),Jc((e=>i(e,"onFollowed"))),Xc((e=>i(e,"onUnfollowed"))),Yc((e=>i(e,"onDeleted")))),()=>{n(`observeFollowers(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeFollowings=(e,t)=>{const{log:n}=ie(),r=Date.now();n(`observeFollowings(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.to===e){if(t instanceof Function)return t(n);null===(o=t.onEvent)||void 0===o||o.call(t,r,n),null===(i=t[r])||void 0===i||i.call(t,n)}};return o.push(Gc((e=>i(e,"onRequested"))),el((e=>i(e,"onAccepted"))),tl((e=>i(e,"onDeclined"))),Zc((e=>i(e,"onCanceled"))),Jc((e=>i(e,"onFollowed"))),Xc((e=>i(e,"onUnfollowed"))),Yc((e=>i(e,"onDeleted")))),()=>{n(`observeFollowings(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=ie(),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(Ec((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Tc((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&J(K(Rs,e),(e=>e.data&&i(e,"onFetch")),Q(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=ie(),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(Ac((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),Ec((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Tc((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),()=>{n(`observeMessages(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observePoll=(e,t,n="cache_then_server")=>{const{log:r}=ie(),o=Date.now();r(`observePoll(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.pollId)===e&&i(t,n)},a=[];return a.push(ol((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),il((e=>s({data:e,loading:!1,origin:"event"},"onDelete")))),J(K(rl,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observePoll(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePost=(e,t,n="cache_then_server")=>{const{log:r}=ie(),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(Ja((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Xa((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Ya((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),Ga((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),Za((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),ec((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),tc((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),nc((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),J(K(Pa,e),(e=>(e.data||e.error)&&i(e,"onFetch")),Q(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=ie(),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(Qa((e=>i(e,"onCreate"))),Ja((e=>i(e,"onUpdate"))),Xa((e=>i(e,"onDelete"))),Ya((e=>i(e,"onApproved"))),Ga((e=>i(e,"onDeclined"))),Za((e=>i(e,"onFlagged"))),ec((e=>i(e,"onUnflagged"))),tc((e=>i(e,"onReactionAdded"))),nc((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=ie(),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(ks((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),vs((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),Ss((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),As((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),Es((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),J(K(bs,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=wc,e.onChannelJoined=Cc,e.onChannelLeft=_c,e.onChannelMemberAdded=kc,e.onChannelMemberRemoved=Sc,e.onChannelUpdated=bc,e.onClientBanned=ms,e.onClientDisconnected=e=>ps((({code:t})=>{800211===t&&e()})),e.onCommentCreated=oc,e.onCommentDeleted=sc,e.onCommentFlagged=ac,e.onCommentReactionAdded=lc,e.onCommentReactionRemoved=uc,e.onCommentUnflagged=cc,e.onCommentUpdated=ic,e.onCommunityCreated=e=>Ic("community.created",e),e.onCommunityDeleted=Bc,e.onCommunityJoined=Nc,e.onCommunityLeft=jc,e.onCommunityUpdated=Pc,e.onCommunityUserAdded=Fc,e.onCommunityUserBanned=Uc,e.onCommunityUserRemoved=Mc,e.onCommunityUserUnbanned=Dc,e.onConnectionError=ps,e.onFollowInfoUpdated=nl,e.onFollowRequestAccepted=el,e.onFollowRequestCanceled=Zc,e.onFollowRequestDeclined=tl,e.onFollowerDeleted=Yc,e.onFollowerRequested=Gc,e.onMessageCreated=Ac,e.onMessageDeleted=Tc,e.onMessageUpdated=Ec,e.onPollDeleted=il,e.onPollUpdated=ol,e.onPostApproved=Ya,e.onPostCreated=Qa,e.onPostDeclined=Ga,e.onPostDeleted=Xa,e.onPostFlagged=Za,e.onPostReactionAdded=tc,e.onPostReactionRemoved=nc,e.onPostUnflagged=ec,e.onPostUpdated=Ja,e.onReactionAdded=(e,t,n)=>{const r=r=>{U(e)(r)===t&&n(r)};if("message"===e){const e=ie(),t=e=>{var t;const n=$e(["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;gs(e),o&&r(e.messages[0])};return fe(e,"reaction/onReactionAdded","v3.message.didUpdate",t)}return"post"===e?tc(r):lc(r)},e.onReactionRemoved=(e,t,n)=>{const r=r=>{U(e)(r)===t&&n(r)};if("message"===e){const e=ie(),t=e=>{var t;const n=$e(["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;gs(e),o&&r(e.messages[0])};return fe(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?nc(r):uc(r)},e.onReactorAdded=hc,e.onReactorRemoved=fc,e.onStreamRecorded=e=>{const t=ie();return fe(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{gs(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=ie();return fe(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{gs(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=ie();return fe(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{gs(t),e(t.videoStreamings[0])}))},e.onUserDeleted=vs,e.onUserFlagCleared=Es,e.onUserFlagged=Ss,e.onUserFollowed=Jc,e.onUserUnflagged=As,e.onUserUnfollowed=Xc,e.onUserUpdated=ks,e.pullFromCache=$e,e.pushToCache=He,e.queryCache=ze,e.queryCategories=Lc,e.queryChannelMembers=vc,e.queryChannels=mc,e.queryComments=Da,e.queryCommunities=Ba,e.queryCommunityMembers=Fa,e.queryFollowers=Hc,e.queryFollowings=Vc,e.queryGlobalFeed=zc,e.queryMessages=Bs,e.queryOptions=Q,e.queryPosts=Oa,e.queryReactions=Wa,e.queryRoles=Is,e.queryStreams=al,e.queryUsers=_s,e.removeChannelMembers=async(e,t)=>{const n=ie();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&&gs(r),de("v3.channel.didRemoveUsers",{channels:r.channels,channelUsers:r.channelUsers});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=ie();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&&gs(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=ie();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&&gs(r),de("community.userRemoved",r);const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRoles=async(e,t,n)=>{const r=ie();r.log("community/removeCommunityMembersRoles",e,t,n);const{data:o}=await r.http.delete(`/api/v4/communities/${e}/users/roles`,{data:{communityId:e,roles:t,userIds:n}});r.cache&&gs(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!t.some((e=>n.roles.includes(e)))))},e.removeReaction=Va,e.restoreCache=async(e="amitySdk")=>{var t;const n=ie();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await Ue.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=J,e.sortByChannelSegment=({channelSegment:e},{channelSegment:t})=>e-t,e.sortByDisplayName=({displayName:e},{displayName:t})=>e===t?0:e<t?-1:1,e.sortByFirstCreated=G,e.sortByLastActivity=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortByLastCreated=Z,e.sortBySegmentNumber=({segmentNumber:e},{segmentNumber:t})=>e-t,e.subscribeTopic=Ce,e.toPage=j,e.toPageRaw=F,e.toToken=N,e.unbanChannelMembers=async(e,t)=>{const n=ie();n.log("channel/unbanChannelMembers",{userIds:t,channelId:e});const r=await n.http.put(`/api/v3/channels/${encodeURIComponent(e)}/users/unban`,{userIds:t}),o=n.cache&&Date.now();n.cache&&gs(r.data,{cachedAt:o});const{channelUsers:i}=r.data;return{data:null==i?void 0:i.filter((e=>"member"===e.membership)),cachedAt:o}},e.unfollow=async e=>{const t=ie();t.log("follow/unfollow",e);const{data:n}=await t.http.delete(`/api/v4/me/following/${e}`);return t.cache&&gs(n),de("follow.unfollowed",n),!0},e.updateChannel=async(e,t)=>{const n=ie();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&&gs(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=ie();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&&gs(r,{cachedAt:o}),de("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=ie();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&&gs(r,{cachedAt:o}),de("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=Ia,e.updatePost=async(e,t)=>{const n=ie();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&&gs(r,{cachedAt:o}),de("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=ie();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&&gs(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=ie();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&&gs(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=We,e.votePoll=async(e,t)=>{const n=ie();n.log("user/votePoll",e);const{data:r}=await n.http.post(`/api/v3/polls/${encodeURIComponent(e)}/votes`,{pollId:e,answerIds:t}),o=n.cache&&Date.now();n.cache&&gs(r,{cachedAt:o});const{polls:i}=r;return de("poll.updated",r),{data:i.find((t=>t.pollId===e)),cachedAt:o}},e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=ie();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await Ue.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});