@amityco/ts-sdk 0.0.1-be4fc2f.0 → 0.0.1-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (527) hide show
  1. package/README.md +2 -2
  2. package/dist/@types/core/cache.d.ts +49 -9
  3. package/dist/@types/core/cache.d.ts.map +1 -1
  4. package/dist/@types/core/events.d.ts +22 -12
  5. package/dist/@types/core/events.d.ts.map +1 -1
  6. package/dist/@types/core/model.d.ts +1 -0
  7. package/dist/@types/core/model.d.ts.map +1 -1
  8. package/dist/@types/core/paging.d.ts +59 -0
  9. package/dist/@types/core/paging.d.ts.map +1 -0
  10. package/dist/@types/core/permissions.d.ts +1 -1
  11. package/dist/@types/core/permissions.d.ts.map +1 -1
  12. package/dist/@types/core/query.d.ts +13 -43
  13. package/dist/@types/core/query.d.ts.map +1 -1
  14. package/dist/@types/core/transport.d.ts +3 -2
  15. package/dist/@types/core/transport.d.ts.map +1 -1
  16. package/dist/@types/domains/category.d.ts +1 -1
  17. package/dist/@types/domains/category.d.ts.map +1 -1
  18. package/dist/@types/domains/channel.d.ts +1 -1
  19. package/dist/@types/domains/channel.d.ts.map +1 -1
  20. package/dist/@types/domains/client.d.ts +2 -0
  21. package/dist/@types/domains/client.d.ts.map +1 -1
  22. package/dist/@types/domains/comment.d.ts +1 -1
  23. package/dist/@types/domains/comment.d.ts.map +1 -1
  24. package/dist/@types/domains/community.d.ts +1 -1
  25. package/dist/@types/domains/community.d.ts.map +1 -1
  26. package/dist/@types/domains/content.d.ts +1 -2
  27. package/dist/@types/domains/content.d.ts.map +1 -1
  28. package/dist/@types/domains/file.d.ts +1 -1
  29. package/dist/@types/domains/file.d.ts.map +1 -1
  30. package/dist/@types/domains/group.d.ts +3 -3
  31. package/dist/@types/domains/group.d.ts.map +1 -1
  32. package/dist/@types/domains/message.d.ts +1 -1
  33. package/dist/@types/domains/message.d.ts.map +1 -1
  34. package/dist/@types/domains/post.d.ts +1 -1
  35. package/dist/@types/domains/post.d.ts.map +1 -1
  36. package/dist/@types/domains/stream.d.ts +1 -1
  37. package/dist/@types/domains/stream.d.ts.map +1 -1
  38. package/dist/@types/domains/user.d.ts +2 -1
  39. package/dist/@types/domains/user.d.ts.map +1 -1
  40. package/dist/@types/index.d.ts +1 -1
  41. package/dist/@types/index.d.ts.map +1 -1
  42. package/dist/cache/api/backupCache.d.ts +24 -0
  43. package/dist/cache/api/backupCache.d.ts.map +1 -0
  44. package/dist/cache/api/disableCache.d.ts +13 -0
  45. package/dist/cache/api/disableCache.d.ts.map +1 -0
  46. package/dist/cache/api/dropFromCache.d.ts +17 -0
  47. package/dist/cache/api/dropFromCache.d.ts.map +1 -0
  48. package/dist/cache/api/enableCache.d.ts +18 -0
  49. package/dist/cache/api/enableCache.d.ts.map +1 -0
  50. package/dist/cache/api/index.d.ts +12 -0
  51. package/dist/cache/api/index.d.ts.map +1 -0
  52. package/dist/cache/api/ingestInCache.d.ts +11 -0
  53. package/dist/cache/api/ingestInCache.d.ts.map +1 -0
  54. package/dist/cache/api/mergeInCache.d.ts +20 -0
  55. package/dist/cache/api/mergeInCache.d.ts.map +1 -0
  56. package/dist/cache/api/pullFromCache.d.ts +17 -0
  57. package/dist/cache/api/pullFromCache.d.ts.map +1 -0
  58. package/dist/cache/api/pushToCache.d.ts +17 -0
  59. package/dist/cache/api/pushToCache.d.ts.map +1 -0
  60. package/dist/cache/api/queryCache.d.ts +17 -0
  61. package/dist/cache/api/queryCache.d.ts.map +1 -0
  62. package/dist/cache/api/restoreCache.d.ts +22 -0
  63. package/dist/cache/api/restoreCache.d.ts.map +1 -0
  64. package/dist/cache/api/snipeIdFromCollection.d.ts +18 -0
  65. package/dist/cache/api/snipeIdFromCollection.d.ts.map +1 -0
  66. package/dist/cache/api/upsertInCache.d.ts +19 -0
  67. package/dist/cache/api/upsertInCache.d.ts.map +1 -0
  68. package/dist/cache/api/wipeCache.d.ts +21 -0
  69. package/dist/cache/api/wipeCache.d.ts.map +1 -0
  70. package/dist/cache/utils/index.d.ts +41 -0
  71. package/dist/cache/utils/index.d.ts.map +1 -0
  72. package/dist/category/api/getCategory.d.ts.map +1 -1
  73. package/dist/category/api/queryCategories.d.ts +5 -4
  74. package/dist/category/api/queryCategories.d.ts.map +1 -1
  75. package/dist/channel/api/addChannelMembers.d.ts.map +1 -1
  76. package/dist/channel/api/addChannelMembersRole.d.ts.map +1 -1
  77. package/dist/channel/api/createChannel.d.ts +1 -1
  78. package/dist/channel/api/createChannel.d.ts.map +1 -1
  79. package/dist/channel/api/deleteChannel.d.ts +1 -1
  80. package/dist/channel/api/deleteChannel.d.ts.map +1 -1
  81. package/dist/channel/api/getChannel.d.ts +2 -2
  82. package/dist/channel/api/getChannel.d.ts.map +1 -1
  83. package/dist/channel/api/getChannels.d.ts +2 -2
  84. package/dist/channel/api/getChannels.d.ts.map +1 -1
  85. package/dist/channel/api/joinChannel.d.ts.map +1 -1
  86. package/dist/channel/api/leaveChannel.d.ts.map +1 -1
  87. package/dist/channel/api/queryChannelMembers.d.ts +1 -5
  88. package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
  89. package/dist/channel/api/queryChannels.d.ts +1 -5
  90. package/dist/channel/api/queryChannels.d.ts.map +1 -1
  91. package/dist/channel/api/removeChannelMembers.d.ts.map +1 -1
  92. package/dist/channel/api/removeChannelMembersRole.d.ts.map +1 -1
  93. package/dist/channel/api/updateChannel.d.ts +1 -1
  94. package/dist/channel/api/updateChannel.d.ts.map +1 -1
  95. package/dist/channel/events/onChannelDeleted.d.ts.map +1 -1
  96. package/dist/channel/events/onChannelJoined.d.ts.map +1 -1
  97. package/dist/channel/events/onChannelLeft.d.ts.map +1 -1
  98. package/dist/channel/events/onChannelUpdated.d.ts.map +1 -1
  99. package/dist/channel/events/onMemberAdded.d.ts.map +1 -1
  100. package/dist/channel/events/onMemberRemoved.d.ts.map +1 -1
  101. package/dist/channel/observers/observeChannel.d.ts +1 -3
  102. package/dist/channel/observers/observeChannel.d.ts.map +1 -1
  103. package/dist/client/api/connectClient.d.ts.map +1 -1
  104. package/dist/client/api/disconnectClient.d.ts.map +1 -1
  105. package/dist/client/api/getToken.d.ts +3 -1
  106. package/dist/client/api/getToken.d.ts.map +1 -1
  107. package/dist/client/api/index.d.ts +0 -2
  108. package/dist/client/api/index.d.ts.map +1 -1
  109. package/dist/comment/api/createComment.d.ts +1 -1
  110. package/dist/comment/api/createComment.d.ts.map +1 -1
  111. package/dist/comment/api/deleteComment.d.ts +1 -37
  112. package/dist/comment/api/deleteComment.d.ts.map +1 -1
  113. package/dist/comment/api/getComment.d.ts +2 -2
  114. package/dist/comment/api/getComment.d.ts.map +1 -1
  115. package/dist/comment/api/getComments.d.ts +2 -2
  116. package/dist/comment/api/getComments.d.ts.map +1 -1
  117. package/dist/comment/api/queryComments.d.ts +4 -18
  118. package/dist/comment/api/queryComments.d.ts.map +1 -1
  119. package/dist/comment/api/updateComment.d.ts +1 -1
  120. package/dist/comment/api/updateComment.d.ts.map +1 -1
  121. package/dist/comment/events/onCommentCreated.d.ts +2 -2
  122. package/dist/comment/events/onCommentCreated.d.ts.map +1 -1
  123. package/dist/comment/events/onCommentDeleted.d.ts +2 -2
  124. package/dist/comment/events/onCommentDeleted.d.ts.map +1 -1
  125. package/dist/comment/events/onCommentFlagged.d.ts +2 -2
  126. package/dist/comment/events/onCommentFlagged.d.ts.map +1 -1
  127. package/dist/comment/events/onCommentReactionAdded.d.ts +2 -2
  128. package/dist/comment/events/onCommentReactionAdded.d.ts.map +1 -1
  129. package/dist/comment/events/onCommentReactionRemoved.d.ts +2 -2
  130. package/dist/comment/events/onCommentReactionRemoved.d.ts.map +1 -1
  131. package/dist/comment/events/onCommentUnflagged.d.ts +2 -2
  132. package/dist/comment/events/onCommentUnflagged.d.ts.map +1 -1
  133. package/dist/comment/events/onCommentUpdated.d.ts +2 -2
  134. package/dist/comment/events/onCommentUpdated.d.ts.map +1 -1
  135. package/dist/comment/events/utils.d.ts +1 -1
  136. package/dist/comment/events/utils.d.ts.map +1 -1
  137. package/dist/comment/observers/observeComment.d.ts +1 -3
  138. package/dist/comment/observers/observeComment.d.ts.map +1 -1
  139. package/dist/community/api/addCommunityMembers.d.ts.map +1 -1
  140. package/dist/community/api/addCommunityMembersRole.d.ts.map +1 -1
  141. package/dist/community/api/createCommunity.d.ts +1 -1
  142. package/dist/community/api/createCommunity.d.ts.map +1 -1
  143. package/dist/community/api/deleteCommunity.d.ts.map +1 -1
  144. package/dist/community/api/getCommunities.d.ts +2 -2
  145. package/dist/community/api/getCommunities.d.ts.map +1 -1
  146. package/dist/community/api/getCommunity.d.ts +2 -2
  147. package/dist/community/api/getCommunity.d.ts.map +1 -1
  148. package/dist/community/api/joinCommunity.d.ts.map +1 -1
  149. package/dist/community/api/leaveCommunity.d.ts.map +1 -1
  150. package/dist/community/api/queryCommunities.d.ts +1 -5
  151. package/dist/community/api/queryCommunities.d.ts.map +1 -1
  152. package/dist/community/api/queryCommunityMembers.d.ts +1 -5
  153. package/dist/community/api/queryCommunityMembers.d.ts.map +1 -1
  154. package/dist/community/api/removeCommunityMembers.d.ts.map +1 -1
  155. package/dist/community/api/removeCommunityMembersRole.d.ts.map +1 -1
  156. package/dist/community/api/updateCommunity.d.ts +1 -1
  157. package/dist/community/api/updateCommunity.d.ts.map +1 -1
  158. package/dist/community/events/onCommunityCreated.d.ts +1 -1
  159. package/dist/community/events/onCommunityDeleted.d.ts +1 -1
  160. package/dist/community/events/onCommunityJoined.d.ts +3 -3
  161. package/dist/community/events/onCommunityJoined.d.ts.map +1 -1
  162. package/dist/community/events/onCommunityLeft.d.ts +3 -3
  163. package/dist/community/events/onCommunityLeft.d.ts.map +1 -1
  164. package/dist/community/events/onCommunityUpdated.d.ts +1 -1
  165. package/dist/community/events/onCommunityUserAdded.d.ts +3 -3
  166. package/dist/community/events/onCommunityUserAdded.d.ts.map +1 -1
  167. package/dist/community/events/onCommunityUserBanned.d.ts +3 -3
  168. package/dist/community/events/onCommunityUserBanned.d.ts.map +1 -1
  169. package/dist/community/events/onCommunityUserRemoved.d.ts +3 -3
  170. package/dist/community/events/onCommunityUserRemoved.d.ts.map +1 -1
  171. package/dist/community/events/onCommunityUserUnbanned.d.ts +3 -3
  172. package/dist/community/events/onCommunityUserUnbanned.d.ts.map +1 -1
  173. package/dist/community/events/utils.d.ts +1 -0
  174. package/dist/community/events/utils.d.ts.map +1 -1
  175. package/dist/community/observers/observeCommunity.d.ts +1 -3
  176. package/dist/community/observers/observeCommunity.d.ts.map +1 -1
  177. package/dist/core/events.d.ts +3 -3
  178. package/dist/core/events.d.ts.map +1 -1
  179. package/dist/core/model/idResolvers.d.ts +9 -11
  180. package/dist/core/model/idResolvers.d.ts.map +1 -1
  181. package/dist/core/model/identifyModel.d.ts +1 -1
  182. package/dist/core/model/identifyModel.d.ts.map +1 -1
  183. package/dist/core/model/index.d.ts +6 -2
  184. package/dist/core/model/index.d.ts.map +1 -1
  185. package/dist/core/query/index.d.ts +0 -1
  186. package/dist/core/query/index.d.ts.map +1 -1
  187. package/dist/core/query/paging.d.ts +21 -3
  188. package/dist/core/query/paging.d.ts.map +1 -1
  189. package/dist/core/query/query.d.ts +9 -21
  190. package/dist/core/query/query.d.ts.map +1 -1
  191. package/dist/core/subscription.d.ts +13 -2
  192. package/dist/core/subscription.d.ts.map +1 -1
  193. package/dist/core/transports/mqtt.d.ts +2 -1
  194. package/dist/core/transports/mqtt.d.ts.map +1 -1
  195. package/dist/core/transports/ws.d.ts.map +1 -1
  196. package/dist/feed/api/queryGlobalFeed.d.ts +1 -5
  197. package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
  198. package/dist/file/api/createFile.d.ts +1 -1
  199. package/dist/file/api/createFile.d.ts.map +1 -1
  200. package/dist/file/api/deleteFile.d.ts.map +1 -1
  201. package/dist/file/api/getFile.d.ts +2 -2
  202. package/dist/file/api/getFile.d.ts.map +1 -1
  203. package/dist/file/observers/observeFile.d.ts +1 -3
  204. package/dist/file/observers/observeFile.d.ts.map +1 -1
  205. package/dist/index.cjs.js +17428 -2854
  206. package/dist/index.d.ts +3 -2
  207. package/dist/index.d.ts.map +1 -1
  208. package/dist/index.esm.js +17411 -2840
  209. package/dist/index.umd.js +6 -4
  210. package/dist/message/api/createMessage.d.ts +2 -2
  211. package/dist/message/api/createMessage.d.ts.map +1 -1
  212. package/dist/message/api/deleteMessage.d.ts +2 -2
  213. package/dist/message/api/deleteMessage.d.ts.map +1 -1
  214. package/dist/message/api/getMessage.d.ts +2 -2
  215. package/dist/message/api/getMessage.d.ts.map +1 -1
  216. package/dist/message/api/getMessages.d.ts +2 -2
  217. package/dist/message/api/getMessages.d.ts.map +1 -1
  218. package/dist/message/api/queryMessages.d.ts +2 -16
  219. package/dist/message/api/queryMessages.d.ts.map +1 -1
  220. package/dist/message/api/updateMessage.d.ts +2 -2
  221. package/dist/message/api/updateMessage.d.ts.map +1 -1
  222. package/dist/message/events/onMessageCreated.d.ts.map +1 -1
  223. package/dist/message/events/onMessageDeleted.d.ts.map +1 -1
  224. package/dist/message/events/onMessageUpdated.d.ts.map +1 -1
  225. package/dist/message/observers/observeMessage.d.ts +1 -3
  226. package/dist/message/observers/observeMessage.d.ts.map +1 -1
  227. package/dist/message/observers/observeMessages.d.ts +1 -1
  228. package/dist/message/observers/observeMessages.d.ts.map +1 -1
  229. package/dist/post/api/createPost.d.ts +1 -1
  230. package/dist/post/api/createPost.d.ts.map +1 -1
  231. package/dist/post/api/deletePost.d.ts +1 -40
  232. package/dist/post/api/deletePost.d.ts.map +1 -1
  233. package/dist/post/api/getPost.d.ts +5 -5
  234. package/dist/post/api/getPost.d.ts.map +1 -1
  235. package/dist/post/api/getPosts.d.ts +4 -4
  236. package/dist/post/api/getPosts.d.ts.map +1 -1
  237. package/dist/post/api/queryPosts.d.ts +4 -8
  238. package/dist/post/api/queryPosts.d.ts.map +1 -1
  239. package/dist/post/api/updatePost.d.ts +1 -1
  240. package/dist/post/api/updatePost.d.ts.map +1 -1
  241. package/dist/post/events/onPostApproved.d.ts +1 -1
  242. package/dist/post/events/onPostCreated.d.ts +1 -1
  243. package/dist/post/events/onPostDeclined.d.ts +1 -1
  244. package/dist/post/events/onPostDeleted.d.ts +1 -1
  245. package/dist/post/events/onPostDeleted.d.ts.map +1 -1
  246. package/dist/post/events/onPostFlagged.d.ts +1 -1
  247. package/dist/post/events/onPostReactionAdded.d.ts +1 -1
  248. package/dist/post/events/onPostReactionAdded.d.ts.map +1 -1
  249. package/dist/post/events/onPostReactionRemoved.d.ts +1 -1
  250. package/dist/post/events/onPostReactionRemoved.d.ts.map +1 -1
  251. package/dist/post/events/onPostUnflagged.d.ts +1 -1
  252. package/dist/post/events/onPostUpdated.d.ts +1 -1
  253. package/dist/post/events/utils.d.ts.map +1 -1
  254. package/dist/post/observers/observePost.d.ts +1 -3
  255. package/dist/post/observers/observePost.d.ts.map +1 -1
  256. package/dist/reaction/api/addReaction.d.ts +1 -1
  257. package/dist/reaction/api/addReaction.d.ts.map +1 -1
  258. package/dist/reaction/api/removeReaction.d.ts +1 -1
  259. package/dist/reaction/api/removeReaction.d.ts.map +1 -1
  260. package/dist/reaction/events/onReactionAdded.d.ts +4 -2
  261. package/dist/reaction/events/onReactionAdded.d.ts.map +1 -1
  262. package/dist/reaction/events/onReactionRemoved.d.ts +4 -2
  263. package/dist/reaction/events/onReactionRemoved.d.ts.map +1 -1
  264. package/dist/reaction/utils/fetchReference.d.ts +1 -1
  265. package/dist/reaction/utils/fetchReference.d.ts.map +1 -1
  266. package/dist/reaction/utils/index.d.ts +1 -0
  267. package/dist/reaction/utils/index.d.ts.map +1 -1
  268. package/dist/reaction/utils/preparePayloadForCache.d.ts +3 -0
  269. package/dist/reaction/utils/preparePayloadForCache.d.ts.map +1 -0
  270. package/dist/report/api/createReport.d.ts.map +1 -1
  271. package/dist/report/api/deleteReport.d.ts.map +1 -1
  272. package/dist/role/api/getRole.d.ts +2 -2
  273. package/dist/role/api/getRole.d.ts.map +1 -1
  274. package/dist/role/api/queryRoles.d.ts +1 -5
  275. package/dist/role/api/queryRoles.d.ts.map +1 -1
  276. package/dist/stream/api/createStream.d.ts +1 -1
  277. package/dist/stream/api/createStream.d.ts.map +1 -1
  278. package/dist/stream/api/deleteStream.d.ts.map +1 -1
  279. package/dist/stream/api/disposeStream.d.ts +1 -1
  280. package/dist/stream/api/disposeStream.d.ts.map +1 -1
  281. package/dist/stream/api/getStream.d.ts +2 -2
  282. package/dist/stream/api/getStream.d.ts.map +1 -1
  283. package/dist/stream/api/queryStreams.d.ts +1 -5
  284. package/dist/stream/api/queryStreams.d.ts.map +1 -1
  285. package/dist/stream/api/updateStream.d.ts +1 -1
  286. package/dist/stream/api/updateStream.d.ts.map +1 -1
  287. package/dist/stream/events/onStreamRecorded.d.ts.map +1 -1
  288. package/dist/stream/events/onStreamStarted.d.ts.map +1 -1
  289. package/dist/stream/events/onStreamStopped.d.ts.map +1 -1
  290. package/dist/user/api/getUser.d.ts +4 -4
  291. package/dist/user/api/getUser.d.ts.map +1 -1
  292. package/dist/user/api/getUsers.d.ts +4 -4
  293. package/dist/user/api/getUsers.d.ts.map +1 -1
  294. package/dist/user/api/queryUsers.d.ts +7 -11
  295. package/dist/user/api/queryUsers.d.ts.map +1 -1
  296. package/dist/user/api/updateUser.d.ts +1 -1
  297. package/dist/user/api/updateUser.d.ts.map +1 -1
  298. package/dist/user/events/onUserFlagCleared.d.ts +1 -1
  299. package/dist/user/events/onUserFlagged.d.ts +1 -1
  300. package/dist/user/events/onUserUnflagged.d.ts +1 -1
  301. package/dist/user/events/onUserUpdated.d.ts +1 -1
  302. package/dist/user/events/utils.d.ts.map +1 -1
  303. package/dist/user/observers/observeUser.d.ts +1 -3
  304. package/dist/user/observers/observeUser.d.ts.map +1 -1
  305. package/package.json +6 -5
  306. package/src/@types/core/cache.ts +56 -9
  307. package/src/@types/core/events.ts +14 -11
  308. package/src/@types/core/model.ts +2 -0
  309. package/src/@types/core/paging.ts +75 -0
  310. package/src/@types/core/permissions.ts +0 -1
  311. package/src/@types/core/query.ts +14 -55
  312. package/src/@types/core/transport.ts +4 -2
  313. package/src/@types/domains/category.ts +0 -1
  314. package/src/@types/domains/channel.ts +0 -1
  315. package/src/@types/domains/client.ts +2 -0
  316. package/src/@types/domains/comment.ts +0 -1
  317. package/src/@types/domains/community.ts +0 -1
  318. package/src/@types/domains/content.ts +17 -15
  319. package/src/@types/domains/file.ts +0 -1
  320. package/src/@types/domains/group.ts +2 -3
  321. package/src/@types/domains/message.ts +0 -1
  322. package/src/@types/domains/post.ts +8 -8
  323. package/src/@types/domains/stream.ts +0 -1
  324. package/src/@types/domains/user.ts +1 -1
  325. package/src/@types/index.ts +1 -1
  326. package/src/@types/mqtt.d.ts +3 -0
  327. package/src/cache/api/backupCache.ts +53 -0
  328. package/src/cache/api/disableCache.ts +23 -0
  329. package/src/cache/api/dropFromCache.ts +44 -0
  330. package/src/cache/api/enableCache.ts +29 -0
  331. package/src/cache/api/index.ts +23 -0
  332. package/src/cache/api/ingestInCache.ts +33 -0
  333. package/src/cache/api/mergeInCache.ts +45 -0
  334. package/src/cache/api/pullFromCache.ts +33 -0
  335. package/src/cache/api/pushToCache.ts +40 -0
  336. package/src/cache/api/queryCache.ts +35 -0
  337. package/src/cache/api/restoreCache.ts +43 -0
  338. package/src/cache/api/snipeIdFromCollection.ts +53 -0
  339. package/src/cache/api/upsertInCache.ts +39 -0
  340. package/src/cache/api/wipeCache.ts +36 -0
  341. package/src/cache/utils/index.ts +84 -0
  342. package/src/category/api/getCategory.ts +3 -4
  343. package/src/category/api/queryCategories.ts +5 -6
  344. package/src/channel/api/addChannelMembers.ts +4 -5
  345. package/src/channel/api/addChannelMembersRole.ts +3 -5
  346. package/src/channel/api/createChannel.ts +16 -11
  347. package/src/channel/api/deleteChannel.ts +2 -2
  348. package/src/channel/api/getChannel.ts +22 -9
  349. package/src/channel/api/getChannels.ts +25 -12
  350. package/src/channel/api/joinChannel.ts +5 -6
  351. package/src/channel/api/leaveChannel.ts +5 -6
  352. package/src/channel/api/queryChannelMembers.ts +9 -11
  353. package/src/channel/api/queryChannels.ts +19 -12
  354. package/src/channel/api/removeChannelMembers.ts +4 -5
  355. package/src/channel/api/removeChannelMembersRole.ts +3 -5
  356. package/src/channel/api/updateChannel.ts +9 -7
  357. package/src/channel/events/onChannelDeleted.ts +1 -3
  358. package/src/channel/events/onChannelJoined.ts +1 -3
  359. package/src/channel/events/onChannelLeft.ts +1 -3
  360. package/src/channel/events/onChannelUpdated.ts +1 -3
  361. package/src/channel/events/onMemberAdded.ts +1 -3
  362. package/src/channel/events/onMemberRemoved.ts +1 -3
  363. package/src/channel/observers/observeChannel.ts +20 -14
  364. package/src/client/api/connectClient.ts +7 -7
  365. package/src/client/api/disconnectClient.ts +3 -0
  366. package/src/client/api/getToken.ts +3 -2
  367. package/src/client/api/index.ts +3 -2
  368. package/src/comment/api/createComment.ts +10 -7
  369. package/src/comment/api/deleteComment.ts +9 -8
  370. package/src/comment/api/getComment.ts +22 -10
  371. package/src/comment/api/getComments.ts +25 -12
  372. package/src/comment/api/queryComments.ts +35 -89
  373. package/src/comment/api/updateComment.ts +9 -6
  374. package/src/comment/events/onCommentCreated.ts +3 -3
  375. package/src/comment/events/onCommentDeleted.ts +3 -3
  376. package/src/comment/events/onCommentFlagged.ts +3 -3
  377. package/src/comment/events/onCommentReactionAdded.ts +40 -6
  378. package/src/comment/events/onCommentReactionRemoved.ts +40 -6
  379. package/src/comment/events/onCommentUnflagged.ts +3 -3
  380. package/src/comment/events/onCommentUpdated.ts +3 -3
  381. package/src/comment/events/utils.ts +30 -8
  382. package/src/comment/observers/observeComment.ts +20 -25
  383. package/src/community/api/addCommunityMembers.ts +5 -6
  384. package/src/community/api/addCommunityMembersRole.ts +3 -5
  385. package/src/community/api/createCommunity.ts +9 -6
  386. package/src/community/api/deleteCommunity.ts +3 -3
  387. package/src/community/api/getCommunities.ts +25 -12
  388. package/src/community/api/getCommunity.ts +23 -9
  389. package/src/community/api/joinCommunity.ts +7 -5
  390. package/src/community/api/leaveCommunity.ts +7 -5
  391. package/src/community/api/queryCommunities.ts +18 -12
  392. package/src/community/api/queryCommunityMembers.ts +10 -11
  393. package/src/community/api/removeCommunityMembers.ts +4 -5
  394. package/src/community/api/removeCommunityMembersRole.ts +3 -5
  395. package/src/community/api/updateCommunity.ts +10 -7
  396. package/src/community/events/onCommunityCreated.ts +1 -1
  397. package/src/community/events/onCommunityDeleted.ts +1 -1
  398. package/src/community/events/onCommunityJoined.ts +5 -5
  399. package/src/community/events/onCommunityLeft.ts +5 -5
  400. package/src/community/events/onCommunityUpdated.ts +1 -1
  401. package/src/community/events/onCommunityUserAdded.ts +5 -5
  402. package/src/community/events/onCommunityUserBanned.ts +5 -5
  403. package/src/community/events/onCommunityUserRemoved.ts +5 -5
  404. package/src/community/events/onCommunityUserUnbanned.ts +5 -5
  405. package/src/community/events/utils.ts +94 -4
  406. package/src/community/observers/observeCommunity.ts +21 -22
  407. package/src/core/model/idResolvers.ts +10 -40
  408. package/src/core/model/identifyModel.ts +37 -16
  409. package/src/core/model/index.ts +22 -2
  410. package/src/core/query/index.ts +0 -1
  411. package/src/core/query/paging.ts +43 -3
  412. package/src/core/query/query.ts +63 -115
  413. package/src/core/subscription.ts +66 -17
  414. package/src/core/transports/mqtt.ts +86 -20
  415. package/src/core/transports/ws.ts +1 -0
  416. package/src/feed/api/queryGlobalFeed.ts +7 -10
  417. package/src/file/api/createFile.ts +8 -6
  418. package/src/file/api/deleteFile.ts +5 -6
  419. package/src/file/api/getFile.ts +21 -9
  420. package/src/file/observers/observeFile.ts +5 -7
  421. package/src/index.ts +6 -6
  422. package/src/message/api/createMessage.ts +21 -17
  423. package/src/message/api/deleteMessage.ts +12 -11
  424. package/src/message/api/getMessage.ts +22 -10
  425. package/src/message/api/getMessages.ts +25 -12
  426. package/src/message/api/queryMessages.ts +34 -68
  427. package/src/message/api/updateMessage.ts +22 -12
  428. package/src/message/events/onMessageCreated.ts +1 -3
  429. package/src/message/events/onMessageDeleted.ts +1 -3
  430. package/src/message/events/onMessageUpdated.ts +1 -3
  431. package/src/message/observers/observeMessage.ts +8 -10
  432. package/src/message/observers/observeMessages.ts +6 -6
  433. package/src/post/api/createPost.ts +9 -6
  434. package/src/post/api/deletePost.ts +11 -9
  435. package/src/post/api/getPost.ts +26 -14
  436. package/src/post/api/getPosts.ts +27 -14
  437. package/src/post/api/queryPosts.ts +46 -19
  438. package/src/post/api/updatePost.ts +10 -6
  439. package/src/post/events/onPostApproved.ts +1 -1
  440. package/src/post/events/onPostCreated.ts +1 -1
  441. package/src/post/events/onPostDeclined.ts +1 -1
  442. package/src/post/events/onPostDeleted.ts +2 -2
  443. package/src/post/events/onPostFlagged.ts +1 -1
  444. package/src/post/events/onPostReactionAdded.ts +38 -4
  445. package/src/post/events/onPostReactionRemoved.ts +38 -4
  446. package/src/post/events/onPostUnflagged.ts +1 -1
  447. package/src/post/events/onPostUpdated.ts +1 -1
  448. package/src/post/events/utils.ts +39 -6
  449. package/src/post/observers/observePost.ts +22 -27
  450. package/src/reaction/api/addReaction.ts +30 -20
  451. package/src/reaction/api/removeReaction.ts +30 -20
  452. package/src/reaction/events/onReactionAdded.ts +37 -18
  453. package/src/reaction/events/onReactionRemoved.ts +38 -15
  454. package/src/reaction/utils/fetchReference.ts +1 -1
  455. package/src/reaction/utils/index.ts +1 -0
  456. package/src/reaction/utils/preparePayloadForCache.ts +45 -0
  457. package/src/report/api/createReport.ts +4 -5
  458. package/src/report/api/deleteReport.ts +4 -5
  459. package/src/role/api/getRole.ts +25 -9
  460. package/src/role/api/queryRoles.ts +10 -12
  461. package/src/stream/api/createStream.ts +9 -6
  462. package/src/stream/api/deleteStream.ts +10 -1
  463. package/src/stream/api/disposeStream.ts +10 -6
  464. package/src/stream/api/getStream.ts +23 -10
  465. package/src/stream/api/queryStreams.ts +10 -11
  466. package/src/stream/api/updateStream.ts +9 -6
  467. package/src/stream/events/onStreamRecorded.ts +1 -3
  468. package/src/stream/events/onStreamStarted.ts +1 -3
  469. package/src/stream/events/onStreamStopped.ts +1 -3
  470. package/src/user/api/getUser.ts +14 -11
  471. package/src/user/api/getUsers.ts +30 -14
  472. package/src/user/api/queryUsers.ts +40 -17
  473. package/src/user/api/updateUser.ts +10 -7
  474. package/src/user/events/onUserFlagCleared.ts +1 -1
  475. package/src/user/events/onUserFlagged.ts +1 -1
  476. package/src/user/events/onUserUnflagged.ts +1 -1
  477. package/src/user/events/onUserUpdated.ts +1 -1
  478. package/src/user/events/utils.ts +6 -4
  479. package/src/user/observers/observeUser.ts +9 -11
  480. package/dist/@types/core/store.d.ts +0 -46
  481. package/dist/@types/core/store.d.ts.map +0 -1
  482. package/dist/client/api/clearCache.d.ts +0 -15
  483. package/dist/client/api/clearCache.d.ts.map +0 -1
  484. package/dist/client/api/enableCache.d.ts +0 -15
  485. package/dist/client/api/enableCache.d.ts.map +0 -1
  486. package/dist/core/cache/drop.d.ts +0 -11
  487. package/dist/core/cache/drop.d.ts.map +0 -1
  488. package/dist/core/cache/index.d.ts +0 -19
  489. package/dist/core/cache/index.d.ts.map +0 -1
  490. package/dist/core/cache/ingest.d.ts +0 -10
  491. package/dist/core/cache/ingest.d.ts.map +0 -1
  492. package/dist/core/cache/merge.d.ts +0 -10
  493. package/dist/core/cache/merge.d.ts.map +0 -1
  494. package/dist/core/cache/mutate.d.ts +0 -10
  495. package/dist/core/cache/mutate.d.ts.map +0 -1
  496. package/dist/core/cache/pull.d.ts +0 -11
  497. package/dist/core/cache/pull.d.ts.map +0 -1
  498. package/dist/core/cache/push.d.ts +0 -10
  499. package/dist/core/cache/push.d.ts.map +0 -1
  500. package/dist/core/cache/sync.d.ts +0 -10
  501. package/dist/core/cache/sync.d.ts.map +0 -1
  502. package/dist/core/model/toRecord.d.ts +0 -10
  503. package/dist/core/model/toRecord.d.ts.map +0 -1
  504. package/dist/core/query/decorate.d.ts +0 -23
  505. package/dist/core/query/decorate.d.ts.map +0 -1
  506. package/dist/core/stores/index.d.ts +0 -3
  507. package/dist/core/stores/index.d.ts.map +0 -1
  508. package/dist/core/stores/memory.d.ts +0 -30
  509. package/dist/core/stores/memory.d.ts.map +0 -1
  510. package/dist/core/stores/persistent.d.ts +0 -13
  511. package/dist/core/stores/persistent.d.ts.map +0 -1
  512. package/src/@types/core/store.ts +0 -52
  513. package/src/client/api/clearCache.ts +0 -23
  514. package/src/client/api/enableCache.ts +0 -36
  515. package/src/core/cache/drop.ts +0 -24
  516. package/src/core/cache/index.ts +0 -24
  517. package/src/core/cache/ingest.ts +0 -24
  518. package/src/core/cache/merge.ts +0 -19
  519. package/src/core/cache/mutate.ts +0 -25
  520. package/src/core/cache/pull.ts +0 -31
  521. package/src/core/cache/push.ts +0 -41
  522. package/src/core/cache/sync.ts +0 -41
  523. package/src/core/model/toRecord.ts +0 -11
  524. package/src/core/query/decorate.ts +0 -64
  525. package/src/core/stores/index.ts +0 -2
  526. package/src/core/stores/memory.ts +0 -59
  527. package/src/core/stores/persistent.ts +0 -63
package/dist/index.umd.js CHANGED
@@ -1,7 +1,9 @@
1
- var Amity=function(e,t,n,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i,s=o(t),a=o(n),c=o(r);const l=null!==(i="v0.0.1-beta.7-umd")?i:"__dev__";class u 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,u)}}class p extends u{constructor(e,t,n){super(e,t,n)}}class d extends u{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class f extends u{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let h=null;const m=()=>{if(!h)throw new u("There is no active client",8e5,"fatal");return h},g=e=>{h=e},y=(e,...t)=>{var n;const{cache:r}=m(),o=null==r?void 0:r[e];if(!r||!o)return;const i=null!==(n=o.read())&&void 0!==n?n:{};return(null==t?void 0:t.length)?t.map((t=>{const n=r.lookup[`${e}#${t}`];return i[n]})).filter(Boolean):Object.values(i)},b={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,stream:({streamId:e})=>e},v=e=>b[e],w={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",videoStreamings:"stream"},_=(e,...t)=>{const{cache:n}=m(),r=null==n?void 0:n[e];if(!n||!r)return;const o=t.filter(Boolean);if(!o.length)return;const i=Object.fromEntries(o.map((t=>{var r,o,i;const s=v(e)(t),a=null!==(r=(o=n.lookup)[i=`${e}#${s}`])&&void 0!==r?r:o[i]=t.localId;return[a,Object.assign(Object.assign({syncedAt:Date.now()},t),{localId:a})]})));r.write(i)},C=(e,t)=>{const{cache:n}=m(),r=null==n?void 0:n[e];if(!n||!r)return[];const o=v(e)(t),i=n.lookup[`${e}#${o}`];delete n.lookup[`${e}#${o}`],r.erase(i)},S={file:["fileId","attributes"],user:["userId","avatarFileId"],role:["roleId"],channel:["channelId","rateLimit"],channelUsers:["channelId","userId","membership"],message:["messageId"],community:["communityId","onlyAdminCanPost"],communityUsers:["userId","communityId","communityMembership"],post:["postId","feedId"],comment:["commentId","referenceId"],stream:["streamId"]},k=e=>{var t;return null===(t=Object.entries(S).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]},E=(e,t)=>{var n;const{cache:r,log:o}=m(),i=null!==(n=k(e))&&void 0!==n?n:k(t);if(!i)return void o("syncInCache","could not identify the models",{original:e,replacement:t});const s=null==r?void 0:r[i];r&&s&&(C(i,e),C(i,t),t.localId=e.localId,_(i,t))},R=(e={},t=Object.keys(e))=>{t.forEach((t=>{const n=w[t];n&&_(n,...e[t])}))},I=(e,t,n)=>{var r;const[o]=null!==(r=y(e,t))&&void 0!==r?r:[];if(!o)return;const i=n(o);return i&&_(e,Object.assign(Object.assign({},o),i)),i},A=(e,t)=>{const n=v(e)(t);I(e,n,(e=>Object.assign(Object.assign({},e),t)))},O=e=>Object.assign({lookup:{}},e),x="function"==typeof atob,T="function"==typeof btoa,P="function"==typeof Buffer,B="function"==typeof TextDecoder?new TextDecoder:void 0,M="function"==typeof TextEncoder?new TextEncoder:void 0,F=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],N=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(F),j=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,U=String.fromCharCode.bind(String),L="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),D=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),q=T?e=>btoa(e):P?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+=F[t>>18&63]+F[t>>12&63]+F[t>>6&63]+F[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},$=P?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(U.apply(null,e.subarray(n,n+4096)));return q(t.join(""))},H=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?U(192|t>>>6)+U(128|63&t):U(224|t>>>12&15)+U(128|t>>>6&63)+U(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return U(240|t>>>18&7)+U(128|t>>>12&63)+U(128|t>>>6&63)+U(128|63&t)},W=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,V=P?e=>Buffer.from(e,"utf8").toString("base64"):M?e=>$(M.encode(e)):e=>q(e.replace(W,H)),K=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,z=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 U(55296+(t>>>10))+U(56320+(1023&t));case 3:return U((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return U((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},J=x?e=>atob(D(e)):P?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!j.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=N[e.charAt(i++)]<<18|N[e.charAt(i++)]<<12|(n=N[e.charAt(i++)])<<6|(r=N[e.charAt(i++)]),o+=64===n?U(t>>16&255):64===r?U(t>>16&255,t>>8&255):U(t>>16&255,t>>8&255,255&t);return o},Q=P?e=>L(Buffer.from(e,"base64")):e=>L(J(e),(e=>e.charCodeAt(0))),X=P?e=>Buffer.from(e,"base64").toString("utf8"):B?e=>B.decode(Q(e)):e=>J(e).replace(K,z),Y=e=>X(D(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),G=e=>["skip","limit"].some((t=>t in e)),Z=e=>["after","before","first","last"].some((t=>t in e)),ee=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),te=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t&&(isNaN(null==e?void 0:e.before)?isNaN(null==e?void 0:e.after)||(r={after:e.after,first:e.limit}):r={before:e.before,last:e.limit}),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/[+\/]/g,(e=>"+"==e?"-":"_")).replace(/=+$/m,""))(V(e)):V(e))(JSON.stringify(r)):void 0},ne=e=>{if(!e)return null;const t=JSON.parse(Y(e));if(G(t))return{after:t.skip,limit:t.limit};if(Z(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}return null},re=e=>"locally"in e,oe=e=>"optimistically"in e,ie=e=>re(e)||oe(e),se=e=>null==e?void 0:e.hasOwnProperty("syncedAt"),ae=e=>se(e)&&-1===(null==e?void 0:e.syncedAt),ce=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.syncedAt)&&void 0!==n?n:0)<=t},le=(e,t=0)=>ae(e)||ce(e,t),ue=(e,...t)=>({func:e,args:t}),pe=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},de=e=>!e||(!(!ee(e)||!de(e.data))||!Object.keys(e).length),fe=(e,t)=>!(!ee(e)||!fe(e.data,t))||(!!le(e,t.lifeSpan)||!!(Object.values(e).length>0&&Object.values(e).every((e=>le(e,t.lifeSpan))))),he=({func:e,args:t},n,r=pe("cache_then_server"))=>{if(!ie(e)||0===r.lifeSpan)return null==n||n(me(void 0,{origin:"server",loading:!0})),void e(...t).then((e=>{null==n||n(me(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(me(void 0,{error:e,loading:!1}))}));const o=oe(e)?e.optimistically(...t):e.locally(...t);de(o)||null==n||n(me(o,{origin:"local"})),o&&re(e)&&fe(o,r)||(null==n||n(me(o,{origin:"local",loading:!0})),e(...t).then((e=>{ae(o)&&E(o,e),null==n||n(me(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(me(o,{error:e,loading:!1}))})))},me=(e,t={})=>ee(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e});var ge="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ye(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}var be={},ve={},we={};Object.defineProperty(we,"__esModule",{value:!0}),we.bytesToString=we.stringToBytes=we.NIL=we.X500=we.OID=we.URL=we.DNS=we.hexToByte=we.byteToHex=void 0;let _e=[],Ce={};for(var Se=0;Se<256;Se++)_e[Se]=(Se+256).toString(16).substr(1),Ce[_e[Se]]=Se;we.byteToHex=_e,we.hexToByte=Ce,we.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",we.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",we.OID="6ba7b812-9dad-11d1-80b4-00c04fd430c8",we.X500="6ba7b814-9dad-11d1-80b4-00c04fd430c8",we.NIL="00000000-0000-0000-0000-000000000000";we.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};we.bytesToString=e=>{const t=new Uint8Array(e,0,e.byteLength);return String.fromCharCode.apply(null,Array.from(t))},Object.defineProperty(ve,"__esModule",{value:!0}),ve.parse=void 0;const ke=we;ve.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++]=ke.hexToByte[e]),"")));o<16;)t[r+o++]=0;return t};var Ee={};Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.unparse=void 0;const Re=we;Ee.unparse=(e,t)=>{let n=t||0,r=Re.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 Ie={},Ae={};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.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 Oe=ge&&ge.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.validate=void 0;const xe=Oe(Ae);Ie.validate=e=>"string"==typeof e&&xe.default.test(e);var Te={};Object.defineProperty(Te,"__esModule",{value:!0}),Te.version=void 0;const Pe=Ie;Te.version=e=>{if(!Pe.validate(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)};var Be={},Me={};Object.defineProperty(Me,"__esModule",{value:!0}),Me.stringify=void 0;const Fe=Ie,Ne=[];for(let e=0;e<256;++e)Ne.push((e+256).toString(16).substr(1));Me.stringify=(e,t=0)=>{const n=(Ne[e[t+0]]+Ne[e[t+1]]+Ne[e[t+2]]+Ne[e[t+3]]+"-"+Ne[e[t+4]]+Ne[e[t+5]]+"-"+Ne[e[t+6]]+Ne[e[t+7]]+"-"+Ne[e[t+8]]+Ne[e[t+9]]+"-"+Ne[e[t+10]]+Ne[e[t+11]]+Ne[e[t+12]]+Ne[e[t+13]]+Ne[e[t+14]]+Ne[e[t+15]]).toLowerCase();if(!Fe.validate(n))throw TypeError("Stringified UUID is invalid");return n};var je={};Object.defineProperty(je,"__esModule",{value:!0}),je.rng=void 0;je.rng=()=>{let e=new Array(16);for(let t=0;t<16;t++)e[t]=255&256*Math.random()+0;return e},Object.defineProperty(Be,"__esModule",{value:!0}),Be.v1=void 0;const Ue=Me,Le=je;let De,qe,$e=0,He=0;Be.v1=(e,t,n=0)=>{let r=t&&n||0;const o=t||new Uint8Array(16);let i=e&&e.node?e.node:De,s=e&&e.clockseq?e.clockseq:qe;if(null==i||null==s){const t=e&&e.random?e.random:e&&e.rng?e.rng():Le.rng();null==i&&(i=De=[1|t[0],t[1],t[2],t[3],t[4],t[5]]),null==s&&(s=qe=16383&(t[6]<<8|t[7]))}let a=e&&e.msecs?e.msecs:Date.now(),c=e&&e.nsecs?e.nsecs:He+1;const l=a-$e+(c-He)/1e4;if(l<0&&e&&!e.clockseq&&(s=s+1&16383),(l<0||a>$e)&&e&&!e.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");$e=a,He=c,qe=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 p=a/4294967296*1e4&268435455;o[r++]=p>>>8&255,o[r++]=255&p,o[r++]=p>>>24&15|16,o[r++]=p>>>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||Ue.stringify(o)};var We={};Object.defineProperty(We,"__esModule",{value:!0}),We.v4=void 0;const Ve=Ee,Ke=je;We.v4=(e,t,n)=>{let r=t&&n||0,o=Ke.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||Ve.unparse(o)};var ze={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.v35=void 0;const Qe=Me,Xe=ve,Ye=we;Je.v35=(e,t,n)=>(e,r,o,i=0)=>{if("string"==typeof e&&(e=Ye.stringToBytes(e)),"string"==typeof r&&(r=Xe.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=Ye.stringToBytes(n(Ye.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||Qe.stringify(s)};var Ge={};!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(p(l(e),8*e.length)),o=(e,t)=>{let n=l(e);n.length>16&&(n=p(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=p(r.concat(l(t)),512+8*t.length);return u(p(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},p=(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,p=i,g=s,y=a,b=0;b<80;b++){n[b]=b<16?e[c+b]:m(n[b-3]^n[b-8]^n[b-14]^n[b-16],1);let t=h(h(m(r,5),d(b,o,i,s)),h(h(a,n[b]),f(b)));a=s,s=i,i=m(o,30),o=r,r=t}r=h(r,l),o=h(o,u),i=h(i,p),s=h(s,g),a=h(a,y)}return[r,o,i,s,a]},d=(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,f=e=>e<20?1518500249:e<40?1859775393:e<60?-1894007588:-899497514,h=(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}(Ge);var Ze=ge&&ge.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ze,"__esModule",{value:!0}),ze.v5=void 0;const et=Je,tt=Ze(Ge);ze.v5=et.v35("v5",80,tt.default),Object.defineProperty(be,"__esModule",{value:!0});const nt=ve,rt=Ee,ot=Ie,it=Te,st=Be,at=We,ct=ze,lt=we;var ut=be.default={parse:nt.parse,unparse:rt.unparse,validate:ot.validate,version:it.version,v1:st.v1,v4:at.v4,v5:ct.v5,NIL:lt.NIL,DNS:lt.DNS,URL:lt.URL,OID:lt.OID,X500:lt.X500};const pt=()=>ut.v4().toString();var dt={exports:{}},ft=1e3,ht=6e4,mt=60*ht,gt=24*mt,yt=7*gt,bt=365.25*gt,vt=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*bt;case"weeks":case"week":case"w":return n*yt;case"days":case"day":case"d":return n*gt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*mt;case"minutes":case"minute":case"mins":case"min":case"m":return n*ht;case"seconds":case"second":case"secs":case"sec":case"s":return n*ft;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=gt)return wt(e,t,gt,"day");if(t>=mt)return wt(e,t,mt,"hour");if(t>=ht)return wt(e,t,ht,"minute");if(t>=ft)return wt(e,t,ft,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=gt)return Math.round(e/gt)+"d";if(t>=mt)return Math.round(e/mt)+"h";if(t>=ht)return Math.round(e/ht)+"m";if(t>=ft)return Math.round(e/ft)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function wt(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var _t=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=vt,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=_t(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(dt,dt.exports);var Ct=dt.exports;const St="sg";var kt;!function(e){e.HTTP="https://api.{region}.amity.co",e.MQTT="wss://sse.{region}.amity.co:443/mqtt"}(kt||(kt={}));const Et=(e,t)=>e.replace("{region}",t);var Rt={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)}},At=It,Ot=Object.prototype.toString;function xt(e){return"[object Array]"===Ot.call(e)}function Tt(e){return void 0===e}function Pt(e){return null!==e&&"object"==typeof e}function Bt(e){if("[object Object]"!==Ot.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Mt(e){return"[object Function]"===Ot.call(e)}function Ft(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),xt(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 Nt={isArray:xt,isArrayBuffer:function(e){return"[object ArrayBuffer]"===Ot.call(e)},isBuffer:function(e){return null!==e&&!Tt(e)&&null!==e.constructor&&!Tt(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:Pt,isPlainObject:Bt,isUndefined:Tt,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:Mt,isStream:function(e){return Pt(e)&&Mt(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:Ft,merge:function e(){var t={};function n(n,r){Bt(t[r])&&Bt(n)?t[r]=e(t[r],n):Bt(n)?t[r]=e({},n):xt(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)Ft(arguments[r],n);return t},extend:function(e,t,n){return Ft(t,(function(t,r){e[r]=n&&"function"==typeof t?At(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}},jt=Nt;function Ut(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Lt=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(jt.isURLSearchParams(t))r=t.toString();else{var o=[];jt.forEach(t,(function(e,t){null!=e&&(jt.isArray(e)?t+="[]":e=[e],jt.forEach(e,(function(e){jt.isDate(e)?e=e.toISOString():jt.isObject(e)&&(e=JSON.stringify(e)),o.push(Ut(t)+"="+Ut(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Dt=Nt;function qt(){this.handlers=[]}qt.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},qt.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},qt.prototype.forEach=function(e){Dt.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var $t=qt,Ht=Nt,Wt=function(e){return!(!e||!e.__CANCEL__)},Vt=Nt,Kt=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},zt=function(e,t,n,r,o){var i=new Error(e);return Kt(i,t,n,r,o)},Jt=zt,Qt=Nt,Xt=Qt.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),Qt.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),Qt.isString(r)&&s.push("path="+r),Qt.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Yt=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Gt=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Zt=Nt,en=["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"],tn=Nt,nn=tn.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=tn.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},rn=Nt,on=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(Jt("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},sn=Xt,an=Lt,cn=function(e,t){return e&&!Yt(t)?Gt(e,t):t},ln=function(e){var t,n,r,o={};return e?(Zt.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=Zt.trim(e.substr(0,r)).toLowerCase(),n=Zt.trim(e.substr(r+1)),t){if(o[t]&&en.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},un=nn,pn=zt,dn=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;rn.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(s+":"+a)}var c=cn(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),an(c,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in i?ln(i.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:r,config:e,request:i};on(t,n,o),i=null}},i.onabort=function(){i&&(n(pn("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(pn("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(pn(t,e,"ECONNABORTED",i)),i=null},rn.isStandardBrowserEnv()){var l=(e.withCredentials||un(c))&&e.xsrfCookieName?sn.read(e.xsrfCookieName):void 0;l&&(o[e.xsrfHeaderName]=l)}if("setRequestHeader"in i&&rn.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),rn.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),n(e),i=null)})),r||(r=null),i.send(r)}))},fn=Nt,hn=function(e,t){Vt.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},mn={"Content-Type":"application/x-www-form-urlencoded"};function gn(e,t){!fn.isUndefined(e)&&fn.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var yn,bn={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(yn=dn),yn),transformRequest:[function(e,t){return hn(t,"Accept"),hn(t,"Content-Type"),fn.isFormData(e)||fn.isArrayBuffer(e)||fn.isBuffer(e)||fn.isStream(e)||fn.isFile(e)||fn.isBlob(e)?e:fn.isArrayBufferView(e)?e.buffer:fn.isURLSearchParams(e)?(gn(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):fn.isObject(e)?(gn(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}};bn.headers={common:{Accept:"application/json, text/plain, */*"}},fn.forEach(["delete","get","head"],(function(e){bn.headers[e]={}})),fn.forEach(["post","put","patch"],(function(e){bn.headers[e]=fn.merge(mn)}));var vn=bn,wn=Nt,_n=function(e,t,n){return Ht.forEach(n,(function(n){e=n(e,t)})),e},Cn=Wt,Sn=vn;function kn(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var En=Nt,Rn=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 En.isPlainObject(e)&&En.isPlainObject(t)?En.merge(e,t):En.isPlainObject(t)?En.merge({},t):En.isArray(t)?t.slice():t}function c(r){En.isUndefined(t[r])?En.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}En.forEach(r,(function(e){En.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),En.forEach(o,c),En.forEach(i,(function(r){En.isUndefined(t[r])?En.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),En.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 En.forEach(u,c),n},In=Nt,An=Lt,On=$t,xn=function(e){return kn(e),e.headers=e.headers||{},e.data=_n(e.data,e.headers,e.transformRequest),e.headers=wn.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),wn.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Sn.adapter)(e).then((function(t){return kn(e),t.data=_n(t.data,t.headers,e.transformResponse),t}),(function(t){return Cn(t)||(kn(e),t&&t.response&&(t.response.data=_n(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Tn=Rn;function Pn(e){this.defaults=e,this.interceptors={request:new On,response:new On}}Pn.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Tn(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[xn,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},Pn.prototype.getUri=function(e){return e=Tn(this.defaults,e),An(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},In.forEach(["delete","get","head","options"],(function(e){Pn.prototype[e]=function(t,n){return this.request(Tn(n||{},{method:e,url:t,data:(n||{}).data}))}})),In.forEach(["post","put","patch"],(function(e){Pn.prototype[e]=function(t,n,r){return this.request(Tn(r||{},{method:e,url:t,data:n}))}}));var Bn=Pn;function Mn(e){this.message=e}Mn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Mn.prototype.__CANCEL__=!0;var Fn=Mn,Nn=Fn;function jn(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new Nn(e),t(n.reason))}))}jn.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},jn.source=function(){var e;return{token:new jn((function(t){e=t})),cancel:e}};var Un=jn,Ln=Nt,Dn=It,qn=Bn,$n=Rn;function Hn(e){var t=new qn(e),n=Dn(qn.prototype.request,t);return Ln.extend(n,qn.prototype,t),Ln.extend(n,t),n}var Wn=Hn(vn);Wn.Axios=qn,Wn.create=function(e){return Hn($n(Wn.defaults,e))},Wn.Cancel=Fn,Wn.CancelToken=Un,Wn.isCancel=Wt,Wn.all=function(e){return Promise.all(e)},Wn.spread=function(e){return function(t){return e.apply(null,t)}},Wn.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},Rt.exports=Wn,Rt.exports.default=Wn;var Vn=Rt.exports,Kn={exports:{}};Kn.exports=Jn;var zn=Kn.exports.HttpsAgent=Jn;function Jn(){}var Qn=Kn.exports;const Xn=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new d(e.code);if("error"===e.status)throw new p(e.message,e.code,"error")},Yn=(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}`:Yn(n,null!=t?t:e)})).join("&");var Gn={exports:{}},Zn=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,er=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],tr=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=Zn.exec(e||""),i={},s=14;s--;)i[er[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},nr={exports:{}},rr={exports:{}},or=1e3,ir=60*or,sr=60*ir,ar=24*sr,cr=365.25*ar,lr=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*cr;case"days":case"day":case"d":return n*ar;case"hours":case"hour":case"hrs":case"hr":case"h":return n*sr;case"minutes":case"minute":case"mins":case"min":case"m":return n*ir;case"seconds":case"second":case"secs":case"sec":case"s":return n*or;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 ur(e,ar,"day")||ur(e,sr,"hour")||ur(e,ir,"minute")||ur(e,or,"second")||e+" ms"}(e):function(e){if(e>=ar)return Math.round(e/ar)+"d";if(e>=sr)return Math.round(e/sr)+"h";if(e>=ir)return Math.round(e/ir)+"m";if(e>=or)return Math.round(e/or)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ur(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=lr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(rr,rr.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=rr.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())}(nr,nr.exports);var pr=tr,dr=nr.exports("socket.io-client:url"),fr=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)||(dr("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),dr("parse %s",e),n=pr(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 hr={},mr={exports:{}},gr={exports:{}};!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var 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=lr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(gr,gr.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=gr.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())}(mr,mr.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 br={},vr={}.toString,wr=Array.isArray||function(e){return"[object Array]"==vr.call(e)},_r=function(e){return Cr&&Buffer.isBuffer(e)||Sr&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},Cr="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,Sr="function"==typeof ArrayBuffer;var kr=wr,Er=_r,Rr=Object.prototype.toString,Ir="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Rr.call(Blob),Ar="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Rr.call(File);function Or(e,t){if(!e)return e;if(Er(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(kr(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=Or(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=Or(e[i],t);return r}return e}function xr(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(kr(e))for(var n=0;n<e.length;n++)e[n]=xr(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=xr(e[r],t);return e}br.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=Or(n,t),r.attachments=t.length,{packet:r,buffers:t}},br.reconstructPacket=function(e,t){return e.data=xr(e.data,t),e.attachments=void 0,e},br.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(Ir&&o instanceof Blob||Ar&&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(kr(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!Er(o))for(var l in o)e(o[l],l,o)}(r),n||t(r)},function(e){var t=mr.exports("socket.io-parser"),n=yr.exports,r=br,o=wr,i=_r;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 p(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 p("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 p("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=[]}}(hr);var Tr={exports:{}},Pr={},Br={exports:{}};try{Br.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){Br.exports=!1}var Mr=Br.exports,Fr=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Mr))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){}},Nr={exports:{}},jr={},Ur=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},Lr={}.toString,Dr=Array.isArray||function(e){return"[object Array]"==Lr.call(e)},qr=Object.prototype.toString,$r="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===qr.call(Blob),Hr="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===qr.call(File),Wr=function e(t){if(!t||"object"!=typeof t)return!1;if(Dr(t)){for(var n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||$r&&t instanceof Blob||Hr&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&e(t[o]))return!0;return!1};var Vr=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},Kr=function(e,t,n){var r=!1;return n=n||zr,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 zr(){}
2
- /*! https://mths.be/utf8js v2.1.2 by @mathias */var Jr,Qr,Xr,Yr=String.fromCharCode;function Gr(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 Zr(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 eo(e,t){return Yr(e>>t&63|128)}function to(e,t){if(0==(4294967168&e))return Yr(e);var n="";return 0==(4294965248&e)?n=Yr(e>>6&31|192):0==(4294901760&e)?(Zr(e,t)||(e=65533),n=Yr(e>>12&15|224),n+=eo(e,6)):0==(4292870144&e)&&(n=Yr(e>>18&7|240),n+=eo(e,12),n+=eo(e,6)),n+=Yr(63&e|128)}function no(){if(Xr>=Qr)throw Error("Invalid byte index");var e=255&Jr[Xr];if(Xr++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function ro(e){var t,n;if(Xr>Qr)throw Error("Invalid byte index");if(Xr==Qr)return!1;if(t=255&Jr[Xr],Xr++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|no())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|no()<<6|no())>=2048)return Zr(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|no()<<12|no()<<6|no())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var oo={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Gr(e),o=r.length,i=-1,s="";++i<o;)s+=to(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;Jr=Gr(e),Qr=Jr.length,Xr=0;for(var r,o=[];!1!==(r=ro(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=Yr((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Yr(t);return o}(o)}},io={};!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=new Uint8Array(256),n=0;n<e.length;n++)t[e.charCodeAt(n)]=n;io.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},io.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),p=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)],p[l++]=r<<2|o>>4,p[l++]=(15&o)<<4|i>>2,p[l++]=(3&i)<<6|63&s;return u}}();var so=void 0!==so?so:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,ao=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),co=ao&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),lo=so&&so.prototype.append&&so.prototype.getBlob;function uo(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 po(e,t){t=t||{};var n=new so;return uo(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function fo(e,t){return new Blob(uo(e),t||{})}"undefined"!=typeof Blob&&(po.prototype=Blob.prototype,fo.prototype=Blob.prototype);var ho=ao?co?Blob:fo:lo?po:void 0;!function(e){var t,n=Ur,r=Wr,o=Vr,i=Kr,s=oo;"undefined"!=typeof ArrayBuffer&&(t=io);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},p=n(u),d={type:"error",data:"parser error"},f=ho;function h(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!==f&&i instanceof f)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 f([o.buffer,t.data]);return r(i)}(t,n,o);if(i&&i.base64)return function(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}(t,o);var a=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!==f&&t.data instanceof f){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(t.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];r=String.fromCharCode.apply(null,a)}return o+=btoa(r),n(o)},e.decodePacket=function(t,n,r){if(void 0===t)return 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=s.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return d;var i=t.charAt(0);return Number(i)==i&&p[i]?t.length>1?{type:p[i],data:t.substring(1)}:{type:p[i]}:d}i=new Uint8Array(t)[0];var a=o(t,1);return f&&"blob"===n&&(a=new f([a])),{type:p[i],data:a}},e.decodeBase64Packet=function(e,n){var r=p[e.charAt(0)];if(!t)return{type:r,data:{base64:!0,data:e.substr(1)}};var o=t.decode(e.substr(1));return"blob"===n&&f&&(o=new f([o])),{type:r,data:o}},e.encodePayload=function(t,n,o){"function"==typeof n&&(o=n,n=null);var i=r(t);if(n&&i)return f&&!l?e.encodePayloadAsBlob(t,o):e.encodePayloadAsArrayBuffer(t,o);if(!t.length)return o("0:");h(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(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));h(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){h(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);e=r.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,f){var a=new f([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new f(t))}))},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var i=t,s=[];i.byteLength>0;){for(var a=new Uint8Array(i),c=0===a[0],l="",u=1;255!==a[u];u++){if(l.length>310)return r(d,0,1);l+=a[u]}i=o(i,2+l.length),l=parseInt(l);var p=o(i,0,l);if(c)try{p=String.fromCharCode.apply(null,new Uint8Array(p))}catch(e){var f=new Uint8Array(p);p="";for(u=0;u<f.length;u++)p+=String.fromCharCode(f[u])}s.push(p),i=o(i,l)}var h=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,h)}))}}(jr);var mo={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}}(mo);var go=jr,yo=bo;function bo(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}(0,mo.exports)(bo.prototype),bo.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},bo.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},bo.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},bo.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},bo.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},bo.prototype.onData=function(e){var t=go.decodePacket(e,this.socket.binaryType);this.onPacket(t)},bo.prototype.onPacket=function(e){this.emit("packet",e)},bo.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var vo,wo={encode:function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},decode:function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},_o=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},Co="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),So={},ko=0,Eo=0;function Ro(e){var t="";do{t=Co[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Io(){var e=Ro(+new Date);return e!==vo?(ko=0,vo=e):e+"."+Ro(ko++)}for(;Eo<64;Eo++)So[Co[Eo]]=Eo;Io.encode=Ro,Io.decode=function(e){var t=0;for(Eo=0;Eo<e.length;Eo++)t=64*t+So[e.charAt(Eo)];return t};var Ao=Io,Oo={exports:{}},xo={exports:{}};!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var 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=lr,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(xo,xo.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=xo.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())}(Oo,Oo.exports);var To=yo,Po=wo,Bo=jr,Mo=_o,Fo=Ao,No=Oo.exports("engine.io-client:polling"),jo=Lo,Uo=null!=new Fr({xdomain:!1}).responseType;function Lo(e){var t=e&&e.forceBase64;Uo&&!t||(this.supportsBinary=!1),To.call(this,e)}Mo(Lo,To),Lo.prototype.name="polling",Lo.prototype.doOpen=function(){this.poll()},Lo.prototype.pause=function(e){var t=this;function n(){No("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(No("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){No("pre-pause polling complete"),--r||n()}))),this.writable||(No("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){No("pre-pause writing complete"),--r||n()})))}else n()},Lo.prototype.poll=function(){No("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},Lo.prototype.onData=function(e){var t=this;No("polling got data %s",e);Bo.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():No('ignoring poll - transport state "%s"',this.readyState))},Lo.prototype.doClose=function(){var e=this;function t(){No("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(No("transport open - closing"),t()):(No("transport not open - deferring close"),this.once("open",t))},Lo.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};Bo.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},Lo.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=Fo()),this.supportsBinary||e.sid||(e.b64=1),e=Po.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 Do=Fr,qo=jo,$o=mo.exports,Ho=_o,Wo=Oo.exports("engine.io-client:polling-xhr");function Vo(){}function Ko(e){if(qo.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 zo(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(Nr.exports=Ko,Nr.exports.Request=zo,Ho(Ko,qo),Ko.prototype.supportsBinary=!0,Ko.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 zo(e)},Ko.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},Ko.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},$o(zo.prototype),zo.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 Do(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=!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))},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=zo.requestsCount++,zo.requests[this.index]=this)},zo.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},zo.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},zo.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},zo.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Vo:this.xhr.onreadystatechange=Vo,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete zo.requests[this.index],this.xhr=null}},zo.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)},zo.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},zo.prototype.abort=function(){this.cleanup()},zo.requestsCount=0,zo.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Qo);else if("function"==typeof addEventListener){var Jo="onpagehide"in self?"pagehide":"unload";addEventListener(Jo,Qo,!1)}function Qo(){for(var e in zo.requests)zo.requests.hasOwnProperty(e)&&zo.requests[e].abort()}var Xo,Yo=jo,Go=ri,Zo=/\n/g,ei=/\\n/g;function ti(){}function ni(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==ge?ge:{}}function ri(e){if(Yo.call(this,e),this.query=this.query||{},!Xo){var t=ni();Xo=t.___eio=t.___eio||[]}this.index=Xo.length;var n=this;Xo.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=ti)}),!1)}_o(ri,Yo),ri.prototype.supportsBinary=!1,ri.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),Yo.prototype.doClose.call(this)},ri.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)},ri.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(ei,"\\\n"),this.area.value=e.replace(Zo,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var oi,ii,si=ye(Object.freeze({__proto__:null,default:{}})),ai=yo,ci=jr,li=wo,ui=_o,pi=Ao,di=Oo.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)oi=WebSocket;else if("undefined"!=typeof self)oi=self.WebSocket||self.MozWebSocket;else try{ii=si}catch(e){}var fi=oi||ii,hi=mi;function mi(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=oi&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(fi=ii),ai.call(this,e)}ui(mi,ai),mi.prototype.name="websocket",mi.prototype.supportsBinary=!0,mi.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 fi(e,t):new fi(e):new fi(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()}},mi.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)}},mi.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){ci.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){di("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},mi.prototype.onClose=function(){ai.prototype.onClose.call(this)},mi.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},mi.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]=pi()),this.supportsBinary||(e.b64=1),(e=li.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},mi.prototype.check=function(){return!(!fi||"__initialize"in fi&&this.name===mi.prototype.name)};var gi=Fr,yi=Nr.exports,bi=Go,vi=hi;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 gi(e)&&!e.forceJSONP)return new yi(e);if(!r)throw new Error("JSONP disabled");return new bi(e)},Pr.websocket=vi;var wi=[].indexOf,_i=function(e,t){if(wi)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},Ci=Pr,Si=mo.exports,ki=Oo.exports("engine.io-client:socket"),Ei=_i,Ri=jr,Ii=tr,Ai=wo,Oi=xi;function xi(e,t){if(!(this instanceof xi))return new xi(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=Ai.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()}xi.priorWebsocketSuccess=!1,Si(xi.prototype),xi.protocol=Ri.protocol,xi.Socket=xi,xi.Transport=yo,xi.transports=Pr,xi.parser=jr,xi.prototype.createTransport=function(e){ki('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=Ri.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new Ci[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})},xi.prototype.open=function(){var e;if(this.rememberUpgrade&&xi.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)},xi.prototype.setTransport=function(e){ki("setting transport %s",e.name);var t=this;this.transport&&(ki("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")}))},xi.prototype.probe=function(e){ki('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||(ki('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(ki('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;xi.priorWebsocketSuccess="websocket"===t.name,ki('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(ki("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{ki('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(),ki('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&&(ki('"%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)}xi.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",l),t.open()},xi.prototype.onOpen=function(){if(ki("socket open"),this.readyState="open",xi.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){ki("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},xi.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(ki('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 ki('packet received with socket readyState "%s"',this.readyState)},xi.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))},xi.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)},xi.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){ki("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},xi.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},xi.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},xi.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(ki("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},xi.prototype.write=xi.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},xi.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()}},xi.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"),ki("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},xi.prototype.onError=function(e){ki("socket error %j",e),xi.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},xi.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){ki('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}},xi.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~Ei(this.transports,e[n])&&t.push(e[n]);return t},Tr.exports=Oi,Tr.exports.parser=jr;var Ti={exports:{}},Pi={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}}(Pi);var Bi=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n};var Mi=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var Fi=[].slice,Ni=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=Fi.call(arguments,2);return function(){return t.apply(e,n.concat(Fi.call(arguments)))}};!function(e,t){var n=hr,r=Pi.exports,o=Bi,i=Mi,s=Ni,a=nr.exports("socket.io-client:socket"),c=wo,l=Wr;e.exports=d;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},p=r.prototype.emit;function d(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(d.prototype),d.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"))]}},d.prototype.open=d.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},d.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},d.prototype.emit=function(e){if(u.hasOwnProperty(e))return p.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},d.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},d.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})},d.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},d.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)}},d.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?p.apply(this,t):this.receiveBuffer.push(t)},d.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})}}},d.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)},d.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},d.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)p.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},d.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},d.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)},d.prototype.close=d.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},d.prototype.compress=function(e){return this.flags.compress=e,this},d.prototype.binary=function(e){return this.flags.binary=e,this}}(Ti);var ji=Ui;function Ui(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}Ui.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)},Ui.prototype.reset=function(){this.attempts=0},Ui.prototype.setMin=function(e){this.ms=e},Ui.prototype.setMax=function(e){this.max=e},Ui.prototype.setJitter=function(e){this.jitter=e};var Li=Tr.exports,Di=Ti.exports,qi=Pi.exports,$i=hr,Hi=Mi,Wi=Ni,Vi=nr.exports("socket.io-client:manager"),Ki=_i,zi=ji,Ji=Object.prototype.hasOwnProperty,Qi=Xi;function Xi(e,t){if(!(this instanceof Xi))return new Xi(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 zi({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||$i;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}Xi.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)Ji.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},Xi.prototype.updateSocketIds=function(){for(var e in this.nsps)Ji.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},Xi.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},qi(Xi.prototype),Xi.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},Xi.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},Xi.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},Xi.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},Xi.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},Xi.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},Xi.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},Xi.prototype.open=Xi.prototype.connect=function(e,t){if(Vi("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Vi("opening %s",this.uri),this.engine=Li(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=Hi(n,"open",(function(){r.onopen(),e&&e()})),i=Hi(n,"error",(function(t){if(Vi("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;Vi("connect attempt will timeout after %d",s);var a=setTimeout((function(){Vi("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},Xi.prototype.onopen=function(){Vi("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(Hi(e,"data",Wi(this,"ondata"))),this.subs.push(Hi(e,"ping",Wi(this,"onping"))),this.subs.push(Hi(e,"pong",Wi(this,"onpong"))),this.subs.push(Hi(e,"error",Wi(this,"onerror"))),this.subs.push(Hi(e,"close",Wi(this,"onclose"))),this.subs.push(Hi(this.decoder,"decoded",Wi(this,"ondecoded")))},Xi.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},Xi.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},Xi.prototype.ondata=function(e){this.decoder.add(e)},Xi.prototype.ondecoded=function(e){this.emit("packet",e)},Xi.prototype.onerror=function(e){Vi("error",e),this.emitAll("error",e)},Xi.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new Di(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(){~Ki(r.connecting,n)||r.connecting.push(n)}return n},Xi.prototype.destroy=function(e){var t=Ki(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},Xi.prototype.packet=function(e){Vi("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()})))},Xi.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},Xi.prototype.cleanup=function(){Vi("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()},Xi.prototype.close=Xi.prototype.disconnect=function(){Vi("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},Xi.prototype.onclose=function(e){Vi("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},Xi.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Vi("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Vi("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Vi("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Vi("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Vi("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},Xi.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=fr,r=hr,o=Qi,i=nr.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,p=s[l]&&u in s[l].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||p?(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=Qi,t.Socket=Ti.exports}(Gn,Gn.exports);var Yi=Gn.exports;var Gi={exports:{}},Zi=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n)es.call(n,r)&&(e[r]=n[r])}return e},es=Object.prototype.hasOwnProperty;var ts={exports:{}},ns=s.default.EventEmitter;function rs(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 os(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function is(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)}}var ss=a.default.Buffer,as=si.inspect,cs=as&&as.custom||"inspect";var ls=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,n,r;return t=e,n=[{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 ss.alloc(0);for(var t,n,r,o=ss.allocUnsafe(e>>>0),i=this.head,s=0;i;)t=i.data,n=o,r=s,ss.prototype.copy.call(t,n,r),s+=i.data.length,i=i.next;return o}},{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=ss.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:cs,value:function(e,t){return as(this,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rs(Object(n),!0).forEach((function(t){os(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rs(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}],n&&is(t.prototype,n),r&&is(t,r),e}();function us(e,t){ds(e,t),ps(e)}function ps(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function ds(e,t){e.emit("error",t)}var fs={destroy:function(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return r||o?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(ds,this,e)):process.nextTick(ds,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?n._writableState?n._writableState.errorEmitted?process.nextTick(ps,n):(n._writableState.errorEmitted=!0,process.nextTick(us,n,e)):process.nextTick(us,n,e):t?(process.nextTick(ps,n),t(e)):process.nextTick(ps,n)})),this)},undestroy:function(){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)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},hs={};var ms={};function gs(e,t,n){n||(n=Error);var r=function(e){var n,r;function o(n,r,o){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,o))||this}return r=e,(n=o).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,o}(n);r.prototype.name=n.name,r.prototype.code=e,ms[e]=r}function ys(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))}gs("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),gs("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o,i,s;if("string"==typeof t&&(o="not ",t.substr(!i||i<0?0:+i,o.length)===o)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))s="The ".concat(e," ").concat(r," ").concat(ys(t,"type"));else{var a=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(a," ").concat(r," ").concat(ys(t,"type"))}return s+=". Received type ".concat(typeof n)}),TypeError),gs("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),gs("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),gs("ERR_STREAM_PREMATURE_CLOSE","Premature close"),gs("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),gs("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),gs("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),gs("ERR_STREAM_WRITE_AFTER_END","write after end"),gs("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),gs("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),gs("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),hs.codes=ms;var bs=hs.codes.ERR_INVALID_OPT_VALUE;var vs={getHighWaterMark:function(e,t,n,r){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new bs(r?n:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}},ws={exports:{}};"function"==typeof Object.create?ws.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:ws.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}};var _s=function(e,t){if(Cs("noDeprecation"))return e;var n=!1;return function(){if(!n){if(Cs("throwDeprecation"))throw new Error(t);Cs("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}};function Cs(e){try{if(!ge.localStorage)return!1}catch(e){return!1}var t=ge.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}var Ss,ks=Vs;function Es(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}Vs.WritableState=Ws;var Rs={deprecate:_s},Is=ns,As=a.default.Buffer,Os=ge.Uint8Array||function(){};var xs,Ts=fs,Ps=vs.getHighWaterMark,Bs=hs.codes,Ms=Bs.ERR_INVALID_ARG_TYPE,Fs=Bs.ERR_METHOD_NOT_IMPLEMENTED,Ns=Bs.ERR_MULTIPLE_CALLBACK,js=Bs.ERR_STREAM_CANNOT_PIPE,Us=Bs.ERR_STREAM_DESTROYED,Ls=Bs.ERR_STREAM_NULL_VALUES,Ds=Bs.ERR_STREAM_WRITE_AFTER_END,qs=Bs.ERR_UNKNOWN_ENCODING,$s=Ts.errorOrDestroy;function Hs(){}function Ws(e,t,n){Ss=Ss||Zs,e=e||{},"boolean"!=typeof n&&(n=t instanceof Ss),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=Ps(this,e,"writableHighWaterMark",n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var r=!1===e.decodeStrings;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,o=n.writecb;if("function"!=typeof o)throw new Ns;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,o){--t.pendingcb,n?(process.nextTick(o,r),process.nextTick(Ys,e,t),e._writableState.errorEmitted=!0,$s(e,r)):(o(r),e._writableState.errorEmitted=!0,$s(e,r),Ys(e,t))}(e,n,r,t,o);else{var i=Qs(n)||e.destroyed;i||n.corked||n.bufferProcessing||!n.bufferedRequest||Js(e,n),r?process.nextTick(zs,e,n,i,o):zs(e,n,i,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Es(this)}function Vs(e){var t=this instanceof(Ss=Ss||Zs);if(!t&&!xs.call(Vs,this))return new Vs(e);this._writableState=new Ws(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),Is.call(this)}function Ks(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new Us("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function zs(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),Ys(e,t)}function Js(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,o=new Array(r),i=t.corkedRequestsFree;i.entry=n;for(var s=0,a=!0;n;)o[s]=n,n.isBuf||(a=!1),n=n.next,s+=1;o.allBuffers=a,Ks(e,t,!0,t.length,o,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new Es(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,u=n.callback;if(Ks(e,t,!1,t.objectMode?1:c.length,c,l,u),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function Qs(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Xs(e,t){e._final((function(n){t.pendingcb--,n&&$s(e,n),t.prefinished=!0,e.emit("prefinish"),Ys(e,t)}))}function Ys(e,t){var n=Qs(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,process.nextTick(Xs,e,t)))}(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}ws.exports(Vs,Is),Ws.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Ws.prototype,"buffer",{get:Rs.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]?(xs=Function.prototype[Symbol.hasInstance],Object.defineProperty(Vs,Symbol.hasInstance,{value:function(e){return!!xs.call(this,e)||this===Vs&&(e&&e._writableState instanceof Ws)}})):xs=function(e){return e instanceof this},Vs.prototype.pipe=function(){$s(this,new js)},Vs.prototype.write=function(e,t,n){var r,o=this._writableState,i=!1,s=!o.objectMode&&(r=e,As.isBuffer(r)||r instanceof Os);return s&&!As.isBuffer(e)&&(e=function(e){return As.from(e)}(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof n&&(n=Hs),o.ending?function(e,t){var n=new Ds;$s(e,n),process.nextTick(t,n)}(this,n):(s||function(e,t,n,r){var o;return null===n?o=new Ls:"string"==typeof n||t.objectMode||(o=new Ms("chunk",["string","Buffer"],n)),!o||($s(e,o),process.nextTick(r,o),!1)}(this,o,e,n))&&(o.pendingcb++,i=function(e,t,n,r,o,i){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=As.from(t,n));return t}(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;c||(t.needDrain=!0);if(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 Ks(e,t,!1,a,r,o,i);return c}(this,o,s,e,t,n)),i},Vs.prototype.cork=function(){this._writableState.corked++},Vs.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||Js(this,e))},Vs.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 qs(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Vs.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(Vs.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Vs.prototype._write=function(e,t,n){n(new Fs("_write()"))},Vs.prototype._writev=null,Vs.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||function(e,t,n){t.ending=!0,Ys(e,t),n&&(t.finished?process.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(Vs.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(Vs.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Vs.prototype.destroy=Ts.destroy,Vs.prototype._undestroy=Ts.undestroy,Vs.prototype._destroy=function(e,t){t(e)};var Gs=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},Zs=ia,ea=$a,ta=ks;ws.exports(ia,ea);for(var na=Gs(ta.prototype),ra=0;ra<na.length;ra++){var oa=na[ra];ia.prototype[oa]||(ia.prototype[oa]=ta.prototype[oa])}function ia(e){if(!(this instanceof ia))return new ia(e);ea.call(this,e),ta.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",sa)))}function sa(){this._writableState.ended||process.nextTick(aa,this)}function aa(e){e.end()}Object.defineProperty(ia.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(ia.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(ia.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(ia.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)}});var ca={},la={exports:{}};
1
+ var Amity=function(e){"use strict";var t;const n=null!==(t="v0.0.1-beta.10-umd")?t:"__dev__",r="function"==typeof atob,o="function"==typeof btoa,i="function"==typeof Buffer,s="function"==typeof TextDecoder?new TextDecoder:void 0,a="function"==typeof TextEncoder?new TextEncoder:void 0,c=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],u=(e=>{let t={};return e.forEach(((e,n)=>t[e]=n)),t})(c),l=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,h=String.fromCharCode.bind(String),p="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),f=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),d=o?e=>btoa(e):i?e=>Buffer.from(e,"binary").toString("base64"):e=>{let t,n,r,o,i="";const s=e.length%3;for(let s=0;s<e.length;){if((n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255||(o=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=n<<16|r<<8|o,i+=c[t>>18&63]+c[t>>12&63]+c[t>>6&63]+c[63&t]}return s?i.slice(0,s-3)+"===".substring(s):i},m=i?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,r=e.length;n<r;n+=4096)t.push(h.apply(null,e.subarray(n,n+4096)));return d(t.join(""))},g=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?h(192|t>>>6)+h(128|63&t):h(224|t>>>12&15)+h(128|t>>>6&63)+h(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return h(240|t>>>18&7)+h(128|t>>>12&63)+h(128|t>>>6&63)+h(128|63&t)},y=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,b=i?e=>Buffer.from(e,"utf8").toString("base64"):a?e=>m(a.encode(e)):e=>d(e.replace(y,g)),v=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,w=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return h(55296+(t>>>10))+h(56320+(1023&t));case 3:return h((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return h((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},_=r?e=>atob(f(e)):i?e=>Buffer.from(e,"base64").toString("binary"):e=>{if(e=e.replace(/\s+/g,""),!l.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,r,o="";for(let i=0;i<e.length;)t=u[e.charAt(i++)]<<18|u[e.charAt(i++)]<<12|(n=u[e.charAt(i++)])<<6|(r=u[e.charAt(i++)]),o+=64===n?h(t>>16&255):64===r?h(t>>16&255,t>>8&255):h(t>>16&255,t>>8&255,255&t);return o},C=i?e=>p(Buffer.from(e,"base64")):e=>p(_(e),(e=>e.charCodeAt(0))),S=i?e=>Buffer.from(e,"base64").toString("utf8"):s?e=>s.decode(C(e)):e=>_(e).replace(v,w),k=e=>S(f(e.replace(/[-_]/g,(e=>"-"==e?"+":"/")))),E=e=>["skip","limit"].some((t=>t in e)),A=e=>["after","before","first","last"].some((t=>t in e)),I=e=>["after","before"].some((t=>t in e)),x=e=>(null==e?void 0:e.hasOwnProperty("data"))&&(null==e?void 0:e.hasOwnProperty("nextPage"))&&(null==e?void 0:e.hasOwnProperty("prevPage")),O=(e,t)=>{var n;if(!e||!Object.keys(e).length)return;let r={};return"skiplimit"===t?r={skip:null!==(n=e.after)&&void 0!==n?n:0,limit:e.limit}:"afterbefore"===t?isNaN(null==e?void 0:e.before)?isNaN(null==e?void 0:e.after)?isNaN(null==e?void 0:e.limit)||(r={last:e.limit}):r={after:e.after,first:e.limit}:r={before:e.before,last:e.limit}:"afterbeforeraw"===t&&(r=e),Object.keys(r).length?((e,t=!1)=>t?(e=>e.replace(/[+\/]/g,(e=>"+"==e?"-":"_")).replace(/=+$/m,""))(b(e)):b(e))(JSON.stringify(r)):void 0},R=e=>{if(!e)return null;const t=JSON.parse(k(e));if(E(t))return{after:t.skip,limit:t.limit};if(A(t)){if("before"in t)return{before:t.before,limit:t.last};if("after"in t)return{after:t.after,limit:t.first}}return null},T=e=>{if(!e)return null;const t=JSON.parse(k(e));return I(t)?t:null},F=e=>"locally"in e,P=e=>"optimistically"in e,j=e=>F(e)||P(e),B=e=>null==e?void 0:e.hasOwnProperty("cachedAt"),M=(e,t=0)=>{var n;return Date.now()-(null!==(n=null==e?void 0:e.cachedAt)&&void 0!==n?n:0)<=t},N=(e,...t)=>({func:e,args:t}),U=(e,t=12e4)=>"cache_only"===e?{lifeSpan:1/0}:"server_only"===e?{lifeSpan:0}:{lifeSpan:t},L=({func:e,args:t},n,r=U("cache_then_server"))=>{let o;if(j(e)&&0!==r.lifeSpan){try{o=P(e)?e.optimistically(...t):e.locally(...t)}catch(e){null==n||n(D(void 0,{origin:"local",loading:!1,error:e}))}const i=B(o)&&M(o,r.lifeSpan);if(null==n||n(D(o,{origin:"local",loading:!(F(e)&&i)})),i)return}else null==n||n(D(void 0,{origin:"local",loading:!0}));e(...t).then((e=>{null==n||n(D(e,{origin:"server",loading:!1}))})).catch((e=>{null==n||n(D(void 0,{origin:"server",loading:!1,error:e}))}))};function D(e,t){return x(e)||B(e)?Object.assign(Object.assign({},t),e):Object.assign(Object.assign({},t),{data:e})}class q extends Error{constructor(e,t,n){super(`Amity SDK (${t}): ${e}`),this.code=t,this.level=n,this.type="ASC",this.timestamp=Date.now(),Error.captureStackTrace&&Error.captureStackTrace(this,q)}}class $ extends q{constructor(e,t,n){super(e,t,n)}}class H extends q{constructor(e=8e5,t="fatal"){super("Unexpected error",e,t)}}class W extends q{constructor(e,t="SDK client is having connection issues"){super(`${t} (${e})`,"disconnected"===e?800211:800210,"error"),this.event=e}}let z=null;const V=()=>{if(!z)throw new q("There is no active client",8e5,"fatal");return z},K=e=>{z=e};var J="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Q(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}function Y(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var X={exports:{}},G=1e3,Z=6e4,ee=60*Z,te=24*ee,ne=7*te,re=365.25*te,oe=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*re;case"weeks":case"week":case"w":return n*ne;case"days":case"day":case"d":return n*te;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ee;case"minutes":case"minute":case"mins":case"min":case"m":return n*Z;case"seconds":case"second":case"secs":case"sec":case"s":return n*G;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=te)return ie(e,t,te,"day");if(t>=ee)return ie(e,t,ee,"hour");if(t>=Z)return ie(e,t,Z,"minute");if(t>=G)return ie(e,t,G,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=te)return Math.round(e/te)+"d";if(t>=ee)return Math.round(e/ee)+"h";if(t>=Z)return Math.round(e/Z)+"m";if(t>=G)return Math.round(e/G)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ie(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}var se=function(e){function t(e){let r,o,i,s=null;function a(...e){if(!a.enabled)return;const n=a,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,o)=>{if("%%"===r)return"%";s++;const i=t.formatters[o];if("function"==typeof i){const t=e[s];r=i.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=oe,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=se(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(X,X.exports);var ae=X.exports;const ce="sg";var ue;!function(e){e.HTTP="https://api.{region}.amity.co",e.MQTT="wss://sse.{region}.amity.co:443/mqtt"}(ue||(ue={}));const le=(e,t)=>e.replace("{region}",t);var he={exports:{}},pe=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}},fe=pe,de=Object.prototype.toString;function me(e){return"[object Array]"===de.call(e)}function ge(e){return void 0===e}function ye(e){return null!==e&&"object"==typeof e}function be(e){if("[object Object]"!==de.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function ve(e){return"[object Function]"===de.call(e)}function we(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),me(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var _e={isArray:me,isArrayBuffer:function(e){return"[object ArrayBuffer]"===de.call(e)},isBuffer:function(e){return null!==e&&!ge(e)&&null!==e.constructor&&!ge(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:ye,isPlainObject:be,isUndefined:ge,isDate:function(e){return"[object Date]"===de.call(e)},isFile:function(e){return"[object File]"===de.call(e)},isBlob:function(e){return"[object Blob]"===de.call(e)},isFunction:ve,isStream:function(e){return ye(e)&&ve(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:we,merge:function e(){var t={};function n(n,r){be(t[r])&&be(n)?t[r]=e(t[r],n):be(n)?t[r]=e({},n):me(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)we(arguments[r],n);return t},extend:function(e,t,n){return we(t,(function(t,r){e[r]=n&&"function"==typeof t?fe(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},Ce=_e;function Se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var ke=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(Ce.isURLSearchParams(t))r=t.toString();else{var o=[];Ce.forEach(t,(function(e,t){null!=e&&(Ce.isArray(e)?t+="[]":e=[e],Ce.forEach(e,(function(e){Ce.isDate(e)?e=e.toISOString():Ce.isObject(e)&&(e=JSON.stringify(e)),o.push(Se(t)+"="+Se(e))})))})),r=o.join("&")}if(r){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e},Ee=_e;function Ae(){this.handlers=[]}Ae.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},Ae.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Ae.prototype.forEach=function(e){Ee.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Ie=Ae,xe=_e,Oe=function(e){return!(!e||!e.__CANCEL__)},Re=_e,Te=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},Fe=function(e,t,n,r,o){var i=new Error(e);return Te(i,t,n,r,o)},Pe=Fe,je=_e,Be=je.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),je.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),je.isString(r)&&s.push("path="+r),je.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},Me=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Ne=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Ue=_e,Le=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],De=_e,qe=De.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=De.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0},$e=_e,He=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(Pe("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},We=Be,ze=ke,Ve=function(e,t){return e&&!Me(t)?Ne(e,t):t},Ke=function(e){var t,n,r,o={};return e?(Ue.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=Ue.trim(e.substr(0,r)).toLowerCase(),n=Ue.trim(e.substr(r+1)),t){if(o[t]&&Le.indexOf(t)>=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o},Je=qe,Qe=Fe,Ye=function(e){return new Promise((function(t,n){var r=e.data,o=e.headers;$e.isFormData(r)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var s=e.auth.username||"",a=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(s+":"+a)}var c=Ve(e.baseURL,e.url);if(i.open(e.method.toUpperCase(),ze(c,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,i.onreadystatechange=function(){if(i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in i?Ke(i.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:r,config:e,request:i};He(t,n,o),i=null}},i.onabort=function(){i&&(n(Qe("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){n(Qe("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(Qe(t,e,"ECONNABORTED",i)),i=null},$e.isStandardBrowserEnv()){var u=(e.withCredentials||Je(c))&&e.xsrfCookieName?We.read(e.xsrfCookieName):void 0;u&&(o[e.xsrfHeaderName]=u)}if("setRequestHeader"in i&&$e.forEach(o,(function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),$e.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),e.responseType)try{i.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),n(e),i=null)})),r||(r=null),i.send(r)}))},Xe=_e,Ge=function(e,t){Re.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))},Ze={"Content-Type":"application/x-www-form-urlencoded"};function et(e,t){!Xe.isUndefined(e)&&Xe.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var tt,nt={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(tt=Ye),tt),transformRequest:[function(e,t){return Ge(t,"Accept"),Ge(t,"Content-Type"),Xe.isFormData(e)||Xe.isArrayBuffer(e)||Xe.isBuffer(e)||Xe.isStream(e)||Xe.isFile(e)||Xe.isBlob(e)?e:Xe.isArrayBufferView(e)?e.buffer:Xe.isURLSearchParams(e)?(et(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Xe.isObject(e)?(et(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};nt.headers={common:{Accept:"application/json, text/plain, */*"}},Xe.forEach(["delete","get","head"],(function(e){nt.headers[e]={}})),Xe.forEach(["post","put","patch"],(function(e){nt.headers[e]=Xe.merge(Ze)}));var rt=nt,ot=_e,it=function(e,t,n){return xe.forEach(n,(function(n){e=n(e,t)})),e},st=Oe,at=rt;function ct(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var ut=_e,lt=function(e,t){t=t||{};var n={},r=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function a(e,t){return ut.isPlainObject(e)&&ut.isPlainObject(t)?ut.merge(e,t):ut.isPlainObject(t)?ut.merge({},t):ut.isArray(t)?t.slice():t}function c(r){ut.isUndefined(t[r])?ut.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(e[r],t[r])}ut.forEach(r,(function(e){ut.isUndefined(t[e])||(n[e]=a(void 0,t[e]))})),ut.forEach(o,c),ut.forEach(i,(function(r){ut.isUndefined(t[r])?ut.isUndefined(e[r])||(n[r]=a(void 0,e[r])):n[r]=a(void 0,t[r])})),ut.forEach(s,(function(r){r in t?n[r]=a(e[r],t[r]):r in e&&(n[r]=a(void 0,e[r]))}));var u=r.concat(o).concat(i).concat(s),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===u.indexOf(e)}));return ut.forEach(l,c),n},ht=_e,pt=ke,ft=Ie,dt=function(e){return ct(e),e.headers=e.headers||{},e.data=it(e.data,e.headers,e.transformRequest),e.headers=ot.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ot.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||at.adapter)(e).then((function(t){return ct(e),t.data=it(t.data,t.headers,e.transformResponse),t}),(function(t){return st(t)||(ct(e),t&&t.response&&(t.response.data=it(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},mt=lt;function gt(e){this.defaults=e,this.interceptors={request:new ft,response:new ft}}gt.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=mt(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[dt,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},gt.prototype.getUri=function(e){return e=mt(this.defaults,e),pt(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ht.forEach(["delete","get","head","options"],(function(e){gt.prototype[e]=function(t,n){return this.request(mt(n||{},{method:e,url:t,data:(n||{}).data}))}})),ht.forEach(["post","put","patch"],(function(e){gt.prototype[e]=function(t,n,r){return this.request(mt(r||{},{method:e,url:t,data:n}))}}));var yt=gt;function bt(e){this.message=e}bt.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},bt.prototype.__CANCEL__=!0;var vt=bt,wt=vt;function _t(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new wt(e),t(n.reason))}))}_t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},_t.source=function(){var e;return{token:new _t((function(t){e=t})),cancel:e}};var Ct=_t,St=_e,kt=pe,Et=yt,At=lt;function It(e){var t=new Et(e),n=kt(Et.prototype.request,t);return St.extend(n,Et.prototype,t),St.extend(n,t),n}var xt=It(rt);xt.Axios=Et,xt.create=function(e){return It(At(xt.defaults,e))},xt.Cancel=vt,xt.CancelToken=Ct,xt.isCancel=Oe,xt.all=function(e){return Promise.all(e)},xt.spread=function(e){return function(t){return e.apply(null,t)}},xt.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},he.exports=xt,he.exports.default=xt;var Ot=he.exports,Rt={exports:{}};Rt.exports=Ft;var Tt=Rt.exports.HttpsAgent=Ft;function Ft(){}var Pt=Rt.exports;const jt=e=>{if("success"===e.status)return e.data;if("fail"===e.status)throw new H(e.code);if("error"===e.status)throw new $(e.message,e.code,"error")},Bt=(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}`:Bt(n,null!=t?t:e)})).join("&");var Mt={exports:{}},Nt=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ut=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Lt=function(e){var t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));for(var o=Nt.exec(e||""),i={},s=14;s--;)i[Ut[s]]=o[s]||"";return-1!=n&&-1!=r&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i},Dt={exports:{}},qt={exports:{}},$t=1e3,Ht=60*$t,Wt=60*Ht,zt=24*Wt,Vt=365.25*zt,Kt=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Vt;case"days":case"day":case"d":return n*zt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Wt;case"minutes":case"minute":case"mins":case"min":case"m":return n*Ht;case"seconds":case"second":case"secs":case"sec":case"s":return n*$t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return Jt(e,zt,"day")||Jt(e,Wt,"hour")||Jt(e,Ht,"minute")||Jt(e,$t,"second")||e+" ms"}(e):function(e){if(e>=zt)return Math.round(e/zt)+"d";if(e>=Wt)return Math.round(e/Wt)+"h";if(e>=Ht)return Math.round(e/Ht)+"m";if(e>=$t)return Math.round(e/$t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Jt(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var u=o.log||t.log||console.log.bind(console);u.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(qt,qt.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=qt.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(Dt,Dt.exports);var Qt=Lt,Yt=Dt.exports("socket.io-client:url"),Xt=function(e,t){var n=e;t=t||"undefined"!=typeof location&&location,null==e&&(e=t.protocol+"//"+t.host);"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?t.protocol+e:t.host+e),/^(https?|wss?):\/\//.test(e)||(Yt("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),Yt("parse %s",e),n=Qt(e));n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443"));n.path=n.path||"/";var r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port,n.href=n.protocol+"://"+r+(t&&t.port===n.port?"":":"+n.port),n};var Gt={},Zt={exports:{}},en={exports:{}};!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var u=o.log||t.log||console.log.bind(console);u.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(en,en.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=en.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(Zt,Zt.exports);var tn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(tn);var nn={},rn={}.toString,on=Array.isArray||function(e){return"[object Array]"==rn.call(e)},sn=function(e){return an&&Buffer.isBuffer(e)||cn&&(e instanceof ArrayBuffer||function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer}(e))},an="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,cn="function"==typeof ArrayBuffer;var un=on,ln=sn,hn=Object.prototype.toString,pn="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===hn.call(Blob),fn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===hn.call(File);function dn(e,t){if(!e)return e;if(ln(e)){var n={_placeholder:!0,num:t.length};return t.push(e),n}if(un(e)){for(var r=new Array(e.length),o=0;o<e.length;o++)r[o]=dn(e[o],t);return r}if("object"==typeof e&&!(e instanceof Date)){r={};for(var i in e)r[i]=dn(e[i],t);return r}return e}function mn(e,t){if(!e)return e;if(e&&e._placeholder)return t[e.num];if(un(e))for(var n=0;n<e.length;n++)e[n]=mn(e[n],t);else if("object"==typeof e)for(var r in e)e[r]=mn(e[r],t);return e}nn.deconstructPacket=function(e){var t=[],n=e.data,r=e;return r.data=dn(n,t),r.attachments=t.length,{packet:r,buffers:t}},nn.reconstructPacket=function(e,t){return e.data=mn(e.data,t),e.attachments=void 0,e},nn.removeBlobs=function(e,t){var n=0,r=e;!function e(o,i,s){if(!o)return o;if(pn&&o instanceof Blob||fn&&o instanceof File){n++;var a=new FileReader;a.onload=function(){s?s[i]=this.result:r=this.result,--n||t(r)},a.readAsArrayBuffer(o)}else if(un(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!ln(o))for(var u in o)e(o[u],u,o)}(r),n||t(r)},function(e){var t=Zt.exports("socket.io-parser"),n=tn.exports,r=nn,o=on,i=sn;function s(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=s,e.Decoder=u;var a=e.ERROR+'"encode error"';function c(n){var r=""+n.type;if(e.BINARY_EVENT!==n.type&&e.BINARY_ACK!==n.type||(r+=n.attachments+"-"),n.nsp&&"/"!==n.nsp&&(r+=n.nsp+","),null!=n.id&&(r+=n.id),null!=n.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(n.data);if(!1===o)return a;r+=o}return t("encoded %j as %s",n,r),r}function u(){this.reconstructor=null}function l(e){this.reconPack=e,this.buffers=[]}function h(t){return{type:e.ERROR,data:"parser error: "+t}}s.prototype.encode=function(n,o){(t("encoding packet %j",n),e.BINARY_EVENT===n.type||e.BINARY_ACK===n.type)?function(e,t){function n(e){var n=r.deconstructPacket(e),o=c(n.packet),i=n.buffers;i.unshift(o),t(i)}r.removeBlobs(e,n)}(n,o):o([c(n)])},n(u.prototype),u.prototype.add=function(n){var r;if("string"==typeof n)r=function(n){var r=0,i={type:Number(n.charAt(0))};if(null==e.types[i.type])return h("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var s=r+1;"-"!==n.charAt(++r)&&r!=n.length;);var a=n.substring(s,r);if(a!=Number(a)||"-"!==n.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(a)}if("/"===n.charAt(r+1)){for(s=r+1;++r;){if(","===(u=n.charAt(r)))break;if(r===n.length)break}i.nsp=n.substring(s,r)}else i.nsp="/";var c=n.charAt(r+1);if(""!==c&&Number(c)==c){for(s=r+1;++r;){var u;if(null==(u=n.charAt(r))||Number(u)!=u){--r;break}if(r===n.length)break}i.id=Number(n.substring(s,r+1))}if(n.charAt(++r)){var l=function(e){try{return JSON.parse(e)}catch(e){return!1}}(n.substr(r));if(!(!1!==l&&(i.type===e.ERROR||o(l))))return h("invalid payload");i.data=l}return t("decoded %s as %j",n,i),i}(n),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new l(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!i(n)&&!n.base64)throw new Error("Unknown type: "+n);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(n))&&(this.reconstructor=null,this.emit("decoded",r))}},u.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},l.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=r.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},l.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}(Gt);var gn={exports:{}},yn={},bn={exports:{}};try{bn.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){bn.exports=!1}var vn=bn.exports,wn=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||vn))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&r)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},_n={exports:{}},Cn={},Sn=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},kn={}.toString,En=Array.isArray||function(e){return"[object Array]"==kn.call(e)},An=Object.prototype.toString,In="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===An.call(Blob),xn="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===An.call(File),On=function e(t){if(!t||"object"!=typeof t)return!1;if(En(t)){for(var n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||In&&t instanceof Blob||xn&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&e(t[o]))return!0;return!1};var Rn=function(e,t,n){var r=e.byteLength;if(t=t||0,n=n||r,e.slice)return e.slice(t,n);if(t<0&&(t+=r),n<0&&(n+=r),n>r&&(n=r),t>=r||t>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(e),i=new Uint8Array(n-t),s=t,a=0;s<n;s++,a++)i[a]=o[s];return i.buffer},Tn=function(e,t,n){var r=!1;return n=n||Fn,o.count=e,0===e?t():o;function o(e,i){if(o.count<=0)throw new Error("after called too many times");--o.count,e?(r=!0,t(e),t=n):0!==o.count||r||t(null,i)}};function Fn(){}
2
+ /*! https://mths.be/utf8js v2.1.2 by @mathias */var Pn,jn,Bn,Mn=String.fromCharCode;function Nn(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 Un(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function Ln(e,t){return Mn(e>>t&63|128)}function Dn(e,t){if(0==(4294967168&e))return Mn(e);var n="";return 0==(4294965248&e)?n=Mn(e>>6&31|192):0==(4294901760&e)?(Un(e,t)||(e=65533),n=Mn(e>>12&15|224),n+=Ln(e,6)):0==(4292870144&e)&&(n=Mn(e>>18&7|240),n+=Ln(e,12),n+=Ln(e,6)),n+=Mn(63&e|128)}function qn(){if(Bn>=jn)throw Error("Invalid byte index");var e=255&Pn[Bn];if(Bn++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function $n(e){var t,n;if(Bn>jn)throw Error("Invalid byte index");if(Bn==jn)return!1;if(t=255&Pn[Bn],Bn++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|qn())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|qn()<<6|qn())>=2048)return Un(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|qn()<<12|qn()<<6|qn())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var Hn={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Nn(e),o=r.length,i=-1,s="";++i<o;)s+=Dn(r[i],n);return s},decode:function(e,t){var n=!1!==(t=t||{}).strict;Pn=Nn(e),jn=Pn.length,Bn=0;for(var r,o=[];!1!==(r=$n(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=Mn((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=Mn(t);return o}(o)}},Wn={};!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=new Uint8Array(256),n=0;n<e.length;n++)t[e.charCodeAt(n)]=n;Wn.encode=function(t){var n,r=new Uint8Array(t),o=r.length,i="";for(n=0;n<o;n+=3)i+=e[r[n]>>2],i+=e[(3&r[n])<<4|r[n+1]>>4],i+=e[(15&r[n+1])<<2|r[n+2]>>6],i+=e[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},Wn.decode=function(e){var n,r,o,i,s,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var l=new ArrayBuffer(a),h=new Uint8Array(l);for(n=0;n<c;n+=4)r=t[e.charCodeAt(n)],o=t[e.charCodeAt(n+1)],i=t[e.charCodeAt(n+2)],s=t[e.charCodeAt(n+3)],h[u++]=r<<2|o>>4,h[u++]=(15&o)<<4|i>>2,h[u++]=(3&i)<<6|63&s;return l}}();var zn=void 0!==zn?zn:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,Vn=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),Kn=Vn&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),Jn=zn&&zn.prototype.append&&zn.prototype.getBlob;function Qn(e){return e.map((function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var n=new Uint8Array(e.byteLength);n.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer}return t}return e}))}function Yn(e,t){t=t||{};var n=new zn;return Qn(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function Xn(e,t){return new Blob(Qn(e),t||{})}"undefined"!=typeof Blob&&(Yn.prototype=Blob.prototype,Xn.prototype=Blob.prototype);var Gn=Vn?Kn?Blob:Xn:Jn?Yn:void 0;!function(e){var t,n=Sn,r=On,o=Rn,i=Tn,s=Hn;"undefined"!=typeof ArrayBuffer&&(t=Wn);var a="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),c="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),u=a||c;e.protocol=3;var l=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},h=n(l),p={type:"error",data:"parser error"},f=Gn;function d(e,t,n){for(var r=new Array(e.length),o=i(e.length,n),s=function(e,n,o){t(n,(function(t,n){r[e]=n,o(t,r)}))},a=0;a<e.length;a++)s(a,e[a],o)}e.encodePacket=function(t,n,r,o){"function"==typeof n&&(o=n,n=!1),"function"==typeof r&&(o=r,r=null);var i=void 0===t.data?void 0:t.data.buffer||t.data;if("undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=l[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return r(s.buffer)}(t,n,o);if(void 0!==f&&i instanceof f)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);if(u)return function(t,n,r){if(!n)return e.encodeBase64Packet(t,r);var o=new FileReader;return o.onload=function(){e.encodePacket({type:t.type,data:o.result},n,!0,r)},o.readAsArrayBuffer(t.data)}(t,n,r);var o=new Uint8Array(1);o[0]=l[t.type];var i=new f([o.buffer,t.data]);return r(i)}(t,n,o);if(i&&i.base64)return function(t,n){var r="b"+e.packets[t.type]+t.data.data;return n(r)}(t,o);var a=l[t.type];return void 0!==t.data&&(a+=r?s.encode(String(t.data),{strict:!1}):String(t.data)),o(""+a)},e.encodeBase64Packet=function(t,n){var r,o="b"+e.packets[t.type];if(void 0!==f&&t.data instanceof f){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(t.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];r=String.fromCharCode.apply(null,a)}return o+=btoa(r),n(o)},e.decodePacket=function(t,n,r){if(void 0===t)return p;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),n);if(r&&!1===(t=function(e){try{e=s.decode(e,{strict:!1})}catch(e){return!1}return e}(t)))return p;var i=t.charAt(0);return Number(i)==i&&h[i]?t.length>1?{type:h[i],data:t.substring(1)}:{type:h[i]}:p}i=new Uint8Array(t)[0];var a=o(t,1);return f&&"blob"===n&&(a=new f([a])),{type:h[i],data:a}},e.decodeBase64Packet=function(e,n){var r=h[e.charAt(0)];if(!t)return{type:r,data:{base64:!0,data:e.substr(1)}};var o=t.decode(e.substr(1));return"blob"===n&&f&&(o=new f([o])),{type:r,data:o}},e.encodePayload=function(t,n,o){"function"==typeof n&&(o=n,n=null);var i=r(t);if(n&&i)return f&&!u?e.encodePayloadAsBlob(t,o):e.encodePayloadAsArrayBuffer(t,o);if(!t.length)return o("0:");d(t,(function(t,r){e.encodePacket(t,!!i&&n,!1,(function(e){r(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return o(t.join(""))}))},e.decodePayload=function(t,n,r){if("string"!=typeof t)return e.decodePayloadAsBinary(t,n,r);var o;if("function"==typeof n&&(r=n,n=null),""===t)return r(p,0,1);for(var i,s,a="",c=0,u=t.length;c<u;c++){var l=t.charAt(c);if(":"===l){if(""===a||a!=(i=Number(a)))return r(p,0,1);if(a!=(s=t.substr(c+1,i)).length)return r(p,0,1);if(s.length){if(o=e.decodePacket(s,n,!1),p.type===o.type&&p.data===o.data)return r(p,0,1);if(!1===r(o,c+i,u))return}c+=i,a=""}else a+=l}return""!==a?r(p,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,n){if(!t.length)return n(new ArrayBuffer(0));d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){return n(null,e)}))}),(function(e,t){var r=t.reduce((function(e,t){var n;return e+(n="string"==typeof t?t.length:t.byteLength).toString().length+n+2}),0),o=new Uint8Array(r),i=0;return t.forEach((function(e){var t="string"==typeof e,n=e;if(t){for(var r=new Uint8Array(e.length),s=0;s<e.length;s++)r[s]=e.charCodeAt(s);n=r.buffer}o[i++]=t?0:1;var a=n.byteLength.toString();for(s=0;s<a.length;s++)o[i++]=parseInt(a[s]);o[i++]=255;for(r=new Uint8Array(n),s=0;s<r.length;s++)o[i++]=r[s]})),n(o.buffer)}))},e.encodePayloadAsBlob=function(t,n){d(t,(function(t,n){e.encodePacket(t,!0,!0,(function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);e=r.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,f){var a=new f([t.buffer,s.buffer,e]);n(null,a)}}))}),(function(e,t){return n(new f(t))}))},e.decodePayloadAsBinary=function(t,n,r){"function"==typeof n&&(r=n,n=null);for(var i=t,s=[];i.byteLength>0;){for(var a=new Uint8Array(i),c=0===a[0],u="",l=1;255!==a[l];l++){if(u.length>310)return r(p,0,1);u+=a[l]}i=o(i,2+u.length),u=parseInt(u);var h=o(i,0,u);if(c)try{h=String.fromCharCode.apply(null,new Uint8Array(h))}catch(e){var f=new Uint8Array(h);h="";for(l=0;l<f.length;l++)h+=String.fromCharCode(f[l])}s.push(h),i=o(i,u)}var d=s.length;s.forEach((function(t,o){r(e.decodePacket(t,n,!0),o,d)}))}}(Cn);var Zn={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(Zn);var er=Cn,tr=nr;function nr(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}(0,Zn.exports)(nr.prototype),nr.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},nr.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},nr.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},nr.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},nr.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},nr.prototype.onData=function(e){var t=er.decodePacket(e,this.socket.binaryType);this.onPacket(t)},nr.prototype.onPacket=function(e){this.emit("packet",e)},nr.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var rr,or={encode:function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},decode:function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},ir=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},sr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),ar={},cr=0,ur=0;function lr(e){var t="";do{t=sr[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function hr(){var e=lr(+new Date);return e!==rr?(cr=0,rr=e):e+"."+lr(cr++)}for(;ur<64;ur++)ar[sr[ur]]=ur;hr.encode=lr,hr.decode=function(e){var t=0;for(ur=0;ur<e.length;ur++)t=64*t+ar[e.charAt(ur)];return t};var pr=hr,fr={exports:{}},dr={exports:{}};!function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var s=new Array(arguments.length),a=0;a<s.length;a++)s[a]=arguments[a];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,(function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=s[c];n=o.call(e,i),s.splice(c,1),c--}return n})),t.formatArgs.call(e,s);var u=o.log||t.log||console.log.bind(console);u.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Kt,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(dr,dr.exports),function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=dr.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())}(fr,fr.exports);var mr=tr,gr=or,yr=Cn,br=ir,vr=pr,wr=fr.exports("engine.io-client:polling"),_r=Sr,Cr=null!=new wn({xdomain:!1}).responseType;function Sr(e){var t=e&&e.forceBase64;Cr&&!t||(this.supportsBinary=!1),mr.call(this,e)}br(Sr,mr),Sr.prototype.name="polling",Sr.prototype.doOpen=function(){this.poll()},Sr.prototype.pause=function(e){var t=this;function n(){wr("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(wr("we are currently polling - waiting to pause"),r++,this.once("pollComplete",(function(){wr("pre-pause polling complete"),--r||n()}))),this.writable||(wr("we are currently writing - waiting to pause"),r++,this.once("drain",(function(){wr("pre-pause writing complete"),--r||n()})))}else n()},Sr.prototype.poll=function(){wr("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},Sr.prototype.onData=function(e){var t=this;wr("polling got data %s",e);yr.decodePayload(e,this.socket.binaryType,(function(e,n,r){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():wr('ignoring poll - transport state "%s"',this.readyState))},Sr.prototype.doClose=function(){var e=this;function t(){wr("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(wr("transport open - closing"),t()):(wr("transport not open - deferring close"),this.once("open",t))},Sr.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};yr.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},Sr.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=vr()),this.supportsBinary||e.sid||(e.b64=1),e=gr.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e};var kr=wn,Er=_r,Ar=Zn.exports,Ir=ir,xr=fr.exports("engine.io-client:polling-xhr");function Or(){}function Rr(e){if(Er.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,"undefined"!=typeof location){var t="https:"===location.protocol,n=location.port;n||(n=t?443:80),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port,this.xs=e.secure!==t}}function Tr(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}if(_n.exports=Rr,_n.exports.Request=Tr,Ir(Rr,Er),Rr.prototype.supportsBinary=!0,Rr.prototype.request=function(e){return(e=e||{}).uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new Tr(e)},Rr.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},Rr.prototype.doPoll=function(){xr("xhr poll");var e=this.request(),t=this;e.on("data",(function(e){t.onData(e)})),e.on("error",(function(e){t.onError("xhr poll error",e)})),this.pollXhr=e},Ar(Tr.prototype),Tr.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new kr(e),n=this;try{xr("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders)for(var r in t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0),this.extraHeaders)this.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.extraHeaders[r])}catch(e){}if("POST"===this.method)try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=!0),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){n.onLoad()},t.onerror=function(){n.onError(t.responseText)}):t.onreadystatechange=function(){if(2===t.readyState)try{var e=t.getResponseHeader("Content-Type");n.supportsBinary&&"application/octet-stream"===e&&(t.responseType="arraybuffer")}catch(e){}4===t.readyState&&(200===t.status||1223===t.status?n.onLoad():setTimeout((function(){n.onError(t.status)}),0))},xr("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout((function(){n.onError(e)}),0)}"undefined"!=typeof document&&(this.index=Tr.requestsCount++,Tr.requests[this.index]=this)},Tr.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},Tr.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},Tr.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},Tr.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=Or:this.xhr.onreadystatechange=Or,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Tr.requests[this.index],this.xhr=null}},Tr.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch(e){}e="application/octet-stream"===t&&this.xhr.response||this.xhr.responseText}catch(e){this.onError(e)}null!=e&&this.onData(e)},Tr.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},Tr.prototype.abort=function(){this.cleanup()},Tr.requestsCount=0,Tr.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Pr);else if("function"==typeof addEventListener){var Fr="onpagehide"in self?"pagehide":"unload";addEventListener(Fr,Pr,!1)}function Pr(){for(var e in Tr.requests)Tr.requests.hasOwnProperty(e)&&Tr.requests[e].abort()}var jr,Br=_r,Mr=qr,Nr=/\n/g,Ur=/\\n/g;function Lr(){}function Dr(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==J?J:{}}function qr(e){if(Br.call(this,e),this.query=this.query||{},!jr){var t=Dr();jr=t.___eio=t.___eio||[]}this.index=jr.length;var n=this;jr.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=Lr)}),!1)}ir(qr,Br),qr.prototype.supportsBinary=!1,qr.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),Br.prototype.doClose.call(this)},qr.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(t,n):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)}),100)},qr.prototype.doWrite=function(e,t){var n=this;if(!this.form){var r,o=document.createElement("form"),i=document.createElement("textarea"),s=this.iframeId="eio_iframe_"+this.index;o.className="socketio",o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px",o.target=s,o.method="POST",o.setAttribute("accept-charset","utf-8"),i.name="d",o.appendChild(i),document.body.appendChild(o),this.form=o,this.area=i}function a(){c(),t()}function c(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(e){n.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+n.iframeId+'">';r=document.createElement(e)}catch(e){(r=document.createElement("iframe")).name=n.iframeId,r.src="javascript:0"}r.id=n.iframeId,n.form.appendChild(r),n.iframe=r}this.form.action=this.uri(),c(),e=e.replace(Ur,"\\\n"),this.area.value=e.replace(Nr,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var $r,Hr,Wr=Q(Object.freeze({__proto__:null,default:{}})),zr=tr,Vr=Cn,Kr=or,Jr=ir,Qr=pr,Yr=fr.exports("engine.io-client:websocket");if("undefined"!=typeof WebSocket)$r=WebSocket;else if("undefined"!=typeof self)$r=self.WebSocket||self.MozWebSocket;else try{Hr=Wr}catch(e){}var Xr=$r||Hr,Gr=Zr;function Zr(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=$r&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(Xr=Hr),zr.call(this,e)}Jr(Zr,zr),Zr.prototype.name="websocket",Zr.prototype.supportsBinary=!0,Zr.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new Xr(e,t):new Xr(e):new Xr(e,t,n)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},Zr.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},Zr.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){Vr.encodePacket(e,t.supportsBinary,(function(r){if(!t.usingBrowserWebSocket){var o={};if(e.options&&(o.compress=e.options.compress),t.perMessageDeflate)("string"==typeof r?Buffer.byteLength(r):r.length)<t.perMessageDeflate.threshold&&(o.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(r):t.ws.send(r,o)}catch(e){Yr("websocket closed before onclose event")}--n||i()}))}(e[r]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},Zr.prototype.onClose=function(){zr.prototype.onClose.call(this)},Zr.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},Zr.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",n="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=Qr()),this.supportsBinary||(e.b64=1),(e=Kr.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},Zr.prototype.check=function(){return!(!Xr||"__initialize"in Xr&&this.name===Zr.prototype.name)};var eo=wn,to=_n.exports,no=Mr,ro=Gr;yn.polling=function(e){var t=!1,n=!1,r=!1!==e.jsonp;if("undefined"!=typeof location){var o="https:"===location.protocol,i=location.port;i||(i=o?443:80),t=e.hostname!==location.hostname||i!==e.port,n=e.secure!==o}if(e.xdomain=t,e.xscheme=n,"open"in new eo(e)&&!e.forceJSONP)return new to(e);if(!r)throw new Error("JSONP disabled");return new no(e)},yn.websocket=ro;var oo=[].indexOf,io=function(e,t){if(oo)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},so=yn,ao=Zn.exports,co=fr.exports("engine.io-client:socket"),uo=io,lo=Cn,ho=Lt,po=or,fo=mo;function mo(e,t){if(!(this instanceof mo))return new mo(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=ho(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=ho(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=po.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||null,this.key=t.key||null,this.passphrase=t.passphrase||null,this.cert=t.cert||null,this.ca=t.ca||null,this.ciphers=t.ciphers||null,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}mo.priorWebsocketSuccess=!1,ao(mo.prototype),mo.protocol=lo.protocol,mo.Socket=mo,mo.Transport=tr,mo.transports=yn,mo.parser=Cn,mo.prototype.createTransport=function(e){co('creating transport "%s"',e);var t=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.query);t.EIO=lo.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new so[e]({query:t,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative})},mo.prototype.open=function(){var e;if(this.rememberUpgrade&&mo.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout((function(){t.emit("error","No transports available")}),0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},mo.prototype.setTransport=function(e){co("setting transport %s",e.name);var t=this;this.transport&&(co("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",(function(){t.onDrain()})).on("packet",(function(e){t.onPacket(e)})).on("error",(function(e){t.onError(e)})).on("close",(function(){t.onClose("transport close")}))},mo.prototype.probe=function(e){co('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,r=this;function o(){if(r.onlyBinaryUpgrades){var o=!this.supportsBinary&&r.transport.supportsBinary;n=n||o}n||(co('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(o){if(!n)if("pong"===o.type&&"probe"===o.data){if(co('probe transport "%s" pong',e),r.upgrading=!0,r.emit("upgrading",t),!t)return;mo.priorWebsocketSuccess="websocket"===t.name,co('pausing current transport "%s"',r.transport.name),r.transport.pause((function(){n||"closed"!==r.readyState&&(co("changing transport and sending upgrade packet"),l(),r.setTransport(t),t.send([{type:"upgrade"}]),r.emit("upgrade",t),t=null,r.upgrading=!1,r.flush())}))}else{co('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,r.emit("upgradeError",i)}})))}function i(){n||(n=!0,l(),t.close(),t=null)}function s(n){var o=new Error("probe error: "+n);o.transport=t.name,i(),co('probe transport "%s" failed because of error: %s',e,n),r.emit("upgradeError",o)}function a(){s("transport closed")}function c(){s("socket closed")}function u(e){t&&e.name!==t.name&&(co('"%s" works - aborting "%s"',e.name,t.name),i())}function l(){t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",a),r.removeListener("close",c),r.removeListener("upgrading",u)}mo.priorWebsocketSuccess=!1,t.once("open",o),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",u),t.open()},mo.prototype.onOpen=function(){if(co("socket open"),this.readyState="open",mo.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){co("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},mo.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(co('socket receive: type "%s", data "%s"',e.type,e.data),this.emit("packet",e),this.emit("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emit("data",e.data),this.emit("message",e.data)}else co('packet received with socket readyState "%s"',this.readyState)},mo.prototype.onHandshake=function(e){this.emit("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},mo.prototype.onHeartbeat=function(e){clearTimeout(this.pingTimeoutTimer);var t=this;t.pingTimeoutTimer=setTimeout((function(){"closed"!==t.readyState&&t.onClose("ping timeout")}),e||t.pingInterval+t.pingTimeout)},mo.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){co("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},mo.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},mo.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},mo.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(co("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},mo.prototype.write=mo.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},mo.prototype.sendPacket=function(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var o={type:e,data:t,options:n};this.emit("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}},mo.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var e=this;this.writeBuffer.length?this.once("drain",(function(){this.upgrading?r():t()})):this.upgrading?r():t()}function t(){e.onClose("forced close"),co("socket closing - telling transport to close"),e.transport.close()}function n(){e.removeListener("upgrade",n),e.removeListener("upgradeError",n),t()}function r(){e.once("upgrade",n),e.once("upgradeError",n)}return this},mo.prototype.onError=function(e){co("socket error %j",e),mo.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},mo.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){co('socket close with reason: "%s"',e);clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",e,t),this.writeBuffer=[],this.prevBufferLen=0}},mo.prototype.filterUpgrades=function(e){for(var t=[],n=0,r=e.length;n<r;n++)~uo(this.transports,e[n])&&t.push(e[n]);return t},gn.exports=fo,gn.exports.parser=Cn;var go={exports:{}},yo={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}(yo);var bo=function(e,t){for(var n=[],r=(t=t||0)||0;r<e.length;r++)n[r-t]=e[r];return n};var vo=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var wo=[].slice,_o=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=wo.call(arguments,2);return function(){return t.apply(e,n.concat(wo.call(arguments)))}};!function(e,t){var n=Gt,r=yo.exports,o=bo,i=vo,s=_o,a=Dt.exports("socket.io-client:socket"),c=or,u=On;e.exports=p;var l={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},h=r.prototype.emit;function p(e,t,n){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}r(p.prototype),p.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[i(e,"open",s(this,"onopen")),i(e,"packet",s(this,"onpacket")),i(e,"close",s(this,"onclose"))]}},p.prototype.open=p.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},p.prototype.send=function(){var e=o(arguments);return e.unshift("message"),this.emit.apply(this,e),this},p.prototype.emit=function(e){if(l.hasOwnProperty(e))return h.apply(this,arguments),this;var t=o(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:u(t))?n.BINARY_EVENT:n.EVENT,data:t,options:{}};return r.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(a("emitting packet with ack id %d",this.ids),this.acks[this.ids]=t.pop(),r.id=this.ids++),this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this},p.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},p.prototype.onopen=function(){if(a("transport is open - connecting"),"/"!==this.nsp)if(this.query){var e="object"==typeof this.query?c.encode(this.query):this.query;a("sending connect packet with query %s",e),this.packet({type:n.CONNECT,query:e})}else this.packet({type:n.CONNECT})},p.prototype.onclose=function(e){a("close (%s)",e),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},p.prototype.onpacket=function(e){var t=e.nsp===this.nsp,r=e.type===n.ERROR&&"/"===e.nsp;if(t||r)switch(e.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(e);break;case n.ACK:case n.BINARY_ACK:this.onack(e);break;case n.DISCONNECT:this.ondisconnect();break;case n.ERROR:this.emit("error",e.data)}},p.prototype.onevent=function(e){var t=e.data||[];a("emitting event %j",t),null!=e.id&&(a("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?h.apply(this,t):this.receiveBuffer.push(t)},p.prototype.ack=function(e){var t=this,r=!1;return function(){if(!r){r=!0;var i=o(arguments);a("sending ack %j",i),t.packet({type:u(i)?n.BINARY_ACK:n.ACK,id:e,data:i})}}},p.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(a("calling ack %s with %j",e.id,e.data),t.apply(this,e.data),delete this.acks[e.id]):a("bad ack %s",e.id)},p.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},p.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)h.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},p.prototype.ondisconnect=function(){a("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},p.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},p.prototype.close=p.prototype.disconnect=function(){return this.connected&&(a("performing disconnect (%s)",this.nsp),this.packet({type:n.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},p.prototype.compress=function(e){return this.flags.compress=e,this},p.prototype.binary=function(e){return this.flags.binary=e,this}}(go);var Co=So;function So(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}So.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},So.prototype.reset=function(){this.attempts=0},So.prototype.setMin=function(e){this.ms=e},So.prototype.setMax=function(e){this.max=e},So.prototype.setJitter=function(e){this.jitter=e};var ko=gn.exports,Eo=go.exports,Ao=yo.exports,Io=Gt,xo=vo,Oo=_o,Ro=Dt.exports("socket.io-client:manager"),To=io,Fo=Co,Po=Object.prototype.hasOwnProperty,jo=Bo;function Bo(e,t){if(!(this instanceof Bo))return new Bo(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new Fo({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=t.parser||Io;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}Bo.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)Po.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},Bo.prototype.updateSocketIds=function(){for(var e in this.nsps)Po.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},Bo.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Ao(Bo.prototype),Bo.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},Bo.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},Bo.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},Bo.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},Bo.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},Bo.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},Bo.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},Bo.prototype.open=Bo.prototype.connect=function(e,t){if(Ro("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;Ro("opening %s",this.uri),this.engine=ko(this.uri,this.opts);var n=this.engine,r=this;this.readyState="opening",this.skipReconnect=!1;var o=xo(n,"open",(function(){r.onopen(),e&&e()})),i=xo(n,"error",(function(t){if(Ro("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;Ro("connect attempt will timeout after %d",s);var a=setTimeout((function(){Ro("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},Bo.prototype.onopen=function(){Ro("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(xo(e,"data",Oo(this,"ondata"))),this.subs.push(xo(e,"ping",Oo(this,"onping"))),this.subs.push(xo(e,"pong",Oo(this,"onpong"))),this.subs.push(xo(e,"error",Oo(this,"onerror"))),this.subs.push(xo(e,"close",Oo(this,"onclose"))),this.subs.push(xo(this.decoder,"decoded",Oo(this,"ondecoded")))},Bo.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},Bo.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},Bo.prototype.ondata=function(e){this.decoder.add(e)},Bo.prototype.ondecoded=function(e){this.emit("packet",e)},Bo.prototype.onerror=function(e){Ro("error",e),this.emitAll("error",e)},Bo.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new Eo(this,e,t),this.nsps[e]=n;var r=this;n.on("connecting",o),n.on("connect",(function(){n.id=r.generateId(e)})),this.autoConnect&&o()}function o(){~To(r.connecting,n)||r.connecting.push(n)}return n},Bo.prototype.destroy=function(e){var t=To(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},Bo.prototype.packet=function(e){Ro("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()})))},Bo.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},Bo.prototype.cleanup=function(){Ro("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()},Bo.prototype.close=Bo.prototype.disconnect=function(){Ro("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},Bo.prototype.onclose=function(e){Ro("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},Bo.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)Ro("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();Ro("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var n=setTimeout((function(){e.skipReconnect||(Ro("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open((function(t){t?(Ro("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(Ro("reconnect success"),e.onreconnect())})))}),t);this.subs.push({destroy:function(){clearTimeout(n)}})}},Bo.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)},function(e,t){var n=Xt,r=Gt,o=jo,i=Dt.exports("socket.io-client");e.exports=t=a;var s=t.managers={};function a(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,a=n(e),c=a.source,u=a.id,l=a.path,h=s[u]&&l in s[u].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||h?(i("ignoring socket cache for %s",c),r=o(c,t)):(s[u]||(i("new io instance for %s",c),s[u]=o(c,t)),r=s[u]),a.query&&!t.query&&(t.query=a.query),r.socket(a.path,t)}t.protocol=r.protocol,t.connect=a,t.Manager=jo,t.Socket=go.exports}(Mt,Mt.exports);var Mo=Mt.exports;var No={exports:{}};No.exports=function(){function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){if(!a&&Y)return Y(s);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return o(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var i=Y,s=0;s<r.length;s++)o(r[s]);return o}return e}()({1:[function(e,t,n){(function(n,r){(function(){var o=e("events").EventEmitter,i=e("./store"),s=e("mqtt-packet"),a=e("readable-stream").Writable,c=e("inherits"),u=e("reinterval"),l=e("./validations"),h=e("xtend"),p=e("debug")("mqttjs:client"),f=n?n.nextTick:function(e){setTimeout(e,0)},d=r.setImmediate||function(e){f(e)},m={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},g=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],y={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function b(){return"mqttjs_"+Math.random().toString(16).substr(2,8)}function v(e,t,n){p("sendPacket :: packet: %O",t),p("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),p("sendPacket :: writing to stream");var r=s.writeToStream(t,e.stream,e.options);p("sendPacket :: writeToStream result %s",r),!r&&n?(p("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(p("sendPacket :: invoking cb"),n())}function w(e){e&&(p("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function _(e){e&&(p("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(e).forEach((function(t){e[t].volatile&&"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function C(e,t,n,r){p("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,(function(o){if(o)return n&&n(o);r(),v(e,t,n)}))}function S(e){p("nop ::",e)}function k(e,t){var n,r=this;if(!(this instanceof k))return new k(e,t);for(n in this.options=t||{},m)void 0===this.options[n]?this.options[n]=m[n]:this.options[n]=t[n];p("MqttClient :: options.protocol",t.protocol),p("MqttClient :: options.protocolVersion",t.protocolVersion),p("MqttClient :: options.username",t.username),p("MqttClient :: options.keepalive",t.keepalive),p("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),p("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),this.options.clientId="string"==typeof t.clientId?t.clientId:b(),p("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.outgoingStore=t.outgoingStore||new i,this.incomingStore=t.incomingStore||new i,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this._firstConnection=!0,this.on("connect",(function(){var e=this.queue;function t(){var n=e.shift();p("deliver :: entry %o",n);var o=null;n&&(o=n.packet,p("deliver :: call _sendPacket for %o",o),r._sendPacket(o,(function(e){n.cb&&n.cb(e),t()})))}p("connect :: sending queued packets"),t()})),this.on("close",(function(){p("close :: connected set to `false`"),this.connected=!1,p("close :: clearing connackTimer"),clearTimeout(this.connackTimer),p("close :: clearing ping timer"),null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),p("close :: calling _setupReconnect"),this._setupReconnect()})),o.call(this),p("MqttClient :: setting up stream"),this._setupStream()}c(k,o),k.prototype._setupStream=function(){var e,t=this,n=new a,r=s.parser(this.options),o=null,i=[];function c(){if(i.length)f(u);else{var e=o;o=null,e()}}function u(){p("work :: getting next packet in queue");var e=i.shift();if(e)p("work :: packet pulled from queue"),t._handlePacket(e,c);else{p("work :: no packets in queue");var n=o;o=null,p("work :: done flag is %s",!!n),n&&n()}}function l(e){p("streamErrorHandler :: error",e.message),g.includes(e.code)?(p("streamErrorHandler :: emitting error"),t.emit("error",e)):S(e)}if(p("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),p("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){p("parser :: on packet push to packets array."),i.push(e)})),n._write=function(e,t,n){o=n,p("writable stream :: parsing buffer"),r.parse(e),u()},p("_setupStream :: pipe stream to writable stream"),this.stream.pipe(n),this.stream.on("error",l),this.stream.on("close",(function(){p("(%s)stream :: on close",t.options.clientId),_(t.outgoing),p("stream: emit close to MqttClient"),t.emit("close")})),p("_setupStream: sending packet `connect`"),(e=Object.create(this.options)).cmd="connect",v(this,e),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return t.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&v(this,h({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){p("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)}),this.options.connectTimeout)},k.prototype._handlePacket=function(e,t){var n=this.options;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(p("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},k.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},k.prototype.publish=function(e,t,n,r){var o;p("publish :: message `%s` to topic `%s`",t,e);var i=this.options;if("function"==typeof n&&(r=n,n=null),n=h({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(o={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},5===i.protocolVersion&&(o.properties=n.properties,(!i.properties&&o.properties&&o.properties.topicAlias||n.properties&&i.properties&&(n.properties.topicAlias&&i.properties.topicAliasMaximum&&n.properties.topicAlias>i.properties.topicAliasMaximum||!i.properties.topicAliasMaximum&&n.properties.topicAlias))&&delete o.properties.topicAlias),p("publish :: qos",n.qos),n.qos){case 1:case 2:this.outgoing[o.messageId]={volatile:!1,cb:r||S},this._storeProcessing?(p("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[o.messageId]=!1,this._storePacket(o,void 0,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,void 0,n.cbStorePut));break;default:this._storeProcessing?(p("_storeProcessing enabled"),this._storePacket(o,r,n.cbStorePut)):(p("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,r,n.cbStorePut))}return this},k.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),n=0;n<arguments.length;n++)t[n]=arguments[n];var r,o=[],i=t.shift(),s=i.resubscribe,a=t.pop()||S,c=t.pop(),u=this,f=this.options.protocolVersion;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof a&&(c=a,a=S),null!==(r=l.validateTopics(i)))return d(a,new Error("Invalid topic "+r)),this;if(this._checkDisconnecting(a))return p("subscribe: discconecting true"),this;var m={qos:0};if(5===f&&(m.nl=!1,m.rap=!1,m.rh=0),c=h(m,c),Array.isArray(i)?i.forEach((function(e){if(p("subscribe: array topic %s",e),!u._resubscribeTopics.hasOwnProperty(e)||u._resubscribeTopics[e].qos<c.qos||s){var t={topic:e,qos:c.qos};5===f&&(t.nl=c.nl,t.rap=c.rap,t.rh=c.rh,t.properties=c.properties),p("subscribe: pushing topic `%s` and qos `%s` to subs list",t.topic,t.qos),o.push(t)}})):Object.keys(i).forEach((function(e){if(p("subscribe: object topic %s",e),!u._resubscribeTopics.hasOwnProperty(e)||u._resubscribeTopics[e].qos<i[e].qos||s){var t={topic:e,qos:i[e].qos};5===f&&(t.nl=i[e].nl,t.rap=i[e].rap,t.rh=i[e].rh,t.properties=c.properties),p("subscribe: pushing `%s` to subs list",t),o.push(t)}})),e={cmd:"subscribe",subscriptions:o,qos:1,retain:!1,dup:!1,messageId:this._nextId()},c.properties&&(e.properties=c.properties),o.length){if(this.options.resubscribe){p("subscribe :: resubscribe true");var g=[];o.forEach((function(e){if(u.options.reconnectPeriod>0){var t={qos:e.qos};5===f&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),u._resubscribeTopics[e.topic]=t,g.push(e.topic)}})),u.messageIdToTopic[e.messageId]=g}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var n=t.granted,r=0;r<n.length;r+=1)o[r].qos=n[r];a(e,o)}},p("subscribe :: call _sendPacket"),this._sendPacket(e),this}a(null,[])},k.prototype.unsubscribe=function(){for(var e={cmd:"unsubscribe",qos:1,messageId:this._nextId()},t=this,n=new Array(arguments.length),r=0;r<arguments.length;r++)n[r]=arguments[r];var o=n.shift(),i=n.pop()||S,s=n.pop();return"string"==typeof o&&(o=[o]),"function"!=typeof i&&(s=i,i=S),this._checkDisconnecting(i)||("string"==typeof o?e.unsubscriptions=[o]:Array.isArray(o)&&(e.unsubscriptions=o),this.options.resubscribe&&e.unsubscriptions.forEach((function(e){delete t._resubscribeTopics[e]})),"object"==typeof s&&s.properties&&(e.properties=s.properties),this.outgoing[e.messageId]={volatile:!0,cb:i},p("unsubscribe: call _sendPacket"),this._sendPacket(e)),this},k.prototype.end=function(e,t,n){var r=this;function o(){p("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(p("end :: closeStores: emitting end"),r.emit("end"),n){let r=e||t;p("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){p("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{p("end :: finish :: calling process.nextTick on closeStores"),f(o.bind(r))}),t)}return p("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||S,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=S))),"object"!=typeof t&&(n=t,t=null),p("end :: cb? %s",!!n),n=n||S,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(p("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(p("end :: (%s) :: immediately calling finish",r.options.clientId),i()),this)},k.prototype.removeOutgoingMessage=function(e){var t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},k.prototype.reconnect=function(e){p("client reconnect");var t=this,n=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new i,t.outgoingStore=t.options.outgoingStore||new i,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},k.prototype._reconnect=function(){p("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),p("client already connected. disconnecting first.")):(p("_reconnect: calling _setupStream"),this._setupStream())},k.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(p("_setupReconnect :: emit `offline` state"),this.emit("offline"),p("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),p("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){p("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):p("_setupReconnect :: doing nothing...")},k.prototype._clearReconnect=function(){p("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},k.prototype._cleanUp=function(e,t){var n=arguments[2];if(t&&(p("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),p("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&w(this.outgoing),p("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var r=h({cmd:"disconnect"},n);p("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(r,d.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(p("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(p("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(p("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},k.prototype._sendPacket=function(e,t,n){if(p("_sendPacket :: (%s) :: start",this.options.clientId),n=n||S,!this.connected)return p("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,n);switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void C(this,e,t,n);default:return void v(this,e,t)}switch(e.qos){case 2:case 1:C(this,e,t,n);break;default:v(this,e,t)}p("_sendPacket :: (%s) :: end",this.options.clientId)},k.prototype._storePacket=function(e,t,n){p("_storePacket :: packet: %o",e),p("_storePacket :: cb? %s",!!t),n=n||S,0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,(function(e){if(e)return t&&t(e);n()}))):t&&t(new Error("No connection to broker"))},k.prototype._setupPingTimer=function(){p("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=u((function(){e._checkPing()}),1e3*this.options.keepalive))},k.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},k.prototype._checkPing=function(){p("_checkPing :: checking ping..."),this.pingResp?(p("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(p("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},k.prototype._handlePingresp=function(){this.pingResp=!0},k.prototype._handleConnack=function(e){p("_handleConnack");var t=this.options,n=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=e.properties.topicAliasMaximum),e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)),0===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){var r=new Error("Connection refused: "+y[n]);r.code=n,this.emit("error",r)}},k.prototype._handlePublish=function(e,t){p("_handlePublish: packet %o",e),t=void 0!==t?t:S;var n=e.topic.toString(),r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];switch(p("_handlePublish: qos %d",o),o){case 2:a.customHandleAcks(n,r,e,(function(n,r){return n instanceof Error||(r=n,n=null),n?s.emit("error",n):-1===c.indexOf(r)?s.emit("error",new Error("Wrong reason code for pubrec")):void(r?s._sendPacket({cmd:"pubrec",messageId:i,reasonCode:r},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:i},t)})))}));break;case 1:a.customHandleAcks(n,r,e,(function(o,a){return o instanceof Error||(a=o,o=null),o?s.emit("error",o):-1===c.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",n,r,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:i,reasonCode:a},t)})))}));break;case 0:this.emit("message",n,r,e),this.handleMessage(e,t);break;default:p("_handlePublish: unknown QoS. Doing nothing.")}},k.prototype.handleMessage=function(e,t){t()},k.prototype._handleAck=function(e){var t,n=e.messageId,r=e.cmd,o=null,i=this.outgoing[n]?this.outgoing[n].cb:null,s=this;if(i){switch(p("_handleAck :: packet type",r),r){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+y[a])).code=a,i(t,e)),delete this.outgoing[n],this.outgoingStore.del(e,i);break;case"pubrec":o={cmd:"pubrel",qos:2,messageId:n};var c=e.reasonCode;c&&c>0&&16!==c?((t=new Error("Publish error: "+y[c])).code=c,i(t,e)):this._sendPacket(o);break;case"suback":delete this.outgoing[n];for(var u=0;u<e.granted.length;u++)if(0!=(128&e.granted[u])){var l=this.messageIdToTopic[n];l&&l.forEach((function(e){delete s._resubscribeTopics[e]}))}i(null,e);break;case"unsuback":delete this.outgoing[n],i(null);break;default:s.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else p("_handleAck :: Server sent an ack in error. Ignoring.")},k.prototype._handlePubrel=function(e,t){p("handling pubrel packet"),t=void 0!==t?t:S;var n=e.messageId,r=this,o={cmd:"pubcomp",messageId:n};r.incomingStore.get(e,(function(e,n){e?r._sendPacket(o,t):(r.emit("message",n.topic,n.payload,n),r.handleMessage(n,(function(e){if(e)return t(e);r.incomingStore.del(n,S),r._sendPacket(o,t)})))}))},k.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},k.prototype._nextId=function(){var e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},k.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},k.prototype._resubscribe=function(e){p("_resubscribe");var t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!e.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){p("_resubscribe: protocolVersion 5");for(var n=0;n<t.length;n++){var r={};r[t[n]]=this._resubscribeTopics[t[n]],r.resubscribe=!0,this.subscribe(r,{properties:r[t[n]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},k.prototype._onConnect=function(e){if(this.disconnected)this.emit("connect",e);else{var t=this;this._setupPingTimer(),this._resubscribe(e),this.connected=!0,n()}function n(){var r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,o()}function s(){if(r){t._storeProcessing=!0;var e,n=r.read(1);n?t._packetIdsDuringStoreProcessing[n.messageId]?s():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(e=t.outgoing[n.messageId]?t.outgoing[n.messageId].cb:null,t.outgoing[n.messageId]={volatile:!1,cb:function(t,n){e&&e(t,n),s()}},t._packetIdsDuringStoreProcessing[n.messageId]=!0,t._sendPacket(n)):r.once("readable",s)}}t.once("close",i),r.on("error",(function(e){o(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){var r=!0;for(var s in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[s]){r=!1;break}r?(o(),t.removeListener("close",i),t.emit("connect",e)):n()})),s()}},t.exports=k}).call(this)}).call(this,e("_process"),void 0!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./store":7,"./validations":8,_process:32,debug:15,events:19,inherits:21,"mqtt-packet":24,"readable-stream":51,reinterval:52,xtend:61}],2:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify"),c=!1;function u(){var e=new s;return e._write=function(e,t,n){r.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){r.closeSocket({success:function(){e()}})},e}function l(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function h(e,t){var n="alis"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function p(){c||(c=!0,r.onSocketOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onSocketMessage((function(e){if("string"==typeof e.data){var t=n.from(e.data,"base64");o.push(t)}else{var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;e=e instanceof ArrayBuffer?n.from(e):n.from(e,"utf8"),o.push(e)})),r.readAsArrayBuffer(e.data)}})),r.onSocketClose((function(){i.end(),i.destroy()})),r.onSocketError((function(e){i.destroy(e)})))}function f(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";l(t);var s=h(t,e);return(r=t.my).connectSocket({url:s,protocols:n}),o=u(),i=a.obj(),p(),i}t.exports=f}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],3:[function(e,t,n){var r=e("net"),o=e("debug")("mqttjs:tcp");function i(e,t){var n,i;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",n=t.port,i=t.hostname,o("port %d and host %s",n,i),r.createConnection(n,i)}t.exports=i},{debug:15,net:13}],4:[function(e,t,n){var r=e("tls"),o=e("debug")("mqttjs:tls");function i(e,t){var n;function i(r){t.rejectUnauthorized&&e.emit("error",r),n.end()}return t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.servername=t.host,t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized),(n=r.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",i)})),n.on("error",i),n}t.exports=i},{debug:15,tls:13}],5:[function(e,t,n){(function(n,r){(function(){const o=e("ws"),i=e("debug")("mqttjs:ws"),s=e("duplexify"),a=e("readable-stream").Transform;let c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const u=void 0!==n&&"browser"===n.title||"function"==typeof __webpack_require__;function l(e,t){let n=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(n=e.transformWsUrl(n,e,t)),n}function h(e){let t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),u||"wss"!==e.protocol||c.forEach((function(n){e.hasOwnProperty(n)&&!e.wsOptions.hasOwnProperty(n)&&(t.wsOptions[n]=e[n])})),t}function p(e){let t=h(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}function f(e,t,n){i("createWebSocket"),i("protocol: "+n.protocolId+" "+n.protocolVersion);const r="MQIsdp"===n.protocolId&&3===n.protocolVersion?"mqttv3.1":"mqtt";return i("creating new Websocket for url: "+t+" and protocol: "+r),new o(t,[r],n.wsOptions)}function d(e,t){const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";let r=l(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}function m(e,t){i("streamBuilder");let n=h(t);const r=l(n,e);let s=f(e,r,n),a=o.createWebSocketStream(s,n.wsOptions);return a.url=r,s.on("close",(()=>{a.destroy()})),a}function g(e,t){let n;i("browserStreamBuilder");const o=p(t).browserBufferSize||524288,c=t.browserBufferTimeout||1e3,u=!t.objectMode;let l=d(e,t),h=m(t,_,C);t.objectMode||(h._writev=w),h.on("close",(()=>{l.close()}));const f=void 0!==l.addEventListener;function m(e,t,n){let r=new a({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}function g(){n.setReadable(h),n.setWritable(h),n.emit("connect")}function y(){n.end(),n.destroy()}function b(e){n.destroy(e)}function v(e){let t=e.data;t=t instanceof ArrayBuffer?r.from(t):r.from(t,"utf8"),h.push(t)}function w(e,t){const n=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?n[t]=r.from(e[t],"utf8"):n[t]=e[t].chunk;this._write(r.concat(n),"binary",t)}function _(e,t,n){l.bufferedAmount>o&&setTimeout(_,c,e,t,n),u&&"string"==typeof e&&(e=r.from(e,"utf8"));try{l.send(e)}catch(e){return n(e)}n()}function C(e){l.close(),e()}return l.readyState===l.OPEN?n=h:(n=n=s(void 0,void 0,t),t.objectMode||(n._writev=w),f?l.addEventListener("open",g):l.onopen=g),n.socket=l,f?(l.addEventListener("close",y),l.addEventListener("error",b),l.addEventListener("message",v)):(l.onclose=y,l.onerror=b,l.onmessage=v),n}t.exports=u?g:m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,debug:15,duplexify:17,"readable-stream":51,ws:60}],6:[function(e,t,n){(function(n){(function(){var r,o,i,s=e("readable-stream").Transform,a=e("duplexify");function c(){var e=new s;return e._write=function(e,t,n){r.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){r.close({success:function(){e()}})},e}function u(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}function l(e,t){var n="wxs"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function h(){r.onOpen((function(){i.setReadable(o),i.setWritable(o),i.emit("connect")})),r.onMessage((function(e){var t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),o.push(t)})),r.onClose((function(){i.end(),i.destroy()})),r.onError((function(e){i.destroy(new Error(e.errMsg))}))}function p(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";u(t);var s=l(t,e);r=wx.connectSocket({url:s,protocols:[n]}),o=c(),(i=a.obj())._destroy=function(e,t){r.close({success:function(){t&&t(e)}})};var p=i.destroy;return i.destroy=function(){i.destroy=p;var e=this;setTimeout((function(){r.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(i),h(),i}t.exports=p}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14,duplexify:17,"readable-stream":51}],7:[function(e,t,n){var r=e("xtend"),o=e("readable-stream").Readable,i={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=r(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){var e=new o(i),t=!1,n=[],r=0;return this._inflights.forEach((function(e,t){n.push(e)})),e._read=function(){!t&&r<n.length?this.push(n[r++]):this.push(null)},e.destroy=function(){if(!t){var e=this;t=!0,setTimeout((function(){e.emit("close")}),0)}},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=a},{"readable-stream":51,xtend:61}],8:[function(e,t,n){function r(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}function o(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!r(e[t]))return e[t];return null}t.exports={validateTopics:o}},{}],9:[function(e,t,n){(function(n){(function(){var r=e("../client"),o=e("../store"),i=e("url"),s=e("xtend"),a=e("debug")("mqttjs"),c={};function u(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}function l(e,t){if(a("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){var n=i.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=s(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(u(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!c[t.protocol]){var o=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(e,t){return(!o||t%2!=0)&&"function"==typeof c[e]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");function l(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),a("calling streambuilder for",t.protocol),c[t.protocol](e,t)}t.protocol&&(t.defaultProtocol=t.protocol);var h=new r(l,t);return h.on("error",(function(){})),h}void 0!==n&&"browser"!==n.title||"function"!=typeof __webpack_require__?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=l,t.exports.connect=l,t.exports.MqttClient=r,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":7,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:32,debug:15,url:56,xtend:61}],10:[function(e,t,n){n.byteLength=l,n.toByteArray=p,n.fromByteArray=m;for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e){var t=u(e),n=t[0],r=t[1];return 3*(n+r)/4-r}function h(e,t,n){return 3*(t+n)/4-n}function p(e){var t,n,r=u(e),s=r[0],a=r[1],c=new i(h(e,s,a)),l=0,p=a>0?s-4:s;for(n=0;n<p;n+=4)t=o[e.charCodeAt(n)]<<18|o[e.charCodeAt(n+1)]<<12|o[e.charCodeAt(n+2)]<<6|o[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===a&&(t=o[e.charCodeAt(n)]<<2|o[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===a&&(t=o[e.charCodeAt(n)]<<10|o[e.charCodeAt(n+1)]<<4|o[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c}function f(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function d(e,t,n){for(var r,o=[],i=t;i<n;i+=3)r=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(255&e[i+2]),o.push(f(r));return o.join("")}function m(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,c=n-o;a<c;a+=s)i.push(d(e,a,a+s>c?c:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],11:[function(e,t,n){const{Buffer:r}=e("buffer"),o=Symbol.for("BufferList");function i(e){if(!(this instanceof i))return new i(e);i._init.call(this,e)}i._init=function(e){Object.defineProperty(this,o,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},i.prototype._new=function(e){return new i(e)},i.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let n=0;n<this._bufs.length;n++){const r=t+this._bufs[n].length;if(e<r||n===this._bufs.length-1)return[n,e-t];t=r}},i.prototype._reverseOffset=function(e){const t=e[0];let n=e[1];for(let e=0;e<t;e++)n+=this._bufs[e].length;return n},i.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,n,o){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof o||o>this.length)&&(o=this.length),n>=this.length)return e||r.alloc(0);if(o<=0)return e||r.alloc(0);const i=!!e,s=this._offset(n),a=o-n;let c=a,u=i&&t||0,l=s[1];if(0===n&&o===this.length){if(!i)return 1===this._bufs.length?this._bufs[0]:r.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,u),u+=this._bufs[t].length;return e}if(c<=this._bufs[s[0]].length-l)return i?this._bufs[s[0]].copy(e,t,l,l+c):this._bufs[s[0]].slice(l,l+c);i||(e=r.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const n=this._bufs[t].length-l;if(!(c>n)){this._bufs[t].copy(e,u,l,l+c),u+=n;break}this._bufs[t].copy(e,u,l),u+=n,c-=n,l&&(l=0)}return e.length>u?e.slice(0,u):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const n=this._offset(e),r=this._offset(t),o=this._bufs.slice(n[0],r[0]+1);return 0===r[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,r[1]),0!==n[1]&&(o[0]=o[0].slice(n[1])),this._new(o)},i.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},i.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(r.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(r.from(e));return this},i.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},i.prototype.indexOf=function(e,t,n){if(void 0===n&&"string"==typeof t&&(n=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=r.from([e]):"string"==typeof e?e=r.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=r.from(e.buffer,e.byteOffset,e.byteLength):r.isBuffer(e)||(e=r.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const o=this._offset(t);let i=o[0],s=o[1];for(;i<this._bufs.length;i++){const t=this._bufs[i];for(;s<t.length;)if(t.length-s>=e.length){const n=t.indexOf(e,s);if(-1!==n)return this._reverseOffset([i,n]);s=t.length-e.length+1}else{const t=this._reverseOffset([i,s]);if(this._match(t,e))return t;s++}s=0}return-1},i.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let n=0;n<t.length;n++)if(this.get(e+n)!==t[n])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){null===e[t]?i.prototype[t]=function(e,n){return this.slice(e,e+n)[t](0,n)}:i.prototype[t]=function(n=0){return this.slice(n,n+e[t])[t](0)}}(t)}(),i.prototype._isBufferList=function(e){return e instanceof i||i.isBufferList(e)},i.isBufferList=function(e){return null!=e&&e[o]},t.exports=i},{buffer:14}],12:[function(e,t,n){const r=e("readable-stream").Duplex,o=e("inherits"),i=e("./BufferList");function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}i._init.call(this,e),r.call(this)}o(s,r),Object.assign(s.prototype,i.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){r.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof i||s.isBufferList(e)},s.isBufferList=i.isBufferList,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=i},{"./BufferList":11,inherits:21,"readable-stream":51}],13:[function(e,t,n){},{}],14:[function(e,t,n){(function(t){(function(){var t=e("base64-js"),r=e("ieee754");n.Buffer=a,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50;var o=2147483647;function i(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function s(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=a.prototype,t}function a(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return c(e,t,n)}function c(e,t,n){if("string"==typeof e)return p(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return d(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return a.from(r,t,n);var o=m(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return a.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e,t,n){return u(e),e<=0?s(e):void 0!==t?"string"==typeof n?s(e).fill(t,n):s(e).fill(t):s(e)}function h(e){return u(e),s(e<0?0:0|g(e))}function p(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|b(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function f(e){for(var t=e.length<0?0:0|g(e.length),n=s(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function d(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return(r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n)).__proto__=a.prototype,r}function m(e){if(a.isBuffer(e)){var t=0|g(e.length),n=s(t);return 0===n.length||e.copy(n,0,0,t),n}return void 0!==e.length?"number"!=typeof e.length||X(e.length)?s(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}function g(e){if(e>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),a.alloc(+e)}function b(e,t){if(a.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return J(e).length;default:if(o)return r?-1:z(e).length;t=(""+t).toLowerCase(),o=!0}}function v(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return B(this,t,n);case"utf8":case"utf-8":return R(this,t,n);case"ascii":return P(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return O(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function _(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),X(n=+n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:C(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):C(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function C(e,t,n,r,o){var i,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=n;i<a;i++)if(u(e,i)===u(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===c)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+c>a&&(n=a-c),i=n;i>=0;i--){for(var h=!0,p=0;p<c;p++)if(u(e,i+p)!==u(t,p)){h=!1;break}if(h)return i}return-1}function S(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(X(a))return s;e[n+s]=a}return s}function k(e,t,n,r){return Q(z(t,e.length-n),e,n,r)}function E(e,t,n,r){return Q(V(t),e,n,r)}function A(e,t,n,r){return E(e,t,n,r)}function I(e,t,n,r){return Q(J(t),e,n,r)}function x(e,t,n,r){return Q(K(t,e.length-n),e,n,r)}function O(e,n,r){return 0===n&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function R(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,c,u=e[o],l=null,h=u>239?4:u>223?3:u>191?2:1;if(o+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(i=e[o+1]))&&(c=(31&u)<<6|63&i)>127&&(l=c);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=h}return F(r)}n.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=i(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),a.poolSize=8192,a.from=function(e,t,n){return c(e,t,n)},a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,a.alloc=function(e,t,n){return l(e,t,n)},a.allocUnsafe=function(e){return h(e)},a.allocUnsafeSlow=function(e){return h(e)},a.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==a.prototype},a.compare=function(e,t){if(Y(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=a.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(Y(i,Uint8Array)&&(i=a.from(i)),!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},a.byteLength=b,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},a.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?R(this,0,e):v.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,o){if(Y(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),u=this.slice(r,o),l=e.slice(t,n),h=0;h<c;++h)if(u[h]!==l[h]){i=u[h],s=l[h];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return _(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return _(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return S(this,e,t,n);case"utf8":case"utf-8":return k(this,e,t,n);case"ascii":return E(this,e,t,n);case"latin1":case"binary":return A(this,e,t,n);case"base64":return I(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function F(e){var t=e.length;if(t<=T)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=T));return n}function P(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function j(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 B(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=t;i<n;++i)o+=W(e[i]);return o}function M(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 N(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||N(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||N(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||N(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(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||N(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||N(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||N(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||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){e>>>=0,t||N(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||N(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||N(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||N(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||N(e,4,this.length),r.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),r.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),r.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(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 $=/[^+/0-9A-Za-z-_]/g;function H(e){if((e=(e=e.split("=")[0]).trim().replace($,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function W(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(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 V(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function K(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}function J(e){return t.toByteArray(H(e))}function Q(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":10,buffer:14,ieee754:20}],15:[function(e,t,n){(function(r){(function(){function o(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}function s(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}}function a(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return localStorage}catch(e){}}n.formatArgs=i,n.save=s,n.load=a,n.useColors=o,n.storage=c(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:u}=t.exports;u.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":16,_process:32}],16:[function(e,t,n){function r(t){function n(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){let t,n=null;function i(...e){if(!i.enabled)return;const n=i,o=Number(new Date),s=o-(t||o);n.diff=s,n.prev=t,n.curr=o,t=o,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,o)=>{if("%%"===t)return"%";a++;const i=r.formatters[o];if("function"==typeof i){const r=e[a];t=i.call(n,r),e.splice(a,1),a--}return t})),r.formatArgs.call(n,e),(n.log||r.log).apply(n,e)}return i.namespace=e,i.useColors=r.useColors(),i.color=r.selectColor(e),i.extend=o,i.destroy=r.destroy,Object.defineProperty(i,"enabled",{enumerable:!0,configurable:!1,get:()=>null===n?r.enabled(e):n,set:e=>{n=e}}),"function"==typeof r.init&&r.init(i),i}function o(e,t){const n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function i(e){let t;r.save(e),r.names=[],r.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function s(){const e=[...r.names.map(c),...r.skips.map(c).map((e=>"-"+e))].join(",");return r.enable(""),e}function a(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1}function c(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function u(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.debug=r,r.default=r,r.coerce=u,r.disable=s,r.enable=i,r.enabled=a,r.humanize=e("ms"),r.destroy=l,Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}t.exports=r},{ms:29}],17:[function(e,t,n){(function(n,r){(function(){var o=e("readable-stream"),i=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),c=r.from&&r.from!==Uint8Array.from?r.from([0]):new r([0]),u=function(e,t){e._corked?e.once("uncork",t):t()},l=function(e,t){e._autoDestroy&&e.destroy(t)},h=function(e,t){return function(n){n?l(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},p=function(e,t){return e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),void t()):t()},f=function(){},d=function(e){return new o.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},m=function(e,t,n){if(!(this instanceof m))return new m(e,t,n);o.Duplex.call(this,n),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!n||!1!==n.autoDestroy,this._forwardDestroy=!n||!1!==n.destroy,this._forwardEnd=!n||!1!==n.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(m,o.Duplex),m.obj=function(e,t,n){return n||(n={}),n.objectMode=!0,n.highWaterMark=16,new m(e,t,n)},m.prototype.cork=function(){1==++this._corked&&this.emit("cork")},m.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},m.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=i(e,{writable:!0,readable:!1},h(this,this._forwardEnd)),o=function(){var e=t._ondrain;t._ondrain=null,e&&e()},s=function(){t._writable.removeListener("drain",o),r()};this._unwrite&&n.nextTick(o),this._writable=e,this._writable.on("drain",o),this._unwrite=s,this.uncork()}else this.end()},m.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t=this,n=i(e,{writable:!1,readable:!0},h(this)),r=function(){t._forward()},o=function(){t.push(null)},s=function(){t._readable2.removeListener("readable",r),t._readable2.removeListener("end",o),n()};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:d(e),this._readable2.on("readable",r),this._readable2.on("end",o),this._unread=s,this._forward()}},m.prototype._read=function(){this._drained=!0,this._forward()},m.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},m.prototype.destroy=function(e,t){if(t||(t=f),this.destroyed)return t(null);this.destroyed=!0;var r=this;n.nextTick((function(){r._destroy(e),t(null)}))},m.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},m.prototype._write=function(e,t,n){if(!this.destroyed)return this._corked?u(this,this._write.bind(this,e,t,n)):e===c?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:this.destroyed||n()):n()},m.prototype._finish=function(e){var t=this;this.emit("preend"),u(this,(function(){p(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),u(t,e)}))}))},m.prototype.end=function(e,t,n){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(c),o.Writable.prototype.end.call(this,n))},t.exports=m}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:32,buffer:14,"end-of-stream":18,inherits:21,"readable-stream":51,"stream-shift":54}],18:[function(e,t,n){(function(n){(function(){var r=e("once"),o=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},s=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,c){if("function"==typeof t)return a(e,null,t);t||(t={}),c=r(c||o);var u=e._writableState,l=e._readableState,h=t.readable||!1!==t.readable&&e.readable,p=t.writable||!1!==t.writable&&e.writable,f=!1,d=function(){e.writable||m()},m=function(){p=!1,h||c.call(e)},g=function(){h=!1,p||c.call(e)},y=function(t){c.call(e,t?new Error("exited with error code: "+t):null)},b=function(t){c.call(e,t)},v=function(){n.nextTick(w)},w=function(){if(!f)return(!h||l&&l.ended&&!l.destroyed)&&(!p||u&&u.ended&&!u.destroyed)?void 0:c.call(e,new Error("premature close"))},_=function(){e.req.on("finish",m)};return i(e)?(e.on("complete",m),e.on("abort",v),e.req?_():e.on("request",_)):p&&!u&&(e.on("end",d),e.on("close",d)),s(e)&&e.on("exit",y),e.on("end",g),e.on("finish",m),!1!==t.error&&e.on("error",b),e.on("close",v),function(){f=!0,e.removeListener("complete",m),e.removeListener("abort",v),e.removeListener("request",_),e.req&&e.req.removeListener("finish",m),e.removeListener("end",d),e.removeListener("close",d),e.removeListener("finish",m),e.removeListener("exit",y),e.removeListener("end",g),e.removeListener("error",b),e.removeListener("close",v)}};t.exports=a}).call(this)}).call(this,e("_process"))},{_process:32,once:30}],19:[function(e,t,n){var r=Object.create||k,o=Object.keys||E,i=Function.prototype.bind||A;function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,c=10;try{var u={};Object.defineProperty&&Object.defineProperty(u,"x",{value:0}),a=0===u.x}catch(e){a=!1}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,n){if(t)e.call(n);else for(var r=e.length,o=C(e,r),i=0;i<r;++i)o[i].call(n)}function p(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,i=C(e,o),s=0;s<o;++s)i[s].call(n,r)}function f(e,t,n,r,o){if(t)e.call(n,r,o);else for(var i=e.length,s=C(e,i),a=0;a<i;++a)s[a].call(n,r,o)}function d(e,t,n,r,o,i){if(t)e.call(n,r,o,i);else for(var s=e.length,a=C(e,s),c=0;c<s;++c)a[c].call(n,r,o,i)}function m(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,i=C(e,o),s=0;s<o;++s)i[s].apply(n,r)}function g(e,t,n,o){var i,s,a;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),a=s[t]):(s=e._events=r(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=o?[n,a]:[a,n]:o?a.unshift(n):a.push(n),!a.warned&&(i=l(e))&&i>0&&a.length>i){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",c.name,c.message)}}else a=s[t]=n,++e._eventsCount;return e}function y(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function b(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=i.call(y,r);return o.listener=n,r.wrapFn=o,o}function v(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?S(o):C(o,o.length):[]}function w(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function _(e,t){for(var n=t,r=n+1,o=e.length;r<o;n+=1,r+=1)e[n]=e[r];e.pop()}function C(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function S(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function k(e){var t=function(){};return t.prototype=e,new t}function E(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t);return t}function A(e){var t=this;return function(){return t.apply(e,arguments)}}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');c=e}}):s.defaultMaxListeners=c,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){var t,n,r,o,i,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var c=new Error('Unhandled "error" event. ('+t+")");throw c.context=t,c}if(!(n=s[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:h(n,u,this);break;case 2:p(n,u,this,arguments[1]);break;case 3:f(n,u,this,arguments[1],arguments[2]);break;case 4:d(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i<r;i++)o[i-1]=arguments[i];m(n,u,this,o)}return!0},s.prototype.addListener=function(e,t){return g(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return g(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,b(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,b(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():_(n,i),1===n.length&&(o[e]=n[0]),o.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,n,i;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=r(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=r(null):delete n[e]),this;if(0===arguments.length){var s,a=o(n);for(i=0;i<a.length;++i)"removeListener"!==(s=a[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=r(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return v(this,e,!0)},s.prototype.rawListeners=function(e){return v(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):w.call(e,t)},s.prototype.listenerCount=w,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],20:[function(e,t,n){
3
+ /*! 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,u=c>>1,l=-7,h=n?o-1:0,p=n?-1:1,f=e[t+h];for(h+=p,i=f&(1<<-l)-1,f>>=-l,l+=a;l>0;i=256*i+e[t+h],h+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=p,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),i-=u}return(f?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,c,u=8*i-o-1,l=(1<<u)-1,h=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,d=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?p/c:p*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,o),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,o),s=0));o>=8;e[n+f]=255&a,f+=d,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;e[n+f]=255&s,f+=d,s/=256,u-=8);e[n+f-d]|=128*m}},{}],21:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],22:[function(e,t,n){(function(e){(function(){const n=t.exports;n.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},n.codes={};for(const e in n.types){const t=n.types[e];n.codes[t]=e}n.CMD_SHIFT=4,n.CMD_MASK=240,n.DUP_MASK=8,n.QOS_MASK=3,n.QOS_SHIFT=1,n.RETAIN_MASK=1,n.VARBYTEINT_MASK=127,n.VARBYTEINT_FIN_MASK=128,n.VARBYTEINT_MAX=268435455,n.SESSIONPRESENT_MASK=1,n.SESSIONPRESENT_HEADER=e.from([n.SESSIONPRESENT_MASK]),n.CONNACK_HEADER=e.from([n.codes.connack<<n.CMD_SHIFT]),n.USERNAME_MASK=128,n.PASSWORD_MASK=64,n.WILL_RETAIN_MASK=32,n.WILL_QOS_MASK=24,n.WILL_QOS_SHIFT=3,n.WILL_FLAG_MASK=4,n.CLEAN_SESSION_MASK=2,n.CONNECT_HEADER=e.from([n.codes.connect<<n.CMD_SHIFT]),n.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},n.propertiesCodes={};for(const e in n.properties){const t=n.properties[e];n.propertiesCodes[t]=e}function r(t){return[0,1,2].map((r=>[0,1].map((o=>[0,1].map((i=>{const s=e.alloc(1);return s.writeUInt8(n.codes[t]<<n.CMD_SHIFT|(o?n.DUP_MASK:0)|r<<n.QOS_SHIFT|i,0,!0),s}))))))}n.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},n.PUBLISH_HEADER=r("publish"),n.SUBSCRIBE_HEADER=r("subscribe"),n.SUBSCRIBE_OPTIONS_QOS_MASK=3,n.SUBSCRIBE_OPTIONS_NL_MASK=1,n.SUBSCRIBE_OPTIONS_NL_SHIFT=2,n.SUBSCRIBE_OPTIONS_RAP_MASK=1,n.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,n.SUBSCRIBE_OPTIONS_RH_MASK=3,n.SUBSCRIBE_OPTIONS_RH_SHIFT=4,n.SUBSCRIBE_OPTIONS_RH=[0,16,32],n.SUBSCRIBE_OPTIONS_NL=4,n.SUBSCRIBE_OPTIONS_RAP=8,n.SUBSCRIBE_OPTIONS_QOS=[0,1,2],n.UNSUBSCRIBE_HEADER=r("unsubscribe"),n.ACKS={unsuback:r("unsuback"),puback:r("puback"),pubcomp:r("pubcomp"),pubrel:r("pubrel"),pubrec:r("pubrec")},n.SUBACK_HEADER=e.from([n.codes.suback<<n.CMD_SHIFT]),n.VERSION3=e.from([3]),n.VERSION4=e.from([4]),n.VERSION5=e.from([5]),n.VERSION131=e.from([131]),n.VERSION132=e.from([132]),n.QOS=[0,1,2].map((t=>e.from([t]))),n.EMPTY={pingreq:e.from([n.codes.pingreq<<4,0]),pingresp:e.from([n.codes.pingresp<<4,0]),disconnect:e.from([n.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14}],23:[function(e,t,n){(function(n){(function(){const r=e("./writeToStream"),o=e("events");function i(e,t){const n=new s;return r(e,n,t),n.concat()}class s extends o{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),r=this._array;let o,i=0;for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?t[o]=r[o].length:t[o]=n.byteLength(r[o]),e+=t[o];const s=n.allocUnsafe(e);for(o=0;o<r.length&&void 0!==r[o];o++)"string"!=typeof r[o]?(r[o].copy(s,i),i+=t[o]):(s.write(r[o],i),i+=t[o]);return s}}t.exports=i}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":28,buffer:14,events:19}],24:[function(e,t,n){n.parser=e("./parser").parser,n.generate=e("./generate"),n.writeToStream=e("./writeToStream")},{"./generate":23,"./parser":27,"./writeToStream":28}],25:[function(e,t,n){(function(e){(function(){const n=65536,r={},o=e.isBuffer(e.from([1,2]).subarray(0,1));function i(t){const n=e.allocUnsafe(2);return n.writeUInt8(t>>8,0),n.writeUInt8(255&t,1),n}function s(){for(let e=0;e<n;e++)r[e]=i(e)}function a(t){const n=4;let r=0,i=0;const s=e.allocUnsafe(n);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),s.writeUInt8(r,i++)}while(t>0&&i<n);return t>0&&(i=0),o?s.subarray(0,i):s.slice(0,i)}function c(t){const n=e.allocUnsafe(4);return n.writeUInt32BE(t,0),n}t.exports={cache:r,generateCache:s,generateNumber:i,genBufVariableByteInt:a,generate4ByteBuffer:c}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:14}],26:[function(e,t,n){class r{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}t.exports=r},{}],27:[function(e,t,n){const r=e("bl"),o=e("events"),i=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class c extends o{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof c?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new c).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new i,this.error=null,this._list=r(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;a("_parseConnect");const o={},i=this.packet,c=this._parseString();if(null===c)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==c&&"MQIsdp"!==c)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=c,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(i.protocolVersion=this._list.readUInt8(this._pos),i.protocolVersion>=128&&(i.bridgeMode=!0,i.protocolVersion=i.protocolVersion-128),3!==i.protocolVersion&&4!==i.protocolVersion&&5!==i.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,i.keepalive=this._parseNum(),-1===i.keepalive)return this._emitError(new Error("Packet too short"));if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.properties=e)}const u=this._parseString();if(null===u)return this._emitError(new Error("Packet too short"));if(i.clientId=u,a("_parseConnect: packet.clientId: %s",i.clientId),o.will){if(5===i.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(i.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(i.will.topic=e,a("_parseConnect: packet.will.topic: %s",i.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));i.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",i.will.payload)}if(o.username){if(r=this._parseString(),null===r)return this._emitError(new Error("Cannot parse username"));i.username=r,a("_parseConnect: packet.username: %s",i.username)}if(o.password){if(n=this._parseBuffer(),null===n)return this._emitError(new Error("Cannot parse password"));i.password=n}return this.settings=i,a("_parseConnect: complete"),i}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,n,r,o,i,c,u;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));n=this._parseByte(),r=n&s.SUBSCRIBE_OPTIONS_QOS_MASK,c=0!=(n>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(n>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),o=n>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,u={topic:t,qos:r},5===this.settings.protocolVersion?(u.nl=c,u.rap=i,u.rh=o):this.settings.bridgeMode&&(u.rh=0,u.rap=!0,u.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",u),e.subscriptions.push(u)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),n=t+this._pos;if(-1===t||n>this._list.length||n>this.packet.length)return null;const r=this._list.toString("utf8",this._pos,n);return this._pos+=t,a("_parseString: result: %s",r),r}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const n=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",n),n}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");const t=4;let n,r=0,o=1,i=0,c=!1;const u=this._pos?this._pos:0;for(;r<t&&u+r<this._list.length;){if(n=this._list.readUInt8(u+r++),i+=o*(n&s.VARBYTEINT_MASK),o*=128,0==(n&s.VARBYTEINT_FIN_MASK)){c=!0;break}if(this._list.length<=r)break}return!c&&r===t&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),u&&(this._pos+=r),c=!!c&&(e?{bytes:r,value:i}:i),a("_parseVarByteNum: result: %o",c),c}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,n={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)n[t]?(Array.isArray(n[t])||(n[t]=[n[t]]),n[t].push(this._parseByType(s.propertiesTypes[t]))):n[t]=this._parseByType(s.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(n[t][e.name])if(Array.isArray(n[t][e.name]))n[t][e.name].push(e.value);else{const r=n[t][e.name];n[t][e.name]=[r],n[t][e.name].push(e.value)}else n[t][e.name]=e.value}}return n}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new i,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}t.exports=c},{"./constants":22,"./packet":26,bl:12,debug:15,events:19}],28:[function(e,t,n){(function(n){(function(){const r=e("./constants"),o=n.allocUnsafe(0),i=n.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,c=e("debug")("mqtt-packet:writeToStream"),u=s.cache,l=s.generateNumber,h=s.generateCache,p=s.genBufVariableByteInt,f=s.generate4ByteBuffer;let d=P,m=!0;function g(e,t,n){switch(c("generate called"),t.cork&&(t.cork(),a(y,t)),m&&(m=!1,h()),c("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return b(e,t);case"connack":return v(e,t,n);case"publish":return w(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return _(e,t,n);case"subscribe":return C(e,t,n);case"suback":return S(e,t,n);case"unsubscribe":return k(e,t,n);case"unsuback":return E(e,t,n);case"pingreq":case"pingresp":return A(e,t);case"disconnect":return I(e,t,n);case"auth":return x(e,t,n);default:return t.emit("error",new Error("Unknown command")),!1}}function y(e){e.uncork()}function b(e,t,o){const i=e||{},s=i.protocolId||"MQTT";let a=i.protocolVersion||4;const c=i.will;let u=i.clean;const l=i.keepalive||0,h=i.clientId||"",p=i.username,f=i.password,m=i.properties;void 0===u&&(u=!0);let g=0;if(!s||"string"!=typeof s&&!n.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(g+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(g+=1,("string"==typeof h||n.isBuffer(h))&&(h||a>=4)&&(h||u))g+=n.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*u==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof l||l<0||l>65535||l%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(g+=2,g+=1,5===a){var y=N(t,m);if(!y)return!1;g+=y.length}if(c){if("object"!=typeof c)return t.emit("error",new Error("Invalid will")),!1;if(!c.topic||"string"!=typeof c.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(g+=n.byteLength(c.topic)+2,g+=2,c.payload){if(!(c.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof c.payload?g+=n.byteLength(c.payload):g+=c.payload.length}var b={};if(5===a){if(!(b=N(t,c.properties)))return!1;g+=b.length}}let v=!1;if(null!=p){if(!$(p))return t.emit("error",new Error("Invalid username")),!1;v=!0,g+=n.byteLength(p)+2}if(null!=f){if(!v)return t.emit("error",new Error("Username is required to use password")),!1;if(!$(f))return t.emit("error",new Error("Invalid password")),!1;g+=q(f)+2}t.write(r.CONNECT_HEADER),R(t,g),M(t,s),i.bridgeMode&&(a+=128),t.write(131===a?r.VERSION131:132===a?r.VERSION132:4===a?r.VERSION4:5===a?r.VERSION5:r.VERSION3);let w=0;return w|=null!=p?r.USERNAME_MASK:0,w|=null!=f?r.PASSWORD_MASK:0,w|=c&&c.retain?r.WILL_RETAIN_MASK:0,w|=c&&c.qos?c.qos<<r.WILL_QOS_SHIFT:0,w|=c?r.WILL_FLAG_MASK:0,w|=u?r.CLEAN_SESSION_MASK:0,t.write(n.from([w])),d(t,l),5===a&&y.write(),M(t,h),c&&(5===a&&b.write(),T(t,c.topic),M(t,c.payload)),null!=p&&M(t,p),null!=f&&M(t,f),!0}function v(e,t,o){const s=o?o.protocolVersion:4,a=e||{},c=5===s?a.reasonCode:a.returnCode,u=a.properties;let l=2;if("number"!=typeof c)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=N(t,u),!h)return!1;l+=h.length}return t.write(r.CONNACK_HEADER),R(t,l),t.write(a.sessionPresent?r.SESSIONPRESENT_HEADER:i),t.write(n.from([c])),null!=h&&h.write(),!0}function w(e,t,i){c("publish: packet: %o",e);const s=i?i.protocolVersion:4,a=e||{},u=a.qos||0,l=a.retain?r.RETAIN_MASK:0,h=a.topic,p=a.payload||o,f=a.messageId,m=a.properties;let g=0;if("string"==typeof h)g+=n.byteLength(h)+2;else{if(!n.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;g+=h.length+2}if(n.isBuffer(p)?g+=p.length:g+=n.byteLength(p),u&&"number"!=typeof f)return t.emit("error",new Error("Invalid messageId")),!1;u&&(g+=2);let y=null;if(5===s){if(y=N(t,m),!y)return!1;g+=y.length}return t.write(r.PUBLISH_HEADER[u][a.dup?1:0][l?1:0]),R(t,g),d(t,q(h)),t.write(h),u>0&&d(t,f),null!=y&&y.write(),c("publish: payload: %o",p),t.write(p)}function _(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.cmd||"puback",c=s.messageId,u=s.dup&&"pubrel"===a?r.DUP_MASK:0;let l=0;const h=s.reasonCode,p=s.properties;let f=5===i?3:2;if("pubrel"===a&&(l=1),"number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===i&&"object"==typeof p){if(m=U(t,p,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[a][l][u][0]),R(t,f),d(t,c),5===i&&t.write(n.from([h])),null!==m&&m.write(),!0}function C(e,t,o){c("subscribe: packet: ");const i=o?o.protocolVersion:4,s=e||{},a=s.dup?r.DUP_MASK:0,u=s.messageId,l=s.subscriptions,h=s.properties;let p=0;if("number"!=typeof u)return t.emit("error",new Error("Invalid messageId")),!1;p+=2;let f=null;if(5===i){if(f=N(t,h),!f)return!1;p+=f.length}if("object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<l.length;e+=1){const r=l[e].topic,o=l[e].qos;if("string"!=typeof r)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===i){if("boolean"!=typeof(l[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(l[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=l[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=n.byteLength(r)+2+1}c("subscribe: writing to stream: %o",r.SUBSCRIBE_HEADER),t.write(r.SUBSCRIBE_HEADER[1][a?1:0][0]),R(t,p),d(t,u),null!==f&&f.write();let m=!0;for(const e of l){const o=e.topic,s=e.qos,a=+e.nl,c=+e.rap,u=e.rh;let l;T(t,o),l=r.SUBSCRIBE_OPTIONS_QOS[s],5===i&&(l|=a?r.SUBSCRIBE_OPTIONS_NL:0,l|=c?r.SUBSCRIBE_OPTIONS_RAP:0,l|=u?r.SUBSCRIBE_OPTIONS_RH[u]:0),m=t.write(n.from([l]))}return m}function S(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.granted,u=s.properties;let l=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(l+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;l+=1}let h=null;if(5===i){if(h=U(t,u,o,l),!h)return!1;l+=h.length}return t.write(r.SUBACK_HEADER),R(t,l),d(t,a),null!==h&&h.write(),t.write(n.from(c))}function k(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,u=s.unsubscriptions,l=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<u.length;e+=1){if("string"!=typeof u[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=n.byteLength(u[e])+2}let p=null;if(5===i){if(p=N(t,l),!p)return!1;h+=p.length}t.write(r.UNSUBSCRIBE_HEADER[1][c?1:0][0]),R(t,h),d(t,a),null!==p&&p.write();let f=!0;for(let e=0;e<u.length;e++)f=T(t,u[e]);return f}function E(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.messageId,c=s.dup?r.DUP_MASK:0,u=s.granted,l=s.properties,h=s.cmd,p=0;let f=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===i){if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<u.length;e+=1){if("number"!=typeof u[e])return t.emit("error",new Error("Invalid qos vector")),!1;f+=1}}let m=null;if(5===i){if(m=U(t,l,o,f),!m)return!1;f+=m.length}return t.write(r.ACKS[h][p][c][0]),R(t,f),d(t,a),null!==m&&m.write(),5===i&&t.write(n.from(u)),!0}function A(e,t,n){return t.write(r.EMPTY[e.cmd])}function I(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===i?1:0,l=null;if(5===i){if(l=U(t,c,o,u),!l)return!1;u+=l.length}return t.write(n.from([r.codes.disconnect<<4])),R(t,u),5===i&&t.write(n.from([a])),null!==l&&l.write(),!0}function x(e,t,o){const i=o?o.protocolVersion:4,s=e||{},a=s.reasonCode,c=s.properties;let u=5===i?1:0;5!==i&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const l=U(t,c,o,u);return!!l&&(u+=l.length,t.write(n.from([r.codes.auth<<4])),R(t,u),t.write(n.from([a])),null!==l&&l.write(),!0)}Object.defineProperty(g,"cacheNumbers",{get:()=>d===P,set(e){e?(u&&0!==Object.keys(u).length||(m=!0),d=P):(m=!1,d=j)}});const O={};function R(e,t){if(t>r.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=O[t];return n||(n=p(t),t<16384&&(O[t]=n)),c("writeVarByteInt: writing to stream: %o",n),e.write(n)}function T(e,t){const r=n.byteLength(t);return d(e,r),c("writeString: %s",t),e.write(t,"utf8")}function F(e,t,n){T(e,t),T(e,n)}function P(e,t){return c("writeNumberCached: number: %d",t),c("writeNumberCached: %o",u[t]),e.write(u[t])}function j(e,t){const n=l(t);return c("writeNumberGenerated: %o",n),e.write(n)}function B(e,t){const n=f(t);return c("write4ByteNumber: %o",n),e.write(n)}function M(e,t){"string"==typeof t?T(e,t):t?(d(e,t.length),e.write(t)):d(e,0)}function N(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){D(e,{},0)}};let o=0;function i(t,o){let i=0;switch(r.propertiesTypes[t]){case"byte":if("boolean"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"int8":if("number"!=typeof o||o<0||o>255)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=2;break;case"binary":if(o&&null===o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(o)+2;break;case"int16":if("number"!=typeof o||o<0||o>65535)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3;break;case"int32":if("number"!=typeof o||o<0||o>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=5;break;case"var":if("number"!=typeof o||o<0||o>268435455)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=1+n.byteLength(p(o));break;case"string":if("string"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=3+n.byteLength(o.toString());break;case"pair":if("object"!=typeof o)return e.emit("error",new Error(`Invalid ${t}: ${o}`)),!1;i+=Object.getOwnPropertyNames(o).reduce(((e,t)=>{const r=o[t];return Array.isArray(r)?e+=r.reduce(((e,r)=>e+=3+n.byteLength(t.toString())+2+n.byteLength(r.toString())),0):e+=3+n.byteLength(t.toString())+2+n.byteLength(o[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${o}`)),!1}return i}if(t)for(const e in t){let n=0,r=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(r=i(e,s[t]),!r)return!1;n+=r}else{if(r=i(e,s),!r)return!1;n=r}if(!n)return!1;o+=n}return{length:n.byteLength(p(o))+o,write(){D(e,t,o)}}}function U(e,t,n,r){const o=["reasonString","userProperties"],i=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0;let s=N(e,t);if(i)for(;r+s.length>i;){const n=o.shift();if(!n||!t[n])return!1;delete t[n],s=N(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]])),M(e,o);break;case"int16":e.write(n.from([r.properties[t]])),d(e,o);break;case"int32":e.write(n.from([r.properties[t]])),B(e,o);break;case"var":e.write(n.from([r.properties[t]])),R(e,o);break;case"string":e.write(n.from([r.properties[t]])),T(e,o);break;case"pair":Object.getOwnPropertyNames(o).forEach((i=>{const s=o[i];Array.isArray(s)?s.forEach((o=>{e.write(n.from([r.properties[t]])),F(e,i.toString(),o.toString())})):(e.write(n.from([r.properties[t]])),F(e,i.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${o}`)),!1}}function D(e,t,n){R(e,n);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&null!==t[n]){const r=t[n];if(Array.isArray(r))for(let t=0;t<r.length;t++)L(e,n,r[t]);else L(e,n,r)}}function q(e){return e?e instanceof n?e.length:n.byteLength(e):0}function $(e){return"string"==typeof e||e instanceof n}t.exports=g}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":22,"./numbers":25,buffer:14,debug:15,"process-nextick-args":31}],29:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,c=365.25*s;function u(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*c;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function l(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}function h(e){var t=Math.abs(e);return t>=s?p(e,t,s,"day"):t>=i?p(e,t,i,"hour"):t>=o?p(e,t,o,"minute"):t>=r?p(e,t,r,"second"):e+" ms"}function p(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return u(e);if("number"===n&&isFinite(e))return t.long?h(e):l(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],30:[function(e,t,n){var r=e("wrappy");function o(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}t.exports=r(o),t.exports.strict=r(i),o.proto=o((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return o(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})}))},{wrappy:59}],31:[function(e,t,n){(function(e){(function(){function n(t,n,r,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,n)}));case 3:return e.nextTick((function(){t.call(null,n,r)}));case 4:return e.nextTick((function(){t.call(null,n,r,o)}));default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick((function(){t.apply(null,i)}))}}void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:n}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:32}],32:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}function u(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var l,h=[],p=!1,f=-1;function d(){p&&l&&(p=!1,l.length?h=l.concat(h):f=-1,h.length&&m())}function m(){if(!p){var e=c(d);p=!0;for(var t=h.length;t;){for(l=h,h=[];++f<t;)l&&l[f].run();f=-1,t=h.length}l=null,p=!1,u(e)}}function g(e,t){this.fun=e,this.array=t}function y(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];h.push(new g(e,t)),1!==h.length||p||c(m)},g.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],33:[function(e,t,n){(function(e){(function(){!function(r){var o="object"==typeof n&&n&&!n.nodeType&&n,i="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,c,u=2147483647,l=36,h=1,p=26,f=38,d=700,m=72,g=128,y="-",b=/^xn--/,v=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},C=l-h,S=Math.floor,k=String.fromCharCode;function E(e){throw new RangeError(_[e])}function A(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function I(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+A((e=e.replace(w,".")).split("."),t).join(".")}function x(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function O(e){return A(e,(function(e){var t="";return e>65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=k(e)})).join("")}function R(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:l}function T(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function F(e,t,n){var r=0;for(e=n?S(e/d):e>>1,e+=S(e/t);e>C*p>>1;r+=l)e=S(e/C);return S(r+(C+1)*e/(e+f))}function P(e){var t,n,r,o,i,s,a,c,f,d,b=[],v=e.length,w=0,_=g,C=m;for((n=e.lastIndexOf(y))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&E("not-basic"),b.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<v;){for(i=w,s=1,a=l;o>=v&&E("invalid-input"),((c=R(e.charCodeAt(o++)))>=l||c>S((u-w)/s))&&E("overflow"),w+=c*s,!(c<(f=a<=C?h:a>=C+p?p:a-C));a+=l)s>S(u/(d=l-f))&&E("overflow"),s*=d;C=F(w-i,t=b.length+1,0==i),S(w/t)>u-_&&E("overflow"),_+=S(w/t),w%=t,b.splice(w++,0,_)}return O(b)}function j(e){var t,n,r,o,i,s,a,c,f,d,b,v,w,_,C,A=[];for(v=(e=x(e)).length,t=g,n=0,i=m,s=0;s<v;++s)(b=e[s])<128&&A.push(k(b));for(r=o=A.length,o&&A.push(y);r<v;){for(a=u,s=0;s<v;++s)(b=e[s])>=t&&b<a&&(a=b);for(a-t>S((u-n)/(w=r+1))&&E("overflow"),n+=(a-t)*w,t=a,s=0;s<v;++s)if((b=e[s])<t&&++n>u&&E("overflow"),b==t){for(c=n,f=l;!(c<(d=f<=i?h:f>=i+p?p:f-i));f+=l)C=c-d,_=l-d,A.push(k(T(d+C%_,0))),c=S(C/_);A.push(k(T(c,0))),i=F(n,w,r==o),n=0,++r}++n,++t}return A.join("")}function B(e){return I(e,(function(e){return b.test(e)?P(e.slice(4).toLowerCase()):e}))}function M(e){return I(e,(function(e){return v.test(e)?"xn--"+j(e):e}))}if(a={version:"1.4.1",ucs2:{decode:x,encode:O},decode:P,encode:j,toASCII:M,toUnicode:B},o&&i)if(t.exports==o)i.exports=a;else for(c in a)a.hasOwnProperty(c)&&(o[c]=a[c]);else r.punycode=a}(this)}).call(this)}).call(this,void 0!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],34:[function(e,t,n){function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var u=e.length;c>0&&u>c&&(u=c);for(var l=0;l<u;++l){var h,p,f,d,m=e[l].replace(a,"%20"),g=m.indexOf(n);g>=0?(h=m.substr(0,g),p=m.substr(g+1)):(h=m,p=""),f=decodeURIComponent(h),d=decodeURIComponent(p),r(s,f)?o(s[f])?s[f].push(d):s[f]=[s[f],d]:s[f]=d}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],35:[function(e,t,n){var r=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?i(s(e),(function(s){var a=encodeURIComponent(r(s))+n;return o(e[s])?i(e[s],(function(e){return a+encodeURIComponent(r(e))})).join(t):a+encodeURIComponent(r(e[s]))})).join(t):a?encodeURIComponent(r(a))+n+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function i(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],36:[function(e,t,n){n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":34,"./encode":35}],37:[function(e,t,n){function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var o={};function i(e,t,n){function i(e,n,r){return"string"==typeof t?t:t(e,n,r)}n||(n=Error);var s=function(e){function t(t,n,r){return e.call(this,i(t,n,r))||this}return r(t,e),t}(n);s.prototype.name=n.name,s.prototype.code=e,o[e]=s}function s(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function a(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function c(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function u(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o;if("string"==typeof t&&a(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be",c(e," argument"))o="The ".concat(e," ").concat(r," ").concat(s(t,"type"));else{var i=u(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(i," ").concat(r," ").concat(s(t,"type"))}return o+=". Received type ".concat(typeof n)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=o},{}],38:[function(e,t,n){(function(n){(function(){var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=u;var o=e("./_stream_readable"),i=e("./_stream_writable");e("inherits")(u,o);for(var s=r(i.prototype),a=0;a<s.length;a++){var c=s[a];u.prototype[c]||(u.prototype[c]=i.prototype[c])}function u(e){if(!(this instanceof u))return new u(e);o.call(this,e),i.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":40,"./_stream_writable":42,_process:32,inherits:21}],39:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}e("inherits")(o,r),o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":41,inherits:21}],40:[function(e,t,n){(function(n,r){(function(){var o;t.exports=x,x.ReadableState=I,e("events").EventEmitter;var i=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,c=r.Uint8Array||function(){};function u(e){return a.from(e)}function l(e){return a.isBuffer(e)||e instanceof c}var h,p=e("util");h=p&&p.debuglog?p.debuglog("stream"):function(){};var f,d,m,g=e("./internal/streams/buffer_list"),y=e("./internal/streams/destroy"),b=e("./internal/streams/state").getHighWaterMark,v=e("../errors").codes,w=v.ERR_INVALID_ARG_TYPE,_=v.ERR_STREAM_PUSH_AFTER_EOF,C=v.ERR_METHOD_NOT_IMPLEMENTED,S=v.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(x,s);var k=y.errorOrDestroy,E=["error","close","destroy","pause","resume"];function A(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}function I(t,n,r){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof o),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=b(this,t,"readableHighWaterMark",r),this.buffer=new g,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=e("string_decoder/").StringDecoder),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function x(t){if(o=o||e("./_stream_duplex"),!(this instanceof x))return new x(t);var n=this instanceof o;this._readableState=new I(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function O(e,t,n,r,o){h("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,B(e,s);else if(o||(i=T(s,t)),i)k(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=u(t)),r)s.endEmitted?k(e,new S):R(e,s,t,!0);else if(s.ended)k(e,new _);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?R(e,s,t,!1):U(e,s)):R(e,s,t,!1)}else r||(s.reading=!1,U(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function R(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&&M(e)),U(e,t)}function T(e,t){var n;return l(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new w("chunk",["string","Buffer","Uint8Array"],t)),n}Object.defineProperty(x.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),x.prototype.destroy=y.destroy,x.prototype._undestroy=y.undestroy,x.prototype._destroy=function(e,t){t(e)},x.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=a.from(e,t),t=""),n=!0),O(this,e,t,!1,n)},x.prototype.unshift=function(e){return O(this,e,null,!0,!1)},x.prototype.isPaused=function(){return!1===this._readableState.flowing},x.prototype.setEncoding=function(t){f||(f=e("string_decoder/").StringDecoder);var n=new f(t);this._readableState.decoder=n,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,o="";null!==r;)o+=n.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==o&&this._readableState.buffer.push(o),this._readableState.length=o.length,this};var F=1073741824;function P(e){return e>=F?e=F:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function j(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=P(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function B(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?M(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,N(e)))}}function M(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(N,e))}function N(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,z(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,z(e))}}function q(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function $(e){h("readable nexttick read 0"),e.read(0)}function H(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(W,e,t))}function W(e,t){h("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),z(e),t.flowing&&!t.reading&&e.read(0)}function z(e){var t=e._readableState;for(h("flow",t.flowing);t.flowing&&null!==e.read(););}function V(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function K(e){var t=e._readableState;h("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(J,t,e))}function J(e,t){if(h("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function Q(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}x.prototype.read=function(e){h("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?K(this):M(this),null;if(0===(e=j(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=j(n,t))),null===(r=e>0?V(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&K(this)),null!==r&&this.emit("data",r),r},x.prototype._read=function(e){k(this,new C("_read()"))},x.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?y:c;function a(e,t){h("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,p())}function c(){h("onend"),e.end()}o.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var u=D(r);e.on("drain",u);var l=!1;function p(){h("cleanup"),e.removeListener("close",m),e.removeListener("finish",g),e.removeListener("drain",u),e.removeListener("error",d),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",f),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||u()}function f(t){h("ondata");var n=e.write(t);h("dest.write",n),!1===n&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==Q(o.pipes,e))&&!l&&(h("false write response, pause",o.awaitDrain),o.awaitDrain++),r.pause())}function d(t){h("onerror",t),y(),e.removeListener("error",d),0===i(e,"error")&&k(e,t)}function m(){e.removeListener("finish",g),y()}function g(){h("onfinish"),e.removeListener("close",m),y()}function y(){h("unpipe"),r.unpipe(e)}return r.on("data",f),A(e,"error",d),e.once("close",m),e.once("finish",g),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},x.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<o;i++)r[i].emit("unpipe",this,{hasUnpiped:!1});return this}var s=Q(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},x.prototype.on=function(e,t){var r=s.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,h("on readable",o.length,o.reading),o.length?M(this):o.reading||n.nextTick($,this))),r},x.prototype.addListener=x.prototype.on,x.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(q,this),r},x.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(q,this),t},x.prototype.resume=function(){var e=this._readableState;return e.flowing||(h("resume"),e.flowing=!e.readableListening,H(this,e)),e.paused=!1,this},x.prototype.pause=function(){return h("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(h("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},x.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var o in e.on("end",(function(){if(h("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){h("wrapped data"),n.decoder&&(o=n.decoder.write(o)),n.objectMode&&null==o||(n.objectMode||o&&o.length)&&(t.push(o)||(r=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var i=0;i<E.length;i++)e.on(E[i],this.emit.bind(this,E[i]));return this._read=function(t){h("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(x.prototype[Symbol.asyncIterator]=function(){return void 0===d&&(d=e("./internal/streams/async_iterator")),d(this)}),Object.defineProperty(x.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(x.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(x.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),x._fromList=V,Object.defineProperty(x.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(x.from=function(t,n){return void 0===m&&(m=e("./internal/streams/from")),m(x,t,n)})}).call(this)}).call(this,e("_process"),void 0!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/async_iterator":43,"./internal/streams/buffer_list":44,"./internal/streams/destroy":45,"./internal/streams/from":47,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,events:19,inherits:21,"string_decoder/":55,util:13}],41:[function(e,t,n){t.exports=l;var r=e("../errors").codes,o=r.ERR_METHOD_NOT_IMPLEMENTED,i=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=e("./_stream_duplex");function u(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new i);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);c.call(this,e),this._transformState={afterTransform:u.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(t,n){p(e,t,n)}))}function p(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(l,c),l.prototype.push=function(e,t){return this._transformState.needTransform=!1,c.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,n){n(new o("_transform()"))},l.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},l.prototype._destroy=function(e,t){c.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":37,"./_stream_duplex":38,inherits:21}],42:[function(e,t,n){(function(n,r){(function(){function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){W(t,e)}}var i;t.exports=I,I.WritableState=A;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),c=e("buffer").Buffer,u=r.Uint8Array||function(){};function l(e){return c.from(e)}function h(e){return c.isBuffer(e)||e instanceof u}var p,f=e("./internal/streams/destroy"),d=e("./internal/streams/state").getHighWaterMark,m=e("../errors").codes,g=m.ERR_INVALID_ARG_TYPE,y=m.ERR_METHOD_NOT_IMPLEMENTED,b=m.ERR_MULTIPLE_CALLBACK,v=m.ERR_STREAM_CANNOT_PIPE,w=m.ERR_STREAM_DESTROYED,_=m.ERR_STREAM_NULL_VALUES,C=m.ERR_STREAM_WRITE_AFTER_END,S=m.ERR_UNKNOWN_ENCODING,k=f.errorOrDestroy;function E(){}function A(t,n,r){i=i||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=d(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){B(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function I(t){var n=this instanceof(i=i||e("./_stream_duplex"));if(!n&&!p.call(I,this))return new I(t);this._writableState=new A(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function x(e,t){var r=new C;k(e,r),n.nextTick(t,r)}function O(e,t,r,o){var i;return null===r?i=new _:"string"==typeof r||t.objectMode||(i=new g("chunk",["string","Buffer"],r)),!i||(k(e,i),n.nextTick(o,i),!1)}function R(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=c.from(t,n)),t}function T(e,t,n,r,o,i){if(!n){var s=R(t,r,o);r!==s&&(n=!0,o="buffer",r=s)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else F(e,t,!1,a,r,o,i);return c}function F(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new w("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function P(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick($,e,t),e._writableState.errorEmitted=!0,k(e,o)):(i(o),e._writableState.errorEmitted=!0,k(e,o),$(e,t))}function j(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function B(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new b;if(j(r),t)P(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(M,e,r,s,i):M(e,r,s,i)}}function M(e,t,n,r){n||N(e,t),t.pendingcb--,r(),$(e,t)}function N(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,F(e,t,!0,t.length,i,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var u=n.chunk,l=n.encoding,h=n.callback;if(F(e,t,!1,t.objectMode?1:u.length,u,l,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function L(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function D(e,t){e._final((function(n){t.pendingcb--,n&&k(e,n),t.prefinished=!0,e.emit("prefinish"),$(e,t)}))}function q(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(D,e,t)))}function $(e,t){var n=L(t);if(n&&(q(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function H(e,t,r){t.ending=!0,$(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function W(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}e("inherits")(I,a),A.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(A.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===I&&e&&e._writableState instanceof A}})):p=function(e){return e instanceof this},I.prototype.pipe=function(){k(this,new v)},I.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&h(e);return i&&!c.isBuffer(e)&&(e=l(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=E),r.ending?x(this,n):(i||O(this,r,e,n))&&(r.pendingcb++,o=T(this,r,i,e,t,n)),o},I.prototype.cork=function(){this._writableState.corked++},I.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||U(this,e))},I.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new S(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function(e,t,n){n(new y("_write()"))},I.prototype._writev=null,I.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||H(this,r,n),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),I.prototype.destroy=f.destroy,I.prototype._undestroy=f.undestroy,I.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":37,"./_stream_duplex":38,"./internal/streams/destroy":45,"./internal/streams/state":49,"./internal/streams/stream":50,_process:32,buffer:14,inherits:21,"util-deprecate":58}],43:[function(e,t,n){(function(n){(function(){var r;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),c=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function f(e,t){return{value:e,done:t}}function d(e){var t=e[s];if(null!==t){var n=e[p].read();null!==n&&(e[l]=null,e[s]=null,e[a]=null,t(f(n,!1)))}}function m(e){n.nextTick(d,e)}function g(e,t){return function(n,r){e.then((function(){t[u]?n(f(void 0,!0)):t[h](n,r)}),r)}}var y=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((o(r={get stream(){return this[p]},next:function(){var e=this,t=this[c];if(null!==t)return Promise.reject(t);if(this[u])return Promise.resolve(f(void 0,!0));if(this[p].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[c]?r(e[c]):t(f(void 0,!0))}))}));var r,o=this[l];if(o)r=new Promise(g(o,this));else{var i=this[p].read();if(null!==i)return Promise.resolve(f(i,!1));r=new Promise(this[h])}return this[l]=r,r}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var e=this;return new Promise((function(t,n){e[p].destroy(null,(function(e){e?n(e):t(f(void 0,!0))}))}))})),r),y),v=function(e){var t,n=Object.create(b,(o(t={},p,{value:e,writable:!0}),o(t,s,{value:null,writable:!0}),o(t,a,{value:null,writable:!0}),o(t,c,{value:null,writable:!0}),o(t,u,{value:e._readableState.endEmitted,writable:!0}),o(t,h,{value:function(e,t){var r=n[p].read();r?(n[l]=null,n[s]=null,n[a]=null,e(f(r,!1))):(n[s]=e,n[a]=t)},writable:!0}),t));return n[l]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[a];return null!==t&&(n[l]=null,n[s]=null,n[a]=null,t(e)),void(n[c]=e)}var r=n[s];null!==r&&(n[l]=null,n[s]=null,n[a]=null,r(f(void 0,!0))),n[u]=!0})),e.on("readable",m.bind(null,n)),n};t.exports=v}).call(this)}).call(this,e("_process"))},{"./end-of-stream":46,_process:32}],44:[function(e,t,n){function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}var u=e("buffer").Buffer,l=e("util").inspect,h=l&&l.custom||"inspect";function p(e,t,n){u.prototype.copy.call(e,t,n)}t.exports=function(){function e(){s(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return u.alloc(0);for(var t=u.allocUnsafe(e>>>0),n=this.head,r=0;n;)p(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var o=t.data,i=e>o.length?o.length:e;if(i===o.length?r+=o:r+=o.slice(0,e),0==(e-=i)){i===o.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=o.slice(i));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,i=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,i),0==(e-=i)){i===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(i));break}++r}return this.length-=r,t}},{key:h,value:function(e,t){return l(this,o({},t,{depth:0,customInspect:!1}))}}]),e}()},{buffer:14,util:13}],45:[function(e,t,n){(function(e){(function(){function n(t,n){var i=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(n?n(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(s,this,t)):e.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!n&&t?i._writableState?i._writableState.errorEmitted?e.nextTick(o,i):(i._writableState.errorEmitted=!0,e.nextTick(r,i,t)):e.nextTick(r,i,t):n?(e.nextTick(o,i),n(t)):e.nextTick(o,i)})),this)}function r(e,t){s(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function i(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function s(e,t){e.emit("error",t)}function a(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}t.exports={destroy:n,undestroy:i,errorOrDestroy:a}}).call(this)}).call(this,e("_process"))},{_process:32}],46:[function(e,t,n){var r=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function o(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];e.apply(this,r)}}}function i(){}function s(e){return e.setHeader&&"function"==typeof e.abort}function a(e,t,n){if("function"==typeof t)return a(e,null,t);t||(t={}),n=o(n||i);var c=t.readable||!1!==t.readable&&e.readable,u=t.writable||!1!==t.writable&&e.writable,l=function(){e.writable||p()},h=e._writableState&&e._writableState.finished,p=function(){u=!1,h=!0,c||n.call(e)},f=e._readableState&&e._readableState.endEmitted,d=function(){c=!1,f=!0,u||n.call(e)},m=function(t){n.call(e,t)},g=function(){var t;return c&&!f?(e._readableState&&e._readableState.ended||(t=new r),n.call(e,t)):u&&!h?(e._writableState&&e._writableState.ended||(t=new r),n.call(e,t)):void 0},y=function(){e.req.on("finish",p)};return s(e)?(e.on("complete",p),e.on("abort",g),e.req?y():e.on("request",y)):u&&!e._writableState&&(e.on("end",l),e.on("close",l)),e.on("end",d),e.on("finish",p),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",p),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",p),e.removeListener("end",l),e.removeListener("close",l),e.removeListener("finish",p),e.removeListener("end",d),e.removeListener("error",m),e.removeListener("close",g)}}t.exports=a},{"../../../errors":37}],47:[function(e,t,n){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],48:[function(e,t,n){var r;function o(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=e("../../../errors").codes,s=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function c(e){if(e)throw e}function u(e){return e.setHeader&&"function"==typeof e.abort}function l(t,n,i,s){s=o(s);var c=!1;t.on("close",(function(){c=!0})),void 0===r&&(r=e("./end-of-stream")),r(t,{readable:n,writable:i},(function(e){if(e)return s(e);c=!0,s()}));var l=!1;return function(e){if(!c&&!l)return l=!0,u(t)?t.abort():"function"==typeof t.destroy?t.destroy():void s(e||new a("pipe"))}}function h(e){e()}function p(e,t){return e.pipe(t)}function f(e){return e.length?"function"!=typeof e[e.length-1]?c:e.pop():c}function d(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=f(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new s("streams");var i=t.map((function(e,n){var s=n<t.length-1;return l(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(h),s||(i.forEach(h),o(r))}))}));return t.reduce(p)}t.exports=d},{"../../../errors":37,"./end-of-stream":46}],49:[function(e,t,n){var r=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;function o(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}function i(e,t,n,i){var s=o(t,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}},{"../../../errors":37}],50:[function(e,t,n){t.exports=e("events").EventEmitter},{events:19}],51:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":38,"./lib/_stream_passthrough.js":39,"./lib/_stream_readable.js":40,"./lib/_stream_transform.js":41,"./lib/_stream_writable.js":42,"./lib/internal/streams/end-of-stream.js":46,"./lib/internal/streams/pipeline.js":48}],52:[function(e,t,n){function r(e,t,n){var r=this;this._callback=e,this._args=n,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=r._interval),r._interval&&clearInterval(r._interval),r._interval=setInterval(r._callback,e,r._args)},this.clear=function(){r._interval&&(clearInterval(r._interval),r._interval=void 0)},this.destroy=function(){r._interval&&clearInterval(r._interval),r._callback=void 0,r._interval=void 0,r._args=void 0}}function o(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new r(arguments[0],arguments[1],e)}t.exports=o},{}],53:[function(e,t,n){
3
5
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
4
- !function(e,t){var n=a.default,r=n.Buffer;function o(e,t){for(var n in e)t[n]=e[n]}function i(e,t,n){return r(e,t,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=i),i.prototype=Object.create(r.prototype),o(r,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return r(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=r(e);return void 0!==t?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}}(la,la.exports);var ua=la.exports.Buffer,pa=ua.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 da(e){var t;switch(this.encoding=function(e){var t=function(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}}(e);if("string"!=typeof t&&(ua.isEncoding===pa||!pa(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=ma,this.end=ga,t=4;break;case"utf8":this.fillLast=ha,t=4;break;case"base64":this.text=ya,this.end=ba,t=3;break;default:return this.write=va,void(this.end=wa)}this.lastNeed=0,this.lastTotal=0,this.lastChar=ua.allocUnsafe(t)}function fa(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function ha(e){var t=this.lastTotal-this.lastNeed,n=function(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,"�"}}(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 ma(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 ga(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 ya(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 ba(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function va(e){return e.toString(this.encoding)}function wa(e){return e&&e.length?this.write(e):""}ca.StringDecoder=da,da.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||""},da.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},da.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var o=fa(t[r]);if(o>=0)return o>0&&(e.lastNeed=o-1),o;if(--r<n||-2===o)return 0;if((o=fa(t[r]))>=0)return o>0&&(e.lastNeed=o-2),o;if(--r<n||-2===o)return 0;if((o=fa(t[r]))>=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(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)},da.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};var _a=hs.codes.ERR_STREAM_PREMATURE_CLOSE;function Ca(){}var Sa,ka=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(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)}}}(r||Ca);var o=n.readable||!1!==n.readable&&t.readable,i=n.writable||!1!==n.writable&&t.writable,s=function(){t.writable||c()},a=t._writableState&&t._writableState.finished,c=function(){i=!1,a=!0,o||r.call(t)},l=t._readableState&&t._readableState.endEmitted,u=function(){o=!1,l=!0,i||r.call(t)},p=function(e){r.call(t,e)},d=function(){var e;return o&&!l?(t._readableState&&t._readableState.ended||(e=new _a),r.call(t,e)):i&&!a?(t._writableState&&t._writableState.ended||(e=new _a),r.call(t,e)):void 0},f=function(){t.req.on("finish",c)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?i&&!t._writableState&&(t.on("end",s),t.on("close",s)):(t.on("complete",c),t.on("abort",d),t.req?f():t.on("request",f)),t.on("end",u),t.on("finish",c),!1!==n.error&&t.on("error",p),t.on("close",d),function(){t.removeListener("complete",c),t.removeListener("abort",d),t.removeListener("request",f),t.req&&t.req.removeListener("finish",c),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",c),t.removeListener("end",u),t.removeListener("error",p),t.removeListener("close",d)}};function Ea(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ra=ka,Ia=Symbol("lastResolve"),Aa=Symbol("lastReject"),Oa=Symbol("error"),xa=Symbol("ended"),Ta=Symbol("lastPromise"),Pa=Symbol("handlePromise"),Ba=Symbol("stream");function Ma(e,t){return{value:e,done:t}}function Fa(e){var t=e[Ia];if(null!==t){var n=e[Ba].read();null!==n&&(e[Ta]=null,e[Ia]=null,e[Aa]=null,t(Ma(n,!1)))}}function Na(e){process.nextTick(Fa,e)}var ja,Ua=Object.getPrototypeOf((function(){})),La=Object.setPrototypeOf((Ea(Sa={get stream(){return this[Ba]},next:function(){var e=this,t=this[Oa];if(null!==t)return Promise.reject(t);if(this[xa])return Promise.resolve(Ma(void 0,!0));if(this[Ba].destroyed)return new Promise((function(t,n){process.nextTick((function(){e[Oa]?n(e[Oa]):t(Ma(void 0,!0))}))}));var n,r=this[Ta];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[xa]?n(Ma(void 0,!0)):t[Pa](n,r)}),r)}}(r,this));else{var o=this[Ba].read();if(null!==o)return Promise.resolve(Ma(o,!1));n=new Promise(this[Pa])}return this[Ta]=n,n}},Symbol.asyncIterator,(function(){return this})),Ea(Sa,"return",(function(){var e=this;return new Promise((function(t,n){e[Ba].destroy(null,(function(e){e?n(e):t(Ma(void 0,!0))}))}))})),Sa),Ua),Da=function(e){var t,n=Object.create(La,(Ea(t={},Ba,{value:e,writable:!0}),Ea(t,Ia,{value:null,writable:!0}),Ea(t,Aa,{value:null,writable:!0}),Ea(t,Oa,{value:null,writable:!0}),Ea(t,xa,{value:e._readableState.endEmitted,writable:!0}),Ea(t,Pa,{value:function(e,t){var r=n[Ba].read();r?(n[Ta]=null,n[Ia]=null,n[Aa]=null,e(Ma(r,!1))):(n[Ia]=e,n[Aa]=t)},writable:!0}),t));return n[Ta]=null,Ra(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[Aa];return null!==t&&(n[Ta]=null,n[Ia]=null,n[Aa]=null,t(e)),void(n[Oa]=e)}var r=n[Ia];null!==r&&(n[Ta]=null,n[Ia]=null,n[Aa]=null,r(Ma(void 0,!0))),n[xa]=!0})),e.on("readable",Na.bind(null,n)),n},qa=function(){throw new Error("Readable.from is not available in the browser")},$a=lc;lc.ReadableState=cc,s.default.EventEmitter;var Ha=function(e,t){return e.listeners(t).length},Wa=ns,Va=a.default.Buffer,Ka=ge.Uint8Array||function(){};var za,Ja=si;za=Ja&&Ja.debuglog?Ja.debuglog("stream"):function(){};var Qa,Xa,Ya,Ga=ls,Za=fs,ec=vs.getHighWaterMark,tc=hs.codes,nc=tc.ERR_INVALID_ARG_TYPE,rc=tc.ERR_STREAM_PUSH_AFTER_EOF,oc=tc.ERR_METHOD_NOT_IMPLEMENTED,ic=tc.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;ws.exports(lc,Wa);var sc=Za.errorOrDestroy,ac=["error","close","destroy","pause","resume"];function cc(e,t,n){ja=ja||Zs,e=e||{},"boolean"!=typeof n&&(n=t instanceof ja),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=ec(this,e,"readableHighWaterMark",n),this.buffer=new Ga,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Qa||(Qa=ca.StringDecoder),this.decoder=new Qa(e.encoding),this.encoding=e.encoding)}function lc(e){if(ja=ja||Zs,!(this instanceof lc))return new lc(e);var t=this instanceof ja;this._readableState=new cc(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),Wa.call(this)}function uc(e,t,n,r,o){za("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(za("onEofChunk"),t.ended)return;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?hc(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,mc(e)))}(e,s);else if(o||(i=function(e,t){var n;r=t,Va.isBuffer(r)||r instanceof Ka||"string"==typeof t||void 0===t||e.objectMode||(n=new nc("chunk",["string","Buffer","Uint8Array"],t));var r;return n}(s,t)),i)sc(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===Va.prototype||(t=function(e){return Va.from(e)}(t)),r)s.endEmitted?sc(e,new ic):pc(e,s,t,!0);else if(s.ended)sc(e,new rc);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?pc(e,s,t,!1):gc(e,s)):pc(e,s,t,!1)}else r||(s.reading=!1,gc(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function pc(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&&hc(e)),gc(e,t)}Object.defineProperty(lc.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),lc.prototype.destroy=Za.destroy,lc.prototype._undestroy=Za.undestroy,lc.prototype._destroy=function(e,t){t(e)},lc.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=Va.from(e,t),t=""),n=!0),uc(this,e,t,!1,n)},lc.prototype.unshift=function(e){return uc(this,e,null,!0,!1)},lc.prototype.isPaused=function(){return!1===this._readableState.flowing},lc.prototype.setEncoding=function(e){Qa||(Qa=ca.StringDecoder);var t=new Qa(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var dc=1073741824;function fc(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=function(e){return e>=dc?e=dc:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function hc(e){var t=e._readableState;za("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(za("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(mc,e))}function mc(e){var t=e._readableState;za("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,_c(e)}function gc(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(yc,e,t))}function yc(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(za("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function bc(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 vc(e){za("readable nexttick read 0"),e.read(0)}function wc(e,t){za("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),_c(e),t.flowing&&!t.reading&&e.read(0)}function _c(e){var t=e._readableState;for(za("flow",t.flowing);t.flowing&&null!==e.read(););}function Cc(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 Sc(e){var t=e._readableState;za("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(kc,t,e))}function kc(e,t){if(za("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 Ec(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}lc.prototype.read=function(e){za("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 za("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Sc(this):hc(this),null;if(0===(e=fc(e,t))&&t.ended)return 0===t.length&&Sc(this),null;var r,o=t.needReadable;return za("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&za("length less than watermark",o=!0),t.ended||t.reading?za("reading or ended",o=!1):o&&(za("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=fc(n,t))),null===(r=e>0?Cc(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&&Sc(this)),null!==r&&this.emit("data",r),r},lc.prototype._read=function(e){sc(this,new oc("_read()"))},lc.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,za("pipe count=%d opts=%j",r.pipesCount,t);var o=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?s:f;function i(t,o){za("onunpipe"),t===n&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,za("cleanup"),e.removeListener("close",p),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",u),e.removeListener("unpipe",i),n.removeListener("end",s),n.removeListener("end",f),n.removeListener("data",l),c=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){za("onend"),e.end()}r.endEmitted?process.nextTick(o):n.once("end",o),e.on("unpipe",i);var a=function(e){return function(){var t=e._readableState;za("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&Ha(e,"data")&&(t.flowing=!0,_c(e))}}(n);e.on("drain",a);var c=!1;function l(t){za("ondata");var o=e.write(t);za("dest.write",o),!1===o&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==Ec(r.pipes,e))&&!c&&(za("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function u(t){za("onerror",t),f(),e.removeListener("error",u),0===Ha(e,"error")&&sc(e,t)}function p(){e.removeListener("finish",d),f()}function d(){za("onfinish"),e.removeListener("close",p),f()}function f(){za("unpipe"),n.unpipe(e)}return n.on("data",l),function(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)}(e,"error",u),e.once("close",p),e.once("finish",d),e.emit("pipe",n),r.flowing||(za("pipe resume"),n.resume()),e},lc.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=Ec(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},lc.prototype.on=function(e,t){var n=Wa.prototype.on.call(this,e,t),r=this._readableState;return"data"===e?(r.readableListening=this.listenerCount("readable")>0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,za("on readable",r.length,r.reading),r.length?hc(this):r.reading||process.nextTick(vc,this))),n},lc.prototype.addListener=lc.prototype.on,lc.prototype.removeListener=function(e,t){var n=Wa.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(bc,this),n},lc.prototype.removeAllListeners=function(e){var t=Wa.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||process.nextTick(bc,this),t},lc.prototype.resume=function(){var e=this._readableState;return e.flowing||(za("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(wc,e,t))}(this,e)),e.paused=!1,this},lc.prototype.pause=function(){return za("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(za("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},lc.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var o in e.on("end",(function(){if(za("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){(za("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<ac.length;i++)e.on(ac[i],this.emit.bind(this,ac[i]));return this._read=function(t){za("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(lc.prototype[Symbol.asyncIterator]=function(){return void 0===Xa&&(Xa=Da),Xa(this)}),Object.defineProperty(lc.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(lc.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(lc.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),lc._fromList=Cc,Object.defineProperty(lc.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(lc.from=function(e,t){return void 0===Ya&&(Ya=qa),Ya(lc,e,t)});var Rc=Mc,Ic=hs.codes,Ac=Ic.ERR_METHOD_NOT_IMPLEMENTED,Oc=Ic.ERR_MULTIPLE_CALLBACK,xc=Ic.ERR_TRANSFORM_ALREADY_TRANSFORMING,Tc=Ic.ERR_TRANSFORM_WITH_LENGTH_0,Pc=Zs;function Bc(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new Oc);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 Mc(e){if(!(this instanceof Mc))return new Mc(e);Pc.call(this,e),this._transformState={afterTransform:Bc.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",Fc)}function Fc(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?Nc(this,null,null):this._flush((function(t,n){Nc(e,t,n)}))}function Nc(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Tc;if(e._transformState.transforming)throw new xc;return e.push(null)}ws.exports(Mc,Pc),Mc.prototype.push=function(e,t){return this._transformState.needTransform=!1,Pc.prototype.push.call(this,e,t)},Mc.prototype._transform=function(e,t,n){n(new Ac("_transform()"))},Mc.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)}},Mc.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))},Mc.prototype._destroy=function(e,t){Pc.prototype._destroy.call(this,e,(function(e){t(e)}))};var jc,Uc=Dc,Lc=Rc;function Dc(e){if(!(this instanceof Dc))return new Dc(e);Lc.call(this,e)}ws.exports(Dc,Lc),Dc.prototype._transform=function(e,t,n){n(null,e)};var qc=hs.codes,$c=qc.ERR_MISSING_ARGS,Hc=qc.ERR_STREAM_DESTROYED;function Wc(e){if(e)throw e}function Vc(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var o=!1;e.on("close",(function(){o=!0})),void 0===jc&&(jc=ka),jc(e,{readable:t,writable:n},(function(e){if(e)return r(e);o=!0,r()}));var i=!1;return function(t){if(!o&&!i)return i=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new Hc("pipe"))}}function Kc(e){e()}function zc(e,t){return e.pipe(t)}function Jc(e){return e.length?"function"!=typeof e[e.length-1]?Wc:e.pop():Wc}var Qc=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=Jc(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new $c("streams");var i=t.map((function(e,n){var s=n<t.length-1;return Vc(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(Kc),s||(i.forEach(Kc),o(r))}))}));return t.reduce(zc)};!function(e,t){(t=e.exports=$a).Stream=t,t.Readable=t,t.Writable=ks,t.Duplex=Zs,t.Transform=Rc,t.PassThrough=Uc,t.finished=ka,t.pipeline=Qc}(ts,ts.exports);var Xc=Zi,Yc=ts.exports.Readable,Gc={objectMode:!0},Zc={clean:!0};function el(e){if(!(this instanceof el))return new el(e);this.options=e||{},this.options=Xc(Zc,e),this._inflights=new Map}el.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},el.prototype.createStream=function(){var e=new Yc(Gc),t=!1,n=[],r=0;return this._inflights.forEach((function(e,t){n.push(e)})),e._read=function(){!t&&r<n.length?this.push(n[r++]):this.push(null)},e.destroy=function(){if(!t){var e=this;t=!0,setTimeout((function(){e.emit("close")}),0)}},e},el.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},el.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},el.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()};var tl=el,nl={},rl={exports:{}},ol={exports:{}},il=s.default.EventEmitter;function sl(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 al(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cl(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)}}var ll=a.default.Buffer,ul=si.inspect,pl=ul&&ul.custom||"inspect";var dl=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,n,r;return t=e,n=[{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 ll.alloc(0);for(var t,n,r,o=ll.allocUnsafe(e>>>0),i=this.head,s=0;i;)t=i.data,n=o,r=s,ll.prototype.copy.call(t,n,r),s+=i.data.length,i=i.next;return o}},{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=ll.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:pl,value:function(e,t){return ul(this,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sl(Object(n),!0).forEach((function(t){al(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sl(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}],n&&cl(t.prototype,n),r&&cl(t,r),e}();function fl(e,t){ml(e,t),hl(e)}function hl(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function ml(e,t){e.emit("error",t)}var gl={destroy:function(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return r||o?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(ml,this,e)):process.nextTick(ml,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?n._writableState?n._writableState.errorEmitted?process.nextTick(hl,n):(n._writableState.errorEmitted=!0,process.nextTick(fl,n,e)):process.nextTick(fl,n,e):t?(process.nextTick(hl,n),t(e)):process.nextTick(hl,n)})),this)},undestroy:function(){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)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},yl={};var bl={};function vl(e,t,n){n||(n=Error);var r=function(e){var n,r;function o(n,r,o){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,o))||this}return r=e,(n=o).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,o}(n);r.prototype.name=n.name,r.prototype.code=e,bl[e]=r}function wl(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))}vl("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),vl("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o,i,s;if("string"==typeof t&&(o="not ",t.substr(!i||i<0?0:+i,o.length)===o)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))s="The ".concat(e," ").concat(r," ").concat(wl(t,"type"));else{var a=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(a," ").concat(r," ").concat(wl(t,"type"))}return s+=". Received type ".concat(typeof n)}),TypeError),vl("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),vl("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),vl("ERR_STREAM_PREMATURE_CLOSE","Premature close"),vl("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),vl("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),vl("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),vl("ERR_STREAM_WRITE_AFTER_END","write after end"),vl("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),vl("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),vl("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),yl.codes=bl;var _l=yl.codes.ERR_INVALID_OPT_VALUE;var Cl,Sl={getHighWaterMark:function(e,t,n,r){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new _l(r?n:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}},kl=Vl;function El(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;e.entry=null;for(;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}Vl.WritableState=Wl;var Rl={deprecate:_s},Il=il,Al=a.default.Buffer,Ol=ge.Uint8Array||function(){};var xl,Tl=gl,Pl=Sl.getHighWaterMark,Bl=yl.codes,Ml=Bl.ERR_INVALID_ARG_TYPE,Fl=Bl.ERR_METHOD_NOT_IMPLEMENTED,Nl=Bl.ERR_MULTIPLE_CALLBACK,jl=Bl.ERR_STREAM_CANNOT_PIPE,Ul=Bl.ERR_STREAM_DESTROYED,Ll=Bl.ERR_STREAM_NULL_VALUES,Dl=Bl.ERR_STREAM_WRITE_AFTER_END,ql=Bl.ERR_UNKNOWN_ENCODING,$l=Tl.errorOrDestroy;function Hl(){}function Wl(e,t,n){Cl=Cl||Zl,e=e||{},"boolean"!=typeof n&&(n=t instanceof Cl),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=Pl(this,e,"writableHighWaterMark",n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var r=!1===e.decodeStrings;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,o=n.writecb;if("function"!=typeof o)throw new Nl;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,o){--t.pendingcb,n?(process.nextTick(o,r),process.nextTick(Yl,e,t),e._writableState.errorEmitted=!0,$l(e,r)):(o(r),e._writableState.errorEmitted=!0,$l(e,r),Yl(e,t))}(e,n,r,t,o);else{var i=Ql(n)||e.destroyed;i||n.corked||n.bufferProcessing||!n.bufferedRequest||Jl(e,n),r?process.nextTick(zl,e,n,i,o):zl(e,n,i,o)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new El(this)}function Vl(e){var t=this instanceof(Cl=Cl||Zl);if(!t&&!xl.call(Vl,this))return new Vl(e);this._writableState=new Wl(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),Il.call(this)}function Kl(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new Ul("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function zl(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),Yl(e,t)}function Jl(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,o=new Array(r),i=t.corkedRequestsFree;i.entry=n;for(var s=0,a=!0;n;)o[s]=n,n.isBuf||(a=!1),n=n.next,s+=1;o.allBuffers=a,Kl(e,t,!0,t.length,o,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new El(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,u=n.callback;if(Kl(e,t,!1,t.objectMode?1:c.length,c,l,u),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function Ql(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function Xl(e,t){e._final((function(n){t.pendingcb--,n&&$l(e,n),t.prefinished=!0,e.emit("prefinish"),Yl(e,t)}))}function Yl(e,t){var n=Ql(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,process.nextTick(Xl,e,t)))}(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}ws.exports(Vl,Il),Wl.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(Wl.prototype,"buffer",{get:Rl.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]?(xl=Function.prototype[Symbol.hasInstance],Object.defineProperty(Vl,Symbol.hasInstance,{value:function(e){return!!xl.call(this,e)||this===Vl&&(e&&e._writableState instanceof Wl)}})):xl=function(e){return e instanceof this},Vl.prototype.pipe=function(){$l(this,new jl)},Vl.prototype.write=function(e,t,n){var r,o=this._writableState,i=!1,s=!o.objectMode&&(r=e,Al.isBuffer(r)||r instanceof Ol);return s&&!Al.isBuffer(e)&&(e=function(e){return Al.from(e)}(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof n&&(n=Hl),o.ending?function(e,t){var n=new Dl;$l(e,n),process.nextTick(t,n)}(this,n):(s||function(e,t,n,r){var o;return null===n?o=new Ll:"string"==typeof n||t.objectMode||(o=new Ml("chunk",["string","Buffer"],n)),!o||($l(e,o),process.nextTick(r,o),!1)}(this,o,e,n))&&(o.pendingcb++,i=function(e,t,n,r,o,i){if(!n){var s=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Al.from(t,n));return t}(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;c||(t.needDrain=!0);if(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 Kl(e,t,!1,a,r,o,i);return c}(this,o,s,e,t,n)),i},Vl.prototype.cork=function(){this._writableState.corked++},Vl.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||Jl(this,e))},Vl.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 ql(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(Vl.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(Vl.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Vl.prototype._write=function(e,t,n){n(new Fl("_write()"))},Vl.prototype._writev=null,Vl.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||function(e,t,n){t.ending=!0,Yl(e,t),n&&(t.finished?process.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(Vl.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(Vl.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),Vl.prototype.destroy=Tl.destroy,Vl.prototype._undestroy=Tl.undestroy,Vl.prototype._destroy=function(e,t){t(e)};var Gl=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},Zl=iu,eu=Ou,tu=kl;ws.exports(iu,eu);for(var nu=Gl(tu.prototype),ru=0;ru<nu.length;ru++){var ou=nu[ru];iu.prototype[ou]||(iu.prototype[ou]=tu.prototype[ou])}function iu(e){if(!(this instanceof iu))return new iu(e);eu.call(this,e),tu.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",su)))}function su(){this._writableState.ended||process.nextTick(au,this)}function au(e){e.end()}Object.defineProperty(iu.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(iu.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(iu.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(iu.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)}});var cu=yl.codes.ERR_STREAM_PREMATURE_CLOSE;function lu(){}var uu,pu=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(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)}}}(r||lu);var o=n.readable||!1!==n.readable&&t.readable,i=n.writable||!1!==n.writable&&t.writable,s=function(){t.writable||c()},a=t._writableState&&t._writableState.finished,c=function(){i=!1,a=!0,o||r.call(t)},l=t._readableState&&t._readableState.endEmitted,u=function(){o=!1,l=!0,i||r.call(t)},p=function(e){r.call(t,e)},d=function(){var e;return o&&!l?(t._readableState&&t._readableState.ended||(e=new cu),r.call(t,e)):i&&!a?(t._writableState&&t._writableState.ended||(e=new cu),r.call(t,e)):void 0},f=function(){t.req.on("finish",c)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?i&&!t._writableState&&(t.on("end",s),t.on("close",s)):(t.on("complete",c),t.on("abort",d),t.req?f():t.on("request",f)),t.on("end",u),t.on("finish",c),!1!==n.error&&t.on("error",p),t.on("close",d),function(){t.removeListener("complete",c),t.removeListener("abort",d),t.removeListener("request",f),t.req&&t.req.removeListener("finish",c),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",c),t.removeListener("end",u),t.removeListener("error",p),t.removeListener("close",d)}};function du(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var fu=pu,hu=Symbol("lastResolve"),mu=Symbol("lastReject"),gu=Symbol("error"),yu=Symbol("ended"),bu=Symbol("lastPromise"),vu=Symbol("handlePromise"),wu=Symbol("stream");function _u(e,t){return{value:e,done:t}}function Cu(e){var t=e[hu];if(null!==t){var n=e[wu].read();null!==n&&(e[bu]=null,e[hu]=null,e[mu]=null,t(_u(n,!1)))}}function Su(e){process.nextTick(Cu,e)}var ku,Eu=Object.getPrototypeOf((function(){})),Ru=Object.setPrototypeOf((du(uu={get stream(){return this[wu]},next:function(){var e=this,t=this[gu];if(null!==t)return Promise.reject(t);if(this[yu])return Promise.resolve(_u(void 0,!0));if(this[wu].destroyed)return new Promise((function(t,n){process.nextTick((function(){e[gu]?n(e[gu]):t(_u(void 0,!0))}))}));var n,r=this[bu];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[yu]?n(_u(void 0,!0)):t[vu](n,r)}),r)}}(r,this));else{var o=this[wu].read();if(null!==o)return Promise.resolve(_u(o,!1));n=new Promise(this[vu])}return this[bu]=n,n}},Symbol.asyncIterator,(function(){return this})),du(uu,"return",(function(){var e=this;return new Promise((function(t,n){e[wu].destroy(null,(function(e){e?n(e):t(_u(void 0,!0))}))}))})),uu),Eu),Iu=function(e){var t,n=Object.create(Ru,(du(t={},wu,{value:e,writable:!0}),du(t,hu,{value:null,writable:!0}),du(t,mu,{value:null,writable:!0}),du(t,gu,{value:null,writable:!0}),du(t,yu,{value:e._readableState.endEmitted,writable:!0}),du(t,vu,{value:function(e,t){var r=n[wu].read();r?(n[bu]=null,n[hu]=null,n[mu]=null,e(_u(r,!1))):(n[hu]=e,n[mu]=t)},writable:!0}),t));return n[bu]=null,fu(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[mu];return null!==t&&(n[bu]=null,n[hu]=null,n[mu]=null,t(e)),void(n[gu]=e)}var r=n[hu];null!==r&&(n[bu]=null,n[hu]=null,n[mu]=null,r(_u(void 0,!0))),n[yu]=!0})),e.on("readable",Su.bind(null,n)),n},Au=function(){throw new Error("Readable.from is not available in the browser")},Ou=Xu;Xu.ReadableState=Qu,s.default.EventEmitter;var xu=function(e,t){return e.listeners(t).length},Tu=il,Pu=a.default.Buffer,Bu=ge.Uint8Array||function(){};var Mu,Fu=si;Mu=Fu&&Fu.debuglog?Fu.debuglog("stream"):function(){};var Nu,ju,Uu,Lu=dl,Du=gl,qu=Sl.getHighWaterMark,$u=yl.codes,Hu=$u.ERR_INVALID_ARG_TYPE,Wu=$u.ERR_STREAM_PUSH_AFTER_EOF,Vu=$u.ERR_METHOD_NOT_IMPLEMENTED,Ku=$u.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;ws.exports(Xu,Tu);var zu=Du.errorOrDestroy,Ju=["error","close","destroy","pause","resume"];function Qu(e,t,n){ku=ku||Zl,e=e||{},"boolean"!=typeof n&&(n=t instanceof ku),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=qu(this,e,"readableHighWaterMark",n),this.buffer=new Lu,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(Nu||(Nu=ca.StringDecoder),this.decoder=new Nu(e.encoding),this.encoding=e.encoding)}function Xu(e){if(ku=ku||Zl,!(this instanceof Xu))return new Xu(e);var t=this instanceof ku;this._readableState=new Qu(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),Tu.call(this)}function Yu(e,t,n,r,o){Mu("readableAddChunk",t);var i,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(Mu("onEofChunk"),t.ended)return;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?tp(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,np(e)))}(e,s);else if(o||(i=function(e,t){var n;r=t,Pu.isBuffer(r)||r instanceof Bu||"string"==typeof t||void 0===t||e.objectMode||(n=new Hu("chunk",["string","Buffer","Uint8Array"],t));var r;return n}(s,t)),i)zu(e,i);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===Pu.prototype||(t=function(e){return Pu.from(e)}(t)),r)s.endEmitted?zu(e,new Ku):Gu(e,s,t,!0);else if(s.ended)zu(e,new Wu);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!n?(t=s.decoder.write(t),s.objectMode||0!==t.length?Gu(e,s,t,!1):rp(e,s)):Gu(e,s,t,!1)}else r||(s.reading=!1,rp(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function Gu(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&&tp(e)),rp(e,t)}Object.defineProperty(Xu.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),Xu.prototype.destroy=Du.destroy,Xu.prototype._undestroy=Du.undestroy,Xu.prototype._destroy=function(e,t){t(e)},Xu.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=Pu.from(e,t),t=""),n=!0),Yu(this,e,t,!1,n)},Xu.prototype.unshift=function(e){return Yu(this,e,null,!0,!1)},Xu.prototype.isPaused=function(){return!1===this._readableState.flowing},Xu.prototype.setEncoding=function(e){Nu||(Nu=ca.StringDecoder);var t=new Nu(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var Zu=1073741824;function ep(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=function(e){return e>=Zu?e=Zu:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function tp(e){var t=e._readableState;Mu("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(Mu("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(np,e))}function np(e){var t=e._readableState;Mu("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,cp(e)}function rp(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(op,e,t))}function op(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(Mu("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function ip(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 sp(e){Mu("readable nexttick read 0"),e.read(0)}function ap(e,t){Mu("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),cp(e),t.flowing&&!t.reading&&e.read(0)}function cp(e){var t=e._readableState;for(Mu("flow",t.flowing);t.flowing&&null!==e.read(););}function lp(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 up(e){var t=e._readableState;Mu("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(pp,t,e))}function pp(e,t){if(Mu("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 dp(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}Xu.prototype.read=function(e){Mu("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 Mu("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?up(this):tp(this),null;if(0===(e=ep(e,t))&&t.ended)return 0===t.length&&up(this),null;var r,o=t.needReadable;return Mu("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&Mu("length less than watermark",o=!0),t.ended||t.reading?Mu("reading or ended",o=!1):o&&(Mu("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=ep(n,t))),null===(r=e>0?lp(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&&up(this)),null!==r&&this.emit("data",r),r},Xu.prototype._read=function(e){zu(this,new Vu("_read()"))},Xu.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,Mu("pipe count=%d opts=%j",r.pipesCount,t);var o=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?s:f;function i(t,o){Mu("onunpipe"),t===n&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,Mu("cleanup"),e.removeListener("close",p),e.removeListener("finish",d),e.removeListener("drain",a),e.removeListener("error",u),e.removeListener("unpipe",i),n.removeListener("end",s),n.removeListener("end",f),n.removeListener("data",l),c=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}function s(){Mu("onend"),e.end()}r.endEmitted?process.nextTick(o):n.once("end",o),e.on("unpipe",i);var a=function(e){return function(){var t=e._readableState;Mu("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&xu(e,"data")&&(t.flowing=!0,cp(e))}}(n);e.on("drain",a);var c=!1;function l(t){Mu("ondata");var o=e.write(t);Mu("dest.write",o),!1===o&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==dp(r.pipes,e))&&!c&&(Mu("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function u(t){Mu("onerror",t),f(),e.removeListener("error",u),0===xu(e,"error")&&zu(e,t)}function p(){e.removeListener("finish",d),f()}function d(){Mu("onfinish"),e.removeListener("close",p),f()}function f(){Mu("unpipe"),n.unpipe(e)}return n.on("data",l),function(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)}(e,"error",u),e.once("close",p),e.once("finish",d),e.emit("pipe",n),r.flowing||(Mu("pipe resume"),n.resume()),e},Xu.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=dp(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},Xu.prototype.on=function(e,t){var n=Tu.prototype.on.call(this,e,t),r=this._readableState;return"data"===e?(r.readableListening=this.listenerCount("readable")>0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,Mu("on readable",r.length,r.reading),r.length?tp(this):r.reading||process.nextTick(sp,this))),n},Xu.prototype.addListener=Xu.prototype.on,Xu.prototype.removeListener=function(e,t){var n=Tu.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(ip,this),n},Xu.prototype.removeAllListeners=function(e){var t=Tu.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||process.nextTick(ip,this),t},Xu.prototype.resume=function(){var e=this._readableState;return e.flowing||(Mu("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(ap,e,t))}(this,e)),e.paused=!1,this},Xu.prototype.pause=function(){return Mu("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(Mu("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},Xu.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var o in e.on("end",(function(){if(Mu("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){(Mu("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<Ju.length;i++)e.on(Ju[i],this.emit.bind(this,Ju[i]));return this._read=function(t){Mu("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(Xu.prototype[Symbol.asyncIterator]=function(){return void 0===ju&&(ju=Iu),ju(this)}),Object.defineProperty(Xu.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(Xu.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(Xu.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),Xu._fromList=lp,Object.defineProperty(Xu.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(Xu.from=function(e,t){return void 0===Uu&&(Uu=Au),Uu(Xu,e,t)});var fp=_p,hp=yl.codes,mp=hp.ERR_METHOD_NOT_IMPLEMENTED,gp=hp.ERR_MULTIPLE_CALLBACK,yp=hp.ERR_TRANSFORM_ALREADY_TRANSFORMING,bp=hp.ERR_TRANSFORM_WITH_LENGTH_0,vp=Zl;function wp(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new gp);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 _p(e){if(!(this instanceof _p))return new _p(e);vp.call(this,e),this._transformState={afterTransform:wp.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",Cp)}function Cp(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?Sp(this,null,null):this._flush((function(t,n){Sp(e,t,n)}))}function Sp(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new bp;if(e._transformState.transforming)throw new yp;return e.push(null)}ws.exports(_p,vp),_p.prototype.push=function(e,t){return this._transformState.needTransform=!1,vp.prototype.push.call(this,e,t)},_p.prototype._transform=function(e,t,n){n(new mp("_transform()"))},_p.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)}},_p.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))},_p.prototype._destroy=function(e,t){vp.prototype._destroy.call(this,e,(function(e){t(e)}))};var kp,Ep=Ip,Rp=fp;function Ip(e){if(!(this instanceof Ip))return new Ip(e);Rp.call(this,e)}ws.exports(Ip,Rp),Ip.prototype._transform=function(e,t,n){n(null,e)};var Ap=yl.codes,Op=Ap.ERR_MISSING_ARGS,xp=Ap.ERR_STREAM_DESTROYED;function Tp(e){if(e)throw e}function Pp(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var o=!1;e.on("close",(function(){o=!0})),void 0===kp&&(kp=pu),kp(e,{readable:t,writable:n},(function(e){if(e)return r(e);o=!0,r()}));var i=!1;return function(t){if(!o&&!i)return i=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new xp("pipe"))}}function Bp(e){e()}function Mp(e,t){return e.pipe(t)}function Fp(e){return e.length?"function"!=typeof e[e.length-1]?Tp:e.pop():Tp}var Np=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,o=Fp(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Op("streams");var i=t.map((function(e,n){var s=n<t.length-1;return Pp(e,s,n>0,(function(e){r||(r=e),e&&i.forEach(Bp),s||(i.forEach(Bp),o(r))}))}));return t.reduce(Mp)};!function(e,t){(t=e.exports=Ou).Stream=t,t.Readable=t,t.Writable=kl,t.Duplex=Zl,t.Transform=fp,t.PassThrough=Ep,t.finished=pu,t.pipeline=Np}(ol,ol.exports);const{Buffer:jp}=a.default,Up=Symbol.for("BufferList");function Lp(e){if(!(this instanceof Lp))return new Lp(e);Lp._init.call(this,e)}Lp._init=function(e){Object.defineProperty(this,Up,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},Lp.prototype._new=function(e){return new Lp(e)},Lp.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}},Lp.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},Lp.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},Lp.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)},Lp.prototype.copy=function(e,t,n,r){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof r||r>this.length)&&(r=this.length),n>=this.length)return e||jp.alloc(0);if(r<=0)return e||jp.alloc(0);const o=!!e,i=this._offset(n),s=r-n;let a=s,c=o&&t||0,l=i[1];if(0===n&&r===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:jp.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,c),c+=this._bufs[t].length;return e}if(a<=this._bufs[i[0]].length-l)return o?this._bufs[i[0]].copy(e,t,l,l+a):this._bufs[i[0]].slice(l,l+a);o||(e=jp.allocUnsafe(s));for(let t=i[0];t<this._bufs.length;t++){const n=this._bufs[t].length-l;if(!(a>n)){this._bufs[t].copy(e,c,l,l+a),c+=n;break}this._bufs[t].copy(e,c,l),c+=n,a-=n,l&&(l=0)}return e.length>c?e.slice(0,c):e},Lp.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)},Lp.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},Lp.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},Lp.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},Lp.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(jp.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(jp.from(e));return this},Lp.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},Lp.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=jp.from([e]):"string"==typeof e?e=jp.from(e,n):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=jp.from(e.buffer,e.byteOffset,e.byteLength):jp.isBuffer(e)||(e=jp.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 r=this._offset(t);let o=r[0],i=r[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;i<t.length;){if(t.length-i>=e.length){const n=t.indexOf(e,i);if(-1!==n)return this._reverseOffset([o,n]);i=t.length-e.length+1}else{const t=this._reverseOffset([o,i]);if(this._match(t,e))return t;i++}}i=0}return-1},Lp.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){Lp.prototype[t]=null===e[t]?function(e,n){return this.slice(e,e+n)[t](0,n)}:function(n=0){return this.slice(n,n+e[t])[t](0)}}(t)}(),Lp.prototype._isBufferList=function(e){return e instanceof Lp||Lp.isBufferList(e)},Lp.isBufferList=function(e){return null!=e&&e[Up]};var Dp=Lp;const qp=ol.exports.Duplex,$p=ws.exports,Hp=Dp;function Wp(e){if(!(this instanceof Wp))return new Wp(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}Hp._init.call(this,e),qp.call(this)}$p(Wp,qp),Object.assign(Wp.prototype,Hp.prototype),Wp.prototype._new=function(e){return new Wp(e)},Wp.prototype._write=function(e,t,n){this._appendBuffer(e),"function"==typeof n&&n()},Wp.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)},Wp.prototype.end=function(e){qp.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},Wp.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},Wp.prototype._isBufferList=function(e){return e instanceof Wp||e instanceof Hp||Wp.isBufferList(e)},Wp.isBufferList=Hp.isBufferList,rl.exports=Wp,rl.exports.BufferListStream=Wp,rl.exports.BufferList=Hp;var Vp=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}},Kp={exports:{}};!function(e){const t=e.exports;t.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"},t.codes={};for(const e in t.types){const n=t.types[e];t.codes[n]=e}t.CMD_SHIFT=4,t.CMD_MASK=240,t.DUP_MASK=8,t.QOS_MASK=3,t.QOS_SHIFT=1,t.RETAIN_MASK=1,t.VARBYTEINT_MASK=127,t.VARBYTEINT_FIN_MASK=128,t.VARBYTEINT_MAX=268435455,t.SESSIONPRESENT_MASK=1,t.SESSIONPRESENT_HEADER=Buffer.from([t.SESSIONPRESENT_MASK]),t.CONNACK_HEADER=Buffer.from([t.codes.connack<<t.CMD_SHIFT]),t.USERNAME_MASK=128,t.PASSWORD_MASK=64,t.WILL_RETAIN_MASK=32,t.WILL_QOS_MASK=24,t.WILL_QOS_SHIFT=3,t.WILL_FLAG_MASK=4,t.CLEAN_SESSION_MASK=2,t.CONNECT_HEADER=Buffer.from([t.codes.connect<<t.CMD_SHIFT]),t.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},t.propertiesCodes={};for(const e in t.properties){const n=t.properties[e];t.propertiesCodes[n]=e}function n(e){return[0,1,2].map((n=>[0,1].map((r=>[0,1].map((o=>{const i=Buffer.alloc(1);return i.writeUInt8(t.codes[e]<<t.CMD_SHIFT|(r?t.DUP_MASK:0)|n<<t.QOS_SHIFT|o,0,!0),i}))))))}t.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"},t.PUBLISH_HEADER=n("publish"),t.SUBSCRIBE_HEADER=n("subscribe"),t.SUBSCRIBE_OPTIONS_QOS_MASK=3,t.SUBSCRIBE_OPTIONS_NL_MASK=1,t.SUBSCRIBE_OPTIONS_NL_SHIFT=2,t.SUBSCRIBE_OPTIONS_RAP_MASK=1,t.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,t.SUBSCRIBE_OPTIONS_RH_MASK=3,t.SUBSCRIBE_OPTIONS_RH_SHIFT=4,t.SUBSCRIBE_OPTIONS_RH=[0,16,32],t.SUBSCRIBE_OPTIONS_NL=4,t.SUBSCRIBE_OPTIONS_RAP=8,t.SUBSCRIBE_OPTIONS_QOS=[0,1,2],t.UNSUBSCRIBE_HEADER=n("unsubscribe"),t.ACKS={unsuback:n("unsuback"),puback:n("puback"),pubcomp:n("pubcomp"),pubrel:n("pubrel"),pubrec:n("pubrec")},t.SUBACK_HEADER=Buffer.from([t.codes.suback<<t.CMD_SHIFT]),t.VERSION3=Buffer.from([3]),t.VERSION4=Buffer.from([4]),t.VERSION5=Buffer.from([5]),t.VERSION131=Buffer.from([131]),t.VERSION132=Buffer.from([132]),t.QOS=[0,1,2].map((e=>Buffer.from([e]))),t.EMPTY={pingreq:Buffer.from([t.codes.pingreq<<4,0]),pingresp:Buffer.from([t.codes.pingresp<<4,0]),disconnect:Buffer.from([t.codes.disconnect<<4,0])}}(Kp);const zp=rl.exports,Jp=s.default,Qp=Vp,Xp=Kp.exports,Yp=dt.exports("mqtt-packet:parser");class Gp extends Jp{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof Gp?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new Gp).parser(e)}_resetState(){Yp("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new Qp,this.error=null,this._list=zp(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),Yp("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++,Yp("parse: state complete. _stateCounter is now: %d",this._stateCounter),Yp("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return Yp("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=Xp.types[e>>Xp.CMD_SHIFT],this.packet.retain=0!=(e&Xp.RETAIN_MASK),this.packet.qos=e>>Xp.QOS_SHIFT&Xp.QOS_MASK,this.packet.dup=0!=(e&Xp.DUP_MASK),Yp("_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)),Yp("_parseLength %d",e.value),!!e}_parsePayload(){Yp("_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 Yp("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,n,r;Yp("_parseConnect");const o={},i=this.packet,s=this._parseString();if(null===s)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==s&&"MQIsdp"!==s)return this._emitError(new Error("Invalid protocolId"));if(i.protocolId=s,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)&Xp.USERNAME_MASK,o.password=this._list.readUInt8(this._pos)&Xp.PASSWORD_MASK,o.will=this._list.readUInt8(this._pos)&Xp.WILL_FLAG_MASK,o.will&&(i.will={},i.will.retain=0!=(this._list.readUInt8(this._pos)&Xp.WILL_RETAIN_MASK),i.will.qos=(this._list.readUInt8(this._pos)&Xp.WILL_QOS_MASK)>>Xp.WILL_QOS_SHIFT),i.clean=0!=(this._list.readUInt8(this._pos)&Xp.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 a=this._parseString();if(null===a)return this._emitError(new Error("Packet too short"));if(i.clientId=a,Yp("_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,Yp("_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,Yp("_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,Yp("_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,Yp("_parseConnect: complete"),i}_parseConnack(){Yp("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&Xp.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)}Yp("_parseConnack: complete")}_parsePublish(){Yp("_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),Yp("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){Yp("_parseSubscribe");const e=this.packet;let t,n,r,o,i,s,a;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&Xp.SUBSCRIBE_OPTIONS_QOS_MASK,s=0!=(n>>Xp.SUBSCRIBE_OPTIONS_NL_SHIFT&Xp.SUBSCRIBE_OPTIONS_NL_MASK),i=0!=(n>>Xp.SUBSCRIBE_OPTIONS_RAP_SHIFT&Xp.SUBSCRIBE_OPTIONS_RAP_MASK),o=n>>Xp.SUBSCRIBE_OPTIONS_RH_SHIFT&Xp.SUBSCRIBE_OPTIONS_RH_MASK,a={topic:t,qos:r},5===this.settings.protocolVersion?(a.nl=s,a.rap=i,a.rh=o):this.settings.bridgeMode&&(a.rh=0,a.rap=!0,a.nl=!0),Yp("_parseSubscribe: push subscription `%s` to subscription",a),e.subscriptions.push(a)}}}_parseSuback(){Yp("_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(){Yp("_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"));Yp("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){Yp("_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(){Yp("_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(),Yp("_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(Yp("_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 Yp("_parseDisconnect result: true"),!0}_parseAuth(){Yp("_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),Yp("_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):(Yp("_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,Yp("_parseString: result: %s",r),r}_parseStringPair(){return Yp("_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,Yp("_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,Yp("_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,Yp("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){Yp("_parseVarByteNum");let t,n=0,r=1,o=0,i=!1;const s=this._pos?this._pos:0;for(;n<4&&s+n<this._list.length;){if(t=this._list.readUInt8(s+n++),o+=r*(t&Xp.VARBYTEINT_MASK),r*=128,0==(t&Xp.VARBYTEINT_FIN_MASK)){i=!0;break}if(this._list.length<=n)break}return!i&&4===n&&this._list.length>=n&&this._emitError(new Error("Invalid variable byte integer")),s&&(this._pos+=n),i=!!i&&(e?{bytes:n,value:o}:o),Yp("_parseVarByteNum: result: %o",i),i}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),Yp("_parseByte: result: %o",e),e}_parseByType(e){switch(Yp("_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(){Yp("_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=Xp.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(Xp.propertiesTypes[t]))):n[t]=this._parseByType(Xp.propertiesTypes[t]);else{n[t]||(n[t]=Object.create(null));const e=this._parseByType(Xp.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 Yp("_newPacket"),this.packet&&(this._list.consume(this.packet.length),Yp("_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)),Yp("_newPacket: new packet"),this.packet=new Qp,this._pos=0,!0}_emitError(e){Yp("_emitError"),this.error=e,this.emit("error",e)}}var Zp=Gp;const ed={},td=Buffer.isBuffer(Buffer.from([1,2]).subarray(0,1));function nd(e){const t=Buffer.allocUnsafe(2);return t.writeUInt8(e>>8,0),t.writeUInt8(255&e,1),t}var rd={cache:ed,generateCache:function(){for(let e=0;e<65536;e++)ed[e]=nd(e)},generateNumber:nd,genBufVariableByteInt:function(e){let t=0,n=0;const r=Buffer.allocUnsafe(4);do{t=e%128|0,(e=e/128|0)>0&&(t|=128),r.writeUInt8(t,n++)}while(e>0&&n<4);return e>0&&(n=0),td?r.subarray(0,n):r.slice(0,n)},generate4ByteBuffer:function(e){const t=Buffer.allocUnsafe(4);return t.writeUInt32BE(e,0),t}},od={exports:{}};"undefined"==typeof process||!process.version||0===process.version.indexOf("v0.")||0===process.version.indexOf("v1.")&&0!==process.version.indexOf("v1.8.")?od.exports={nextTick:function(e,t,n,r){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,i,s=arguments.length;switch(s){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick((function(){e.call(null,t)}));case 3:return process.nextTick((function(){e.call(null,t,n)}));case 4:return process.nextTick((function(){e.call(null,t,n,r)}));default:for(o=new Array(s-1),i=0;i<o.length;)o[i++]=arguments[i];return process.nextTick((function(){e.apply(null,o)}))}}}:od.exports=process;const id=Kp.exports,sd=Buffer.allocUnsafe(0),ad=Buffer.from([0]),cd=rd,ld=od.exports.nextTick,ud=dt.exports("mqtt-packet:writeToStream"),pd=cd.cache,dd=cd.generateNumber,fd=cd.generateCache,hd=cd.genBufVariableByteInt,md=cd.generate4ByteBuffer;let gd=kd,yd=!0;function bd(e,t,n){switch(ud("generate called"),t.cork&&(t.cork(),ld(vd,t)),yd&&(yd=!1,fd()),ud("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,t,n){const r=e||{},o=r.protocolId||"MQTT";let i=r.protocolVersion||4;const s=r.will;let a=r.clean;const c=r.keepalive||0,l=r.clientId||"",u=r.username,p=r.password,d=r.properties;void 0===a&&(a=!0);let f=0;if(!o||"string"!=typeof o&&!Buffer.isBuffer(o))return t.emit("error",new Error("Invalid protocolId")),!1;f+=o.length+2;if(3!==i&&4!==i&&5!==i)return t.emit("error",new Error("Invalid protocol version")),!1;f+=1;if(("string"==typeof l||Buffer.isBuffer(l))&&(l||i>=4)&&(l||a))f+=Buffer.byteLength(l)+2;else{if(i<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*a==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof c||c<0||c>65535||c%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;f+=2;if(f+=1,5===i){var h=Id(t,d);if(!h)return!1;f+=h.length}if(s){if("object"!=typeof s)return t.emit("error",new Error("Invalid will")),!1;if(!s.topic||"string"!=typeof s.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(f+=Buffer.byteLength(s.topic)+2,f+=2,s.payload){if(!(s.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof s.payload?f+=Buffer.byteLength(s.payload):f+=s.payload.length}var m={};if(5===i){if(!(m=Id(t,s.properties)))return!1;f+=m.length}}let g=!1;if(null!=u){if(!Pd(u))return t.emit("error",new Error("Invalid username")),!1;g=!0,f+=Buffer.byteLength(u)+2}if(null!=p){if(!g)return t.emit("error",new Error("Username is required to use password")),!1;if(!Pd(p))return t.emit("error",new Error("Invalid password")),!1;f+=Td(p)+2}t.write(id.CONNECT_HEADER),_d(t,f),Rd(t,o),r.bridgeMode&&(i+=128);t.write(131===i?id.VERSION131:132===i?id.VERSION132:4===i?id.VERSION4:5===i?id.VERSION5:id.VERSION3);let y=0;y|=null!=u?id.USERNAME_MASK:0,y|=null!=p?id.PASSWORD_MASK:0,y|=s&&s.retain?id.WILL_RETAIN_MASK:0,y|=s&&s.qos?s.qos<<id.WILL_QOS_SHIFT:0,y|=s?id.WILL_FLAG_MASK:0,y|=a?id.CLEAN_SESSION_MASK:0,t.write(Buffer.from([y])),gd(t,c),5===i&&h.write();Rd(t,l),s&&(5===i&&m.write(),Cd(t,s.topic),Rd(t,s.payload));null!=u&&Rd(t,u);null!=p&&Rd(t,p);return!0}(e,t);case"connack":return function(e,t,n){const r=n?n.protocolVersion:4,o=e||{},i=5===r?o.reasonCode:o.returnCode,s=o.properties;let a=2;if("number"!=typeof i)return t.emit("error",new Error("Invalid return code")),!1;let c=null;if(5===r){if(c=Id(t,s),!c)return!1;a+=c.length}t.write(id.CONNACK_HEADER),_d(t,a),t.write(o.sessionPresent?id.SESSIONPRESENT_HEADER:ad),t.write(Buffer.from([i])),null!=c&&c.write();return!0}(e,t,n);case"publish":return function(e,t,n){ud("publish: packet: %o",e);const r=n?n.protocolVersion:4,o=e||{},i=o.qos||0,s=o.retain?id.RETAIN_MASK:0,a=o.topic,c=o.payload||sd,l=o.messageId,u=o.properties;let p=0;if("string"==typeof a)p+=Buffer.byteLength(a)+2;else{if(!Buffer.isBuffer(a))return t.emit("error",new Error("Invalid topic")),!1;p+=a.length+2}Buffer.isBuffer(c)?p+=c.length:p+=Buffer.byteLength(c);if(i&&"number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;i&&(p+=2);let d=null;if(5===r){if(d=Id(t,u),!d)return!1;p+=d.length}t.write(id.PUBLISH_HEADER[i][o.dup?1:0][s?1:0]),_d(t,p),gd(t,Td(a)),t.write(a),i>0&&gd(t,l);null!=d&&d.write();return ud("publish: payload: %o",c),t.write(c)}(e,t,n);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,n){const r=n?n.protocolVersion:4,o=e||{},i=o.cmd||"puback",s=o.messageId,a=o.dup&&"pubrel"===i?id.DUP_MASK:0;let c=0;const l=o.reasonCode,u=o.properties;let p=5===r?3:2;"pubrel"===i&&(c=1);if("number"!=typeof s)return t.emit("error",new Error("Invalid messageId")),!1;let d=null;if(5===r&&"object"==typeof u){if(d=Ad(t,u,n,p),!d)return!1;p+=d.length}t.write(id.ACKS[i][c][a][0]),_d(t,p),gd(t,s),5===r&&t.write(Buffer.from([l]));null!==d&&d.write();return!0}(e,t,n);case"subscribe":return function(e,t,n){ud("subscribe: packet: ");const r=n?n.protocolVersion:4,o=e||{},i=o.dup?id.DUP_MASK:0,s=o.messageId,a=o.subscriptions,c=o.properties;let l=0;if("number"!=typeof s)return t.emit("error",new Error("Invalid messageId")),!1;l+=2;let u=null;if(5===r){if(u=Id(t,c),!u)return!1;l+=u.length}if("object"!=typeof a||!a.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<a.length;e+=1){const n=a[e].topic,o=a[e].qos;if("string"!=typeof n)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof o)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===r){if("boolean"!=typeof(a[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(a[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const n=a[e].rh||0;if("number"!=typeof n||n>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}l+=Buffer.byteLength(n)+2+1}ud("subscribe: writing to stream: %o",id.SUBSCRIBE_HEADER),t.write(id.SUBSCRIBE_HEADER[1][i?1:0][0]),_d(t,l),gd(t,s),null!==u&&u.write();let p=!0;for(const e of a){const n=e.topic,o=e.qos,i=+e.nl,s=+e.rap,a=e.rh;let c;Cd(t,n),c=id.SUBSCRIBE_OPTIONS_QOS[o],5===r&&(c|=i?id.SUBSCRIBE_OPTIONS_NL:0,c|=s?id.SUBSCRIBE_OPTIONS_RAP:0,c|=a?id.SUBSCRIBE_OPTIONS_RH[a]:0),p=t.write(Buffer.from([c]))}return p}(e,t,n);case"suback":return function(e,t,n){const r=n?n.protocolVersion:4,o=e||{},i=o.messageId,s=o.granted,a=o.properties;let c=0;if("number"!=typeof i)return t.emit("error",new Error("Invalid messageId")),!1;c+=2;if("object"!=typeof s||!s.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<s.length;e+=1){if("number"!=typeof s[e])return t.emit("error",new Error("Invalid qos vector")),!1;c+=1}let l=null;if(5===r){if(l=Ad(t,a,n,c),!l)return!1;c+=l.length}t.write(id.SUBACK_HEADER),_d(t,c),gd(t,i),null!==l&&l.write();return t.write(Buffer.from(s))}(e,t,n);case"unsubscribe":return function(e,t,n){const r=n?n.protocolVersion:4,o=e||{},i=o.messageId,s=o.dup?id.DUP_MASK:0,a=o.unsubscriptions,c=o.properties;let l=0;if("number"!=typeof i)return t.emit("error",new Error("Invalid messageId")),!1;l+=2;if("object"!=typeof a||!a.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<a.length;e+=1){if("string"!=typeof a[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;l+=Buffer.byteLength(a[e])+2}let u=null;if(5===r){if(u=Id(t,c),!u)return!1;l+=u.length}t.write(id.UNSUBSCRIBE_HEADER[1][s?1:0][0]),_d(t,l),gd(t,i),null!==u&&u.write();let p=!0;for(let e=0;e<a.length;e++)p=Cd(t,a[e]);return p}(e,t,n);case"unsuback":return function(e,t,n){const r=n?n.protocolVersion:4,o=e||{},i=o.messageId,s=o.dup?id.DUP_MASK:0,a=o.granted,c=o.properties,l=o.cmd,u=0;let p=2;if("number"!=typeof i)return t.emit("error",new Error("Invalid messageId")),!1;if(5===r){if("object"!=typeof a||!a.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<a.length;e+=1){if("number"!=typeof a[e])return t.emit("error",new Error("Invalid qos vector")),!1;p+=1}}let d=null;if(5===r){if(d=Ad(t,c,n,p),!d)return!1;p+=d.length}t.write(id.ACKS[l][u][s][0]),_d(t,p),gd(t,i),null!==d&&d.write();5===r&&t.write(Buffer.from(a));return!0}(e,t,n);case"pingreq":case"pingresp":return function(e,t,n){return t.write(id.EMPTY[e.cmd])}(e,t);case"disconnect":return function(e,t,n){const r=n?n.protocolVersion:4,o=e||{},i=o.reasonCode,s=o.properties;let a=5===r?1:0,c=null;if(5===r){if(c=Ad(t,s,n,a),!c)return!1;a+=c.length}t.write(Buffer.from([id.codes.disconnect<<4])),_d(t,a),5===r&&t.write(Buffer.from([i]));null!==c&&c.write();return!0}(e,t,n);case"auth":return function(e,t,n){const r=n?n.protocolVersion:4,o=e||{},i=o.reasonCode,s=o.properties;let a=5===r?1:0;5!==r&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const c=Ad(t,s,n,a);if(!c)return!1;a+=c.length,t.write(Buffer.from([id.codes.auth<<4])),_d(t,a),t.write(Buffer.from([i])),null!==c&&c.write();return!0}(e,t,n);default:return t.emit("error",new Error("Unknown command")),!1}}function vd(e){e.uncork()}Object.defineProperty(bd,"cacheNumbers",{get:()=>gd===kd,set(e){e?(pd&&0!==Object.keys(pd).length||(yd=!0),gd=kd):(yd=!1,gd=Ed)}});const wd={};function _d(e,t){if(t>id.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let n=wd[t];return n||(n=hd(t),t<16384&&(wd[t]=n)),ud("writeVarByteInt: writing to stream: %o",n),e.write(n)}function Cd(e,t){const n=Buffer.byteLength(t);return gd(e,n),ud("writeString: %s",t),e.write(t,"utf8")}function Sd(e,t,n){Cd(e,t),Cd(e,n)}function kd(e,t){return ud("writeNumberCached: number: %d",t),ud("writeNumberCached: %o",pd[t]),e.write(pd[t])}function Ed(e,t){const n=dd(t);return ud("writeNumberGenerated: %o",n),e.write(n)}function Rd(e,t){"string"==typeof t?Cd(e,t):t?(gd(e,t.length),e.write(t)):gd(e,0)}function Id(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){xd(e,{},0)}};let n=0;function r(t,n){let r=0;switch(id.propertiesTypes[t]){case"byte":if("boolean"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=2;break;case"int8":if("number"!=typeof n||n<0||n>255)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=2;break;case"binary":if(n&&null===n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=1+Buffer.byteLength(n)+2;break;case"int16":if("number"!=typeof n||n<0||n>65535)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=3;break;case"int32":if("number"!=typeof n||n<0||n>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=5;break;case"var":if("number"!=typeof n||n<0||n>268435455)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=1+Buffer.byteLength(hd(n));break;case"string":if("string"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=3+Buffer.byteLength(n.toString());break;case"pair":if("object"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;r+=Object.getOwnPropertyNames(n).reduce(((e,t)=>{const r=n[t];return Array.isArray(r)?e+=r.reduce(((e,n)=>e+=3+Buffer.byteLength(t.toString())+2+Buffer.byteLength(n.toString())),0):e+=3+Buffer.byteLength(t.toString())+2+Buffer.byteLength(n[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${n}`)),!1}return r}if(t)for(const e in t){let o=0,i=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(i=r(e,s[t]),!i)return!1;o+=i}else{if(i=r(e,s),!i)return!1;o=i}if(!o)return!1;n+=o}return{length:Buffer.byteLength(hd(n))+n,write(){xd(e,t,n)}}}function Ad(e,t,n,r){const o=["reasonString","userProperties"],i=n&&n.properties&&n.properties.maximumPacketSize?n.properties.maximumPacketSize:0;let s=Id(e,t);if(i)for(;r+s.length>i;){const n=o.shift();if(!n||!t[n])return!1;delete t[n],s=Id(e,t)}return s}function Od(e,t,n){switch(id.propertiesTypes[t]){case"byte":e.write(Buffer.from([id.properties[t]])),e.write(Buffer.from([+n]));break;case"int8":e.write(Buffer.from([id.properties[t]])),e.write(Buffer.from([n]));break;case"binary":e.write(Buffer.from([id.properties[t]])),Rd(e,n);break;case"int16":e.write(Buffer.from([id.properties[t]])),gd(e,n);break;case"int32":e.write(Buffer.from([id.properties[t]])),function(e,t){const n=md(t);ud("write4ByteNumber: %o",n),e.write(n)}(e,n);break;case"var":e.write(Buffer.from([id.properties[t]])),_d(e,n);break;case"string":e.write(Buffer.from([id.properties[t]])),Cd(e,n);break;case"pair":Object.getOwnPropertyNames(n).forEach((r=>{const o=n[r];Array.isArray(o)?o.forEach((n=>{e.write(Buffer.from([id.properties[t]])),Sd(e,r.toString(),n.toString())})):(e.write(Buffer.from([id.properties[t]])),Sd(e,r.toString(),o.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${n}`)),!1}}function xd(e,t,n){_d(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++)Od(e,n,r[t]);else Od(e,n,r)}}function Td(e){return e?e instanceof Buffer?e.length:Buffer.byteLength(e):0}function Pd(e){return"string"==typeof e||e instanceof Buffer}var Bd=bd;const Md=Bd,Fd=s.default;class Nd extends Fd{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),n=this._array;let r,o=0;for(r=0;r<n.length&&void 0!==n[r];r++)"string"!=typeof n[r]?t[r]=n[r].length:t[r]=Buffer.byteLength(n[r]),e+=t[r];const i=Buffer.allocUnsafe(e);for(r=0;r<n.length&&void 0!==n[r];r++)"string"!=typeof n[r]?(n[r].copy(i,o),o+=t[r]):(i.write(n[r],o),o+=t[r]);return i}}var jd=function(e,t){const n=new Nd;return Md(e,n,t),n.concat()};function Ud(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}}nl.parser=Zp.parser,nl.generate=jd,nl.writeToStream=Bd;var Ld=function(){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 Ud(arguments[0],arguments[1],e)};function Dd(e){for(var t=e.split("/"),n=0;n<t.length;n++)if("+"!==t[n]){if("#"===t[n])return n===t.length-1;if(-1!==t[n].indexOf("+")||-1!==t[n].indexOf("#"))return!1}return!0}var qd={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(var t=0;t<e.length;t++)if(!Dd(e[t]))return e[t];return null}},$d=s.default.EventEmitter,Hd=tl,Wd=nl,Vd=ts.exports.Writable,Kd=ws.exports,zd=Ld,Jd=qd,Qd=Zi,Xd=dt.exports("mqttjs:client"),Yd=process?process.nextTick:function(e){setTimeout(e,0)},Gd=ge.setImmediate||function(e){Yd(e)},Zd={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},ef=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],tf={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 nf(e,t,n){Xd("sendPacket :: packet: %O",t),Xd("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),Xd("sendPacket :: writing to stream");var r=Wd.writeToStream(t,e.stream,e.options);Xd("sendPacket :: writeToStream result %s",r),!r&&n?(Xd("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",n)):n&&(Xd("sendPacket :: invoking cb"),n())}function rf(e){e&&(Xd("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 of(e,t,n,r){Xd("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd),e.outgoingStore.put(t,(function(o){if(o)return n&&n(o);r(),nf(e,t,n)}))}function sf(e){Xd("nop ::",e)}function af(e,t){var n,r=this;if(!(this instanceof af))return new af(e,t);for(n in this.options=t||{},Zd)void 0===this.options[n]?this.options[n]=Zd[n]:this.options[n]=t[n];Xd("MqttClient :: options.protocol",t.protocol),Xd("MqttClient :: options.protocolVersion",t.protocolVersion),Xd("MqttClient :: options.username",t.username),Xd("MqttClient :: options.keepalive",t.keepalive),Xd("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),Xd("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),Xd("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.outgoingStore=t.outgoingStore||new Hd,this.incomingStore=t.incomingStore||new Hd,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this.nextId=Math.max(1,Math.floor(65535*Math.random())),this.outgoing={},this._firstConnection=!0,this.on("connect",(function(){var e=this.queue;Xd("connect :: sending queued packets"),function t(){var n,o=e.shift();Xd("deliver :: entry %o",o),o&&(n=o.packet,Xd("deliver :: call _sendPacket for %o",n),r._sendPacket(n,(function(e){o.cb&&o.cb(e),t()})))}()})),this.on("close",(function(){Xd("close :: connected set to `false`"),this.connected=!1,Xd("close :: clearing connackTimer"),clearTimeout(this.connackTimer),Xd("close :: clearing ping timer"),null!==r.pingTimer&&(r.pingTimer.clear(),r.pingTimer=null),Xd("close :: calling _setupReconnect"),this._setupReconnect()})),$d.call(this),Xd("MqttClient :: setting up stream"),this._setupStream()}Kd(af,$d),af.prototype._setupStream=function(){var e,t=this,n=new Vd,r=Wd.parser(this.options),o=null,i=[];function s(){if(i.length)Yd(a);else{var e=o;o=null,e()}}function a(){Xd("work :: getting next packet in queue");var e=i.shift();if(e)Xd("work :: packet pulled from queue"),t._handlePacket(e,s);else{Xd("work :: no packets in queue");var n=o;o=null,Xd("work :: done flag is %s",!!n),n&&n()}}if(Xd("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),Xd("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){Xd("parser :: on packet push to packets array."),i.push(e)})),n._write=function(e,t,n){o=n,Xd("writable stream :: parsing buffer"),r.parse(e),a()},Xd("_setupStream :: pipe stream to writable stream"),this.stream.pipe(n),this.stream.on("error",(function(e){Xd("streamErrorHandler :: error",e.message),ef.includes(e.code)?(Xd("streamErrorHandler :: emitting error"),t.emit("error",e)):sf(e)})),this.stream.on("close",(function(){var e;Xd("(%s)stream :: on close",t.options.clientId),(e=t.outgoing)&&(Xd("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])}))),Xd("stream: emit close to MqttClient"),t.emit("close")})),Xd("_setupStream: sending packet `connect`"),(e=Object.create(this.options)).cmd="connect",nf(this,e),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return t.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;if(this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket)nf(this,Qd({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){Xd("!!connectTimeout hit!! Calling _cleanUp with force `true`"),t._cleanUp(!0)}),this.options.connectTimeout)},af.prototype._handlePacket=function(e,t){var n=this.options;if(5===n.protocolVersion&&n.properties&&n.properties.maximumPacketSize&&n.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(Xd("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},af.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},af.prototype.publish=function(e,t,n,r){var o;Xd("publish :: message `%s` to topic `%s`",t,e);var i=this.options;"function"==typeof n&&(r=n,n=null);if(n=Qd({qos:0,retain:!1,dup:!1},n),this._checkDisconnecting(r))return this;switch(o={cmd:"publish",topic:e,payload:t,qos:n.qos,retain:n.retain,messageId:this._nextId(),dup:n.dup},5===i.protocolVersion&&(o.properties=n.properties,(!i.properties&&o.properties&&o.properties.topicAlias||n.properties&&i.properties&&(n.properties.topicAlias&&i.properties.topicAliasMaximum&&n.properties.topicAlias>i.properties.topicAliasMaximum||!i.properties.topicAliasMaximum&&n.properties.topicAlias))&&delete o.properties.topicAlias),Xd("publish :: qos",n.qos),n.qos){case 1:case 2:this.outgoing[o.messageId]={volatile:!1,cb:r||sf},this._storeProcessing?(Xd("_storeProcessing enabled"),this._packetIdsDuringStoreProcessing[o.messageId]=!1,this._storePacket(o,void 0,n.cbStorePut)):(Xd("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,void 0,n.cbStorePut));break;default:this._storeProcessing?(Xd("_storeProcessing enabled"),this._storePacket(o,r,n.cbStorePut)):(Xd("MqttClient:publish: packet cmd: %s",o.cmd),this._sendPacket(o,r,n.cbStorePut))}return this},af.prototype.subscribe=function(){for(var e,t=new Array(arguments.length),n=0;n<arguments.length;n++)t[n]=arguments[n];var r,o=[],i=t.shift(),s=i.resubscribe,a=t.pop()||sf,c=t.pop(),l=this,u=this.options.protocolVersion;if(delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof a&&(c=a,a=sf),null!==(r=Jd.validateTopics(i)))return Gd(a,new Error("Invalid topic "+r)),this;if(this._checkDisconnecting(a))return Xd("subscribe: discconecting true"),this;var p={qos:0};if(5===u&&(p.nl=!1,p.rap=!1,p.rh=0),c=Qd(p,c),Array.isArray(i)?i.forEach((function(e){if(Xd("subscribe: array topic %s",e),!l._resubscribeTopics.hasOwnProperty(e)||l._resubscribeTopics[e].qos<c.qos||s){var t={topic:e,qos:c.qos};5===u&&(t.nl=c.nl,t.rap=c.rap,t.rh=c.rh,t.properties=c.properties),Xd("subscribe: pushing topic `%s` and qos `%s` to subs list",t.topic,t.qos),o.push(t)}})):Object.keys(i).forEach((function(e){if(Xd("subscribe: object topic %s",e),!l._resubscribeTopics.hasOwnProperty(e)||l._resubscribeTopics[e].qos<i[e].qos||s){var t={topic:e,qos:i[e].qos};5===u&&(t.nl=i[e].nl,t.rap=i[e].rap,t.rh=i[e].rh,t.properties=c.properties),Xd("subscribe: pushing `%s` to subs list",t),o.push(t)}})),e={cmd:"subscribe",subscriptions:o,qos:1,retain:!1,dup:!1,messageId:this._nextId()},c.properties&&(e.properties=c.properties),o.length){if(this.options.resubscribe){Xd("subscribe :: resubscribe true");var d=[];o.forEach((function(e){if(l.options.reconnectPeriod>0){var t={qos:e.qos};5===u&&(t.nl=e.nl||!1,t.rap=e.rap||!1,t.rh=e.rh||0,t.properties=e.properties),l._resubscribeTopics[e.topic]=t,d.push(e.topic)}})),l.messageIdToTopic[e.messageId]=d}return this.outgoing[e.messageId]={volatile:!0,cb:function(e,t){if(!e)for(var n=t.granted,r=0;r<n.length;r+=1)o[r].qos=n[r];a(e,o)}},Xd("subscribe :: call _sendPacket"),this._sendPacket(e),this}a(null,[])},af.prototype.unsubscribe=function(){for(var e={cmd:"unsubscribe",qos:1,messageId:this._nextId()},t=this,n=new Array(arguments.length),r=0;r<arguments.length;r++)n[r]=arguments[r];var o=n.shift(),i=n.pop()||sf,s=n.pop();return"string"==typeof o&&(o=[o]),"function"!=typeof i&&(s=i,i=sf),this._checkDisconnecting(i)||("string"==typeof o?e.unsubscriptions=[o]:Array.isArray(o)&&(e.unsubscriptions=o),this.options.resubscribe&&e.unsubscriptions.forEach((function(e){delete t._resubscribeTopics[e]})),"object"==typeof s&&s.properties&&(e.properties=s.properties),this.outgoing[e.messageId]={volatile:!0,cb:i},Xd("unsubscribe: call _sendPacket"),this._sendPacket(e)),this},af.prototype.end=function(e,t,n){var r=this;function o(){Xd("end :: closeStores: closing incoming and outgoing stores"),r.disconnected=!0,r.incomingStore.close((function(e){r.outgoingStore.close((function(t){if(Xd("end :: closeStores: emitting end"),r.emit("end"),n){let r=e||t;Xd("end :: closeStores: invoking callback with args"),n(r)}}))})),r._deferredReconnect&&r._deferredReconnect()}function i(){Xd("end :: (%s) :: finish :: calling _cleanUp with force %s",r.options.clientId,e),r._cleanUp(e,(()=>{Xd("end :: finish :: calling process.nextTick on closeStores"),Yd(o.bind(r))}),t)}return Xd("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(n=t||sf,t=e,e=!1,"object"!=typeof t&&(n=t,t=null,"function"!=typeof n&&(n=sf))),"object"!=typeof t&&(n=t,t=null),Xd("end :: cb? %s",!!n),n=n||sf,this.disconnecting?(n(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(Xd("end :: (%s) :: calling finish in 10ms once outgoing is empty",r.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,i,10))):(Xd("end :: (%s) :: immediately calling finish",r.options.clientId),i()),this)},af.prototype.removeOutgoingMessage=function(e){var t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},af.prototype.reconnect=function(e){Xd("client reconnect");var t=this,n=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new Hd,t.outgoingStore=t.options.outgoingStore||new Hd,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=n:n(),this},af.prototype._reconnect=function(){Xd("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),Xd("client already connected. disconnecting first.")):(Xd("_reconnect: calling _setupStream"),this._setupStream())},af.prototype._setupReconnect=function(){var e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(Xd("_setupReconnect :: emit `offline` state"),this.emit("offline"),Xd("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),Xd("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){Xd("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):Xd("_setupReconnect :: doing nothing...")},af.prototype._clearReconnect=function(){Xd("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},af.prototype._cleanUp=function(e,t){var n=arguments[2];if(t&&(Xd("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),Xd("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&rf(this.outgoing),Xd("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{var r=Qd({cmd:"disconnect"},n);Xd("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(r,Gd.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(Xd("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(Xd("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(Xd("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},af.prototype._sendPacket=function(e,t,n){if(Xd("_sendPacket :: (%s) :: start",this.options.clientId),n=n||sf,!this.connected)return Xd("_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 of(this,e,t,n);default:return void nf(this,e,t)}switch(e.qos){case 2:case 1:of(this,e,t,n);break;default:nf(this,e,t)}Xd("_sendPacket :: (%s) :: end",this.options.clientId)},af.prototype._storePacket=function(e,t,n){Xd("_storePacket :: packet: %o",e),Xd("_storePacket :: cb? %s",!!t),n=n||sf,0===(e.qos||0)&&this.queueQoSZero||"publish"!==e.cmd?this.queue.push({packet:e,cb:t}):e.qos>0?(t=this.outgoing[e.messageId]?this.outgoing[e.messageId].cb:null,this.outgoingStore.put(e,(function(e){if(e)return t&&t(e);n()}))):t&&t(new Error("No connection to broker"))},af.prototype._setupPingTimer=function(){Xd("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);var e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=zd((function(){e._checkPing()}),1e3*this.options.keepalive))},af.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},af.prototype._checkPing=function(){Xd("_checkPing :: checking ping..."),this.pingResp?(Xd("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(Xd("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},af.prototype._handlePingresp=function(){this.pingResp=!0},af.prototype._handleConnack=function(e){Xd("_handleConnack");var t=this.options,n=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),e.properties&&(e.properties.topicAliasMaximum&&(t.properties||(t.properties={}),t.properties.topicAliasMaximum=e.properties.topicAliasMaximum),e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)),0===n)this.reconnecting=!1,this._onConnect(e);else if(n>0){var r=new Error("Connection refused: "+tf[n]);r.code=n,this.emit("error",r)}},af.prototype._handlePublish=function(e,t){Xd("_handlePublish: packet %o",e),t=void 0!==t?t:sf;var n=e.topic.toString(),r=e.payload,o=e.qos,i=e.messageId,s=this,a=this.options,c=[0,16,128,131,135,144,145,151,153];switch(Xd("_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:Xd("_handlePublish: unknown QoS. Doing nothing.")}},af.prototype.handleMessage=function(e,t){t()},af.prototype._handleAck=function(e){var t,n=e.messageId,r=e.cmd,o=null,i=this.outgoing[n]?this.outgoing[n].cb:null,s=this;if(i){switch(Xd("_handleAck :: packet type",r),r){case"pubcomp":case"puback":var a=e.reasonCode;a&&a>0&&16!==a&&((t=new Error("Publish error: "+tf[a])).code=a,i(t,e)),delete this.outgoing[n],this.outgoingStore.del(e,i);break;case"pubrec":o={cmd:"pubrel",qos:2,messageId:n};var c=e.reasonCode;c&&c>0&&16!==c?((t=new Error("Publish error: "+tf[c])).code=c,i(t,e)):this._sendPacket(o);break;case"suback":delete this.outgoing[n];for(var l=0;l<e.granted.length;l++)if(0!=(128&e.granted[l])){var u=this.messageIdToTopic[n];u&&u.forEach((function(e){delete s._resubscribeTopics[e]}))}i(null,e);break;case"unsuback":delete this.outgoing[n],i(null);break;default:s.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else Xd("_handleAck :: Server sent an ack in error. Ignoring.")},af.prototype._handlePubrel=function(e,t){Xd("handling pubrel packet"),t=void 0!==t?t:sf;var n=e.messageId,r=this,o={cmd:"pubcomp",messageId:n};r.incomingStore.get(e,(function(e,n){e?r._sendPacket(o,t):(r.emit("message",n.topic,n.payload,n),r.handleMessage(n,(function(e){if(e)return t(e);r.incomingStore.del(n,sf),r._sendPacket(o,t)})))}))},af.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},af.prototype._nextId=function(){var e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},af.prototype.getLastMessageId=function(){return 1===this.nextId?65535:this.nextId-1},af.prototype._resubscribe=function(e){Xd("_resubscribe");var t=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!e.sessionPresent)&&t.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){Xd("_resubscribe: protocolVersion 5");for(var n=0;n<t.length;n++){var r={};r[t[n]]=this._resubscribeTopics[t[n]],r.resubscribe=!0,this.subscribe(r,{properties:r[t[n]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},af.prototype._onConnect=function(e){if(this.disconnected)this.emit("connect",e);else{var t=this;this._setupPingTimer(),this._resubscribe(e),this.connected=!0,function n(){var r=t.outgoingStore.createStream();function o(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function i(){r.destroy(),r=null,o()}t.once("close",i),r.on("error",(function(e){o(),t.removeListener("close",i),t.emit("error",e)})),r.on("end",(function(){var r=!0;for(var s in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[s]){r=!1;break}r?(o(),t.removeListener("close",i),t.emit("connect",e)):n()})),function e(){if(r){t._storeProcessing=!0;var n,o=r.read(1);o?t._packetIdsDuringStoreProcessing[o.messageId]?e():t.disconnecting||t.reconnectTimer?r.destroy&&r.destroy():(n=t.outgoing[o.messageId]?t.outgoing[o.messageId].cb:null,t.outgoing[o.messageId]={volatile:!1,cb:function(t,r){n&&n(t,r),e()}},t._packetIdsDuringStoreProcessing[o.messageId]=!0,t._sendPacket(o)):r.once("readable",e)}}()}()}};var cf=af,lf=si,uf=dt.exports("mqttjs:tcp");var pf=function(e,t){var n,r;return t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost",n=t.port,r=t.hostname,uf("port %d and host %s",n,r),lf.createConnection(n,r)},df=si,ff=dt.exports("mqttjs:tls");var hf=function(e,t){var n;function r(r){t.rejectUnauthorized&&e.emit("error",r),n.end()}return t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",t.servername=t.host,t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,ff("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized),(n=df.connect(t)).on("secureConnect",(function(){t.rejectUnauthorized&&!n.authorized?n.emit("error",new Error("TLS not authorized")):n.removeListener("error",r)})),n.on("error",r),n},mf={exports:{}},gf=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),o=e[e.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach((function(e){r[e]=o[e]})),r}};var yf=gf;function bf(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function vf(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}mf.exports=yf(bf),mf.exports.strict=yf(vf),bf.proto=bf((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return bf(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return vf(this)},configurable:!0})}));var wf=mf.exports,_f=function(){},Cf=function(e,t,n){if("function"==typeof t)return Cf(e,null,t);t||(t={}),n=wf(n||_f);var r=e._writableState,o=e._readableState,i=t.readable||!1!==t.readable&&e.readable,s=t.writable||!1!==t.writable&&e.writable,a=!1,c=function(){e.writable||l()},l=function(){s=!1,i||n.call(e)},u=function(){i=!1,s||n.call(e)},p=function(t){n.call(e,t?new Error("exited with error code: "+t):null)},d=function(t){n.call(e,t)},f=function(){process.nextTick(h)},h=function(){if(!a)return(!i||o&&o.ended&&!o.destroyed)&&(!s||r&&r.ended&&!r.destroyed)?void 0:n.call(e,new Error("premature close"))},m=function(){e.req.on("finish",l)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(e)?s&&!r&&(e.on("end",c),e.on("close",c)):(e.on("complete",l),e.on("abort",f),e.req?m():e.on("request",m)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",p),e.on("end",u),e.on("finish",l),!1!==t.error&&e.on("error",d),e.on("close",f),function(){a=!0,e.removeListener("complete",l),e.removeListener("abort",f),e.removeListener("request",m),e.req&&e.req.removeListener("finish",l),e.removeListener("end",c),e.removeListener("close",c),e.removeListener("finish",l),e.removeListener("exit",p),e.removeListener("end",u),e.removeListener("error",d),e.removeListener("close",f)}},Sf=function(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(function(e){if(e.buffer.length)return e.buffer.head?e.buffer.head.data.length:e.buffer[0].length;return e.length}(t)):null};var kf=ts.exports,Ef=Cf,Rf=ws.exports,If=Sf,Af=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]),Of=function(e,t){e._corked?e.once("uncork",t):t()},xf=function(e,t){return function(n){n?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===n.message?null:n):t&&!e._ended&&e.end()}},Tf=function(){},Pf=function(e,t,n){if(!(this instanceof Pf))return new Pf(e,t,n);kf.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)};Rf(Pf,kf.Duplex),Pf.obj=function(e,t,n){return n||(n={}),n.objectMode=!0,n.highWaterMark=16,new Pf(e,t,n)},Pf.prototype.cork=function(){1==++this._corked&&this.emit("cork")},Pf.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},Pf.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,n=Ef(e,{writable:!0,readable:!1},xf(this,this._forwardEnd)),r=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&process.nextTick(r),this._writable=e,this._writable.on("drain",r),this._unwrite=function(){t._writable.removeListener("drain",r),n()},this.uncork()}else this.end()},Pf.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,n=this,r=Ef(e,{writable:!1,readable:!0},xf(this)),o=function(){n._forward()},i=function(){n.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(t=e,new kf.Readable({objectMode:!0,highWaterMark:16}).wrap(t)),this._readable2.on("readable",o),this._readable2.on("end",i),this._unread=function(){n._readable2.removeListener("readable",o),n._readable2.removeListener("end",i),r()},this._forward()}},Pf.prototype._read=function(){this._drained=!0,this._forward()},Pf.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=If(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},Pf.prototype.destroy=function(e,t){if(t||(t=Tf),this.destroyed)return t(null);this.destroyed=!0;var n=this;process.nextTick((function(){n._destroy(e),t(null)}))},Pf.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")},Pf.prototype._write=function(e,t,n){if(!this.destroyed)return this._corked?Of(this,this._write.bind(this,e,t,n)):e===Af?this._finish(n):this._writable?void(!1===this._writable.write(e)?this._ondrain=n:this.destroyed||n()):n()},Pf.prototype._finish=function(e){var t=this;this.emit("preend"),Of(this,(function(){!function(e,t){e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),t()):t()}(t._forwardEnd&&t._writable,(function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),Of(t,e)}))}))},Pf.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(Af),kf.Writable.prototype.end.call(this,n))};var Bf,Mf,Ff,Nf=Pf,jf=ts.exports.Transform,Uf=Nf;var Lf,Df,qf,$f=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);var r=function(e,t){var n="wxs"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}(t,e);Bf=wx.connectSocket({url:r,protocols:[n]}),Mf=function(){var e=new jf;return e._write=function(e,t,n){Bf.send({data:e.buffer,success:function(){n()},fail:function(e){n(new Error(e))}})},e._flush=function(e){Bf.close({success:function(){e()}})},e}(),(Ff=Uf.obj())._destroy=function(e,t){Bf.close({success:function(){t&&t(e)}})};var o=Ff.destroy;return Ff.destroy=function(){Ff.destroy=o;var e=this;setTimeout((function(){Bf.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(Ff),Bf.onOpen((function(){Ff.setReadable(Mf),Ff.setWritable(Mf),Ff.emit("connect")})),Bf.onMessage((function(e){var t=e.data;t=t instanceof ArrayBuffer?Buffer.from(t):Buffer.from(t,"utf8"),Mf.push(t)})),Bf.onClose((function(){Ff.end(),Ff.destroy()})),Bf.onError((function(e){Ff.destroy(new Error(e.errMsg))})),Ff},Hf=ts.exports.Transform,Wf=Nf,Vf=!1;var Kf=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");var n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);var r=function(e,t){var n="alis"===e.protocol?"wss":"ws",r=n+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(r=n+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}(t,e);return(Lf=t.my).connectSocket({url:r,protocols:n}),Df=function(){var e=new Hf;return e._write=function(e,t,n){Lf.sendSocketMessage({data:e.buffer,success:function(){n()},fail:function(){n(new Error)}})},e._flush=function(e){Lf.closeSocket({success:function(){e()}})},e}(),qf=Wf.obj(),Vf||(Vf=!0,Lf.onSocketOpen((function(){qf.setReadable(Df),qf.setWritable(Df),qf.emit("connect")})),Lf.onSocketMessage((function(e){if("string"==typeof e.data){var t=Buffer.from(e.data,"base64");Df.push(t)}else{var n=new FileReader;n.addEventListener("load",(function(){var e=n.result;e=e instanceof ArrayBuffer?Buffer.from(e):Buffer.from(e,"utf8"),Df.push(e)})),n.readAsArrayBuffer(e.data)}})),Lf.onSocketClose((function(){qf.end(),qf.destroy()})),Lf.onSocketError((function(e){qf.destroy(e)}))),qf},zf={exports:{}};const Jf=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")},Qf=dt.exports("mqttjs:ws"),Xf=Nf,Yf=ts.exports.Transform;let Gf=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];const Zf="undefined"!=typeof process&&"browser"===process.title||"function"==typeof __webpack_require__;function eh(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 th(e){let t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),Zf||"wss"!==e.protocol||Gf.forEach((function(n){e.hasOwnProperty(n)&&!e.wsOptions.hasOwnProperty(n)&&(t.wsOptions[n]=e[n])})),t}zf.exports=Zf?function(e,t){let n;Qf("browserStreamBuilder");let r=function(e){let t=th(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}(t);const o=r.browserBufferSize||524288,i=t.browserBufferTimeout||1e3,s=!t.objectMode;let a=function(e,t){const n="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";let r=eh(t,e),o=new WebSocket(r,[n]);return o.binaryType="arraybuffer",o}(e,t),c=function(e,t,n){let r=new Yf({objectModeMode:e.objectMode});return r._write=t,r._flush=n,r}(t,(function e(t,n,r){a.bufferedAmount>o&&setTimeout(e,i,t,n,r),s&&"string"==typeof t&&(t=Buffer.from(t,"utf8"));try{a.send(t)}catch(e){return r(e)}r()}),(function(e){a.close(),e()}));t.objectMode||(c._writev=h),c.on("close",(()=>{a.close()}));const l=void 0!==a.addEventListener;function u(){n.setReadable(c),n.setWritable(c),n.emit("connect")}function p(){n.end(),n.destroy()}function d(e){n.destroy(e)}function f(e){let t=e.data;t=t instanceof ArrayBuffer?Buffer.from(t):Buffer.from(t,"utf8"),c.push(t)}function h(e,t){const n=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?n[t]=Buffer.from(e[t],"utf8"):n[t]=e[t].chunk;this._write(Buffer.concat(n),"binary",t)}return a.readyState===a.OPEN?n=c:(n=n=Xf(void 0,void 0,t),t.objectMode||(n._writev=h),l?a.addEventListener("open",u):a.onopen=u),n.socket=a,l?(a.addEventListener("close",p),a.addEventListener("error",d),a.addEventListener("message",f)):(a.onclose=p,a.onerror=d,a.onmessage=f),n}:function(e,t){Qf("streamBuilder");let n=th(t);const r=eh(n,e);let o=function(e,t,n){Qf("createWebSocket"),Qf("protocol: "+n.protocolId+" "+n.protocolVersion);const r="MQIsdp"===n.protocolId&&3===n.protocolVersion?"mqttv3.1":"mqtt";return Qf("creating new Websocket for url: "+t+" and protocol: "+r),new Jf(t,[r],n.wsOptions)}(0,r,n),i=Jf.createWebSocketStream(o,n.wsOptions);return i.url=r,o.on("close",(()=>{i.destroy()})),i};var nh=cf,rh=tl,oh=c.default,ih=Zi,sh=dt.exports("mqttjs"),ah={};function ch(e,t){if(sh("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){var n=oh.parse(e,!0);if(null!=n.port&&(n.port=Number(n.port)),null===(t=ih(n,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(function(e){var t;e.auth&&((t=e.auth.match(/^(.+):(.+)$/))?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(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(!ah[t.protocol]){var r=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(e,t){return(!r||t%2!=0)&&"function"==typeof ah[e]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);var o=new nh((function(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++),sh("calling streambuilder for",t.protocol),ah[t.protocol](e,t)}),t);return o.on("error",(function(){})),o}"undefined"!=typeof process&&"browser"!==process.title||"function"!=typeof __webpack_require__?(ah.mqtt=pf,ah.tcp=pf,ah.ssl=hf,ah.tls=hf,ah.mqtts=hf):(ah.wx=$f,ah.wxs=$f,ah.ali=Kf,ah.alis=Kf),ah.ws=zf.exports,ah.wss=zf.exports,Gi.exports=ch,Gi.exports.connect=ch,Gi.exports.MqttClient=nh,Gi.exports.Store=rh;var lh=Gi.exports;const uh=e=>{let t;return{connect:async function(n){return t=lh.connect(e,function(e){return Object.assign({keepalive:30,protocolId:"MQTT",protocolVersion:4,clean:!0,reconnectPeriod:1e3,connectTimeout:3e4,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1},rejectUnauthorized:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`},e)}({username:n.userId,password:n.accessToken})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(this.connected)return new Promise((e=>t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,n){t.on(e,n)},once(e,n){t.on(e,n)},off(e,n){void 0!==n?t.off(e,n):t.removeAllListeners(e)},removeAllListeners(){t.removeAllListeners()},subscribe(e,n){t.subscribe(e,{qos:0},n)},unsubscribe(e,n){t.unsubscribe(e,n)}}};const ph=["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"],dh=["connect","message","disconnect","error","close","end","reconnect"],fh=()=>{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},hh=(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)}},mh=(e,t)=>{const{emitter:n}=m();setTimeout((()=>{n.emit(e,t)}),0)},gh=()=>{const e=(()=>{var e,t;return(null===(e=null===process||void 0===process?void 0:process.versions)||void 0===e?void 0:e.node)?process.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}},yh=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],bh=e=>{const t=m(),n=yh.map((n=>hh(t,`client/onConnectionError(${n})`,n,(t=>{const r=t&&"code"in t?new u(t.message,t.code,"fatal"):new f(n);e(r)}))));return()=>{n.forEach((e=>e()))}},vh=e=>bh((({code:t})=>{400312===t&&e()})),wh=(e={})=>{const t=e;return{read:()=>t,write:e=>{Object.assign(t,e)},erase:(...e)=>{e.length||(e=Object.keys(t)),e.forEach((e=>delete t[e]))}}},_h=(...e)=>e.reduce(((e,t)=>{const n=wh();return Object.assign(Object.assign({},e),{[t]:n})}),{});const Ch=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:Sh}=Object.prototype,{propertyIsEnumerable:kh}=Object,Eh=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),Rh=ge,Ih={concatArrays:!1,ignoreUndefined:!1},Ah=e=>{const t=[];for(const n in e)Sh.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)kh.call(e,r)&&t.push(r)}return t};function Oh(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return Ah(e).forEach((n=>{Eh(t,n,Oh(e[n]))})),t}(e):Ch(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return Ah(e).forEach((n=>{Eh(t,n,Oh(e[n]))})),t}(e):e}const xh=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?Eh(e,n,Th(e[n],t[n],r)):Eh(e,n,Oh(t[n])))})),e);function Th(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++)Sh.call(t,n)&&(i.push(String(n)),Eh(r,o++,t===e?t[n]:Oh(t[n])));r=xh(r,t,Ah(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):Ch(t)&&Ch(e)?xh(e,t,Ah(t),n):Oh(t)}const Ph=function(...e){const t=Th(Oh(Ih),this!==Rh&&this||{},Ih);let n={_:{}};for(const r of e)if(void 0!==r){if(!Ch(r))throw new TypeError("`"+r+"` is not an Option Object");n=Th(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0}),Bh=(e,t)=>new Promise(((n,r)=>{try{const r=e();t&&t(null,r),n(r)}catch(e){t&&t(e),r(e)}})),Mh=(e,t,n)=>Promise.all(e).then((e=>{const r=n?n(e):null;return t&&t(null,r),Promise.resolve(r)}),(e=>(t&&t(e),Promise.reject(e))));class Fh{static getItem(e,t){return Bh((()=>window.localStorage.getItem(e)),t)}static setItem(e,t,n){return Bh((()=>{window.localStorage.setItem(e,t)}),n)}static removeItem(e,t){return Bh((()=>window.localStorage.removeItem(e)),t)}static mergeItem(e,t,n){return Bh((()=>{((e,t)=>{const n=window.localStorage.getItem(e),r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(Ph(r,o));window.localStorage.setItem(e,i)})(e,t)}),n)}static clear(e){return Bh((()=>{window.localStorage.clear()}),e)}static getAllKeys(e){return Bh((()=>{const e=window.localStorage.length,t=[];for(let n=0;n<e;n+=1){const e=window.localStorage.key(n);t.push(e)}return t}),e)}static flushGetRequests(){}static multiGet(e,t){const n=e.map((e=>Fh.getItem(e)));return Mh(n,t,(t=>t.map(((t,n)=>[e[n],t]))))}static multiSet(e,t){const n=e.map((e=>Fh.setItem(e[0],e[1])));return Mh(n,t)}static multiRemove(e,t){const n=e.map((e=>Fh.removeItem(e)));return Mh(n,t)}static multiMerge(e,t){const n=e.map((e=>Fh.mergeItem(e[0],e[1])));return Mh(n,t)}}const Nh=e=>e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.localId]:t})),{}),jh=(e,t=Date.now(),n=w)=>{Object.fromEntries(Object.entries(e).map((([e,r])=>[e,Uh(r,t,n[e])])))},Uh=(e,t=Date.now(),n)=>{e.forEach((e=>Lh(e,t,n)))},Lh=(e,t=Date.now(),n=k(e))=>{var r,o;null!==(r=e.syncedAt)&&void 0!==r||(e.syncedAt=t);const{cache:i}=m();if(n){const t=v(n)(e);e.localId=null!==(o=null==i?void 0:i.lookup[`${n}#${t}`])&&void 0!==o?o:pt()}},Dh=(e,t,n)=>void 0!==n?e.filter((e=>e[t]===n)):e,qh=({channelSegment:e},{channelSegment:t})=>e-t,$h=({segmentNumber:e},{segmentNumber:t})=>e-t,Hh=async e=>{const t=m();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${e}`);jh(n),R(n);const{users:r}=n;return r.find((t=>t.userId===e))};Hh.locally=e=>{var t;m().log("user/getUser.locally",e);const[n]=null!==(t=y("user",e))&&void 0!==t?t:[];return n};const Wh=async e=>{const t=m();t.log("user/getUsers",e);const{data:n}=await t.http.get("/api/v3/users/list",{params:{userIds:e}});jh(n),R(n);const{users:r}=n;return Nh(r)};
6
+ var r=e("buffer"),o=r.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}function s(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(i(r,n),n.Buffer=s),s.prototype=Object.create(o.prototype),i(o,s),s.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},s.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},{buffer:14}],54:[function(e,t,n){function r(e){var t=e._readableState;return t?t.objectMode||"number"==typeof e._duplexState?e.read():e.read(o(t)):null}function o(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}t.exports=r},{}],55:[function(e,t,n){var r=e("safe-buffer").Buffer,o=r.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function s(e){var t=i(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}function a(e){var t;switch(this.encoding=s(e),this.encoding){case"utf16le":this.text=d,this.end=m,t=4;break;case"utf8":this.fillLast=h,t=4;break;case"base64":this.text=g,this.end=y,t=3;break;default:return this.write=b,void(this.end=v)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function c(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function u(e,t,n){var r=t.length-1;if(r<n)return 0;var o=c(t[r]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=c(t[r]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}function l(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}function h(e){var t=this.lastTotal-this.lastNeed,n=l(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function p(e,t){var n=u(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)}function f(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function d(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function m(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function g(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function y(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function b(e){return e.toString(this.encoding)}function v(e){return e&&e.length?this.write(e):""}n.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},a.prototype.end=f,a.prototype.text=p,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":53}],56:[function(e,t,n){var r=e("punycode"),o=e("./util");function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}n.parse=w,n.resolve=C,n.resolveObject=S,n.format=_,n.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(u),h=["%","/","?",";","#"].concat(l),p=["/","?","#"],f=255,d=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=e("querystring");function w(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}function _(e){return o.isString(e)&&(e=w(e)),e instanceof i?e.format():i.prototype.format.call(e)}function C(e,t){return w(e,!1,!0).resolve(t)}function S(e,t){return e?w(e,!1,!0).resolveObject(t):t}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),a=-1!==i&&i<e.indexOf("#")?"?":"#",u=e.split(a),w=/\\/g;u[0]=u[0].replace(w,"/");var _=e=u.join(a);if(_=_.trim(),!n&&1===e.split("#").length){var C=c.exec(_);if(C)return this.path=_,this.href=_,this.pathname=C[1],C[2]?(this.search=C[2],this.query=t?v.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var S=s.exec(_);if(S){var k=(S=S[0]).toLowerCase();this.protocol=k,_=_.substr(S.length)}if(n||S||_.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===_.substr(0,2);!E||S&&y[S]||(_=_.substr(2),this.slashes=!0)}if(!y[S]&&(E||S&&!b[S])){for(var A,I,x=-1,O=0;O<p.length;O++)-1!==(R=_.indexOf(p[O]))&&(-1===x||R<x)&&(x=R);for(-1!==(I=-1===x?_.lastIndexOf("@"):_.lastIndexOf("@",x))&&(A=_.slice(0,I),_=_.slice(I+1),this.auth=decodeURIComponent(A)),x=-1,O=0;O<h.length;O++){var R;-1!==(R=_.indexOf(h[O]))&&(-1===x||R<x)&&(x=R)}-1===x&&(x=_.length),this.host=_.slice(0,x),_=_.slice(x),this.parseHost(),this.hostname=this.hostname||"";var T="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!T)for(var F=this.hostname.split(/\./),P=(O=0,F.length);O<P;O++){var j=F[O];if(j&&!j.match(d)){for(var B="",M=0,N=j.length;M<N;M++)j.charCodeAt(M)>127?B+="x":B+=j[M];if(!B.match(d)){var U=F.slice(0,O),L=F.slice(O+1),D=j.match(m);D&&(U.push(D[1]),L.unshift(D[2])),L.length&&(_="/"+L.join(".")+_),this.hostname=U.join(".");break}}}this.hostname.length>f?this.hostname="":this.hostname=this.hostname.toLowerCase(),T||(this.hostname=r.toASCII(this.hostname));var q=this.port?":"+this.port:"",$=this.hostname||"";this.host=$+q,this.href+=this.host,T&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==_[0]&&(_="/"+_))}if(!g[k])for(O=0,P=l.length;O<P;O++){var H=l[O];if(-1!==_.indexOf(H)){var W=encodeURIComponent(H);W===H&&(W=escape(H)),_=_.split(H).join(W)}}var z=_.indexOf("#");-1!==z&&(this.hash=_.substr(z),_=_.slice(0,z));var V=_.indexOf("?");if(-1!==V?(this.search=_.substr(V),this.query=_.substr(V+1),t&&(this.query=v.parse(this.query)),_=_.slice(0,V)):t&&(this.search="",this.query={}),_&&(this.pathname=_),b[k]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var K=this.search||"";this.path=q+K}return this.href=this.format(),this},i.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,s="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=v.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||b[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+r},i.prototype.resolve=function(e){return this.resolveObject(w(e,!1,!0)).format()},i.prototype.resolveObject=function(e){if(o.isString(e)){var t=new i;t.parse(e,!1,!0),e=t}for(var n=new i,r=Object.keys(this),s=0;s<r.length;s++){var a=r[s];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),u=0;u<c.length;u++){var l=c[u];"protocol"!==l&&(n[l]=e[l])}return b[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!b[e.protocol]){for(var h=Object.keys(e),p=0;p<h.length;p++){var f=h[p];n[f]=e[f]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||y[e.protocol])n.pathname=e.pathname;else{for(var d=(e.pathname||"").split("/");d.length&&!(e.host=d.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),n.pathname=d.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var m=n.pathname||"",g=n.search||"";n.path=m+g}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var v=n.pathname&&"/"===n.pathname.charAt(0),w=e.host||e.pathname&&"/"===e.pathname.charAt(0),_=w||v||n.host&&e.pathname,C=_,S=n.pathname&&n.pathname.split("/")||[],k=(d=e.pathname&&e.pathname.split("/")||[],n.protocol&&!b[n.protocol]);if(k&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===d[0]?d[0]=e.host:d.unshift(e.host)),e.host=null),_=_&&(""===d[0]||""===S[0])),w)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,S=d;else if(d.length)S||(S=[]),S.pop(),S=S.concat(d),n.search=e.search,n.query=e.query;else if(!o.isNullOrUndefined(e.search))return k&&(n.hostname=n.host=S.shift(),(O=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=O.shift(),n.host=n.hostname=O.shift())),n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!S.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var E=S.slice(-1)[0],A=(n.host||e.host||S.length>1)&&("."===E||".."===E)||""===E,I=0,x=S.length;x>=0;x--)"."===(E=S[x])?S.splice(x,1):".."===E?(S.splice(x,1),I++):I&&(S.splice(x,1),I--);if(!_&&!C)for(;I--;I)S.unshift("..");!_||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),A&&"/"!==S.join("/").substr(-1)&&S.push("");var O,R=""===S[0]||S[0]&&"/"===S[0].charAt(0);return k&&(n.hostname=n.host=R?"":S.length?S.shift():"",(O=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=O.shift(),n.host=n.hostname=O.shift())),(_=_||n.host&&S.length)&&!R&&S.unshift(""),S.length?n.pathname=S.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":57,punycode:33,querystring:36}],57:[function(e,t,n){t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],58:[function(e,t,n){(function(e){(function(){function n(e,t){if(r("noDeprecation"))return e;var n=!1;function o(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return o}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this)}).call(this,void 0!==J?J:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],59:[function(e,t,n){function r(e,t){if(e&&t)return r(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach((function(t){n[t]=e[t]})),n;function n(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach((function(e){r[e]=o[e]})),r}}t.exports=r},{}],60:[function(e,t,n){t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],61:[function(e,t,n){t.exports=o;var r=Object.prototype.hasOwnProperty;function o(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var o in n)r.call(n,o)&&(e[o]=n[o])}return e}},{}]},{},[9])(9);var Uo=No.exports;var Lo;!function(e){e[e.IDENTIFIER_REJECTED=2]="IDENTIFIER_REJECTED",e[e.BAD_USERNAME_OR_PASSWORD=4]="BAD_USERNAME_OR_PASSWORD",e[e.NOT_AUTHORIZED=5]="NOT_AUTHORIZED"}(Lo||(Lo={}));const Do=e=>{let t,n=0,r=!0;const o=()=>{setTimeout((()=>{n+=1,t.reconnect()}),1e3*Math.pow(2,n>10?10:n))};return{connect:async function(i){return t&&(t.removeAllListeners(),t.end(!0)),t=Uo.connect(e,function(e){return Object.assign({clean:!1,clientId:`mqttjs_ + ${Math.random().toString(16).substr(2,8)}`,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:0,will:{topic:"WillMsg",payload:"Connection Closed abnormally..!",qos:0,retain:!1}},e)}({username:i.userId,password:i.accessToken})),t.on("connect",(()=>{n=0,r=!0})),t.on("error",(e=>{switch(e.code){case 2:case 4:case 5:r=!1}})),t.on("close",(()=>{r&&o()})),new Promise((e=>t.once("connect",(()=>e()))))},async disconnect(){if(r=!1,this.connected)return new Promise((e=>null==t?void 0:t.end(!0,void 0,(()=>e()))))},get connected(){return!!(null==t?void 0:t.connected)},on(e,n){null==t||t.on(e,n)},once(e,n){null==t||t.once(e,n)},off(e,n){void 0!==n?null==t||t.off(e,n):null==t||t.removeAllListeners(e)},removeAllListeners(){null==t||t.removeAllListeners()},subscribe(e,n){const r=(t,r)=>{if(t||128===r[0].qos){const r=t?new q(t.message,8e5,"error"):new H(8e5,"error");console.error(`Failed to subscribe to topic ${e}`,r),null==n||n(r)}else console.log(`Subscribed to topic ${r[0].topic}`),null==n||n()};return t?t.subscribe(e,{qos:0},r):r(new Error("No connection to broker"),[]),()=>null==t?void 0:t.unsubscribe(e)},unsubscribe(e){null==t||t.unsubscribe(e)}}};const qo=["disconnected","error","connect_error","reconnect_error","reconnect_failed","v3.channel.didUpdate","v3.channel.didUpdate","v3.channel.didJoin","v3.channel.didLeave","v3.channel.didAddUsers","v3.channel.didRemoveUsers","v3.channel.didBan","v3.channel.didUnban","v3.message.didCreate","v3.message.didUpdate","v3.message.didDelete"],$o=["connect","message","disconnect","error","close","end","reconnect"],Ho=()=>{return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}};var e},Wo=(e,t,n,r)=>{const{log:o,emitter:i}=e,s=Date.now();o(`${t}(tmpid: ${s}) > listen`);const a=(...e)=>{o(`${t}(tmpid: ${s}) > trigger`,e),r(...e)};return i.on(n,a),()=>{o(`${t}(tmpid: ${s}) > dispose`),i.off(n,a)}},zo=(e,t)=>{const{emitter:n}=V();setTimeout((()=>{n.emit(e,t)}),0)},Vo=async()=>{const e=V();return e.log("client/api/disconnectClient"),await new Promise((t=>{e.ws.once("disconnect",t),e.ws.disconnect(),e.mqtt.disconnect()})),e.emitter.all.clear(),e.ws.removeAllListeners(),e.mqtt.removeAllListeners(),e.userId=void 0,e.user=void 0,e.accessToken=void 0,!e.ws.connected},Ko=()=>{const e=(()=>{var e,t;return(null===(e=null===process||void 0===process?void 0:process.versions)||void 0===e?void 0:e.node)?process.versions.node:navigator?`${navigator.product.toLowerCase()}#${null!==(t=navigator.userAgent)&&void 0!==t?t:"unknown_agent"}`:"unknown_model"})();return{version:"11.0.0",kind:"web",model:e}},Jo=["disconnected","error","connect_error","reconnect_error","reconnect_failed"],Qo=e=>{const t=V(),n=Jo.map((n=>Wo(t,`client/onConnectionError(${n})`,n,(t=>{const r=t&&"code"in t?new q(t.message,t.code,"fatal"):new W(n);e(r)}))));return()=>{n.forEach((e=>e()))}},Yo=e=>Qo((({code:t})=>{400312===t&&e()}));var Xo;e.SubscriptionLevels=void 0,(Xo=e.SubscriptionLevels||(e.SubscriptionLevels={})).COMMUNITY="community",Xo.POST="post",Xo.COMMENT="comment",Xo.POST_AND_COMMENT="post_and_comment",Xo.USER="user";const Go=({path:e},t)=>{switch(t){case"post":return`${e}/post/+`;case"comment":return`${e}/post/+/comment/+`;case"post_and_comment":return`${e}/post/#`;default:return e}};let Zo,ei;const ti=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},{hasOwnProperty:ni}=Object.prototype,{propertyIsEnumerable:ri}=Object,oi=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),ii=J,si={concatArrays:!1,ignoreUndefined:!1},ai=e=>{const t=[];for(const n in e)ni.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)ri.call(e,r)&&t.push(r)}return t};function ci(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return ai(e).forEach((n=>{oi(t,n,ci(e[n]))})),t}(e):ti(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return ai(e).forEach((n=>{oi(t,n,ci(e[n]))})),t}(e):e}const ui=(e,t,n,r)=>(n.forEach((n=>{void 0===t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?oi(e,n,li(e[n],t[n],r)):oi(e,n,ci(t[n])))})),e);function li(e,t,n){return n.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,n)=>{let r=e.slice(0,0),o=0;return[e,t].forEach((t=>{const i=[];for(let n=0;n<t.length;n++)ni.call(t,n)&&(i.push(String(n)),oi(r,o++,t===e?t[n]:ci(t[n])));r=ui(r,t,ai(t).filter((e=>!i.includes(e))),n)})),r})(e,t,n):ti(t)&&ti(e)?ui(e,t,ai(t),n):ci(t)}const hi=function(...e){const t=li(ci(si),this!==ii&&this||{},si);let n={_:{}};for(const r of e)if(void 0!==r){if(!ti(r))throw new TypeError("`"+r+"` is not an Option Object");n=li(n,{_:r},t)}return n._}.bind({concatArrays:!0,ignoreUndefined:!0}),pi=(e,t)=>new Promise(((n,r)=>{try{const r=e();t&&t(null,r),n(r)}catch(e){t&&t(e),r(e)}})),fi=(e,t,n)=>Promise.all(e).then((e=>{const r=n?n(e):null;return t&&t(null,r),Promise.resolve(r)}),(e=>(t&&t(e),Promise.reject(e))));class di{static getItem(e,t){return pi((()=>window.localStorage.getItem(e)),t)}static setItem(e,t,n){return pi((()=>{window.localStorage.setItem(e,t)}),n)}static removeItem(e,t){return pi((()=>window.localStorage.removeItem(e)),t)}static mergeItem(e,t,n){return pi((()=>{((e,t)=>{const n=window.localStorage.getItem(e),r=JSON.parse(n),o=JSON.parse(t),i=JSON.stringify(hi(r,o));window.localStorage.setItem(e,i)})(e,t)}),n)}static clear(e){return pi((()=>{window.localStorage.clear()}),e)}static getAllKeys(e){return pi((()=>{const e=window.localStorage.length,t=[];for(let n=0;n<e;n+=1){const e=window.localStorage.key(n);t.push(e)}return t}),e)}static flushGetRequests(){}static multiGet(e,t){const n=e.map((e=>di.getItem(e)));return fi(n,t,(t=>t.map(((t,n)=>[e[n],t]))))}static multiSet(e,t){const n=e.map((e=>di.setItem(e[0],e[1])));return fi(n,t)}static multiRemove(e,t){const n=e.map((e=>di.removeItem(e)));return fi(n,t)}static multiMerge(e,t){const n=e.map((e=>di.mergeItem(e[0],e[1])));return fi(n,t)}}const mi=e=>JSON.stringify(e,((e,t)=>{return"object"==typeof t?(n=t,Object.keys(n).sort().reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:n[t]})),{})):t;var n})),gi=e=>JSON.parse(e),yi=(e,t)=>e===t||!(!e||!t)&&("object"==typeof e&&Object.keys(e).every((n=>yi(e[n],t[n])))),bi=e=>{const{log:t,cache:n}=V();if(n)return t("cache/api/queryCache",{key:e}),Object.keys(n.data).filter((t=>{const n=gi(t);return yi(e,n)})).map((e=>n.data[e]))},vi=e=>{const{log:t,cache:n}=V();if(!n)return;t("cache/api/pullFromCache",e);const r=mi(e);return n.data[r]?n.data[r]:void 0},wi=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=V();if(!o)return!1;r("cache/api/pushToCache",{key:e,data:t,options:n}),!(null==n?void 0:n.hasOwnProperty("offline"))&&o.persistIf&&(n.offline=o.persistIf(e,t));const i=mi(e);return o.data[i]=Object.assign({key:e,data:t},n),!0},_i=(e,t,n)=>{const{log:r,cache:o}=V();if(!o)return!1;r("cache/api/mergeInCache",{key:e,mutation:t});const i=vi(e);if(!i)return!1;const s="function"==typeof t?t(i.data):Object.assign(Object.assign({},i.data),t);return wi(e,s,n),!0},Ci=(e,t,n={cachedAt:Date.now()})=>{const{log:r,cache:o}=V();if(!o)return!1;r("cache/api/upsertInCache",{key:e,data:t,options:n});return vi(e)?_i(e,t,n):wi(e,t,n)},Si=(e,t=!1)=>{const{log:n,cache:r}=V();if(!r)return!1;if(n("cache/api/dropFromCache",{key:e,exact:t}),!t)return Object.keys(r.data).map((e=>gi(e))).filter((t=>yi(e,t))).map((e=>Si(e,!0))).every((e=>e));const o=mi(e);return o in r.data&&(delete r.data[o],!0)},ki={user:({userId:e})=>e,file:({fileId:e})=>e,role:({roleId:e})=>e,channel:({channelId:e})=>e,channelUsers:({channelId:e,userId:t})=>`${e}#${t}`,message:({messageId:e})=>e,community:({communityId:e})=>e,communityUsers:({communityId:e,userId:t})=>`${e}#${t}`,post:({postId:e})=>e,comment:({commentId:e})=>e,stream:({streamId:e})=>e},Ei=e=>ki[e],Ai={users:"user",files:"file",roles:"role",channels:"channel",channelUsers:"channelUsers",messages:"message",communities:"community",communityUsers:"communityUsers",posts:"post",postChildren:"post",comments:"comment",videoStreamings:"stream"},Ii=(e={},t)=>{Object.entries(e).forEach((([e,n])=>{const r=Ai[e];if(!r)return;const o=Ei(r);n.forEach((e=>{Ci([r,"get",o(e)],e,t)}))}))},xi=async e=>{const t=V();t.log("user/getUser",e);const{data:n}=await t.http.get(`/api/v3/users/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{users:o}=n;return{data:o.find((t=>t.userId===e)),cachedAt:r}};xi.locally=e=>{const t=V();return t.log("user/getUser.locally",e),t.cache&&vi(["user","get",e])};const Oi=async e=>{const t=V();t.log("user/getUsers",e);const{data:n}=await t.http.get("/api/v3/users/list",{params:{userIds:e}}),r=t.cache&&Date.now();return t.cache&&Ii(n,{cachedAt:r}),{data:n.users,cachedAt:r}};
5
7
  /*! *****************************************************************************
6
8
  Copyright (c) Microsoft Corporation.
7
9
 
@@ -16,4 +18,4 @@ var Amity=function(e,t,n,r){"use strict";function o(e){return e&&"object"==typeo
16
18
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
19
  PERFORMANCE OF THIS SOFTWARE.
18
20
  ***************************************************************************** */
19
- function Vh(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}Wh.locally=e=>{var t;const n=null!==(t=y("user",...e))&&void 0!==t?t:[];if((null==n?void 0:n.length)===e.length)return Nh(n)};const Kh=async e=>{const t=m();t.log("user/queryUsers",e);const n=null!=e?e:{},{page:r,displayName:o,filter:i="all",sortBy:s="displayName"}=n,a=Vh(n,["page","displayName","filter","sortBy"]),{data:c}=await t.http.get("/api/v3/users",{params:Object.assign(Object.assign({},a),{keyword:o,filter:i,sortBy:s,options:{token:te(r,"skiplimit")}})}),{paging:l}=c,u=Vh(c,["paging"]);jh(u),R(u);const p=ne(l.previous),d=ne(l.next),{users:f}=u;return{data:Nh(f),prevPage:p,nextPage:d}};Kh.locally=e=>{m().log("user/queryUsers.locally",e)};const zh=(e,t)=>{const n=m();return hh(n,e,e,(e=>{jh(e),R(e),t(e.users[0])}))},Jh=e=>zh("user.updated",e),Qh=e=>zh("user.flagged",e),Xh=e=>zh("user.unflagged",e),Yh=e=>zh("user.flagCleared",e),Gh=async e=>{const t=m();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`);return Lh(n),R({files:[n]}),n};Gh.locally=e=>{var t;m().log("file/getFile.locally",e);const[n]=null!==(t=y("file",e))&&void 0!==t?t:[];return n};const Zh=async e=>{const t=m();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r,displayName:o,sortBy:i}=n,s=Vh(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:te(r,"skiplimit")}})}),{paging:c}=a,l=Vh(a,["paging"]);jh(l),R(l);const u=ne(c.previous),p=ne(c.next),{roles:d}=l;return{data:Nh(d),prevPage:u,nextPage:p}};Zh.locally=e=>{m().log("role/queryRoles.locally",e)};const em=async e=>{const t=m();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`);return Uh(n),R({roles:n}),n.find((t=>t.roleId===e))};em.locally=e=>{var t;m().log("role/getRole.locally",e);const[n]=null!==(t=y("role",e))&&void 0!==t?t:[];return n};const tm=(e,t)=>{"message"===e?mh("v3.message.didUpdate",{messages:[t]}):"post"===e?mh("post.updated",{posts:[t]}):"comment"===e&&mh("comment.updated",{comments:[t]})},nm=async e=>{const t=m();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${e}`);jh(n),R(n);const{messages:r}=n;return r.find((t=>t.messageId===e))};nm.locally=e=>{var t;m().log("message/getMessage.locally",e);const[n]=null!==(t=y("message",e))&&void 0!==t?t:[];return n};const rm=async e=>{const t=m();t.log("message/getMessages",e);const{data:n}=await t.http.get("/api/v3/messages/list",{params:{messageIds:e}});jh(n),R(n);const{messages:r}=n;return Nh(r)};rm.locally=e=>{var t;m().log("message/getMessages.locally",e);const n=null!==(t=y("message",...e))&&void 0!==t?t:[];if((null==n?void 0:n.length)===e.length)return Nh(n)};const om=async e=>{const t=m();t.log("message/queryMessages",e);const n=null!=e?e:{},{page:r}=n,o=Vh(n,["page"]),{data:i}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},o),{options:{token:te(r,"afterbefore")}})}),{paging:s}=i,a=Vh(i,["paging"]);jh(a),R(a);const{messages:c}=a,l=ne(s.next),u=ne(s.previous);return{data:Nh(c),nextPage:l,prevPage:u}};om.locally=e=>{var t,n,r,o,i;m().log("message/queryMessages.locally",e);const{channelId:s,page:a}=e,[c]=null!==(t=y("channel",s))&&void 0!==t?t:[];let l=null!==(n=y("message"))&&void 0!==n?n:[];if(l=Dh(l,"channelId",s),l=l.sort(qh),a){let e,t=0;"after"in a?(t=0!==a.after?l.findIndex((e=>e.channelSegment===(null==a?void 0:a.after)))+1:0,e=t+a.limit):"before"in a&&(e=0!==a.before?l.findIndex((e=>e.channelSegment===(null==a?void 0:a.before)))+1:l.length-1,t=e>a.limit?e-a.limit:0);const n=l.slice(t,e);l=n.length===a.limit?n:[]}const u=(null===(r=l[0])||void 0===r?void 0:r.channelSegment)>0?{before:l[0].channelSegment,limit:null==a?void 0:a.limit}:void 0,p=(null===(o=l[l.length-1])||void 0===o?void 0:o.channelSegment)<(null!==(i=null==c?void 0:c.messageCount)&&void 0!==i?i:0)?{after:l[l.length-1].channelSegment,limit:null==a?void 0:a.limit}:void 0;return{data:Nh(l),nextPage:p,prevPage:u}};const im=async e=>{const t=m();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e);jh(n),R(n);const{messages:r}=n;return r[0]};im.optimistically=e=>{var t,n,r;const o=m();if(o.log("user/createMessage.locally",e),!o.cache)return;const[i]=null!==(t=y("channel",e.channelId))&&void 0!==t?t:[];_("channel",Object.assign(Object.assign({},i),{messageCount:(null!==(n=i.messageCount)&&void 0!==n?n:0)+1}));const s=Object.assign(Object.assign({localId:pt(),messageId:Math.random().toString(16),userId:o.userId,channelSegment:(null!==(r=null==i?void 0:i.messageCount)&&void 0!==r?r:0)+1,createdAt:(new Date).toISOString()},e),{syncedAt:-1});return _("message",s),mh("v3.message.didCreate",{messages:[s]}),s};const sm=async(e,t)=>{const n=m();n.log("user/updateMessage",t);const{data:r}=await n.http.put(`/api/v3/messages/${e}`,t);return jh(r),R(r),r.messages.find((t=>t.messageId===e))};sm.optimistically=(e,t)=>{var n;m().log("user/updateMessage",t);const[r]=null!==(n=y("message",e))&&void 0!==n?n:[];if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r),t),{updatedAt:(new Date).toISOString()});return _("message",o),mh("v3.message.didUpdate",{messages:[o]}),o};const am=async e=>{const t=m();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${e}`);return await nm(e)};am.optimistically=e=>{var t;m().log("message/deleteMessage",e);const[n]=null!==(t=y("message",e))&&void 0!==t?t:[];if(!n)return;const r=Object.assign(Object.assign({},n),{isDeleted:!0,updatedAt:(new Date).toISOString()});return _("message",r),mh("v3.message.didDelete",{messages:[r]}),r};const cm=async e=>{const t=m();t.log("post/queryPosts",e);const n=null!=e?e:{},{page:r}=n,o=Vh(n,["page"]),{data:i}=await t.http.get("/api/v3/posts",{params:Object.assign(Object.assign({},o),{options:{token:te(r,"skiplimit")}})}),{paging:s}=i,a=Vh(i,["paging"]);jh(a),R(a);const{posts:c}=a,l=ne(s.next),u=ne(s.previous);return{data:Nh(c),nextPage:l,prevPage:u}};cm.locally=e=>{m().log("post/queryPosts.locally",e)};const lm=async e=>{const t=m();t.log("post/getPosts",e);const{data:n}=await t.http.get("/api/v3/posts/list",{params:{postIds:e}});jh(n),R(n);const{posts:r}=n;return r};lm.locally=e=>{var t;m().log("post/getPosts.locally",e);const n=null!==(t=y("post",...e))&&void 0!==t?t:[];if((null==n?void 0:n.length)===e.length)return Nh(n)};const um=async e=>{var t;const n=m();let r;n.log("post/getPost",e);try{r=(await n.http.get(`/api/v3/posts/${e}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&C("post",{postId:e}),n}jh(r),R(r);const{posts:o}=r;return o.find((t=>t.postId===e))};um.locally=e=>{var t;m().log("post/getPost.locally",e);const[n]=null!==(t=y("post",e))&&void 0!==t?t:[];return n};const pm=async e=>{const t=m();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=Vh(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:te(r,"skiplimit")}})}),{paging:c}=a,l=Vh(a,["paging"]);jh(l),R(l);const u=ne(null==c?void 0:c.previous),p=ne(null==c?void 0:c.next),{communities:d}=l;return{data:Nh(d),prevPage:u,nextPage:p}};pm.locally=e=>{m().log("community/queryCommunities.locally",e)};const dm=async e=>{const t=m();t.log("community/getCommunities",e);const{data:n}=await t.http.get("/api/v3/communities/list",{params:{communityIds:e}});jh(n),R(n);const{communities:r}=n;return Nh(r)};dm.locally=e=>{var t;m().log("community/getCommunities.locally",e);const n=null!==(t=y("community",...e))&&void 0!==t?t:[];if((null==n?void 0:n.length)===e.length)return Nh(n)};const fm=async e=>{const t=m();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`);jh(n),R(n);const{communities:r}=n;return r.find((t=>t.communityId===e))};fm.locally=e=>{var t;m().log("community/getCommunity.locally",e);const[n]=null!==(t=y("community",e))&&void 0!==t?t:[];return n};const hm=async e=>{const t=m();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=Vh(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:te(r,"skiplimit")}})}),{paging:a}=s,c=Vh(s,["paging"]);jh(c),R(c);const{communityUsers:l}=c,u=ne(a.next),p=ne(a.previous);return{data:Nh(l),nextPage:u,prevPage:p}};hm.locally=e=>{m().log("community/queryCommunityMembers",e)};const mm=async e=>{const t=m();t.log("comment/queryComments",e);const{page:n}=e,r=Vh(e,["page"]);e.parentId;const{data:o}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:{token:te(n,"afterbefore")}})}),{paging:i}=o,s=Vh(o,["paging"]);jh(s),R(s);const a=ne(i.previous),c=ne(i.next),{comments:l}=s;return{data:Nh(l),prevPage:a,nextPage:c}};mm.locally=e=>{var t;m().log("post/queryComments.locally",e);const{referenceId:n,referenceType:r,parentId:o,isDeleted:i,page:s={before:0,limit:5}}=e;isNaN(s.after)&&isNaN(s.before)&&(s.before=0),isNaN(s.limit)&&(s.limit=5);let a=null!==(t=y("comment"))&&void 0!==t?t:[];if(!a.length)return;if(a=Dh(a,"referenceId",n),a=Dh(a,"referenceType",r),a=Dh(a,"parentId",o),a=Dh(a,"isDeleted",i),!a.length)return;a=a.sort($h);const c=isNaN(s.after)?0:a.findIndex((({segmentNumber:e})=>e===s.after+1)),l=isNaN(s.before)||0===s.before?a.length:a.findIndex((({segmentNumber:e})=>e===s.before-1))+1;if(c<0||l<0)return;let u=a.slice(-1!==c?c:0,-1!==l?l:void 0);if(!u.length)return;(isNaN(s.after)||isNaN(s.before))&&(isNaN(s.after)?isNaN(s.before)||(u=u.slice(-s.limit)):u=u.slice(0,s.limit));for(let e=0;e<u.length-1;e++)if(u[e].segmentNumber!==u[e+1].segmentNumber-1)return;const p=u[0].segmentNumber>1?{before:u[0].segmentNumber,limit:s.limit}:void 0,d={after:u[u.length-1].segmentNumber,limit:s.limit};return{data:Nh(u),nextPage:d,prevPage:p}};const gm=async e=>{const t=m();t.log("comment/getComments",e);const{data:n}=await t.http.get("/api/v3/comments/list",{params:{commentIds:e}});jh(n),R(n);const{comments:r}=n;return Nh(r)};gm.locally=e=>{var t;m().log("comment/getComments.locally",e);const n=null!==(t=y("comment",...e))&&void 0!==t?t:[];if((null==n?void 0:n.length)===e.length)return Nh(n)};const ym=async e=>{var t;const n=m();let r;n.log("comment/getComment",e);try{r=(await n.http.get(`/api/v3/comments/${e}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&C("comment",{commentId:e}),n}jh(r),R(r);const{comments:o}=r;return o.find((t=>t.commentId===e))};ym.locally=e=>{var t;m().log("comment/getComment.locally",e);const[n]=null!==(t=y("comment",e))&&void 0!==t?t:[];return n};const bm=async(e,t)=>{if("message"===e)return nm(t);if("post"===e)return um(t);if("comment"===e)return ym(t);throw new Error(`Incorrect referenceType: ${e}`)},vm=async(e,t,n)=>{var r,o;const i=m();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 bm(e,t);return tm(e,s),null!==(o=null===(r=s.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};vm.optimistically=(e,t,n)=>{var r,o;const i=I(e,t,(e=>{var t,r,o;if(!(null===(t=e.myReactions)||void 0===t?void 0:t.includes(n)))return Object.assign(Object.assign({},e),{syncedAt:-1,reactionsCount:e.reactionsCount+1,myReactions:[...null!==(r=e.myReactions)&&void 0!==r?r:[],n],reactions:Object.assign(Object.assign({},e.reactions),{[n]:(null!==(o=e.reactions[n])&&void 0!==o?o:0)+1})})}));return i&&tm(e,i),null!==(o=null===(r=null==i?void 0:i.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};const wm=async(e,t,n)=>{var r,o;const i=m();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 bm(e,t);return tm(e,s),null!==(o=!(null===(r=s.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};wm.optimistically=(e,t,n)=>{var r,o;const i=I(e,t,(e=>{var t,r,o;if(null===(t=e.myReactions)||void 0===t?void 0:t.includes(n))return Object.assign(Object.assign({},e),{syncedAt:-1,reactionsCount:Math.max(0,e.reactionsCount-1),myReactions:(null!==(r=e.myReactions)&&void 0!==r?r:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},e.reactions),{[n]:Math.max(0,(null!==(o=e.reactions[n])&&void 0!==o?o:0)-1)})})}));return i&&tm(e,i),null!==(o=!(null===(r=null==i?void 0:i.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};var _m={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 Cm=async e=>{const t=m();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=Vh(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:te(r,"skiplimit")}})}),{paging:c}=a,l=Vh(a,["paging"]);jh(l),R(l);const u=ne(null==c?void 0:c.previous),p=ne(null==c?void 0:c.next),{channels:d}=l;return{data:Nh(d),prevPage:u,nextPage:p}};Cm.locally=e=>{m().log("channel/queryChannels.locally",e)};const Sm=async e=>{const t=m();t.log("channel/getChannels",e);const{data:n}=await t.http.get("/api/v3/channels/list",{params:{channelIds:e}});jh(n),R(n);const{channels:r}=n;return Nh(r)};Sm.locally=e=>{var t;m().log("channel/getChannels.locally",e);const n=null!==(t=y("channel",...e))&&void 0!==t?t:[];if((null==n?void 0:n.length)===e.length)return Nh(n)};const km=async e=>{const t=m();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${e}`);jh(n),R(n);const{channels:r}=n;return r.find((t=>t.channelId===e))};km.locally=e=>{var t;m().log("channel/getChannel.locally",e);const[n]=null!==(t=y("channel",e))&&void 0!==t?t:[];return n};const Em=async e=>{const t=m();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o,membership:i}=n,s=Vh(n,["page","channelId","membership"]),{data:a}=await t.http.get(`/api/v3/channels/${o}/users`,{params:Object.assign(Object.assign({},s),{filter:i,options:{token:te(r,"skiplimit")}})}),{paging:c}=a,l=Vh(a,["paging"]);jh(l),R(l);const{channelUsers:u}=l,p=ne(c.next),d=ne(c.previous);return{data:Nh(u),nextPage:p,prevPage:d}};Em.locally=e=>{m().log("channel/queryChannelMembers",e)};const Rm=e=>{const t=m();return hh(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{jh(t),R(t),e(t.channels[0])}))},Im=e=>{const t=m();return hh(t,"onChannelDeleted","v3.channel.didDelete",(t=>{jh(t),R(t),e(t.channels[0])}))},Am=e=>{const t=m();return hh(t,"onChannelJoined","v3.channel.didJoin",(t=>{jh(t),R(t),e(t.channels[0])}))},Om=e=>{const t=m();return hh(t,"onChannelLeft","v3.channel.didLeave",(t=>{jh(t),R(t),e(t.channels[0])}))},xm=e=>{const t=m();return hh(t,"onMemberAdded","v3.channel.didAddUsers",(t=>{jh(t),R(t),e(t.channels[0])}))},Tm=e=>{const t=m();return hh(t,"onMemberRemoved","v3.channel.didRemoveUsers",(t=>{jh(t),R(t),e(t.channels[0])}))},Pm=e=>{const t=m();return hh(t,"message/onMessageCreated","v3.message.didCreate",(t=>{jh(t),R(t),e(t.messages[0])}))},Bm=e=>{const t=m();return hh(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{jh(t),R(t),e(t.messages[0])}))},Mm=e=>{const t=m();return hh(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{jh(t),R(t),e(t.messages[0])}))},Fm=(e,t)=>{const n=m();return hh(n,e,e,(e=>{jh(e),R(e),t(e.communities[0])}))},Nm=e=>Fm("community.updated",e),jm=e=>Fm("community.deleted",e),Um=e=>Fm("community.joined",e),Lm=e=>Fm("community.left",e),Dm=e=>Fm("community.userAdded",e),qm=e=>Fm("community.userRemoved",e),$m=e=>Fm("community.userUnbanned",e),Hm=e=>Fm("community.userUnbanned",e),Wm={all_and_children:"#",children_only:"+"},Vm=({path:e},t)=>`${e}/${t?Wm[t]:""}`;function Km(e){const t=m();return t.mqtt.subscribe(e,((t,n)=>{t?console.error(`Can not subscribe to ${e}`,t):console.log("Subscribe granted",n)})),()=>t.mqtt.unsubscribe(e)}const zm=(e,t)=>{const n=m();return hh(n,e,e,(e=>{jh(e),R(e),t(e.posts[0])}))},Jm=e=>zm("post.created",e),Qm=e=>zm("post.updated",e),Xm=e=>zm("post.afterDeleted",e),Ym=e=>zm("post.approved",e),Gm=e=>zm("post.declined",e),Zm=e=>zm("post.flagged",e),eg=e=>zm("post.unflagged",e),tg=e=>zm("post.addReaction",e),ng=e=>zm("post.removeReaction",e),rg=(e,t)=>{const n=m();return hh(n,e,e,(e=>{jh(e),R(e),t(e.comments[0])}))},og=e=>rg("comment.created",e),ig=e=>rg("comment.updated",e),sg=e=>rg("comment.deleted",e),ag=e=>rg("comment.flagged",e),cg=e=>rg("comment.unflagged",e),lg=e=>rg("comment.addReaction",e),ug=e=>rg("comment.removeReaction",e),pg=async e=>{const t=m();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`);jh(n),R(n);const{videoStreamings:r}=n;return r.find((t=>t.streamId===e))};pg.locally=e=>{var t;m().log("stream/getStream",e);const[n]=null!==(t=y("stream",e))&&void 0!==t?t:[];return n};const dg=async e=>{const t=m();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=Vh(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:te(r,"skiplimit")}})}),{paging:s,results:a}=i;jh(a),R(a);const c=ne(null==s?void 0:s.previous),l=ne(null==s?void 0:s.next),{videoStreamings:u}=a;return{data:Nh(u),prevPage:c,nextPage:l}};dg.locally=e=>{m().log("stream/queryStreams.locally",e)};return e.VERSION=l,e.addChannelMembers=async(e,t)=>{const n=m();n.log("channel/addChannelMembers",e,t);const{data:r}=await n.http.post(`/api/v3/channels/${e}/users`,{channelId:e,userIds:t});jh(r),R(r),mh("v3.channel.didAddUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=m();r.log("channel/addChannelMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/channels/${e}/users/roles`,{channelId:e,role:t,userIds:n});jh(o),R(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=m();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});jh(r),R(r),mh("community.userAdded",{communities:r.communities});const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRole=async(e,t,n)=>{const r=m();r.log("community/addCommunityMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/communities/${e}/users/roles`,{communityId:e,role:t,userIds:n});jh(o),R(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&n.roles.includes(t)))},e.addReaction=vm,e.clearCache=(e=["user","file","channel","message","community","post","comment"])=>{const t=m();t.log("client/api/enableCache"),e.forEach((e=>{var n,r;return null===(r=null===(n=t.cache)||void 0===n?void 0:n[e])||void 0===r?void 0:r.erase()}))},e.connectClient=async e=>{var t,n;const r=m();r.log("client/api/connectClient",Object.assign({apiKey:r.apiKey},e)),null!==(t=e.displayName)&&void 0!==t||(e.displayName=e.userId),null!==(n=e.deviceId)&&void 0!==n||(e.deviceId=`ascWebSdk#${Math.random().toString(16)}`);const{accessToken:o}=await(async e=>{const t=m();t.log("client/api/getToken",e);const n=await gh(),{data:r}=await t.http.post("/v1/device",Object.assign(Object.assign({},e),{deviceInfo:n}),{headers:{"X-API-Key":t.apiKey}});return r})(e);var i,s;r.http.defaults.headers.common.Authorization=`Bearer ${o}`,r.ws.io.opts.query={token:o},((e,t)=>{ph.forEach((n=>{e.on(n,(e=>t.emit(n,e)))}))})(r.ws,r.emitter),await r.mqtt.connect({accessToken:o,userId:e.userId}),i=r.mqtt,s=r.emitter,dh.forEach((e=>{i.on(e,((...t)=>s.emit(e,1===t.length?t[0]:t)))})),i.on("message",((e,t)=>{const n=JSON.parse(t.toString());s.emit(n.eventType,n.data)})),await new Promise((e=>{r.ws.once("connect",e),r.ws.open()}));const a=vh((()=>{r.mqtt.disconnect(),a()}));return r.userId=e.userId,r.ws.connected},e.createCache=O,e.createChannel=async e=>{const t=m();t.log("user/createChannel",e);const{data:n}=await t.http.post("/api/v3/channels",e);jh(n),R(n);const{channels:r}=n;return r[0]},e.createClient=(e,t=St,n="amity")=>{const r=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&"production"!==process.env.NODE_ENV,n=Ct(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(n);r("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiEndpoint:t});const o=(e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Vn.create({baseURL:e,httpAgent:new Qn(t),httpsAgent:new zn(t),paramsSerializer:Yn});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&&Xn(n.data)})),n})(Et(kt.HTTP,t)),i=(e=>{const t=Yi(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(Et(kt.HTTP,t)),s=uh(Et(kt.MQTT,t)),a=fh(),c={version:`${l}`,apiKey:e,log:r,http:o,ws:i,mqtt:s,emitter:a,use:()=>g(c)};try{m()}catch(e){g(c)}return c},e.createComment=async e=>{const t=m();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e);jh(n),R(n);const r=await um(e.referenceId);mh("post.updated",{posts:[r]}),mh("comment.created",n);const{comments:o}=n;return o[0]},e.createCommunity=async e=>{const t=m();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e);jh(n),R(n),mh("community.created",n);const{communities:r}=n;return r[0]},e.createFile=async(e,t)=>{const n=m();if(n.log("file/createFile",e),!e.getAll("file").length)throw new Error("The formData object must have a `file` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v3/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}});return Uh(o),R({files:o}),o[0]},e.createMessage=im,e.createPost=async e=>{const t=m();t.log("post/createPost",e),e.dataType&&!["text","image","file"].includes(e.dataType)||delete e.dataType;const{data:n}=await t.http.post("/api/v3/posts",e);jh(n),R(n),mh("community.updated",{communities:n.communities}),mh("post.created",n);const{posts:r}=n;return r[0]},e.createQuery=ue,e.createReport=async(e,t)=>{const n=m();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=_m[e],{data:o}=await n.http.post(`/api/v3/${r}/${t}/flag`),i="message"===e?"v3.message.didUpdate":`${e}.updated`;return jh(o),R(o),mh(i,o),!!o},e.createStream=async e=>{const t=m();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e);jh(n),R(n);const{videoStreamings:r}=n;return r[0]},e.decorateModel=Lh,e.decorateModels=Uh,e.decoratePayload=jh,e.deleteChannel=async e=>{const t=m();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${e}`);return await km(e)},e.deleteComment=async(e,t=!1)=>{const n=m();n.log("comment/deleteComment",e);const r=await ym(e);await n.http.delete(`/api/v4/comments/${e}`,{params:{commentId:e,permanent:t}});const o=Object.assign(Object.assign({},r),{isDeleted:!0}),i=await um(r.referenceId);return mh("post.updated",{posts:[i]}),mh("comment.deleted",{comments:[o]}),t?setTimeout((()=>{C("comment",{commentId:e})}),0):A("comment",{commentId:e,isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=m();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await fm(e);return mh("community.deleted",{communities:[n]}),n},e.deleteFile=async e=>{const t=m();t.log("file/deleteFile",e);const{data:n}=await t.http.delete(`/api/v3/files/${e}`);return C("file",{fileId:n.fileId}),{success:!0}},e.deleteMessage=am,e.deletePost=async(e,t=!1)=>{const n=m();n.log("post/deletePost",e);let r=await um(e);if(await n.http.delete(`/api/v4/posts/${e}`,{params:{postId:e,permanent:t}}),"community"===r.targetType){const e=await fm(r.targetId);mh("community.updated",{communities:[e]})}const o=Object.assign(Object.assign({},r),{isDeleted:!0});return mh("post.afterDeleted",{posts:[o]}),t?setTimeout((()=>{C("post",{postId:e})}),0):A("post",{postId:e,isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=m();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=_m[e],{data:o}=await n.http.delete(`/api/v3/${r}/${t}/unflag`),i="message"===e?"v3.message.didUpdate":`${e}.updated`;return jh(o),R(o),mh(i,o),!!o},e.deleteStream=async e=>{const t=m();t.log("stream/deleteStream",e);const{data:n}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:r}=n;return r},e.disconnectClient=async()=>{const e=m();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.ws.connected},e.disposeStream=async e=>{const t=m();t.log("stream/disposeStream",e);const{data:n}=await t.http.delete(`/api/v3/video-streaming/${e}/streaming-url`);jh(n),R(n);const{videoStreamings:r}=n;return r.find((t=>t.streamId===e))},e.dropFromCache=C,e.enableCache=(e=_h("user","file","channel","message","community","post","comment","communityUsers","channelUsers","stream"))=>{const t=m();t.log("client/api/enableCache"),t.cache=O(e)},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=Dh,e.getActiveClient=m,e.getChannel=km,e.getChannels=Sm,e.getComment=ym,e.getComments=gm,e.getCommunities=dm,e.getCommunity=fm,e.getFile=Gh,e.getMessage=nm,e.getMessages=rm,e.getPost=um,e.getPosts=lm,e.getRole=em,e.getStream=pg,e.getUser=Hh,e.getUsers=Wh,e.ingestInCache=R,e.isAfterBefore=Z,e.isConnected=()=>{var e,t;const n=m();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=re,e.isFresh=ce,e.isLocal=ae,e.isMutator=oe,e.isOffline=ie,e.isPaged=ee,e.isReportedByMe=async(e,t)=>{var n,r;const o=m();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=_m[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(Xn(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=G,e.isSyncable=se,e.isSynced=le,e.joinChannel=async e=>{const t=m();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${e}/join`);jh(n),R(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=m();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`);jh(n),R(n),mh("community.joined",{communities:n.communities});const{communityUsers:r}=n;return!!r.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=m();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${e}/leave`);jh(n),R(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=m();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`);jh(n),R(n),mh("community.left",{communities:n.communities});const{communityUsers:r}=n;return!!r.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.memoryStore=wh,e.memoryStores=_h,e.mergeInCache=A,e.mutateCache=I,e.observeChannel=(e,t)=>{const{log:n}=m(),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(Rm((e=>o({data:e},"onUpdate"))),Im((e=>o({data:e},"onDelete"))),Am((e=>o({data:e},"onJoin"))),Om((e=>o({data:e},"onLeft"))),xm((e=>o({data:e},"onMemberAdded"))),Tm((e=>o({data:e},"onMemberRemoved")))),he(ue(km,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}=m(),o=Date.now();r(`observeComment(tmpid: ${o}) > listen`);const i=(n,r)=>{var o,i,a;if((null===(o=n.data)||void 0===o?void 0:o.commentId)===e){if("onFetch"===r)try{s.push(Km(Vm(n.data)))}catch(e){console.error(e)}if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(a=t[r])||void 0===a||a.call(t,n)}},s=[];return s.push(ig((e=>i({data:e},"onUpdate"))),sg((e=>i({data:e},"onDelete"))),ag((e=>i({data:e},"onFlagged"))),cg((e=>i({data:e},"onUnflagged"))),lg((e=>i({data:e},"onReactionAdded"))),ug((e=>i({data:e},"onReactionRemoved")))),he(ue(ym,e),(e=>e.data&&i(e,"onFetch")),pe(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=m(),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(og((e=>i(e,"onCreate"))),ig((e=>i(e,"onUpdate"))),sg((e=>i(e,"onDelete"))),ag((e=>i(e,"onFlagged"))),cg((e=>i(e,"onUnflagged"))),lg((e=>i(e,"onReactionAdded"))),ug((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=m(),r=Date.now();n(`observeCommunity(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,s,a;if((null===(o=n.data)||void 0===o?void 0:o.communityId)===e){if("onFetch"===r&&i.push(Km(Vm(n.data))),t instanceof Function)return t(n);"onFetch"!==r&&(null===(s=t.onEvent)||void 0===s||s.call(t,r,n)),null===(a=t[r])||void 0===a||a.call(t,n)}},i=[];return i.push(Nm((e=>o({data:e},"onUpdate"))),jm((e=>o({data:e},"onDelete"))),Um((e=>o({data:e},"onJoin"))),Lm((e=>o({data:e},"onLeft"))),Dm((e=>o({data:e},"onUserAdded"))),qm((e=>o({data:e},"onUserRemoved"))),$m((e=>o({data:e},"onUserBanned"))),Hm((e=>o({data:e},"onUserUnbanned")))),he(ue(fm,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeCommunity(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.observeFile=(e,t)=>{const{log:n}=m(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return he(ue(Gh,e),(n=>n.data&&((n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}})(n,"onFetch"))),()=>{n(`observeFile(tmpid: ${r}) > dispose`)}},e.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=m(),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(Bm((e=>i(e,"onUpdate"))),Mm((e=>i(e,"onDelete")))),"no_fetch"!==n&&he(ue(nm,e),(e=>e.data&&i(e,"onFetch")),pe(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=m(),r=Date.now();n(`observeMessages(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i;if(n.channelId===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(Pm((e=>i(e,"onCreate"))),Bm((e=>i(e,"onUpdate"))),Mm((e=>i(e,"onDelete")))),()=>{n(`observeMessages(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observePost=(e,t,n="cache_then_server")=>{const{log:r}=m(),o=Date.now();r(`observePost(tmpid: ${o}) > listen`);const i=(n,r)=>{var o,i,a;if((null===(o=n.data)||void 0===o?void 0:o.postId)===e){if("onFetch"===r)try{s.push(Km(Vm(n.data)))}catch(e){console.error(e)}if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(a=t[r])||void 0===a||a.call(t,n)}},s=[];return s.push(Qm((e=>i({data:e},"onUpdate"))),Xm((e=>i({data:e},"onDelete"))),Ym((e=>i({data:e},"onApproved"))),Gm((e=>i({data:e},"onDeclined"))),Zm((e=>i({data:e},"onFlagged"))),eg((e=>i({data:e},"onUnflagged"))),tg((e=>i({data:e},"onReactionAdded"))),ng((e=>i({data:e},"onReactionRemoved")))),he(ue(um,e),(e=>e.data&&i(e,"onFetch")),pe(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=m(),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(Jm((e=>i(e,"onCreate"))),Qm((e=>i(e,"onUpdate"))),Xm((e=>i(e,"onDelete"))),Ym((e=>i(e,"onApproved"))),Gm((e=>i(e,"onDeclined"))),Zm((e=>i(e,"onFlagged"))),eg((e=>i(e,"onUnflagged"))),tg((e=>i(e,"onReactionAdded"))),ng((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=m(),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(Jh((e=>o({data:e},"onUpdate"))),Qh((e=>o({data:e},"onFlagged"))),Xh((e=>o({data:e},"onUnflagged"))),Yh((e=>o({data:e},"onFlagCleared")))),he(ue(Hh,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=Im,e.onChannelJoined=Am,e.onChannelLeft=Om,e.onChannelUpdated=Rm,e.onClientBanned=vh,e.onClientDisconnected=e=>bh((({code:t})=>{800211===t&&e()})),e.onCommentCreated=og,e.onCommentDeleted=sg,e.onCommentFlagged=ag,e.onCommentReactionAdded=lg,e.onCommentReactionRemoved=ug,e.onCommentUnflagged=cg,e.onCommentUpdated=ig,e.onCommunityCreated=e=>Fm("community.created",e),e.onCommunityDeleted=jm,e.onCommunityJoined=Um,e.onCommunityLeft=Lm,e.onCommunityUpdated=Nm,e.onCommunityUserAdded=Dm,e.onCommunityUserBanned=$m,e.onCommunityUserRemoved=qm,e.onCommunityUserUnbanned=Hm,e.onConnectionError=bh,e.onMemberAdded=xm,e.onMemberRemoved=Tm,e.onMessageCreated=Pm,e.onMessageDeleted=Mm,e.onMessageUpdated=Bm,e.onPostApproved=Ym,e.onPostCreated=Jm,e.onPostDeclined=Gm,e.onPostDeleted=Xm,e.onPostFlagged=Zm,e.onPostReactionAdded=tg,e.onPostReactionRemoved=ng,e.onPostUnflagged=eg,e.onPostUpdated=Qm,e.onReactionRemoved=(e,t,n)=>{const r=m();return hh(r,"reaction/onReactionRemoved","v3.message.didUpdate",(e=>{jh(e),R(e)}))},e.onUserFlagCleared=Yh,e.onUserFlagged=Qh,e.onUserUnflagged=Xh,e.onUserUpdated=Jh,e.persistentStore=async(e,t={},n=250)=>{let r=t;const o=await Fh.getItem(e);if(o)try{r=JSON.parse(o)}catch(e){}const i=wh(r);let s=null;const a=()=>{s?s.then((()=>a())):(clearTimeout(undefined),setTimeout((async()=>{s=Promise.resolve().then((()=>Fh.setItem(e,JSON.stringify(i.read())))).then((()=>s=null))}),n))};return{read:i.read,write:e=>{i.write(e),a()},erase:(...e)=>{i.erase(...e),a()}}},e.pullFromCache=y,e.pushToCache=_,e.queryChannelMembers=Em,e.queryChannels=Cm,e.queryComments=mm,e.queryCommunities=pm,e.queryCommunityMembers=hm,e.queryGlobalFeed=async e=>{const t=m();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{page:r}=n,o=Vh(n,["page"]),{data:i}=await t.http.get("/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},o),{options:{token:te(r,"skiplimit")}})}),{paging:s}=i,a=Vh(i,["paging"]);jh(a),R(a);const{posts:c}=a,l=ne(s.next),u=ne(s.previous);return{data:Nh(c),nextPage:l,prevPage:u}},e.queryMessages=om,e.queryOptions=pe,e.queryPosts=cm,e.queryRoles=Zh,e.queryStreams=dg,e.queryUsers=Kh,e.removeChannelMembers=async(e,t)=>{const n=m();n.log("channel/removeChannelMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/channels/${e}/users`,{data:{channelId:e,userIds:t}});jh(r),R(r),mh("v3.channel.didRemoveUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=m();r.log("channel/removeChannelMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/channels/${e}/users/roles`,{data:{channelId:e,role:t,userIds:n}});jh(o),R(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=m();n.log("community/removeCommunityMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/communities/${e}/users`,{data:{communityId:e,userIds:t}});jh(r),R(r),mh("community.userRemoved",{communities:r.communities});const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRole=async(e,t,n)=>{const r=m();r.log("community/removeCommunityMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/communities/${e}/users/roles`,{data:{communityId:e,role:t,userIds:n}});jh(o),R(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!n.roles.includes(t)))},e.removeReaction=wm,e.runQuery=he,e.sliceByPaging=(e,t,n)=>{if(console.log("slice by paging",n),!n)return t.slice();let r,o=0;n.after?(o=n.after,r=o+n.limit):n.before&&(r=n.before+1,o=r>n.limit?r-n.limit:0);const i=t.slice(o,r);return i.length===n.limit?i:void 0},e.sortByChannelSegment=qh,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=$h,e.syncInCache=E,e.toPage=ne,e.toToken=te,e.updateChannel=async(e,t)=>{const n=m();n.log("channel/updateChannel",e,t);const{data:r}=await n.http.put(`/api/v3/channels/${e}`,t);jh(r),R(r);const{channels:o}=r;return o.find((t=>t.channelId===e))},e.updateComment=async(e,t)=>{const n=m();n.log("user/updateComment",t);const{data:r}=await n.http.put(`/api/v3/comments/${e}`,t);jh(r),R(r),mh("comment.updated",r);const{comments:o}=r;return o.find((t=>t.commentId===e))},e.updateCommunity=async(e,t)=>{const n=m();n.log("community/updateCommunity",e,t);const{data:r}=await n.http.put(`/api/v3/communities/${e}`,t);jh(r),R(r),mh("community.updated",r);const{communities:o}=r;return o.find((t=>t.communityId===e))},e.updateMessage=sm,e.updatePost=async(e,t)=>{const n=m();n.log("user/updatePost",t);const{data:r}=await n.http.put(`/api/v3/posts/${e}`,t);jh(r),R(r),mh("post.updated",r);const{posts:o}=r;return o.find((t=>t.postId===e))},e.updateStream=async(e,t)=>{const n=m();n.log("stream/updateStream",e,t);const{data:r}=await n.http.put(`/api/v3/video-streaming/${e}`,t);jh(r),R(r);const{videoStreamings:o}=r;return o.find((t=>t.streamId===e))},e.updateUser=async(e,t)=>{const n=m();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}));return jh(r),R(r),r.users.find((t=>t.userId===e))},Object.defineProperty(e,"__esModule",{value:!0}),e}({},require$$0$1,require$$2,require$$2$1);
21
+ function Ri(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}Oi.locally=e=>{var t;const n=V();if(n.log("user/getUsers.locally",e),!n.cache)return;const r=e.map((e=>vi(["user","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Ti=async(e={})=>{const t=V();t.log("user/queryUsers",e);const{page:n,displayName:r,filter:o="all",sortBy:i="displayName"}=e,s=Ri(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:O(n,"skiplimit")}})}),{paging:c}=a,u=Ri(a,["paging"]),{users:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});wi(["user","query",e],{users:l.map(Ei("user")),paging:c})}return{data:l,cachedAt:h,prevPage:R(c.previous),nextPage:R(c.next)}};Ti.locally=(e={})=>{var t,n,r;const o=V();if(o.log("user/queryUsers.locally",e),!o.cache)return;const i=["user","query",e],{data:s,cachedAt:a}=null!==(t=vi(i))&&void 0!==t?t:{},c=null!==(n=null==s?void 0:s.users.map((e=>vi(["user","get",e]))).filter(Boolean).map((({data:e})=>e)))&&void 0!==n?n:[],u=R(null==s?void 0:s.paging.previous),l=R(null==s?void 0:s.paging.next);return c.length>0&&c.length===(null===(r=null==s?void 0:s.users)||void 0===r?void 0:r.length)?{data:c,cachedAt:a,prevPage:u,nextPage:l}:void 0};const Fi=(e,t)=>{const n=V();return Wo(n,e,e,(e=>{n.cache&&Ii(e),t(e.users[0])}))},Pi=e=>Fi("user.updated",e),ji=e=>Fi("user.flagged",e),Bi=e=>Fi("user.unflagged",e),Mi=e=>Fi("user.flagCleared",e),Ni=async e=>{const t=V();t.log("file/getFile",e);const{data:n}=await t.http.get(`/api/v3/files/${e}`),r=t.cache&&Date.now();return t.cache&&Ii({files:[n]},{cachedAt:r}),{data:n,cachedAt:r}};Ni.locally=e=>{const t=V();if(t.log("file/getFile.locally",e),!t.cache)return;const n=vi(["file","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ui=async e=>{const t=V();t.log("role/queryRoles",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,sortBy:i}=n,s=Ri(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:O(r,"skiplimit")}})}),{paging:c}=a,u=Ri(a,["paging"]),{roles:l}=u,h=t.cache&&Date.now();t.cache&&Ii(u,{cachedAt:h});const p=R(c.next);return{data:l,cachedAt:h,prevPage:R(c.previous),nextPage:p}};Ui.locally=e=>{V().log("role/queryRoles.locally",e)};const Li=async e=>{const t=V();t.log("role/getRole",e);const{data:n}=await t.http.get(`/api/v3/roles/${e}`),r=t.cache&&Date.now();return t.cache&&Ii({roles:n},{cachedAt:r}),{data:n.find((t=>t.roleId===e)),cachedAt:r}};Li.locally=e=>{const t=V();if(t.log("role/getRole.locally",e),!t.cache)return;const n=vi(["role","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Di=(e,t)=>{"message"===e?zo("v3.message.didUpdate",{messages:[t]}):"post"===e?zo("post.updated",{posts:[t]}):"comment"===e&&zo("comment.updated",{comments:[t]})},qi=async e=>{const t=V();t.log("message/getMessage",e);const{data:n}=await t.http.get(`/api/v3/messages/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{messages:o}=n;return{data:o.find((t=>t.messageId===e)),cachedAt:r}};qi.locally=e=>{const t=V();if(t.log("message/getMessage.locally",e),!t.cache)return;const n=vi(["message","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const $i=async e=>{const t=V();t.log("message/getMessages",e);const{data:n}=await t.http.get("/api/v3/messages/list",{params:{messageIds:e}}),r=t.cache&&Date.now();return t.cache&&Ii(n,{cachedAt:r}),{data:n.messages,cachedAt:r}};$i.locally=e=>{var t;const n=V();if(n.log("message/getMessages.locally",e),!n.cache)return;const r=e.map((e=>vi(["message","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Hi=async e=>{const t=V();t.log("message/queryMessages",e);const{page:n={limit:10}}=e,r=Ri(e,["page"]),{data:o}=await t.http.get("/api/v3/messages",{params:Object.assign(Object.assign({},r),{options:{token:O(n,"afterbefore")}})}),{paging:i}=o,s=Ri(o,["paging"]),{messages:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["message","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{messages:a.map(Ei("message")),paging:i})}const u=R(i.next);return{data:a,cachedAt:c,prevPage:R(i.previous),nextPage:u}};Hi.locally=e=>{var t,n;const r=V();if(r.log("message/queryMessages.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Ri(e,["page"]),s=["message","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.messages.length))return;const u=a.messages.map((e=>vi(["message","get",e]))).filter(Boolean).map((({data:e})=>e)),l=R(null==a?void 0:a.paging.previous),h=R(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.messages)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const Wi=async e=>{const t=V();t.log("user/createMessage",e);const{data:n}=await t.http.post("/api/v3/messages",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{messages:o}=n;return{data:o[0],cachedAt:r}};Wi.optimistically=e=>{var t,n;const r=V();if(r.log("user/createMessage.locally",e),!r.cache)return;const o=vi(["channel","get",e.channelId]);Ci(["channel","get",e.channelId],Object.assign(Object.assign({},null==o?void 0:o.data),{messageCount:(null!==(t=null==o?void 0:o.data.messageCount)&&void 0!==t?t:0)+1}));const i=Object.assign({messageId:Math.random().toString(16),userId:r.userId,channelSegment:(null!==(n=null==o?void 0:o.data.messageCount)&&void 0!==n?n:0)+1,createdAt:(new Date).toISOString()},e);return wi(["message","get",i.messageId],i,{cachedAt:-1}),zo("v3.message.didCreate",{messages:[i]}),{data:i,cachedAt:-1}};const zi=async(e,t)=>{const n=V();n.log("user/updateMessage",t);const{data:r}=await n.http.put(`/api/v3/messages/${e}`,t),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{messages:i}=r;return{data:i.find((t=>t.messageId===e)),cachedAt:o}};zi.optimistically=(e,t)=>{const n=V();if(n.log("user/updateMessage",t),!n.cache)return;const r=vi(["message","get",e]);if(!r)return;const o=Object.assign(Object.assign(Object.assign({},r.data),t),{updatedAt:(new Date).toISOString()});return Ci(["message","get",e],o,{cachedAt:-1}),zo("v3.message.didUpdate",{messages:[o]}),{data:o,cachedAt:-1}};const Vi=async e=>{const t=V();t.log("message/deleteMessage",e),await t.http.delete(`/api/v3/messages/${e}`);return(await qi(e)).data};Vi.optimistically=e=>{V().log("message/deleteMessage",e);const t=vi(["message","get",e]);if(!t)return;const n=Object.assign(Object.assign({},t.data),{isDeleted:!0,updatedAt:(new Date).toISOString()});return Ci(["message","get",e],n,{cachedAt:-1}),zo("v3.message.didDelete",{messages:[n]}),{data:n,cachedAt:-1}};const Ki=async e=>{const t=V();t.log("post/queryPosts",e);const{page:n={limit:10}}=e,r=Ri(e,["page"]),{data:o}=await t.http.get("/api/v4/posts",{params:Object.assign(Object.assign({},r),{options:{token:O(n,"afterbeforeraw")}})}),{paging:i}=o,s=Ri(o,["paging"]),{posts:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["post","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{posts:a.map(Ei("post")),paging:i})}const u=T(i.next);return{data:a,cachedAt:c,prevPage:T(i.previous),nextPage:u}};Ki.locally=e=>{var t,n;const r=V();if(r.log("post/queryPosts.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Ri(e,["page"]),s=["post","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.posts.length))return;const u=a.posts.map((e=>vi(["post","get",e]))).filter(Boolean).map((({data:e})=>e)),l=T(null==a?void 0:a.paging.previous),h=T(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.posts)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const Ji=async e=>{const t=V();t.log("post/getPosts",e);const{data:n}=await t.http.get("/api/v3/posts/list",{params:{postIds:e}}),r=t.cache&&Date.now();return t.cache&&Ii(n,{cachedAt:r}),{data:n.posts,cachedAt:r}};Ji.locally=e=>{var t;const n=V();if(n.log("post/getPosts.locally",e),!n.cache)return;const r=e.map((e=>vi(["post","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Qi=async e=>{var t;const n=V();let r;n.log("post/getPost",e);try{r=(await n.http.get(`/api/v3/posts/${e}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Si(["post","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}};Qi.locally=e=>{const t=V();if(t.log("post/getPost.locally",e),!t.cache)return;const n=vi(["post","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Yi=async e=>{const t=V();t.log("channel/queryCommunities",e);const n=null!=e?e:{},{page:r,displayName:o,membership:i}=n,s=Ri(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:O(r,"skiplimit")}})}),{paging:c}=a,u=Ri(a,["paging"]),{communities:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});const e=["community","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];wi(e,{communities:l.map(Ei("community")),paging:c})}const p=R(c.next);return{data:l,cachedAt:h,prevPage:R(c.previous),nextPage:p}};Yi.locally=e=>{V().log("community/queryCommunities.locally",e)};const Xi=async e=>{const t=V();t.log("community/getCommunities",e);const{data:n}=await t.http.get("/api/v3/communities/list",{params:{communityIds:e}}),r=t.cache&&Date.now();return t.cache&&Ii(n,{cachedAt:r}),{data:n.communities,cachedAt:r}};Xi.locally=e=>{var t;const n=V();if(n.log("community/getCommunities.locally",e),!n.cache)return;const r=e.map((e=>vi(["community","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Gi=async e=>{const t=V();t.log("community/getCommunity",e);const{data:n}=await t.http.get(`/api/v3/communities/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{communities:o}=n;return{data:o.find((t=>t.communityId===e)),cachedAt:r}};Gi.locally=e=>{const t=V();if(t.log("community/getCommunity.locally",e),!t.cache)return;const n=vi(["community","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Zi=async e=>{const t=V();t.log("community/queryCommunityMembers",e);const n=null!=e?e:{},{page:r,communityId:o}=n,i=Ri(n,["page","communityId"]),{data:s}=await t.http.get(`/api/v3/communities/${o}/users`,{params:Object.assign(Object.assign({},i),{options:{token:O(r,"skiplimit")}})}),{paging:a}=s,c=Ri(s,["paging"]),{communityUsers:u}=c,l=t.cache&&Date.now();t.cache&&Ii(c,{cachedAt:l});return{data:u,nextPage:R(a.next),prevPage:R(a.previous)}};Zi.locally=e=>{V().log("community/queryCommunityMembers",e)};const es=async e=>{const t=V();t.log("comment/queryComments",e);const{page:n={limit:10}}=e,r=Ri(e,["page"]),{data:o}=await t.http.get("/api/v3/comments",{params:Object.assign(Object.assign({},r),{options:{token:O(n,"afterbefore")}})}),{paging:i}=o,s=Ri(o,["paging"]),{comments:a}=s,c=t.cache&&Date.now();if(t.cache){Ii(s,{cachedAt:c});const e=["comment","query",Object.assign(Object.assign({},r),{options:Object.assign({},n)})];wi(e,{comments:a.map(Ei("comment")),paging:i})}const u=R(i.next);return{data:a,cachedAt:c,prevPage:R(i.previous),nextPage:u}};es.locally=e=>{var t,n;const r=V();if(r.log("comment/queryComments.locally",e),!r.cache)return;const{page:o={limit:10}}=e,i=Ri(e,["page"]),s=["comment","query",Object.assign(Object.assign({},i),{options:Object.assign({},o)})],{data:a,cachedAt:c}=null!==(t=vi(s))&&void 0!==t?t:{};if(!(null==a?void 0:a.comments.length))return;const u=a.comments.map((e=>vi(["comment","get",e]))).filter(Boolean).map((({data:e})=>e)),l=R(null==a?void 0:a.paging.previous),h=R(null==a?void 0:a.paging.next);return u.length===(null===(n=null==a?void 0:a.comments)||void 0===n?void 0:n.length)?{data:u,cachedAt:c,prevPage:l,nextPage:h}:void 0};const ts=async e=>{const t=V();t.log("comment/getComments",e);const{data:n}=await t.http.get("/api/v3/comments/list",{params:{commentIds:e}}),r=t.cache&&Date.now();return t.cache&&Ii(n,{cachedAt:r}),{data:n.comments,cachedAt:r}};ts.locally=e=>{var t;const n=V();if(n.log("comment/getComments.locally",e),!n.cache)return;const r=e.map((e=>vi(["comment","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const ns=async e=>{var t;const n=V();let r;n.log("comment/getComment",e);try{r=(await n.http.get(`/api/v3/comments/${e}`)).data}catch(n){throw 400400===(null===(t=n)||void 0===t?void 0:t.code)&&Si(["comment","get",e],!0),n}const o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}};ns.locally=e=>{const t=V();if(t.log("comment/getComment.locally",e),!t.cache)return;const n=vi(["comment","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const rs=async(e,t)=>{if("message"===e)return qi(t);if("post"===e)return Qi(t);if("comment"===e)return ns(t);throw new Error(`Incorrect referenceType: ${e}`)},os=(e,t)=>{var n,r;if(V().userId!==t.reactor.userId)return;let o,i;if("post.addReaction"===e||"post.removeReaction"===e){const e=t.posts[0];i=null===(n=vi(["post","get",e.postId]))||void 0===n?void 0:n.data,o=e}else{const e=t.comments[0];i=null===(r=vi(["comment","get",e.commentId]))||void 0===r?void 0:r.data,o=e}if(i&&i.myReactions)if("post.addReaction"===e||"comment.addReaction"===e){if(i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:[...i.myReactions,t.reactor.reactionName]})}else{if(!i.myReactions.includes(t.reactor.reactionName))return;Object.assign(o,{myReactions:i.myReactions.filter((e=>e!==t.reactor.reactionName))})}},is=async(e,t,n)=>{var r,o;const i=V();i.log("reaction/createReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.post("/api/v2/reactions",{referenceId:t,referenceType:e,reactionName:n});const s=await rs(e,t);return Di(e,s.data),null!==(o=null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n))&&void 0!==o&&o};is.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=V();if(c.log("reaction/createReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const u=vi([e,"get",t]);if(!(null==u?void 0:u.data)||(null===(r=u.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const l=Object.assign(Object.assign({},u.data),{reactionsCount:u.data.reactionsCount+1,myReactions:[...null!==(o=u.data.myReactions)&&void 0!==o?o:[],n],reactions:Object.assign(Object.assign({},u.data.reactions),{[n]:(null!==(i=u.data.reactions[n])&&void 0!==i?i:0)+1})});return Ci([e,"get",t],l,{cachedAt:-1}),Di(e,l),null!==(a=null===(s=null==l?void 0:l.myReactions)||void 0===s?void 0:s.includes(n))&&void 0!==a&&a};const ss=async(e,t,n)=>{var r,o;const i=V();i.log("reaction/removeReaction",{referenceId:t,referenceType:e,reactionName:n}),await i.http.delete("/api/v2/reactions",{data:{referenceId:t,referenceType:e,reactionName:n}});const s=await rs(e,t);return Di(e,s.data),null!==(o=!(null===(r=s.data.myReactions)||void 0===r?void 0:r.includes(n)))&&void 0!==o&&o};ss.optimistically=(e,t,n)=>{var r,o,i,s,a;const c=V();if(c.log("reaction/removeReaction.optimistically",{referenceId:t,referenceType:e,reactionName:n}),!c.cache)return;const u=vi([e,"get",t]);if(!(null==u?void 0:u.data)||!(null===(r=u.data.myReactions)||void 0===r?void 0:r.includes(n)))return;const l=Object.assign(Object.assign({},u.data),{reactionsCount:Math.max(0,u.data.reactionsCount-1),myReactions:(null!==(o=u.data.myReactions)&&void 0!==o?o:[]).filter((e=>e!==n)),reactions:Object.assign(Object.assign({},u.data.reactions),{[n]:Math.max(0,(null!==(i=u.data.reactions[n])&&void 0!==i?i:0)-1)})});return Ci([e,"get",t],l,{cachedAt:-1}),Di(e,l),null!==(a=!(null===(s=null==l?void 0:l.myReactions)||void 0===s?void 0:s.includes(n)))&&void 0!==a&&a};var as={exports:{}};!function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,o="[object Arguments]",i="[object Array]",s="[object Boolean]",a="[object Date]",c="[object Error]",u="[object Function]",l="[object Map]",h="[object Number]",p="[object Object]",f="[object Promise]",d="[object RegExp]",m="[object Set]",g="[object String]",y="[object Symbol]",b="[object WeakMap]",v="[object ArrayBuffer]",w="[object DataView]",_=/^\[object .+?Constructor\]$/,C=/^(?:0|[1-9]\d*)$/,S={};S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S[o]=S[i]=S[v]=S[s]=S[w]=S[a]=S[c]=S[u]=S[l]=S[h]=S[p]=S[d]=S[m]=S[g]=S[b]=!1;var k="object"==typeof J&&J&&J.Object===Object&&J,E="object"==typeof self&&self&&self.Object===Object&&self,A=k||E||Function("return this")(),I=t&&!t.nodeType&&t,x=I&&e&&!e.nodeType&&e,O=x&&x.exports===I&&k.process,R=function(){try{return O&&O.binding("util")}catch(e){}}(),T=R&&R.isTypedArray;function F(e,t){for(var n=-1,r=e?e.length:0;++n<r;)if(t(e[n],n,e))return!0;return!1}function P(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function j(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function B(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var M,N,U,L=Array.prototype,D=Function.prototype,q=Object.prototype,$=A["__core-js_shared__"],H=(M=/[^.]+$/.exec($&&$.keys&&$.keys.IE_PROTO||""))?"Symbol(src)_1."+M:"",W=D.toString,z=q.hasOwnProperty,V=q.toString,K=RegExp("^"+W.call(z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Q=A.Symbol,Y=A.Uint8Array,X=q.propertyIsEnumerable,G=L.splice,Z=(N=Object.keys,U=Object,function(e){return N(U(e))}),ee=Ee(A,"DataView"),te=Ee(A,"Map"),ne=Ee(A,"Promise"),re=Ee(A,"Set"),oe=Ee(A,"WeakMap"),ie=Ee(Object,"create"),se=Oe(ee),ae=Oe(te),ce=Oe(ne),ue=Oe(re),le=Oe(oe),he=Q?Q.prototype:void 0,pe=he?he.valueOf:void 0;function fe(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function de(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function me(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ge(e){var t=-1,n=e?e.length:0;for(this.__data__=new me;++t<n;)this.add(e[t])}function ye(e){this.__data__=new de(e)}function be(e,t){var n=Te(e)||function(e){return function(e){return Me(e)&&Fe(e)}(e)&&z.call(e,"callee")&&(!X.call(e,"callee")||V.call(e)==o)}(e)?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],r=n.length,i=!!r;for(var s in e)!t&&!z.call(e,s)||i&&("length"==s||Ie(s,r))||n.push(s);return n}function ve(e,t){for(var n=e.length;n--;)if(Re(e[n][0],t))return n;return-1}function we(e,t,n,r,u){return e===t||(null==e||null==t||!Be(e)&&!Me(t)?e!=e&&t!=t:function(e,t,n,r,u,f){var b=Te(e),_=Te(t),C=i,S=i;b||(C=(C=Ae(e))==o?p:C);_||(S=(S=Ae(t))==o?p:S);var k=C==p&&!P(e),E=S==p&&!P(t),A=C==S;if(A&&!k)return f||(f=new ye),b||Ne(e)?Se(e,t,n,r,u,f):function(e,t,n,r,o,i,u){switch(n){case w:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case v:return!(e.byteLength!=t.byteLength||!r(new Y(e),new Y(t)));case s:case a:case h:return Re(+e,+t);case c:return e.name==t.name&&e.message==t.message;case d:case g:return e==t+"";case l:var p=j;case m:var f=2&i;if(p||(p=B),e.size!=t.size&&!f)return!1;var b=u.get(e);if(b)return b==t;i|=1,u.set(e,t);var _=Se(p(e),p(t),r,o,i,u);return u.delete(e),_;case y:if(pe)return pe.call(e)==pe.call(t)}return!1}(e,t,C,n,r,u,f);if(!(2&u)){var I=k&&z.call(e,"__wrapped__"),x=E&&z.call(t,"__wrapped__");if(I||x){var O=I?e.value():e,R=x?t.value():t;return f||(f=new ye),n(O,R,r,u,f)}}if(!A)return!1;return f||(f=new ye),function(e,t,n,r,o,i){var s=2&o,a=Ue(e),c=a.length,u=Ue(t).length;if(c!=u&&!s)return!1;var l=c;for(;l--;){var h=a[l];if(!(s?h in t:z.call(t,h)))return!1}var p=i.get(e);if(p&&i.get(t))return p==t;var f=!0;i.set(e,t),i.set(t,e);var d=s;for(;++l<c;){var m=e[h=a[l]],g=t[h];if(r)var y=s?r(g,m,h,t,e,i):r(m,g,h,e,t,i);if(!(void 0===y?m===g||n(m,g,r,o,i):y)){f=!1;break}d||(d="constructor"==h)}if(f&&!d){var b=e.constructor,v=t.constructor;b==v||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof v&&v instanceof v||(f=!1)}return i.delete(e),i.delete(t),f}(e,t,n,r,u,f)}(e,t,we,n,r,u))}function _e(e){return!(!Be(e)||function(e){return!!H&&H in e}(e))&&(Pe(e)||P(e)?K:_).test(Oe(e))}function Ce(e){if(n=(t=e)&&t.constructor,r="function"==typeof n&&n.prototype||q,t!==r)return Z(e);var t,n,r,o=[];for(var i in Object(e))z.call(e,i)&&"constructor"!=i&&o.push(i);return o}function Se(e,t,n,r,o,i){var s=2&o,a=e.length,c=t.length;if(a!=c&&!(s&&c>a))return!1;var u=i.get(e);if(u&&i.get(t))return u==t;var l=-1,h=!0,p=1&o?new ge:void 0;for(i.set(e,t),i.set(t,e);++l<a;){var f=e[l],d=t[l];if(r)var m=s?r(d,f,l,t,e,i):r(f,d,l,e,t,i);if(void 0!==m){if(m)continue;h=!1;break}if(p){if(!F(t,(function(e,t){if(!p.has(t)&&(f===e||n(f,e,r,o,i)))return p.add(t)}))){h=!1;break}}else if(f!==d&&!n(f,d,r,o,i)){h=!1;break}}return i.delete(e),i.delete(t),h}function ke(e,t){var n,r,o=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof t?"string":"hash"]:o.map}function Ee(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return _e(n)?n:void 0}fe.prototype.clear=function(){this.__data__=ie?ie(null):{}},fe.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},fe.prototype.get=function(e){var t=this.__data__;if(ie){var r=t[e];return r===n?void 0:r}return z.call(t,e)?t[e]:void 0},fe.prototype.has=function(e){var t=this.__data__;return ie?void 0!==t[e]:z.call(t,e)},fe.prototype.set=function(e,t){return this.__data__[e]=ie&&void 0===t?n:t,this},de.prototype.clear=function(){this.__data__=[]},de.prototype.delete=function(e){var t=this.__data__,n=ve(t,e);return!(n<0)&&(n==t.length-1?t.pop():G.call(t,n,1),!0)},de.prototype.get=function(e){var t=this.__data__,n=ve(t,e);return n<0?void 0:t[n][1]},de.prototype.has=function(e){return ve(this.__data__,e)>-1},de.prototype.set=function(e,t){var n=this.__data__,r=ve(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},me.prototype.clear=function(){this.__data__={hash:new fe,map:new(te||de),string:new fe}},me.prototype.delete=function(e){return ke(this,e).delete(e)},me.prototype.get=function(e){return ke(this,e).get(e)},me.prototype.has=function(e){return ke(this,e).has(e)},me.prototype.set=function(e,t){return ke(this,e).set(e,t),this},ge.prototype.add=ge.prototype.push=function(e){return this.__data__.set(e,n),this},ge.prototype.has=function(e){return this.__data__.has(e)},ye.prototype.clear=function(){this.__data__=new de},ye.prototype.delete=function(e){return this.__data__.delete(e)},ye.prototype.get=function(e){return this.__data__.get(e)},ye.prototype.has=function(e){return this.__data__.has(e)},ye.prototype.set=function(e,t){var n=this.__data__;if(n instanceof de){var r=n.__data__;if(!te||r.length<199)return r.push([e,t]),this;n=this.__data__=new me(r)}return n.set(e,t),this};var Ae=function(e){return V.call(e)};function Ie(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||C.test(e))&&e>-1&&e%1==0&&e<t}function xe(e){return e==e&&!Be(e)}function Oe(e){if(null!=e){try{return W.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Re(e,t){return e===t||e!=e&&t!=t}(ee&&Ae(new ee(new ArrayBuffer(1)))!=w||te&&Ae(new te)!=l||ne&&Ae(ne.resolve())!=f||re&&Ae(new re)!=m||oe&&Ae(new oe)!=b)&&(Ae=function(e){var t=V.call(e),n=t==p?e.constructor:void 0,r=n?Oe(n):void 0;if(r)switch(r){case se:return w;case ae:return l;case ce:return f;case ue:return m;case le:return b}return t});var Te=Array.isArray;function Fe(e){return null!=e&&je(e.length)&&!Pe(e)}function Pe(e){var t=Be(e)?V.call(e):"";return t==u||"[object GeneratorFunction]"==t}function je(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}function Be(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Me(e){return!!e&&"object"==typeof e}var Ne=T?function(e){return function(t){return e(t)}}(T):function(e){return Me(e)&&je(e.length)&&!!S[V.call(e)]};function Ue(e){return Fe(e)?be(e):Ce(e)}e.exports=function(e,t){return e===t||function(e,t,n,r){var o=n.length,i=o,s=!r;if(null==e)return!i;for(e=Object(e);o--;){var a=n[o];if(s&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++o<i;){var c=(a=n[o])[0],u=e[c],l=a[1];if(s&&a[2]){if(void 0===u&&!(c in e))return!1}else{var h=new ye;if(r)var p=r(u,l,c,e,t,h);if(!(void 0===p?we(l,u,r,3,h):p))return!1}}return!0}(e,t,function(e){for(var t=Ue(e),n=t.length;n--;){var r=t[n],o=e[r];t[n]=[r,o,xe(o)]}return t}(t))}}(as,as.exports);var cs=as.exports;const us=(e,t)=>{const n=V();return Wo(n,e,e,(r=>{var o;if(n.cache){const n=vi(["post","get",r.posts[0].postId]),{communities:i}=r,s=Ri(r,["communities"]);Ii(s),(null==i?void 0:i[0])&&zo("community.updated",{communities:i});const a=vi(["post","get",r.posts[0].postId]);if(n&&cs(n.data,a.data))return;if(["post.created","post.approved","post.declined"].includes(e)){let t=null===(o=bi(["post","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.targetId)===a.data.targetId}));"post.declined"===e&&(t=null==t?void 0:t.filter((({key:e})=>{var t;return"reviewing"===(null===(t=e[2])||void 0===t?void 0:t.feedType)}))),null==t||t.map((({key:e,data:t})=>Ci(e,t,{cachedAt:-1})))}t(a.data)}else t(r.posts[0])}))},ls=e=>us("post.created",e),hs=e=>us("post.updated",e),ps=e=>us("post.deleted",e),fs=e=>us("post.approved",e),ds=e=>us("post.declined",e),ms=e=>us("post.flagged",e),gs=e=>us("post.unflagged",e),ys=e=>{const t=V();return Wo(t,"post.addReaction","post.addReaction",(n=>{if(t.cache){const t=vi(["post","get",n.posts[0].postId]);os("post.addReaction",n);const r=Ri(n,["reactor"]);Ii(r);const o=vi(["post","get",n.posts[0].postId]);if(t&&cs(t.data,o.data))return;e(o.data)}else e(n.posts[0])}))},bs=e=>{const t=V();return Wo(t,"post.removeReaction","post.removeReaction",(n=>{if(t.cache){const t=vi(["post","get",n.posts[0].postId]);os("post.removeReaction",n);const r=Ri(n,["reactor"]);Ii(r);const o=vi(["post","get",n.posts[0].postId]);if(t&&cs(t.data,o.data))return;e(o.data)}else e(n.posts[0])}))},vs=(e,t)=>{const n=V();return Wo(n,e,e,(r=>{var o;if(n.cache){const n=vi(["comment","get",r.comments[0].commentId]);Ii(r);const i=vi(["comment","get",r.comments[0].commentId]);if(n&&cs(n.data,i.data))return;if(["comment.created"].includes(e)){const e=null===(o=bi(["comment","query"]))||void 0===o?void 0:o.filter((({key:e})=>{var t;return(null===(t=e[2])||void 0===t?void 0:t.referenceId)===i.data.referenceId}));null==e||e.map((({key:e,data:t})=>Ci(e,t,{cachedAt:-1})))}t(i.data)}else t(r.comments[0])}))},ws=e=>vs("comment.created",e),_s=e=>vs("comment.updated",e),Cs=e=>vs("comment.deleted",e),Ss=e=>vs("comment.flagged",e),ks=e=>vs("comment.unflagged",e),Es=e=>{const t=V();return Wo(t,"comment.addReaction","comment.addReaction",(n=>{if(t.cache){const t=vi(["comment","get",n.comments[0].commentId]);os("comment.addReaction",n);const r=Ri(n,["reactor"]);Ii(r);const o=vi(["comment","get",n.comments[0].commentId]);if(t&&cs(t.data,o.data))return;e(o.data)}else e(n.comments[0])}))},As=e=>{const t=V();return Wo(t,"comment.removeReaction","comment.removeReaction",(n=>{if(t.cache){const t=vi(["comment","get",n.comments[0].commentId]);os("comment.removeReaction",n);const r=Ri(n,["reactor"]);Ii(r);const o=vi(["comment","get",n.comments[0].commentId]);if(t&&cs(t.data,o.data))return;e(o.data)}else e(n.comments[0])}))};var Is={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 xs=async e=>{const t=V();t.log("channel/queryChannels",e);const n=null!=e?e:{},{page:r={limit:10},displayName:o,membership:i}=n,s=Ri(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:O(r,"skiplimit")}})}),{paging:c}=a,u=Ri(a,["paging"]),{channels:l}=u,h=t.cache&&Date.now();if(t.cache){Ii(u,{cachedAt:h});const e=["channel","query",Object.assign(Object.assign({},s),{options:Object.assign({},r)})];wi(e,{channels:l.map(Ei("channel")),paging:c})}const p=R(c.next);return{data:l,cachedAt:h,prevPage:R(c.previous),nextPage:p}};xs.locally=e=>{V().log("channel/queryChannels.locally",e)};const Os=async e=>{const t=V();t.log("channel/getChannels",e);const{data:n}=await t.http.get("/api/v3/channels/list",{params:{channelIds:e}}),r=t.cache&&Date.now();return t.cache&&Ii(n,{cachedAt:r}),{data:n.channels,cachedAt:r}};Os.locally=e=>{var t;const n=V();if(n.log("channel/getChannels.locally",e),!n.cache)return;const r=e.map((e=>vi(["channel","get",e]))).filter(Boolean),o=r.map((({data:e})=>e)),i=null===(t=r.sort(((e,t)=>e.cachedAt<t.cachedAt?-1:1)))||void 0===t?void 0:t[0];return(null==r?void 0:r.length)<e.length?void 0:{data:o,cachedAt:i.cachedAt}};const Rs=async e=>{const t=V();t.log("channel/getChannel",e);const{data:n}=await t.http.get(`/api/v3/channels/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{channels:o}=n;return{data:o.find((t=>t.channelId===e)),cachedAt:r}};Rs.locally=e=>{const t=V();if(t.log("channel/getChannel.locally",e),!t.cache)return;const n=vi(["channel","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const Ts=async e=>{const t=V();t.log("channel/queryChannelMembers",e);const n=null!=e?e:{},{page:r,channelId:o,membership:i}=n,s=Ri(n,["page","channelId","membership"]),{data:a}=await t.http.get(`/api/v3/channels/${o}/users`,{params:Object.assign(Object.assign({},s),{filter:i,options:{token:O(r,"skiplimit")}})}),{paging:c}=a,u=Ri(a,["paging"]),{channelUsers:l}=u;t.cache&&Ii(u);return{data:l,nextPage:R(c.next),prevPage:R(c.previous)}};Ts.locally=e=>{V().log("channel/queryChannelMembers",e)};const Fs=e=>{const t=V();return Wo(t,"onChannelUpdated","v3.channel.didUpdate",(t=>{Ii(t),e(t.channels[0])}))},Ps=e=>{const t=V();return Wo(t,"onChannelDeleted","v3.channel.didDelete",(t=>{Ii(t),e(t.channels[0])}))},js=e=>{const t=V();return Wo(t,"onChannelJoined","v3.channel.didJoin",(t=>{Ii(t),e(t.channels[0])}))},Bs=e=>{const t=V();return Wo(t,"onChannelLeft","v3.channel.didLeave",(t=>{Ii(t),e(t.channels[0])}))},Ms=e=>{const t=V();return Wo(t,"onMemberAdded","v3.channel.didAddUsers",(t=>{Ii(t),e(t.channels[0])}))},Ns=e=>{const t=V();return Wo(t,"onMemberRemoved","v3.channel.didRemoveUsers",(t=>{Ii(t),e(t.channels[0])}))},Us=e=>{const t=V();return Wo(t,"message/onMessageCreated","v3.message.didCreate",(t=>{Ii(t),e(t.messages[0])}))},Ls=e=>{const t=V();return Wo(t,"message/onMessageUpdated","v3.message.didUpdate",(t=>{Ii(t),e(t.messages[0])}))},Ds=e=>{const t=V();return Wo(t,"message/onMessageDeleted","v3.message.didDelete",(t=>{Ii(t),e(t.messages[0])}))},qs=(e,t)=>{const n=V();return Wo(n,e,e,(e=>{if(n.cache){const n=vi(["community","get",e.communities[0].communityId]);Ii(e);const r=vi(["community","get",e.communities[0].communityId]);if(n&&cs(n.data,null==r?void 0:r.data))return;t(r.data)}else t(e.communities[0])}))};function $s(e,t,n){return!!e.permissions.some((e=>e===n))||t.users.find((t=>t.userId===e.userId)).permissions.some((e=>e===n))}function Hs(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=>!$s(e,t,"BAN_COMMUNITY_USER")))[0]:t.communityUsers.filter((e=>!$s(e,t,"ADD_COMMUNITY_USER")))[0]}const Ws=(e,t)=>{const n=V();return Wo(n,e,e,(n=>{const r=vi(["community","get",n.communities[0].communityId]),o=vi(["communityUsers","get",Ei("communityUsers")(Hs(e,n))]);Ii(n);const i=vi(["community","get",n.communities[0].communityId]),s=vi(["communityUsers","get",Ei("communityUsers")(Hs(e,n))]);r&&cs(r.data,i.data)&&o&&cs(o.data,s.data)||t(i.data,s.data)}))},zs=e=>qs("community.updated",e),Vs=e=>qs("community.deleted",e),Ks=e=>Ws("community.joined",e),Js=e=>Ws("community.left",e),Qs=e=>Ws("community.userAdded",e),Ys=e=>Ws("community.userRemoved",e),Xs=e=>Ws("community.userBanned",e),Gs=e=>Ws("community.userUnbanned",e),Zs=async e=>{const t=V();t.log("stream/getStream",e);const{data:n}=await t.http.get(`/api/v3/video-streaming/${e}`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}};Zs.locally=e=>{const t=V();if(t.log("stream/getStream",e),!t.cache)return;const n=vi(["stream","get",e]);return n?{data:n.data,cachedAt:n.cachedAt}:void 0};const ea=async e=>{const t=V();t.log("stream/queryStreams",e);const n=null!=e?e:{},{page:r}=n,o=Ri(n,["page"]),{data:i}=await t.http.get("/api/v3/video-streaming",{params:Object.assign(Object.assign({},o),{options:{token:O(r,"skiplimit")}})}),{paging:s,results:a}=i,{videoStreamings:c}=a,u=t.cache&&Date.now();t.cache&&Ii(a,{cachedAt:u});const l=R(s.next);return{data:c,cachedAt:u,prevPage:R(s.previous),nextPage:l}};ea.locally=e=>{V().log("stream/queryStreams.locally",e)};return e.VERSION=n,e.addChannelMembers=async(e,t)=>{const n=V();n.log("channel/addChannelMembers",e,t);const{data:r}=await n.http.post(`/api/v3/channels/${e}/users`,{channelId:e,userIds:t});n.cache&&Ii(r),zo("v3.channel.didAddUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"===t.membership))},e.addChannelMembersRole=async(e,t,n)=>{const r=V();r.log("channel/addChannelMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/channels/${e}/users/roles`,{channelId:e,role:t,userIds:n});r.cache&&Ii(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&n.roles.includes(t)))},e.addCommunityMembers=async(e,t)=>{const n=V();n.log("community/addCommunityMembers",e,t);const{data:r}=await n.http.post(`/api/v3/communities/${e}/users`,{communityId:e,userIds:t});n.cache&&Ii(r),zo("community.userAdded",{communities:r.communities});const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.addCommunityMembersRole=async(e,t,n)=>{const r=V();r.log("community/addCommunityMembersRole",e,t,n);const{data:o}=await r.http.post(`/api/v3/communities/${e}/users/roles`,{communityId:e,role:t,userIds:n});r.cache&&Ii(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&n.roles.includes(t)))},e.addReaction=is,e.backupCache=async(e="amitySdk",t=(e=>e.offline))=>{const{log:n,cache:r,userId:o}=V();if(!r)return!1;n("cache/api/backupCache",{storageKey:e});const i=Object.fromEntries(Object.entries(r.data).filter((([e,n])=>t(n))));return!!Object.keys(i).length&&(await di.setItem(`${e}#${o}`,JSON.stringify(i)),!0)},e.connectClient=async e=>{var t,n;const r=V();r.log("client/api/connectClient",Object.assign({apiKey:r.apiKey},e)),null!==(t=e.displayName)&&void 0!==t||(e.displayName=e.userId),null!==(n=e.deviceId)&&void 0!==n||(e.deviceId=`ascWebSdk#${Math.random().toString(16)}`);const{accessToken:o,users:i}=await(async e=>{const t=V();t.log("client/api/getToken",e);const n=await Ko(),{data:r}=await t.http.post("/v1/device",Object.assign(Object.assign({},e),{deviceInfo:n}),{headers:{"X-API-Key":t.apiKey}});return r})(e);var s,a;r.http.defaults.headers.common.Authorization=`Bearer ${o}`,r.ws.io.opts.query={token:o},s=r.ws,a=r.emitter,qo.forEach((e=>{s.on(e,(t=>a.emit(e,t)))})),await new Promise((e=>{r.ws.once("connect",e),r.ws.open()}));const c=Yo((()=>{Vo(),c()}));return r.userId=e.userId,r.user=i[0],r.accessToken=o,r.ws.connected},e.createChannel=async e=>{const t=V();let n;t.log("user/createChannel",e),n="conversation"===(null==e?void 0:e.type)?await t.http.post("/api/v3/channels/conversation",Object.assign(Object.assign({},e),{isDistinct:!0})):await t.http.post("/api/v3/channels",e);const r=t.cache&&Date.now();t.cache&&Ii(n.data,{cachedAt:r});const{channels:o}=n.data;return{data:o[0],cachedAt:r}},e.createClient=(e,t=ce,r="amity")=>{const o=(e=>{const t=`${null==e?void 0:e.trim()}`.length>0&&"production"!==process.env.NODE_ENV,n=ae(e),r=(e,...r)=>{t&&n(e,r)};return r.__instance__=n,r})(r);o("client/api/createClient",{apiKey:e.replace(/.{5}$/g,"xxxxx"),apiEndpoint:t});const i=(e=>{const t={maxSockets:100,maxFreeSockets:10,timeout:6e4,freeSocketTimeout:3e4},n=Ot.create({baseURL:e,httpAgent:new Pt(t),httpsAgent:new Tt(t),paramsSerializer:Bt});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&&jt(n.data)})),n})(le(ue.HTTP,t)),s=(e=>{const t=Mo(e,{autoConnect:!1,reconnectionDelay:2e3,transports:["websocket"]});return t.on("disconnect",(e=>{"io server disconnect"===e&&t.connect()})),t})(le(ue.HTTP,t)),a=Do(le(ue.MQTT,t)),c=Ho(),u={version:`${n}`,apiKey:e,log:o,http:i,ws:s,mqtt:a,emitter:c,use:()=>K(u)};try{V()}catch(e){K(u)}return u},e.createComment=async e=>{const t=V();t.log("comment/createComment",e);const{data:n}=await t.http.post("/api/v3/comments",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const o=await Qi(e.referenceId);zo("post.updated",{posts:[o.data]}),zo("comment.created",n);const{comments:i}=n;return{data:i[0],cachedAt:r}},e.createCommunity=async e=>{const t=V();t.log("user/createCommunity",e);const{data:n}=await t.http.post("/api/v3/communities/",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),zo("community.created",n);const{communities:o}=n;return{data:o[0],cachedAt:r}},e.createFile=async(e,t)=>{const n=V();if(n.log("file/createFile",e),!e.getAll("file").length)throw new Error("The formData object must have a `file` key.");const r="getHeaders"in e?e.getHeaders():{"content-type":"multipart/form-data"},{data:o}=await n.http.post("/api/v3/files",e,{headers:r,onUploadProgress({loaded:e,total:n}){t&&t(Math.round(100*e/n))}}),i=n.cache&&Date.now();return n.cache&&Ii({files:o},{cachedAt:i}),{data:o[0],cachedAt:i}},e.createMessage=Wi,e.createPost=async e=>{const t=V();t.log("post/createPost",e),e.dataType&&!["text","image","file"].includes(e.dataType)||delete e.dataType;const{data:n}=await t.http.post("/api/v3/posts",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),zo("community.updated",{communities:n.communities}),zo("post.created",n);const{posts:o}=n;return{data:o[0],cachedAt:r}},e.createQuery=N,e.createReport=async(e,t)=>{const n=V();n.log("report/createReport",{referenceType:e,referenceId:t});const{domainName:r}=Is[e],{data:o}=await n.http.post(`/api/v3/${r}/${t}/flag`);n.cache&&Ii(o);return zo("message"===e?"v3.message.didUpdate":`${e}.updated`,o),!!o},e.createStream=async e=>{const t=V();t.log("stream/createStream",e);const{data:n}=await t.http.post("/api/v3/video-streaming",e),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o[0],cachedAt:r}},e.deleteChannel=async e=>{const t=V();t.log("channel/deleteChannel",e),await t.http.delete(`/api/v3/channels/${e}`);return(await Rs(e)).data},e.deleteComment=async(e,t=!1)=>{const n=V();n.log("comment/deleteComment",e);const r=await ns(e);await n.http.delete(`/api/v4/comments/${e}`,{params:{commentId:e,permanent:t}});const o=Object.assign(Object.assign({},r.data),{isDeleted:!0}),i=await Qi(r.data.referenceId);return zo("post.updated",{posts:[i.data]}),zo("comment.deleted",{comments:[o]}),t?setTimeout((()=>{Si(["comment","get",e],!0)}),0):Ci(["comment","get",e],{isDeleted:!0}),o},e.deleteCommunity=async e=>{const t=V();t.log("community/deleteCommunity",e),await t.http.delete(`/api/v3/communities/${e}`);const n=await Gi(e);return zo("community.deleted",{communities:[n.data]}),n.data},e.deleteFile=async e=>{const t=V();return t.log("file/deleteFile",e),await t.http.delete(`/api/v3/files/${e}`),Si(["file","get",e],!0),{success:!0}},e.deleteMessage=Vi,e.deletePost=async(e,t=!1)=>{const n=V();n.log("post/deletePost",e);let r=await Qi(e);if(await n.http.delete(`/api/v4/posts/${e}`,{params:{postId:e,permanent:t}}),"community"===r.data.targetType){const e=await Gi(r.data.targetId);zo("community.updated",{communities:[e.data]})}const o=Object.assign(Object.assign({},r.data),{isDeleted:!0});return zo("post.deleted",{posts:[o]}),t?setTimeout((()=>{Si(["post","get",e],!0)}),0):Ci(["post","get",e],{isDeleted:!0}),o},e.deleteReport=async(e,t)=>{const n=V();n.log("report/deleteReport",{referenceType:e,referenceId:t});const{domainName:r}=Is[e],{data:o}=await n.http.delete(`/api/v3/${r}/${t}/unflag`);n.cache&&Ii(o);return zo("message"===e?"v3.message.didUpdate":`${e}.updated`,o),!!o},e.deleteStream=async e=>{const t=V();t.log("stream/deleteStream",e);let n=await Zs(e);const{data:r}=await t.http.delete(`/api/v3/video-streaming/${e}`),{success:o}=r,i=Object.assign(Object.assign({},n.data),{isDeleted:!0});return Ci(["stream","get",e],i),o},e.disableCache=()=>{const e=V();e.cache&&(e.log("cache/api/disableCache"),delete e.cache)},e.disconnectClient=Vo,e.disposeStream=async e=>{const t=V();t.log("stream/disposeStream",e);const{data:n}=await t.http.delete(`/api/v3/video-streaming/${e}/streaming-url`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r});const{videoStreamings:o}=n;return{data:o.find((t=>t.streamId===e)),cachedAt:r}},e.dropFromCache=Si,e.enableCache=(e={},t)=>{const n=V();n.cache||(n.log("cache/api/enableCache"),n.cache={data:e,persistIf:t})},e.fileUrlWithSize=(e,t)=>`${e}?size=${t}`,e.filterByPropEquality=(e,t,n)=>void 0!==n?e.filter((e=>e[t]===n)):e,e.getActiveClient=V,e.getChannel=Rs,e.getChannels=Os,e.getComment=ns,e.getCommentTopic=({path:e})=>e,e.getComments=ts,e.getCommunities=Xi,e.getCommunity=Gi,e.getCommunityTopic=({path:t},n=e.SubscriptionLevels.COMMUNITY)=>Go({path:t},n),e.getFile=Ni,e.getMessage=qi,e.getMessages=$i,e.getPost=Qi,e.getPostTopic=({path:t},n=e.SubscriptionLevels.POST)=>"comment"===n?`${t}/comment/+`:t,e.getPosts=Ji,e.getRole=Li,e.getStream=Zs,e.getUser=xi,e.getUserTopic=({path:t},n=e.SubscriptionLevels.USER)=>Go({path:t},n),e.getUsers=Oi,e.isAfterBefore=A,e.isAfterBeforeRaw=I,e.isCachable=B,e.isConnected=()=>{var e,t;const n=V();return n.log("client/api/isConnected",n),!!(n.userId&&(null===(t=null===(e=n.http.defaults.headers.common)||void 0===e?void 0:e.Authorization)||void 0===t?void 0:t.length)&&n.ws.connected)},e.isFetcher=F,e.isFresh=M,e.isLocal=e=>B(e)&&-1===(null==e?void 0:e.cachedAt),e.isMutator=P,e.isOffline=j,e.isPaged=x,e.isReportedByMe=async(e,t)=>{var n,r;const o=V();o.log("report/isReportedByMe",{referenceType:e,referenceId:t});const{eventName:i,primaryKey:s}=Is[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(jt(t))}catch(e){o(e)}}))}))})(o,i,{[s]:t}))&&void 0!==n?n:{};return null!==(r=null!=a?a:c)&&void 0!==r&&r},e.isSkipLimit=E,e.joinChannel=async e=>{const t=V();t.log("channel/joinChannel",e);const{data:n}=await t.http.post(`/api/v3/channels/${e}/join`);t.cache&&Ii(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"===t.membership))},e.joinCommunity=async e=>{const t=V();t.log("community/joinCommunity",e);const{data:n}=await t.http.post(`/api/v3/communities/${e}/join`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),zo("community.joined",{communities:n.communities});const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"===t.communityMembership))},e.leaveChannel=async e=>{const t=V();t.log("channel/leaveChannel",e);const{data:n}=await t.http.delete(`/api/v3/channels/${e}/leave`);t.cache&&Ii(n);const{channelUsers:r}=n;return!!r.find((t=>t.channelId===e&&"member"!==t.membership))},e.leaveCommunity=async e=>{const t=V();t.log("community/leaveCommunity",e);const{data:n}=await t.http.delete(`/api/v3/communities/${e}/leave`),r=t.cache&&Date.now();t.cache&&Ii(n,{cachedAt:r}),zo("community.left",{communities:n.communities});const{communityUsers:o}=n;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.mergeInCache=_i,e.observeChannel=(e,t)=>{const{log:n}=V(),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(Fs((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),Ps((e=>o({data:e,loading:!1,origin:"event"},"onDelete"))),js((e=>o({data:e,loading:!1,origin:"event"},"onJoin"))),Bs((e=>o({data:e,loading:!1,origin:"event"},"onLeft"))),Ms((e=>o({data:e,loading:!1,origin:"event"},"onMemberAdded"))),Ns((e=>o({data:e,loading:!1,origin:"event"},"onMemberRemoved")))),L(N(Rs,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}=V(),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(_s((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),Cs((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),Ss((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),ks((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),Es((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),As((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),L(N(ns,e),(e=>(e.data||e.error)&&i(e,"onFetch")),U(n)),()=>{r(`observeComment(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observeComments=(e,t)=>{const{log:n}=V(),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(ws((e=>i(e,"onCreate"))),_s((e=>i(e,"onUpdate"))),Cs((e=>i(e,"onDelete"))),Ss((e=>i(e,"onFlagged"))),ks((e=>i(e,"onUnflagged"))),Es((e=>i(e,"onReactionAdded"))),As((e=>i(e,"onReactionRemoved")))),()=>{n(`observeComments(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeCommunity=(e,t)=>{const{log:n}=V(),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(zs((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Vs((e=>i({data:e,loading:!1,origin:"event"},"onDelete"))),Ks((e=>i({data:e,loading:!1,origin:"event"},"onJoin"))),Js((e=>i({data:e,loading:!1,origin:"event"},"onLeft"))),Qs((e=>i({data:e,loading:!1,origin:"event"},"onUserAdded"))),Ys((e=>i({data:e,loading:!1,origin:"event"},"onUserRemoved"))),Xs((e=>i({data:e,loading:!1,origin:"event"},"onUserBanned"))),Gs((e=>i({data:e,loading:!1,origin:"event"},"onUserUnbanned")))),L(N(Gi,e),(e=>(e.data||e.error)&&o(e,"onFetch"))),()=>{n(`observeCommunity(tmpid: ${r}) > dispose`),s.forEach((e=>e()))}},e.observeFile=(e,t)=>{const{log:n}=V(),r=Date.now();n(`observeFile(tmpid: ${r}) > listen`);return L(N(Ni,e),(n=>n.data&&((n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.fileId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}})(n,"onFetch"))),()=>{n(`observeFile(tmpid: ${r}) > dispose`)}},e.observeMessage=(e,t,n="cache_then_server")=>{const{log:r}=V(),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(Ls((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ds((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),"no_fetch"!==n&&L(N(qi,e),(e=>e.data&&i(e,"onFetch")),U(n)),()=>{r(`observeMessages(tmpid: ${o}) > dispose`),s.forEach((e=>e()))}},e.observeMessages=(e,t)=>{const{log:n}=V(),r=Date.now();n(`observeMessages(tmpid: ${r}) > listen`);const o=[],i=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.channelId)===e){if(t instanceof Function)return t(n);null===(i=t.onEvent)||void 0===i||i.call(t,r,n),null===(s=t[r])||void 0===s||s.call(t,n)}};return o.push(Us((e=>i({data:e,loading:!1,origin:"event"},"onCreate"))),Ls((e=>i({data:e,loading:!1,origin:"event"},"onUpdate"))),Ds((e=>i({data:e,loading:!1,origin:"event"},"onDelete")))),()=>{n(`observeMessages(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observePost=(e,t,n="cache_then_server")=>{const{log:r}=V(),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(hs((e=>s({data:e,loading:!1,origin:"event"},"onUpdate"))),ps((e=>s({data:e,loading:!1,origin:"event"},"onDelete"))),fs((e=>s({data:e,loading:!1,origin:"event"},"onApproved"))),ds((e=>s({data:e,loading:!1,origin:"event"},"onDeclined"))),ms((e=>s({data:e,loading:!1,origin:"event"},"onFlagged"))),gs((e=>s({data:e,loading:!1,origin:"event"},"onUnflagged"))),ys((e=>s({data:e,loading:!1,origin:"event"},"onReactionAdded"))),bs((e=>s({data:e,loading:!1,origin:"event"},"onReactionRemoved")))),L(N(Qi,e),(e=>(e.data||e.error)&&i(e,"onFetch")),U(n)),()=>{r(`observePosts(tmpid: ${o}) > dispose`),a.forEach((e=>e()))}},e.observePosts=(e,t)=>{const{log:n}=V(),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(ls((e=>i(e,"onCreate"))),hs((e=>i(e,"onUpdate"))),ps((e=>i(e,"onDelete"))),fs((e=>i(e,"onApproved"))),ds((e=>i(e,"onDeclined"))),ms((e=>i(e,"onFlagged"))),gs((e=>i(e,"onUnflagged"))),ys((e=>i(e,"onReactionAdded"))),bs((e=>i(e,"onReactionRemoved")))),()=>{n(`observePosts(tmpid: ${r}) > dispose`),o.forEach((e=>e()))}},e.observeUser=(e,t)=>{const{log:n}=V(),r=Date.now();n(`observeUser(tmpid: ${r}) > listen`);const o=(n,r)=>{var o,i,s;if((null===(o=n.data)||void 0===o?void 0:o.userId)===e){if(t instanceof Function)return t(n);"onFetch"!==r&&(null===(i=t.onEvent)||void 0===i||i.call(t,r,n)),null===(s=t[r])||void 0===s||s.call(t,n)}},i=[];return i.push(Pi((e=>o({data:e,loading:!1,origin:"event"},"onUpdate"))),ji((e=>o({data:e,loading:!1,origin:"event"},"onFlagged"))),Bi((e=>o({data:e,loading:!1,origin:"event"},"onUnflagged"))),Mi((e=>o({data:e,loading:!1,origin:"event"},"onFlagCleared")))),L(N(xi,e),(e=>e.data&&o(e,"onFetch"))),()=>{n(`observeUser(tmpid: ${r}) > dispose`),i.forEach((e=>e()))}},e.onChannelDeleted=Ps,e.onChannelJoined=js,e.onChannelLeft=Bs,e.onChannelUpdated=Fs,e.onClientBanned=Yo,e.onClientDisconnected=e=>Qo((({code:t})=>{800211===t&&e()})),e.onCommentCreated=ws,e.onCommentDeleted=Cs,e.onCommentFlagged=Ss,e.onCommentReactionAdded=Es,e.onCommentReactionRemoved=As,e.onCommentUnflagged=ks,e.onCommentUpdated=_s,e.onCommunityCreated=e=>qs("community.created",e),e.onCommunityDeleted=Vs,e.onCommunityJoined=Ks,e.onCommunityLeft=Js,e.onCommunityUpdated=zs,e.onCommunityUserAdded=Qs,e.onCommunityUserBanned=Xs,e.onCommunityUserRemoved=Ys,e.onCommunityUserUnbanned=Gs,e.onConnectionError=Qo,e.onMemberAdded=Ms,e.onMemberRemoved=Ns,e.onMessageCreated=Us,e.onMessageDeleted=Ds,e.onMessageUpdated=Ls,e.onPostApproved=fs,e.onPostCreated=ls,e.onPostDeclined=ds,e.onPostDeleted=ps,e.onPostFlagged=ms,e.onPostReactionAdded=ys,e.onPostReactionRemoved=bs,e.onPostUnflagged=gs,e.onPostUpdated=hs,e.onReactionRemoved=(e,t,n)=>{const r=r=>{Ei(e)(r)===t&&n(r)};if("message"===e){const e=V(),t=e=>{var t;const n=vi(["message","get",e.messages[0].messageId]),o=(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.reactionsCount)!==e.messages[0].reactionsCount;Ii(e),o&&r(e.messages[0])};return Wo(e,"reaction/onReactionRemoved","v3.message.didUpdate",t)}return"post"===e?bs(r):As(r)},e.onStreamRecorded=e=>{const t=V();return Wo(t,"stream/onStreamRecorded","video-streaming.didRecord",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onStreamStarted=e=>{const t=V();return Wo(t,"stream/onStreamStarted","video-streaming.didStart",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onStreamStopped=e=>{const t=V();return Wo(t,"stream/onStreamStarted","video-streaming.didStop",(t=>{Ii(t),e(t.videoStreamings[0])}))},e.onUserFlagCleared=Mi,e.onUserFlagged=ji,e.onUserUnflagged=Bi,e.onUserUpdated=Pi,e.pullFromCache=vi,e.pushToCache=wi,e.queryCache=bi,e.queryChannelMembers=Ts,e.queryChannels=xs,e.queryComments=es,e.queryCommunities=Yi,e.queryCommunityMembers=Zi,e.queryGlobalFeed=async e=>{const t=V();t.log("feed/queryGlobalFeed",e);const n=null!=e?e:{},{page:r}=n,o=Ri(n,["page"]),{data:i}=await t.http.get("/api/v4/me/global-feeds",{params:Object.assign(Object.assign({},o),{options:{token:O(r,"skiplimit")}})}),{paging:s}=i,a=Ri(i,["paging"]),{posts:c}=a;t.cache&&Ii(a);const u=R(s.next);return{data:c,prevPage:R(s.previous),nextPage:u}},e.queryMessages=Hi,e.queryOptions=U,e.queryPosts=Ki,e.queryRoles=Ui,e.queryStreams=ea,e.queryUsers=Ti,e.removeChannelMembers=async(e,t)=>{const n=V();n.log("channel/removeChannelMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/channels/${e}/users`,{data:{channelId:e,userIds:t}});n.cache&&Ii(r),zo("v3.channel.didRemoveUsers",{channels:r.channels});const{channelUsers:o}=r;return!!o.find((t=>t.channelId===e&&"member"!==t.membership))},e.removeChannelMembersRole=async(e,t,n)=>{const r=V();r.log("channel/removeChannelMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/channels/${e}/users/roles`,{data:{channelId:e,role:t,userIds:n}});r.cache&&Ii(o);const{channelUsers:i}=o;return!!i.find((n=>n.channelId===e&&!n.roles.includes(t)))},e.removeCommunityMembers=async(e,t)=>{const n=V();n.log("community/removeCommunityMembers",e,t);const{data:r}=await n.http.delete(`/api/v3/communities/${e}/users`,{data:{communityId:e,userIds:t}});n.cache&&Ii(r),zo("community.userRemoved",{communities:r.communities});const{communityUsers:o}=r;return!!o.find((t=>t.communityId===e&&"member"!==t.communityMembership))},e.removeCommunityMembersRole=async(e,t,n)=>{const r=V();r.log("community/removeCommunityMembersRole",e,t,n);const{data:o}=await r.http.delete(`/api/v3/communities/${e}/users/roles`,{data:{communityId:e,role:t,userIds:n}});r.cache&&Ii(o);const{communityUsers:i}=o;return!!i.find((n=>n.communityId===e&&!n.roles.includes(t)))},e.removeReaction=ss,e.restoreCache=async(e="amitySdk")=>{var t;const n=V();if(!n.cache)return!1;n.log("cache/api/restoreCache",{storageKey:e});const r=null!==(t=await di.getItem(`${e}#${n.userId}`))&&void 0!==t?t:"{}";let o={};try{o=JSON.parse(r)}catch(e){}return n.cache.data=Object.assign(Object.assign({},o),n.cache.data),!0},e.runQuery=L,e.sliceByPaging=(e,t,n)=>{if(console.log("slice by paging",n),!n)return t.slice();let r,o=0;n.after?(o=n.after,r=o+n.limit):n.before&&(r=n.before+1,o=r>n.limit?r-n.limit:0);const i=t.slice(o,r);return i.length===n.limit?i:void 0},e.sortByChannelSegment=({channelSegment:e},{channelSegment:t})=>e-t,e.sortByDisplayName=({displayName:e},{displayName:t})=>e===t?0:e<t?-1:1,e.sortByFirstCreated=({createdAt:e},{createdAt:t})=>new Date(e).valueOf()-new Date(t).valueOf(),e.sortByLastActivity=({lastActivity:e},{lastActivity:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortByLastCreated=({createdAt:e},{createdAt:t})=>new Date(t).valueOf()-new Date(e).valueOf(),e.sortBySegmentNumber=({segmentNumber:e},{segmentNumber:t})=>e-t,e.subscribeTopic=function(e,t){const{mqtt:n,emitter:r,accessToken:o,user:i}=V();return Zo===o&&ei===i._id||(Zo=o,ei=i._id,n.connect({accessToken:o,userId:i._id}),((e,t)=>{$o.forEach((n=>{e.on(n,((...e)=>t.emit(n,1===e.length?e[0]:e)))})),e.on("message",((e,n)=>{const r=JSON.parse(n.toString());t.emit(r.eventType,r.data)}))})(n,r)),n.subscribe(e,t)},e.toPage=R,e.toPageRaw=T,e.toToken=O,e.updateChannel=async(e,t)=>{const n=V();n.log("channel/updateChannel",e,t);const{data:r}=await n.http.put(`/api/v3/channels/${e}`,t),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{channels:i}=r;return{data:i.find((t=>t.channelId===e)),cachedAt:o}},e.updateComment=async(e,t)=>{const n=V();n.log("user/updateComment",t);const{data:r}=await n.http.put(`/api/v3/comments/${e}`,t),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o}),zo("comment.updated",r);const{comments:i}=r;return{data:i.find((t=>t.commentId===e)),cachedAt:o}},e.updateCommunity=async(e,t)=>{const n=V();n.log("community/updateCommunity",e,t);const{data:r}=await n.http.put(`/api/v3/communities/${e}`,t),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o}),zo("community.updated",r);const{communities:i}=r;return{data:i.find((t=>t.communityId===e)),cachedAt:o}},e.updateMessage=zi,e.updatePost=async(e,t)=>{const n=V();n.log("user/updatePost",t);const{data:r}=await n.http.put(`/api/v3/posts/${e}`,t),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o}),zo("post.updated",r);const{posts:i}=r;return{data:i.find((t=>t.postId===e)),cachedAt:o}},e.updateStream=async(e,t)=>{const n=V();n.log("stream/updateStream",e,t);const{data:r}=await n.http.put(`/api/v3/video-streaming/${e}`,t),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{videoStreamings:i}=r;return{data:i.find((t=>t.streamId===e)),cachedAt:o}},e.updateUser=async(e,t)=>{const n=V();n.log("user/updateUser",e,t);const{data:r}=await n.http.put("/api/v3/users/",Object.assign(Object.assign({userId:e},t),{createNewUserWhenNotFound:!1})),o=n.cache&&Date.now();n.cache&&Ii(r,{cachedAt:o});const{users:i}=r;return{data:i.find((t=>t.userId===e)),cachedAt:o}},e.upsertInCache=Ci,e.wipeCache=async(e="amitySdk")=>{const{log:t,cache:n,userId:r}=V();return!!n&&(t("cache/api/wipeCache",{storageKey:e}),n.data={},await di.setItem(`${e}#${r}`,"{}"),!0)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});