@twilio/conversations 1.3.0-rc8 → 2.0.0-rc.4

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 (282) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/README.md +22 -17
  3. package/dist/browser.js +7873 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/docs/assets/css/main.css +2660 -0
  6. package/dist/docs/assets/images/icons.png +0 -0
  7. package/dist/docs/assets/images/icons@2x.png +0 -0
  8. package/dist/docs/assets/images/widgets.png +0 -0
  9. package/dist/docs/assets/images/widgets@2x.png +0 -0
  10. package/dist/docs/assets/js/main.js +248 -0
  11. package/dist/docs/assets/js/search.js +1 -0
  12. package/dist/docs/classes/AggregatedDeliveryReceipt.html +3286 -0
  13. package/dist/docs/classes/Client.html +4181 -0
  14. package/dist/docs/classes/Conversation.html +4397 -0
  15. package/dist/docs/classes/DetailedDeliveryReceipt.html +3265 -0
  16. package/dist/docs/classes/Media.html +3295 -0
  17. package/dist/docs/classes/Message.html +3713 -0
  18. package/dist/docs/classes/MessageBuilder.html +3280 -0
  19. package/dist/docs/classes/Participant.html +3517 -0
  20. package/dist/docs/classes/PushNotification.html +3232 -0
  21. package/dist/docs/classes/RestPaginator.html +3262 -0
  22. package/dist/docs/classes/UnsentMessage.html +3144 -0
  23. package/dist/docs/classes/User.html +3451 -0
  24. package/dist/docs/index.html +3394 -212
  25. package/dist/docs/interfaces/ClientOptions.html +3136 -0
  26. package/dist/docs/interfaces/ConversationState.html +3152 -0
  27. package/dist/docs/interfaces/CreateConversationOptions.html +3168 -0
  28. package/dist/docs/interfaces/LastMessage.html +3152 -0
  29. package/dist/docs/interfaces/Paginator.html +3243 -0
  30. package/dist/docs/interfaces/PushNotificationData.html +3168 -0
  31. package/dist/docs/interfaces/SendEmailOptions.html +3136 -0
  32. package/dist/docs/interfaces/SendMediaOptions.html +3170 -0
  33. package/dist/docs/modules.html +3425 -0
  34. package/dist/lib.d.ts +1952 -0
  35. package/dist/lib.js +7873 -0
  36. package/dist/lib.js.map +1 -0
  37. package/dist/post-install.js +29 -0
  38. package/dist/react-native.js +4038 -0
  39. package/dist/react-native.js.map +1 -0
  40. package/dist/twilio-conversations.js +40912 -0
  41. package/dist/twilio-conversations.min.js +156 -0
  42. package/package.json +59 -48
  43. package/.circleci/config.yml +0 -650
  44. package/.deepsource.toml +0 -6
  45. package/.env.example +0 -13
  46. package/browser/aggregateddeliveryreceipt.js +0 -152
  47. package/browser/client.js +0 -991
  48. package/browser/configuration.js +0 -80
  49. package/browser/conversation.js +0 -1826
  50. package/browser/data/conversations.js +0 -632
  51. package/browser/data/messages.js +0 -522
  52. package/browser/data/participants.js +0 -411
  53. package/browser/data/users.js +0 -281
  54. package/browser/detaileddeliveryreceipt.js +0 -44
  55. package/browser/index.js +0 -4
  56. package/browser/interfaces/limits.js +0 -3
  57. package/browser/interfaces/notificationtypes.js +0 -21
  58. package/browser/interfaces/paginator.js +0 -53
  59. package/browser/interfaces/responsecodes.js +0 -20
  60. package/browser/interfaces/transport.js +0 -3
  61. package/browser/logger.js +0 -141
  62. package/browser/media.js +0 -198
  63. package/browser/message.js +0 -685
  64. package/browser/participant.js +0 -415
  65. package/browser/pushnotification.js +0 -49
  66. package/browser/restpaginator.js +0 -74
  67. package/browser/services/network.js +0 -223
  68. package/browser/services/readhorizon.js +0 -181
  69. package/browser/services/typingindicator.js +0 -142
  70. package/browser/session.js +0 -505
  71. package/browser/sessionerror.js +0 -93
  72. package/browser/sri.json +0 -1
  73. package/browser/synclist.js +0 -90
  74. package/browser/synclistdescriptor.js +0 -29
  75. package/browser/syncpaginator.js +0 -63
  76. package/browser/user.js +0 -431
  77. package/browser/util/deferred.js +0 -56
  78. package/browser/util/index.js +0 -108
  79. package/dist/@twilio/conversations.js +0 -35533
  80. package/dist/@twilio/conversations.min.js +0 -204
  81. package/dist/docs/AggregatedDeliveryReceipt.html +0 -948
  82. package/dist/docs/Client.html +0 -5075
  83. package/dist/docs/Conversation.html +0 -6018
  84. package/dist/docs/DetailedDeliveryReceipt.html +0 -641
  85. package/dist/docs/Media.html +0 -694
  86. package/dist/docs/Message.html +0 -1934
  87. package/dist/docs/Paginator.html +0 -605
  88. package/dist/docs/Participant.html +0 -1510
  89. package/dist/docs/PushNotification.html +0 -836
  90. package/dist/docs/SessionError.html +0 -379
  91. package/dist/docs/User.html +0 -1315
  92. package/dist/docs/classes.list.html +0 -4431
  93. package/dist/docs/fonts/glyphicons-halflings-regular.eot +0 -0
  94. package/dist/docs/fonts/glyphicons-halflings-regular.svg +0 -288
  95. package/dist/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
  96. package/dist/docs/fonts/glyphicons-halflings-regular.woff +0 -0
  97. package/dist/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
  98. package/dist/docs/img/glyphicons-halflings-white.png +0 -0
  99. package/dist/docs/img/glyphicons-halflings.png +0 -0
  100. package/dist/docs/quicksearch.html +0 -31
  101. package/dist/docs/scripts/docstrap.lib.js +0 -11
  102. package/dist/docs/scripts/fulltext-search-ui.js +0 -89
  103. package/dist/docs/scripts/fulltext-search.js +0 -36
  104. package/dist/docs/scripts/lunr.min.js +0 -6
  105. package/dist/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  106. package/dist/docs/scripts/prettify/jquery.min.js +0 -6
  107. package/dist/docs/scripts/prettify/lang-css.js +0 -21
  108. package/dist/docs/scripts/prettify/prettify.js +0 -496
  109. package/dist/docs/scripts/sunlight.js +0 -1157
  110. package/dist/docs/scripts/toc.js +0 -203
  111. package/dist/docs/styles/darkstrap.css +0 -960
  112. package/dist/docs/styles/prettify-tomorrow.css +0 -132
  113. package/dist/docs/styles/site.cerulean.css +0 -7008
  114. package/dist/docs/styles/site.cosmo.css +0 -7061
  115. package/dist/docs/styles/site.cyborg.css +0 -7048
  116. package/dist/docs/styles/site.darkly.css +0 -7171
  117. package/dist/docs/styles/site.darkstrap.css +0 -5638
  118. package/dist/docs/styles/site.dibs-bootstrap.css +0 -5899
  119. package/dist/docs/styles/site.flatly.css +0 -7147
  120. package/dist/docs/styles/site.journal.css +0 -6973
  121. package/dist/docs/styles/site.lumen.css +0 -7298
  122. package/dist/docs/styles/site.paper.css +0 -7623
  123. package/dist/docs/styles/site.readable.css +0 -6997
  124. package/dist/docs/styles/site.sandstone.css +0 -7035
  125. package/dist/docs/styles/site.simplex.css +0 -7023
  126. package/dist/docs/styles/site.slate.css +0 -7343
  127. package/dist/docs/styles/site.spacelab.css +0 -7055
  128. package/dist/docs/styles/site.superhero.css +0 -7131
  129. package/dist/docs/styles/site.united.css +0 -6895
  130. package/dist/docs/styles/site.yeti.css +0 -7195
  131. package/dist/docs/styles/sunlight.dark.css +0 -345
  132. package/dist/docs/styles/sunlight.default.css +0 -344
  133. package/dist/sri.json +0 -1
  134. package/lib/aggregateddeliveryreceipt.d.ts +0 -98
  135. package/lib/aggregateddeliveryreceipt.js +0 -112
  136. package/lib/client.d.ts +0 -317
  137. package/lib/client.js +0 -633
  138. package/lib/configuration.d.ts +0 -21
  139. package/lib/configuration.js +0 -41
  140. package/lib/conversation.d.ts +0 -460
  141. package/lib/conversation.js +0 -940
  142. package/lib/data/conversations.d.ts +0 -57
  143. package/lib/data/conversations.js +0 -296
  144. package/lib/data/messages.d.ts +0 -75
  145. package/lib/data/messages.js +0 -208
  146. package/lib/data/participants.d.ts +0 -94
  147. package/lib/data/participants.js +0 -204
  148. package/lib/data/users.d.ts +0 -42
  149. package/lib/data/users.js +0 -113
  150. package/lib/detaileddeliveryreceipt.d.ts +0 -45
  151. package/lib/detaileddeliveryreceipt.js +0 -34
  152. package/lib/index.d.ts +0 -1
  153. package/lib/index.js +0 -3
  154. package/lib/interfaces/limits.d.ts +0 -8
  155. package/lib/interfaces/limits.js +0 -2
  156. package/lib/interfaces/notificationtypes.d.ts +0 -8
  157. package/lib/interfaces/notificationtypes.js +0 -11
  158. package/lib/interfaces/paginator.d.ts +0 -52
  159. package/lib/interfaces/paginator.js +0 -28
  160. package/lib/interfaces/responsecodes.d.ts +0 -8
  161. package/lib/interfaces/responsecodes.js +0 -10
  162. package/lib/interfaces/transport.d.ts +0 -13
  163. package/lib/interfaces/transport.js +0 -2
  164. package/lib/logger.d.ts +0 -18
  165. package/lib/logger.js +0 -35
  166. package/lib/media.d.ts +0 -52
  167. package/lib/media.js +0 -69
  168. package/lib/message.d.ts +0 -136
  169. package/lib/message.js +0 -305
  170. package/lib/participant.d.ts +0 -142
  171. package/lib/participant.js +0 -219
  172. package/lib/pushnotification.d.ts +0 -48
  173. package/lib/pushnotification.js +0 -39
  174. package/lib/restpaginator.d.ts +0 -19
  175. package/lib/restpaginator.js +0 -36
  176. package/lib/services/network.d.ts +0 -22
  177. package/lib/services/network.js +0 -87
  178. package/lib/services/readhorizon.d.ts +0 -28
  179. package/lib/services/readhorizon.js +0 -112
  180. package/lib/services/typingindicator.d.ts +0 -50
  181. package/lib/services/typingindicator.js +0 -102
  182. package/lib/session.d.ts +0 -63
  183. package/lib/session.js +0 -213
  184. package/lib/sessionerror.d.ts +0 -12
  185. package/lib/sessionerror.js +0 -24
  186. package/lib/sri.json +0 -1
  187. package/lib/synclist.d.ts +0 -24
  188. package/lib/synclist.js +0 -28
  189. package/lib/synclistdescriptor.d.ts +0 -27
  190. package/lib/synclistdescriptor.js +0 -19
  191. package/lib/syncpaginator.d.ts +0 -22
  192. package/lib/syncpaginator.js +0 -37
  193. package/lib/user.d.ts +0 -98
  194. package/lib/user.js +0 -219
  195. package/lib/util/deferred.d.ts +0 -12
  196. package/lib/util/deferred.js +0 -22
  197. package/lib/util/index.d.ts +0 -28
  198. package/lib/util/index.js +0 -82
  199. package/tools/rtd-sdk-cdn-pin/.gitrepo +0 -12
  200. package/tools/rtd-sdk-cdn-pin/README.md +0 -54
  201. package/tools/rtd-sdk-cdn-pin/bintray-settings.xml.template +0 -16
  202. package/tools/rtd-sdk-cdn-pin/cdn-common/cdn-prepare.sh +0 -67
  203. package/tools/rtd-sdk-cdn-pin/cdn-pin-latest.sh +0 -19
  204. package/tools/rtd-sdk-cdn-pin/cdn-pin.sh +0 -19
  205. package/tools/rtd-sdk-cdn-pin/cdn-upload.sh +0 -13
  206. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-bintray-android.sh +0 -34
  207. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-npm.sh +0 -18
  208. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-android.sh +0 -5
  209. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-js.sh +0 -5
  210. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-android.sh +0 -6
  211. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-js.sh +0 -5
  212. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-android.sh +0 -5
  213. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-js.sh +0 -5
  214. package/tools/rtd-sdk-cdn-pin/fetch-artifact.sh +0 -26
  215. package/tools/sdk-release-tool/.gitrepo +0 -12
  216. package/tools/sdk-release-tool/Makefile +0 -49
  217. package/tools/sdk-release-tool/README.md +0 -275
  218. package/tools/sdk-release-tool/delete +0 -3
  219. package/tools/sdk-release-tool/download +0 -3
  220. package/tools/sdk-release-tool/get-cors +0 -3
  221. package/tools/sdk-release-tool/list +0 -3
  222. package/tools/sdk-release-tool/pin +0 -3
  223. package/tools/sdk-release-tool/pin-latest +0 -3
  224. package/tools/sdk-release-tool/requirements.txt +0 -4
  225. package/tools/sdk-release-tool/sdk-release-tool +0 -3
  226. package/tools/sdk-release-tool/sdk_release_tools/__init__.py +0 -0
  227. package/tools/sdk-release-tool/sdk_release_tools/__main__.py +0 -110
  228. package/tools/sdk-release-tool/sdk_release_tools/aws.py +0 -70
  229. package/tools/sdk-release-tool/sdk_release_tools/cli.py +0 -181
  230. package/tools/sdk-release-tool/sdk_release_tools/log.py +0 -24
  231. package/tools/sdk-release-tool/sdk_release_tools/ops.py +0 -295
  232. package/tools/sdk-release-tool/sdk_release_tools/rpm.py +0 -28
  233. package/tools/sdk-release-tool/sdk_release_tools/util.py +0 -186
  234. package/tools/sdk-release-tool/sdk_release_tools/versions.py +0 -362
  235. package/tools/sdk-release-tool/signal-sdk-js.json +0 -28
  236. package/tools/sdk-release-tool/tests/test_versions.py +0 -94
  237. package/tools/sdk-release-tool/twilio-accessmanager-android.json +0 -19
  238. package/tools/sdk-release-tool/twilio-accessmanager-ios.json +0 -26
  239. package/tools/sdk-release-tool/twilio-auth-ios.json +0 -29
  240. package/tools/sdk-release-tool/twilio-authenticator-ios.json +0 -29
  241. package/tools/sdk-release-tool/twilio-chat-android-2.json +0 -19
  242. package/tools/sdk-release-tool/twilio-chat-android.json +0 -22
  243. package/tools/sdk-release-tool/twilio-chat-ios.json +0 -26
  244. package/tools/sdk-release-tool/twilio-chat-js.json +0 -27
  245. package/tools/sdk-release-tool/twilio-client-android-aar.json +0 -22
  246. package/tools/sdk-release-tool/twilio-client-android.json +0 -22
  247. package/tools/sdk-release-tool/twilio-client-ios.json +0 -20
  248. package/tools/sdk-release-tool/twilio-client-js.json +0 -17
  249. package/tools/sdk-release-tool/twilio-client-sounds-js.json +0 -14
  250. package/tools/sdk-release-tool/twilio-common-android-maven.json +0 -16
  251. package/tools/sdk-release-tool/twilio-common-android.json +0 -22
  252. package/tools/sdk-release-tool/twilio-common-ios-rtc.json +0 -25
  253. package/tools/sdk-release-tool/twilio-common-ios.json +0 -25
  254. package/tools/sdk-release-tool/twilio-common-js.json +0 -19
  255. package/tools/sdk-release-tool/twilio-conversations-android.json +0 -22
  256. package/tools/sdk-release-tool/twilio-conversations-ios.json +0 -26
  257. package/tools/sdk-release-tool/twilio-conversations-js.json +0 -27
  258. package/tools/sdk-release-tool/twilio-flex-js.json +0 -20
  259. package/tools/sdk-release-tool/twilio-flex-webchat-js.json +0 -16
  260. package/tools/sdk-release-tool/twilio-frame-chat-android.json +0 -22
  261. package/tools/sdk-release-tool/twilio-frame-chat-ios.json +0 -23
  262. package/tools/sdk-release-tool/twilio-frame-chat-js.json +0 -23
  263. package/tools/sdk-release-tool/twilio-ip-messaging-android-maven.json +0 -16
  264. package/tools/sdk-release-tool/twilio-ip-messaging-android.json +0 -22
  265. package/tools/sdk-release-tool/twilio-ip-messaging-ios.json +0 -25
  266. package/tools/sdk-release-tool/twilio-ip-messaging-js.json +0 -21
  267. package/tools/sdk-release-tool/twilio-sync-android.json +0 -22
  268. package/tools/sdk-release-tool/twilio-sync-ios.json +0 -26
  269. package/tools/sdk-release-tool/twilio-sync-js.json +0 -39
  270. package/tools/sdk-release-tool/twilio-taskrouter-js.json +0 -17
  271. package/tools/sdk-release-tool/twilio-video-android.json +0 -22
  272. package/tools/sdk-release-tool/twilio-video-cpp-linux-cross-rootfs.json +0 -13
  273. package/tools/sdk-release-tool/twilio-video-cpp.json +0 -33
  274. package/tools/sdk-release-tool/twilio-video-ios.json +0 -25
  275. package/tools/sdk-release-tool/twilio-video-js.json +0 -19
  276. package/tools/sdk-release-tool/twilio-video-jsdocs.json +0 -14
  277. package/tools/sdk-release-tool/twilio-voice-android.json +0 -22
  278. package/tools/sdk-release-tool/twilio-voice-ios.json +0 -29
  279. package/tools/sdk-release-tool/unpin +0 -3
  280. package/tools/sdk-release-tool/unpin-latest +0 -3
  281. package/tools/sdk-release-tool/upload +0 -3
  282. package/twilio-chat.js.iml +0 -9
@@ -1,204 +0,0 @@
1
- /* @twilio/conversations.js 1.3.0-rc8
2
- The following license applies to all parts of this software except as
3
- documented below.
4
-
5
- Copyright (c) 2019, Twilio, inc.
6
- All rights reserved.
7
-
8
- Redistribution and use in source and binary forms, with or without
9
- modification, are permitted provided that the following conditions are
10
- met:
11
-
12
- 1. Redistributions of source code must retain the above copyright
13
- notice, this list of conditions and the following disclaimer.
14
-
15
- 2. Redistributions in binary form must reproduce the above copyright
16
- notice, this list of conditions and the following disclaimer in
17
- the documentation and/or other materials provided with the
18
- distribution.
19
-
20
- 3. Neither the name of Twilio nor the names of its contributors may
21
- be used to endorse or promote products derived from this software
22
- without specific prior written permission.
23
-
24
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
-
36
- This software includes javascript-state-machine under the following license.
37
-
38
- Copyright (c) 2012, 2013, 2014, 2015, Jake Gordon and contributors
39
-
40
- Permission is hereby granted, free of charge, to any person obtaining a copy
41
- of this software and associated documentation files (the "Software"), to deal
42
- in the Software without restriction, including without limitation the rights
43
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
- copies of the Software, and to permit persons to whom the Software is
45
- furnished to do so, subject to the following conditions:
46
-
47
- The above copyright notice and this permission notice shall be included in all
48
- copies or substantial portions of the Software.
49
-
50
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
53
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56
-
57
- This software includes loglevel under the following license.
58
-
59
- Copyright (c) 2013 Tim Perry
60
-
61
- Permission is hereby granted, free of charge, to any person
62
- obtaining a copy of this software and associated documentation
63
- files (the "Software"), to deal in the Software without
64
- restriction, including without limitation the rights to use,
65
- copy, modify, merge, publish, distribute, sublicense, and/or sell
66
- copies of the Software, and to permit persons to whom the
67
- Software is furnished to do so, subject to the following
68
- conditions:
69
-
70
- The above copyright notice and this permission notice shall be
71
- included in all copies or substantial portions of the Software.
72
-
73
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
74
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
75
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
76
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
77
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
78
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
79
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
80
- OTHER DEALINGS IN THE SOFTWARE.
81
-
82
- This software includes q under the following license.
83
-
84
- Copyright 2009–2014 Kristopher Michael Kowal. All rights reserved.
85
- Permission is hereby granted, free of charge, to any person obtaining a copy
86
- of this software and associated documentation files (the "Software"), to
87
- deal in the Software without restriction, including without limitation the
88
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
89
- sell copies of the Software, and to permit persons to whom the Software is
90
- furnished to do so, subject to the following conditions:
91
-
92
- The above copyright notice and this permission notice shall be included in
93
- all copies or substantial portions of the Software.
94
-
95
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
96
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
98
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
99
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
100
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
101
- IN THE SOFTWARE.
102
-
103
- This software includes platform.js under the following license.
104
-
105
- Copyright 2014 Benjamin Tan <https://d10.github.io/>
106
- Copyright 2011-2015 John-David Dalton <http://allyoucanleet.com/>
107
-
108
- Permission is hereby granted, free of charge, to any person obtaining
109
- a copy of this software and associated documentation files (the
110
- "Software"), to deal in the Software without restriction, including
111
- without limitation the rights to use, copy, modify, merge, publish,
112
- distribute, sublicense, and/or sell copies of the Software, and to
113
- permit persons to whom the Software is furnished to do so, subject to
114
- the following conditions:
115
-
116
- The above copyright notice and this permission notice shall be
117
- included in all copies or substantial portions of the Software.
118
-
119
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
120
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
121
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
122
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
123
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
124
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
125
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
126
- */
127
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;((t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Twilio||(t.Twilio={})).Conversations=e()}}(function(){return function(){return function e(t,n,r){function i(a,o){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){return i(t[a][1][e]||e)},l,l.exports,e,t,n,r)}return n[a].exports}for(var s="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}}()({1:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(t){(0,r.default)(this,e),this.state=t}return(0,i.default)(e,[{key:"_update",value:function(e){this.state=e}},{key:"_isEquals",value:function(e){var t=this.total===e.total,n=this.sent===e.sent,r=this.delivered===e.delivered,i=this.read===e.read,s=this.undelivered===e.undelivered,a=this.failed===e.failed;return t&&n&&r&&i&&s&&a}},{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}}]),e}();n.AggregatedDeliveryReceipt=a},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],2:[function(e,t,n){"use strict";var r=m(e("babel-runtime/regenerator")),i=m(e("babel-runtime/helpers/asyncToGenerator")),s=m(e("babel-runtime/core-js/promise")),a=m(e("babel-runtime/core-js/object/assign")),o=m(e("babel-runtime/core-js/object/get-prototype-of")),u=m(e("babel-runtime/helpers/createClass")),c=m(e("babel-runtime/helpers/possibleConstructorReturn")),l=m(e("babel-runtime/helpers/inherits")),d=m(e("babel-runtime/helpers/classCallCheck")),f=m(e("babel-runtime/core-js/reflect/metadata")),p=m(e("babel-runtime/core-js/object/define-property")),h=m(e("babel-runtime/helpers/typeof")),b=m(e("babel-runtime/core-js/object/get-own-property-descriptor"));function m(e){return e&&e.__esModule?e:{default:e}}var v=function(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=(0,b.default)(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,h.default)(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&(0,p.default)(t,n,a),a},y=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,h.default)(Reflect))&&"function"==typeof f.default)return(0,f.default)(e,t)};Object.defineProperty(n,"__esModule",{value:!0});var g=e("events"),_=e("./logger"),k=e("./configuration"),w=e("./user");n.User=w.User;var x=e("./services/network"),C=e("./interfaces/notificationtypes"),j=e("./synclist"),S=e("twilsock"),T=e("twilio-notifications"),E=e("twilio-sync"),M=e("twilio-mcs-client"),I=e("./session"),R=e("./data/conversations"),P=e("./data/users"),O=e("./services/typingindicator"),L=e("./services/readhorizon"),N=e("./pushnotification");n.PushNotification=N.PushNotification;var A=e("./util"),D=e("twilsock/lib/services/telemetrytracker"),U=e("twilio-sdk-type-validator"),F=_.Logger.scope("Client"),q=e("./../package.json").version,B=function e(){(0,d.default)(this,e)},z=function(e){function t(e,n){(0,d.default)(this,t);var r=(0,c.default)(this,(t.__proto__||(0,o.default)(t)).call(this));if(r.connectionState="connecting",r.sessionPromise=null,r.conversationsPromise=null,r.version=q,r.parsePushNotification=t.parsePushNotification,r.options=n||{},!r.options.disableDeepClone){var i=(0,a.default)((0,a.default)({},r.options),{transport:void 0,twilsockClient:void 0});(i=A.deepClone(i)).transport=r.options.transport,i.twilsockClient=r.options.twilsockClient,r.options=i}r.options.logLevel=r.options.logLevel||"silent",F.setLevel(r.options.logLevel);var s=r.options.productId="ip_messaging";if(r.options.clientMetadata=r.options.clientMetadata||{},r.options.clientMetadata.hasOwnProperty("type")||(r.options.clientMetadata.type="conversations"),r.options.clientMetadata.hasOwnProperty("sdk")||(r.options.clientMetadata.sdk="JS",r.options.clientMetadata.sdkv=q),r.options.Sync=r.options.Sync||{},void 0===r.options.Sync.enableSessionStorage&&(r.options.Sync.enableSessionStorage=!0),r.options.region&&(r.options.Sync.region=r.options.region),!e)throw new Error("A valid Twilio token should be provided");return r.services=new B,r.config=new k.Configuration(r.options),r.options.twilsockClient=r.options.twilsockClient||new S.Twilsock(e,s,r.options),r.options.transport=r.options.transport||r.options.twilsockClient,r.options.notificationsClient=r.options.notificationsClient||new T.Notifications(e,r.options),r.options.syncClient=r.options.syncClient||new E.SyncClient(e,r.options),r.services.syncClient=r.options.syncClient,r.services.transport=r.options.transport,r.services.twilsockClient=r.options.twilsockClient,r.services.notificationClient=r.options.notificationsClient,r.services.session=new I.Session(r.services,r.config),r.sessionPromise=r.services.session.initialize(),r.services.network=new x.Network(r.config,r.services),r.services.users=new P.Users({session:r.services.session,network:r.services.network,syncClient:r.services.syncClient}),r.services.users.on("userSubscribed",r.emit.bind(r,"userSubscribed")),r.services.users.on("userUpdated",function(e){return r.emit("userUpdated",e)}),r.services.users.on("userUnsubscribed",r.emit.bind(r,"userUnsubscribed")),r.services.twilsockClient.on("tokenAboutToExpire",function(e){return r.emit("tokenAboutToExpire",e)}),r.services.twilsockClient.on("tokenExpired",function(){return r.emit("tokenExpired")}),r.services.twilsockClient.on("connectionError",function(e){return r.emit("connectionError",e)}),r.services.readHorizon=new L.ReadHorizon(r.services),r.services.typingIndicator=new O.TypingIndicator(r.config,{transport:r.services.twilsockClient,notificationClient:r.services.notificationClient},r.getConversationBySid.bind(r)),r.services.syncList=new j.SyncList(r.services),r.conversations=new R.Conversations(r.services),r.conversationsPromise=r.sessionPromise.then(function(){return r.conversations.on("conversationAdded",r.emit.bind(r,"conversationAdded")),r.conversations.on("conversationRemoved",r.emit.bind(r,"conversationRemoved")),r.conversations.on("conversationJoined",r.emit.bind(r,"conversationJoined")),r.conversations.on("conversationLeft",r.emit.bind(r,"conversationLeft")),r.conversations.on("conversationUpdated",function(e){return r.emit("conversationUpdated",e)}),r.conversations.on("participantJoined",r.emit.bind(r,"participantJoined")),r.conversations.on("participantLeft",r.emit.bind(r,"participantLeft")),r.conversations.on("participantUpdated",function(e){return r.emit("participantUpdated",e)}),r.conversations.on("messageAdded",r.emit.bind(r,"messageAdded")),r.conversations.on("messageUpdated",function(e){return r.emit("messageUpdated",e)}),r.conversations.on("messageRemoved",r.emit.bind(r,"messageRemoved")),r.conversations.on("typingStarted",r.emit.bind(r,"typingStarted")),r.conversations.on("typingEnded",r.emit.bind(r,"typingEnded")),r.conversations.fetchConversations()}).then(function(){return r.conversations}),r.services.notificationClient.on("connectionStateChanged",function(e){var t=null;switch(e){case"connected":t="connected";break;case"denied":t="denied";break;case"disconnecting":t="disconnecting";break;case"disconnected":t="disconnected";break;default:t="connecting"}t!==r.connectionState&&(r.connectionState=t,r.emit("connectionStateChanged",r.connectionState))}),r.fpaToken=e,r}return(0,l.default)(t,e),(0,u.default)(t,[{key:"subscribeToPushNotifications",value:function(e){var t=this,n=[];return[C.NotificationTypes.NEW_MESSAGE,C.NotificationTypes.ADDED_TO_CONVERSATION,C.NotificationTypes.REMOVED_FROM_CONVERSATION,C.NotificationTypes.TYPING_INDICATOR,C.NotificationTypes.CONSUMPTION_UPDATE].forEach(function(r){n.push(t.services.notificationClient.subscribe(r,e))}),s.default.all(n)}},{key:"unsubscribeFromPushNotifications",value:function(e){var t=this,n=[];return[C.NotificationTypes.NEW_MESSAGE,C.NotificationTypes.ADDED_TO_CONVERSATION,C.NotificationTypes.REMOVED_FROM_CONVERSATION,C.NotificationTypes.TYPING_INDICATOR,C.NotificationTypes.CONSUMPTION_UPDATE].forEach(function(r){n.push(t.services.notificationClient.unsubscribe(r,e))}),s.default.all(n)}},{key:"initialize",value:function(){var e=(0,i.default)(r.default.mark(function e(){var n,i,s=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionPromise;case 2:return t.supportedPushChannels.forEach(function(e){return s.subscribeToPushNotifications(e)}),e.next=5,this.services.session.getSessionLinks();case 5:return n=e.sent,(i=(0,a.default)(this.options)).transport=null,this.services.mcsClient=new M.McsClient(this.fpaToken,n.mediaServiceUrl,n.mediaSetServiceUrl,i),e.next=11,this.services.typingIndicator.initialize();case 11:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"shutdown",value:function(){var e=(0,i.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.twilsockClient.disconnect();case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateToken",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(F.info("updateToken"),this.fpaToken!==t){e.next=3;break}return e.abrupt("return",this);case 3:return e.next=5,this.services.twilsockClient.updateToken(t).then(function(){return n.fpaToken=t}).then(function(){return n.services.mcsClient.updateToken(t)}).then(function(){return n.sessionPromise});case 5:return e.abrupt("return",this);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getConversationBySid",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.conversations.syncListRead.promise;case 2:return e.next=4,this.conversations.getConversation(t);case 4:if(n=e.sent){e.next=9;break}return e.next=8,this.conversations.getWhisperConversation(t);case 8:n=e.sent;case 9:if(n){e.next=11;break}throw new Error("Conversation with SID "+t+" is not found.");case 11:return e.abrupt("return",n);case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getConversationByUniqueName",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.conversations.syncListRead.promise;case 2:return e.next=4,this.conversations.getConversationByUniqueName(t);case 4:if(n=e.sent){e.next=7;break}throw new Error("Conversation with unique name "+t+" is not found.");case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getSubscribedConversations",value:function(e){return this.conversationsPromise.then(function(t){return t.getConversations(e)})}},{key:"createConversation",value:function(e){return e=e||{},this.conversationsPromise.then(function(t){return t.addConversation(e)})}},{key:"setPushRegistrationId",value:function(){var e=(0,i.default)(r.default.mark(function e(t,n){var i=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.subscribeToPushNotifications(t).then(function(){return i.services.notificationClient.setPushRegistrationId(n,t)});case 2:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"unsetPushRegistrationId",value:function(){var e=(0,i.default)(r.default.mark(function e(n){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(-1!==t.supportedPushChannels.indexOf(n)){e.next=2;break}throw new Error("Invalid or unsupported channelType: "+n);case 2:return e.next=4,this.unsubscribeFromPushNotifications(n);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"handlePushNotification",value:function(){var e=(0,i.default)(r.default.mark(function e(n){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:F.debug("handlePushNotification, notificationPayload=",n),this.emit("pushNotification",t.parsePushNotification(n));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getUser",value:function(e){return this.services.users.getUser(e)}},{key:"getSubscribedUsers",value:function(){var e=(0,i.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.users.getSubscribedUsers());case 1:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"user",get:function(){return this.services.users.myself}},{key:"reachabilityEnabled",get:function(){return this.services.session.reachabilityEnabled}},{key:"token",get:function(){return this.fpaToken}}],[{key:"create",value:function(){var e=(0,i.default)(r.default.mark(function e(n,i){var s,a;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return s=new t(n,i),a="conversations.client.startup",s.services.twilsockClient.addPartialTelemetryEvent(new D.TelemetryEventDescription(a,"Conversations client startup",new Date),a,D.TelemetryPoint.Start),e.next=5,s.initialize();case 5:return s.services.twilsockClient.addPartialTelemetryEvent(new D.TelemetryEventDescription("","",new Date),a,D.TelemetryPoint.End),e.abrupt("return",s);case 7:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"parsePushNotificationChatData",value:function(e){var n={};for(var r in t.supportedPushDataFields)void 0!==e[r]&&null!==e[r]&&("message_index"===r?null!==A.parseToNumber(e[r])&&(n[t.supportedPushDataFields[r]]=Number(e[r])):n[t.supportedPushDataFields[r]]=e[r]);return n}},{key:"parsePushNotification",value:function(e){if(F.debug("parsePushNotification, notificationPayload=",e),void 0!==e.aps){if(!e.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var n=t.parsePushNotificationChatData(e),r=e.aps,i=null,s=null;return"string"==typeof r.alert?i=r.alert||null:(i=r.alert.body||null,s=r.alert.title||null),new N.PushNotification({title:s,body:i,sound:r.sound||null,badge:r.badge||null,action:r.category||null,type:e.twi_message_type,data:n})}if(void 0!==e.data){var a=e.data;if(!a.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var o=t.parsePushNotificationChatData(e.data);return new N.PushNotification({title:a.twi_title||null,body:a.twi_body||null,sound:a.twi_sound||null,badge:null,action:a.twi_action||null,type:a.twi_message_type,data:o})}throw new Error("Provided push notification payload is not Programmable Chat notification")}}]),t}(g.EventEmitter);z.version=q,z.supportedPushChannels=["fcm","apn"],z.supportedPushDataFields={conversation_sid:"conversationSid",message_sid:"messageSid",message_index:"messageIndex"},v([U.validateTypesAsync(U.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",s.default)],z.prototype,"updateToken",null),v([U.validateTypesAsync(U.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",s.default)],z.prototype,"getConversationBySid",null),v([U.validateTypesAsync(U.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",s.default)],z.prototype,"getConversationByUniqueName",null),v([U.validateTypesAsync(["undefined",U.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),y("design:type",Function),y("design:paramtypes",[Object]),y("design:returntype",s.default)],z.prototype,"createConversation",null),v([U.validateTypesAsync(U.literal("fcm","apn"),"string"),y("design:type",Function),y("design:paramtypes",[String,String]),y("design:returntype",s.default)],z.prototype,"setPushRegistrationId",null),v([U.validateTypesAsync(U.literal("fcm","apn")),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",s.default)],z.prototype,"unsetPushRegistrationId",null),v([U.validateTypesAsync(U.pureObject),y("design:type",Function),y("design:paramtypes",[Object]),y("design:returntype",s.default)],z.prototype,"handlePushNotification",null),v([U.validateTypesAsync(U.nonEmptyString),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",s.default)],z.prototype,"getUser",null),v([U.validateTypesAsync("string",["undefined",U.pureObject]),y("design:type",Function),y("design:paramtypes",[String,Object]),y("design:returntype",s.default)],z,"create",null),v([U.validateTypes(U.pureObject),y("design:type",Function),y("design:paramtypes",[Object]),y("design:returntype",N.PushNotification)],z,"parsePushNotification",null),n.Client=z,n.default=z},{"./../package.json":375,"./configuration":3,"./data/conversations":5,"./data/users":8,"./interfaces/notificationtypes":10,"./logger":12,"./pushnotification":16,"./services/network":18,"./services/readhorizon":19,"./services/typingindicator":20,"./session":21,"./synclist":23,"./user":25,"./util":27,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/define-property":37,"babel-runtime/core-js/object/get-own-property-descriptor":38,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/core-js/reflect/metadata":44,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/typeof":56,"babel-runtime/regenerator":57,events:200,"twilio-mcs-client":218,"twilio-notifications":308,"twilio-sdk-type-validator":313,"twilio-sync":321,twilsock:349,"twilsock/lib/services/telemetrytracker":365}],3:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a="/v1/typing",o=function(){function e(t){(0,r.default)(this,e);var n=(t=t||{}).Chat||t.IPMessaging||t||{};this.region=n.region||t.region,this.baseUrl=n.apiUri||n.typingUri||(this.region&&"us1"!==this.region?"https://aim."+this.region+".twilio.com":"https://aim.twilio.com"),this.typingIndicatorUri=this.baseUrl+a,this.typingIndicatorTimeoutOverride=n.typingIndicatorTimeoutOverride,this.httpCacheIntervalOverride=n.httpCacheIntervalOverride,this.consumptionReportIntervalOverride=n.consumptionReportIntervalOverride,this.userInfosToSubscribeOverride=n.userInfosToSubscribeOverride,this.retryWhenThrottledOverride=n.retryWhenThrottledOverride,this.backoffConfigOverride=n.backoffConfigOverride,this.productId=t.productId}return(0,i.default)(e,[{key:"typingIndicatorTimeoutDefault",get:function(){return 5e3}},{key:"httpCacheIntervalDefault",get:function(){return"PT5S"}},{key:"consumptionReportIntervalDefault",get:function(){return"PT5S"}},{key:"userInfosToSubscribeDefault",get:function(){return 100}},{key:"retryWhenThrottledDefault",get:function(){return!0}},{key:"backoffConfigDefault",get:function(){return{min:1e3,max:4e3,maxAttemptsCount:3}}}]),e}();n.Configuration=o},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],4:[function(e,t,n){"use strict";var r=w(e("babel-runtime/core-js/object/keys")),i=w(e("babel-runtime/core-js/get-iterator")),s=w(e("babel-runtime/helpers/toConsumableArray")),a=w(e("babel-runtime/core-js/set")),o=w(e("babel-runtime/core-js/promise")),u=w(e("babel-runtime/core-js/json/stringify")),c=w(e("babel-runtime/core-js/number/is-integer")),l=w(e("babel-runtime/core-js/object/get-prototype-of")),d=w(e("babel-runtime/helpers/possibleConstructorReturn")),f=w(e("babel-runtime/helpers/inherits")),p=w(e("babel-runtime/core-js/map")),h=w(e("babel-runtime/regenerator")),b=w(e("babel-runtime/helpers/asyncToGenerator")),m=w(e("babel-runtime/helpers/classCallCheck")),v=w(e("babel-runtime/helpers/createClass")),y=w(e("babel-runtime/core-js/reflect/metadata")),g=w(e("babel-runtime/core-js/object/define-property")),_=w(e("babel-runtime/helpers/typeof")),k=w(e("babel-runtime/core-js/object/get-own-property-descriptor"));function w(e){return e&&e.__esModule?e:{default:e}}var x=function(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=(0,k.default)(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,_.default)(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&(0,g.default)(t,n,a),a},C=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,_.default)(Reflect))&&"function"==typeof y.default)return(0,y.default)(e,t)};Object.defineProperty(n,"__esModule",{value:!0});var j=e("events"),S=e("./logger"),T=e("./data/participants"),E=e("./participant"),M=e("./data/messages"),I=e("./util"),R=e("twilio-sdk-type-validator"),P=S.Logger.scope("Conversation"),O={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"};function L(e){try{return new Date(e)}catch(e){return null}}var N=function(){function e(t){(0,m.default)(this,e),this.messagesEntity=t,this.attributes={},this.mediaContent=[],this.emailOptions={}}return(0,v.default)(e,[{key:"send",value:function(){var e=(0,b.default)(h.default.mark(function e(){var t;return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.messagesEntity.sendV2(this);case 2:return t=e.sent,e.abrupt("return",I.parseToNumber(t.messageId));case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()}]),e}();n.UnsentMessage=N;var A=function(){function e(t,n){(0,m.default)(this,e),this.limits=t,this.message=new N(n),this.emailBodies=new p.default,this.emailHistories=new p.default}return(0,v.default)(e,[{key:"setBody",value:function(e){return this.message.text=e,this}},{key:"setSubject",value:function(e){return this.message.emailOptions.subject=e,this}},{key:"setAttributes",value:function(e){return this.message.attributes=e,this}},{key:"setEmailBody",value:function(e,t){return this.emailBodies.set(e,t),this}},{key:"setEmailHistory",value:function(e,t){return this.emailHistories.set(e,t),this}},{key:"addMedia",value:function(e){return this.message.mediaContent.push(["media",e]),this}},{key:"build",value:function(){var e=this;if(this.emailBodies.forEach(function(t,n){if(!e.limits.emailBodiesAllowedMimeTypes.includes(n))throw new Error("Unsupported email body MIME type "+n)}),this.emailHistories.forEach(function(t,n){if(!e.limits.emailHistoriesAllowedMimeTypes.includes(n))throw new Error("Unsupported email history MIME type "+n)}),this.emailBodies.size>this.limits.emailBodiesAllowedMimeTypes.length)throw new Error("Email bodies set is too large");if(this.emailHistories.size>this.limits.emailHistoriesAllowedMimeTypes.length)throw new Error("Email histories set is too large");if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message ("+this.message.mediaContent.length+" > "+this.limits.mediaAttachmentsCountLimit+")");return this.emailBodies.forEach(function(t){e.message.mediaContent.push(["body",t])}),this.emailHistories.forEach(function(t){e.message.mediaContent.push(["history",t])}),this.message}},{key:"getPayloadContentType",value:function(e){return"undefined"!=typeof FormData&&e instanceof FormData?e.get("Content-Type"):e.contentType}}]),e}(),D=function(e){function t(e,n,r){var i;(0,m.default)(this,t);var s=(0,d.default)(this,(t.__proto__||(0,l.default)(t)).call(this));s.services=e;var a=n.attributes||{},o=n.createdBy,f=L(n.dateCreated),h=L(n.dateUpdated),b=n.friendlyName||null,v=(0,c.default)(n.lastConsumedMessageIndex)?n.lastConsumedMessageIndex:null,y=n.uniqueName||null;try{(0,u.default)(a)}catch(e){throw new Error("Attributes must be a valid JSON object.")}return s.sid=r,s.entityName=n.channel,s.channelState={uniqueName:y,status:"notParticipating",attributes:a,createdBy:o,dateCreated:f,dateUpdated:h,friendlyName:b,lastReadMessageIndex:v,bindings:(i=n.bindings,null!=i?i:{})},n.notificationLevel&&(s.channelState.notificationLevel=n.notificationLevel),s.participants=new p.default,s.participantsEntity=new T.Participants(s,s.services,s.participants),s.participantsEntity.on("participantJoined",s.emit.bind(s,"participantJoined")),s.participantsEntity.on("participantLeft",s.emit.bind(s,"participantLeft")),s.participantsEntity.on("participantUpdated",function(e){return s.emit("participantUpdated",e)}),s.messagesEntity=new M.Messages(s,e),s.messagesEntity.on("messageAdded",function(e){return s._onMessageAdded(e)}),s.messagesEntity.on("messageUpdated",function(e){return s.emit("messageUpdated",e)}),s.messagesEntity.on("messageRemoved",s.emit.bind(s,"messageRemoved")),s}return(0,f.default)(t,e),(0,v.default)(t,[{key:"_subscribe",value:function(){var e,t=this;return this.entityPromise=null!=(e=this.entityPromise)?e:this.services.syncClient.document({id:this.entityName,mode:"open_existing"}).then(function(e){return t.entity=e,t.entity.on("updated",function(e){t._update(e.data)}),t.entity.on("removed",function(){return t.emit("removed",t)}),t._update(t.entity.data),e}).catch(function(e){throw t.entity=null,t.entityPromise=null,"disconnected"!=t.services.syncClient.connectionState&&P.error("Failed to get conversation object",e),P.debug("ERROR: Failed to get conversation object",e),e})}},{key:"_subscribeStreams",value:function(){var e=(0,b.default)(h.default.mark(function e(){var t,n;return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._subscribe();case 3:return P.trace("_subscribeStreams, this.entity.data=",this.entity.data),t=this.entity.data.messages,n=this.entity.data.roster,e.next=8,o.default.all([this.messagesEntity.subscribe(t),this.participantsEntity.subscribe(n)]);case 8:e.next=15;break;case 10:throw e.prev=10,e.t0=e.catch(0),"disconnected"!==this.services.syncClient.connectionState&&P.error("Failed to subscribe on conversation objects",this.sid,e.t0),P.debug("ERROR: Failed to subscribe on conversation objects",this.sid,e.t0),e.t0;case 15:case"end":return e.stop()}},e,this,[[0,10]])}));return function(){return e.apply(this,arguments)}}()},{key:"_unsubscribe",value:function(){var e=(0,b.default)(h.default.mark(function e(){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.entity){e.next=5;break}return e.next=3,this.entity.close();case 3:this.entity=null,this.entityPromise=null;case 5:return e.abrupt("return",o.default.all([this.participantsEntity.unsubscribe(),this.messagesEntity.unsubscribe()]));case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"_setStatus",value:function(e,t){var n=this;this.statusSource=t,this.channelState.status!==e&&(this.channelState.status=e,"joined"===e?this._subscribeStreams().catch(function(t){if(P.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n.services.syncClient.connectionState)throw t}):this.entityPromise&&this._unsubscribe().catch(function(t){if(P.debug("ERROR while setting conversation status "+e,t),"disconnected"!==n.services.syncClient.connectionState)throw t}))}},{key:"_statusSource",value:function(){return this.statusSource}},{key:"_update",value:function(e){var n,o,u,c,l;P.trace("_update",e),t.preprocessUpdate(e,this.sid);var d=new a.default,f=!0,p=!1,h=void 0;try{for(var b,m=(0,i.default)((0,r.default)(e));!(f=(b=m.next()).done);f=!0){var v=b.value,y=O[v];if(y)switch(y){case O.status:if(!e.status||"unknown"===e.status||this.channelState.status===e.status)break;this.channelState.status=e.status,d.add(y);break;case O.attributes:if(I.isDeepEqual(this.channelState.attributes,e.attributes))break;this.channelState.attributes=e.attributes,d.add(y);break;case O.lastConsumedMessageIndex:if(void 0===e.lastConsumedMessageIndex||e.lastConsumedMessageIndex===this.channelState.lastReadMessageIndex)break;this.channelState.lastReadMessageIndex=e.lastConsumedMessageIndex,d.add("lastReadMessageIndex");break;case O.lastMessage:if(this.channelState.lastMessage&&!e.lastMessage){delete this.channelState.lastMessage,d.add(y);break}this.channelState.lastMessage=this.channelState.lastMessage||{},void 0!==(null===(n=e.lastMessage)||void 0===n?void 0:n.index)&&e.lastMessage.index!==this.channelState.lastMessage.index&&(this.channelState.lastMessage.index=e.lastMessage.index,d.add(y)),void 0!==(null===(o=e.lastMessage)||void 0===o?void 0:o.timestamp)&&(null===(c=null===(u=this.channelState.lastMessage)||void 0===u?void 0:u.dateCreated)||void 0===c?void 0:c.getTime())!==e.lastMessage.timestamp.getTime()&&(this.channelState.lastMessage.dateCreated=e.lastMessage.timestamp,d.add(y)),I.isDeepEqual(this.channelState.lastMessage,{})&&delete this.channelState.lastMessage;break;case O.state:var g=e.state||void 0;if(void 0!==g&&(g.dateUpdated=new Date(g.dateUpdated)),I.isDeepEqual(this.channelState.state,g))break;this.channelState.state=g,d.add(y);break;case O.bindings:if(I.isDeepEqual(this.channelState.bindings,e.bindings))break;this.channelState.bindings=e.bindings,d.add(y);break;default:var _=e[v]instanceof Date,k=_&&(null===(l=this.channelState[y])||void 0===l?void 0:l.getTime())===e[v].getTime(),w=!_&&this[y]===e[v];if(k||w)break;this.channelState[y]=e[v],d.add(y)}}}catch(e){p=!0,h=e}finally{try{!f&&m.return&&m.return()}finally{if(p)throw h}}d.size>0&&this.emit("updated",{conversation:this,updateReasons:[].concat((0,s.default)(d))})}},{key:"_onMessageAdded",value:function(e){var t=!0,n=!1,r=void 0;try{for(var s,a=(0,i.default)(this.participants.values());!(t=(s=a.next()).done);t=!0){var o=s.value;if(o.identity===e.author){o._endTyping();break}}}catch(e){n=!0,r=e}finally{try{!t&&a.return&&a.return()}finally{if(n)throw r}}this.emit("messageAdded",e)}},{key:"add",value:function(){var e=(0,b.default)(h.default.mark(function e(t,n){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.participantsEntity.add(t,n));case 1:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"addNonChatParticipant",value:function(){var e=(0,b.default)(h.default.mark(function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.participantsEntity.addNonChatParticipant(t,n,r));case 1:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"advanceLastReadMessageIndex",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this.services.readHorizon.advanceLastReadMessageIndexForConversation(this.sid,t,this.lastReadMessageIndex));case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"delete",value:function(){var e=(0,b.default)(h.default.mark(function e(){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("destroyChannel",{channelSid:this.sid});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getAttributes",value:function(){var e=(0,b.default)(h.default.mark(function e(){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribe();case 2:return e.abrupt("return",this.attributes);case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getMessages",value:function(){var e=(0,b.default)(h.default.mark(function e(t,n,r){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this.messagesEntity.getMessages(t,n,r));case 3:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"getParticipants",value:function(){var e=(0,b.default)(h.default.mark(function e(){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this.participantsEntity.getParticipants());case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getParticipantsCount",value:function(){var e=(0,b.default)(h.default.mark(function e(){var t,n,r;return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getSessionLinks();case 2:return t=e.sent,n=new I.UriBuilder(t.publicChannelsUrl).path(this.sid).build(),e.next=6,this.services.network.get(n);case 6:return r=e.sent,e.abrupt("return",r.body.members_count);case 8:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getParticipantBySid",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.participantsEntity.getParticipantBySid(t));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getParticipantByIdentity",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.participantsEntity.getParticipantByIdentity(t));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getMessagesCount",value:function(){var e=(0,b.default)(h.default.mark(function e(){var t,n,r;return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getSessionLinks();case 2:return t=e.sent,n=new I.UriBuilder(t.publicChannelsUrl).path(this.sid).build(),e.next=6,this.services.network.get(n);case 6:return r=e.sent,e.abrupt("return",r.body.messages_count);case 8:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getUnreadMessagesCount",value:function(){var e=(0,b.default)(h.default.mark(function e(){var t,n,r;return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getSessionLinks();case 2:return t=e.sent,n=new I.UriBuilder(t.myChannelsUrl).arg("ChannelSid",this.sid).build(),e.next=6,this.services.network.get(n);case 6:if(!(r=e.sent).body.channels.length||r.body.channels[0].channel_sid!=this.sid){e.next=11;break}if(void 0===r.body.channels[0].unread_messages_count||null==r.body.channels[0].unread_messages_count){e.next=10;break}return e.abrupt("return",r.body.channels[0].unread_messages_count);case 10:return e.abrupt("return",null);case 11:throw new Error("Conversation is not in user conversations list");case 12:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"join",value:function(){var e=(0,b.default)(h.default.mark(function e(){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("joinChannelV2",{channelSid:this.sid});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"leave",value:function(){var e=(0,b.default)(h.default.mark(function e(){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("joined"!==this.channelState.status){e.next=3;break}return e.next=3,this.services.session.addCommand("leaveChannel",{channelSid:this.sid});case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"removeParticipant",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t instanceof E.Participant)){e.next=4;break}return e.next=3,this.participantsEntity.removeBySid(t.sid);case 3:return e.abrupt("return");case 4:return e.next=6,this.participantsEntity.removeByIdentity(t);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"sendMessage",value:function(){var e=(0,b.default)(h.default.mark(function e(t,n,r){var i,s;return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("string"!=typeof t&&null!==t){e.next=5;break}return e.next=3,this.messagesEntity.send(t,n,r);case 3:return i=e.sent,e.abrupt("return",I.parseToNumber(i.messageId));case 5:return e.next=7,this.messagesEntity.sendMedia(t,n,r);case 7:return s=e.sent,e.abrupt("return",I.parseToNumber(s.messageId));case 9:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"prepareMessage",value:function(){return new A(this.limits,this.messagesEntity)}},{key:"setAllMessagesRead",value:function(){var e=(0,b.default)(h.default.mark(function e(){var t;return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.next=4,this.getMessages(1);case 4:if(!((t=e.sent).items.length>0)){e.next=7;break}return e.abrupt("return",this.advanceLastReadMessageIndex(t.items[0].index));case 7:return e.abrupt("return",o.default.resolve(0));case 8:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"setAllMessagesUnread",value:function(){var e=(0,b.default)(h.default.mark(function e(){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this.services.readHorizon.updateLastReadMessageIndexForConversation(this.sid,null));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"setUserNotificationLevel",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("editNotificationLevel",{channelSid:this.sid,notificationLevel:t});case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"typing",value:function(){return this.services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("editAttributes",{channelSid:this.sid,attributes:(0,u.default)(t)});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateFriendlyName",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.channelState.friendlyName===t){e.next=3;break}return e.next=3,this.services.session.addCommand("editFriendlyName",{channelSid:this.sid,friendlyName:t});case 3:return e.abrupt("return",this);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateLastReadMessageIndex",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._subscribeStreams();case 2:return e.abrupt("return",this.services.readHorizon.updateLastReadMessageIndexForConversation(this.sid,t));case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateUniqueName",value:function(){var e=(0,b.default)(h.default.mark(function e(t){return h.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.channelState.uniqueName===t){e.next=4;break}return t||(t=""),e.next=4,this.services.session.addCommand("editUniqueName",{channelSid:this.sid,uniqueName:t});case 4:return e.abrupt("return",this);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"uniqueName",get:function(){return this.channelState.uniqueName}},{key:"status",get:function(){return this.channelState.status}},{key:"friendlyName",get:function(){return this.channelState.friendlyName}},{key:"dateUpdated",get:function(){return this.channelState.dateUpdated}},{key:"dateCreated",get:function(){return this.channelState.dateCreated}},{key:"createdBy",get:function(){return this.channelState.createdBy}},{key:"attributes",get:function(){return this.channelState.attributes}},{key:"lastReadMessageIndex",get:function(){return this.channelState.lastReadMessageIndex}},{key:"lastMessage",get:function(){return this.channelState.lastMessage}},{key:"notificationLevel",get:function(){return this.channelState.notificationLevel}},{key:"state",get:function(){return this.channelState.state}},{key:"bindings",get:function(){return this.channelState.bindings}},{key:"limits",get:function(){return this.services.limits}}],[{key:"preprocessUpdate",value:function(e,t){try{"string"==typeof e.attributes?e.attributes=JSON.parse(e.attributes):e.attributes&&(0,u.default)(e.attributes)}catch(n){P.warn("Retrieved malformed attributes from the server for conversation: "+t),e.attributes={}}try{e.dateCreated&&(e.dateCreated=new Date(e.dateCreated))}catch(n){P.warn("Retrieved malformed dateCreated from the server for conversation: "+t),delete e.dateCreated}try{e.dateUpdated&&(e.dateUpdated=new Date(e.dateUpdated))}catch(n){P.warn("Retrieved malformed dateUpdated from the server for conversation: "+t),delete e.dateUpdated}try{e.lastMessage&&e.lastMessage.timestamp&&(e.lastMessage.timestamp=new Date(e.lastMessage.timestamp))}catch(n){P.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+t),delete e.lastMessage.timestamp}}}]),t}(j.EventEmitter);x([R.validateTypesAsync(R.nonEmptyString,["undefined","string","number","boolean","object",R.literal(null)]),C("design:type",Function),C("design:paramtypes",[String,Object]),C("design:returntype",o.default)],D.prototype,"add",null),x([R.validateTypesAsync(R.nonEmptyString,R.nonEmptyString,["undefined","object"]),C("design:type",Function),C("design:paramtypes",[String,String,Object]),C("design:returntype",o.default)],D.prototype,"addNonChatParticipant",null),x([R.validateTypesAsync(R.nonNegativeInteger),C("design:type",Function),C("design:paramtypes",[Number]),C("design:returntype",o.default)],D.prototype,"advanceLastReadMessageIndex",null),x([R.validateTypesAsync(["undefined",R.nonNegativeInteger],["undefined",R.nonNegativeInteger],["undefined",R.literal("backwards","forward")]),C("design:type",Function),C("design:paramtypes",[Number,Number,String]),C("design:returntype",o.default)],D.prototype,"getMessages",null),x([R.validateTypesAsync(R.nonEmptyString),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",o.default)],D.prototype,"getParticipantBySid",null),x([R.validateTypesAsync(R.nonEmptyString),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",o.default)],D.prototype,"getParticipantByIdentity",null),x([R.validateTypesAsync([R.nonEmptyString,E.Participant]),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",o.default)],D.prototype,"removeParticipant",null),x([R.validateTypesAsync(["string",R.literal(null),R.custom(function(e){return[e instanceof FormData,"an instance of FormData"]}),R.objectSchema("media options",{contentType:R.nonEmptyString,media:R.custom(function(e){var t="string"==typeof e&&e.length>0||e instanceof Uint8Array||e instanceof ArrayBuffer;return"function"==typeof Blob&&(t=t||e instanceof Blob),[t,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],["undefined","string","number","boolean","object",R.literal(null)],["undefined",R.literal(null),R.objectSchema("email attributes",{subject:[R.nonEmptyString,"undefined"]})]),C("design:type",Function),C("design:paramtypes",[Object,Object,Object]),C("design:returntype",o.default)],D.prototype,"sendMessage",null),x([R.validateTypesAsync(R.literal("default","muted")),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",o.default)],D.prototype,"setUserNotificationLevel",null),x([R.validateTypesAsync(["string","number","boolean","object",R.literal(null)]),C("design:type",Function),C("design:paramtypes",[Object]),C("design:returntype",o.default)],D.prototype,"updateAttributes",null),x([R.validateTypesAsync(["string",R.literal(null)]),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",o.default)],D.prototype,"updateFriendlyName",null),x([R.validateTypesAsync([R.literal(null),R.nonNegativeInteger]),C("design:type",Function),C("design:paramtypes",[Number]),C("design:returntype",o.default)],D.prototype,"updateLastReadMessageIndex",null),x([R.validateTypesAsync(["string",R.literal(null)]),C("design:type",Function),C("design:paramtypes",[String]),C("design:returntype",o.default)],D.prototype,"updateUniqueName",null),n.Conversation=D},{"./data/messages":6,"./data/participants":7,"./logger":12,"./participant":15,"./util":27,"babel-runtime/core-js/get-iterator":30,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/map":33,"babel-runtime/core-js/number/is-integer":34,"babel-runtime/core-js/object/define-property":37,"babel-runtime/core-js/object/get-own-property-descriptor":38,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/object/keys":40,"babel-runtime/core-js/promise":42,"babel-runtime/core-js/reflect/metadata":44,"babel-runtime/core-js/set":45,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/toConsumableArray":55,"babel-runtime/helpers/typeof":56,"babel-runtime/regenerator":57,events:200,"twilio-sdk-type-validator":313}],5:[function(e,t,n){"use strict";var r,i=m(e("babel-runtime/core-js/promise")),s=m(e("babel-runtime/core-js/json/stringify")),a=m(e("babel-runtime/core-js/set")),o=m(e("babel-runtime/core-js/map")),u=m(e("babel-runtime/core-js/object/get-prototype-of")),c=m(e("babel-runtime/helpers/classCallCheck")),l=m(e("babel-runtime/helpers/createClass")),d=m(e("babel-runtime/helpers/possibleConstructorReturn")),f=m(e("babel-runtime/helpers/inherits")),p=m(e("babel-runtime/regenerator")),h=m(e("babel-runtime/helpers/asyncToGenerator")),b=(r=(0,h.default)(p.default.mark(function e(t){return p.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.session.getMediaLimits();case 2:return e.t0=e.sent,e.t1=t.session,e.t2=t.syncClient,e.t3=t.users,e.t4=t.typingIndicator,e.t5=t.readHorizon,e.t6=t.network,e.t7=t.mcsClient,e.abrupt("return",{limits:e.t0,session:e.t1,syncClient:e.t2,users:e.t3,typingIndicator:e.t4,readHorizon:e.t5,network:e.t6,mcsClient:e.t7});case 11:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)});function m(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var v=e("events"),y=e("../logger"),g=e("../conversation");n.Conversation=g.Conversation;var _=e("../util/deferred"),k=e("../util"),w=y.Logger.scope("Conversations"),x=function(e){function t(e){(0,c.default)(this,t);var n=(0,d.default)(this,(t.__proto__||(0,u.default)(t)).call(this));return n.services=e,n.conversations=new o.default,n.tombstones=new a.default,n.syncListFetched=!1,n.syncListRead=new _.Deferred,n}return(0,f.default)(t,e),(0,l.default)(t,[{key:"getMap",value:function(){var e=this;return this.services.session.getMyConversationsId().then(function(t){return e.services.syncClient.map({id:t,mode:"open_existing"})})}},{key:"addConversation",value:function(){var e=(0,h.default)(p.default.mark(function e(t){var n,r,i,a,o,u;return p.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=void 0,n=void 0===t.attributes?{}:t.attributes,e.next=4,this.services.session.addCommand("createConversation",{friendlyName:t.friendlyName,uniqueName:t.uniqueName,attributes:(0,s.default)(n)});case 4:if(r=e.sent,i="conversationSid"in r?r.conversationSid:null,a="conversation"in r?r.conversation:null,!(o=this.conversations.get(i))){e.next=12;break}return e.next=11,o._subscribe();case 11:return e.abrupt("return",o);case 12:return e.t0=g.Conversation,e.next=15,b(this.services);case 15:return e.t1=e.sent,e.t2={channel:a,entityName:null,uniqueName:null,attributes:null,createdBy:null,friendlyName:null,lastConsumedMessageIndex:null,dateCreated:null,dateUpdated:null},e.t3=i,u=new e.t0(e.t1,e.t2,e.t3),this.conversations.set(u.sid,u),this.registerForEvents(u),e.next=23,u._subscribe();case 23:return this.emit("conversationAdded",u),e.abrupt("return",u);case 25:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"fetchConversations",value:function(){var e,t=this;this.getMap().then((e=(0,h.default)(p.default.mark(function e(n){var r,s;return p.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n.on("itemAdded",function(e){w.debug("itemAdded: "+e.item.key),t.upsertConversation("sync",e.item.key,e.item.data)}),n.on("itemRemoved",function(e){w.debug("itemRemoved: "+e.key);var n=e.key;t.syncListFetched||t.tombstones.add(n);var r=t.conversations.get(n);r&&(r&&"joined"===r.status&&(r._setStatus("notParticipating","sync"),t.emit("conversationLeft",r)),t.conversations.delete(n),t.emit("conversationRemoved",r),r.emit("removed",r))}),n.on("itemUpdated",function(e){w.debug("itemUpdated: "+e.item.key),t.upsertConversation("sync",e.item.key,e.item.data)}),r=[],e.next=6,t.services.syncList.getPage();case 6:s=e.sent,s.items.forEach(function(e){r.push(t.upsertConversation("synclist",e.channel_sid,e))});case 9:if(!s.hasNextPage){e.next=16;break}return e.next=12,s.nextPage();case 12:(s=e.sent).items.forEach(function(e){r.push(t.upsertConversation("synclist",e.channel_sid,e))}),e.next=9;break;case 16:return t.syncListRead.set(!0),e.abrupt("return",i.default.all(r));case 18:case"end":return e.stop()}},e,t)})),function(t){return e.apply(this,arguments)})).then(function(){t.syncListFetched=!0,t.tombstones.clear(),w.debug("Conversations list fetched")}).then(function(){return t}).catch(function(e){throw"disconnected"!=t.services.syncClient.connectionState&&w.error("Failed to get conversations list",e),w.debug("ERROR: Failed to get conversations list",e),e})}},{key:"_wrapPaginator",value:function(e,t){var n=this;return t(e.items).then(function(r){return{items:r,hasNextPage:e.hasNextPage,hasPrevPage:e.hasPrevPage,nextPage:function(){return e.nextPage().then(function(e){return n._wrapPaginator(e,t)})},prevPage:function(){return e.prevPage().then(function(e){return n._wrapPaginator(e,t)})}}})}},{key:"getConversations",value:function(e){var t=this;return this.getMap().then(function(t){return t.getItems(e)}).then(function(e){return t._wrapPaginator(e,function(e){return i.default.all(e.map(function(e){return t.upsertConversation("sync",e.key,e.data)}))})})}},{key:"getConversation",value:function(e){var t=this;return this.getMap().then(function(t){return t.getItems({key:e})}).then(function(e){return e.items.map(function(e){return t.upsertConversation("sync",e.key,e.data)})}).then(function(e){return e.length>0?e[0]:null})}},{key:"getConversationByUniqueName",value:function(){var e=(0,h.default)(p.default.mark(function e(t){var n,r,i,s,a,o,u,c;return p.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getSessionLinks();case 2:return i=e.sent,s=new k.UriBuilder(i.myChannelsUrl).path(t).build(),e.next=6,this.services.network.get(s);case 6:return a=e.sent,o=a.body,u=o.channel_sid,c={entityName:null,lastConsumedMessageIndex:o.last_consumed_message_index,status:(null===(n=o)||void 0===n?void 0:n.status)||"unknown",friendlyName:o.friendly_name,dateUpdated:o.date_updated,dateCreated:o.date_created,uniqueName:o.unique_name,createdBy:o.created_by,attributes:o.attributes,channel:u+".channel",notificationLevel:null===(r=o)||void 0===r?void 0:r.notification_level,sid:u},e.abrupt("return",this.upsertConversation("sync",u,c));case 11:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getWhisperConversation",value:function(){var e=(0,h.default)(p.default.mark(function e(t){var n,r,i,s,a,o,u;return p.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getSessionLinks();case 2:return i=e.sent,s=new k.UriBuilder(i.publicChannelsUrl).path(t).build(),e.next=6,this.services.network.get(s);case 6:if(a=e.sent,"private"===(o=a.body).type){e.next=10;break}return e.abrupt("return",null);case 10:return u={entityName:null,lastConsumedMessageIndex:o.last_consumed_message_index,status:(null===(n=o)||void 0===n?void 0:n.status)||"unknown",friendlyName:o.friendly_name,dateUpdated:o.date_updated,dateCreated:o.date_created,uniqueName:o.unique_name,createdBy:o.created_by,attributes:o.attributes,channel:t+".channel",notificationLevel:null===(r=o)||void 0===r?void 0:r.notification_level,sid:t},e.abrupt("return",this.upsertConversation("sync",t,u));case 12:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"upsertConversation",value:function(){var e=(0,h.default)(p.default.mark(function e(t,n,r){var i,s,a=this;return p.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(w.trace("upsertConversation(sid="+n+", data=",r),!(i=this.conversations.get(n))){e.next=6;break}return w.trace("upsertConversation: conversation "+n+" is known and it's status is known from source "+i._statusSource()+" and update came from source "+t,i),void 0===i._statusSource()||t===i._statusSource()||"synclist"===t&&"sync"!==i._statusSource()||"sync"===t?"joined"===r.status&&"joined"!==i.status?(i._setStatus("joined",t),s={},void 0!==r.notificationLevel&&(s.notificationLevel=r.notificationLevel),void 0!==r.lastConsumedMessageIndex&&(s.lastConsumedMessageIndex=r.lastConsumedMessageIndex),k.isDeepEqual(s,{})||i._update(s),i._subscribe().then(function(){a.emit("conversationJoined",i)})):"notParticipating"===r.status&&"joined"===i.status?(i._setStatus("notParticipating",t),i._update(r),i._subscribe().then(function(){a.emit("conversationLeft",i)})):"notParticipating"===r.status?i._subscribe():i._update(r):w.trace("upsertConversation: conversation is known from sync and came from chat, ignoring",{sid:n,data:r.status,conversation:i.status}),e.abrupt("return",i._subscribe().then(function(){return i}));case 6:if("chat"!==t&&"synclist"!==t||!this.tombstones.has(n)){e.next=9;break}return w.trace("upsertConversation: conversation is deleted and came again from chat, ignoring",n),e.abrupt("return");case 9:return w.trace("upsertConversation: creating local conversation object with sid "+n,r),e.t0=g.Conversation,e.next=13,b(this.services);case 13:return e.t1=e.sent,e.t2=r,e.t3=n,i=new e.t0(e.t1,e.t2,e.t3),this.conversations.set(n,i),e.abrupt("return",i._subscribe().then(function(){return a.registerForEvents(i),a.emit("conversationAdded",i),"joined"===r.status&&(i._setStatus("joined",t),a.emit("conversationJoined",i)),i}));case 19:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"onConversationRemoved",value:function(e){var t=this.conversations.get(e);t&&(this.conversations.delete(e),this.emit("conversationRemoved",t))}},{key:"registerForEvents",value:function(e){var t=this;e.on("removed",function(){return t.onConversationRemoved(e.sid)}),e.on("updated",function(e){return t.emit("conversationUpdated",e)}),e.on("participantJoined",this.emit.bind(this,"participantJoined")),e.on("participantLeft",this.emit.bind(this,"participantLeft")),e.on("participantUpdated",function(e){return t.emit("participantUpdated",e)}),e.on("messageAdded",this.emit.bind(this,"messageAdded")),e.on("messageUpdated",function(e){return t.emit("messageUpdated",e)}),e.on("messageRemoved",this.emit.bind(this,"messageRemoved")),e.on("typingStarted",this.emit.bind(this,"typingStarted")),e.on("typingEnded",this.emit.bind(this,"typingEnded"))}}]),t}(v.EventEmitter);n.Conversations=x},{"../conversation":4,"../logger":12,"../util":27,"../util/deferred":26,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/map":33,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/core-js/set":45,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200}],6:[function(e,t,n){"use strict";var r=m(e("babel-runtime/core-js/promise")),i=m(e("babel-runtime/core-js/get-iterator")),s=m(e("babel-runtime/core-js/json/stringify")),a=m(e("babel-runtime/helpers/toConsumableArray")),o=m(e("babel-runtime/helpers/slicedToArray")),u=m(e("babel-runtime/regenerator")),c=m(e("babel-runtime/helpers/asyncToGenerator")),l=m(e("babel-runtime/core-js/map")),d=m(e("babel-runtime/core-js/object/get-prototype-of")),f=m(e("babel-runtime/helpers/classCallCheck")),p=m(e("babel-runtime/helpers/createClass")),h=m(e("babel-runtime/helpers/possibleConstructorReturn")),b=m(e("babel-runtime/helpers/inherits"));function m(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var v=e("events"),y=e("../logger"),g=e("../message"),_=y.Logger.scope("Messages"),k=function(e){function t(e,n){(0,f.default)(this,t);var r=(0,h.default)(this,(t.__proto__||(0,d.default)(t)).call(this));return r.conversation=e,r.services=n,r.messagesByIndex=new l.default,r.messagesListPromise=null,r}return(0,b.default)(t,e),(0,p.default)(t,[{key:"subscribe",value:function(e){var t=this;return this.messagesListPromise=this.messagesListPromise||this.services.syncClient.list({id:e,mode:"open_existing"}).then(function(e){return e.on("itemAdded",function(e){_.debug(t.conversation.sid+" itemAdded: "+e.item.index);var n=new g.Message(t.conversation,t.services,e.item.index,e.item.data);t.messagesByIndex.has(n.index)?_.debug("Message arrived, but already known and ignored",t.conversation.sid,n.index):(t.messagesByIndex.set(n.index,n),n.on("updated",function(e){return t.emit("messageUpdated",e)}),t.emit("messageAdded",n))}),e.on("itemRemoved",function(e){_.debug(t.conversation.sid+" itemRemoved: "+e.index);var n=e.index;if(t.messagesByIndex.has(n)){var r=t.messagesByIndex.get(n);t.messagesByIndex.delete(r.index),r.removeAllListeners("updated"),t.emit("messageRemoved",r)}}),e.on("itemUpdated",function(e){_.debug(t.conversation.sid+" itemUpdated: "+e.item.index);var n=t.messagesByIndex.get(e.item.index);n&&n._update(e.item.data)}),e}).catch(function(e){throw t.messagesListPromise=null,"disconnected"!=t.services.syncClient.connectionState&&_.error("Failed to get messages object for conversation",t.conversation.sid,e),_.debug("ERROR: Failed to get messages object for conversation",t.conversation.sid,e),e})}},{key:"unsubscribe",value:function(){var e=(0,c.default)(u.default.mark(function e(){return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.messagesListPromise){e.next=6;break}return e.next=3,this.messagesListPromise;case 3:e.sent.close(),this.messagesListPromise=null;case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"sendV2",value:function(){var e=(0,c.default)(u.default.mark(function e(t){var n,r,c,l,d,f,p,h,b,m,v,y;return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:_.debug("Sending message V2",t.mediaContent,t.attributes,t.emailOptions),r=new Array,c=!0,l=!1,d=void 0,e.prev=5,f=(0,i.default)(t.mediaContent);case 7:if(c=(p=f.next()).done){e.next=33;break}if(h=p.value,b=(0,o.default)(h,2),m=b[0],v=b[1],!("undefined"!=typeof FormData&&v instanceof FormData)){e.next=21;break}return _.debug("Adding media to a message as FormData",v),e.t0=r,e.next=17,this.services.mcsClient.postFormData(v,m);case 17:e.t1=e.sent,e.t0.push.call(e.t0,e.t1),e.next=30;break;case 21:if(_.debug("Adding media to a message as SendMediaOptions",v),(y=v).contentType&&y.media){e.next=25;break}throw new Error("Media content <Conversation#SendMediaOptions> must contain non-empty contentType and media");case 25:return e.t2=r,e.next=28,this.services.mcsClient.post(y.contentType,y.media,m);case 28:e.t3=e.sent,e.t2.push.call(e.t2,e.t3);case 30:c=!0,e.next=7;break;case 33:e.next=39;break;case 35:e.prev=35,e.t4=e.catch(5),l=!0,d=e.t4;case 39:e.prev=39,e.prev=40,!c&&f.return&&f.return();case 42:if(e.prev=42,!l){e.next=45;break}throw d;case 45:return e.finish(42);case 46:return e.finish(39);case 47:return e.abrupt("return",this.services.session.addCommand("sendMessageV2",{conversationSid:this.conversation.sid,text:t.text,subject:null===(n=t.emailOptions)||void 0===n?void 0:n.subject,mediaSids:[].concat((0,a.default)(r.map(function(e){return e.sid}))),attributes:(0,s.default)(t.attributes)}));case 48:case"end":return e.stop()}},e,this,[[5,35,39,47],[40,,42,46]])}));return function(t){return e.apply(this,arguments)}}()},{key:"send",value:function(){var e=(0,c.default)(u.default.mark(function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments[2];return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return _.debug("Sending text message",t,r,i),e.abrupt("return",this.services.session.addCommand("sendMessage",{channelSid:this.conversation.sid,text:t,attributes:(0,s.default)(r),subject:null===(n=i)||void 0===n?void 0:n.subject}));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"sendMedia",value:function(){var e=(0,c.default)(u.default.mark(function e(t){var n,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments[2];return u.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(_.debug("Sending media message",t,i,a),n=void 0,!("undefined"!=typeof FormData&&t instanceof FormData)){e.next=9;break}return _.debug("Sending media message as FormData",t,i),e.next=6,this.services.mcsClient.postFormData(t);case 6:n=e.sent,e.next=16;break;case 9:if(_.debug("Sending media message as SendMediaOptions",t,i),(r=t).contentType&&r.media){e.next=13;break}throw new Error("Media content <Conversation#SendMediaOptions> must contain non-empty contentType and media");case 13:return e.next=15,this.services.mcsClient.post(r.contentType,r.media);case 15:n=e.sent;case 16:return e.abrupt("return",this.services.session.addCommand("sendMediaMessage",{channelSid:this.conversation.sid,mediaSid:n.sid,attributes:(0,s.default)(i)}));case 17:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getMessages",value:function(e,t,n){return t=void 0!==t?t:"end",n=n||"backwards",this._getMessages(e,t,n)}},{key:"wrapPaginator",value:function(e,t,n){var r=this,i="desc"===e,s=function(){return t.nextPage().then(function(t){return r.wrapPaginator(e,t,n)})},a=function(){return t.prevPage().then(function(t){return r.wrapPaginator(e,t,n)})};return n(t.items).then(function(e){return{items:e.sort(function(e,t){return e.index-t.index}),hasPrevPage:i?t.hasNextPage:t.hasPrevPage,hasNextPage:i?t.hasPrevPage:t.hasNextPage,prevPage:i?s:a,nextPage:i?a:s}})}},{key:"_upsertMessage",value:function(e,t){var n=this,r=this.messagesByIndex.get(e);if(r)return r;var i=new g.Message(this.conversation,this.services,e,t);return this.messagesByIndex.set(i.index,i),i.on("updated",function(e){return n.emit("messageUpdated",e)}),i}},{key:"_getMessages",value:function(e,t,n){var i=this;t=void 0!==t?t:"end",e=e||30;var s="backwards"===n?"desc":"asc";return this.messagesListPromise.then(function(n){return n.getItems({from:"end"!==t?t:void 0,pageSize:e,order:s})}).then(function(e){return i.wrapPaginator(s,e,function(e){return r.default.all(e.map(function(e){return i._upsertMessage(e.index,e.data)}))})})}}]),t}(v.EventEmitter);n.Messages=k},{"../logger":12,"../message":14,"babel-runtime/core-js/get-iterator":30,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/map":33,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/slicedToArray":54,"babel-runtime/helpers/toConsumableArray":55,"babel-runtime/regenerator":57,events:200}],7:[function(e,t,n){"use strict";var r=f(e("babel-runtime/core-js/json/stringify")),i=f(e("babel-runtime/core-js/promise")),s=f(e("babel-runtime/regenerator")),a=f(e("babel-runtime/helpers/asyncToGenerator")),o=f(e("babel-runtime/core-js/object/get-prototype-of")),u=f(e("babel-runtime/helpers/classCallCheck")),c=f(e("babel-runtime/helpers/createClass")),l=f(e("babel-runtime/helpers/possibleConstructorReturn")),d=f(e("babel-runtime/helpers/inherits"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("events"),h=e("../participant"),b=e("../logger").Logger.scope("Participants"),m=function(e){function t(e,n,r){(0,u.default)(this,t);var i=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this));return i.services=n,i.conversation=e,i.participants=r,i}return(0,d.default)(t,e),(0,c.default)(t,[{key:"unsubscribe",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.rosterEntityPromise){e.next=6;break}return e.next=3,this.rosterEntityPromise;case 3:e.sent.close(),this.rosterEntityPromise=null;case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"subscribe",value:function(e){var t=this;return this.rosterEntityPromise=this.rosterEntityPromise||this.services.syncClient.map({id:e,mode:"open_existing"}).then(function(e){e.on("itemAdded",function(e){b.debug(t.conversation.sid+" itemAdded: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data).then(function(e){t.emit("participantJoined",e)})}),e.on("itemRemoved",function(e){b.debug(t.conversation.sid+" itemRemoved: "+e.key);var n=e.key;if(t.participants.has(n)){var r=t.participants.get(n);t.participants.delete(n),t.emit("participantLeft",r)}}),e.on("itemUpdated",function(e){b.debug(t.conversation.sid+" itemUpdated: "+e.item.key),t.upsertParticipant(e.item.key,e.item.data)});var n=[],r=t;return e.getItems().then(function e(t){return t.items.forEach(function(e){n.push(r.upsertParticipant(e.key,e.data))}),t.hasNextPage?t.nextPage().then(e):null}).then(function(){return i.default.all(n)}).then(function(){return e})}).catch(function(e){throw t.rosterEntityPromise=null,"disconnected"!=t.services.syncClient.connectionState&&b.error("Failed to get roster object for conversation",t.conversation.sid,e),b.debug("ERROR: Failed to get roster object for conversation",t.conversation.sid,e),e})}},{key:"upsertParticipant",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){var r,i=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this.participants.get(t))){e.next=3;break}return e.abrupt("return",r._update(n));case 3:return r=new h.Participant(this.services,this.conversation,n,t),this.participants.set(t,r),r.on("updated",function(e){return i.emit("participantUpdated",e)}),e.abrupt("return",r);case 7:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"getParticipants",value:function(){var e=(0,a.default)(s.default.mark(function e(){var t=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise.then(function(){var e=[];return t.participants.forEach(function(t){return e.push(t)}),e}));case 1:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getParticipantBySid",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rosterEntityPromise.then(function(){var e=n.participants.get(t);if(!e)throw new Error("Participant with SID "+t+" was not found");return e}));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getParticipantByIdentity",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,r=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=null,e.abrupt("return",this.rosterEntityPromise.then(function(){if(r.participants.forEach(function(e){e.identity===t&&(n=e)}),!n)throw new Error("Participant with identity "+t+" was not found");return n}));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"add",value:function(e,t){return this.services.session.addCommand("addMemberV2",{channelSid:this.conversation.sid,attributes:(0,r.default)(t),username:e})}},{key:"addNonChatParticipant",value:function(e,t){var n,i,s,a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.services.session.addCommand("addNonChatParticipant",{conversationSid:this.conversation.sid,proxyAddress:e,attributes:(0,r.default)(o),address:t,name:null===(i=null===(n=u)||void 0===n?void 0:n.email)||void 0===i?void 0:i.name,level:null===(a=null===(s=u)||void 0===s?void 0:s.email)||void 0===a?void 0:a.level})}},{key:"invite",value:function(e){return this.services.session.addCommand("inviteMember",{channelSid:this.conversation.sid,username:e})}},{key:"removeByIdentity",value:function(e){return this.services.session.addCommand("removeMember",{channelSid:this.conversation.sid,username:e})}},{key:"removeBySid",value:function(e){return this.services.session.addCommand("removeMember",{channelSid:this.conversation.sid,memberSid:e})}}]),t}(p.EventEmitter);n.Participants=m},{"../logger":12,"../participant":15,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200}],8:[function(e,t,n){"use strict";var r=d(e("babel-runtime/regenerator")),i=d(e("babel-runtime/helpers/asyncToGenerator")),s=d(e("babel-runtime/core-js/map")),a=d(e("babel-runtime/core-js/object/get-prototype-of")),o=d(e("babel-runtime/helpers/classCallCheck")),u=d(e("babel-runtime/helpers/createClass")),c=d(e("babel-runtime/helpers/possibleConstructorReturn")),l=d(e("babel-runtime/helpers/inherits"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var f=e("events"),p=e("../user"),h=e("../util"),b=function(e){function t(e){(0,o.default)(this,t);var n=(0,c.default)(this,(t.__proto__||(0,a.default)(t)).call(this));return n.services=e,n.fifoStack=[],n.fifoStackMaxLength=100,n.myself=new p.User(null,null,n.services),n.myself.on("updated",function(e){return n.emit("userUpdated",e)}),n.myself.on("userSubscribed",function(){return n.emit("userSubscribed",n.myself)}),n.myself.on("userUnsubscribed",function(){n.emit("userUnsubscribed",n.myself),n.myself._ensureFetched()}),n.services=e,n.subscribedUsers=new s.default,n.userUrlPromise=n.services.session.getSessionLinks().then(function(e){return n.userUrl=e.usersUrl,n.userUrl}),n.services.session.getMaxUserInfosToSubscribe().then(function(e){n.fifoStackMaxLength=e}),n.services.session.getUsersData().then(function(e){return n.myself.identity=e.identity,n.myself.entityName=e.user,n.myself._ensureFetched()}),n}return(0,l.default)(t,e),(0,u.default)(t,[{key:"handleUnsubscribeUser",value:function(e){this.subscribedUsers.has(e.identity)&&this.subscribedUsers.delete(e.identity);var t=-1;this.fifoStack.find(function(n,r){return n==e.identity&&(t=r,!0)})&&this.fifoStack.splice(t,1),this.emit("userUnsubscribed",e)}},{key:"handleSubscribeUser",value:function(e){this.subscribedUsers.has(e.identity)||(this.fifoStack.length>=this.fifoStackMaxLength&&this.subscribedUsers.get(this.fifoStack.shift()).unsubscribe(),this.fifoStack.push(e.identity),this.subscribedUsers.set(e.identity,e),this.emit("userSubscribed",e))}},{key:"getUser",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n,i=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getUsersData();case 2:return e.next=4,this.myself._ensureFetched();case 4:if(t!=this.myself.identity){e.next=6;break}return e.abrupt("return",this.myself);case 6:if(n=this.subscribedUsers.get(t)){e.next=18;break}if(s){e.next=12;break}return e.next=11,this.getSyncUniqueName(t);case 11:s=e.sent;case 12:return(n=new p.User(t,s,this.services)).on("updated",function(e){return i.emit("userUpdated",e)}),n.on("userSubscribed",function(){return i.handleSubscribeUser(n)}),n.on("userUnsubscribed",function(){return i.handleUnsubscribeUser(n)}),e.next=18,n._ensureFetched();case 18:return e.abrupt("return",n);case 19:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getSubscribedUsers",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getUsersData();case 2:return e.next=4,this.myself._ensureFetched();case 4:return t=[this.myself],this.subscribedUsers.forEach(function(e){return t.push(e)}),e.abrupt("return",t);case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getSyncUniqueName",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n,i;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=new h.UriBuilder(this.userUrl).path(t).build(),e.next=3,this.services.network.get(n);case 3:return i=e.sent,e.abrupt("return",i.body.sync_unique_name);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),t}(f.EventEmitter);n.Users=b},{"../user":25,"../util":27,"babel-runtime/core-js/map":33,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200}],9:[function(e,t,n){"use strict";var r,i=e("babel-runtime/helpers/classCallCheck"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});n.DetailedDeliveryReceipt=function e(t){(0,s.default)(this,e),this.sid=t.sid,this.messageSid=t.message_sid,this.conversationSid=t.conversation_sid,this.channelMessageSid=t.channel_message_sid,this.participantSid=t.participant_sid,this.status=t.status||"queued",this.errorCode=t.error_code||0,this.dateCreated=t.date_created,this.dateUpdated=t.date_updated}},{"babel-runtime/helpers/classCallCheck":49}],10:[function(e,t,n){"use strict";var r,i=e("babel-runtime/helpers/classCallCheck"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});var a=function e(){(0,s.default)(this,e)};n.NotificationTypes=a,a.TYPING_INDICATOR="twilio.ipmsg.typing_indicator",a.NEW_MESSAGE="twilio.conversations.new_message",a.ADDED_TO_CONVERSATION="twilio.conversations.added_to_conversation",a.REMOVED_FROM_CONVERSATION="twilio.conversations.removed_from_conversation",a.CONSUMPTION_UPDATE="twilio.channel.consumption_update"},{"babel-runtime/helpers/classCallCheck":49}],11:[function(e,t,n){"use strict";var r,i=e("babel-runtime/helpers/classCallCheck"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});var a=function e(){(0,s.default)(this,e)};n.ResponseCodes=a,a.HTTP_200_OK=200,a.HTTP_400_BAD_REQUEST=400,a.HTTP_404_NOT_FOUND=404,a.ACCESS_FORBIDDEN_FOR_IDENTITY=54007,a.LIST_NOT_FOUND=54150},{"babel-runtime/helpers/classCallCheck":49}],12:[function(e,t,n){"use strict";var r=a(e("babel-runtime/helpers/classCallCheck")),i=a(e("babel-runtime/helpers/createClass")),s=a(e("babel-runtime/core-js/array/from"));function a(e){return e&&e.__esModule?e:{default:e}}function o(e,t){return[(new Date).toISOString()+" Conversations "+e+":"].concat((0,s.default)(t))}Object.defineProperty(n,"__esModule",{value:!0});var u=e("loglevel").getLogger("twilio-conversations"),c=function(){function e(t){(0,r.default)(this,e),this.prefix="",this.prefix=null!=t&&t.length>0?t+" ":""}return(0,i.default)(e,[{key:"setLevel",value:function(e){u.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.trace.apply(null,o(this.prefix+"T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.debug.apply(null,o(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.info.apply(null,o(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.warn.apply(null,o(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.error.apply(null,o(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){u.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.trace.apply(null,o("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.debug.apply(null,o("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.info.apply(null,o("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.warn.apply(null,o("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];u.error.apply(null,o("E",t))}}]),e}();n.Logger=c},{"babel-runtime/core-js/array/from":29,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,loglevel:203}],13:[function(e,t,n){"use strict";var r=o(e("babel-runtime/regenerator")),i=o(e("babel-runtime/helpers/asyncToGenerator")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=e("twilio-mcs-client"),c=function(){function e(t,n){(0,s.default)(this,e),this.mcsMedia=null,this.services=n,t instanceof u.McsMedia&&(this.mcsMedia=t),this.state={sid:t.sid,category:t.category,filename:t.filename,contentType:t.contentType,size:t.size}}return(0,a.default)(e,[{key:"getContentTemporaryUrl",value:function(){var e=(0,i.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._fetchMcsMedia();case 2:return e.abrupt("return",this.mcsMedia.getContentUrl());case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getCachedTemporaryUrl",value:function(){var e=(0,i.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._fetchMcsMedia();case 2:return e.abrupt("return",this.mcsMedia.getCachedContentUrl());case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"_fetchMcsMedia",value:function(){var e=(0,i.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mcsMedia){e.next=8;break}if(!this.services.mcsClient){e.next=7;break}return e.next=4,this.services.mcsClient.get(this.state.sid);case 4:this.mcsMedia=e.sent,e.next=8;break;case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"category",get:function(){return this.state.category}},{key:"size",get:function(){return this.state.size}}]),e}();n.Media=c},{"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57,"twilio-mcs-client":218}],14:[function(e,t,n){"use strict";var r=v(e("babel-runtime/core-js/promise")),i=v(e("babel-runtime/core-js/json/stringify")),s=v(e("babel-runtime/helpers/toConsumableArray")),a=v(e("babel-runtime/regenerator")),o=v(e("babel-runtime/helpers/asyncToGenerator")),u=v(e("babel-runtime/core-js/object/get-prototype-of")),c=v(e("babel-runtime/helpers/classCallCheck")),l=v(e("babel-runtime/helpers/createClass")),d=v(e("babel-runtime/helpers/possibleConstructorReturn")),f=v(e("babel-runtime/helpers/inherits")),p=v(e("babel-runtime/core-js/reflect/metadata")),h=v(e("babel-runtime/core-js/object/define-property")),b=v(e("babel-runtime/helpers/typeof")),m=v(e("babel-runtime/core-js/object/get-own-property-descriptor"));function v(e){return e&&e.__esModule?e:{default:e}}var y=function(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=(0,m.default)(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,b.default)(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&(0,h.default)(t,n,a),a},g=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,b.default)(Reflect))&&"function"==typeof p.default)return(0,p.default)(e,t)};Object.defineProperty(n,"__esModule",{value:!0});var _=e("events"),k=e("./util"),w=e("./logger"),x=e("./media"),C=e("./aggregateddeliveryreceipt"),j=e("twilio-sdk-type-validator"),S=e("./restpaginator"),T=e("./detaileddeliveryreceipt"),E=w.Logger.scope("Message"),M=function(e){function t(e,n,r,i){var s,a,o,l,f;(0,c.default)(this,t);var p=(0,d.default)(this,(t.__proto__||(0,u.default)(t)).call(this));return p.conversation=e,p.services=n,p.state={sid:i.sid,index:r,author:(s=i.author,null!=s?s:null),subject:(a=i.subject,null!=a?a:null),body:i.text,timestamp:i.timestamp?new Date(i.timestamp):null,dateUpdated:i.dateUpdated?new Date(i.dateUpdated):null,lastUpdatedBy:(o=i.lastUpdatedBy,null!=o?o:null),attributes:k.parseAttributes(i.attributes,"Got malformed attributes for the message "+i.sid,E),type:(l=i.type,null!=l?l:"text"),media:i.type&&"media"===i.type&&i.media?new x.Media(i.media,p.services):null,medias:i.type&&"media"===i.type&&i.medias?i.medias.map(function(e){return new x.Media(e,p.services)}):null,participantSid:(f=i.memberSid,null!=f?f:null),aggregatedDeliveryReceipt:i.delivery?new C.AggregatedDeliveryReceipt(i.delivery):null},p}return(0,f.default)(t,e),(0,l.default)(t,[{key:"getMediaByCategory",value:function(e){var t;return null===(t=this.state.medias)||void 0===t?void 0:t.filter(function(t){return e.includes(t.category)})}},{key:"getEmailBody",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!=(t=null===(e=this.getMediaByCategory(["body"]))||void 0===e?void 0:e.filter(function(e){return e.contentType==n}).shift())?t:null}},{key:"getEmailHistory",value:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"text/plain";return null!=(t=null===(e=this.getMediaByCategory(["history"]))||void 0===e?void 0:e.filter(function(e){return e.contentType==n}).shift())?t:null}},{key:"_update",value:function(e){var t=[];!e.text&&"string"!=typeof e.text||e.text===this.state.body||(this.state.body=e.text,t.push("body")),e.subject&&e.subject!==this.state.subject&&(this.state.subject=e.subject,t.push("subject")),e.lastUpdatedBy&&e.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=e.lastUpdatedBy,t.push("lastUpdatedBy")),e.author&&e.author!==this.state.author&&(this.state.author=e.author,t.push("author")),e.dateUpdated&&new Date(e.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(e.dateUpdated),t.push("dateUpdated")),e.timestamp&&new Date(e.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(e.timestamp),t.push("dateCreated"));var n=k.parseAttributes(e.attributes,"Got malformed attributes for the message "+this.sid,E);k.isDeepEqual(this.state.attributes,n)||(this.state.attributes=n,t.push("attributes"));var r=e.delivery,i=this.state.aggregatedDeliveryReceipt;!!(r&&r.total&&r.delivered&&r.failed&&r.read&&r.sent&&r.undelivered)&&(i?i._isEquals(r)||(i._update(r),t.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new C.AggregatedDeliveryReceipt(r),t.push("deliveryReceipt"))),t.length>0&&this.emit("updated",{message:this,updateReasons:t})}},{key:"getParticipant",value:function(){var e=(0,o.default)(a.default.mark(function e(){var t,n,r=this;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=null,!this.state.participantSid){e.next=5;break}return e.next=4,this.conversation.getParticipantBySid(this.participantSid).catch(function(){return E.debug('Participant with sid "'+r.participantSid+'" not found for message '+r.sid),null});case 4:t=e.sent;case 5:if(t||!this.state.author){e.next=9;break}return e.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch(function(){return E.debug('Participant with identity "'+r.author+'" not found for message '+r.sid),null});case 8:t=e.sent;case 9:if(!t){e.next=11;break}return e.abrupt("return",t);case 11:throw n="Participant with ",this.state.participantSid&&(n+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(n+="or "),n+="identity '"+this.state.author+"' "),"Participant with "===n&&(n="Participant "),n+="was not found",new Error(n);case 17:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getDetailedDeliveryReceipts",value:function(){var e=(0,o.default)(a.default.mark(function e(){var t,n;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:t=e.sent,n=[];case 4:if(n=[].concat((0,s.default)(n),(0,s.default)(t.items)),t.hasNextPage){e.next=8;break}return e.abrupt("break",13);case 8:return e.next=10,t.nextPage();case 10:t=e.sent,e.next=4;break;case 13:return e.abrupt("return",n);case 14:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"remove",value:function(){var e=(0,o.default)(a.default.mark(function e(){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("deleteMessage",{channelSid:this.conversation.sid,messageIdx:this.index.toString()});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateBody",value:function(){var e=(0,o.default)(a.default.mark(function e(t){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("editMessage",{channelSid:this.conversation.sid,messageIdx:this.index.toString(),text:t});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateAttributes",value:function(){var e=(0,o.default)(a.default.mark(function e(t){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("editMessageAttributes",{channelSid:this.conversation.sid,messageIdx:this.index,attributes:(0,i.default)(t)});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"attachTemporaryUrlsFor",value:function(){var e=(0,o.default)(a.default.mark(function e(t){var n,r=this;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.map(function(e){return e.sid}),!this.services.mcsClient){e.next=8;break}return e.next=4,this.services.mcsClient.mediaSetGet(n);case 4:return e.t0=function(e){return new x.Media(e,r.services)},e.abrupt("return",e.sent.map(e.t0));case 8:throw new Error("Media Content Service is unavailable");case 9:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_getDetailedDeliveryReceiptsPaginator",value:function(){var e=(0,o.default)(a.default.mark(function e(t){var n,r,i,s,o,u,c=this;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.getSessionLinks();case 2:return i=e.sent,s=i.messagesReceiptsUrl.replace("%s",this.conversation.sid).replace("%s",this.sid),o=new k.UriBuilder(s).arg("PageToken",null===(n=t)||void 0===n?void 0:n.pageToken).arg("PageSize",null===(r=t)||void 0===r?void 0:r.pageSize).build(),e.next=7,this.services.network.get(o);case 7:return u=e.sent,e.abrupt("return",new S.RestPaginator(u.body.delivery_receipts.map(function(e){return new T.DetailedDeliveryReceipt(e)}),function(e,t){return c._getDetailedDeliveryReceiptsPaginator({pageToken:e,pageSize:t})},u.body.meta.previous_token,u.body.meta.next_token));case 9:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategory(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}}]),t}(_.EventEmitter);y([j.validateTypesAsync("string"),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",r.default)],M.prototype,"updateBody",null),y([j.validateTypesAsync(["string","number","boolean","object",j.literal(null)]),g("design:type",Function),g("design:paramtypes",[Object]),g("design:returntype",r.default)],M.prototype,"updateAttributes",null),n.Message=M},{"./aggregateddeliveryreceipt":1,"./detaileddeliveryreceipt":9,"./logger":12,"./media":13,"./restpaginator":17,"./util":27,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/object/define-property":37,"babel-runtime/core-js/object/get-own-property-descriptor":38,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/core-js/reflect/metadata":44,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/toConsumableArray":55,"babel-runtime/helpers/typeof":56,"babel-runtime/regenerator":57,events:200,"twilio-sdk-type-validator":313}],15:[function(e,t,n){"use strict";var r=v(e("babel-runtime/core-js/promise")),i=v(e("babel-runtime/core-js/json/stringify")),s=v(e("babel-runtime/regenerator")),a=v(e("babel-runtime/helpers/asyncToGenerator")),o=v(e("babel-runtime/core-js/number/is-integer")),u=v(e("babel-runtime/core-js/object/get-prototype-of")),c=v(e("babel-runtime/helpers/classCallCheck")),l=v(e("babel-runtime/helpers/createClass")),d=v(e("babel-runtime/helpers/possibleConstructorReturn")),f=v(e("babel-runtime/helpers/inherits")),p=v(e("babel-runtime/core-js/reflect/metadata")),h=v(e("babel-runtime/core-js/object/define-property")),b=v(e("babel-runtime/helpers/typeof")),m=v(e("babel-runtime/core-js/object/get-own-property-descriptor"));function v(e){return e&&e.__esModule?e:{default:e}}var y=function(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=(0,m.default)(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,b.default)(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&(0,h.default)(t,n,a),a},g=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,b.default)(Reflect))&&"function"==typeof p.default)return(0,p.default)(e,t)};Object.defineProperty(n,"__esModule",{value:!0});var _=e("events"),k=e("./util"),w=e("./logger"),x=e("twilio-sdk-type-validator"),C=w.Logger.scope("Participant"),j=function(e){function t(e,n,r,i){var s;(0,c.default)(this,t);var a=(0,d.default)(this,(t.__proto__||(0,u.default)(t)).call(this));if(a.conversation=n,a.services=e,a.state={attributes:k.parseAttributes(r.attributes,"Retrieved malformed attributes from the server for participant: "+i,C),dateCreated:r.dateCreated?k.parseTime(r.dateCreated):null,dateUpdated:r.dateCreated?k.parseTime(r.dateUpdated):null,sid:i,typingTimeout:null,isTyping:!1,identity:r.identity||null,roleSid:r.roleSid||null,lastReadMessageIndex:(0,o.default)(r.lastConsumedMessageIndex)?r.lastConsumedMessageIndex:null,lastReadTimestamp:r.lastConsumptionTimestamp?k.parseTime(r.lastConsumptionTimestamp):null,type:r.type||"chat",userInfo:r.userInfo,bindings:(s=r.bindings,null!=s?s:{})},!r.identity&&!r.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return a}return(0,f.default)(t,e),(0,l.default)(t,[{key:"_startTyping",value:function(e){var t=this;return clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit("typingStarted",this),this.conversation.emit("typingStarted",this),this.state.typingTimeout=setTimeout(function(){return t._endTyping()},e),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit("typingEnded",this),this.conversation.emit("typingEnded",this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(e){var t=[],n=k.parseAttributes(e.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,C);e.attributes&&!k.isDeepEqual(this.state.attributes,n)&&(this.state.attributes=n,t.push("attributes"));var r=k.parseTime(e.dateUpdated);e.dateUpdated&&r.getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=r,t.push("dateUpdated"));var i=k.parseTime(e.dateCreated);if(e.dateCreated&&i.getTime()!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=i,t.push("dateCreated")),e.roleSid&&this.state.roleSid!==e.roleSid&&(this.state.roleSid=e.roleSid,t.push("roleSid")),!(0,o.default)(e.lastConsumedMessageIndex)&&null!==e.lastConsumedMessageIndex||this.state.lastReadMessageIndex===e.lastConsumedMessageIndex||(this.state.lastReadMessageIndex=e.lastConsumedMessageIndex,t.push("lastReadMessageIndex")),e.lastConsumptionTimestamp){var s=new Date(e.lastConsumptionTimestamp);this.state.lastReadTimestamp&&this.state.lastReadTimestamp.getTime()===s.getTime()||(this.state.lastReadTimestamp=s,t.push("lastReadTimestamp"))}return e.bindings&&!k.isDeepEqual(this.state.bindings,e.bindings)&&(this.state.bindings=e.bindings,t.push("bindings")),t.length>0&&this.emit("updated",{participant:this,updateReasons:t}),this}},{key:"getUser",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("chat"==this.type){e.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return e.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"remove",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateAttributes",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.session.addCommand("editMemberAttributes",{channelSid:this.conversation.sid,memberSid:this.sid,attributes:(0,i.default)(t)});case 2:return e.abrupt("return",this);case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){return this.state.bindings}}]),t}(_.EventEmitter);y([x.validateTypesAsync(["string","number","boolean","object",x.literal(null)]),g("design:type",Function),g("design:paramtypes",[Object]),g("design:returntype",r.default)],j.prototype,"updateAttributes",null),n.Participant=j},{"./logger":12,"./util":27,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/number/is-integer":34,"babel-runtime/core-js/object/define-property":37,"babel-runtime/core-js/object/get-own-property-descriptor":38,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/core-js/reflect/metadata":44,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/typeof":56,"babel-runtime/regenerator":57,events:200,"twilio-sdk-type-validator":313}],16:[function(e,t,n){"use strict";var r,i=e("babel-runtime/helpers/classCallCheck"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});n.PushNotification=function e(t){(0,s.default)(this,e),this.title=t.title||null,this.body=t.body||null,this.sound=t.sound||null,this.badge=t.badge||null,this.action=t.action||null,this.type=t.type||null,this.data=t.data||{}}},{"babel-runtime/helpers/classCallCheck":49}],17:[function(e,t,n){"use strict";var r=a(e("babel-runtime/core-js/promise")),i=a(e("babel-runtime/helpers/classCallCheck")),s=a(e("babel-runtime/helpers/createClass"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(t,n,r,s){(0,i.default)(this,e),this.state={prevToken:r,nextToken:s,source:n,items:t}}return(0,s.default)(e,[{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):r.default.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):r.default.reject(new Error("No previous page"))}},{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}}]),e}();n.RestPaginator=o},{"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],18:[function(e,t,n){"use strict";var r=f(e("babel-runtime/regenerator")),i=f(e("babel-runtime/helpers/asyncToGenerator")),s=f(e("babel-runtime/core-js/promise")),a=f(e("babel-runtime/core-js/get-iterator")),o=f(e("babel-runtime/helpers/slicedToArray")),u=f(e("babel-runtime/core-js/object/assign")),c=f(e("babel-runtime/core-js/map")),l=f(e("babel-runtime/helpers/classCallCheck")),d=f(e("babel-runtime/helpers/createClass"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("operation-retrier"),h=function(){function e(t,n){var r=this;(0,l.default)(this,e),this.config=t,this.services=n,this.cache=new c.default,this.cacheLifetime=0,this.services.session.getHttpCacheInterval().then(function(e){r.cacheLifetime=1e3*e,r.cleanupCache()})}return(0,d.default)(e,[{key:"backoffConfig",value:function(){return(0,u.default)(this.config.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){return void 0!==this.config.retryWhenThrottledOverride?this.config.retryWhenThrottledOverride:void 0!==this.config.retryWhenThrottledDefault&&this.config.retryWhenThrottledDefault}},{key:"isExpired",value:function(e){return!this.cacheLifetime||Date.now()-e>this.cacheLifetime}},{key:"cleanupCache",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,i=(0,a.default)(this.cache);!(e=(r=i.next()).done);e=!0){var s=r.value,u=(0,o.default)(s,2),c=u[0],l=u[1];this.isExpired(l.timestamp)&&this.cache.delete(c)}}catch(e){t=!0,n=e}finally{try{!e&&i.return&&i.return()}finally{if(t)throw n}}0===this.cache.size&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var e=this;this.timer=this.timer||setInterval(function(){return e.cleanupCache()},2*this.cacheLifetime)}},{key:"executeWithRetry",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new s.default(function(r,i){var s=[502,503,504];n&&s.push(429);var a=new p.Retrier(t.backoffConfig());a.on("attempt",function(){e().then(function(e){return a.succeeded(e)}).catch(function(e){s.indexOf(e.status)>-1?a.failed(e):"Twilsock disconnected"===e.message?a.failed(e):(a.removeAllListeners(),a.cancel(),i(e))})}),a.on("succeeded",function(e){r(e)}),a.on("cancelled",function(e){return i(e)}),a.on("failed",function(e){return i(e)}),a.start()})}},{key:"get",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n,i,s,a=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))||this.isExpired(n.timestamp)){e.next=3;break}return e.abrupt("return",n.response);case 3:return i={},e.next=6,this.executeWithRetry(function(){return a.services.transport.get(t,i,a.config.productId)},this.retryWhenThrottled());case 6:return s=e.sent,this.cache.set(t,{response:s,timestamp:Date.now()}),this.pokeTimer(),e.abrupt("return",s);case 10:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();n.Network=h},{"babel-runtime/core-js/get-iterator":30,"babel-runtime/core-js/map":33,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/slicedToArray":54,"babel-runtime/regenerator":57,"operation-retrier":205}],19:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/promise")),i=o(e("babel-runtime/core-js/map")),s=o(e("babel-runtime/helpers/createClass")),a=o(e("babel-runtime/helpers/classCallCheck"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=e("../sessionerror"),c=function(){function e(t){(0,a.default)(this,e),this.services=t,this.readHorizonRequests=new i.default,this.readHorizonUpdateTimer=null}return(0,s.default)(e,[{key:"getReportInterval",value:function(){return this.services.session.getConsumptionReportInterval().then(function(e){return 1e3*e})}},{key:"delayedSendReadHorizon",value:function(e){var t=this;null===this.readHorizonUpdateTimer&&(this.sendConsumptionReport(!0),this.readHorizonUpdateTimer=setTimeout(function(){t.sendConsumptionReport(!1)},e))}},{key:"sendConsumptionReport",value:function(e){var t=this,n=[],r=new i.default;this.readHorizonRequests.forEach(function(e,t){n.push(e.entry),r.set(t,e.promises)}),n.length>0&&this.services.session.addCommand("consumptionReportV2",{report:n}).then(function(e){return t.processConsumptionReportResponse(e,r)}).catch(function(e){return t.processConsumptionReportError(e,r)}),e||(this.readHorizonUpdateTimer=null),this.readHorizonRequests.clear()}},{key:"processConsumptionReportResponse",value:function(e,t){e&&e.report&&Array.isArray(e.report)&&e.report.length>0&&e.report.forEach(function(e){var n=e;if(t.has(n.channelSid)){var r=null;void 0!==n.unreadMessagesCount&&null!=n.unreadMessagesCount&&(r=n.unreadMessagesCount),t.get(n.channelSid).forEach(function(e){return e.resolve(r)}),t.delete(n.channelSid)}}),this.processConsumptionReportError(new u.SessionError("Error while setting LastReadMessageIndex",null),t)}},{key:"processConsumptionReportError",value:function(e,t){t.forEach(function(t){return t.forEach(function(t){return t.reject(e)})})}},{key:"updateLastReadMessageIndexForConversation",value:function(e,t){var n=this;return new r.default(function(r,i){n.addPendingConsumptionHorizonRequest(e,{channelSid:e,messageIdx:t},{resolve:r,reject:i}),n.getReportInterval().then(function(e){return n.delayedSendReadHorizon(e)})})}},{key:"advanceLastReadMessageIndexForConversation",value:function(e,t,n){var i=this,s=this.readHorizonRequests.get(e);return new r.default(function(r,a){s&&s.entry?s.entry.messageIdx>=t?i.addPendingConsumptionHorizonRequest(e,s.entry,{resolve:r,reject:a}):i.addPendingConsumptionHorizonRequest(e,{channelSid:e,messageIdx:t},{resolve:r,reject:a}):null!==n&&t<n?i.addPendingConsumptionHorizonRequest(e,{channelSid:e,messageIdx:n},{resolve:r,reject:a}):i.addPendingConsumptionHorizonRequest(e,{channelSid:e,messageIdx:t},{resolve:r,reject:a}),i.getReportInterval().then(function(e){return i.delayedSendReadHorizon(e)})})}},{key:"addPendingConsumptionHorizonRequest",value:function(e,t,n){if(this.readHorizonRequests.has(e)){var r=this.readHorizonRequests.get(e);r.entry=t,r.promises.push(n)}else this.readHorizonRequests.set(e,{entry:t,promises:[n]})}}]),e}();n.ReadHorizon=c},{"../sessionerror":22,"babel-runtime/core-js/map":33,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],20:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/promise")),i=o(e("babel-runtime/core-js/map")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=e("../logger"),c=e("../interfaces/notificationtypes"),l=u.Logger.scope("TypingIndicator"),d=function(){function e(t,n,r){(0,s.default)(this,e),this.config=t,this.services=n,this.getConversation=r,this.serviceTypingTimeout=null,this.sentUpdates=new i.default}return(0,a.default)(e,[{key:"initialize",value:function(){var e=this;this.services.notificationClient.subscribe(c.NotificationTypes.TYPING_INDICATOR,"twilsock"),this.services.notificationClient.on("message",function(t,n){t===c.NotificationTypes.TYPING_INDICATOR&&e.handleRemoteTyping(n)})}},{key:"handleRemoteTyping",value:function(e){var t=this;l.trace("Got new typing indicator ",e),this.getConversation(e.channel_sid).then(function(n){n&&n.participants.forEach(function(n){if(n.identity===e.identity){var r=t.config.typingIndicatorTimeoutOverride+1e3||1e3*e.typing_timeout;n._startTyping(r)}})}).catch(function(e){throw l.error(e),e})}},{key:"send",value:function(e){var t=this.sentUpdates.get(e);return t&&t>Date.now()-this.typingTimeout?r.default.resolve():(this.sentUpdates.set(e,Date.now()),this._send(e))}},{key:"_send",value:function(e){var t=this;l.trace("Sending typing indicator");var n=this.config.typingIndicatorUri,r="ChannelSid="+e;return this.services.transport.post(n,{"Content-Type":"application/x-www-form-urlencoded"},r,this.config.productId).then(function(e){e.body.hasOwnProperty("typing_timeout")&&(t.serviceTypingTimeout=1e3*e.body.typing_timeout)}).catch(function(e){throw l.error("Failed to send typing indicator:",e),e})}},{key:"typingTimeout",get:function(){return this.config.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.config.typingIndicatorTimeoutDefault}}]),e}();n.TypingIndicator=d},{"../interfaces/notificationtypes":10,"../logger":12,"babel-runtime/core-js/map":33,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],21:[function(e,t,n){"use strict";var r=c(e("babel-runtime/regenerator")),i=c(e("babel-runtime/helpers/asyncToGenerator")),s=c(e("babel-runtime/core-js/promise")),a=c(e("babel-runtime/core-js/map")),o=c(e("babel-runtime/helpers/createClass")),u=c(e("babel-runtime/helpers/classCallCheck"));function c(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var l=e("uuid"),d=e("platform"),f=e("./interfaces/responsecodes"),p=e("./logger"),h=e("./sessionerror"),b=e("./util/deferred"),m=e("iso8601-duration"),v=e("./../package.json").version,y=p.Logger.scope("Session"),g=function e(){(0,u.default)(this,e)};var _=function(){function e(t,n){(0,u.default)(this,e);var r="undefined"!=typeof navigator?d.parse(navigator.userAgent):d;this.services=t,this.config=n,this.sessionInfo=new b.Deferred,this.currentContext={},this.pendingCommands=new a.default,this.sessionStreamPromise=null,this.endpointPlatform=["JS",v,r.os,r.name,r.version].join("|")}return(0,o.default)(e,[{key:"handleContextUpdate",value:function(e){var t;(y.info("Session context updated"),y.debug("new session context:",e),this.currentContext=e,t=e,["identity","userInfo","links","myChannels","channels"].some(function(e){return!t.hasOwnProperty(e)}))||(y.info("new session context accepted"),this.sessionInfo.set(e))}},{key:"initialize",value:function(){var e=this,t={type:"IpMsgSession",apiVersion:"4",endpointPlatform:this.endpointPlatform};return this.sessionStreamPromise=this.services.syncClient.list({purpose:"com.twilio.rtd.ipmsg",context:t}).then(function(t){return y.info("Session created",t.sid),t.on("itemAdded",function(t){return e.processCommandResponse(t.item)}),t.on("itemUpdated",function(t){return e.processCommandResponse(t.item)}),t.on("contextUpdated",function(t){return e.handleContextUpdate(t.context)}),t}).catch(function(e){throw y.error("Failed to create session",e),e}),this.sessionStreamPromise}},{key:"addCommand",value:function(e,t){return this.processCommand(e,t)}},{key:"processCommand",value:function(e,t){var n=this,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=new g;return i.request=t,i.request.action=e,i.commandId=l.v4(),y.info("Adding command: ",e,i.commandId),y.debug("command arguments:",t,r),new s.default(function(s,a){n.sessionStreamPromise.then(function(e){return n.pendingCommands.set(i.commandId,{resolve:s,reject:a,commandId:i.commandId,request:i.request}),e.push(i)}).then(function(){return y.debug("Command accepted by server",i.commandId)}).catch(function(o){n.pendingCommands.delete(i.commandId),y.error("Failed to add a command to the session",o),o.code!=f.ResponseCodes.ACCESS_FORBIDDEN_FOR_IDENTITY&&o.code!==f.ResponseCodes.LIST_NOT_FOUND||!r?a(new Error("Can't add command: "+o.message)):(y.info("recreating session..."),n.initialize(),s(n.processCommand(e,t,!1)))})})}},{key:"processCommandResponse",value:function(e){if(e.data.hasOwnProperty("response")&&e.data.hasOwnProperty("commandId")&&this.pendingCommands.has(e.data.commandId)){var t=e.data,n=t.commandId;if(t.response.status===f.ResponseCodes.HTTP_200_OK){y.debug("Command succeeded: ",t);var r=this.pendingCommands.get(n).resolve;this.pendingCommands.delete(n),r(t.response)}else{y.error("Command failed: ",t);var i=this.pendingCommands.get(n).reject;this.pendingCommands.delete(n),i(new h.SessionError(t.response.statusText,t.response.status))}}}},{key:"getSessionContext",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionStreamPromise;case 2:return t=e.sent,e.abrupt("return",t.getContext());case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getSessionLinks",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionInfo.promise;case 2:return t=e.sent,e.abrupt("return",{publicChannelsUrl:this.config.baseUrl+t.links.publicChannelsUrl,myChannelsUrl:this.config.baseUrl+t.links.myChannelsUrl,typingUrl:this.config.baseUrl+t.links.typingUrl,syncListUrl:this.config.baseUrl+t.links.syncListUrl,usersUrl:this.config.baseUrl+t.links.usersUrl,mediaServiceUrl:t.links.mediaServiceUrl,mediaSetServiceUrl:t.links.mediaSetServiceUrl,messagesReceiptsUrl:this.config.baseUrl+t.links.messagesReceiptsUrl});case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getMediaLimits",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t,n,i,s,a,o,u,c,l;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=10,u=150,c=["text/plain","text/html"],e.next=5,this.sessionInfo.promise;case 5:return l=e.sent,e.abrupt("return",{mediaAttachmentsCountLimit:(t=l.mediaAttachmentsCountLimit,null!=t?t:o),mediaAttachmentSizeLimitInMb:(n=l.mediaAttachmentSizeLimitInMb,null!=n?n:u),mediaAttachmentsTotalSizeLimitInMb:(i=l.mediaAttachmentsTotalSizeLimitInMb,null!=i?i:u),emailHistoriesAllowedMimeTypes:(s=l.emailHistoriesAllowedMimeTypes,null!=s?s:c),emailBodiesAllowedMimeTypes:(a=l.emailBodiesAllowedMimeTypes,null!=a?a:c)});case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getConversationsId",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionInfo.promise;case 2:return t=e.sent,e.abrupt("return",t.channels);case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getMyConversationsId",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionInfo.promise;case 2:return t=e.sent,e.abrupt("return",t.myChannels);case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getMaxUserInfosToSubscribe",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionInfo.promise;case 2:return t=e.sent,e.abrupt("return",this.config.userInfosToSubscribeOverride||t.userInfosToSubscribe||this.config.userInfosToSubscribeDefault);case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getUsersData",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sessionInfo.promise;case 2:return t=e.sent,e.abrupt("return",{user:t.userInfo,identity:t.identity});case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getConsumptionReportInterval",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t,n;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSessionContext();case 2:return t=e.sent,n=this.config.consumptionReportIntervalOverride||t.consumptionReportInterval||this.config.consumptionReportIntervalDefault,e.prev=4,e.abrupt("return",m.toSeconds(m.parse(n)));case 8:return e.prev=8,e.t0=e.catch(4),y.error("Failed to parse consumption report interval",n,"using default value",this.config.consumptionReportIntervalDefault),e.abrupt("return",m.toSeconds(m.parse(this.config.consumptionReportIntervalDefault)));case 12:case"end":return e.stop()}},e,this,[[4,8]])}));return function(){return e.apply(this,arguments)}}()},{key:"getHttpCacheInterval",value:function(){var e=(0,i.default)(r.default.mark(function e(){var t,n;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getSessionContext();case 2:return t=e.sent,n=this.config.httpCacheIntervalOverride||t.httpCacheInterval||this.config.httpCacheIntervalDefault,e.prev=4,e.abrupt("return",m.toSeconds(m.parse(n)));case 8:return e.prev=8,e.t0=e.catch(4),y.error("Failed to parse cache interval",n,"using default value",this.config.httpCacheIntervalDefault),e.abrupt("return",m.toSeconds(m.parse(this.config.httpCacheIntervalDefault)));case 12:case"end":return e.stop()}},e,this,[[4,8]])}));return function(){return e.apply(this,arguments)}}()},{key:"identity",get:function(){return this.sessionInfo.current.identity}},{key:"reachabilityEnabled",get:function(){return this.currentContext.reachabilityEnabled}}]),e}();n.Session=_},{"./../package.json":375,"./interfaces/responsecodes":11,"./logger":12,"./sessionerror":22,"./util/deferred":26,"babel-runtime/core-js/map":33,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57,"iso8601-duration":201,platform:207,uuid:370}],22:[function(e,t,n){"use strict";var r=d(e("babel-runtime/core-js/object/create")),i=d(e("babel-runtime/core-js/object/set-prototype-of")),s=d(e("babel-runtime/core-js/array/from")),a=d(e("babel-runtime/core-js/reflect/construct")),o=d(e("babel-runtime/core-js/object/get-prototype-of")),u=d(e("babel-runtime/helpers/classCallCheck")),c=d(e("babel-runtime/helpers/possibleConstructorReturn")),l=d(e("babel-runtime/helpers/inherits"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var f=function(e){function t(e,n){(0,u.default)(this,t);var r=(0,c.default)(this,(t.__proto__||(0,o.default)(t)).call(this));return r.name=r.constructor.name,r.message=e,r.code=n,Error.captureStackTrace?Error.captureStackTrace(r,r.constructor):r.stack=(new Error).stack,r}return(0,l.default)(t,e),t}(function(e){function t(){var t=(0,a.default)(e,(0,s.default)(arguments));return(0,i.default)(t,(0,o.default)(this)),t}return t.prototype=(0,r.default)(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i.default?(0,i.default)(t,e):t.__proto__=e,t}(Error));n.SessionError=f},{"babel-runtime/core-js/array/from":29,"babel-runtime/core-js/object/create":36,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/object/set-prototype-of":41,"babel-runtime/core-js/reflect/construct":43,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],23:[function(e,t,n){"use strict";var r=o(e("babel-runtime/regenerator")),i=o(e("babel-runtime/helpers/asyncToGenerator")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=e("./util/index"),c=e("./restpaginator"),l=e("./synclistdescriptor"),d=function(){function e(t){(0,s.default)(this,e),this.services=t}return(0,a.default)(e,[{key:"getPage",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n,i,s,a=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},e.next=3,this.services.session.getSessionLinks();case 3:return n=e.sent,i=new u.UriBuilder(n.syncListUrl).arg("PageToken",t.pageToken).build(),e.next=7,this.services.network.get(i);case 7:return s=e.sent,e.abrupt("return",new c.RestPaginator(s.body.channels.map(function(e){return new l.SyncListDescriptor(e)}),function(e){return a.getPage({pageToken:e})},s.body.meta.previous_token,s.body.meta.next_token));case 9:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();n.SyncList=d},{"./restpaginator":17,"./synclistdescriptor":24,"./util/index":27,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57}],24:[function(e,t,n){"use strict";var r,i=e("babel-runtime/helpers/classCallCheck"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});n.SyncListDescriptor=function e(t){(0,s.default)(this,e),this.channel_sid=t.channel_sid,this.status=t.status,this.channel=t.channel,this.messages=t.messages,this.roster=t.roster,this.lastConsumedMessageIndex=t.last_consumed_message_index,this.notificationLevel=t.notification_level,this.descriptor=t}},{"babel-runtime/helpers/classCallCheck":49}],25:[function(e,t,n){"use strict";var r=m(e("babel-runtime/core-js/json/stringify")),i=m(e("babel-runtime/regenerator")),s=m(e("babel-runtime/helpers/asyncToGenerator")),a=m(e("babel-runtime/core-js/promise")),o=m(e("babel-runtime/core-js/object/get-prototype-of")),u=m(e("babel-runtime/helpers/classCallCheck")),c=m(e("babel-runtime/helpers/createClass")),l=m(e("babel-runtime/helpers/possibleConstructorReturn")),d=m(e("babel-runtime/helpers/inherits")),f=m(e("babel-runtime/core-js/reflect/metadata")),p=m(e("babel-runtime/core-js/object/define-property")),h=m(e("babel-runtime/helpers/typeof")),b=m(e("babel-runtime/core-js/object/get-own-property-descriptor"));function m(e){return e&&e.__esModule?e:{default:e}}var v=function(e,t,n,r){var i,s=arguments.length,a=s<3?t:null===r?r=(0,b.default)(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,h.default)(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(a=(s<3?i(a):s>3?i(t,n,a):i(t,n))||a);return s>3&&a&&(0,p.default)(t,n,a),a},y=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,h.default)(Reflect))&&"function"==typeof f.default)return(0,f.default)(e,t)};Object.defineProperty(n,"__esModule",{value:!0});var g=e("events"),_=e("./logger"),k=e("./util"),w=e("twilio-sdk-type-validator"),x=_.Logger.scope("User"),C=function(e){function t(e,n,r){(0,u.default)(this,t);var i=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this));return i.subscribed="initializing",i.setMaxListeners(0),i.services=r,i.state={identity:e,entityName:n,friendlyName:null,attributes:{},online:null,notifiable:null},i}return(0,d.default)(t,e),(0,c.default)(t,[{key:"_update",value:function(e,t){var n=[];switch(x.debug("User for",this.state.identity,"updated:",e,t),e){case"friendlyName":this.state.friendlyName!==t.value&&(n.push("friendlyName"),this.state.friendlyName=t.value);break;case"attributes":var r=k.parseAttributes(t.value,"Retrieved malformed attributes from the server for user: "+this.state.identity,x);k.isDeepEqual(this.state.attributes,r)||(this.state.attributes=r,n.push("attributes"));break;case"reachability":this.state.online!==t.online&&(this.state.online=t.online,n.push("reachabilityOnline")),this.state.notifiable!==t.notifiable&&(this.state.notifiable=t.notifiable,n.push("reachabilityNotifiable"));break;default:return}n.length>0&&this.emit("updated",{user:this,updateReasons:n})}},{key:"_updateReachabilityInfo",value:function(e,t){var n=this;return this.services.session.reachabilityEnabled?e.get("reachability").then(t).catch(function(e){x.warn("Failed to get reachability info for ",n.state.identity,e)}):a.default.resolve()}},{key:"_fetch",value:function(){var e=(0,s.default)(i.default.mark(function e(){var t=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.state.entityName){e.next=2;break}return e.abrupt("return",this);case 2:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(e){return t.entity=e,e.on("itemUpdated",function(e){return x.debug(t.state.entityName+" ("+t.state.identity+") itemUpdated: "+e.item.key),t._update(e.item.key,e.item.data)}),a.default.all([e.get("friendlyName").then(function(e){return t._update(e.key,e.data)}),e.get("attributes").then(function(e){return t._update(e.key,e.data)}),t._updateReachabilityInfo(e,function(e){return t._update(e.key,e.data)})])}).then(function(){return x.debug("Fetched for",t.identity),t.subscribed="subscribed",t.emit("userSubscribed",t),t}).catch(function(e){throw t.promiseToFetch=null,e}),e.abrupt("return",this.promiseToFetch);case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"_ensureFetched",value:function(){return this.promiseToFetch||this._fetch()}},{key:"updateAttributes",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("unsubscribed"!=this.subscribed){e.next=2;break}throw new Error("Can't modify unsubscribed object");case 2:return e.next=4,this.services.session.addCommand("editUserAttributes",{username:this.state.identity,attributes:(0,r.default)(t)});case 4:return e.abrupt("return",this);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateFriendlyName",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("unsubscribed"!=this.subscribed){e.next=2;break}throw new Error("Can't modify unsubscribed object");case 2:return e.next=4,this.services.session.addCommand("editUserFriendlyName",{username:this.state.identity,friendlyName:t});case 4:return e.abrupt("return",this);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"unsubscribe",value:function(){var e=(0,s.default)(i.default.mark(function e(){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.promiseToFetch){e.next=7;break}return e.next=3,this.promiseToFetch;case 3:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"identity",get:function(){return this.state.identity},set:function(e){this.state.identity=e}},{key:"entityName",set:function(e){this.state.entityName=e}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return"subscribed"==this.subscribed}}]),t}(g.EventEmitter);v([w.validateTypesAsync(["string","number","boolean","object",w.literal(null)]),y("design:type",Function),y("design:paramtypes",[Object]),y("design:returntype",a.default)],C.prototype,"updateAttributes",null),v([w.validateTypesAsync(["string",w.literal(null)]),y("design:type",Function),y("design:paramtypes",[String]),y("design:returntype",a.default)],C.prototype,"updateFriendlyName",null),n.User=C},{"./logger":12,"./util":27,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/object/define-property":37,"babel-runtime/core-js/object/get-own-property-descriptor":38,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/core-js/reflect/metadata":44,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/typeof":56,"babel-runtime/regenerator":57,events:200,"twilio-sdk-type-validator":313}],26:[function(e,t,n){"use strict";var r=a(e("babel-runtime/core-js/promise")),i=a(e("babel-runtime/helpers/classCallCheck")),s=a(e("babel-runtime/helpers/createClass"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(){var t=this;(0,i.default)(this,e),this._promise=new r.default(function(e,n){t._resolve=e,t._reject=n})}return(0,s.default)(e,[{key:"update",value:function(e){this._resolve(e)}},{key:"set",value:function(e){this.current=e,this._resolve(e)}},{key:"fail",value:function(e){this._reject(e)}},{key:"promise",get:function(){return this._promise}}]),e}();n.Deferred=o},{"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],27:[function(e,t,n){"use strict";var r=a(e("babel-runtime/helpers/classCallCheck")),i=a(e("babel-runtime/helpers/createClass")),s=a(e("babel-runtime/core-js/json/stringify"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("rfc6902");n.isDeepEqual=function(e,t){return 0===o.createPatch(e,t).length},n.deepClone=function(e){return JSON.parse((0,s.default)(e))},n.parseToNumber=function(e){return void 0===e||isNaN(Number(e))?null:Number(e)},n.parseTime=function(e){try{return new Date(e)}catch(e){return null}},n.parseAttributes=function(e,t,n){var r={};if(e)try{r=JSON.parse(e)}catch(e){n.warn(t,e)}return r};var u=function(){function e(t){(0,r.default)(this,e),this.base=t.replace(/\/$/,""),this.args=[],this.paths=[]}return(0,i.default)(e,[{key:"arg",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"path",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();n.UriBuilder=u},{"babel-runtime/core-js/json/stringify":32,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,rfc6902:212}],28:[function(e,t,n){t.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},t.exports.default=t.exports,t.exports.__esModule=!0},{}],29:[function(e,t,n){t.exports={default:e("core-js/library/fn/array/from"),__esModule:!0}},{"core-js/library/fn/array/from":59}],30:[function(e,t,n){t.exports={default:e("core-js/library/fn/get-iterator"),__esModule:!0}},{"core-js/library/fn/get-iterator":60}],31:[function(e,t,n){t.exports={default:e("core-js/library/fn/is-iterable"),__esModule:!0}},{"core-js/library/fn/is-iterable":61}],32:[function(e,t,n){t.exports={default:e("core-js/library/fn/json/stringify"),__esModule:!0}},{"core-js/library/fn/json/stringify":62}],33:[function(e,t,n){t.exports={default:e("core-js/library/fn/map"),__esModule:!0}},{"core-js/library/fn/map":63}],34:[function(e,t,n){t.exports={default:e("core-js/library/fn/number/is-integer"),__esModule:!0}},{"core-js/library/fn/number/is-integer":64}],35:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/assign"),__esModule:!0}},{"core-js/library/fn/object/assign":65}],36:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/create"),__esModule:!0}},{"core-js/library/fn/object/create":66}],37:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/define-property"),__esModule:!0}},{"core-js/library/fn/object/define-property":67}],38:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/get-own-property-descriptor"),__esModule:!0}},{"core-js/library/fn/object/get-own-property-descriptor":68}],39:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/get-prototype-of"),__esModule:!0}},{"core-js/library/fn/object/get-prototype-of":69}],40:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/keys"),__esModule:!0}},{"core-js/library/fn/object/keys":70}],41:[function(e,t,n){t.exports={default:e("core-js/library/fn/object/set-prototype-of"),__esModule:!0}},{"core-js/library/fn/object/set-prototype-of":71}],42:[function(e,t,n){t.exports={default:e("core-js/library/fn/promise"),__esModule:!0}},{"core-js/library/fn/promise":72}],43:[function(e,t,n){t.exports={default:e("core-js/library/fn/reflect/construct"),__esModule:!0}},{"core-js/library/fn/reflect/construct":73}],44:[function(e,t,n){t.exports={default:e("core-js/library/fn/reflect/metadata"),__esModule:!0}},{"core-js/library/fn/reflect/metadata":74}],45:[function(e,t,n){t.exports={default:e("core-js/library/fn/set"),__esModule:!0}},{"core-js/library/fn/set":75}],46:[function(e,t,n){t.exports={default:e("core-js/library/fn/symbol"),__esModule:!0}},{"core-js/library/fn/symbol":76}],47:[function(e,t,n){t.exports={default:e("core-js/library/fn/symbol/iterator"),__esModule:!0}},{"core-js/library/fn/symbol/iterator":77}],48:[function(e,t,n){"use strict";n.__esModule=!0;var r,i=e("../core-js/promise"),s=(r=i)&&r.__esModule?r:{default:r};n.default=function(e){return function(){var t=e.apply(this,arguments);return new s.default(function(e,n){return function r(i,a){try{var o=t[i](a),u=o.value}catch(e){return void n(e)}if(!o.done)return s.default.resolve(u).then(function(e){r("next",e)},function(e){r("throw",e)});e(u)}("next")})}}},{"../core-js/promise":42}],49:[function(e,t,n){"use strict";n.__esModule=!0,n.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},{}],50:[function(e,t,n){"use strict";n.__esModule=!0;var r,i=e("../core-js/object/define-property"),s=(r=i)&&r.__esModule?r:{default:r};n.default=function(){function e(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),(0,s.default)(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()},{"../core-js/object/define-property":37}],51:[function(e,t,n){"use strict";n.__esModule=!0;var r=s(e("../core-js/object/get-prototype-of")),i=s(e("../core-js/object/get-own-property-descriptor"));function s(e){return e&&e.__esModule?e:{default:e}}n.default=function e(t,n,s){null===t&&(t=Function.prototype);var a=(0,i.default)(t,n);if(void 0===a){var o=(0,r.default)(t);return null===o?void 0:e(o,n,s)}if("value"in a)return a.value;var u=a.get;return void 0!==u?u.call(s):void 0}},{"../core-js/object/get-own-property-descriptor":38,"../core-js/object/get-prototype-of":39}],52:[function(e,t,n){"use strict";n.__esModule=!0;var r=a(e("../core-js/object/set-prototype-of")),i=a(e("../core-js/object/create")),s=a(e("../helpers/typeof"));function a(e){return e&&e.__esModule?e:{default:e}}n.default=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":(0,s.default)(t)));e.prototype=(0,i.default)(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(r.default?(0,r.default)(e,t):e.__proto__=t)}},{"../core-js/object/create":36,"../core-js/object/set-prototype-of":41,"../helpers/typeof":56}],53:[function(e,t,n){"use strict";n.__esModule=!0;var r,i=e("../helpers/typeof"),s=(r=i)&&r.__esModule?r:{default:r};n.default=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":(0,s.default)(t))&&"function"!=typeof t?e:t}},{"../helpers/typeof":56}],54:[function(e,t,n){"use strict";n.__esModule=!0;var r=s(e("../core-js/is-iterable")),i=s(e("../core-js/get-iterator"));function s(e){return e&&e.__esModule?e:{default:e}}n.default=function(){return function(e,t){if(Array.isArray(e))return e;if((0,r.default)(Object(e)))return function(e,t){var n=[],r=!0,s=!1,a=void 0;try{for(var o,u=(0,i.default)(e);!(r=(o=u.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){s=!0,a=e}finally{try{!r&&u.return&&u.return()}finally{if(s)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()},{"../core-js/get-iterator":30,"../core-js/is-iterable":31}],55:[function(e,t,n){"use strict";n.__esModule=!0;var r,i=e("../core-js/array/from"),s=(r=i)&&r.__esModule?r:{default:r};n.default=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return(0,s.default)(e)}},{"../core-js/array/from":29}],56:[function(e,t,n){"use strict";n.__esModule=!0;var r=a(e("../core-js/symbol/iterator")),i=a(e("../core-js/symbol")),s="function"==typeof i.default&&"symbol"==typeof r.default?function(e){return typeof e}:function(e){return e&&"function"==typeof i.default&&e.constructor===i.default&&e!==i.default.prototype?"symbol":typeof e};function a(e){return e&&e.__esModule?e:{default:e}}n.default="function"==typeof i.default&&"symbol"===s(r.default)?function(e){return void 0===e?"undefined":s(e)}:function(e){return e&&"function"==typeof i.default&&e.constructor===i.default&&e!==i.default.prototype?"symbol":void 0===e?"undefined":s(e)}},{"../core-js/symbol":46,"../core-js/symbol/iterator":47}],57:[function(e,t,n){t.exports=e("regenerator-runtime")},{"regenerator-runtime":208}],58:[function(e,t,n){},{}],59:[function(e,t,n){e("../../modules/es6.string.iterator"),e("../../modules/es6.array.from"),t.exports=e("../../modules/_core").Array.from},{"../../modules/_core":94,"../../modules/es6.array.from":170,"../../modules/es6.string.iterator":185}],60:[function(e,t,n){e("../modules/web.dom.iterable"),e("../modules/es6.string.iterator"),t.exports=e("../modules/core.get-iterator")},{"../modules/core.get-iterator":168,"../modules/es6.string.iterator":185,"../modules/web.dom.iterable":199}],61:[function(e,t,n){e("../modules/web.dom.iterable"),e("../modules/es6.string.iterator"),t.exports=e("../modules/core.is-iterable")},{"../modules/core.is-iterable":169,"../modules/es6.string.iterator":185,"../modules/web.dom.iterable":199}],62:[function(e,t,n){var r=e("../../modules/_core"),i=r.JSON||(r.JSON={stringify:JSON.stringify});t.exports=function(e){return i.stringify.apply(i,arguments)}},{"../../modules/_core":94}],63:[function(e,t,n){e("../modules/es6.object.to-string"),e("../modules/es6.string.iterator"),e("../modules/web.dom.iterable"),e("../modules/es6.map"),e("../modules/es7.map.to-json"),e("../modules/es7.map.of"),e("../modules/es7.map.from"),t.exports=e("../modules/_core").Map},{"../modules/_core":94,"../modules/es6.map":172,"../modules/es6.object.to-string":181,"../modules/es6.string.iterator":185,"../modules/es7.map.from":188,"../modules/es7.map.of":189,"../modules/es7.map.to-json":190,"../modules/web.dom.iterable":199}],64:[function(e,t,n){e("../../modules/es6.number.is-integer"),t.exports=e("../../modules/_core").Number.isInteger},{"../../modules/_core":94,"../../modules/es6.number.is-integer":173}],65:[function(e,t,n){e("../../modules/es6.object.assign"),t.exports=e("../../modules/_core").Object.assign},{"../../modules/_core":94,"../../modules/es6.object.assign":174}],66:[function(e,t,n){e("../../modules/es6.object.create");var r=e("../../modules/_core").Object;t.exports=function(e,t){return r.create(e,t)}},{"../../modules/_core":94,"../../modules/es6.object.create":175}],67:[function(e,t,n){e("../../modules/es6.object.define-property");var r=e("../../modules/_core").Object;t.exports=function(e,t,n){return r.defineProperty(e,t,n)}},{"../../modules/_core":94,"../../modules/es6.object.define-property":176}],68:[function(e,t,n){e("../../modules/es6.object.get-own-property-descriptor");var r=e("../../modules/_core").Object;t.exports=function(e,t){return r.getOwnPropertyDescriptor(e,t)}},{"../../modules/_core":94,"../../modules/es6.object.get-own-property-descriptor":177}],69:[function(e,t,n){e("../../modules/es6.object.get-prototype-of"),t.exports=e("../../modules/_core").Object.getPrototypeOf},{"../../modules/_core":94,"../../modules/es6.object.get-prototype-of":178}],70:[function(e,t,n){e("../../modules/es6.object.keys"),t.exports=e("../../modules/_core").Object.keys},{"../../modules/_core":94,"../../modules/es6.object.keys":179}],71:[function(e,t,n){e("../../modules/es6.object.set-prototype-of"),t.exports=e("../../modules/_core").Object.setPrototypeOf},{"../../modules/_core":94,"../../modules/es6.object.set-prototype-of":180}],72:[function(e,t,n){e("../modules/es6.object.to-string"),e("../modules/es6.string.iterator"),e("../modules/web.dom.iterable"),e("../modules/es6.promise"),e("../modules/es7.promise.finally"),e("../modules/es7.promise.try"),t.exports=e("../modules/_core").Promise},{"../modules/_core":94,"../modules/es6.object.to-string":181,"../modules/es6.promise":182,"../modules/es6.string.iterator":185,"../modules/es7.promise.finally":191,"../modules/es7.promise.try":192,"../modules/web.dom.iterable":199}],73:[function(e,t,n){e("../../modules/es6.reflect.construct"),t.exports=e("../../modules/_core").Reflect.construct},{"../../modules/_core":94,"../../modules/es6.reflect.construct":183}],74:[function(e,t,n){e("../../modules/es7.reflect.metadata"),t.exports=e("../../modules/_core").Reflect.metadata},{"../../modules/_core":94,"../../modules/es7.reflect.metadata":193}],75:[function(e,t,n){e("../modules/es6.object.to-string"),e("../modules/es6.string.iterator"),e("../modules/web.dom.iterable"),e("../modules/es6.set"),e("../modules/es7.set.to-json"),e("../modules/es7.set.of"),e("../modules/es7.set.from"),t.exports=e("../modules/_core").Set},{"../modules/_core":94,"../modules/es6.object.to-string":181,"../modules/es6.set":184,"../modules/es6.string.iterator":185,"../modules/es7.set.from":194,"../modules/es7.set.of":195,"../modules/es7.set.to-json":196,"../modules/web.dom.iterable":199}],76:[function(e,t,n){e("../../modules/es6.symbol"),e("../../modules/es6.object.to-string"),e("../../modules/es7.symbol.async-iterator"),e("../../modules/es7.symbol.observable"),t.exports=e("../../modules/_core").Symbol},{"../../modules/_core":94,"../../modules/es6.object.to-string":181,"../../modules/es6.symbol":186,"../../modules/es7.symbol.async-iterator":197,"../../modules/es7.symbol.observable":198}],77:[function(e,t,n){e("../../modules/es6.string.iterator"),e("../../modules/web.dom.iterable"),t.exports=e("../../modules/_wks-ext").f("iterator")},{"../../modules/_wks-ext":165,"../../modules/es6.string.iterator":185,"../../modules/web.dom.iterable":199}],78:[function(e,t,n){t.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},{}],79:[function(e,t,n){t.exports=function(){}},{}],80:[function(e,t,n){t.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},{}],81:[function(e,t,n){var r=e("./_is-object");t.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},{"./_is-object":115}],82:[function(e,t,n){var r=e("./_for-of");t.exports=function(e,t){var n=[];return r(e,!1,n.push,n,t),n}},{"./_for-of":104}],83:[function(e,t,n){var r=e("./_to-iobject"),i=e("./_to-length"),s=e("./_to-absolute-index");t.exports=function(e){return function(t,n,a){var o,u=r(t),c=i(u.length),l=s(a,c);if(e&&n!=n){for(;c>l;)if((o=u[l++])!=o)return!0}else for(;c>l;l++)if((e||l in u)&&u[l]===n)return e||l||0;return!e&&-1}}},{"./_to-absolute-index":155,"./_to-iobject":157,"./_to-length":158}],84:[function(e,t,n){var r=e("./_ctx"),i=e("./_iobject"),s=e("./_to-object"),a=e("./_to-length"),o=e("./_array-species-create");t.exports=function(e,t){var n=1==e,u=2==e,c=3==e,l=4==e,d=6==e,f=5==e||d,p=t||o;return function(t,o,h){for(var b,m,v=s(t),y=i(v),g=r(o,h,3),_=a(y.length),k=0,w=n?p(t,_):u?p(t,0):void 0;_>k;k++)if((f||k in y)&&(m=g(b=y[k],k,v),e))if(n)w[k]=m;else if(m)switch(e){case 3:return!0;case 5:return b;case 6:return k;case 2:w.push(b)}else if(l)return!1;return d?-1:c||l?l:w}}},{"./_array-species-create":86,"./_ctx":96,"./_iobject":111,"./_to-length":158,"./_to-object":159}],85:[function(e,t,n){var r=e("./_is-object"),i=e("./_is-array"),s=e("./_wks")("species");t.exports=function(e){var t;return i(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!i(t.prototype)||(t=void 0),r(t)&&null===(t=t[s])&&(t=void 0)),void 0===t?Array:t}},{"./_is-array":113,"./_is-object":115,"./_wks":166}],86:[function(e,t,n){var r=e("./_array-species-constructor");t.exports=function(e,t){return new(r(e))(t)}},{"./_array-species-constructor":85}],87:[function(e,t,n){"use strict";var r=e("./_a-function"),i=e("./_is-object"),s=e("./_invoke"),a=[].slice,o={};t.exports=Function.bind||function(e){var t=r(this),n=a.call(arguments,1),u=function(){var r=n.concat(a.call(arguments));return this instanceof u?function(e,t,n){if(!(t in o)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";o[t]=Function("F,a","return new F("+r.join(",")+")")}return o[t](e,n)}(t,r.length,r):s(t,r,e)};return i(t.prototype)&&(u.prototype=t.prototype),u}},{"./_a-function":78,"./_invoke":110,"./_is-object":115}],88:[function(e,t,n){var r=e("./_cof"),i=e("./_wks")("toStringTag"),s="Arguments"==r(function(){return arguments}());t.exports=function(e){var t,n,a;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),i))?n:s?r(t):"Object"==(a=r(t))&&"function"==typeof t.callee?"Arguments":a}},{"./_cof":89,"./_wks":166}],89:[function(e,t,n){var r={}.toString;t.exports=function(e){return r.call(e).slice(8,-1)}},{}],90:[function(e,t,n){"use strict";var r=e("./_object-dp").f,i=e("./_object-create"),s=e("./_redefine-all"),a=e("./_ctx"),o=e("./_an-instance"),u=e("./_for-of"),c=e("./_iter-define"),l=e("./_iter-step"),d=e("./_set-species"),f=e("./_descriptors"),p=e("./_meta").fastKey,h=e("./_validate-collection"),b=f?"_s":"size",m=function(e,t){var n,r=p(t);if("F"!==r)return e._i[r];for(n=e._f;n;n=n.n)if(n.k==t)return n};t.exports={getConstructor:function(e,t,n,c){var l=e(function(e,r){o(e,l,t,"_i"),e._t=t,e._i=i(null),e._f=void 0,e._l=void 0,e[b]=0,null!=r&&u(r,n,e[c],e)});return s(l.prototype,{clear:function(){for(var e=h(this,t),n=e._i,r=e._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];e._f=e._l=void 0,e[b]=0},delete:function(e){var n=h(this,t),r=m(n,e);if(r){var i=r.n,s=r.p;delete n._i[r.i],r.r=!0,s&&(s.n=i),i&&(i.p=s),n._f==r&&(n._f=i),n._l==r&&(n._l=s),n[b]--}return!!r},forEach:function(e){h(this,t);for(var n,r=a(e,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(r(n.v,n.k,this);n&&n.r;)n=n.p},has:function(e){return!!m(h(this,t),e)}}),f&&r(l.prototype,"size",{get:function(){return h(this,t)[b]}}),l},def:function(e,t,n){var r,i,s=m(e,t);return s?s.v=n:(e._l=s={i:i=p(t,!0),k:t,v:n,p:r=e._l,n:void 0,r:!1},e._f||(e._f=s),r&&(r.n=s),e[b]++,"F"!==i&&(e._i[i]=s)),e},getEntry:m,setStrong:function(e,t,n){c(e,t,function(e,n){this._t=h(e,t),this._k=n,this._l=void 0},function(){for(var e=this._k,t=this._l;t&&t.r;)t=t.p;return this._t&&(this._l=t=t?t.n:this._t._f)?l(0,"keys"==e?t.k:"values"==e?t.v:[t.k,t.v]):(this._t=void 0,l(1))},n?"entries":"values",!n,!0),d(t)}}},{"./_an-instance":80,"./_ctx":96,"./_descriptors":98,"./_for-of":104,"./_iter-define":118,"./_iter-step":120,"./_meta":123,"./_object-create":128,"./_object-dp":129,"./_redefine-all":143,"./_set-species":148,"./_validate-collection":163}],91:[function(e,t,n){var r=e("./_classof"),i=e("./_array-from-iterable");t.exports=function(e){return function(){if(r(this)!=e)throw TypeError(e+"#toJSON isn't generic");return i(this)}}},{"./_array-from-iterable":82,"./_classof":88}],92:[function(e,t,n){"use strict";var r=e("./_redefine-all"),i=e("./_meta").getWeak,s=e("./_an-object"),a=e("./_is-object"),o=e("./_an-instance"),u=e("./_for-of"),c=e("./_array-methods"),l=e("./_has"),d=e("./_validate-collection"),f=c(5),p=c(6),h=0,b=function(e){return e._l||(e._l=new m)},m=function(){this.a=[]},v=function(e,t){return f(e.a,function(e){return e[0]===t})};m.prototype={get:function(e){var t=v(this,e);if(t)return t[1]},has:function(e){return!!v(this,e)},set:function(e,t){var n=v(this,e);n?n[1]=t:this.a.push([e,t])},delete:function(e){var t=p(this.a,function(t){return t[0]===e});return~t&&this.a.splice(t,1),!!~t}},t.exports={getConstructor:function(e,t,n,s){var c=e(function(e,r){o(e,c,t,"_i"),e._t=t,e._i=h++,e._l=void 0,null!=r&&u(r,n,e[s],e)});return r(c.prototype,{delete:function(e){if(!a(e))return!1;var n=i(e);return!0===n?b(d(this,t)).delete(e):n&&l(n,this._i)&&delete n[this._i]},has:function(e){if(!a(e))return!1;var n=i(e);return!0===n?b(d(this,t)).has(e):n&&l(n,this._i)}}),c},def:function(e,t,n){var r=i(s(t),!0);return!0===r?b(e).set(t,n):r[e._i]=n,e},ufstore:b}},{"./_an-instance":80,"./_an-object":81,"./_array-methods":84,"./_for-of":104,"./_has":106,"./_is-object":115,"./_meta":123,"./_redefine-all":143,"./_validate-collection":163}],93:[function(e,t,n){"use strict";var r=e("./_global"),i=e("./_export"),s=e("./_meta"),a=e("./_fails"),o=e("./_hide"),u=e("./_redefine-all"),c=e("./_for-of"),l=e("./_an-instance"),d=e("./_is-object"),f=e("./_set-to-string-tag"),p=e("./_object-dp").f,h=e("./_array-methods")(0),b=e("./_descriptors");t.exports=function(e,t,n,m,v,y){var g=r[e],_=g,k=v?"set":"add",w=_&&_.prototype,x={};return b&&"function"==typeof _&&(y||w.forEach&&!a(function(){(new _).entries().next()}))?(_=t(function(t,n){l(t,_,e,"_c"),t._c=new g,null!=n&&c(n,v,t[k],t)}),h("add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON".split(","),function(e){var t="add"==e||"set"==e;e in w&&(!y||"clear"!=e)&&o(_.prototype,e,function(n,r){if(l(this,_,e),!t&&y&&!d(n))return"get"==e&&void 0;var i=this._c[e](0===n?0:n,r);return t?this:i})}),y||p(_.prototype,"size",{get:function(){return this._c.size}})):(_=m.getConstructor(t,e,v,k),u(_.prototype,n),s.NEED=!0),f(_,e),x[e]=_,i(i.G+i.W+i.F,x),y||m.setStrong(_,e,v),_}},{"./_an-instance":80,"./_array-methods":84,"./_descriptors":98,"./_export":102,"./_fails":103,"./_for-of":104,"./_global":105,"./_hide":107,"./_is-object":115,"./_meta":123,"./_object-dp":129,"./_redefine-all":143,"./_set-to-string-tag":149}],94:[function(e,t,n){var r=t.exports={version:"2.6.11"};"number"==typeof __e&&(__e=r)},{}],95:[function(e,t,n){"use strict";var r=e("./_object-dp"),i=e("./_property-desc");t.exports=function(e,t,n){t in e?r.f(e,t,i(0,n)):e[t]=n}},{"./_object-dp":129,"./_property-desc":142}],96:[function(e,t,n){var r=e("./_a-function");t.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},{"./_a-function":78}],97:[function(e,t,n){t.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},{}],98:[function(e,t,n){t.exports=!e("./_fails")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},{"./_fails":103}],99:[function(e,t,n){var r=e("./_is-object"),i=e("./_global").document,s=r(i)&&r(i.createElement);t.exports=function(e){return s?i.createElement(e):{}}},{"./_global":105,"./_is-object":115}],100:[function(e,t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},{}],101:[function(e,t,n){var r=e("./_object-keys"),i=e("./_object-gops"),s=e("./_object-pie");t.exports=function(e){var t=r(e),n=i.f;if(n)for(var a,o=n(e),u=s.f,c=0;o.length>c;)u.call(e,a=o[c++])&&t.push(a);return t}},{"./_object-gops":134,"./_object-keys":137,"./_object-pie":138}],102:[function(e,t,n){var r=e("./_global"),i=e("./_core"),s=e("./_ctx"),a=e("./_hide"),o=e("./_has"),u=function(e,t,n){var c,l,d,f=e&u.F,p=e&u.G,h=e&u.S,b=e&u.P,m=e&u.B,v=e&u.W,y=p?i:i[t]||(i[t]={}),g=y.prototype,_=p?r:h?r[t]:(r[t]||{}).prototype;for(c in p&&(n=t),n)(l=!f&&_&&void 0!==_[c])&&o(y,c)||(d=l?_[c]:n[c],y[c]=p&&"function"!=typeof _[c]?n[c]:m&&l?s(d,r):v&&_[c]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t.prototype=e.prototype,t}(d):b&&"function"==typeof d?s(Function.call,d):d,b&&((y.virtual||(y.virtual={}))[c]=d,e&u.R&&g&&!g[c]&&a(g,c,d)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},{"./_core":94,"./_ctx":96,"./_global":105,"./_has":106,"./_hide":107}],103:[function(e,t,n){t.exports=function(e){try{return!!e()}catch(e){return!0}}},{}],104:[function(e,t,n){var r=e("./_ctx"),i=e("./_iter-call"),s=e("./_is-array-iter"),a=e("./_an-object"),o=e("./_to-length"),u=e("./core.get-iterator-method"),c={},l={};(n=t.exports=function(e,t,n,d,f){var p,h,b,m,v=f?function(){return e}:u(e),y=r(n,d,t?2:1),g=0;if("function"!=typeof v)throw TypeError(e+" is not iterable!");if(s(v)){for(p=o(e.length);p>g;g++)if((m=t?y(a(h=e[g])[0],h[1]):y(e[g]))===c||m===l)return m}else for(b=v.call(e);!(h=b.next()).done;)if((m=i(b,y,h.value,t))===c||m===l)return m}).BREAK=c,n.RETURN=l},{"./_an-object":81,"./_ctx":96,"./_is-array-iter":112,"./_iter-call":116,"./_to-length":158,"./core.get-iterator-method":167}],105:[function(e,t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},{}],106:[function(e,t,n){var r={}.hasOwnProperty;t.exports=function(e,t){return r.call(e,t)}},{}],107:[function(e,t,n){var r=e("./_object-dp"),i=e("./_property-desc");t.exports=e("./_descriptors")?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},{"./_descriptors":98,"./_object-dp":129,"./_property-desc":142}],108:[function(e,t,n){var r=e("./_global").document;t.exports=r&&r.documentElement},{"./_global":105}],109:[function(e,t,n){t.exports=!e("./_descriptors")&&!e("./_fails")(function(){return 7!=Object.defineProperty(e("./_dom-create")("div"),"a",{get:function(){return 7}}).a})},{"./_descriptors":98,"./_dom-create":99,"./_fails":103}],110:[function(e,t,n){t.exports=function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},{}],111:[function(e,t,n){var r=e("./_cof");t.exports=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==r(e)?e.split(""):Object(e)}},{"./_cof":89}],112:[function(e,t,n){var r=e("./_iterators"),i=e("./_wks")("iterator"),s=Array.prototype;t.exports=function(e){return void 0!==e&&(r.Array===e||s[i]===e)}},{"./_iterators":121,"./_wks":166}],113:[function(e,t,n){var r=e("./_cof");t.exports=Array.isArray||function(e){return"Array"==r(e)}},{"./_cof":89}],114:[function(e,t,n){var r=e("./_is-object"),i=Math.floor;t.exports=function(e){return!r(e)&&isFinite(e)&&i(e)===e}},{"./_is-object":115}],115:[function(e,t,n){t.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},{}],116:[function(e,t,n){var r=e("./_an-object");t.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var s=e.return;throw void 0!==s&&r(s.call(e)),t}}},{"./_an-object":81}],117:[function(e,t,n){"use strict";var r=e("./_object-create"),i=e("./_property-desc"),s=e("./_set-to-string-tag"),a={};e("./_hide")(a,e("./_wks")("iterator"),function(){return this}),t.exports=function(e,t,n){e.prototype=r(a,{next:i(1,n)}),s(e,t+" Iterator")}},{"./_hide":107,"./_object-create":128,"./_property-desc":142,"./_set-to-string-tag":149,"./_wks":166}],118:[function(e,t,n){"use strict";var r=e("./_library"),i=e("./_export"),s=e("./_redefine"),a=e("./_hide"),o=e("./_iterators"),u=e("./_iter-create"),c=e("./_set-to-string-tag"),l=e("./_object-gpo"),d=e("./_wks")("iterator"),f=!([].keys&&"next"in[].keys()),p=function(){return this};t.exports=function(e,t,n,h,b,m,v){u(n,t,h);var y,g,_,k=function(e){if(!f&&e in j)return j[e];switch(e){case"keys":case"values":return function(){return new n(this,e)}}return function(){return new n(this,e)}},w=t+" Iterator",x="values"==b,C=!1,j=e.prototype,S=j[d]||j["@@iterator"]||b&&j[b],T=S||k(b),E=b?x?k("entries"):T:void 0,M="Array"==t&&j.entries||S;if(M&&(_=l(M.call(new e)))!==Object.prototype&&_.next&&(c(_,w,!0),r||"function"==typeof _[d]||a(_,d,p)),x&&S&&"values"!==S.name&&(C=!0,T=function(){return S.call(this)}),r&&!v||!f&&!C&&j[d]||a(j,d,T),o[t]=T,o[w]=p,b)if(y={values:x?T:k("values"),keys:m?T:k("keys"),entries:E},v)for(g in y)g in j||s(j,g,y[g]);else i(i.P+i.F*(f||C),t,y);return y}},{"./_export":102,"./_hide":107,"./_iter-create":117,"./_iterators":121,"./_library":122,"./_object-gpo":135,"./_redefine":144,"./_set-to-string-tag":149,"./_wks":166}],119:[function(e,t,n){var r=e("./_wks")("iterator"),i=!1;try{var s=[7][r]();s.return=function(){i=!0},Array.from(s,function(){throw 2})}catch(e){}t.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var s=[7],a=s[r]();a.next=function(){return{done:n=!0}},s[r]=function(){return a},e(s)}catch(e){}return n}},{"./_wks":166}],120:[function(e,t,n){t.exports=function(e,t){return{value:t,done:!!e}}},{}],121:[function(e,t,n){t.exports={}},{}],122:[function(e,t,n){t.exports=!0},{}],123:[function(e,t,n){var r=e("./_uid")("meta"),i=e("./_is-object"),s=e("./_has"),a=e("./_object-dp").f,o=0,u=Object.isExtensible||function(){return!0},c=!e("./_fails")(function(){return u(Object.preventExtensions({}))}),l=function(e){a(e,r,{value:{i:"O"+ ++o,w:{}}})},d=t.exports={KEY:r,NEED:!1,fastKey:function(e,t){if(!i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!s(e,r)){if(!u(e))return"F";if(!t)return"E";l(e)}return e[r].i},getWeak:function(e,t){if(!s(e,r)){if(!u(e))return!0;if(!t)return!1;l(e)}return e[r].w},onFreeze:function(e){return c&&d.NEED&&u(e)&&!s(e,r)&&l(e),e}}},{"./_fails":103,"./_has":106,"./_is-object":115,"./_object-dp":129,"./_uid":161}],124:[function(e,t,n){var r=e("./es6.map"),i=e("./_export"),s=e("./_shared")("metadata"),a=s.store||(s.store=new(e("./es6.weak-map"))),o=function(e,t,n){var i=a.get(e);if(!i){if(!n)return;a.set(e,i=new r)}var s=i.get(t);if(!s){if(!n)return;i.set(t,s=new r)}return s};t.exports={store:a,map:o,has:function(e,t,n){var r=o(t,n,!1);return void 0!==r&&r.has(e)},get:function(e,t,n){var r=o(t,n,!1);return void 0===r?void 0:r.get(e)},set:function(e,t,n,r){o(n,r,!0).set(e,t)},keys:function(e,t){var n=o(e,t,!1),r=[];return n&&n.forEach(function(e,t){r.push(t)}),r},key:function(e){return void 0===e||"symbol"==typeof e?e:String(e)},exp:function(e){i(i.S,"Reflect",e)}}},{"./_export":102,"./_shared":151,"./es6.map":172,"./es6.weak-map":187}],125:[function(e,t,n){var r=e("./_global"),i=e("./_task").set,s=r.MutationObserver||r.WebKitMutationObserver,a=r.process,o=r.Promise,u="process"==e("./_cof")(a);t.exports=function(){var e,t,n,c=function(){var r,i;for(u&&(r=a.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(u)n=function(){a.nextTick(c)};else if(!s||r.navigator&&r.navigator.standalone)if(o&&o.resolve){var l=o.resolve(void 0);n=function(){l.then(c)}}else n=function(){i.call(r,c)};else{var d=!0,f=document.createTextNode("");new s(c).observe(f,{characterData:!0}),n=function(){f.data=d=!d}}return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},{"./_cof":89,"./_global":105,"./_task":154}],126:[function(e,t,n){"use strict";
128
- // 25.4.1.5 NewPromiseCapability(C)
129
- var r=e("./_a-function");function i(e){var t,n;this.promise=new e(function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r}),this.resolve=r(t),this.reject=r(n)}t.exports.f=function(e){return new i(e)}},{"./_a-function":78}],127:[function(e,t,n){"use strict";var r=e("./_descriptors"),i=e("./_object-keys"),s=e("./_object-gops"),a=e("./_object-pie"),o=e("./_to-object"),u=e("./_iobject"),c=Object.assign;t.exports=!c||e("./_fails")(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=c({},e)[n]||Object.keys(c({},t)).join("")!=r})?function(e,t){for(var n=o(e),c=arguments.length,l=1,d=s.f,f=a.f;c>l;)for(var p,h=u(arguments[l++]),b=d?i(h).concat(d(h)):i(h),m=b.length,v=0;m>v;)p=b[v++],r&&!f.call(h,p)||(n[p]=h[p]);return n}:c},{"./_descriptors":98,"./_fails":103,"./_iobject":111,"./_object-gops":134,"./_object-keys":137,"./_object-pie":138,"./_to-object":159}],128:[function(e,t,n){var r=e("./_an-object"),i=e("./_object-dps"),s=e("./_enum-bug-keys"),a=e("./_shared-key")("IE_PROTO"),o=function(){},u=function(){var t,n=e("./_dom-create")("iframe"),r=s.length;for(n.style.display="none",e("./_html").appendChild(n),n.src="javascript:",(t=n.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),u=t.F;r--;)delete u.prototype[s[r]];return u()};t.exports=Object.create||function(e,t){var n;return null!==e?(o.prototype=r(e),n=new o,o.prototype=null,n[a]=e):n=u(),void 0===t?n:i(n,t)}},{"./_an-object":81,"./_dom-create":99,"./_enum-bug-keys":100,"./_html":108,"./_object-dps":130,"./_shared-key":150}],129:[function(e,t,n){var r=e("./_an-object"),i=e("./_ie8-dom-define"),s=e("./_to-primitive"),a=Object.defineProperty;n.f=e("./_descriptors")?Object.defineProperty:function(e,t,n){if(r(e),t=s(t,!0),r(n),i)try{return a(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},{"./_an-object":81,"./_descriptors":98,"./_ie8-dom-define":109,"./_to-primitive":160}],130:[function(e,t,n){var r=e("./_object-dp"),i=e("./_an-object"),s=e("./_object-keys");t.exports=e("./_descriptors")?Object.defineProperties:function(e,t){i(e);for(var n,a=s(t),o=a.length,u=0;o>u;)r.f(e,n=a[u++],t[n]);return e}},{"./_an-object":81,"./_descriptors":98,"./_object-dp":129,"./_object-keys":137}],131:[function(e,t,n){var r=e("./_object-pie"),i=e("./_property-desc"),s=e("./_to-iobject"),a=e("./_to-primitive"),o=e("./_has"),u=e("./_ie8-dom-define"),c=Object.getOwnPropertyDescriptor;n.f=e("./_descriptors")?c:function(e,t){if(e=s(e),t=a(t,!0),u)try{return c(e,t)}catch(e){}if(o(e,t))return i(!r.f.call(e,t),e[t])}},{"./_descriptors":98,"./_has":106,"./_ie8-dom-define":109,"./_object-pie":138,"./_property-desc":142,"./_to-iobject":157,"./_to-primitive":160}],132:[function(e,t,n){var r=e("./_to-iobject"),i=e("./_object-gopn").f,s={}.toString,a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(e){return a&&"[object Window]"==s.call(e)?function(e){try{return i(e)}catch(e){return a.slice()}}(e):i(r(e))}},{"./_object-gopn":133,"./_to-iobject":157}],133:[function(e,t,n){var r=e("./_object-keys-internal"),i=e("./_enum-bug-keys").concat("length","prototype");n.f=Object.getOwnPropertyNames||function(e){return r(e,i)}},{"./_enum-bug-keys":100,"./_object-keys-internal":136}],134:[function(e,t,n){n.f=Object.getOwnPropertySymbols},{}],135:[function(e,t,n){var r=e("./_has"),i=e("./_to-object"),s=e("./_shared-key")("IE_PROTO"),a=Object.prototype;t.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,s)?e[s]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?a:null}},{"./_has":106,"./_shared-key":150,"./_to-object":159}],136:[function(e,t,n){var r=e("./_has"),i=e("./_to-iobject"),s=e("./_array-includes")(!1),a=e("./_shared-key")("IE_PROTO");t.exports=function(e,t){var n,o=i(e),u=0,c=[];for(n in o)n!=a&&r(o,n)&&c.push(n);for(;t.length>u;)r(o,n=t[u++])&&(~s(c,n)||c.push(n));return c}},{"./_array-includes":83,"./_has":106,"./_shared-key":150,"./_to-iobject":157}],137:[function(e,t,n){var r=e("./_object-keys-internal"),i=e("./_enum-bug-keys");t.exports=Object.keys||function(e){return r(e,i)}},{"./_enum-bug-keys":100,"./_object-keys-internal":136}],138:[function(e,t,n){n.f={}.propertyIsEnumerable},{}],139:[function(e,t,n){var r=e("./_export"),i=e("./_core"),s=e("./_fails");t.exports=function(e,t){var n=(i.Object||{})[e]||Object[e],a={};a[e]=t(n),r(r.S+r.F*s(function(){n(1)}),"Object",a)}},{"./_core":94,"./_export":102,"./_fails":103}],140:[function(e,t,n){t.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},{}],141:[function(e,t,n){var r=e("./_an-object"),i=e("./_is-object"),s=e("./_new-promise-capability");t.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=s.f(e);return(0,n.resolve)(t),n.promise}},{"./_an-object":81,"./_is-object":115,"./_new-promise-capability":126}],142:[function(e,t,n){t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},{}],143:[function(e,t,n){var r=e("./_hide");t.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},{"./_hide":107}],144:[function(e,t,n){t.exports=e("./_hide")},{"./_hide":107}],145:[function(e,t,n){"use strict";var r=e("./_export"),i=e("./_a-function"),s=e("./_ctx"),a=e("./_for-of");t.exports=function(e){r(r.S,e,{from:function(e){var t,n,r,o,u=arguments[1];return i(this),(t=void 0!==u)&&i(u),null==e?new this:(n=[],t?(r=0,o=s(u,arguments[2],2),a(e,!1,function(e){n.push(o(e,r++))})):a(e,!1,n.push,n),new this(n))}})}},{"./_a-function":78,"./_ctx":96,"./_export":102,"./_for-of":104}],146:[function(e,t,n){"use strict";var r=e("./_export");t.exports=function(e){r(r.S,e,{of:function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];return new this(t)}})}},{"./_export":102}],147:[function(e,t,n){var r=e("./_is-object"),i=e("./_an-object"),s=function(e,t){if(i(e),!r(t)&&null!==t)throw TypeError(t+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,r){try{(r=e("./_ctx")(Function.call,e("./_object-gopd").f(Object.prototype,"__proto__").set,2))(t,[]),n=!(t instanceof Array)}catch(e){n=!0}return function(e,t){return s(e,t),n?e.__proto__=t:r(e,t),e}}({},!1):void 0),check:s}},{"./_an-object":81,"./_ctx":96,"./_is-object":115,"./_object-gopd":131}],148:[function(e,t,n){"use strict";var r=e("./_global"),i=e("./_core"),s=e("./_object-dp"),a=e("./_descriptors"),o=e("./_wks")("species");t.exports=function(e){var t="function"==typeof i[e]?i[e]:r[e];a&&t&&!t[o]&&s.f(t,o,{configurable:!0,get:function(){return this}})}},{"./_core":94,"./_descriptors":98,"./_global":105,"./_object-dp":129,"./_wks":166}],149:[function(e,t,n){var r=e("./_object-dp").f,i=e("./_has"),s=e("./_wks")("toStringTag");t.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,s)&&r(e,s,{configurable:!0,value:t})}},{"./_has":106,"./_object-dp":129,"./_wks":166}],150:[function(e,t,n){var r=e("./_shared")("keys"),i=e("./_uid");t.exports=function(e){return r[e]||(r[e]=i(e))}},{"./_shared":151,"./_uid":161}],151:[function(e,t,n){var r=e("./_core"),i=e("./_global"),s=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(t.exports=function(e,t){return s[e]||(s[e]=void 0!==t?t:{})})("versions",[]).push({version:r.version,mode:e("./_library")?"pure":"global",copyright:"\xa9 2019 Denis Pushkarev (zloirock.ru)"})},{"./_core":94,"./_global":105,"./_library":122}],152:[function(e,t,n){var r=e("./_an-object"),i=e("./_a-function"),s=e("./_wks")("species");t.exports=function(e,t){var n,a=r(e).constructor;return void 0===a||null==(n=r(a)[s])?t:i(n)}},{"./_a-function":78,"./_an-object":81,"./_wks":166}],153:[function(e,t,n){var r=e("./_to-integer"),i=e("./_defined");t.exports=function(e){return function(t,n){var s,a,o=String(i(t)),u=r(n),c=o.length;return u<0||u>=c?e?"":void 0:(s=o.charCodeAt(u))<55296||s>56319||u+1===c||(a=o.charCodeAt(u+1))<56320||a>57343?e?o.charAt(u):s:e?o.slice(u,u+2):a-56320+(s-55296<<10)+65536}}},{"./_defined":97,"./_to-integer":156}],154:[function(e,t,n){var r,i,s,a=e("./_ctx"),o=e("./_invoke"),u=e("./_html"),c=e("./_dom-create"),l=e("./_global"),d=l.process,f=l.setImmediate,p=l.clearImmediate,h=l.MessageChannel,b=l.Dispatch,m=0,v={},y=function(){var e=+this;if(v.hasOwnProperty(e)){var t=v[e];delete v[e],t()}},g=function(e){y.call(e.data)};f&&p||(f=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return v[++m]=function(){o("function"==typeof e?e:Function(e),t)},r(m),m},p=function(e){delete v[e]},"process"==e("./_cof")(d)?r=function(e){d.nextTick(a(y,e,1))}:b&&b.now?r=function(e){b.now(a(y,e,1))}:h?(s=(i=new h).port2,i.port1.onmessage=g,r=a(s.postMessage,s,1)):l.addEventListener&&"function"==typeof postMessage&&!l.importScripts?(r=function(e){l.postMessage(e+"","*")},l.addEventListener("message",g,!1)):r="onreadystatechange"in c("script")?function(e){u.appendChild(c("script")).onreadystatechange=function(){u.removeChild(this),y.call(e)}}:function(e){setTimeout(a(y,e,1),0)}),t.exports={set:f,clear:p}},{"./_cof":89,"./_ctx":96,"./_dom-create":99,"./_global":105,"./_html":108,"./_invoke":110}],155:[function(e,t,n){var r=e("./_to-integer"),i=Math.max,s=Math.min;t.exports=function(e,t){return(e=r(e))<0?i(e+t,0):s(e,t)}},{"./_to-integer":156}],156:[function(e,t,n){var r=Math.ceil,i=Math.floor;t.exports=function(e){return isNaN(e=+e)?0:(e>0?i:r)(e)}},{}],157:[function(e,t,n){var r=e("./_iobject"),i=e("./_defined");t.exports=function(e){return r(i(e))}},{"./_defined":97,"./_iobject":111}],158:[function(e,t,n){var r=e("./_to-integer"),i=Math.min;t.exports=function(e){return e>0?i(r(e),9007199254740991):0}},{"./_to-integer":156}],159:[function(e,t,n){var r=e("./_defined");t.exports=function(e){return Object(r(e))}},{"./_defined":97}],160:[function(e,t,n){var r=e("./_is-object");t.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},{"./_is-object":115}],161:[function(e,t,n){var r=0,i=Math.random();t.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++r+i).toString(36))}},{}],162:[function(e,t,n){var r=e("./_global").navigator;t.exports=r&&r.userAgent||""},{"./_global":105}],163:[function(e,t,n){var r=e("./_is-object");t.exports=function(e,t){if(!r(e)||e._t!==t)throw TypeError("Incompatible receiver, "+t+" required!");return e}},{"./_is-object":115}],164:[function(e,t,n){var r=e("./_global"),i=e("./_core"),s=e("./_library"),a=e("./_wks-ext"),o=e("./_object-dp").f;t.exports=function(e){var t=i.Symbol||(i.Symbol=s?{}:r.Symbol||{});"_"==e.charAt(0)||e in t||o(t,e,{value:a.f(e)})}},{"./_core":94,"./_global":105,"./_library":122,"./_object-dp":129,"./_wks-ext":165}],165:[function(e,t,n){n.f=e("./_wks")},{"./_wks":166}],166:[function(e,t,n){var r=e("./_shared")("wks"),i=e("./_uid"),s=e("./_global").Symbol,a="function"==typeof s;(t.exports=function(e){return r[e]||(r[e]=a&&s[e]||(a?s:i)("Symbol."+e))}).store=r},{"./_global":105,"./_shared":151,"./_uid":161}],167:[function(e,t,n){var r=e("./_classof"),i=e("./_wks")("iterator"),s=e("./_iterators");t.exports=e("./_core").getIteratorMethod=function(e){if(null!=e)return e[i]||e["@@iterator"]||s[r(e)]}},{"./_classof":88,"./_core":94,"./_iterators":121,"./_wks":166}],168:[function(e,t,n){var r=e("./_an-object"),i=e("./core.get-iterator-method");t.exports=e("./_core").getIterator=function(e){var t=i(e);if("function"!=typeof t)throw TypeError(e+" is not iterable!");return r(t.call(e))}},{"./_an-object":81,"./_core":94,"./core.get-iterator-method":167}],169:[function(e,t,n){var r=e("./_classof"),i=e("./_wks")("iterator"),s=e("./_iterators");t.exports=e("./_core").isIterable=function(e){var t=Object(e);return void 0!==t[i]||"@@iterator"in t||s.hasOwnProperty(r(t))}},{"./_classof":88,"./_core":94,"./_iterators":121,"./_wks":166}],170:[function(e,t,n){"use strict";var r=e("./_ctx"),i=e("./_export"),s=e("./_to-object"),a=e("./_iter-call"),o=e("./_is-array-iter"),u=e("./_to-length"),c=e("./_create-property"),l=e("./core.get-iterator-method");i(i.S+i.F*!e("./_iter-detect")(function(e){Array.from(e)}),"Array",{from:function(e){var t,n,i,d,f=s(e),p="function"==typeof this?this:Array,h=arguments.length,b=h>1?arguments[1]:void 0,m=void 0!==b,v=0,y=l(f);if(m&&(b=r(b,h>2?arguments[2]:void 0,2)),null==y||p==Array&&o(y))for(n=new p(t=u(f.length));t>v;v++)c(n,v,m?b(f[v],v):f[v]);else for(d=y.call(f),n=new p;!(i=d.next()).done;v++)c(n,v,m?a(d,b,[i.value,v],!0):i.value);return n.length=v,n}})},{"./_create-property":95,"./_ctx":96,"./_export":102,"./_is-array-iter":112,"./_iter-call":116,"./_iter-detect":119,"./_to-length":158,"./_to-object":159,"./core.get-iterator-method":167}],171:[function(e,t,n){"use strict";var r=e("./_add-to-unscopables"),i=e("./_iter-step"),s=e("./_iterators"),a=e("./_to-iobject");t.exports=e("./_iter-define")(Array,"Array",function(e,t){this._t=a(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):i(0,"keys"==t?n:"values"==t?e[n]:[n,e[n]])},"values"),s.Arguments=s.Array,r("keys"),r("values"),r("entries")},{"./_add-to-unscopables":79,"./_iter-define":118,"./_iter-step":120,"./_iterators":121,"./_to-iobject":157}],172:[function(e,t,n){"use strict";var r=e("./_collection-strong"),i=e("./_validate-collection");t.exports=e("./_collection")("Map",function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{get:function(e){var t=r.getEntry(i(this,"Map"),e);return t&&t.v},set:function(e,t){return r.def(i(this,"Map"),0===e?0:e,t)}},r,!0)},{"./_collection":93,"./_collection-strong":90,"./_validate-collection":163}],173:[function(e,t,n){var r=e("./_export");r(r.S,"Number",{isInteger:e("./_is-integer")})},{"./_export":102,"./_is-integer":114}],174:[function(e,t,n){var r=e("./_export");r(r.S+r.F,"Object",{assign:e("./_object-assign")})},{"./_export":102,"./_object-assign":127}],175:[function(e,t,n){var r=e("./_export");r(r.S,"Object",{create:e("./_object-create")})},{"./_export":102,"./_object-create":128}],176:[function(e,t,n){var r=e("./_export");r(r.S+r.F*!e("./_descriptors"),"Object",{defineProperty:e("./_object-dp").f})},{"./_descriptors":98,"./_export":102,"./_object-dp":129}],177:[function(e,t,n){var r=e("./_to-iobject"),i=e("./_object-gopd").f;e("./_object-sap")("getOwnPropertyDescriptor",function(){return function(e,t){return i(r(e),t)}})},{"./_object-gopd":131,"./_object-sap":139,"./_to-iobject":157}],178:[function(e,t,n){var r=e("./_to-object"),i=e("./_object-gpo");e("./_object-sap")("getPrototypeOf",function(){return function(e){return i(r(e))}})},{"./_object-gpo":135,"./_object-sap":139,"./_to-object":159}],179:[function(e,t,n){var r=e("./_to-object"),i=e("./_object-keys");e("./_object-sap")("keys",function(){return function(e){return i(r(e))}})},{"./_object-keys":137,"./_object-sap":139,"./_to-object":159}],180:[function(e,t,n){var r=e("./_export");r(r.S,"Object",{setPrototypeOf:e("./_set-proto").set})},{"./_export":102,"./_set-proto":147}],181:[function(e,t,n){},{}],182:[function(e,t,n){"use strict";var r,i,s,a,o=e("./_library"),u=e("./_global"),c=e("./_ctx"),l=e("./_classof"),d=e("./_export"),f=e("./_is-object"),p=e("./_a-function"),h=e("./_an-instance"),b=e("./_for-of"),m=e("./_species-constructor"),v=e("./_task").set,y=e("./_microtask")(),g=e("./_new-promise-capability"),_=e("./_perform"),k=e("./_user-agent"),w=e("./_promise-resolve"),x=u.TypeError,C=u.process,j=C&&C.versions,S=j&&j.v8||"",T=u.Promise,E="process"==l(C),M=function(){},I=i=g.f,R=!!function(){try{var t=T.resolve(1),n=(t.constructor={})[e("./_wks")("species")]=function(e){e(M,M)};return(E||"function"==typeof PromiseRejectionEvent)&&t.then(M)instanceof n&&0!==S.indexOf("6.6")&&-1===k.indexOf("Chrome/66")}catch(e){}}(),P=function(e){var t;return!(!f(e)||"function"!=typeof(t=e.then))&&t},O=function(e,t){if(!e._n){e._n=!0;var n=e._c;y(function(){for(var r=e._v,i=1==e._s,s=0,a=function(t){var n,s,a,o=i?t.ok:t.fail,u=t.resolve,c=t.reject,l=t.domain;try{o?(i||(2==e._h&&A(e),e._h=1),!0===o?n=r:(l&&l.enter(),n=o(r),l&&(l.exit(),a=!0)),n===t.promise?c(x("Promise-chain cycle")):(s=P(n))?s.call(n,u,c):u(n)):c(r)}catch(e){l&&!a&&l.exit(),c(e)}};n.length>s;)a(n[s++]);e._c=[],e._n=!1,t&&!e._h&&L(e)})}},L=function(e){v.call(u,function(){var t,n,r,i=e._v,s=N(e);if(s&&(t=_(function(){E?C.emit("unhandledRejection",i,e):(n=u.onunhandledrejection)?n({promise:e,reason:i}):(r=u.console)&&r.error&&r.error("Unhandled promise rejection",i)}),e._h=E||N(e)?2:1),e._a=void 0,s&&t.e)throw t.v})},N=function(e){return 1!==e._h&&0===(e._a||e._c).length},A=function(e){v.call(u,function(){var t;E?C.emit("rejectionHandled",e):(t=u.onrejectionhandled)&&t({promise:e,reason:e._v})})},D=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),O(t,!0))},U=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw x("Promise can't be resolved itself");(t=P(e))?y(function(){var r={_w:n,_d:!1};try{t.call(e,c(U,r,1),c(D,r,1))}catch(e){D.call(r,e)}}):(n._v=e,n._s=1,O(n,!1))}catch(e){D.call({_w:n,_d:!1},e)}}};R||(T=function(e){h(this,T,"Promise","_h"),p(e),r.call(this);try{e(c(U,this,1),c(D,this,1))}catch(e){D.call(this,e)}},(r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=e("./_redefine-all")(T.prototype,{then:function(e,t){var n=I(m(this,T));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=E?C.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&O(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),s=function(){var e=new r;this.promise=e,this.resolve=c(U,e,1),this.reject=c(D,e,1)},g.f=I=function(e){return e===T||e===a?new s(e):i(e)}),d(d.G+d.W+d.F*!R,{Promise:T}),e("./_set-to-string-tag")(T,"Promise"),e("./_set-species")("Promise"),a=e("./_core").Promise,d(d.S+d.F*!R,"Promise",{reject:function(e){var t=I(this);return(0,t.reject)(e),t.promise}}),d(d.S+d.F*(o||!R),"Promise",{resolve:function(e){return w(o&&this===a?T:this,e)}}),d(d.S+d.F*!(R&&e("./_iter-detect")(function(e){T.all(e).catch(M)})),"Promise",{all:function(e){var t=this,n=I(t),r=n.resolve,i=n.reject,s=_(function(){var n=[],s=0,a=1;b(e,!1,function(e){var o=s++,u=!1;n.push(void 0),a++,t.resolve(e).then(function(e){u||(u=!0,n[o]=e,--a||r(n))},i)}),--a||r(n)});return s.e&&i(s.v),n.promise},race:function(e){var t=this,n=I(t),r=n.reject,i=_(function(){b(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}})},{"./_a-function":78,"./_an-instance":80,"./_classof":88,"./_core":94,"./_ctx":96,"./_export":102,"./_for-of":104,"./_global":105,"./_is-object":115,"./_iter-detect":119,"./_library":122,"./_microtask":125,"./_new-promise-capability":126,"./_perform":140,"./_promise-resolve":141,"./_redefine-all":143,"./_set-species":148,"./_set-to-string-tag":149,"./_species-constructor":152,"./_task":154,"./_user-agent":162,"./_wks":166}],183:[function(e,t,n){var r=e("./_export"),i=e("./_object-create"),s=e("./_a-function"),a=e("./_an-object"),o=e("./_is-object"),u=e("./_fails"),c=e("./_bind"),l=(e("./_global").Reflect||{}).construct,d=u(function(){function e(){}return!(l(function(){},[],e)instanceof e)}),f=!u(function(){l(function(){})});r(r.S+r.F*(d||f),"Reflect",{construct:function(e,t){s(e),a(t);var n=arguments.length<3?e:s(arguments[2]);if(f&&!d)return l(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return r.push.apply(r,t),new(c.apply(e,r))}var u=n.prototype,p=i(o(u)?u:Object.prototype),h=Function.apply.call(e,p,t);return o(h)?h:p}})},{"./_a-function":78,"./_an-object":81,"./_bind":87,"./_export":102,"./_fails":103,"./_global":105,"./_is-object":115,"./_object-create":128}],184:[function(e,t,n){"use strict";var r=e("./_collection-strong"),i=e("./_validate-collection");t.exports=e("./_collection")("Set",function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},{add:function(e){return r.def(i(this,"Set"),e=0===e?0:e,e)}},r)},{"./_collection":93,"./_collection-strong":90,"./_validate-collection":163}],185:[function(e,t,n){"use strict";var r=e("./_string-at")(!0);e("./_iter-define")(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},{"./_iter-define":118,"./_string-at":153}],186:[function(e,t,n){"use strict";var r=e("./_global"),i=e("./_has"),s=e("./_descriptors"),a=e("./_export"),o=e("./_redefine"),u=e("./_meta").KEY,c=e("./_fails"),l=e("./_shared"),d=e("./_set-to-string-tag"),f=e("./_uid"),p=e("./_wks"),h=e("./_wks-ext"),b=e("./_wks-define"),m=e("./_enum-keys"),v=e("./_is-array"),y=e("./_an-object"),g=e("./_is-object"),_=e("./_to-object"),k=e("./_to-iobject"),w=e("./_to-primitive"),x=e("./_property-desc"),C=e("./_object-create"),j=e("./_object-gopn-ext"),S=e("./_object-gopd"),T=e("./_object-gops"),E=e("./_object-dp"),M=e("./_object-keys"),I=S.f,R=E.f,P=j.f,O=r.Symbol,L=r.JSON,N=L&&L.stringify,A=p("_hidden"),D=p("toPrimitive"),U={}.propertyIsEnumerable,F=l("symbol-registry"),q=l("symbols"),B=l("op-symbols"),z=Object.prototype,W="function"==typeof O&&!!T.f,G=r.QObject,H=!G||!G.prototype||!G.prototype.findChild,K=s&&c(function(){return 7!=C(R({},"a",{get:function(){return R(this,"a",{value:7}).a}})).a})?function(e,t,n){var r=I(z,t);r&&delete z[t],R(e,t,n),r&&e!==z&&R(z,t,r)}:R,V=function(e){var t=q[e]=C(O.prototype);return t._k=e,t},Q=W&&"symbol"==typeof O.iterator?function(e){return"symbol"==typeof e}:function(e){return e instanceof O},J=function(e,t,n){return e===z&&J(B,t,n),y(e),t=w(t,!0),y(n),i(q,t)?(n.enumerable?(i(e,A)&&e[A][t]&&(e[A][t]=!1),n=C(n,{enumerable:x(0,!1)})):(i(e,A)||R(e,A,x(1,{})),e[A][t]=!0),K(e,t,n)):R(e,t,n)},X=function(e,t){y(e);for(var n,r=m(t=k(t)),i=0,s=r.length;s>i;)J(e,n=r[i++],t[n]);return e},$=function(e){var t=U.call(this,e=w(e,!0));return!(this===z&&i(q,e)&&!i(B,e))&&(!(t||!i(this,e)||!i(q,e)||i(this,A)&&this[A][e])||t)},Y=function(e,t){if(e=k(e),t=w(t,!0),e!==z||!i(q,t)||i(B,t)){var n=I(e,t);return!n||!i(q,t)||i(e,A)&&e[A][t]||(n.enumerable=!0),n}},Z=function(e){for(var t,n=P(k(e)),r=[],s=0;n.length>s;)i(q,t=n[s++])||t==A||t==u||r.push(t);return r},ee=function(e){for(var t,n=e===z,r=P(n?B:k(e)),s=[],a=0;r.length>a;)!i(q,t=r[a++])||n&&!i(z,t)||s.push(q[t]);return s};W||(o((O=function(){if(this instanceof O)throw TypeError("Symbol is not a constructor!");var e=f(arguments.length>0?arguments[0]:void 0),t=function(n){this===z&&t.call(B,n),i(this,A)&&i(this[A],e)&&(this[A][e]=!1),K(this,e,x(1,n))};return s&&H&&K(z,e,{configurable:!0,set:t}),V(e)}).prototype,"toString",function(){return this._k}),S.f=Y,E.f=J,e("./_object-gopn").f=j.f=Z,e("./_object-pie").f=$,T.f=ee,s&&!e("./_library")&&o(z,"propertyIsEnumerable",$,!0),h.f=function(e){return V(p(e))}),a(a.G+a.W+a.F*!W,{Symbol:O});for(var te="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),ne=0;te.length>ne;)p(te[ne++]);for(var re=M(p.store),ie=0;re.length>ie;)b(re[ie++]);a(a.S+a.F*!W,"Symbol",{for:function(e){return i(F,e+="")?F[e]:F[e]=O(e)},keyFor:function(e){if(!Q(e))throw TypeError(e+" is not a symbol!");for(var t in F)if(F[t]===e)return t},useSetter:function(){H=!0},useSimple:function(){H=!1}}),a(a.S+a.F*!W,"Object",{create:function(e,t){return void 0===t?C(e):X(C(e),t)},defineProperty:J,defineProperties:X,getOwnPropertyDescriptor:Y,getOwnPropertyNames:Z,getOwnPropertySymbols:ee});var se=c(function(){T.f(1)});a(a.S+a.F*se,"Object",{getOwnPropertySymbols:function(e){return T.f(_(e))}}),L&&a(a.S+a.F*(!W||c(function(){var e=O();return"[null]"!=N([e])||"{}"!=N({a:e})||"{}"!=N(Object(e))})),"JSON",{stringify:function(e){for(var t,n,r=[e],i=1;arguments.length>i;)r.push(arguments[i++]);if(n=t=r[1],(g(t)||void 0!==e)&&!Q(e))return v(t)||(t=function(e,t){if("function"==typeof n&&(t=n.call(this,e,t)),!Q(t))return t}),r[1]=t,N.apply(L,r)}}),O.prototype[D]||e("./_hide")(O.prototype,D,O.prototype.valueOf),d(O,"Symbol"),d(Math,"Math",!0),d(r.JSON,"JSON",!0)},{"./_an-object":81,"./_descriptors":98,"./_enum-keys":101,"./_export":102,"./_fails":103,"./_global":105,"./_has":106,"./_hide":107,"./_is-array":113,"./_is-object":115,"./_library":122,"./_meta":123,"./_object-create":128,"./_object-dp":129,"./_object-gopd":131,"./_object-gopn":133,"./_object-gopn-ext":132,"./_object-gops":134,"./_object-keys":137,"./_object-pie":138,"./_property-desc":142,"./_redefine":144,"./_set-to-string-tag":149,"./_shared":151,"./_to-iobject":157,"./_to-object":159,"./_to-primitive":160,"./_uid":161,"./_wks":166,"./_wks-define":164,"./_wks-ext":165}],187:[function(e,t,n){"use strict";var r,i=e("./_global"),s=e("./_array-methods")(0),a=e("./_redefine"),o=e("./_meta"),u=e("./_object-assign"),c=e("./_collection-weak"),l=e("./_is-object"),d=e("./_validate-collection"),f=e("./_validate-collection"),p=!i.ActiveXObject&&"ActiveXObject"in i,h=o.getWeak,b=Object.isExtensible,m=c.ufstore,v=function(e){return function(){return e(this,arguments.length>0?arguments[0]:void 0)}},y={get:function(e){if(l(e)){var t=h(e);return!0===t?m(d(this,"WeakMap")).get(e):t?t[this._i]:void 0}},set:function(e,t){return c.def(d(this,"WeakMap"),e,t)}},g=t.exports=e("./_collection")("WeakMap",v,y,c,!0,!0);f&&p&&(u((r=c.getConstructor(v,"WeakMap")).prototype,y),o.NEED=!0,s(["delete","has","get","set"],function(e){var t=g.prototype,n=t[e];a(t,e,function(t,i){if(l(t)&&!b(t)){this._f||(this._f=new r);var s=this._f[e](t,i);return"set"==e?this:s}return n.call(this,t,i)})}))},{"./_array-methods":84,"./_collection":93,"./_collection-weak":92,"./_global":105,"./_is-object":115,"./_meta":123,"./_object-assign":127,"./_redefine":144,"./_validate-collection":163}],188:[function(e,t,n){e("./_set-collection-from")("Map")},{"./_set-collection-from":145}],189:[function(e,t,n){e("./_set-collection-of")("Map")},{"./_set-collection-of":146}],190:[function(e,t,n){var r=e("./_export");r(r.P+r.R,"Map",{toJSON:e("./_collection-to-json")("Map")})},{"./_collection-to-json":91,"./_export":102}],191:[function(e,t,n){"use strict";var r=e("./_export"),i=e("./_core"),s=e("./_global"),a=e("./_species-constructor"),o=e("./_promise-resolve");r(r.P+r.R,"Promise",{finally:function(e){var t=a(this,i.Promise||s.Promise),n="function"==typeof e;return this.then(n?function(n){return o(t,e()).then(function(){return n})}:e,n?function(n){return o(t,e()).then(function(){throw n})}:e)}})},{"./_core":94,"./_export":102,"./_global":105,"./_promise-resolve":141,"./_species-constructor":152}],192:[function(e,t,n){"use strict";var r=e("./_export"),i=e("./_new-promise-capability"),s=e("./_perform");r(r.S,"Promise",{try:function(e){var t=i.f(this),n=s(e);return(n.e?t.reject:t.resolve)(n.v),t.promise}})},{"./_export":102,"./_new-promise-capability":126,"./_perform":140}],193:[function(e,t,n){var r=e("./_metadata"),i=e("./_an-object"),s=e("./_a-function"),a=r.key,o=r.set;r.exp({metadata:function(e,t){return function(n,r){o(e,t,(void 0!==r?i:s)(n),a(r))}}})},{"./_a-function":78,"./_an-object":81,"./_metadata":124}],194:[function(e,t,n){e("./_set-collection-from")("Set")},{"./_set-collection-from":145}],195:[function(e,t,n){e("./_set-collection-of")("Set")},{"./_set-collection-of":146}],196:[function(e,t,n){var r=e("./_export");r(r.P+r.R,"Set",{toJSON:e("./_collection-to-json")("Set")})},{"./_collection-to-json":91,"./_export":102}],197:[function(e,t,n){e("./_wks-define")("asyncIterator")},{"./_wks-define":164}],198:[function(e,t,n){e("./_wks-define")("observable")},{"./_wks-define":164}],199:[function(e,t,n){e("./es6.array.iterator");for(var r=e("./_global"),i=e("./_hide"),s=e("./_iterators"),a=e("./_wks")("toStringTag"),o="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),u=0;u<o.length;u++){var c=o[u],l=r[c],d=l&&l.prototype;d&&!d[a]&&i(d,a,c),s[c]=s.Array}},{"./_global":105,"./_hide":107,"./_iterators":121,"./_wks":166,"./es6.array.iterator":171}],200:[function(e,t,n){
130
- // Copyright Joyent, Inc. and other Node contributors.
131
- //
132
- // Permission is hereby granted, free of charge, to any person obtaining a
133
- // copy of this software and associated documentation files (the
134
- // "Software"), to deal in the Software without restriction, including
135
- // without limitation the rights to use, copy, modify, merge, publish,
136
- // distribute, sublicense, and/or sell copies of the Software, and to permit
137
- // persons to whom the Software is furnished to do so, subject to the
138
- // following conditions:
139
- //
140
- // The above copyright notice and this permission notice shall be included
141
- // in all copies or substantial portions of the Software.
142
- //
143
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
144
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
145
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
146
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
147
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
148
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
149
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
150
- var r=Object.create||function(e){var t=function(){};return t.prototype=e,new t},i=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},s=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function a(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=r(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._maxListeners=void 0;var o,u=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),o=0===c.x}catch(e){o=!1}function l(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function d(e,t,n,i){var s,a,o;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),o=a[t]):(a=e._events=r(null),e._eventsCount=0),o){if("function"==typeof o?o=a[t]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),!o.warned&&(s=l(e))&&s>0&&o.length>s){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else o=a[t]=n,++e._eventsCount;return e}function f(){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 p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=s.call(f,r);return i.listener=n,r.wrapFn=i,i}function h(e,t,n){var r=e._events;if(!r)return[];var i=r[t];return i?"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):m(i,i.length):[]}function b(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 m(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}o?Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');u=e}}):a.defaultMaxListeners=u,a.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},a.prototype.getMaxListeners=function(){return l(this)},a.prototype.emit=function(e){var t,n,r,i,s,a,o="error"===e;if(a=this._events)o=o&&null==a.error;else if(!o)return!1;if(o){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var u=new Error('Unhandled "error" event. ('+t+")");throw u.context=t,u}if(!(n=a[e]))return!1;var c="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=m(e,r),s=0;s<r;++s)i[s].call(n)}(n,c,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=m(e,i),a=0;a<i;++a)s[a].call(n,r)}(n,c,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,a=m(e,s),o=0;o<s;++o)a[o].call(n,r,i)}(n,c,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var a=e.length,o=m(e,a),u=0;u<a;++u)o[u].call(n,r,i,s)}(n,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=m(e,i),a=0;a<i;++a)s[a].apply(n,r)}(n,c,this,i)}return!0},a.prototype.addListener=function(e,t){return d(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return d(this,e,t,!0)},a.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,p(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,p(this,e,t)),this},a.prototype.removeListener=function(e,t){var n,i,s,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(n=i[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=r(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(s=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,s=a;break}if(s<0)return this;0===s?n.shift():function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,s),1===n.length&&(i[e]=n[0]),i.removeListener&&this.emit("removeListener",e,o||t)}return this},a.prototype.removeAllListeners=function(e){var t,n,s;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 a,o=i(n);for(s=0;s<o.length;++s)"removeListener"!==(a=o[s])&&this.removeAllListeners(a);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(s=t.length-1;s>=0;s--)this.removeListener(e,t[s]);return this},a.prototype.listeners=function(e){return h(this,e,!0)},a.prototype.rawListeners=function(e){return h(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):b.call(e,t)},a.prototype.listenerCount=b,a.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],201:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=["weeks","years","months","days","hours","minutes","seconds"],i=n.pattern=new RegExp("P(?:(\\d+(?:[\\.,]\\d+)?W)|(\\d+(?:[\\.,]\\d+)?Y)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?D)?(?:T(\\d+(?:[\\.,]\\d+)?H)?(\\d+(?:[\\.,]\\d+)?M)?(\\d+(?:[\\.,]\\d+)?S)?)?)"),s=n.parse=function(e){return e.match(i).slice(1).reduce(function(e,t,n){return e[r[n]]=parseFloat(t)||0,e},{})},a=n.end=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return r.setFullYear(r.getFullYear()+e.years),r.setMonth(r.getMonth()+e.months),r.setDate(r.getDate()+e.days),r.setHours(r.getHours()+e.hours),r.setMinutes(r.getMinutes()+e.minutes),r.setMilliseconds(r.getMilliseconds()+1e3*e.seconds),r.setDate(r.getDate()+7*e.weeks),r},o=n.toSeconds=function(e,t){var n=t?t.getTime():Date.now(),r=new Date(n);return(a(e,r).getTime()-r.getTime())/1e3};n.default={end:a,toSeconds:o,pattern:i,parse:s}},{}],202:[function(e,t,n){var r,i;r=this,i=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){"use strict";e.exports=function(e,t){var n,r,i;for(n=1;n<arguments.length;n++)for(i in r=arguments[n])r.hasOwnProperty(i)&&(e[i]=r[i]);return e}},function(e,t,n){"use strict";var r=n(0);e.exports={build:function(e,t){var n,i,s,a=t.plugins;for(n=0,i=a.length;n<i;n++)(s=a[n]).methods&&r(e,s.methods),s.properties&&Object.defineProperties(e,s.properties)},hook:function(e,t,n){var r,i,s,a,o=e.config.plugins,u=[e.context];for(n&&(u=u.concat(n)),r=0,i=o.length;r<i;r++)a=o[r],(s=o[r][t])&&s.apply(a,u)}}},function(e,t,n){"use strict";function r(e){if(0===e.length)return e;var t,n,r=e.split(/[_-]/);if(1===r.length&&r[0][0].toLowerCase()===r[0][0])return e;for(n=r[0].toLowerCase(),t=1;t<r.length;t++)n=n+r[t].charAt(0).toUpperCase()+r[t].substring(1).toLowerCase();return n}r.prepended=function(e,t){return e+(t=r(t))[0].toUpperCase()+t.substring(1)},e.exports=r},function(e,t,n){"use strict";var r=n(0),i=n(2);function s(e,t){e=e||{},this.options=e,this.defaults=t.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(e.init),this.data=this.configureData(e.data),this.methods=this.configureMethods(e.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(e.transitions||[]),this.plugins=this.configurePlugins(e.plugins,t.plugin)}r(s.prototype,{addState:function(e){this.map[e]||(this.states.push(e),this.addStateLifecycleNames(e),this.map[e]={})},addStateLifecycleNames:function(e){this.lifecycle.onEnter[e]=i.prepended("onEnter",e),this.lifecycle.onLeave[e]=i.prepended("onLeave",e),this.lifecycle.on[e]=i.prepended("on",e)},addTransition:function(e){this.transitions.indexOf(e)<0&&(this.transitions.push(e),this.addTransitionLifecycleNames(e))},addTransitionLifecycleNames:function(e){this.lifecycle.onBefore[e]=i.prepended("onBefore",e),this.lifecycle.onAfter[e]=i.prepended("onAfter",e),this.lifecycle.on[e]=i.prepended("on",e)},mapTransition:function(e){var t=e.name,n=e.from,r=e.to;return this.addState(n),"function"!=typeof r&&this.addState(r),this.addTransition(t),this.map[n][t]=e,e},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(e){return"string"==typeof e?this.mapTransition(r({},this.defaults.init,{to:e,active:!0})):"object"==typeof e?this.mapTransition(r({},this.defaults.init,e,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(e){return"function"==typeof e?e:"object"==typeof e?function(){return e}:function(){return{}}},configureMethods:function(e){return e||{}},configurePlugins:function(e,t){var n,r,i;for(n=0,r=(e=e||[]).length;n<r;n++)"function"==typeof(i=e[n])&&(e[n]=i=i()),i.configure&&i.configure(this);return e},configureTransitions:function(e){var t,n,r,i,s,a=this.defaults.wildcard;for(n=0;n<e.length;n++)for(r=e[n],i=Array.isArray(r.from)?r.from:[r.from||a],s=r.to||a,t=0;t<i.length;t++)this.mapTransition({name:r.name,from:i[t],to:s})},transitionFor:function(e,t){var n=this.defaults.wildcard;return this.map[e][t]||this.map[n][t]},transitionsFor:function(e){var t=this.defaults.wildcard;return Object.keys(this.map[e]).concat(Object.keys(this.map[t]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),e.exports=s},function(e,t,n){var r=n(0),i=n(6),s=n(1),a=[null,[]];function o(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}r(o.prototype,{init:function(e){if(r(this.context,this.config.data.apply(this.context,e)),s.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(e){return Array.isArray(e)?e.indexOf(this.state)>=0:this.state===e},isPending:function(){return this.pending},can:function(e){return!this.isPending()&&!!this.seek(e)},cannot:function(e){return!this.can(e)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(e,t){var n=this.config.defaults.wildcard,r=this.config.transitionFor(this.state,e),i=r&&r.to;return"function"==typeof i?i.apply(this.context,t):i===n?this.state:i},fire:function(e,t){return this.transit(e,this.state,this.seek(e,t),t)},transit:function(e,t,n,r){var i=this.config.lifecycle,s=this.config.options.observeUnchangedState||t!==n;return n?this.isPending()?this.context.onPendingTransition(e,t,n):(this.config.addState(n),this.beginTransit(),r.unshift({transition:e,from:t,to:n,fsm:this.context}),this.observeEvents([this.observersForEvent(i.onBefore.transition),this.observersForEvent(i.onBefore[e]),s?this.observersForEvent(i.onLeave.state):a,s?this.observersForEvent(i.onLeave[t]):a,this.observersForEvent(i.on.transition),s?["doTransit",[this]]:a,s?this.observersForEvent(i.onEnter.state):a,s?this.observersForEvent(i.onEnter[n]):a,s?this.observersForEvent(i.on[n]):a,this.observersForEvent(i.onAfter.transition),this.observersForEvent(i.onAfter[e]),this.observersForEvent(i.on[e])],r)):this.context.onInvalidTransition(e,t,n)},beginTransit:function(){this.pending=!0},endTransit:function(e){return this.pending=!1,e},failTransit:function(e){throw this.pending=!1,e},doTransit:function(e){this.state=e.to},observe:function(e){if(2===e.length){var t={};t[e[0]]=e[1],this.observers.push(t)}else this.observers.push(e[0])},observersForEvent:function(e){for(var t,n=0,r=this.observers.length,i=[];n<r;n++)(t=this.observers[n])[e]&&i.push(t);return[e,i,!0]},observeEvents:function(e,t,n,r){if(0===e.length)return this.endTransit(void 0===r||r);var i=e[0][0],a=e[0][1],o=e[0][2];if(t[0].event=i,i&&o&&i!==n&&s.hook(this,"lifecycle",t),0===a.length)return e.shift(),this.observeEvents(e,t,i,r);var u=a.shift(),c=u[i].apply(u,t);return c&&"function"==typeof c.then?c.then(this.observeEvents.bind(this,e,t,i)).catch(this.failTransit.bind(this)):!1===c?this.endTransit(!1):this.observeEvents(e,t,i,c)},onInvalidTransition:function(e,t,n){throw new i("transition is invalid in current state",e,t,n,this.state)},onPendingTransition:function(e,t,n){throw new i("transition is invalid while previous transition is still in progress",e,t,n,this.state)}}),e.exports=o},function(e,t,n){"use strict";var r=n(0),i=n(2),s=n(1),a=n(3),o=n(4),u={is:function(e){return this._fsm.is(e)},can:function(e){return this._fsm.can(e)},cannot:function(e){return this._fsm.cannot(e)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(e,t,n){return this._fsm.onInvalidTransition(e,t,n)},onPendingTransition:function(e,t,n){return this._fsm.onPendingTransition(e,t,n)}},c={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(e){throw Error("use transitions to change state")}}};function l(e){return d(this||{},e)}function d(e,t){return f(e,new a(t,l)),e._fsm(),e}function f(e,t){if("object"!=typeof e||Array.isArray(e))throw Error("StateMachine can only be applied to objects");s.build(e,t),Object.defineProperties(e,c),r(e,u),r(e,t.methods),t.allTransitions().forEach(function(t){e[i(t)]=function(){return this._fsm.fire(t,[].slice.call(arguments))}}),e._fsm=function(){this._fsm=new o(this,t),this._fsm.init(arguments)}}l.version="3.0.1",l.factory=function(){var e,t;"function"==typeof arguments[0]?(e=arguments[0],t=arguments[1]||{}):(e=function(){this._fsm.apply(this,arguments)},t=arguments[0]||{});var n=new a(t,l);return f(e.prototype,n),e.prototype._fsm.config=n,e},l.apply=d,l.defaults={wildcard:"*",init:{name:"init",from:"none"}},e.exports=l},function(e,t,n){"use strict";e.exports=function(e,t,n,r,i){this.message=e,this.transition=t,this.from=n,this.to=r,this.current=i}}])},"object"==typeof n&&"object"==typeof t?t.exports=i():"object"==typeof n?n.StateMachine=i():r.StateMachine=i()},{}],203:[function(e,t,n){
151
- /*
152
- * loglevel - https://github.com/pimterry/loglevel
153
- *
154
- * Copyright (c) 2013 Tim Perry
155
- * Licensed under the MIT license.
156
- */
157
- !function(e,n){"use strict";"object"==typeof t&&t.exports?t.exports=n():e.log=n()}(this,function(){"use strict";var e=function(){},t="undefined",n=typeof window!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"];function i(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(t,n){for(var i=0;i<r.length;i++){var s=r[i];this[s]=i<t?e:this.methodFactory(s,t,n)}this.log=this.debug}function o(r,o,u){return function(r){return"debug"===r&&(r="log"),typeof console!==t&&("trace"===r&&n?s:void 0!==console[r]?i(console,r):void 0!==console.log?i(console,"log"):e)}(r)||function(e,n,r){return function(){typeof console!==t&&(a.call(this,n,r),this[e].apply(this,arguments))}}.apply(this,arguments)}function u(e,n,i){var s,u=this,c="loglevel";function l(){var e;if(typeof window!==t){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,r=n.indexOf(encodeURIComponent(c)+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r))[1])}catch(e){}return void 0===u.levels[e]&&(e=void 0),e}}e&&(c+=":"+e),u.name=e,u.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},u.methodFactory=i||o,u.getLevel=function(){return s},u.setLevel=function(n,i){if("string"==typeof n&&void 0!==u.levels[n.toUpperCase()]&&(n=u.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=u.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(s=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),a.call(u,n,e),typeof console===t&&n<u.levels.SILENT)return"No console available for logging"},u.setDefaultLevel=function(e){l()||u.setLevel(e,!1)},u.enableAll=function(e){u.setLevel(u.levels.TRACE,e)},u.disableAll=function(e){u.setLevel(u.levels.SILENT,e)};var d=l();null==d&&(d=null==n?"WARN":n),u.setLevel(d,!1)}var c=new u,l={};c.getLogger=function(e){if("string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=l[e];return t||(t=l[e]=new u(e,c.getLevel(),c.methodFactory)),t};var d=typeof window!==t?window.log:void 0;return c.noConflict=function(){return typeof window!==t&&window.log===c&&(window.log=d),c},c.getLoggers=function(){return l},c})},{}],204:[function(e,t,n){"use strict";var r=u(e("babel-runtime/core-js/object/get-prototype-of")),i=u(e("babel-runtime/helpers/classCallCheck")),s=u(e("babel-runtime/helpers/createClass")),a=u(e("babel-runtime/helpers/possibleConstructorReturn")),o=u(e("babel-runtime/helpers/inherits"));function u(e){return e&&e.__esModule?e:{default:e}}function c(e){return null!=e}Object.defineProperty(n,"__esModule",{value:!0});var l=function(e){function t(e){(0,i.default)(this,t);var n=(0,a.default)(this,(t.__proto__||(0,r.default)(t)).call(this));if(c((e=e||{}).initialDelay)&&e.initialDelay<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(c(e.maxDelay)&&e.maxDelay<=1)throw new Error("The maximal timeout must be greater than 1.");if(c(e.randomisationFactor)&&(e.randomisationFactor<0||e.randomisationFactor>1))throw new Error("The randomisation factor must be between 0 and 1.");if(c(e.factor)&&e.factor<=1)throw new Error("Exponential factor should be greater than 1.");if(n.initialDelay=e.initialDelay||100,n.maxDelay=e.maxDelay||1e4,n.maxDelay<=n.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return n.randomisationFactor=e.randomisationFactor||0,n.factor=e.factor||2,n.maxNumberOfRetry=-1,n.reset(),n}return(0,o.default)(t,e),(0,s.default)(t,[{key:"backoff",value:function(e){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",e),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,e)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(e){if(e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got "+e);this.maxNumberOfRetry=e}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var e=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*e))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(e){return new t(e)}}]),t}(e("events").EventEmitter);n.Backoff=l,n.default=l},{"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,events:200}],205:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./retrier");n.Retrier=r.Retrier;var i=e("./backoff");n.Backoff=i.Backoff,n.default=r.Retrier},{"./backoff":204,"./retrier":206}],206:[function(e,t,n){"use strict";var r=c(e("babel-runtime/core-js/promise")),i=c(e("babel-runtime/core-js/object/get-prototype-of")),s=c(e("babel-runtime/helpers/classCallCheck")),a=c(e("babel-runtime/helpers/createClass")),o=c(e("babel-runtime/helpers/possibleConstructorReturn")),u=c(e("babel-runtime/helpers/inherits"));function c(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var l=function(e){function t(e){(0,s.default)(this,t);var n=(0,o.default)(this,(t.__proto__||(0,i.default)(t)).call(this));return n.minDelay=e.min,n.maxDelay=e.max,n.initialDelay=e.initial||0,n.maxAttemptsCount=e.maxAttemptsCount||0,n.maxAttemptsTime=e.maxAttemptsTime||0,n.randomness=e.randomness||0,n.inProgress=!1,n.attemptNum=0,n.prevDelay=0,n.currDelay=0,n}return(0,u.default)(t,e),(0,a.default)(t,[{key:"attempt",value:function(){clearTimeout(this.timeout),this.attemptNum++,this.timeout=null,this.emit("attempt",this)}},{key:"nextDelay",value:function(e){if("number"==typeof e)return this.prevDelay=0,this.currDelay=e,e;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var t=this.currDelay+this.prevDelay;return this.maxDelay&&t>this.maxDelay&&(this.currDelay=this.maxDelay,t=this.maxDelay),this.currDelay=t,t}},{key:"randomize",value:function(e){var t=e*this.randomness,n=Math.round(Math.random()*t*2-t);return Math.max(0,e+n)}},{key:"scheduleAttempt",value:function(e){var t=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),this.emit("failed",new Error("Maximum attempt count limit reached")),void this.reject(new Error("Maximum attempt count reached"));var n=this.nextDelay(e);if(n=this.randomize(n),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+n)return this.cleanup(),this.emit("failed",new Error("Maximum attempt time limit reached")),void this.reject(new Error("Maximum attempt time limit reached"));this.timeout=setTimeout(function(){return t.attempt()},n)}},{key:"cleanup",value:function(){clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){var e=this;if(this.inProgress)throw new Error("Retrier is already in progress");return this.inProgress=!0,new r.default(function(t,n){e.resolve=t,e.reject=n,e.startTimestamp=Date.now(),e.scheduleAttempt(e.initialDelay)})}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"),this.reject(new Error("Cancelled")))}},{key:"succeeded",value:function(e){this.emit("succeeded",e),this.resolve(e)}},{key:"failed",value:function(e,t){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(t)}},{key:"run",value:function(e){var t=this;return this.on("attempt",function(){e().then(function(e){return t.succeeded(e)}).catch(function(e){return t.failed(e)})}),this.start()}}]),t}(e("events").EventEmitter);n.Retrier=l,n.default=l},{"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,events:200}],207:[function(e,t,n){(function(e){(function(){"use strict";var r={function:!0,object:!0},i=r[typeof window]&&window||this,s=r[typeof n]&&n,a=r[typeof t]&&t&&!t.nodeType&&t,o=s&&a&&"object"==typeof e&&e;!o||o.global!==o&&o.window!==o&&o.self!==o||(i=o);var u=Math.pow(2,53)-1,c=/\bOpera/,l=Object.prototype,d=l.hasOwnProperty,f=l.toString;function p(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function h(e){return e=g(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:p(e)}function b(e,t){for(var n in e)d.call(e,n)&&t(e[n],n,e)}function m(e){return null==e?p(e):f.call(e).slice(8,-1)}function v(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function y(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=u)for(;++n<r;)t(e[n],n,e);else b(e,t)}(e,function(r,i){n=t(n,r,i,e)}),n}function g(e){return String(e).replace(/^ +| +$/g,"")}var _=function e(t){var n=i,r=t&&"object"==typeof t&&"String"!=m(t);r&&(n=t,t=null);var s=n.navigator||{},a=s.userAgent||"";t||(t=a);var o,u,l,d,p,_=r?!!s.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(f.toString()),k=r?"Object":"ScriptBridgingProxyObject",w=r?"Object":"Environment",x=r&&n.java?"JavaPackage":m(n.java),C=r?"Object":"RuntimeObject",j=/\bJava/.test(x)&&n.java,S=j&&m(n.environment)==w,T=j?"a":"\u03b1",E=j?"b":"\u03b2",M=n.document||{},I=n.operamini||n.opera,R=c.test(R=r&&I?I["[[Class]]"]:m(I))?R:I=null,P=t,O=[],L=null,N=t==a,A=N&&I&&"function"==typeof I.version&&I.version(),D=y([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],function(e,n){return e||RegExp("\\b"+(n.pattern||v(n))+"\\b","i").exec(t)&&(n.label||n)}),U=function(e){return y(e,function(e,n){return e||RegExp("\\b"+(n.pattern||v(n))+"\\b","i").exec(t)&&(n.label||n)})}(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),F=z([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),q=function(e){return y(e,function(e,n,r){return e||(n[F]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(F)]||RegExp("\\b"+v(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r})}({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),B=function(e){return y(e,function(e,n){var r=n.pattern||v(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),e=h(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,r,n.label||n)),e})}(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function z(e){return y(e,function(e,n){var r=n.pattern||v(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=h(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e})}function W(e){return y(e,function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null})}if(D&&(D=[D]),/\bAndroid\b/.test(B)&&!F&&(o=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(F=g(o[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),q&&!F?F=z([q]):q&&F&&(F=F.replace(RegExp("^("+v(q)+")[-_.\\s]","i"),q+" ").replace(RegExp("^("+v(q)+")[-_.]?(\\w)","i"),q+" $2")),(o=/\bGoogle TV\b/.exec(F))&&(F=o[0]),/\bSimulator\b/i.test(t)&&(F=(F?F+" ":"")+"Simulator"),"Opera Mini"==U&&/\bOPiOS\b/.test(t)&&O.push("running in Turbo/Uncompressed mode"),"IE"==U&&/\blike iPhone OS\b/.test(t)?(q=(o=e(t.replace(/like iPhone OS/,""))).manufacturer,F=o.product):/^iP/.test(F)?(U||(U="Safari"),B="iOS"+((o=/ OS ([\d_]+)/i.exec(t))?" "+o[1].replace(/_/g,"."):"")):"Konqueror"==U&&/^Linux\b/i.test(B)?B="Kubuntu":q&&"Google"!=q&&(/Chrome/.test(U)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(F))||/\bAndroid\b/.test(B)&&/^Chrome/.test(U)&&/\bVersion\//i.test(t)?(U="Android Browser",B=/\bAndroid\b/.test(B)?B:"Android"):"Silk"==U?(/\bMobi/i.test(t)||(B="Android",O.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&O.unshift("accelerated")):"UC Browser"==U&&/\bUCWEB\b/.test(t)?O.push("speed mode"):"PaleMoon"==U&&(o=/\bFirefox\/([\d.]+)\b/.exec(t))?O.push("identifying as Firefox "+o[1]):"Firefox"==U&&(o=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(B||(B="Firefox OS"),F||(F=o[1])):!U||(o=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(U))?(U&&!F&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(o+"/")+8))&&(U=null),(o=F||q||B)&&(F||q||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(B))&&(U=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(B)?B:o)+" Browser")):"Electron"==U&&(o=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&O.push("Chromium "+o),A||(A=W(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",v(U),"(?:Firefox|Minefield|NetFront)"])),(o=("iCab"==D&&parseFloat(A)>3?"WebKit":/\bOpera\b/.test(U)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(D)&&"WebKit"||!D&&/\bMSIE\b/i.test(t)&&("Mac OS"==B?"Tasman":"Trident")||"WebKit"==D&&/\bPlayStation\b(?! Vita\b)/i.test(U)&&"NetFront")&&(D=[o]),"IE"==U&&(o=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(U+=" Mobile",B="Windows Phone "+(/\+$/.test(o)?o:o+".x"),O.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(U="IE Mobile",B="Windows Phone 8.x",O.unshift("desktop mode"),A||(A=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=U&&"Trident"==D&&(o=/\brv:([\d.]+)/.exec(t))&&(U&&O.push("identifying as "+U+(A?" "+A:"")),U="IE",A=o[1]),N){if(d="global",p=null!=(l=n)?typeof l[d]:"number",/^(?:boolean|number|string|undefined)$/.test(p)||"object"==p&&!l[d])m(o=n.runtime)==k?(U="Adobe AIR",B=o.flash.system.Capabilities.os):m(o=n.phantom)==C?(U="PhantomJS",A=(o=o.version||null)&&o.major+"."+o.minor+"."+o.patch):"number"==typeof M.documentMode&&(o=/\bTrident\/(\d+)/i.exec(t))?(A=[A,M.documentMode],(o=+o[1]+4)!=A[1]&&(O.push("IE "+A[1]+" mode"),D&&(D[1]=""),A[1]=o),A="IE"==U?String(A[1].toFixed(1)):A[0]):"number"==typeof M.documentMode&&/^(?:Chrome|Firefox)\b/.test(U)&&(O.push("masking as "+U+" "+A),U="IE",A="11.0",D=["Trident"],B="Windows");else if(j&&(P=(o=j.lang.System).getProperty("os.arch"),B=B||o.getProperty("os.name")+" "+o.getProperty("os.version")),S){try{A=n.require("ringo/engine").version.join("."),U="RingoJS"}catch(e){(o=n.system)&&o.global.system==n.system&&(U="Narwhal",B||(B=o[0].os||null))}U||(U="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(o=n.process)&&("object"==typeof o.versions&&("string"==typeof o.versions.electron?(O.push("Node "+o.versions.node),U="Electron",A=o.versions.electron):"string"==typeof o.versions.nw&&(O.push("Chromium "+A,"Node "+o.versions.node),U="NW.js",A=o.versions.nw)),U||(U="Node.js",P=o.arch,B=o.platform,A=(A=/[\d.]+/.exec(o.version))?A[0]:null));B=B&&h(B)}if(A&&(o=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(A)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(N&&s.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&(L=/b/i.test(o)?"beta":"alpha",A=A.replace(RegExp(o+"\\+?$"),"")+("beta"==L?E:T)+(/\d+\+?/.exec(o)||"")),"Fennec"==U||"Firefox"==U&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(B))U="Firefox Mobile";else if("Maxthon"==U&&A)A=A.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(F))"Xbox 360"==F&&(B=null),"Xbox 360"==F&&/\bIEMobile\b/.test(t)&&O.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(U)&&(!U||F||/Browser|Mobi/.test(U))||"Windows CE"!=B&&!/Mobi/i.test(t))if("IE"==U&&N)try{null===n.external&&O.unshift("platform preview")}catch(e){O.unshift("embedded")}else(/\bBlackBerry\b/.test(F)||/\bBB10\b/.test(t))&&(o=(RegExp(F.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||A)?(B=((o=[o,/BB10/.test(t)])[1]?(F=null,q="BlackBerry"):"Device Software")+" "+o[0],A=null):this!=b&&"Wii"!=F&&(N&&I||/Opera/.test(U)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==U&&/\bOS X (?:\d+\.){2,}/.test(B)||"IE"==U&&(B&&!/^Win/.test(B)&&A>5.5||/\bWindows XP\b/.test(B)&&A>8||8==A&&!/\bTrident\b/.test(t)))&&!c.test(o=e.call(b,t.replace(c,"")+";"))&&o.name&&(o="ing as "+o.name+((o=o.version)?" "+o:""),c.test(U)?(/\bIE\b/.test(o)&&"Mac OS"==B&&(B=null),o="identify"+o):(o="mask"+o,U=R?h(R.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(o)&&(B=null),N||(A=null)),D=["Presto"],O.push(o));else U+=" Mobile";(o=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(o=[parseFloat(o.replace(/\.(\d)$/,".0$1")),o],"Safari"==U&&"+"==o[1].slice(-1)?(U="WebKit Nightly",L="alpha",A=o[1].slice(0,-1)):A!=o[1]&&A!=(o[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(A=null),o[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==o[0]&&537.36==o[2]&&parseFloat(o[1])>=28&&"WebKit"==D&&(D=["Blink"]),N&&(_||o[1])?(D&&(D[1]="like Chrome"),o=o[1]||((o=o[0])<530?1:o<532?2:o<532.05?3:o<533?4:o<534.03?5:o<534.07?6:o<534.1?7:o<534.13?8:o<534.16?9:o<534.24?10:o<534.3?11:o<535.01?12:o<535.02?"13+":o<535.07?15:o<535.11?16:o<535.19?17:o<536.05?18:o<536.1?19:o<537.01?20:o<537.11?"21+":o<537.13?23:o<537.18?24:o<537.24?25:o<537.36?26:"Blink"!=D?"27":"28")):(D&&(D[1]="like Safari"),o=(o=o[0])<400?1:o<500?2:o<526?3:o<533?4:o<534?"4+":o<535?5:o<537?6:o<538?7:o<601?8:o<602?9:o<604?10:o<606?11:o<608?12:"12"),D&&(D[1]+=" "+(o+="number"==typeof o?".x":/[.+]/.test(o)?"":"+")),"Safari"==U&&(!A||parseInt(A)>45)?A=o:"Chrome"==U&&/\bHeadlessChrome/i.test(t)&&O.unshift("headless")),"Opera"==U&&(o=/\bzbov|zvav$/.exec(B))?(U+=" ",O.unshift("desktop mode"),"zvav"==o?(U+="Mini",A=null):U+="Mobile",B=B.replace(RegExp(" *"+o+"$"),"")):"Safari"==U&&/\bChrome\b/.exec(D&&D[1])?(O.unshift("desktop mode"),U="Chrome Mobile",A=null,/\bOS X\b/.test(B)?(q="Apple",B="iOS 4.3+"):B=null):/\bSRWare Iron\b/.test(U)&&!A&&(A=W("Chrome")),A&&0==A.indexOf(o=/[\d.]+$/.exec(B))&&t.indexOf("/"+o+"-")>-1&&(B=g(B.replace(o,""))),B&&-1!=B.indexOf(U)&&!RegExp(U+" OS").test(B)&&(B=B.replace(RegExp(" *"+v(U)+" *"),"")),D&&!/\b(?:Avant|Nook)\b/.test(U)&&(/Browser|Lunascape|Maxthon/.test(U)||"Safari"!=U&&/^iOS/.test(B)&&/\bSafari\b/.test(D[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(U)&&D[1])&&(o=D[D.length-1])&&O.push(o),O.length&&(O=["("+O.join("; ")+")"]),q&&F&&F.indexOf(q)<0&&O.push("on "+q),F&&O.push((/^on /.test(O[O.length-1])?"":"on ")+F),B&&(o=/ ([\d.+]+)$/.exec(B),u=o&&"/"==B.charAt(B.length-o[0].length-1),B={architecture:32,family:o&&!u?B.replace(o[0],""):B,version:o?o[1]:null,toString:function(){var e=this.version;return this.family+(e&&!u?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(o=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(P))&&!/\bi686\b/i.test(P)?(B&&(B.architecture=64,B.family=B.family.replace(RegExp(" *"+o),"")),U&&(/\bWOW64\b/i.test(t)||N&&/\w(?:86|32)$/.test(s.cpuClass||s.platform)&&!/\bWin64; x64\b/i.test(t))&&O.unshift("32-bit")):B&&/^OS X/.test(B.family)&&"Chrome"==U&&parseFloat(A)>=39&&(B.architecture=64),t||(t=null);var G={};return G.description=t,G.layout=D&&D[0],G.manufacturer=q,G.name=U,G.prerelease=L,G.product=F,G.ua=t,G.version=U&&A,G.os=B||{architecture:null,family:null,version:null,toString:function(){return"null"}},G.parse=e,G.toString=function(){return this.description||""},G.version&&O.unshift(A),G.name&&O.unshift(U),B&&U&&(B!=String(B).split(" ")[0]||B!=U.split(" ")[0]&&!F)&&O.push(F?"("+B+")":"on "+B),O.length&&(G.description=O.join(" ")),G}();s&&a?b(_,function(e,t){s[t]=e}):i.platform=_}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],208:[function(e,t,n){
158
- /**
159
- * Copyright (c) 2014-present, Facebook, Inc.
160
- *
161
- * This source code is licensed under the MIT license found in the
162
- * LICENSE file in the root directory of this source tree.
163
- */
164
- var r=function(){return this}()||Function("return this")(),i=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,s=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,t.exports=e("./runtime"),i)r.regeneratorRuntime=s;else try{delete r.regeneratorRuntime}catch(e){r.regeneratorRuntime=void 0}},{"./runtime":209}],209:[function(e,t,n){
165
- /**
166
- * Copyright (c) 2014-present, Facebook, Inc.
167
- *
168
- * This source code is licensed under the MIT license found in the
169
- * LICENSE file in the root directory of this source tree.
170
- */
171
- !function(e){"use strict";var n,r=Object.prototype,i=r.hasOwnProperty,s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag",c="object"==typeof t,l=e.regeneratorRuntime;if(l)c&&(t.exports=l);else{(l=e.regeneratorRuntime=c?t.exports:{}).wrap=_;var d="suspendedStart",f="suspendedYield",p="executing",h="completed",b={},m={};m[a]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(R([])));y&&y!==r&&i.call(y,a)&&(m=y);var g=C.prototype=w.prototype=Object.create(m);x.prototype=g.constructor=C,C.constructor=x,C[u]=x.displayName="GeneratorFunction",l.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===x||"GeneratorFunction"===(t.displayName||t.name))},l.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,C):(e.__proto__=C,u in e||(e[u]="GeneratorFunction")),e.prototype=Object.create(g),e},l.awrap=function(e){return{__await:e}},j(S.prototype),S.prototype[o]=function(){return this},l.AsyncIterator=S,l.async=function(e,t,n,r){var i=new S(_(e,t,n,r));return l.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},j(g),g[u]="Generator",g[a]=function(){return this},g.toString=function(){return"[object Generator]"},l.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},l.values=R,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(M),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(r,i){return o.type="throw",o.arg=e,t.next=r,i&&(t.method="next",t.arg=n),!!i}for(var s=this.tryEntries.length-1;s>=0;--s){var a=this.tryEntries[s],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var s=r;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var a=s?s.completion:{};return a.type=e,a.arg=t,s?(this.method="next",this.next=s.finallyLoc,b):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),M(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;M(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),b}}}function _(e,t,n,r){var i=t&&t.prototype instanceof w?t:w,s=Object.create(i.prototype),a=new I(r||[]);return s._invoke=function(e,t,n){var r=d;return function(i,s){if(r===p)throw new Error("Generator is already running");if(r===h){if("throw"===i)throw s;return P()}for(n.method=i,n.arg=s;;){var a=n.delegate;if(a){var o=T(a,n);if(o){if(o===b)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===d)throw r=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=p;var u=k(e,t,n);if("normal"===u.type){if(r=n.done?h:f,u.arg===b)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=h,n.method="throw",n.arg=u.arg)}}}(e,n,a),s}function k(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}function w(){}function x(){}function C(){}function j(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function S(e){var t;this._invoke=function(n,r){function s(){return new Promise(function(t,s){!function t(n,r,s,a){var o=k(e[n],e,r);if("throw"!==o.type){var u=o.arg,c=u.value;return c&&"object"==typeof c&&i.call(c,"__await")?Promise.resolve(c.__await).then(function(e){t("next",e,s,a)},function(e){t("throw",e,s,a)}):Promise.resolve(c).then(function(e){u.value=e,s(u)},a)}a(o.arg)}(n,r,t,s)})}return t=t?t.then(s,s):s()}}function T(e,t){var r=e.iterator[t.method];if(r===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,T(e,t),"throw"===t.method))return b;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return b}var i=k(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,b;var s=i.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,b):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,b)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function R(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,s=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=n,t.done=!0,t};return s.next=s}}return{next:P}}function P(){return{value:n,done:!0}}}(function(){return this}()||Function("return this")())},{}],210:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./equal"),i=Object.prototype.hasOwnProperty;function s(e,t){var n={};for(var r in e)i.call(e,r)&&void 0!==e[r]&&(n[r]=1);for(var s in t)i.call(t,s)&&void 0!==t[s]&&delete n[s];return Object.keys(n)}function a(e){for(var t=e.length,n={},r=0;r<t;r++){var s=e[r];for(var a in s)i.call(s,a)&&void 0!==s[a]&&(n[a]=(n[a]||0)+1)}for(var a in n)n[a]<t&&delete n[a];return Object.keys(n)}function o(e,t){return{operations:e.operations.concat(t),cost:e.cost+1}}function u(e,t,n,i){void 0===i&&(i=d);var s={"0,0":{operations:[],cost:0}};var a=isNaN(e.length)||e.length<=0?0:e.length,u=isNaN(t.length)||t.length<=0?0:t.length;return function n(i,a){var u=i+","+a,c=s[u];if(void 0===c){if(i>0&&a>0&&r.compare(e[i-1],t[a-1]))c=n(i-1,a-1);else{var l=[];if(i>0){var d=n(i-1,a),f={op:"remove",index:i-1};l.push(o(d,f))}if(a>0){var p=n(i,a-1),h={op:"add",index:i-1,value:t[a-1]};l.push(o(p,h))}if(i>0&&a>0){var b=n(i-1,a-1),m={op:"replace",index:i-1,original:e[i-1],value:t[a-1]};l.push(o(b,m))}c=l.sort(function(e,t){return e.cost-t.cost})[0]}s[u]=c}return c}(a,u).operations.reduce(function(e,t){var r=e[0],s=e[1];if(function(e){return"add"===e.op}(t)){var o=t.index+1+s,u=o<a+s?String(o):"-",c={op:t.op,path:n.add(u).toString(),value:t.value};return[r.concat(c),s+1]}if(function(e){return"remove"===e.op}(t)){c={op:t.op,path:n.add(String(t.index+s)).toString()};return[r.concat(c),s-1]}var l=n.add(String(t.index+s)),d=i(t.original,t.value,l);return[r.concat.apply(r,d),s]},[[],0])[0]}function c(e,t,n,r){void 0===r&&(r=d);var i=[];return s(e,t).forEach(function(e){i.push({op:"remove",path:n.add(e).toString()})}),s(t,e).forEach(function(e){i.push({op:"add",path:n.add(e).toString(),value:t[e]})}),a([e,t]).forEach(function(s){i.push.apply(i,r(e[s],t[s],n.add(s)))}),i}function l(e,t,n){return r.compare(e,t)?[]:[{op:"replace",path:n.toString(),value:t}]}function d(e,t,n,i){void 0===i&&(i=d);var s=r.objectType(e),a=r.objectType(t);return"array"==s&&"array"==a?u(e,t,n,i):"object"==s&&"object"==a?c(e,t,n,i):l(e,t,n)}n.isDestructive=function(e){var t=e.op;return"remove"===t||"replace"===t||"copy"===t||"move"===t},n.subtract=s,n.intersection=a,n.diffArrays=u,n.diffObjects=c,n.diffValues=l,n.diffAny=d},{"./equal":211}],211:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty;function i(e){return void 0===e?"undefined":null===e?"null":Array.isArray(e)?"array":typeof e}function s(e,t){if(e===t)return!0;var n=i(e),a=i(t);return"array"==n&&"array"==a?function(e,t){var n=e.length;if(n!==t.length)return!1;for(var r=0;r<n;r++)if(!s(e[r],t[r]))return!1;return!0}(e,t):"object"==n&&"object"==a&&function(e,t){var n=Object.keys(e),i=Object.keys(t),a=n.length;if(a!==i.length)return!1;for(var o=0;o<a;o++){var u=n[o];if(!r.call(t,u)||!s(e[u],t[u]))return!1}return!0}(e,t)}n.objectType=i,n.compare=s},{}],212:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./pointer"),i=e("./patch"),s=e("./diff");function a(e,t){var n=r.Pointer.fromJSON(t).evaluate(e);if(void 0!==n)return{op:"test",path:t,value:n.value}}n.applyPatch=function(e,t){return t.map(function(t){return i.apply(e,t)})},n.createPatch=function(e,t,n){var i=new r.Pointer;return(n?function(e){return function t(n,r,i){var a=e(n,r,i);return Array.isArray(a)?a:s.diffAny(n,r,i,t)}}(n):s.diffAny)(e,t,i)},n.createTests=function(e,t){var n=new Array;return t.filter(s.isDestructive).forEach(function(t){var r=a(e,t.path);if(r&&n.push(r),"from"in t){var i=a(e,t.from);i&&n.push(i)}}),n}},{"./diff":210,"./patch":213,"./pointer":214}],213:[function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(n,"__esModule",{value:!0});var s=e("./pointer"),a=e("./util"),o=e("./equal"),u=function(e){function t(t){var n=e.call(this,"Value required at path: "+t)||this;return n.path=t,n.name="MissingError",n}return i(t,e),t}(Error);n.MissingError=u;var c=function(e){function t(t,n){var r=e.call(this,"Test failed: "+t+" != "+n)||this;return r.actual=t,r.expected=n,r.name="TestError",r.actual=t,r.expected=n,r}return i(t,e),t}(Error);function l(e,t,n){if(Array.isArray(e))if("-"==t)e.push(n);else{var r=parseInt(t,10);e.splice(r,0,n)}else e[t]=n}function d(e,t){if(Array.isArray(e)){var n=parseInt(t,10);e.splice(n,1)}else delete e[t]}function f(e,t){var n=s.Pointer.fromJSON(t.path).evaluate(e);return void 0===n.parent?new u(t.path):(l(n.parent,n.key,a.clone(t.value)),null)}function p(e,t){var n=s.Pointer.fromJSON(t.path).evaluate(e);return void 0===n.value?new u(t.path):(d(n.parent,n.key),null)}function h(e,t){var n=s.Pointer.fromJSON(t.path).evaluate(e);if(null===n.parent)return new u(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new u(t.path)}else if(void 0===n.value)return new u(t.path);return n.parent[n.key]=t.value,null}function b(e,t){var n=s.Pointer.fromJSON(t.from).evaluate(e);if(void 0===n.value)return new u(t.from);var r=s.Pointer.fromJSON(t.path).evaluate(e);return void 0===r.parent?new u(t.path):(d(n.parent,n.key),l(r.parent,r.key,n.value),null)}function m(e,t){var n=s.Pointer.fromJSON(t.from).evaluate(e);if(void 0===n.value)return new u(t.from);var r=s.Pointer.fromJSON(t.path).evaluate(e);return void 0===r.parent?new u(t.path):(l(r.parent,r.key,a.clone(n.value)),null)}function v(e,t){var n=s.Pointer.fromJSON(t.path).evaluate(e);return o.compare(n.value,t.value)?null:new c(n.value,t.value)}n.TestError=c,n.add=f,n.remove=p,n.replace=h,n.move=b,n.copy=m,n.test=v;var y=function(e){function t(t){var n=e.call(this,"Invalid operation: "+t.op)||this;return n.operation=t,n.name="InvalidOperationError",n}return i(t,e),t}(Error);n.InvalidOperationError=y,n.apply=function(e,t){switch(t.op){case"add":return f(e,t);case"remove":return p(e,t);case"replace":return h(e,t);case"move":return b(e,t);case"copy":return m(e,t);case"test":return v(e,t)}return new y(t)}},{"./equal":211,"./pointer":214,"./util":215}],214:[function(e,t,n){"use strict";function r(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function i(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(e){void 0===e&&(e=[""]),this.tokens=e}return e.fromJSON=function(t){var n=t.split("/").map(r);if(""!==n[0])throw new Error("Invalid JSON Pointer: "+t);return new e(n)},e.prototype.toString=function(){return this.tokens.map(i).join("/")},e.prototype.evaluate=function(e){for(var t=null,n="",r=e,i=1,s=this.tokens.length;i<s;i++)r=((t=r)||{})[n=this.tokens[i]];return{parent:t,key:n,value:r}},e.prototype.get=function(e){return this.evaluate(e).value},e.prototype.set=function(e,t){for(var n=e,r=1,i=this.tokens.length-1,s=this.tokens[r];r<i;r++)n=(n||{})[s];n&&(n[this.tokens[this.tokens.length-1]]=t)},e.prototype.push=function(e){this.tokens.push(e)},e.prototype.add=function(t){return new e(this.tokens.concat(String(t)))},e}();n.Pointer=s},{}],215:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty;n.clone=function e(t){if(null==t||"object"!=typeof t)return t;if(t.constructor==Array){for(var n=t.length,i=new Array(n),s=0;s<n;s++)i[s]=e(t[s]);return i}var a={};for(var o in t)r.call(t,o)&&(a[o]=e(t[o]));return a}},{}],216:[function(e,t,n){"use strict";var r=u(e("babel-runtime/core-js/json/stringify")),i=u(e("babel-runtime/regenerator")),s=u(e("babel-runtime/helpers/asyncToGenerator")),a=u(e("babel-runtime/helpers/classCallCheck")),o=u(e("babel-runtime/helpers/createClass"));function u(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.McsMedia=n.Media=n.McsClient=n.Client=void 0;var c=e("./logger"),l=e("./configuration"),d=e("./media");Object.defineProperty(n,"Media",{enumerable:!0,get:function(){return d.Media}}),Object.defineProperty(n,"McsMedia",{enumerable:!0,get:function(){return d.Media}});var f=e("./services/transport"),p=e("./services/network"),h=c.Logger.scope(""),b=e("./../package.json").version,m="A valid Twilio token should be provided",v=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if((0,a.default)(this,e),this.options=i,this.options.logLevel=this.options.logLevel||"silent",this.config=new l.Configuration(t,n,r,this.options),!t)throw new Error(m);h.setLevel(this.options.logLevel),this.options.transport=this.options.transport||new f.Transport,this.transport=this.options.transport,this.network=new p.Network(this.config,this.transport)}return(0,o.default)(e,[{key:"updateToken",value:function(e){if(h.info("updateToken"),!e)throw new Error(m);this.config.updateToken(e)}},{key:"get",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.network.get(this.config.mediaUrl+"/"+t);case 2:return n=e.sent,e.abrupt("return",new d.Media(this.config,this.network,n.body));case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"post",value:function(){var e=(0,s.default)(i.default.mark(function e(t,n){var r,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"media";return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.network.post(this.config.mediaUrl,s,n,t);case 2:return r=e.sent,e.abrupt("return",new d.Media(this.config,this.network,r.body));case 4:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"postFormData",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"media";return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.network.post(this.config.mediaUrl,r,t);case 2:return n=e.sent,e.abrupt("return",new d.Media(this.config,this.network,n.body));case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"mediaSetGet",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,s,a=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n={command:"get",list:t.map(function(e){return{media_sid:e}})},e.next=3,this.network.post(""+this.config.mediaSetUrl,null,(0,r.default)(n),"application/json");case 3:return s=e.sent,e.abrupt("return",s.map(function(e){if(200!==e.code)throw new Error("Failed to obtain detailed information about Media items (failed SID "+e.media_record.sid+")");return new d.Media(a.config,a.network,e.media_record)}));case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),e}();n.Client=v,n.McsClient=v,v.version=b,n.default=v},{"./../package.json":304,"./configuration":217,"./logger":219,"./media":220,"./services/network":221,"./services/transport":222,"babel-runtime/core-js/json/stringify":32,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57}],217:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Configuration=void 0;var a=function(e,t){return""+(e.startsWith("http")?"":function(e){return"https://mcs."+(null!=e?e:"us1")+".twilio.com"}(t))+e},o=function(){function e(t,n,i,s){(0,r.default)(this,e);var o=s.MCS||s||{};this.region=o.region||s.region,this.mediaUrl=a(n,this.region),this.mediaSetUrl=i?a(i):this.mediaUrl+"Set",this.token=t,this.retryWhenThrottledOverride=o.retryWhenThrottledOverride,this.backoffConfigOverride=o.backoffConfigOverride}return(0,i.default)(e,[{key:"updateToken",value:function(e){this.token=e}}],[{key:"backoffConfigDefault",get:function(){return{min:1e3,max:4e3,maxAttemptsCount:3}}},{key:"retryWhenThrottledDefault",get:function(){return!0}}]),e}();n.Configuration=o},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],218:[function(e,t,n){"use strict";var r=e("./client");t.exports=r},{"./client":216}],219:[function(e,t,n){"use strict";var r=a(e("babel-runtime/helpers/classCallCheck")),i=a(e("babel-runtime/helpers/createClass")),s=a(e("babel-runtime/core-js/array/from"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Logger=void 0;var o=e("loglevel");function u(e,t){return[(new Date).toISOString()+" MCS Client "+e+":"].concat((0,s.default)(t))}var c=function(){function e(t){(0,r.default)(this,e),this.prefix="",this.prefix=null!=t&&t.length>0?t+" ":""}return(0,i.default)(e,[{key:"setLevel",value:function(e){o.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.trace.apply(null,u(this.prefix+"T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.debug.apply(null,u(this.prefix+"D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.info.apply(null,u(this.prefix+"I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.warn.apply(null,u(this.prefix+"W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.error.apply(null,u(this.prefix+"E",t))}}],[{key:"scope",value:function(t){return new e(t)}},{key:"setLevel",value:function(e){o.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.trace.apply(null,u("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.debug.apply(null,u("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.info.apply(null,u("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.warn.apply(null,u("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.error.apply(null,u("E",t))}}]),e}();n.Logger=c},{"babel-runtime/core-js/array/from":29,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,loglevel:203}],220:[function(e,t,n){"use strict";var r=u(e("babel-runtime/regenerator")),i=u(e("babel-runtime/core-js/promise")),s=u(e("babel-runtime/helpers/asyncToGenerator")),a=u(e("babel-runtime/helpers/classCallCheck")),o=u(e("babel-runtime/helpers/createClass"));function u(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Media=void 0;var c=function(){function e(t,n,r){(0,a.default)(this,e),this.config=t,this.network=n,this._update(r)}return(0,o.default)(e,[{key:"getContentUrl",value:function(){var e=(0,s.default)(r.default.mark(function e(){var t;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.network.get(this.config.mediaUrl+"/"+this.sid);case 2:return t=e.sent,this._update(t.body),e.abrupt("return",i.default.resolve(this.state.contentDirectUrl));case 5:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getCachedContentUrl",value:function(){var e=(0,s.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.state.contentDirectUrl){e.next=2;break}return e.abrupt("return",i.default.resolve(this.state.contentDirectUrl));case 2:return e.next=4,this.getContentUrl();case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"_update",value:function(e){var t,n,r;this.state={sid:e.sid,serviceSid:e.service_sid,channelSid:e.channel_sid,messageSid:e.message_sid,dateCreated:e.date_created?new Date(e.date_created):null,dateUploadUpdated:e.date_upload_updated?new Date(e.date_upload_updated):null,dateUpdated:e.date_updated?new Date(e.date_updated):null,size:e.size,contentType:e.content_type,author:e.author,url:e.url,contentUrl:e.links.content,contentDirectUrl:e.links.content_direct_temporary,filename:null!==(t=e.filename)&&void 0!==t?t:null,category:null!==(n=e.category)&&void 0!==n?n:"media",isMultipartUpstream:null!==(r=e.is_multipart_upstream)&&void 0!==r&&r}}},{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}}]),e}();n.Media=c},{"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57}],221:[function(e,t,n){"use strict";var r=c(e("babel-runtime/regenerator")),i=c(e("babel-runtime/core-js/promise")),s=c(e("babel-runtime/helpers/asyncToGenerator")),a=c(e("babel-runtime/core-js/object/assign")),o=c(e("babel-runtime/helpers/classCallCheck")),u=c(e("babel-runtime/helpers/createClass"));function c(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Network=void 0;var l=e("operation-retrier"),d=e("../logger"),f=e("../configuration"),p=d.Logger.scope("Network"),h=function(){function e(t,n){(0,o.default)(this,e),this.config=t,this.transport=n}return(0,u.default)(e,[{key:"backoffConfig",value:function(){return(0,a.default)(f.Configuration.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var e,t;return null!==(t=null!==(e=this.config.retryWhenThrottledOverride)&&void 0!==e?e:f.Configuration.retryWhenThrottledDefault)&&void 0!==t&&t}},{key:"executeWithRetry",value:function(){var e=(0,s.default)(r.default.mark(function e(t,n){var a=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new i.default(function(e,i){var o=[502,503,504];n&&o.push(429);var u=new l.Retrier(a.backoffConfig());u.on("attempt",(0,s.default)(r.default.mark(function e(){var n;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t();case 3:n=e.sent,u.succeeded(n),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),o.indexOf(e.t0.status)>-1?u.failed(e.t0):"Twilsock disconnected"===e.t0.message?u.failed(e.t0):(u.removeAllListeners(),u.cancel(),i(e.t0));case 10:case"end":return e.stop()}},e,a,[[0,7]])}))),u.on("succeeded",function(t){e(t)}),u.on("cancelled",function(e){return i(e)}),u.on("failed",function(e){return i(e)}),u.start()}));case 1:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"get",value:function(){var e=(0,s.default)(r.default.mark(function e(t){var n,i,s=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n={"X-Twilio-Token":this.config.token},p.trace("sending GET request to ",t," headers ",n),e.prev=2,e.next=5,this.executeWithRetry(function(){return s.transport.get(t,n)},this.retryWhenThrottled());case 5:return i=e.sent,p.trace("response",i),e.abrupt("return",i);case 10:throw e.prev=10,e.t0=e.catch(2),p.debug("get() error "+e.t0),e.t0;case 14:case"end":return e.stop()}},e,this,[[2,10]])}));return function(t){return e.apply(this,arguments)}}()},{key:"post",value:function(){var e=(0,s.default)(r.default.mark(function e(t,n,i,s){var o,u,c;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o={"X-Twilio-Token":this.config.token},"undefined"!=typeof FormData&&i instanceof FormData||!s||(0,a.default)(o,{"Content-Type":s}),u=new URL(t),n&&u.searchParams.append("Category",n),c=void 0,p.trace("sending POST request to "+t+" with headers "+o),e.prev=6,e.next=9,this.transport.post(u.href,o,i);case 9:c=e.sent,e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(6),!(e.t0 instanceof TypeError)){e.next=17;break}throw p.trace("got error in post response",e.t0),new TypeError("Posting FormData supported only with browser engine's FormData");case 17:throw p.debug("post() error "+e.t0),e.t0;case 19:return p.trace("response",c),e.abrupt("return",c);case 21:case"end":return e.stop()}},e,this,[[6,12]])}));return function(t,n,r,i){return e.apply(this,arguments)}}()}]),e}();n.Network=h},{"../configuration":217,"../logger":219,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57,"operation-retrier":303}],222:[function(e,t,n){(function(t){"use strict";var r=o(e("babel-runtime/core-js/json/stringify")),i=o(e("babel-runtime/core-js/promise")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Transport=void 0;var u=e("./transporterror"),c=t.XMLHttpRequest||e("xmlhttprequest").XMLHttpRequest;var l=function(){function e(){(0,s.default)(this,e)}return(0,a.default)(e,[{key:"get",value:function(t,n){return e.request("GET",t,n)}},{key:"post",value:function(t,n,r){return e.request("POST",t,n,r)}}],[{key:"request",value:function(e,t,n,s){return new i.default(function(i,a){var o=new c;for(var l in o.open(e,t,!0),o.onreadystatechange=function(){if(4===o.readyState){var e,t=(e=o.getAllResponseHeaders())?e.split("\r\n").map(function(e){return e.split(": ")}).filter(function(e){return 2===e.length&&e[1].length>0}).reduce(function(e,t){return e[t[0]]=t[1],e},{}):{},n=function(e){var t=e.getResponseHeader("Content-Type");if(!t||0!==t.indexOf("application/json")||0===e.responseText.length)return e.responseText;try{return JSON.parse(e.responseText)}catch(t){return e.responseText}}(o);if(200<=o.status&&o.status<300)i({status:o.status,headers:t,body:n});else{var s=o.statusText&&o.statusText.code?o.statusText.code:"NONE",c=void 0;c="string"==typeof n?n&&1===n.split("\n",2).length?n:"":(0,r.default)(n);var l=o.status+": ["+s+"] "+c;a(new u.TransportError(l,o.status,n,s,t))}}},n)o.setRequestHeader(l,n[l]),"Content-Type"===l&&"application/json"===n[l]&&(s=(0,r.default)(s));o.send(s)})}}]),e}();n.Transport=l}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./transporterror":223,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,xmlhttprequest:58}],223:[function(e,t,n){"use strict";var r=d(e("babel-runtime/core-js/object/create")),i=d(e("babel-runtime/core-js/object/set-prototype-of")),s=d(e("babel-runtime/core-js/array/from")),a=d(e("babel-runtime/core-js/reflect/construct")),o=d(e("babel-runtime/core-js/object/get-prototype-of")),u=d(e("babel-runtime/helpers/classCallCheck")),c=d(e("babel-runtime/helpers/possibleConstructorReturn")),l=d(e("babel-runtime/helpers/inherits"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.TransportError=void 0;var f=function(e){function t(e,n,r,i,s){(0,u.default)(this,t);var a=(0,c.default)(this,(t.__proto__||(0,o.default)(t)).call(this,e));return a.code=n,a.body=r,a.status=i,a.headers=s,a}return(0,l.default)(t,e),t}(function(e){function t(){var t=(0,a.default)(e,(0,s.default)(arguments));return(0,i.default)(t,(0,o.default)(this)),t}return t.prototype=(0,r.default)(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i.default?(0,i.default)(t,e):t.__proto__=e,t}(Error));n.TransportError=f},{"babel-runtime/core-js/array/from":29,"babel-runtime/core-js/object/create":36,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/object/set-prototype-of":41,"babel-runtime/core-js/reflect/construct":43,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],224:[function(e,t,n){t.exports=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e}},{}],225:[function(e,t,n){var r=e("../internals/is-object");t.exports=function(e){if(!r(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype");return e}},{"../internals/is-object":260}],226:[function(e,t,n){t.exports=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e}},{}],227:[function(e,t,n){var r=e("../internals/is-object");t.exports=function(e){if(!r(e))throw TypeError(String(e)+" is not an object");return e}},{"../internals/is-object":260}],228:[function(e,t,n){var r=e("../internals/to-indexed-object"),i=e("../internals/to-length"),s=e("../internals/to-absolute-index"),a=function(e){return function(t,n,a){var o,u=r(t),c=i(u.length),l=s(a,c);if(e&&n!=n){for(;c>l;)if((o=u[l++])!=o)return!0}else for(;c>l;l++)if((e||l in u)&&u[l]===n)return e||l||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},{"../internals/to-absolute-index":292,"../internals/to-indexed-object":293,"../internals/to-length":295}],229:[function(e,t,n){var r=e("../internals/well-known-symbol")("iterator"),i=!1;try{var s=0,a={next:function(){return{done:!!s++}},return:function(){i=!0}};a[r]=function(){return this},Array.from(a,function(){throw 2})}catch(e){}t.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var s={};s[r]=function(){return{next:function(){return{done:n=!0}}}},e(s)}catch(e){}return n}},{"../internals/well-known-symbol":301}],230:[function(e,t,n){arguments[4][89][0].apply(n,arguments)},{dup:89}],231:[function(e,t,n){var r=e("../internals/to-string-tag-support"),i=e("../internals/classof-raw"),s=e("../internals/well-known-symbol")("toStringTag"),a="Arguments"==i(function(){return arguments}());t.exports=r?i:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),s))?n:a?i(t):"Object"==(r=i(t))&&"function"==typeof t.callee?"Arguments":r}},{"../internals/classof-raw":230,"../internals/to-string-tag-support":298,"../internals/well-known-symbol":301}],232:[function(e,t,n){var r=e("../internals/has"),i=e("../internals/own-keys"),s=e("../internals/object-get-own-property-descriptor"),a=e("../internals/object-define-property");t.exports=function(e,t){for(var n=i(t),o=a.f,u=s.f,c=0;c<n.length;c++){var l=n[c];r(e,l)||o(e,l,u(t,l))}}},{"../internals/has":250,"../internals/object-define-property":270,"../internals/object-get-own-property-descriptor":271,"../internals/own-keys":277}],233:[function(e,t,n){var r=e("../internals/descriptors"),i=e("../internals/object-define-property"),s=e("../internals/create-property-descriptor");t.exports=r?function(e,t,n){return i.f(e,t,s(1,n))}:function(e,t,n){return e[t]=n,e}},{"../internals/create-property-descriptor":234,"../internals/descriptors":235,"../internals/object-define-property":270}],234:[function(e,t,n){arguments[4][142][0].apply(n,arguments)},{dup:142}],235:[function(e,t,n){var r=e("../internals/fails");t.exports=!r(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})},{"../internals/fails":245}],236:[function(e,t,n){var r=e("../internals/global"),i=e("../internals/is-object"),s=r.document,a=i(s)&&i(s.createElement);t.exports=function(e){return a?s.createElement(e):{}}},{"../internals/global":249,"../internals/is-object":260}],237:[function(e,t,n){t.exports="object"==typeof window},{}],238:[function(e,t,n){var r=e("../internals/engine-user-agent");t.exports=/(?:iphone|ipod|ipad).*applewebkit/i.test(r)},{"../internals/engine-user-agent":241}],239:[function(e,t,n){var r=e("../internals/classof-raw"),i=e("../internals/global");t.exports="process"==r(i.process)},{"../internals/classof-raw":230,"../internals/global":249}],240:[function(e,t,n){var r=e("../internals/engine-user-agent");t.exports=/web0s(?!.*chrome)/i.test(r)},{"../internals/engine-user-agent":241}],241:[function(e,t,n){var r=e("../internals/get-built-in");t.exports=r("navigator","userAgent")||""},{"../internals/get-built-in":247}],242:[function(e,t,n){var r,i,s=e("../internals/global"),a=e("../internals/engine-user-agent"),o=s.process,u=o&&o.versions,c=u&&u.v8;c?i=(r=c.split("."))[0]<4?1:r[0]+r[1]:a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(i=r[1]),t.exports=i&&+i},{"../internals/engine-user-agent":241,"../internals/global":249}],243:[function(e,t,n){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},{}],244:[function(e,t,n){var r=e("../internals/global"),i=e("../internals/object-get-own-property-descriptor").f,s=e("../internals/create-non-enumerable-property"),a=e("../internals/redefine"),o=e("../internals/set-global"),u=e("../internals/copy-constructor-properties"),c=e("../internals/is-forced");t.exports=function(e,t){var n,l,d,f,p,h=e.target,b=e.global,m=e.stat;if(n=b?r:m?r[h]||o(h,{}):(r[h]||{}).prototype)for(l in t){if(f=t[l],d=e.noTargetGet?(p=i(n,l))&&p.value:n[l],!c(b?l:h+(m?".":"#")+l,e.forced)&&void 0!==d){if(typeof f==typeof d)continue;u(f,d)}(e.sham||d&&d.sham)&&s(f,"sham",!0),a(n,l,f,e)}}},{"../internals/copy-constructor-properties":232,"../internals/create-non-enumerable-property":233,"../internals/global":249,"../internals/is-forced":259,"../internals/object-get-own-property-descriptor":271,"../internals/redefine":282,"../internals/set-global":284}],245:[function(e,t,n){t.exports=function(e){try{return!!e()}catch(e){return!0}}},{}],246:[function(e,t,n){var r=e("../internals/a-function");t.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},{"../internals/a-function":224}],247:[function(e,t,n){var r=e("../internals/path"),i=e("../internals/global"),s=function(e){return"function"==typeof e?e:void 0};t.exports=function(e,t){return arguments.length<2?s(r[e])||s(i[e]):r[e]&&r[e][t]||i[e]&&i[e][t]}},{"../internals/global":249,"../internals/path":278}],248:[function(e,t,n){var r=e("../internals/classof"),i=e("../internals/iterators"),s=e("../internals/well-known-symbol")("iterator");t.exports=function(e){if(null!=e)return e[s]||e["@@iterator"]||i[r(e)]}},{"../internals/classof":231,"../internals/iterators":264,"../internals/well-known-symbol":301}],249:[function(e,t,n){(function(e){var n=function(e){return e&&e.Math==Math&&e};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||function(){return this}()||Function("return this")()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],250:[function(e,t,n){var r=e("../internals/to-object"),i={}.hasOwnProperty;t.exports=Object.hasOwn||function(e,t){return i.call(r(e),t)}},{"../internals/to-object":296}],251:[function(e,t,n){arguments[4][121][0].apply(n,arguments)},{dup:121}],252:[function(e,t,n){var r=e("../internals/global");t.exports=function(e,t){var n=r.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))}},{"../internals/global":249}],253:[function(e,t,n){var r=e("../internals/get-built-in");t.exports=r("document","documentElement")},{"../internals/get-built-in":247}],254:[function(e,t,n){var r=e("../internals/descriptors"),i=e("../internals/fails"),s=e("../internals/document-create-element");t.exports=!r&&!i(function(){return 7!=Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a})},{"../internals/descriptors":235,"../internals/document-create-element":236,"../internals/fails":245}],255:[function(e,t,n){var r=e("../internals/fails"),i=e("../internals/classof-raw"),s="".split;t.exports=r(function(){return!Object("z").propertyIsEnumerable(0)})?function(e){return"String"==i(e)?s.call(e,""):Object(e)}:Object},{"../internals/classof-raw":230,"../internals/fails":245}],256:[function(e,t,n){var r=e("../internals/shared-store"),i=Function.toString;"function"!=typeof r.inspectSource&&(r.inspectSource=function(e){return i.call(e)}),t.exports=r.inspectSource},{"../internals/shared-store":288}],257:[function(e,t,n){var r,i,s,a=e("../internals/native-weak-map"),o=e("../internals/global"),u=e("../internals/is-object"),c=e("../internals/create-non-enumerable-property"),l=e("../internals/has"),d=e("../internals/shared-store"),f=e("../internals/shared-key"),p=e("../internals/hidden-keys"),h=o.WeakMap;if(a||d.state){var b=d.state||(d.state=new h),m=b.get,v=b.has,y=b.set;r=function(e,t){if(v.call(b,e))throw new TypeError("Object already initialized");return t.facade=e,y.call(b,e,t),t},i=function(e){return m.call(b,e)||{}},s=function(e){return v.call(b,e)}}else{var g=f("state");p[g]=!0,r=function(e,t){if(l(e,g))throw new TypeError("Object already initialized");return t.facade=e,c(e,g,t),t},i=function(e){return l(e,g)?e[g]:{}},s=function(e){return l(e,g)}}t.exports={set:r,get:i,has:s,enforce:function(e){return s(e)?i(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!u(t)||(n=i(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}}},{"../internals/create-non-enumerable-property":233,"../internals/global":249,"../internals/has":250,"../internals/hidden-keys":251,"../internals/is-object":260,"../internals/native-weak-map":268,"../internals/shared-key":287,"../internals/shared-store":288}],258:[function(e,t,n){var r=e("../internals/well-known-symbol"),i=e("../internals/iterators"),s=r("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(i.Array===e||a[s]===e)}},{"../internals/iterators":264,"../internals/well-known-symbol":301}],259:[function(e,t,n){var r=e("../internals/fails"),i=/#|\.prototype\./,s=function(e,t){var n=o[a(e)];return n==c||n!=u&&("function"==typeof t?r(t):!!t)},a=s.normalize=function(e){return String(e).replace(i,".").toLowerCase()},o=s.data={},u=s.NATIVE="N",c=s.POLYFILL="P";t.exports=s},{"../internals/fails":245}],260:[function(e,t,n){arguments[4][115][0].apply(n,arguments)},{dup:115}],261:[function(e,t,n){t.exports=!1},{}],262:[function(e,t,n){var r=e("../internals/an-object"),i=e("../internals/is-array-iterator-method"),s=e("../internals/to-length"),a=e("../internals/function-bind-context"),o=e("../internals/get-iterator-method"),u=e("../internals/iterator-close"),c=function(e,t){this.stopped=e,this.result=t};t.exports=function(e,t,n){var l,d,f,p,h,b,m,v=n&&n.that,y=!(!n||!n.AS_ENTRIES),g=!(!n||!n.IS_ITERATOR),_=!(!n||!n.INTERRUPTED),k=a(t,v,1+y+_),w=function(e){return l&&u(l),new c(!0,e)},x=function(e){return y?(r(e),_?k(e[0],e[1],w):k(e[0],e[1])):_?k(e,w):k(e)};if(g)l=e;else{if("function"!=typeof(d=o(e)))throw TypeError("Target is not iterable");if(i(d)){for(f=0,p=s(e.length);p>f;f++)if((h=x(e[f]))&&h instanceof c)return h;return new c(!1)}l=d.call(e)}for(b=l.next;!(m=b.call(l)).done;){try{h=x(m.value)}catch(e){throw u(l),e}if("object"==typeof h&&h&&h instanceof c)return h}return new c(!1)}},{"../internals/an-object":227,"../internals/function-bind-context":246,"../internals/get-iterator-method":248,"../internals/is-array-iterator-method":258,"../internals/iterator-close":263,"../internals/to-length":295}],263:[function(e,t,n){var r=e("../internals/an-object");t.exports=function(e){var t=e.return;if(void 0!==t)return r(t.call(e)).value}},{"../internals/an-object":227}],264:[function(e,t,n){arguments[4][121][0].apply(n,arguments)},{dup:121}],265:[function(e,t,n){var r,i,s,a,o,u,c,l,d=e("../internals/global"),f=e("../internals/object-get-own-property-descriptor").f,p=e("../internals/task").set,h=e("../internals/engine-is-ios"),b=e("../internals/engine-is-webos-webkit"),m=e("../internals/engine-is-node"),v=d.MutationObserver||d.WebKitMutationObserver,y=d.document,g=d.process,_=d.Promise,k=f(d,"queueMicrotask"),w=k&&k.value;w||(r=function(){var e,t;for(m&&(e=g.domain)&&e.exit();i;){t=i.fn,i=i.next;try{t()}catch(e){throw i?a():s=void 0,e}}s=void 0,e&&e.enter()},h||m||b||!v||!y?_&&_.resolve?((c=_.resolve(void 0)).constructor=_,l=c.then,a=function(){l.call(c,r)}):a=m?function(){g.nextTick(r)}:function(){p.call(d,r)}:(o=!0,u=y.createTextNode(""),new v(r).observe(u,{characterData:!0}),a=function(){u.data=o=!o})),t.exports=w||function(e){var t={fn:e,next:void 0};s&&(s.next=t),i||(i=t,a()),s=t}},{"../internals/engine-is-ios":238,"../internals/engine-is-node":239,"../internals/engine-is-webos-webkit":240,"../internals/global":249,"../internals/object-get-own-property-descriptor":271,"../internals/task":291}],266:[function(e,t,n){var r=e("../internals/global");t.exports=r.Promise},{"../internals/global":249}],267:[function(e,t,n){var r=e("../internals/engine-v8-version"),i=e("../internals/fails");t.exports=!!Object.getOwnPropertySymbols&&!i(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41})},{"../internals/engine-v8-version":242,"../internals/fails":245}],268:[function(e,t,n){var r=e("../internals/global"),i=e("../internals/inspect-source"),s=r.WeakMap;t.exports="function"==typeof s&&/native code/.test(i(s))},{"../internals/global":249,"../internals/inspect-source":256}],269:[function(e,t,n){"use strict";var r=e("../internals/a-function"),i=function(e){var t,n;this.promise=new e(function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r}),this.resolve=r(t),this.reject=r(n)};t.exports.f=function(e){return new i(e)}},{"../internals/a-function":224}],270:[function(e,t,n){var r=e("../internals/descriptors"),i=e("../internals/ie8-dom-define"),s=e("../internals/an-object"),a=e("../internals/to-primitive"),o=Object.defineProperty;n.f=r?o:function(e,t,n){if(s(e),t=a(t,!0),s(n),i)try{return o(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},{"../internals/an-object":227,"../internals/descriptors":235,"../internals/ie8-dom-define":254,"../internals/to-primitive":297}],271:[function(e,t,n){var r=e("../internals/descriptors"),i=e("../internals/object-property-is-enumerable"),s=e("../internals/create-property-descriptor"),a=e("../internals/to-indexed-object"),o=e("../internals/to-primitive"),u=e("../internals/has"),c=e("../internals/ie8-dom-define"),l=Object.getOwnPropertyDescriptor;n.f=r?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch(e){}if(u(e,t))return s(!i.f.call(e,t),e[t])}},{"../internals/create-property-descriptor":234,"../internals/descriptors":235,"../internals/has":250,"../internals/ie8-dom-define":254,"../internals/object-property-is-enumerable":275,"../internals/to-indexed-object":293,"../internals/to-primitive":297}],272:[function(e,t,n){var r=e("../internals/object-keys-internal"),i=e("../internals/enum-bug-keys").concat("length","prototype");n.f=Object.getOwnPropertyNames||function(e){return r(e,i)}},{"../internals/enum-bug-keys":243,"../internals/object-keys-internal":274}],273:[function(e,t,n){n.f=Object.getOwnPropertySymbols},{}],274:[function(e,t,n){var r=e("../internals/has"),i=e("../internals/to-indexed-object"),s=e("../internals/array-includes").indexOf,a=e("../internals/hidden-keys");t.exports=function(e,t){var n,o=i(e),u=0,c=[];for(n in o)!r(a,n)&&r(o,n)&&c.push(n);for(;t.length>u;)r(o,n=t[u++])&&(~s(c,n)||c.push(n));return c}},{"../internals/array-includes":228,"../internals/has":250,"../internals/hidden-keys":251,"../internals/to-indexed-object":293}],275:[function(e,t,n){"use strict";var r={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,s=i&&!r.call({1:2},1);n.f=s?function(e){var t=i(this,e);return!!t&&t.enumerable}:r},{}],276:[function(e,t,n){var r=e("../internals/an-object"),i=e("../internals/a-possible-prototype");t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,s){return r(n),i(s),t?e.call(n,s):n.__proto__=s,n}}():void 0)},{"../internals/a-possible-prototype":225,"../internals/an-object":227}],277:[function(e,t,n){var r=e("../internals/get-built-in"),i=e("../internals/object-get-own-property-names"),s=e("../internals/object-get-own-property-symbols"),a=e("../internals/an-object");t.exports=r("Reflect","ownKeys")||function(e){var t=i.f(a(e)),n=s.f;return n?t.concat(n(e)):t}},{"../internals/an-object":227,"../internals/get-built-in":247,"../internals/object-get-own-property-names":272,"../internals/object-get-own-property-symbols":273}],278:[function(e,t,n){var r=e("../internals/global");t.exports=r},{"../internals/global":249}],279:[function(e,t,n){t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}},{}],280:[function(e,t,n){var r=e("../internals/an-object"),i=e("../internals/is-object"),s=e("../internals/new-promise-capability");t.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=s.f(e);return(0,n.resolve)(t),n.promise}},{"../internals/an-object":227,"../internals/is-object":260,"../internals/new-promise-capability":269}],281:[function(e,t,n){var r=e("../internals/redefine");t.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},{"../internals/redefine":282}],282:[function(e,t,n){var r=e("../internals/global"),i=e("../internals/create-non-enumerable-property"),s=e("../internals/has"),a=e("../internals/set-global"),o=e("../internals/inspect-source"),u=e("../internals/internal-state"),c=u.get,l=u.enforce,d=String(String).split("String");(t.exports=function(e,t,n,o){var u,c=!!o&&!!o.unsafe,f=!!o&&!!o.enumerable,p=!!o&&!!o.noTargetGet;"function"==typeof n&&("string"!=typeof t||s(n,"name")||i(n,"name",t),(u=l(n)).source||(u.source=d.join("string"==typeof t?t:""))),e!==r?(c?!p&&e[t]&&(f=!0):delete e[t],f?e[t]=n:i(e,t,n)):f?e[t]=n:a(t,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&c(this).source||o(this)})},{"../internals/create-non-enumerable-property":233,"../internals/global":249,"../internals/has":250,"../internals/inspect-source":256,"../internals/internal-state":257,"../internals/set-global":284}],283:[function(e,t,n){t.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},{}],284:[function(e,t,n){var r=e("../internals/global"),i=e("../internals/create-non-enumerable-property");t.exports=function(e,t){try{i(r,e,t)}catch(n){r[e]=t}return t}},{"../internals/create-non-enumerable-property":233,"../internals/global":249}],285:[function(e,t,n){"use strict";var r=e("../internals/get-built-in"),i=e("../internals/object-define-property"),s=e("../internals/well-known-symbol"),a=e("../internals/descriptors"),o=s("species");t.exports=function(e){var t=r(e),n=i.f;a&&t&&!t[o]&&n(t,o,{configurable:!0,get:function(){return this}})}},{"../internals/descriptors":235,"../internals/get-built-in":247,"../internals/object-define-property":270,"../internals/well-known-symbol":301}],286:[function(e,t,n){var r=e("../internals/object-define-property").f,i=e("../internals/has"),s=e("../internals/well-known-symbol")("toStringTag");t.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,s)&&r(e,s,{configurable:!0,value:t})}},{"../internals/has":250,"../internals/object-define-property":270,"../internals/well-known-symbol":301}],287:[function(e,t,n){var r=e("../internals/shared"),i=e("../internals/uid"),s=r("keys");t.exports=function(e){return s[e]||(s[e]=i(e))}},{"../internals/shared":289,"../internals/uid":299}],288:[function(e,t,n){var r=e("../internals/global"),i=e("../internals/set-global"),s=r["__core-js_shared__"]||i("__core-js_shared__",{});t.exports=s},{"../internals/global":249,"../internals/set-global":284}],289:[function(e,t,n){var r=e("../internals/is-pure"),i=e("../internals/shared-store");(t.exports=function(e,t){return i[e]||(i[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.15.2",mode:r?"pure":"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})},{"../internals/is-pure":261,"../internals/shared-store":288}],290:[function(e,t,n){var r=e("../internals/an-object"),i=e("../internals/a-function"),s=e("../internals/well-known-symbol")("species");t.exports=function(e,t){var n,a=r(e).constructor;return void 0===a||null==(n=r(a)[s])?t:i(n)}},{"../internals/a-function":224,"../internals/an-object":227,"../internals/well-known-symbol":301}],291:[function(e,t,n){var r,i,s,a=e("../internals/global"),o=e("../internals/fails"),u=e("../internals/function-bind-context"),c=e("../internals/html"),l=e("../internals/document-create-element"),d=e("../internals/engine-is-ios"),f=e("../internals/engine-is-node"),p=a.location,h=a.setImmediate,b=a.clearImmediate,m=a.process,v=a.MessageChannel,y=a.Dispatch,g=0,_={},k=function(e){if(_.hasOwnProperty(e)){var t=_[e];delete _[e],t()}},w=function(e){return function(){k(e)}},x=function(e){k(e.data)},C=function(e){a.postMessage(e+"",p.protocol+"//"+p.host)};h&&b||(h=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return _[++g]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},r(g),g},b=function(e){delete _[e]},f?r=function(e){m.nextTick(w(e))}:y&&y.now?r=function(e){y.now(w(e))}:v&&!d?(s=(i=new v).port2,i.port1.onmessage=x,r=u(s.postMessage,s,1)):a.addEventListener&&"function"==typeof postMessage&&!a.importScripts&&p&&"file:"!==p.protocol&&!o(C)?(r=C,a.addEventListener("message",x,!1)):r="onreadystatechange"in l("script")?function(e){c.appendChild(l("script")).onreadystatechange=function(){c.removeChild(this),k(e)}}:function(e){setTimeout(w(e),0)}),t.exports={set:h,clear:b}},{"../internals/document-create-element":236,"../internals/engine-is-ios":238,"../internals/engine-is-node":239,"../internals/fails":245,"../internals/function-bind-context":246,"../internals/global":249,"../internals/html":253}],292:[function(e,t,n){var r=e("../internals/to-integer"),i=Math.max,s=Math.min;t.exports=function(e,t){var n=r(e);return n<0?i(n+t,0):s(n,t)}},{"../internals/to-integer":294}],293:[function(e,t,n){var r=e("../internals/indexed-object"),i=e("../internals/require-object-coercible");t.exports=function(e){return r(i(e))}},{"../internals/indexed-object":255,"../internals/require-object-coercible":283}],294:[function(e,t,n){var r=Math.ceil,i=Math.floor;t.exports=function(e){return isNaN(e=+e)?0:(e>0?i:r)(e)}},{}],295:[function(e,t,n){var r=e("../internals/to-integer"),i=Math.min;t.exports=function(e){return e>0?i(r(e),9007199254740991):0}},{"../internals/to-integer":294}],296:[function(e,t,n){var r=e("../internals/require-object-coercible");t.exports=function(e){return Object(r(e))}},{"../internals/require-object-coercible":283}],297:[function(e,t,n){var r=e("../internals/is-object");t.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},{"../internals/is-object":260}],298:[function(e,t,n){var r={};r[e("../internals/well-known-symbol")("toStringTag")]="z",t.exports="[object z]"===String(r)},{"../internals/well-known-symbol":301}],299:[function(e,t,n){var r=0,i=Math.random();t.exports=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++r+i).toString(36)}},{}],300:[function(e,t,n){var r=e("../internals/native-symbol");t.exports=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},{"../internals/native-symbol":267}],301:[function(e,t,n){var r=e("../internals/global"),i=e("../internals/shared"),s=e("../internals/has"),a=e("../internals/uid"),o=e("../internals/native-symbol"),u=e("../internals/use-symbol-as-uid"),c=i("wks"),l=r.Symbol,d=u?l:l&&l.withoutSetter||a;t.exports=function(e){return s(c,e)&&(o||"string"==typeof c[e])||(o&&s(l,e)?c[e]=l[e]:c[e]=d("Symbol."+e)),c[e]}},{"../internals/global":249,"../internals/has":250,"../internals/native-symbol":267,"../internals/shared":289,"../internals/uid":299,"../internals/use-symbol-as-uid":300}],302:[function(e,t,n){"use strict";var r,i,s,a,o=e("../internals/export"),u=e("../internals/is-pure"),c=e("../internals/global"),l=e("../internals/get-built-in"),d=e("../internals/native-promise-constructor"),f=e("../internals/redefine"),p=e("../internals/redefine-all"),h=e("../internals/object-set-prototype-of"),b=e("../internals/set-to-string-tag"),m=e("../internals/set-species"),v=e("../internals/is-object"),y=e("../internals/a-function"),g=e("../internals/an-instance"),_=e("../internals/inspect-source"),k=e("../internals/iterate"),w=e("../internals/check-correctness-of-iteration"),x=e("../internals/species-constructor"),C=e("../internals/task").set,j=e("../internals/microtask"),S=e("../internals/promise-resolve"),T=e("../internals/host-report-errors"),E=e("../internals/new-promise-capability"),M=e("../internals/perform"),I=e("../internals/internal-state"),R=e("../internals/is-forced"),P=e("../internals/well-known-symbol"),O=e("../internals/engine-is-browser"),L=e("../internals/engine-is-node"),N=e("../internals/engine-v8-version"),A=P("species"),D="Promise",U=I.get,F=I.set,q=I.getterFor(D),B=d&&d.prototype,z=d,W=B,G=c.TypeError,H=c.document,K=c.process,V=E.f,Q=V,J=!!(H&&H.createEvent&&c.dispatchEvent),X="function"==typeof PromiseRejectionEvent,$=!1,Y=R(D,function(){var e=_(z),t=e!==String(z);if(!t&&66===N)return!0;if(u&&!W.finally)return!0;if(N>=51&&/native code/.test(e))return!1;var n=new z(function(e){e(1)}),r=function(e){e(function(){},function(){})};return(n.constructor={})[A]=r,!($=n.then(function(){})instanceof r)||!t&&O&&!X}),Z=Y||!w(function(e){z.all(e).catch(function(){})}),ee=function(e){var t;return!(!v(e)||"function"!=typeof(t=e.then))&&t},te=function(e,t){if(!e.notified){e.notified=!0;var n=e.reactions;j(function(){for(var r=e.value,i=1==e.state,s=0;n.length>s;){var a,o,u,c=n[s++],l=i?c.ok:c.fail,d=c.resolve,f=c.reject,p=c.domain;try{l?(i||(2===e.rejection&&se(e),e.rejection=1),!0===l?a=r:(p&&p.enter(),a=l(r),p&&(p.exit(),u=!0)),a===c.promise?f(G("Promise-chain cycle")):(o=ee(a))?o.call(a,d,f):d(a)):f(r)}catch(e){p&&!u&&p.exit(),f(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&re(e)})}},ne=function(e,t,n){var r,i;J?((r=H.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),c.dispatchEvent(r)):r={promise:t,reason:n},!X&&(i=c["on"+e])?i(r):"unhandledrejection"===e&&T("Unhandled promise rejection",n)},re=function(e){C.call(c,function(){var t,n=e.facade,r=e.value;if(ie(e)&&(t=M(function(){L?K.emit("unhandledRejection",r,n):ne("unhandledrejection",n,r)}),e.rejection=L||ie(e)?2:1,t.error))throw t.value})},ie=function(e){return 1!==e.rejection&&!e.parent},se=function(e){C.call(c,function(){var t=e.facade;L?K.emit("rejectionHandled",t):ne("rejectionhandled",t,e.value)})},ae=function(e,t,n){return function(r){e(t,r,n)}},oe=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,te(e,!0))},ue=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw G("Promise can't be resolved itself");var r=ee(t);r?j(function(){var n={done:!1};try{r.call(t,ae(ue,n,e),ae(oe,n,e))}catch(t){oe(n,t,e)}}):(e.value=t,e.state=1,te(e,!1))}catch(t){oe({done:!1},t,e)}}};if(Y&&(W=(z=function(e){g(this,z,D),y(e),r.call(this);var t=U(this);try{e(ae(ue,t),ae(oe,t))}catch(e){oe(t,e)}}).prototype,(r=function(e){F(this,{type:D,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=p(W,{then:function(e,t){var n=q(this),r=V(x(this,z));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=L?K.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&te(n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),i=function(){var e=new r,t=U(e);this.promise=e,this.resolve=ae(ue,t),this.reject=ae(oe,t)},E.f=V=function(e){return e===z||e===s?new i(e):Q(e)},!u&&"function"==typeof d&&B!==Object.prototype)){a=B.then,$||(f(B,"then",function(e,t){var n=this;return new z(function(e,t){a.call(n,e,t)}).then(e,t)},{unsafe:!0}),f(B,"catch",W.catch,{unsafe:!0}));try{delete B.constructor}catch(e){}h&&h(B,W)}o({global:!0,wrap:!0,forced:Y},{Promise:z}),b(z,D,!1,!0),m(D),s=l(D),o({target:D,stat:!0,forced:Y},{reject:function(e){var t=V(this);return t.reject.call(void 0,e),t.promise}}),o({target:D,stat:!0,forced:u||Y},{resolve:function(e){return S(u&&this===s?z:this,e)}}),o({target:D,stat:!0,forced:Z},{all:function(e){var t=this,n=V(t),r=n.resolve,i=n.reject,s=M(function(){var n=y(t.resolve),s=[],a=0,o=1;k(e,function(e){var u=a++,c=!1;s.push(void 0),o++,n.call(t,e).then(function(e){c||(c=!0,s[u]=e,--o||r(s))},i)}),--o||r(s)});return s.error&&i(s.value),n.promise},race:function(e){var t=this,n=V(t),r=n.reject,i=M(function(){var i=y(t.resolve);k(e,function(e){i.call(t,e).then(n.resolve,r)})});return i.error&&r(i.value),n.promise}})},{"../internals/a-function":224,"../internals/an-instance":226,"../internals/check-correctness-of-iteration":229,"../internals/engine-is-browser":237,"../internals/engine-is-node":239,"../internals/engine-v8-version":242,"../internals/export":244,"../internals/get-built-in":247,"../internals/global":249,"../internals/host-report-errors":252,"../internals/inspect-source":256,"../internals/internal-state":257,"../internals/is-forced":259,"../internals/is-object":260,"../internals/is-pure":261,"../internals/iterate":262,"../internals/microtask":265,"../internals/native-promise-constructor":266,"../internals/new-promise-capability":269,"../internals/object-set-prototype-of":276,"../internals/perform":279,"../internals/promise-resolve":280,"../internals/redefine":282,"../internals/redefine-all":281,"../internals/set-species":285,"../internals/set-to-string-tag":286,"../internals/species-constructor":290,"../internals/task":291,"../internals/well-known-symbol":301}],303:[function(e,t,n){
172
- /*
173
- @license
174
- Copyright (c) 2016, Twilio, Inc.
175
-
176
- Permission to use, copy, modify, and/or distribute this software for any
177
- purpose with or without fee is hereby granted, provided that the above
178
- copyright notice and this permission notice appear in all copies.
179
-
180
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
181
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
182
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
183
- SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
184
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
185
- OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
186
- CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
187
-
188
- */
189
- "use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("@babel/runtime/helpers/defineProperty");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}e("core-js/modules/es.promise.js");var s=i(r);function a(){}function o(){o.init.call(this)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,s,o,c;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),o=s[t]):(s=e._events=new a,e._eventsCount=0),o){if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),!o.warned&&(i=u(e))&&i>0&&o.length>i){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,c=l,"function"==typeof console.warn?console.warn(c):console.log(c)}}else o=s[t]=n,++e._eventsCount;return e}function l(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function d(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 f(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}a.prototype=Object.create(null),o.EventEmitter=o,o.usingDomains=!1,o.prototype.domain=void 0,o.prototype._events=void 0,o.prototype._maxListeners=void 0,o.defaultMaxListeners=10,o.init=function(){this.domain=null,o.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new a,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.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},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){var t,n,r,i,s,a,o,u="error"===e;if(a=this._events)u=u&&null==a.error;else if(!u)return!1;if(o=this.domain,u){if(t=arguments[1],!o){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(n=a[e]))return!1;var l="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=f(e,r),s=0;s<r;++s)i[s].call(n)}(n,l,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,s=f(e,i),a=0;a<i;++a)s[a].call(n,r)}(n,l,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var s=e.length,a=f(e,s),o=0;o<s;++o)a[o].call(n,r,i)}(n,l,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,s){if(t)e.call(n,r,i,s);else for(var a=e.length,o=f(e,a),u=0;u<a;++u)o[u].call(n,r,i,s)}(n,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),s=1;s<r;s++)i[s-1]=arguments[s];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,s=f(e,i),a=0;a<i;++a)s[a].apply(n,r)}(n,l,this,i)}return!0},o.prototype.addListener=function(e,t){return c(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return c(this,e,t,!0)},o.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,l(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,l(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new a:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new a,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,o||t)}return this},o.prototype.off=function(e,t){return this.removeListener(e,t)},o.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new a,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new a:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),s=0;s<i.length;++s)"removeListener"!==(r=i[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new a,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},o.prototype.listeners=function(e){var t,n=this._events;return n&&(t=n[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[]},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class p extends o{constructor(e){super(),s.default(this,"timeout",null),s.default(this,"startTimestamp",-1),this.minDelay=e.min,this.maxDelay=e.max,this.initialDelay=e.initial||0,this.maxAttemptsCount=e.maxAttemptsCount||0,this.maxAttemptsTime=e.maxAttemptsTime||0,this.randomness=e.randomness||0,this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}attempt(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}nextDelay(e){if("number"==typeof e)return this.prevDelay=0,this.currDelay=e,e;if(0==this.attemptNum)return this.initialDelay;if(1==this.attemptNum)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var t=this.currDelay+this.prevDelay;return this.maxDelay&&t>this.maxDelay&&(this.currDelay=this.maxDelay,t=this.maxDelay),this.currDelay=t,t}randomize(e){var t=e*this.randomness,n=Math.round(Math.random()*t*2-t);return Math.max(0,e+n)}scheduleAttempt(e){if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt count limit reached"));var t=this.nextDelay(e);if(t=this.randomize(t),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+t)return this.cleanup(),void this.emit("failed",new Error("Maximum attempt time limit reached"));this.timeout=setTimeout(()=>this.attempt(),t)}cleanup(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}start(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}cancel(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}succeeded(e){this.emit("succeeded",e)}failed(e,t){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(t)}}function h(e){return null!=e}class b extends o{constructor(e){super(),s.default(this,"backoffDelay",0),s.default(this,"nextBackoffDelay",0),s.default(this,"backoffNumber",0),s.default(this,"timeoutID",null),s.default(this,"maxNumberOfRetry",-1);var t=e=e||{},n=t.initialDelay,r=t.maxDelay,i=t.randomisationFactor,a=t.factor;if(h(n)&&n<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(h(r)&&r<=1)throw new Error("The maximal timeout must be greater than 1.");if(h(i)&&(i<0||i>1))throw new Error("The randomisation factor must be between 0 and 1.");if(h(a)&&a<=1)throw new Error("Exponential factor should be greater than 1.");if(this.initialDelay=n||100,this.maxDelay=r||1e4,this.maxDelay<=this.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");this.randomisationFactor=i||0,this.factor=a||2,this.reset()}static exponential(e){return new b(e)}backoff(e){null==this.timeoutID&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",e),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,e)))}reset(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}failAfter(e){if(e<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(e));this.maxNumberOfRetry=e}next(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var e=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*e))}onBackoff(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}n.AsyncRetrier=class extends o{constructor(e){super(),s.default(this,"resolve",()=>void 0),s.default(this,"reject",()=>void 0),this.retrier=new p(e)}run(e){return this.retrier.on("attempt",()=>{e().then(e=>this.retrier.succeeded(e)).catch(e=>this.retrier.failed(e))}),this.retrier.on("succeeded",e=>this.resolve(e)),this.retrier.on("cancelled",()=>this.reject(new Error("Cancelled"))),this.retrier.on("failed",e=>this.reject(e)),new Promise((e,t)=>{this.resolve=e,this.reject=t,this.retrier.start()})}cancel(){this.retrier.cancel()}},n.Backoff=b,n.Retrier=p},{"@babel/runtime/helpers/defineProperty":28,"core-js/modules/es.promise.js":302}],304:[function(e,t,n){t.exports={_from:"twilio-mcs-client@=0.5.0-rc2",_id:"twilio-mcs-client@0.5.0-rc2",_inBundle:!1,_integrity:"sha512-RF34zN6JLDwyW7Rl6npqcXOkkFMqXP1eD6yHeQRgZ/frEXQgRL7oODI3ljW+4bonTddY4RjOGS0nvrIH7vYffg==",_location:"/twilio-mcs-client",_phantomChildren:{"@babel/runtime":"7.14.6"},_requested:{type:"version",registry:!0,raw:"twilio-mcs-client@=0.5.0-rc2",name:"twilio-mcs-client",escapedName:"twilio-mcs-client",rawSpec:"=0.5.0-rc2",saveSpec:null,fetchSpec:"=0.5.0-rc2"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/twilio-mcs-client/-/twilio-mcs-client-0.5.0-rc2.tgz",_shasum:"bfd568e493261c475da2472d58c3af3b14cb4d94",_spec:"twilio-mcs-client@=0.5.0-rc2",_where:"/home/circleci/project",author:{name:"Twilio"},browser:{xmlhttprequest:!1},browserify:{transform:["babelify"]},bundleDependencies:!1,dependencies:{loglevel:"^1.6.4","operation-retrier":"^4.0.1",xmlhttprequest:"^1.8.0"},deprecated:!1,description:"Twilio Media Content Service client library",devDependencies:{"@types/chai":"^4.2.2","@types/chai-as-promised":"^7.1.2","@types/chai-datetime":"0.0.33","@types/chai-string":"^1.4.2","@types/core-js":"^2.5.2","@types/express":"^4.17.7","@types/mocha":"^5.2.7","@types/node":"^12.7.4","@types/qs":"6.9.4","@types/sinon":"^7.0.13","@types/sinon-chai":"^3.2.3",async:"^3.1.0","async-test-tools":"^1.0.7","babel-core":"^6.26.0","babel-plugin-transform-builtin-extend":"^1.1.2","babel-plugin-transform-runtime":"^6.23.0","babel-preset-env":"^1.6.1","babel-runtime":"^6.26.0",babelify:"^8.0.0",browserify:"^16.2.3",chai:"^4.2.0","chai-as-promised":"^7.1.1","chai-datetime":"^1.5.0","chai-string":"^1.5.0",cheerio:"^1.0.0-rc.2",del:"^5.1.0",dotenv:"^8.6.0",express:"^4.17.1",gulp:"^4.0.2","gulp-babel":"^7.0.1","gulp-derequire":"^2.1.0","gulp-if":"^3.0.0","gulp-insert":"^0.5.0","gulp-mocha":"^7.0.1","gulp-rename":"^1.4.0","gulp-sourcemaps":"^2.6.5","gulp-tap":"^2.0.0","gulp-tslint":"^8.1.4","gulp-typescript":"^5.0.1","gulp-uglify-es":"^1.0.0","ink-docstrap":"^1.3.2","isomorphic-form-data":"^2.0.0",jsdoc:"~3.5.5","jsdoc-strip-async-await":"^0.1.0",mocha:"^6.2.0",ngrok:"^3.2.5",nyc:"^14.1.1",sinon:"^7.4.2","sinon-chai":"^3.3.0","ts-node":"^8.3.0",tslint:"^5.19.0",twilio:"^3.55.0",typescript:"^3.6.2","uglify-save-license":"^0.4.1","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},engines:{node:">=10"},license:"MIT",main:"lib/index.js",name:"twilio-mcs-client",scripts:{integrationTest:"npx gulp integrationTest",unitTest:"npx gulp unitTest"},types:"./lib/client.d.ts",version:"0.5.0-rc2"}},{}],305:[function(e,t,n){"use strict";var r=l(e("babel-runtime/regenerator")),i=l(e("babel-runtime/helpers/asyncToGenerator")),s=l(e("babel-runtime/core-js/object/get-prototype-of")),a=l(e("babel-runtime/helpers/classCallCheck")),o=l(e("babel-runtime/helpers/createClass")),u=l(e("babel-runtime/helpers/possibleConstructorReturn")),c=l(e("babel-runtime/helpers/inherits"));function l(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Client=void 0;var d=e("events"),f=e("twilsock"),p=e("./configuration"),h=e("./registrar"),b=e("./logger"),m=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.default)(this,t);var r=(0,u.default)(this,(t.__proto__||(0,s.default)(t)).call(this));if(!e||0===e.length)throw new Error("Token is required for Notifications client");n.logLevel=n.logLevel||"error",b.log.setLevel(n.logLevel);n.minTokenRefreshInterval;var i=n.productId||"notifications";return n.twilsockClient=n.twilsockClient||new f.TwilsockClient(e,i,n),n.transport=n.transport||n.twilsockClient,r.services={twilsock:n.twilsockClient,transport:n.transport,config:new p.Configuration(null,n)},r.registrar=new h.Registrar(i,r.services.transport,r.services.twilsock,r.services.config),r.reliableTransportState={overall:!1,transport:!1,registration:!1,lastEmitted:null},r._onTransportStateChange(r.services.twilsock.isConnected),r.registrar.on("transportReady",function(e){r._onRegistrationStateChange(e?"registered":"")}),r.registrar.on("stateChanged",function(e){r._onRegistrationStateChange(e)}),r.registrar.on("needReliableTransport",r._onNeedReliableTransport.bind(r)),r.services.twilsock.on("message",function(e,t){return r._routeMessage(e,t)}),r.services.twilsock.on("connected",function(e){r._onTransportStateChange(!0),r.registrar.setNotificationId("twilsock",e)}),r.services.twilsock.on("disconnected",function(){r._onTransportStateChange(!1)}),r.services.config.updateToken(e),r.registrar.updateToken(e),r}return(0,c.default)(t,e),(0,o.default)(t,[{key:"_routeMessage",value:function(e,t){b.log.trace("Message arrived: ",e,t),this.emit("message",e,t)}},{key:"_onNeedReliableTransport",value:function(e){e?this.services.twilsock.connect():this.services.twilsock.disconnect()}},{key:"_onRegistrationStateChange",value:function(e){this.reliableTransportState.registration="registered"===e,this._updateTransportState()}},{key:"_onTransportStateChange",value:function(e){this.reliableTransportState.transport=e,this._updateTransportState()}},{key:"_updateTransportState",value:function(){var e=this.reliableTransportState.transport&&this.reliableTransportState.registration;this.reliableTransportState.overall!==e&&(this.reliableTransportState.overall=e,b.log.info("Transport ready:",e),this.emit("transportReady",e)),this.reliableTransportState.lastEmitted!==this.connectionState&&(this.reliableTransportState.lastEmitted=this.connectionState,this.emit("connectionStateChanged",this.connectionState))}},{key:"subscribe",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"twilsock";return b.log.trace("Add subscriptions for message type: ",e,t),this.registrar.subscribe(e,t)}},{key:"unsubscribe",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"twilsock";return b.log.trace("Remove subscriptions for message type: ",e,t),this.registrar.unsubscribe(e,t)}},{key:"handlePushNotification",value:function(e){return{messageType:e.twi_message_type,payload:e.payload}}},{key:"setPushRegistrationId",value:function(e,t){b.log.trace("Set push registration id",e,t),this.registrar.setNotificationId(t,e)}},{key:"updateToken",value:function(){var e=(0,i.default)(r.default.mark(function e(t){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(b.log.info("authTokenUpdated"),this.services.config.token!==t){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this.services.twilsock.updateToken(t);case 5:this.services.config.updateToken(t),this.registrar.updateToken(t);case 7:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"connectionState",get:function(){return"disconnected"===this.services.twilsock.state?"disconnected":"disconnecting"===this.services.twilsock.state?"disconnecting":"connected"===this.services.twilsock.state&&this.reliableTransportState.registration?"connected":"rejected"===this.services.twilsock.state?"denied":"connecting"}}]),t}(d.EventEmitter);n.Client=m},{"./configuration":306,"./logger":309,"./registrar":311,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200,twilsock:349}],306:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Configuration=void 0;var a=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,r.default)(this,e);var i=n.notifications||{},s="https://ers."+(i.region||n.region||"us1")+".twilio.com/v1/registrations";this.registrarUrl=i.ersUrl||s,this._token=t}return(0,i.default)(e,[{key:"updateToken",value:function(e){this._token=e}},{key:"token",get:function(){return this._token}}]),e}();n.Configuration=a},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],307:[function(e,t,n){"use strict";var r=p(e("babel-runtime/helpers/slicedToArray")),i=p(e("babel-runtime/regenerator")),s=p(e("babel-runtime/helpers/asyncToGenerator")),a=p(e("babel-runtime/core-js/object/get-prototype-of")),o=p(e("babel-runtime/helpers/possibleConstructorReturn")),u=p(e("babel-runtime/helpers/inherits")),c=p(e("babel-runtime/helpers/toConsumableArray")),l=p(e("babel-runtime/core-js/set")),d=p(e("babel-runtime/helpers/classCallCheck")),f=p(e("babel-runtime/helpers/createClass"));function p(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Connector=n.RegistrationState=void 0;var h=e("events"),b=e("./logger"),m=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new l.default;(0,d.default)(this,e),this.token=t,this.notificationId=n,this.messageTypes=r}return(0,f.default)(e,[{key:"clone",value:function(){return new e(this.token,this.notificationId,new l.default(this.messageTypes))}}]),e}();function v(e,t){var n=new l.default;return e.notificationId!==t.notificationId&&n.add("notificationId"),e.token!==t.token&&n.add("token"),function(e,t){return[].concat((0,c.default)([].concat((0,c.default)(e)).filter(function(e){return!t.has(e)})),(0,c.default)([].concat((0,c.default)(t)).filter(function(t){return!e.has(t)})))}(e.messageTypes,t.messageTypes).length>0&&n.add("messageType"),[n.size>0,n]}n.RegistrationState=m;var y=function(e){function t(e){(0,d.default)(this,t);var n=(0,o.default)(this,(t.__proto__||(0,a.default)(t)).call(this));return n.config=e,n.desiredState=new m,n.currentState=new m,n.hasActiveAttempt=!1,n}return(0,u.default)(t,e),(0,f.default)(t,[{key:"subscribe",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.desiredState.messageTypes.has(t)){e.next=3;break}return b.log.debug("message type already registered ",t),e.abrupt("return");case 3:return this.desiredState.messageTypes.add(t),e.next=6,this.persistRegistration();case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"unsubscribe",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.desiredState.messageTypes.has(t)){e.next=2;break}return e.abrupt("return");case 2:return this.desiredState.messageTypes.delete(t),e.next=5,this.persistRegistration();case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateToken",value:function(e){this.desiredState.token=e,this.persistRegistration()}},{key:"persistRegistration",value:function(){var e=(0,s.default)(i.default.mark(function e(){var t,n,s,a,o,u,c=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.config.token&&0!==this.config.token.length){e.next=3;break}return b.log.trace("Can't persist registration: token is not set"),e.abrupt("return");case 3:if(!this.hasActiveAttempt){e.next=6;break}return b.log.trace("One registration attempt is already in progress"),e.abrupt("return");case 6:if(t=v(this.desiredState,this.currentState),n=(0,r.default)(t,2),s=n[0],a=n[1],s){e.next=9;break}return e.abrupt("return");case 9:if(this.currentState.notificationId||a.delete("notificationId"),b.log.trace("Persisting registration",a,this.desiredState),e.prev=11,this.hasActiveAttempt=!0,!((o=this.desiredState.clone()).messageTypes.size>0)){e.next=24;break}return e.next=17,this.updateRegistration(o,a);case 17:u=e.sent,this.currentState.token=u.token,this.currentState.notificationId=u.notificationId,this.currentState.messageTypes=u.messageTypes,this.emit("stateChanged","registered"),e.next=30;break;case 24:return e.next=26,this.removeRegistration();case 26:this.currentState.token=o.token,this.currentState.notificationId=o.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged","unregistered");case 30:return e.prev=30,this.hasActiveAttempt=!1,setTimeout(function(){return c.persistRegistration()},0),e.finish(30);case 34:case"end":return e.stop()}},e,this,[[11,,30,34]])}));return function(){return e.apply(this,arguments)}}()},{key:"setNotificationId",value:function(e){this.desiredState.notificationId=e,this.persistRegistration()}}]),t}(h.EventEmitter);n.Connector=y},{"./logger":309,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/set":45,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/slicedToArray":54,"babel-runtime/helpers/toConsumableArray":55,"babel-runtime/regenerator":57,events:200}],308:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.Notifications=void 0;var r=e("./client");Object.defineProperty(n,"Notifications",{enumerable:!0,get:function(){return r.Client}})},{"./client":305}],309:[function(e,t,n){"use strict";var r=a(e("babel-runtime/helpers/classCallCheck")),i=a(e("babel-runtime/helpers/createClass")),s=a(e("babel-runtime/core-js/array/from"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.log=n.Logger=void 0;var o=e("loglevel");function u(e,t){return[(new Date).toISOString()+" Notifications "+e+":"].concat((0,s.default)(t))}var c=function(){function e(){(0,r.default)(this,e),this.prefix=""}return(0,i.default)(e,[{key:"setLevel",value:function(e){o.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.debug.apply(null,u("T"+this.prefix,t))}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.debug.apply(null,u("D"+this.prefix,t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.info.apply(null,u("I"+this.prefix,t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.warn.apply(null,u("W"+this.prefix,t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.error.apply(null,u("E"+this.prefix,t))}}],[{key:"scope",value:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new e}}]),e}();n.Logger=c;var l=c.scope();n.log=l},{"babel-runtime/core-js/array/from":29,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,loglevel:203}],310:[function(e,t,n){"use strict";var r=f(e("babel-runtime/core-js/array/from")),i=f(e("babel-runtime/core-js/object/assign")),s=f(e("babel-runtime/regenerator")),a=f(e("babel-runtime/helpers/asyncToGenerator")),o=f(e("babel-runtime/core-js/object/get-prototype-of")),u=f(e("babel-runtime/helpers/classCallCheck")),c=f(e("babel-runtime/helpers/createClass")),l=f(e("babel-runtime/helpers/possibleConstructorReturn")),d=f(e("babel-runtime/helpers/inherits"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.RegistrarConnector=n.Connector=void 0;var p=e("operation-retrier"),h=e("./logger"),b=e("./connector");Object.defineProperty(n,"Connector",{enumerable:!0,get:function(){return b.Connector}});var m={min:2e3,max:12e4,randomness:.2},v=function(e){function t(e,n,r,i){(0,u.default)(this,t);var s=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this,i));return s.channelType=e,s.context=n,s.transport=r,s}return(0,d.default)(t,e),(0,c.default)(t,[{key:"updateRegistration",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.has("notificationId")){e.next=3;break}return e.next=3,this.removeRegistration();case 3:if(t.notificationId&&t.notificationId.length){e.next=5;break}return e.abrupt("return",t);case 5:return e.next=7,this.register(t);case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"removeRegistration",value:function(){var e=(0,a.default)(s.default.mark(function e(){var t,n,r=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrationId){e.next=2;break}return e.abrupt("return");case 2:return t=this.config.registrarUrl+"/"+this.registrationId+"?productId="+this.context.productId,n={"Content-Type":"application/json","X-Twilio-Token":this.config.token},e.prev=4,h.log.trace("Removing registration for ",this.channelType),e.next=8,new p.Retrier((0,i.default)(m,{maxAttemptsCount:3})).run(function(){return r.transport.delete(t,n)});case 8:h.log.debug("Registration removed for",this.channelType),e.next=15;break;case 11:throw e.prev=11,e.t0=e.catch(4),h.log.error("Failed to remove of registration ",this.channelType,e.t0),e.t0;case 15:case"end":return e.stop()}},e,this,[[4,11]])}));return function(){return e.apply(this,arguments)}}()},{key:"register",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,i,a,o,u=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return h.log.trace("Registering",this.channelType,t),n={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:(0,r.default)(t.messageTypes),data:{registration_id:t.notificationId},ttl:"PT24H"},i=this.config.registrarUrl+"?productId="+this.context.productId,a={"Content-Type":"application/json","X-Twilio-Token":t.token},h.log.trace("Creating registration for channel ",this.channelType),e.prev=5,e.next=8,new p.Retrier(m).run(function(){return u.transport.post(i,a,n)});case 8:o=e.sent,this.registrationId=o.body.id,h.log.debug("Registration created: ",o),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(5),h.log.error("Registration failed: ",e.t0),e.t0;case 17:case"end":return e.stop()}},e,this,[[5,13]])}));return function(t){return e.apply(this,arguments)}}()}]),t}(b.Connector);n.RegistrarConnector=v},{"./connector":307,"./logger":309,"babel-runtime/core-js/array/from":29,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,"operation-retrier":205}],311:[function(e,t,n){"use strict";var r=c(e("babel-runtime/core-js/map")),i=c(e("babel-runtime/core-js/object/get-prototype-of")),s=c(e("babel-runtime/helpers/classCallCheck")),a=c(e("babel-runtime/helpers/createClass")),o=c(e("babel-runtime/helpers/possibleConstructorReturn")),u=c(e("babel-runtime/helpers/inherits"));function c(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Registrar=void 0;var l=e("events"),d=e("./registrar.connector"),f=e("./twilsock.connector"),p=function(e){function t(e,n,a,u){(0,s.default)(this,t);var c=(0,o.default)(this,(t.__proto__||(0,i.default)(t)).call(this));c.config=u,c.connectors=new r.default;var l=c.detectPlatform();return c.connectors.set("gcm",new d.RegistrarConnector("gcm",{protocolVersion:3,productId:e,platform:l},n,u)),c.connectors.set("fcm",new d.RegistrarConnector("fcm",{protocolVersion:3,productId:e,platform:l},n,u)),c.connectors.set("apn",new d.RegistrarConnector("apn",{protocolVersion:4,productId:e,platform:l},n,u)),c.connectors.set("twilsock",new f.TwilsockConnector({productId:e,platform:l},a,u)),c.connectors.get("twilsock").on("transportReady",function(e){return c.emit("transportReady",e)}),c}return(0,u.default)(t,e),(0,a.default)(t,[{key:"setNotificationId",value:function(e,t){this.connector(e).setNotificationId(t)}},{key:"subscribe",value:function(e,t){return this.connector(t).subscribe(e)}},{key:"unsubscribe",value:function(e,t){return this.connector(t).unsubscribe(e)}},{key:"updateToken",value:function(e){this.connectors.forEach(function(t){return t.updateToken(e)})}},{key:"connector",value:function(e){var t=this.connectors.get(e);if(!t)throw new Error("Unknown channel type: "+e);return t}},{key:"detectPlatform",value:function(){var e="";return"undefined"!=typeof navigator?(e="unknown",void 0!==navigator.product&&(e=navigator.product),void 0!==navigator.userAgent&&(e=navigator.userAgent)):e="web",e.substring(0,128)}}]),t}(l.EventEmitter);n.Registrar=p},{"./registrar.connector":310,"./twilsock.connector":312,"babel-runtime/core-js/map":33,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,events:200}],312:[function(e,t,n){"use strict";var r=d(e("babel-runtime/core-js/array/from")),i=d(e("babel-runtime/regenerator")),s=d(e("babel-runtime/helpers/asyncToGenerator")),a=d(e("babel-runtime/core-js/object/get-prototype-of")),o=d(e("babel-runtime/helpers/classCallCheck")),u=d(e("babel-runtime/helpers/createClass")),c=d(e("babel-runtime/helpers/possibleConstructorReturn")),l=d(e("babel-runtime/helpers/inherits"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.TwilsockConnector=void 0;var f=e("uuid"),p=function(e){function t(e,n,r){(0,o.default)(this,t);var i=(0,c.default)(this,(t.__proto__||(0,a.default)(t)).call(this,r));return i.twilsock=n,i.context=e,e.id=f.v4(),i.twilsock.on("stateChanged",function(e){"connected"!==e&&i.emit("transportReady",!1)}),i.twilsock.on("registered",function(t){e&&t===e.id&&"connected"===n.state&&i.emit("transportReady",!0)}),i}return(0,l.default)(t,e),(0,u.default)(t,[{key:"setNotificationId",value:function(){}},{key:"updateToken",value:function(e){}},{key:"updateContextRequest",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n={product_id:this.context.productId,notification_protocol_version:4,endpoint_platform:this.context.platform,message_types:t},this.emit("transportReady",!1),e.next=4,this.twilsock.setNotificationsContext(this.context.id,n);case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateRegistration",value:function(){var e=(0,s.default)(i.default.mark(function e(t,n){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n.has("messageType")){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.updateContextRequest((0,r.default)(t.messageTypes));case 4:return e.abrupt("return",t);case 5:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"removeRegistration",value:function(){return this.twilsock.removeNotificationsContext(this.context.id)}}]),t}(e("./connector").Connector);n.TwilsockConnector=p},{"./connector":307,"babel-runtime/core-js/array/from":29,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,uuid:370}],313:[function(e,t,n){"use strict";
190
- /*! *****************************************************************************
191
- Copyright (c) Microsoft Corporation.
192
-
193
- Permission to use, copy, modify, and/or distribute this software for any
194
- purpose with or without fee is hereby granted.
195
-
196
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
197
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
198
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
199
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
200
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
201
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
202
- PERFORMANCE OF THIS SOFTWARE.
203
- ***************************************************************************** */
204
- function r(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{mode:"type",checks:e}},a=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{mode:"custom",checks:e}},o=a(function(e){return["string"==typeof e&&e.length>0,"a non-empty string"]}),u=a(function(e){return["number"==typeof e&&Number.isInteger(e)&&e>=0,"a non-negative integer"]}),c=a(function(e){return["object"==typeof e&&null!==e&&!Array.isArray(e),"a pure object (non-null and non-array)"]}),l=function(e,t){var n,s;if(t.length>e.length)throw new Error("Expected at most "+e.length+" argument(s), but got "+t.length);for(;t.length<e.length;)t.push(void 0);try{for(var a=r(t.entries()),o=a.next();!o.done;o=a.next()){var u=i(o.value,2),c=u[0],l=u[1],d=i(h(e[c],l),4),f=d[0],p=d[1],b=d[2],m=d[3];if(!f)throw new Error("Argument "+(c+1)+" is expected to be "+b+m+" but got "+p)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(n)throw n.error}}},d=function(e){var t,n,r;return["undefined","boolean","number","bigint","string"].includes(typeof e)&&(r="string"==typeof e?'"'+e+'"':""+e),"object"==typeof e&&"Object"!==(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)&&(r=null===e?"null":"instance of "+(null===(n=null==e?void 0:e.constructor)||void 0===n?void 0:n.name)),r||(r=typeof e),r},f=function(e){var t,n,i=[];try{for(var s=r(e),a=s.next();!a.done;a=s.next()){var o=a.value;i.push(p(o))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},p=function(e){var t,n,i=[],a=Array.isArray(e)?e:[e];try{for(var o=r(a),u=o.next();!u.done;u=o.next()){var c=u.value;"string"!=typeof c&&"function"!=typeof c?i.push(c):i.push(s(c))}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return i},h=function(e,t){var n,s,a,o,u,c,l,f,p,h=[],b=!1;try{for(var m=r(e),v=m.next();!v.done;v=m.next()){var y=v.value;switch(y.mode){case"type":try{for(var g=(a=void 0,r(y.checks)),_=g.next();!_.done;_=g.next()){var k=_.value;"string"!=typeof k?(b=b||t instanceof k,h.push("an instance of "+k.name)):(b=b||typeof t===k,h.push("of type "+k))}}catch(e){a={error:e}}finally{try{_&&!_.done&&(o=g.return)&&o.call(g)}finally{if(a)throw a.error}}break;case"literal":try{for(var w=(u=void 0,r(y.checks)),x=w.next();!x.done;x=w.next()){var C=x.value;b=b||t===C,h.push("string"==typeof C?'"'+C+'"':""+C)}}catch(e){u={error:e}}finally{try{x&&!x.done&&(c=w.return)&&c.call(w)}finally{if(u)throw u.error}}break;case"custom":try{for(var j=(l=void 0,r(y.checks)),S=j.next();!S.done;S=j.next()){var T=i((0,S.value)(t),3),E=T[0],M=T[1],I=T[2];b=b||E,!p&&I&&(p=I),M&&h.push(M)}}catch(e){l={error:e}}finally{try{S&&!S.done&&(f=j.return)&&f.call(j)}finally{if(l)throw l.error}}}}}catch(e){n={error:e}}finally{try{v&&!v.done&&(s=m.return)&&s.call(m)}finally{if(n)throw n.error}}if(b)return[!0];var R=p||d(t),P=h.length-1;return[!1,R,P>0?h.slice(0,P).join(", ")+" or "+h[P]:h.join(", "),P>1?";":","]};n.custom=a,n.literal=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{mode:"literal",checks:e}},n.nonEmptyString=o,n.nonNegativeInteger=u,n.objectSchema=function(e,t){return a(function(n){var s,a;if("object"!=typeof n||null===n||Array.isArray(n))return[!1,"valid "+e+" (should be a pure object)"];try{for(var o=r(Object.entries(t)),u=o.next();!u.done;u=o.next()){var c=i(u.value,2),l=c[0],d=c[1],f=i(h(p(d),n[l]),3),b=f[0],m=f[1],v=f[2];if(!b)return[!1,"valid "+e+' (key "'+l+'" should be '+v+")","malformed "+e+' (key "'+l+'" is '+m+")"]}}catch(e){s={error:e}}finally{try{u&&!u.done&&(a=o.return)&&a.call(o)}finally{if(s)throw s.error}}return[!0]})},n.pureObject=c,n.runtimeTypeValidation=l,n.stringifyReceivedType=d,n.type=s,n.validateTypes=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=f(e);return function(e,t,r){if("function"!=typeof r.value)throw new Error("The validateTypes decorator can only be applied to methods");var i=r.value;r.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return l(n,e),i.apply(this,e)}}},n.validateTypesAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=f(e);return function(e,t,r){if("function"!=typeof r.value)throw new Error("The validateTypesAsync decorator can only be applied to methods");var i=r.value;r.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{l(n,e)}catch(e){return Promise.reject(e)}return i.apply(this,e)}}}},{}],314:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/get-iterator")),i=o(e("babel-runtime/helpers/slicedToArray")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=e("./utils/tree"),c=function(){function e(t,n){(0,s.default)(this,e),this.value=t,this.revision=n||0}return(0,a.default)(e,[{key:"isValid",get:function(){return!0}}]),e}(),l=function(){function e(t){(0,s.default)(this,e),this.revision=t}return(0,a.default)(e,[{key:"isValid",get:function(){return!1}}]),e}(),d=function(){function e(){(0,s.default)(this,e),this.items=new u.TreeMap}return(0,a.default)(e,[{key:"store",value:function(e,t,n){var r=this.items.get(e);return r&&r.revision>n?r.isValid?r.value:null:(this.items.set(e,new c(t,n)),t)}},{key:"delete",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.items.get(e);(!r||r.revision<t||r&&!0===n)&&this.items.set(e,new l(t))}},{key:"isKnown",value:function(e,t){var n=this.items.get(e);return n&&n.revision>=t}},{key:"get",value:function(e){var t=this.items.get(e);return t&&t.isValid?t.value:null}},{key:"has",value:function(e){var t=this.items.get(e);return t&&t.isValid}},{key:"forEach",value:function(e){if(this.items){var t=!0,n=!1,s=void 0;try{for(var a,o=(0,r.default)(this.items);!(t=(a=o.next()).done);t=!0){var u=a.value,c=(0,i.default)(u,2),l=c[0],d=c[1];d.isValid&&e(l,d.value)}}catch(e){n=!0,s=e}finally{try{!t&&o.return&&o.return()}finally{if(n)throw s}}}}}]),e}();n.Cache=d,n.default=d},{"./utils/tree":338,"babel-runtime/core-js/get-iterator":30,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/slicedToArray":54}],315:[function(e,t,n){"use strict";var r=f(e("babel-runtime/core-js/promise")),i=f(e("babel-runtime/regenerator")),s=f(e("babel-runtime/helpers/asyncToGenerator")),a=f(e("babel-runtime/core-js/object/get-prototype-of")),o=f(e("babel-runtime/helpers/classCallCheck")),u=f(e("babel-runtime/helpers/createClass")),c=f(e("babel-runtime/helpers/possibleConstructorReturn")),l=f(e("babel-runtime/helpers/inherits")),d=f(e("babel-runtime/core-js/object/assign"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("events"),h=e("twilsock"),b=e("twilio-notifications"),m=e("./utils/uri"),v=e("./utils/syncerror"),y=e("./utils/sanitize"),g=e("./utils/logger"),_=e("./configuration"),k=e("./subscriptions"),w=e("./router"),x=e("./services/network"),C=e("./syncdocument"),j=e("./synclist"),S=e("./syncmap"),T=e("./clientInfo"),E=e("./entitiesCache"),M=e("./services/storage"),I=e("./streams/syncstream"),R=e("./livequery"),P=e("./livequery"),O="data_sync",L=e("../package.json").version;function N(e){if(e){if("string"==typeof e)return{id:e,mode:"open_or_create"};y.validateOptionalTtl(e.ttl),y.validateId(e.id),e.mode&&y.validateMode(e.mode);var t=e.mode||(e.id?"open_or_create":"create_new");return(0,d.default)((0,d.default)({},e),{mode:t})}return{mode:"create_new"}}var A=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,o.default)(this,t);var r=(0,c.default)(this,(t.__proto__||(0,a.default)(t)).call(this));if(!e)throw new Error("Sync library needs a valid Twilio token to be passed");n.hasOwnProperty("logLevel")?g.default.setLevel(n.logLevel):g.default.setLevel("silent");var i=n.productId=n.productId||O;n.clientMetadata=n.clientMetadata||{},n.clientMetadata.hasOwnProperty("type")||(n.clientMetadata.type="sync"),n.clientMetadata.hasOwnProperty("sdk")||(n.clientMetadata.sdk="JS",n.clientMetadata.sdkv=L);var s=n.twilsockClient=n.twilsockClient||new h.Twilsock(e,i,n);s.on("tokenAboutToExpire",function(e){return r.emit("tokenAboutToExpire",e)}),s.on("tokenExpired",function(){return r.emit("tokenExpired")}),s.on("connectionError",function(e){return r.emit("connectionError",e)});var u=n.notificationsClient=n.notificationsClient||new b.Notifications(e,n),l=new _.Configuration(n),d=new x.NetworkService(new T.ClientInfo(L),l,s),f=new M.SessionStorage(l);r.localStorageId=null,s.connect(),r.services={config:l,twilsock:s,notifications:u,network:d,storage:f,router:null,subscriptions:null};var p=new k.Subscriptions(r.services),m=new w.Router({config:l,subscriptions:p,notifications:u});return r.services.router=m,r.services.subscriptions=p,r.entities=new E.EntitiesCache,u.on("connectionStateChanged",function(){r.emit("connectionStateChanged",r.services.notifications.connectionState)}),r}return(0,l.default)(t,e),(0,u.default)(t,[{key:"ensureReady",value:function(){var e=(0,s.default)(i.default.mark(function e(){var t;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.services.config.sessionStorageEnabled){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.services.twilsock.storageId();case 5:t=e.sent,this.services.storage.updateStorageId(t.id),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),g.default.warn("Failed to initialize storage",e.t0);case 12:case"end":return e.stop()}},e,this,[[2,9]])}));return function(){return e.apply(this,arguments)}}()},{key:"storeRootInSessionCache",value:function(e,t,n){if(this.services.config.sessionStorageEnabled&&t){var r=y.deepClone(n);e!==j.SyncList.type&&e!==S.SyncMap.type||(r.last_event_id=null,delete r.items),this.services.storage.store(e,t,r)}}},{key:"readRootFromSessionCache",value:function(e,t){return this.services.config.sessionStorageEnabled&&t?this.services.storage.read(e,t):null}},{key:"_get",value:function(){var e=(0,s.default)(i.default.mark(function e(t,n){var r,s,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}throw new v.SyncError("Cannot get entity without id",404);case 2:return r=new m.UriBuilder(t).pathSegment(n).queryParam("Include",a?"items":void 0).build(),e.next=5,this.services.network.get(r);case 5:return s=e.sent,e.abrupt("return",s.body);case 7:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"_createDocument",value:function(e,t,n){var r={unique_name:e,data:t||{}};return void 0!==n&&(r.ttl=n),this.services.network.post(this.services.config.documentsUri,r).then(function(e){return e.body.data=r.data,e.body})}},{key:"_getDocument",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(C.SyncDocument.type,t)||this._get(this.services.config.documentsUri,t));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_createList",value:function(e,t,n,r){var i={unique_name:e,purpose:t,context:n};return void 0!==r&&(i.ttl=r),this.services.network.post(this.services.config.listsUri,i).then(function(e){return e.body})}},{key:"_getList",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(j.SyncList.type,t)||this._get(this.services.config.listsUri,t));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_createMap",value:function(e,t){var n={unique_name:e};return void 0!==t&&(n.ttl=t),this.services.network.post(this.services.config.mapsUri,n).then(function(e){return e.body})}},{key:"_getMap",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(S.SyncMap.type,t)||this._get(this.services.config.mapsUri,t,n));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_getStream",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.readRootFromSessionCache(I.SyncStream.type,t)||this._get(this.services.config.streamsUri,t,!1));case 1:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_createStream",value:function(){var e=(0,s.default)(i.default.mark(function e(t,n){var r,s;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r={unique_name:t},void 0!==n&&(r.ttl=n),e.next=4,this.services.network.post(this.services.config.streamsUri,r);case 4:return s=e.sent,e.abrupt("return",s.body);case 6:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"_getLiveQuery",value:function(e){return this.readRootFromSessionCache(R.LiveQuery.type,e)}},{key:"getCached",value:function(e,t){return e&&this.entities.get(e,t)||null}},{key:"removeFromCacheAndSession",value:function(e,t,n){this.entities.remove(t),this.services.config.sessionStorageEnabled&&this.services.storage.remove(e,t,n)}},{key:"document",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r,s,a,o=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if(n=N(t),r=void 0,"create_new"!==n.mode){e.next=10;break}return e.next=7,this._createDocument(n.id,n.data,n.ttl);case 7:r=e.sent,e.next=40;break;case 10:if(!(s=this.getCached(n.id,C.SyncDocument.type))){e.next=15;break}return e.abrupt("return",new C.SyncDocument(s));case 15:return e.prev=15,e.next=18,this._getDocument(n.id);case 18:r=e.sent,e.next=40;break;case 21:if(e.prev=21,e.t0=e.catch(15),404===e.t0.status&&"open_existing"!==n.mode){e.next=27;break}throw e.t0;case 27:return e.prev=27,e.next=30,this._createDocument(n.id,n.data,n.ttl);case 30:r=e.sent,e.next=40;break;case 33:if(e.prev=33,e.t1=e.catch(27),409!==e.t1.status){e.next=39;break}return e.abrupt("return",this.document(t));case 39:throw e.t1;case 40:return this.storeRootInSessionCache(C.SyncDocument.type,n.id,r),a=new C.SyncDocumentImpl(this.services,r,function(e,t,n){return o.removeFromCacheAndSession(e,t,n)}),a=this.entities.store(a),e.abrupt("return",new C.SyncDocument(a));case 44:case"end":return e.stop()}},e,this,[[15,21],[27,33]])}));return function(t){return e.apply(this,arguments)}}()},{key:"map",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r,s,a,o=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if(n=N(t),r=void 0,"create_new"!==n.mode){e.next=10;break}return e.next=7,this._createMap(n.id,n.ttl);case 7:r=e.sent,e.next=40;break;case 10:if(!(s=this.getCached(n.id,S.SyncMap.type))){e.next=15;break}return e.abrupt("return",new S.SyncMap(s));case 15:return e.prev=15,e.next=18,this._getMap(n.id,n.includeItems);case 18:r=e.sent,e.next=40;break;case 21:if(e.prev=21,e.t0=e.catch(15),404===e.t0.status&&"open_existing"!==n.mode){e.next=27;break}throw e.t0;case 27:return e.prev=27,e.next=30,this._createMap(n.id,n.ttl);case 30:r=e.sent,e.next=40;break;case 33:if(e.prev=33,e.t1=e.catch(27),409!==e.t1.status){e.next=39;break}return e.abrupt("return",this.map(t));case 39:throw e.t1;case 40:return this.storeRootInSessionCache(S.SyncMap.type,n.id,r),a=new S.SyncMapImpl(this.services,r,function(e,t,n){return o.removeFromCacheAndSession(e,t,n)}),a=this.entities.store(a),e.abrupt("return",new S.SyncMap(a));case 44:case"end":return e.stop()}},e,this,[[15,21],[27,33]])}));return function(t){return e.apply(this,arguments)}}()},{key:"list",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r,s,a,o=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if(n=N(t),r=void 0,"create_new"!==n.mode){e.next=10;break}return e.next=7,this._createList(n.id,n.purpose,n.context,n.ttl);case 7:r=e.sent,e.next=40;break;case 10:if(!(s=this.getCached(n.id,j.SyncList.type))){e.next=15;break}return e.abrupt("return",new j.SyncList(s));case 15:return e.prev=15,e.next=18,this._getList(n.id);case 18:r=e.sent,e.next=40;break;case 21:if(e.prev=21,e.t0=e.catch(15),404===e.t0.status&&"open_existing"!==n.mode){e.next=27;break}throw e.t0;case 27:return e.prev=27,e.next=30,this._createList(n.id,n.purpose,n.context,n.ttl);case 30:r=e.sent,e.next=40;break;case 33:if(e.prev=33,e.t1=e.catch(27),409!==e.t1.status){e.next=39;break}return e.abrupt("return",this.list(t));case 39:throw e.t1;case 40:return this.storeRootInSessionCache(j.SyncList.type,n.id,r),a=new j.SyncListImpl(this.services,r,function(e,t,n){return o.removeFromCacheAndSession(e,t,n)}),a=this.entities.store(a),e.abrupt("return",new j.SyncList(a));case 44:case"end":return e.stop()}},e,this,[[15,21],[27,33]])}));return function(t){return e.apply(this,arguments)}}()},{key:"stream",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r,s,a,o,u=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if(n=N(t),r=void 0,"create_new"!==n.mode){e.next=10;break}return e.next=7,this._createStream(n.id,n.ttl);case 7:r=e.sent,e.next=40;break;case 10:if(!(s=this.getCached(n.id,I.SyncStream.type))){e.next=15;break}return e.abrupt("return",new I.SyncStream(s));case 15:return e.prev=15,e.next=18,this._getStream(n.id);case 18:r=e.sent,e.next=40;break;case 21:if(e.prev=21,e.t0=e.catch(15),404===e.t0.status&&"open_existing"!==n.mode){e.next=27;break}throw e.t0;case 27:return e.prev=27,e.next=30,this._createStream(n.id,n.ttl);case 30:r=e.sent,e.next=40;break;case 33:if(e.prev=33,e.t1=e.catch(27),409!==e.t1.status){e.next=39;break}return e.abrupt("return",this.stream(t));case 39:throw e.t1;case 40:return this.storeRootInSessionCache(I.SyncStream.type,n.id,r),a=function(e,t,n){return u.removeFromCacheAndSession(e,t,n)},o=new I.SyncStreamImpl(this.services,r,a),o=this.entities.store(o),e.abrupt("return",new I.SyncStream(o));case 45:case"end":return e.stop()}},e,this,[[15,21],[27,33]])}));return function(t){return e.apply(this,arguments)}}()},{key:"shutdown",value:function(){var e=(0,s.default)(i.default.mark(function e(){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.subscriptions.shutdown();case 2:return e.next=4,this.services.twilsock.disconnect();case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"updateToken",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",r.default.reject(new Error("A valid Twilio token should be provided")));case 2:return e.abrupt("return",this.services.twilsock.updateToken(t).catch(function(e){var t,n=null===(t=null==e?void 0:e.reply)||void 0===t?void 0:t.status;if(401===(null==n?void 0:n.code)&&"UNAUTHORIZED"===(null==n?void 0:n.status))throw new v.SyncError("Updated token was rejected by server",400,51130);throw e}));case 3:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"liveQuery",value:function(){var e=(0,s.default)(i.default.mark(function e(t,n){var r,s,a,o,u,c=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:if(t&&"string"==typeof t){e.next=4;break}throw new Error("Index name must contain a non-empty string value");case 4:return r=new m.UriBuilder(this.services.config.insightsUri).pathSegment(t).pathSegment("Items").build(),e.next=7,P.queryItems({network:this.services.network,uri:r,queryString:n,type:R.LiveQuery.type});case 7:return s=e.sent,(a=this.getCached(s.query_id,R.LiveQuery.type))||((o=this._getLiveQuery(s.query_id))||(o={indexName:t,queryExpression:n,sid:s.query_id,queryUri:r,last_event_id:s.last_event_id}),u=function(e,t,n){return c.removeFromCacheAndSession(e,t,n)},a=new R.LiveQueryImpl(o,this.services,u,s.items)),this.storeRootInSessionCache(R.LiveQuery.type,s.query_id,a.liveQueryDescriptor),a=this.entities.store(a),e.abrupt("return",new R.LiveQuery(a));case 13:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"instantQuery",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r,s=this;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.ensureReady();case 2:return n=function(e,t){return s.liveQuery(e,t)},r=new R.InstantQuery({indexName:t,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:n}),e.abrupt("return",r);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"connectionState",get:function(){return this.services.notifications.connectionState}}],[{key:"version",get:function(){return L}}]),t}(p.EventEmitter);n.Client=A,n.SyncClient=A,n.default=A},{"../package.json":340,"./clientInfo":316,"./configuration":318,"./entitiesCache":319,"./livequery":323,"./router":327,"./services/network":328,"./services/storage":329,"./streams/syncstream":330,"./subscriptions":331,"./syncdocument":332,"./synclist":333,"./syncmap":334,"./utils/logger":335,"./utils/sanitize":336,"./utils/syncerror":337,"./utils/uri":339,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200,"twilio-notifications":308,twilsock:349}],316:[function(e,t,n){"use strict";var r,i=e("babel-runtime/helpers/classCallCheck"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});var a=e("platform"),o=function e(t){(0,s.default)(this,e),this.sdk="js",this.sdkVer=t,this.os=a.os.family,this.osVer=a.os.version,this.pl=a.name,this.plVer=a.version};n.ClientInfo=o,n.default=o},{"babel-runtime/helpers/classCallCheck":49,platform:207}],317:[function(e,t,n){"use strict";var r=u(e("babel-runtime/core-js/object/get-prototype-of")),i=u(e("babel-runtime/helpers/classCallCheck")),s=u(e("babel-runtime/helpers/createClass")),a=u(e("babel-runtime/helpers/possibleConstructorReturn")),o=u(e("babel-runtime/helpers/inherits"));function u(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var c=e("events"),l=e("uuid"),d=function(e){function t(){(0,i.default)(this,t);var e=(0,a.default)(this,(t.__proto__||(0,r.default)(t)).call(this));return e.closed=!1,e.uuid=l(),e}return(0,o.default)(t,e),(0,s.default)(t,[{key:"close",value:function(){this.removeAllListeners(),this.closed=!0}},{key:"ensureNotClosed",value:function(){if(this.closed)throw new Error("Invalid operation on closed object")}},{key:"listenerUuid",get:function(){return this.uuid}}]),t}(c.EventEmitter);n.Closeable=d,n.default=d},{"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,events:200,uuid:370}],318:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a="/v4/Subscriptions",o="/v3/Maps",u="/v3/Lists",c="/v3/Documents",l="/v3/Streams",d="/v3/Insights";var f=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,r.default)(this,e);var n,i,s,f="https://cds."+(t.region||"us1")+".twilio.com",p=t.cdsUri||f;this.settings={subscriptionsUri:p+a,documentsUri:p+c,listsUri:p+u,mapsUri:p+o,streamsUri:p+l,insightsUri:p+d,sessionStorageEnabled:(n=t.Sync,i="enableSessionStorage",s=!0,n&&void 0!==n[i]?n[i]:s),productId:t.productId}}return(0,i.default)(e,[{key:"subscriptionsUri",get:function(){return this.settings.subscriptionsUri}},{key:"documentsUri",get:function(){return this.settings.documentsUri}},{key:"listsUri",get:function(){return this.settings.listsUri}},{key:"mapsUri",get:function(){return this.settings.mapsUri}},{key:"streamsUri",get:function(){return this.settings.streamsUri}},{key:"insightsUri",get:function(){return this.settings.insightsUri}},{key:"backoffConfig",get:function(){return this.settings.backoffConfig||{}}},{key:"sessionStorageEnabled",get:function(){return this.settings.sessionStorageEnabled}},{key:"productId",get:function(){return this.settings.productId}}]),e}();n.Configuration=f},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],319:[function(e,t,n){"use strict";var r=a(e("babel-runtime/core-js/map")),i=a(e("babel-runtime/helpers/classCallCheck")),s=a(e("babel-runtime/helpers/createClass"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(){(0,i.default)(this,e),this.names=new r.default,this.entities=new r.default}return(0,s.default)(e,[{key:"store",value:function(e){var t=this.entities.get(e.sid);return t||(this.entities.set(e.sid,e),e.uniqueName&&this.names.set(e.type+"::"+e.uniqueName,e.sid),e)}},{key:"getResolved",value:function(e,t){var n=this.names.get(t+"::"+e);return n?this.entities.get(n):null}},{key:"get",value:function(e,t){return this.entities.get(e)||this.getResolved(e,t)||null}},{key:"remove",value:function(e){var t=this.entities.get(e);t&&(this.entities.delete(e),t.uniqueName&&this.names.delete(t.type+"::"+t.uniqueName))}}]),e}();n.EntitiesCache=o},{"babel-runtime/core-js/map":33,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],320:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/get-iterator")),i=o(e("babel-runtime/core-js/map")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(t,n){(0,s.default)(this,e),this.services=t,this.removalHandler=n,this.subscriptionState="none",this._attachedListeners=new i.default}return(0,a.default)(e,[{key:"_advanceLastEventId",value:function(e,t){}},{key:"reportFailure",value:function(e){404===e.status?this.onRemoved(!1):this.broadcastEventToListeners("failure",e)}},{key:"_subscribe",value:function(){this.services.router.subscribe(this.sid,this)}},{key:"_unsubscribe",value:function(){this.services.router.unsubscribe(this.sid)}},{key:"_setSubscriptionState",value:function(e){this.subscriptionState=e,this.broadcastEventToListeners("_subscriptionStateChanged",e)}},{key:"close",value:function(){this._unsubscribe(),null!=this.removalHandler&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(e){var t=e.listenerUuid;this._attachedListeners.get(t)||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(t,e))}},{key:"detach",value:function(e){this._attachedListeners.delete(e),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(e,t){var n=!0,i=!1,s=void 0;try{for(var a,o=(0,r.default)(this._attachedListeners.values());!(n=(a=o.next()).done);n=!0){a.value.emit(e,t)}}catch(e){i=!0,s=e}finally{try{!n&&o.return&&o.return()}finally{if(i)throw s}}}}]),e}();n.SyncEntity=u,n.default=u},{"babel-runtime/core-js/get-iterator":30,"babel-runtime/core-js/map":33,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],321:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./client");n.SyncClient=r.SyncClient;var i=e("./syncdocument");n.SyncDocument=i.SyncDocument;var s=e("./synclist");n.SyncList=s.SyncList;var a=e("./listitem");n.SyncListItem=a.ListItem;var o=e("./syncmap");n.SyncMap=o.SyncMap;var u=e("./mapitem");n.SyncMapItem=u.MapItem,n.default=r.SyncClient,t.exports=r.SyncClient,t.exports.SyncClient=r.SyncClient},{"./client":315,"./listitem":322,"./mapitem":324,"./syncdocument":332,"./synclist":333,"./syncmap":334}],322:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(t){(0,r.default)(this,e),this.descriptor=t}return(0,i.default)(e,[{key:"update",value:function(e,t,n,r){return this.descriptor.lastEventId=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.dateUpdated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.dateExpires=e}},{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}}]),e}();n.ListItem=a,n.default=a},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],323:[function(e,t,n){"use strict";var r,i=b(e("babel-runtime/core-js/promise")),s=b(e("babel-runtime/core-js/object/assign")),a=b(e("babel-runtime/helpers/get")),o=b(e("babel-runtime/regenerator")),u=b(e("babel-runtime/helpers/asyncToGenerator")),c=b(e("babel-runtime/core-js/object/get-prototype-of")),l=b(e("babel-runtime/helpers/createClass")),d=b(e("babel-runtime/helpers/possibleConstructorReturn")),f=b(e("babel-runtime/helpers/inherits")),p=b(e("babel-runtime/helpers/classCallCheck")),h=(r=(0,u.default)(o.default.mark(function e(t){var n,r,i,s,a,u;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.network,r=t.queryString,i=t.uri,s=t.type,null!=r){e.next=3;break}throw new v.SyncError("Invalid query",400,54507);case 3:return a={query_string:r},s===C.type&&(a.type=s),e.next=7,n.post(i,a,void 0,!0);case 7:return u=e.sent,e.abrupt("return",u.body);case 9:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)});function b(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var m=e("./utils/uri"),v=e("./utils/syncerror"),y=e("./utils/logger"),g=e("events"),_=e("./entity"),k=e("./closeable"),w=e("./cache");n.InsightsItem=function e(){(0,p.default)(this,e)};var x=function(e){function t(e,n,r,i){(0,p.default)(this,t);var s=(0,d.default)(this,(t.__proto__||(0,c.default)(t)).call(this,n,r));return s.descriptor=e,s.cache=new w.Cache,i&&i.forEach(function(e){s.cache.store(e.key,{key:e.key,value:e.data},e.revision)}),s}return(0,f.default)(t,e),(0,l.default)(t,[{key:"onRemoved",value:function(){}},{key:"getItems",value:function(){var e={};return this.cache.forEach(function(t,n){e[t]=n.value}),e}},{key:"_update",value:function(e,t){switch(e.type){case"live_query_item_updated":this.handleItemMutated(e.item_key,e.item_data,e.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(e.item_key,e.item_revision);break;case"live_query_updated":this.handleBatchUpdate(e.items)}t&&this._advanceLastEventId(e.last_event_id)}},{key:"handleItemMutated",value:function(e,t,n){if(this.shouldIgnoreEvent(e,n))y.default.trace("Item "+e+" update skipped, revision: "+n);else{var r={key:e,value:t};this.cache.store(e,r,n),this.broadcastEventToListeners("itemUpdated",r)}}},{key:"handleItemRemoved",value:function(e,t){var n=null===t;this.shouldIgnoreEvent(e,t)?y.default.trace("Item "+e+" delete skipped, revision: "+t):(this.cache.delete(e,t,n),this.broadcastEventToListeners("itemRemoved",{key:e}))}},{key:"handleBatchUpdate",value:function(e){var t=this,n={};for(var r in null!=e&&e.forEach(function(e){n[e.key]={data:e.data,revision:e.revision}}),this.cache.forEach(function(e,r){var i=n[e];null!=i?t.handleItemMutated(e,i.data,i.revision):t.handleItemRemoved(e,null),delete n[e]}),n)this.handleItemMutated(r,n[r].data,n[r].revision)}},{key:"shouldIgnoreEvent",value:function(e,t){return null!=e&&null!=t&&this.cache.isKnown(e,t)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e)}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return t.type}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"indexName",get:function(){return this.descriptor.indexName}},{key:"queryString",get:function(){return this.descriptor.queryExpression}},{key:"queryUri",get:function(){return this.descriptor.queryUri}},{key:"liveQueryDescriptor",get:function(){return this.descriptor}}],[{key:"type",get:function(){return"live_query"}}]),t}(_.SyncEntity);n.LiveQueryImpl=x,n.queryItems=h;var C=function(e){function t(e){(0,p.default)(this,t);var n=(0,d.default)(this,(t.__proto__||(0,c.default)(t)).call(this));return n.liveQueryImpl=e,n.liveQueryImpl.attach(n),n}return(0,f.default)(t,e),(0,l.default)(t,[{key:"close",value:function(){(0,a.default)(t.prototype.__proto__||(0,c.default)(t.prototype),"close",this).call(this),this.liveQueryImpl.detach(this.listenerUuid)}},{key:"getItems",value:function(){return this.ensureNotClosed(),this.liveQueryImpl.getItems()}},{key:"type",get:function(){return x.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}}],[{key:"type",get:function(){return x.type}}]),t}(k.Closeable);n.LiveQuery=C;var j=function(e){function t(e){(0,p.default)(this,t);var n=(0,d.default)(this,(t.__proto__||(0,c.default)(t)).call(this));return n.queryExpression=null,n.items={},(0,s.default)(n,e),n.updateIndexName(e.indexName),n}return(0,f.default)(t,e),(0,l.default)(t,[{key:"search",value:function(){var e=(0,u.default)(o.default.mark(function e(t){var n=this;return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.items={},e.abrupt("return",h({network:this.network,uri:this.queryUri,queryString:t}).then(function(e){n.queryExpression=t,e.items&&e.items.forEach(function(e){n.items[e.key]=e.data}),n.emit("searchResult",n.getItems())}).catch(function(e){throw y.default.error("Error '"+e.message+"' while executing query '"+t+"'"),n.queryExpression=null,e}));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"subscribe",value:function(){var e=(0,u.default)(o.default.mark(function e(){return o.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=this.queryExpression){e.next=2;break}return e.abrupt("return",i.default.reject(new v.SyncError("Invalid query",400,54507)));case 2:return e.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(e){if(!e||"string"!=typeof e)throw new Error("Index name must contain a non-empty string value");this.indexName=e,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(e){return new m.UriBuilder(this.insightsUri).pathSegment(e).pathSegment("Items").build()}},{key:"type",get:function(){return t.type}}],[{key:"type",get:function(){return"instant_query"}}]),t}(g.EventEmitter);n.InstantQuery=j,n.default=C},{"./cache":314,"./closeable":317,"./entity":320,"./utils/logger":335,"./utils/syncerror":337,"./utils/uri":339,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/get":51,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200}],324:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(t){(0,r.default)(this,e),this.descriptor=t}return(0,i.default)(e,[{key:"update",value:function(e,t,n,r){return this.descriptor.last_event_id=e,this.descriptor.revision=t,this.descriptor.data=n,this.descriptor.date_updated=r,this}},{key:"updateDateExpires",value:function(e){this.descriptor.date_expires=e}},{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"key",get:function(){return this.descriptor.key}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}}]),e}();n.MapItem=a},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],325:[function(e,t,n){"use strict";var r=c(e("babel-runtime/regenerator")),i=c(e("babel-runtime/helpers/asyncToGenerator")),s=c(e("babel-runtime/core-js/map")),a=c(e("babel-runtime/core-js/promise")),o=c(e("babel-runtime/helpers/classCallCheck")),u=c(e("babel-runtime/helpers/createClass"));function c(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var l=function(){function e(t){(0,o.default)(this,e),this.queuedRequests=[],this.isRequestInFlight=!1,this.inputMergingFunction=t}return(0,u.default)(e,[{key:"add",value:function(e,t){var n=this,r=new a.default(function(r,i){return n.queuedRequests.push({input:e,requestFunction:t,resolve:r,reject:i})});return this.wakeupQueue(),r}},{key:"squashAndAdd",value:function(e,t){var n=this.queuedRequests;this.queuedRequests=[];var r=void 0;n.length>0?(r=n.map(function(e){return e.input}).reduce(this.inputMergingFunction),r=this.inputMergingFunction(r,e)):r=e;var i=this.add(r,t);return n.forEach(function(e){return i.then(e.resolve,e.reject)}),i}},{key:"isEmpty",value:function(){return 0===this.queuedRequests.length&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var e=this;if(0!==this.queuedRequests.length&&!this.isRequestInFlight){var t=this.queuedRequests.shift();this.isRequestInFlight=!0,t.requestFunction(t.input).then(t.resolve,t.reject).then(function(t){e.isRequestInFlight=!1,e.wakeupQueue()})}}}]),e}();n.MergingQueue=l;var d=function(){function e(t){(0,o.default)(this,e),this.queueByNamespaceKey=new s.default,this.inputReducer=t}return(0,u.default)(e,[{key:"add",value:function(){var e=(0,i.default)(r.default.mark(function e(t,n,i){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,function(e){return e.add(n,i)}));case 1:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"squashAndAdd",value:function(){var e=(0,i.default)(r.default.mark(function e(t,n,i){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.invokeQueueMethod(t,function(e){return e.squashAndAdd(n,i)}));case 1:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"invokeQueueMethod",value:function(){var e=(0,i.default)(r.default.mark(function e(t,n){var i,s;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.queueByNamespaceKey.has(t)||this.queueByNamespaceKey.set(t,new l(this.inputReducer)),i=this.queueByNamespaceKey.get(t),s=n(i),this.queueByNamespaceKey.get(t).isEmpty()&&this.queueByNamespaceKey.delete(t),e.abrupt("return",s);case 5:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()}]),e}();n.NamespacedMergingQueue=d},{"babel-runtime/core-js/map":33,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57}],326:[function(e,t,n){"use strict";var r=o(e("babel-runtime/regenerator")),i=o(e("babel-runtime/helpers/asyncToGenerator")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(t,n,r,i){(0,s.default)(this,e),this.prevToken=r,this.nextToken=i,this.items=t,this.source=n}return(0,a.default)(e,[{key:"nextPage",value:function(){var e=(0,i.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasNextPage){e.next=2;break}throw new Error("No next page");case 2:return e.abrupt("return",this.source(this.nextToken));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"prevPage",value:function(){var e=(0,i.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hasPrevPage){e.next=2;break}throw new Error("No previous page");case 2:return e.abrupt("return",this.source(this.prevToken));case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}}]),e}();n.Paginator=u},{"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57}],327:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=e("./utils/logger"),o="com.twilio.rtd.cds.document",u="com.twilio.rtd.cds.list",c="com.twilio.rtd.cds.map",l="twilio.sync.event",d=function(){function e(t){var n=this;(0,r.default)(this,e),this.config=t.config,this.subscriptions=t.subscriptions,this.notifications=t.notifications,this.notifications.subscribe(l),this.notifications.subscribe(o),this.notifications.subscribe(u),this.notifications.subscribe(c),this.notifications.on("message",function(e,t){return n.onMessage(e,t)}),this.notifications.on("transportReady",function(e){return n.onConnectionStateChanged(e)})}return(0,i.default)(e,[{key:"onMessage",value:function(e,t){switch(a.default.trace("Notification type:",e,"content:",t),e){case o:case u:case c:this.subscriptions.acceptMessage(t,!1);break;case l:this.subscriptions.acceptMessage(t,!0)}}},{key:"subscribe",value:function(e,t){this.subscriptions.add(e,t)}},{key:"unsubscribe",value:function(e){this.subscriptions.remove(e)}},{key:"onConnectionStateChanged",value:function(e){this.subscriptions.onConnectionStateChanged(e)}}]),e}();n.Router=d,n.default=d},{"./utils/logger":335,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],328:[function(e,t,n){"use strict";var r=u(e("babel-runtime/core-js/promise")),i=u(e("babel-runtime/core-js/object/assign")),s=u(e("babel-runtime/core-js/json/stringify")),a=u(e("babel-runtime/helpers/classCallCheck")),o=u(e("babel-runtime/helpers/createClass"));function u(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var c=e("uuid"),l=e("../utils/syncerror"),d=e("../utils/logger"),f=e("operation-retrier"),p=e("twilsock");function h(e){if(e.body&&e.body.message)return e.body.message;switch(e.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function b(e){return e.body?e.body.code:0}function m(e){return 409===e.status?new l.SyncNetworkError(h(e),e.status,b(e),e.body):e.status?new l.SyncError(h(e),e.status,b(e)):e instanceof p.TransportUnavailableError?e:new l.SyncError(e.message,0,0)}var v=function(){function e(t,n,r){(0,a.default)(this,e),this.clientInfo=t,this.config=n,this.transport=r}return(0,o.default)(e,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":(0,s.default)(this.clientInfo),"Twilio-Request-Id":"RQ"+c.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return(0,i.default)({min:4e3,max:6e4,maxAttemptsTime:9e4,randomness:.2},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new r.default(function(r,i){var s=[502,503,504];n&&s.push(429);var a=new f.Retrier(t.backoffConfig());a.on("attempt",function(){e().then(function(e){return a.succeeded(e)}).catch(function(e){if(s.includes(e.status)){var t=parseInt(e.headers?e.headers["Retry-After"]:null);a.failed(m(e),isNaN(t)?null:1e3*t)}else"Twilsock disconnected"===e.message?a.failed(m(e)):(a.removeAllListeners(),a.cancel(),i(m(e)))})}),a.on("succeeded",function(e){r(e)}),a.on("cancelled",function(e){return i(m(e))}),a.on("failed",function(e){return i(m(e))}),a.start()})}},{key:"get",value:function(e){var t=this,n=this.createHeaders();return d.default.debug("GET",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry(function(){return t.transport.get(e,n,t.config.productId)},!0)}},{key:"post",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=this.createHeaders();return null!=n&&(s["If-Match"]=n),d.default.debug("POST",e,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return r.transport.post(e,s,t,r.config.productId)},i)}},{key:"put",value:function(e,t,n){var r=this,i=this.createHeaders();return null!=n&&(i["If-Match"]=n),d.default.debug("PUT",e,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return r.transport.put(e,i,t,r.config.productId)},!1)}},{key:"delete",value:function(e){var t=this,n=this.createHeaders();return d.default.debug("DELETE",e,"ID:",n["Twilio-Request-Id"]),this.executeWithRetry(function(){return t.transport.delete(e,n,t.config.productId)},!1)}}]),e}();n.NetworkService=v},{"../utils/logger":335,"../utils/syncerror":337,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"operation-retrier":205,twilsock:349,uuid:370}],329:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/assign")),i=o(e("babel-runtime/core-js/json/stringify")),s=o(e("babel-runtime/helpers/classCallCheck")),a=o(e("babel-runtime/helpers/createClass"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(t,n){(0,s.default)(this,e),this.config=t,this.storageId=null;try{this.storage=n||sessionStorage}catch(e){}}return(0,a.default)(e,[{key:"storageKey",value:function(e,t){return this.storageId+"::"+e+"::"+t}},{key:"updateStorageId",value:function(e){this.storageId=e}},{key:"store",value:function(e,t,n){return this.isReady?this._store(this.storageKey(e,t),n):null}},{key:"read",value:function(e,t){return this.isReady?this._read(this.storageKey(e,t)):null}},{key:"remove",value:function(e,t,n){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(e,t)),n&&this.storage.removeItem(this.storageKey(e,n))}catch(e){}}},{key:"update",value:function(e,t,n,r){if(!this.isReady)return null;this._apply(this.storageKey(e,t),r),n&&this._apply(this.storageKey(e,n),r)}},{key:"_store",value:function(e,t){try{this.storage.setItem(e,(0,i.default)(t))}catch(e){}}},{key:"_read",value:function(e){try{var t=this.storage.getItem(e);if(t)return JSON.parse(t)}catch(e){}return null}},{key:"_apply",value:function(e,t){var n=this._read(e);if(!n)return!1;this._store(e,(0,r.default)(n,t))}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}}]),e}();n.SessionStorage=u},{"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/object/assign":35,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],330:[function(e,t,n){"use strict";var r=d(e("babel-runtime/helpers/get")),i=d(e("babel-runtime/regenerator")),s=d(e("babel-runtime/helpers/asyncToGenerator")),a=d(e("babel-runtime/core-js/object/get-prototype-of")),o=d(e("babel-runtime/helpers/classCallCheck")),u=d(e("babel-runtime/helpers/createClass")),c=d(e("babel-runtime/helpers/possibleConstructorReturn")),l=d(e("babel-runtime/helpers/inherits"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var f=e("../entity"),p=e("../utils/sanitize"),h=e("../closeable"),b=function(e){function t(e,n,r){(0,o.default)(this,t);var i=(0,c.default)(this,(t.__proto__||(0,a.default)(t)).call(this,e,r));return i.descriptor=n,i}return(0,l.default)(t,e),(0,u.default)(t,[{key:"publishMessage",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r,s,a;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n={data:t},e.next=3,this.services.network.post(this.links.messages,n);case 3:return r=e.sent,s=r.body,a=this._handleMessagePublished(s.sid,t,!1),e.abrupt("return",a);case 7:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setTtl",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n,r;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.validateMandatoryTtl(t),e.prev=1,n={ttl:t},e.next=5,this.services.network.post(this.uri,n);case 5:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),404===e.t0.status&&this.onRemoved(!1),e.t0;case 13:case"end":return e.stop()}},e,this,[[1,9]])}));return function(t){return e.apply(this,arguments)}}()},{key:"removeStream",value:function(){var e=(0,s.default)(i.default.mark(function e(){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"_update",value:function(e){switch(e.type){case"stream_message_published":this._handleMessagePublished(e.message_sid,e.message_data,!0);break;case"stream_removed":this.onRemoved(!1)}}},{key:"_handleMessagePublished",value:function(e,t,n){var r={sid:e,value:t};return this.broadcastEventToListeners("messagePublished",{message:r,isLocal:!n}),r}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"stream"}},{key:"lastEventId",get:function(){return null}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}}],[{key:"type",get:function(){return"stream"}}]),t}(f.SyncEntity);n.SyncStreamImpl=b;var m=function(e){function t(e){(0,o.default)(this,t);var n=(0,c.default)(this,(t.__proto__||(0,a.default)(t)).call(this));return n.syncStreamImpl=e,n.syncStreamImpl.attach(n),n}return(0,l.default)(t,e),(0,u.default)(t,[{key:"publishMessage",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.publishMessage(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setTtl",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.setTtl(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"removeStream",value:function(){var e=(0,s.default)(i.default.mark(function e(){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"close",value:function(){(0,r.default)(t.prototype.__proto__||(0,a.default)(t.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}},{key:"uri",get:function(){return this.syncStreamImpl.uri}},{key:"links",get:function(){return this.syncStreamImpl.links}},{key:"dateExpires",get:function(){return this.syncStreamImpl.dateExpires}},{key:"type",get:function(){return b.type}},{key:"lastEventId",get:function(){return null}},{key:"sid",get:function(){return this.syncStreamImpl.sid}},{key:"uniqueName",get:function(){return this.syncStreamImpl.uniqueName}}],[{key:"type",get:function(){return b.type}}]),t}(h.default);n.SyncStream=m,n.default=m},{"../closeable":317,"../entity":320,"../utils/sanitize":336,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/get":51,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57}],331:[function(e,t,n){"use strict";var r=d(e("babel-runtime/regenerator")),i=d(e("babel-runtime/helpers/asyncToGenerator")),s=d(e("babel-runtime/core-js/get-iterator")),a=d(e("babel-runtime/helpers/slicedToArray")),o=d(e("babel-runtime/core-js/object/assign")),u=d(e("babel-runtime/core-js/map")),c=d(e("babel-runtime/helpers/classCallCheck")),l=d(e("babel-runtime/helpers/createClass"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var f=e("operation-retrier"),p=e("./utils/syncerror"),h=e("./utils/logger"),b=e("twilsock"),m=function(){function e(t){(0,c.default)(this,e),this.localObject=t,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return(0,l.default)(e,[{key:"update",value:function(e,t){this.localObject._update(e,t)}},{key:"updatePending",value:function(e,t){this.pendingAction=e,this.pendingCorrelationId=t}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(e){this.rejectedWithError=e.error,this.updatePending(null,null),this.localObject.reportFailure(new p.SyncError("Failed to subscribe on service events: "+e.error.message,e.error.status,e.error.code))}},{key:"complete",value:function(e){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(e)}},{key:"setSubscriptionState",value:function(e){this.localObject._setSubscriptionState(e)}},{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}}]),e}(),v=function(){function e(t){var n=this;(0,c.default)(this,e),this.isConnected=!1,this.maxBatchSize=100,this.subscriptionTtlTimer=null,this.pendingPokeReason=null,this.services=t,this.subscriptions=new u.default,this.persisted=new u.default,this.latestPokeResponseArrivalTimestampByCorrelationId=new u.default;this.backoff=f.Backoff.exponential((0,o.default)({randomisationFactor:.2,initialDelay:100,maxDelay:12e4},this.services.config.backoffConfig)),this.backoff.on("ready",function(){var e=n.getSubscriptionUpdateBatch(),t=e.action,r=e.subscriptions;t?n.applyNewSubscriptionUpdateBatch(t,r):(n.backoff.reset(),h.default.debug("All subscriptions resolved."))})}return(0,l.default)(e,[{key:"getSubscriptionUpdateBatch",value:function(){function e(e,t,n,r){var i=[],o=!0,u=!1,c=void 0;try{for(var l,d=(0,s.default)(e);!(o=(l=d.next()).done);o=!0){var f=l.value,p=(0,a.default)(f,2),h=p[0],b=p[1];if(!t.get(h)&&n!==b.pendingAction&&!b.rejectedWithError&&(i.push(b),r&&i.length>=r))break}}catch(e){u=!0,c=e}finally{try{!o&&d.return&&d.return()}finally{if(u)throw c}}return i}var t=e(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(t.length>0)return{action:"establish",subscriptions:t};var n=e(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return n.length>0?{action:"cancel",subscriptions:n}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:function(){var e=(0,i.default)(r.default.mark(function e(t,n){var i,a,o,u,c,l,d,f,p,m,v,y,g,_,k,w,x,C,j,S,T=this;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isConnected){e.next=4;break}return h.default.debug("Twilsock connection (required for subscription) not ready; waiting\u2026"),this.backoff.reset(),e.abrupt("return");case 4:for(n=this.processLocalActions(t,n),i=(new Date).getTime(),a=!0,o=!1,u=void 0,e.prev=9,c=(0,s.default)(n);!(a=(l=c.next()).done);a=!0)d=l.value,this.recordActionAttemptOn(d,t,i);e.next=17;break;case 13:e.prev=13,e.t0=e.catch(9),o=!0,u=e.t0;case 17:e.prev=17,e.prev=18,!a&&c.return&&c.return();case 20:if(e.prev=20,!o){e.next=23;break}throw u;case 23:return e.finish(20);case 24:return e.finish(17);case 25:return f=this.pendingPokeReason,this.pendingPokeReason=null,e.prev=27,e.next=30,this.request(t,i,f,n);case 30:p=e.sent,m=p.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(v=p.body.ttl_in_s,y=!isNaN(parseFloat(v))&&isFinite(v),y&&v>0&&(this.subscriptionTtlTimer=setTimeout(function(){return T.onSubscriptionTtlElapsed()},1e3*v))),"establish"===t&&(g=p.body.estimated_delivery_in_ms,_=!isNaN(parseFloat(g))&&isFinite(g),_&&g>0?setTimeout(function(){return T.verifyPokeDelivery(i,g,n)},g):h.default.error("Invalid timeout: "+g),n.filter(function(e){return e.pendingCorrelationId===i}).forEach(function(e){return e.setSubscriptionState("response_in_flight")})),this.backoff.reset(),e.next=60;break;case 38:for(e.prev=38,e.t1=e.catch(27),k=!0,w=!1,x=void 0,e.prev=43,C=(0,s.default)(n);!(k=(j=C.next()).done);k=!0)S=j.value,this.recordActionFailureOn(S,t);e.next=51;break;case 47:e.prev=47,e.t2=e.catch(43),w=!0,x=e.t2;case 51:e.prev=51,e.prev=52,!k&&C.return&&C.return();case 54:if(e.prev=54,!w){e.next=57;break}throw x;case 57:return e.finish(54);case 58:return e.finish(51);case 59:e.t1 instanceof b.TransportUnavailableError?(h.default.debug("Twilsock connection (required for subscription) not ready (c:"+i+"); waiting\u2026"),this.backoff.reset()):(h.default.debug("Failed an attempt to "+t+" subscriptions (c:"+i+"); retrying",e.t1),this.persist());case 60:case"end":return e.stop()}},e,this,[[9,13,17,25],[18,,20,24],[27,38],[43,47,51,59],[52,,54,58]])}));return function(t,n){return e.apply(this,arguments)}}()},{key:"verifyPokeDelivery",value:function(e,t,n){var r=this,i=this.latestPokeResponseArrivalTimestampByCorrelationId.get(e),s=i?(new Date).getTime()-i:t;s>=t?(n.filter(function(t){return t.pendingCorrelationId===e}).forEach(function(e){e.updatePending(null,null),e.retryCount++,r.persisted.delete(e.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(e)):setTimeout(function(){return r.verifyPokeDelivery(e,t,n)},t-s)}},{key:"processLocalActions",value:function(e,t){return"cancel"===e?t.filter(function(e){return!e.rejectedWithError}):t}},{key:"recordActionAttemptOn",value:function(e,t,n){if(e.setSubscriptionState("request_in_flight"),"establish"===t)this.persisted.set(e.sid,e),e.updatePending(t,n);else{var r=this.persisted.get(e.sid);r&&r.updatePending(t,n)}}},{key:"recordActionFailureOn",value:function(e,t){e.setSubscriptionState("none"),e.updatePending(null,null),"establish"===t&&this.persisted.delete(e.sid)}},{key:"request",value:function(e,t,n,r){var i=r.map(function(t){return{object_sid:t.sid,object_type:t.type,last_event_id:"establish"===e?t.lastEventId:void 0,index_name:"establish"===e?t.indexName:void 0,query_string:"establish"===e?t.queryString:void 0}}),s=r.filter(function(e){return e.retryCount>0}).length;h.default.debug("Attempting '"+e+"' request (c:"+t+"):",i);var a={event_protocol_version:3,action:e,correlation_id:t,retried_requests:s,ttl_in_s:-1,requests:i};return"ttl"===n&&(a.reason=n),this.services.network.post(this.services.config.subscriptionsUri,a)}},{key:"add",value:function(e,t){h.default.debug("Establishing intent to subscribe to "+e);var n=this.subscriptions.get(e);n&&t&&n.lastEventId===t.lastEventId||(this.persisted.delete(e),this.subscriptions.set(e,new m(t)),this.persist())}},{key:"remove",value:function(e){h.default.debug("Establishing intent to unsubscribe from "+e),this.subscriptions.delete(e)&&this.persist()}},{key:"acceptMessage",value:function(e,t){h.default.trace("Subscriptions received",e),e.correlation_id&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(e.correlation_id,(new Date).getTime());var n=void 0;switch(e.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(e.event,e.correlation_id);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(e.event,e.correlation_id);break;case"subscription_failed":this.applySubscriptionFailedMessage(e.event,e.correlation_id);break;case(n=e.event_type.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:var r=void 0;switch(n[0]){case"map_":r=e.event.map_sid;break;case"list_":r=e.event.list_sid;break;case"document_":r=e.event.document_sid;break;case"stream_":r=e.event.stream_sid;break;case"live_query_":r=e.event.query_id,t=!1,!0===e.strictly_ordered&&(t=!0);break;default:r=void 0}this.applyEventToSubscribedEntity(r,e,t);break;default:h.default.debug("Dropping unknown message type "+e.event_type)}}},{key:"applySubscriptionEstablishedMessage",value:function(e,t){var n=e.object_sid,r=this.persisted.get(e.object_sid);r&&r.pendingCorrelationId===t?"interrupted"===e.replay_status?(h.default.debug("Event Replay for subscription to "+n+" (c:"+t+") interrupted; continuing eagerly."),r.updatePending(null,null),this.persisted.delete(r.sid),this.backoff.reset()):"completed"===e.replay_status&&(h.default.debug("Event Replay for subscription to "+n+" (c:"+t+") completed. Subscription is ready."),r.complete(e.last_event_id),this.persisted.set(e.object_sid,r),r.setSubscriptionState("established"),this.backoff.reset()):h.default.debug("Late message for "+e.object_sid+" (c:"+t+") dropped."),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(e,t){var n=this.persisted.get(e.object_sid);n&&n.pendingCorrelationId===t?(n.updatePending(null,null),n.setSubscriptionState("none"),this.persisted.delete(e.object_sid)):h.default.debug("Late message for "+e.object_sid+" (c:"+t+") dropped."),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(e,t){var n=e.object_sid,r=this.subscriptions.get(n),i=this.persisted.get(n);r&&i?i.pendingCorrelationId===t&&(h.default.error("Failed to subscribe on "+i.sid,e.error),i.markAsFailed(e),i.setSubscriptionState("none")):!r&&i&&(this.persisted.delete(n),i.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(e,t,n){if(e){var r;n=n||(r=this.persisted.get(e))&&r.isEstablished;var i=this.subscriptions.get(e);i?(t.event.type=t.event_type,i.update(t.event,n)):h.default.debug("Message dropped for SID '"+e+"', for which there is no subscription.")}}},{key:"onConnectionStateChanged",value:function(e){this.isConnected=e,e&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(e){h.default.debug("Triggering event replay for all subscriptions, reason="+e),this.pendingPokeReason=e,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var t=[],n=!0,r=!1,i=void 0;try{for(var a,o=(0,s.default)(this.persisted.values());!(n=(a=o.next()).done);n=!0){var u=a.value;u.reset(),u.rejectedWithError&&t.push(u)}}catch(e){r=!0,i=e}finally{try{!n&&o.return&&o.return()}finally{if(r)throw i}}this.persisted.clear();var c=!0,l=!1,d=void 0;try{for(var f,p=(0,s.default)(t);!(c=(f=p.next()).done);c=!0){var b=f.value;this.persisted.set(b.sid,b)}}catch(e){l=!0,d=e}finally{try{!c&&p.return&&p.return()}finally{if(l)throw d}}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),e}();n.Subscriptions=v},{"./utils/logger":335,"./utils/syncerror":337,"babel-runtime/core-js/get-iterator":30,"babel-runtime/core-js/map":33,"babel-runtime/core-js/object/assign":35,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/slicedToArray":54,"babel-runtime/regenerator":57,"operation-retrier":205,twilsock:349}],332:[function(e,t,n){"use strict";var r=p(e("babel-runtime/helpers/get")),i=p(e("babel-runtime/core-js/promise")),s=p(e("babel-runtime/core-js/object/assign")),a=p(e("babel-runtime/regenerator")),o=p(e("babel-runtime/helpers/asyncToGenerator")),u=p(e("babel-runtime/core-js/object/get-prototype-of")),c=p(e("babel-runtime/helpers/classCallCheck")),l=p(e("babel-runtime/helpers/createClass")),d=p(e("babel-runtime/helpers/possibleConstructorReturn")),f=p(e("babel-runtime/helpers/inherits"));function p(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var h=e("./utils/syncerror"),b=e("./utils/sanitize"),m=e("./utils/logger"),v=e("./entity"),y=e("./mergingqueue"),g=e("./closeable"),_=function(e){function t(e,n,r){(0,c.default)(this,t);var i=(0,d.default)(this,(t.__proto__||(0,u.default)(t)).call(this,e,r));i.isDeleted=!1;return i.updateMergingQueue=new y.MergingQueue(function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e}),i.descriptor=n,i.descriptor.data=i.descriptor.data||{},i.descriptor.date_updated=new Date(i.descriptor.date_updated),i}return(0,f.default)(t,e),(0,l.default)(t,[{key:"_update",value:function(e){switch(e.date_created=new Date(e.date_created),e.type){case"document_updated":if(e.id<=this.lastEventId){m.default.trace("Document update skipped, current:",this.lastEventId,", remote:",e.id);break}var t=void 0!==this.descriptor.data?b.deepClone(this.descriptor.data):null;this.descriptor.last_event_id=e.id,this.descriptor.revision=e.document_revision,this.descriptor.date_updated=e.date_created,this.descriptor.data=e.document_data,this.broadcastEventToListeners("updated",{data:e.document_data,isLocal:!1,previousData:t}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.id,revision:e.document_revision,date_updated:e.date_created,data:e.document_data});break;case"document_removed":this.onRemoved(!1)}}},{key:"set",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){var r,i=this;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},b.validateOptionalTtl(r.ttl),e.abrupt("return",this.updateMergingQueue.squashAndAdd(r,function(e){return i._setUnconditionally(t,e.ttl)}));case 3:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"mutate",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){var r,i=this;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=n||{},b.validateOptionalTtl(r.ttl),e.abrupt("return",this.updateMergingQueue.add(r,function(e){return i._setWithIfMatch(t,e.ttl)}));case 3:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"update",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(function(e){return(0,s.default)(e,t)},n));case 1:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"setTtl",value:function(){var e=(0,o.default)(a.default.mark(function e(t){var n;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return b.validateMandatoryTtl(t),e.next=3,this._postUpdateToServer({ttl:t});case 3:n=e.sent,this.descriptor.date_expires=n.date_expires;case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_setUnconditionally",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){var r;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._postUpdateToServer({data:t,revision:void 0,ttl:n});case 2:return r=e.sent,this._handleSuccessfulUpdateResult(r),e.abrupt("return",this.descriptor.data);case 5:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"_setWithIfMatch",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){var r,i,s;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=t(b.deepClone(this.descriptor.data)))){e.next=22;break}return i=this.revision,e.prev=3,e.next=6,this._postUpdateToServer({data:r,revision:i,ttl:n});case 6:return s=e.sent,this._handleSuccessfulUpdateResult(s),e.abrupt("return",this.descriptor.data);case 11:if(e.prev=11,e.t0=e.catch(3),412!==e.t0.status){e.next=19;break}return e.next=16,this._softSync();case 16:return e.abrupt("return",this._setWithIfMatch(t));case 19:throw e.t0;case 20:e.next=23;break;case 22:return e.abrupt("return",this.descriptor.data);case 23:case"end":return e.stop()}},e,this,[[3,11]])}));return function(t,n){return e.apply(this,arguments)}}()},{key:"_handleSuccessfulUpdateResult",value:function(e){if(!(e.last_event_id<=this.descriptor.last_event_id)){var t=void 0!==this.descriptor.data?b.deepClone(this.descriptor.data):null;this.descriptor.revision=e.revision,this.descriptor.data=e.data,this.descriptor.last_event_id=e.last_event_id,this.descriptor.date_expires=e.date_expires,this.descriptor.date_updated=new Date(e.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:e.last_event_id,revision:e.revision,date_updated:e.date_updated,data:e.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:t})}}},{key:"_postUpdateToServer",value:function(){var e=(0,o.default)(a.default.mark(function e(t){var n,r,s;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=17;break}return n={data:t.data},void 0!==t.ttl&&(n.ttl=t.ttl),r=t.revision,e.prev=4,e.next=7,this.services.network.post(this.uri,n,r);case 7:return s=e.sent,e.abrupt("return",{revision:s.body.revision,data:t.data,last_event_id:s.body.last_event_id,date_updated:s.body.date_updated,date_expires:s.body.date_expires});case 11:throw e.prev=11,e.t0=e.catch(4),404===e.t0.status&&this.onRemoved(!1),e.t0;case 15:e.next=18;break;case 17:return e.abrupt("return",i.default.reject(new h.SyncError("The Document has been removed",404,54100)));case 18:case"end":return e.stop()}},e,this,[[4,11]])}));return function(t){return e.apply(this,arguments)}}()},{key:"_softSync",value:function(){var e=(0,o.default)(a.default.mark(function e(){var t=this;return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.services.network.get(this.uri).then(function(e){var n={type:"document_updated",id:e.body.last_event_id,document_revision:e.body.revision,document_data:e.body.data,date_created:e.body.date_updated};return t._update(n),t}).catch(function(e){404===e.status?t.onRemoved(!1):m.default.error("Can't get updates for "+t.sid+":",e)}));case 1:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"onRemoved",value:function(e){if(!this.isDeleted){var t=void 0!==this.descriptor.data?b.deepClone(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e,previousData:t})}}},{key:"removeDocument",value:function(){var e=(0,o.default)(a.default.mark(function e(){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isDeleted){e.next=6;break}return e.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),e.next=7;break;case 6:return e.abrupt("return",i.default.reject(new h.SyncError("The Document has been removed",404,54100)));case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"document"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}}],[{key:"type",get:function(){return"document"}}]),t}(v.SyncEntity);n.SyncDocumentImpl=_;var k=function(e){function t(e){(0,c.default)(this,t);var n=(0,d.default)(this,(t.__proto__||(0,u.default)(t)).call(this));return n.syncDocumentImpl=e,n.syncDocumentImpl.attach(n),n}return(0,f.default)(t,e),(0,l.default)(t,[{key:"set",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.set(t,n));case 2:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"mutate",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.mutate(t,n));case 2:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"update",value:function(){var e=(0,o.default)(a.default.mark(function e(t,n){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.update(t,n));case 2:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"setTtl",value:function(){var e=(0,o.default)(a.default.mark(function e(t){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.setTtl(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"removeDocument",value:function(){var e=(0,o.default)(a.default.mark(function e(){return a.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"close",value:function(){(0,r.default)(t.prototype.__proto__||(0,u.default)(t.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}},{key:"uri",get:function(){return this.syncDocumentImpl.uri}},{key:"revision",get:function(){return this.syncDocumentImpl.revision}},{key:"lastEventId",get:function(){return this.syncDocumentImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncDocumentImpl.dateExpires}},{key:"type",get:function(){return _.type}},{key:"sid",get:function(){return this.syncDocumentImpl.sid}},{key:"data",get:function(){return this.syncDocumentImpl.data}},{key:"dateUpdated",get:function(){return this.syncDocumentImpl.dateUpdated}},{key:"uniqueName",get:function(){return this.syncDocumentImpl.uniqueName}}],[{key:"type",get:function(){return _.type}}]),t}(g.default);n.SyncDocument=k,n.default=k},{"./closeable":317,"./entity":320,"./mergingqueue":325,"./utils/logger":335,"./utils/sanitize":336,"./utils/syncerror":337,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/get":51,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57}],333:[function(e,t,n){"use strict";var r=f(e("babel-runtime/helpers/get")),i=f(e("babel-runtime/core-js/object/assign")),s=f(e("babel-runtime/regenerator")),a=f(e("babel-runtime/helpers/asyncToGenerator")),o=f(e("babel-runtime/core-js/object/get-prototype-of")),u=f(e("babel-runtime/helpers/classCallCheck")),c=f(e("babel-runtime/helpers/createClass")),l=f(e("babel-runtime/helpers/possibleConstructorReturn")),d=f(e("babel-runtime/helpers/inherits"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("./utils/sanitize"),h=e("./utils/uri"),b=e("./utils/syncerror"),m=e("./utils/logger"),v=e("./entity"),y=e("./listitem"),g=e("./paginator"),_=e("./cache"),k=e("./mergingqueue"),w=e("./closeable"),x=function(e){function t(e,n,r){(0,u.default)(this,t);var i=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this,e,r));return i.updateMergingQueue=new k.NamespacedMergingQueue(function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e}),i.cache=new _.Cache,i.descriptor=n,i.descriptor.date_updated=new Date(i.descriptor.date_updated),i}return(0,d.default)(t,e),(0,c.default)(t,[{key:"_addOrUpdateItemOnServer",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r,i){var a,o;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a={data:n},void 0!==i&&(a.ttl=i),e.next=4,this.services.network.post(t,a,r);case 4:return(o=e.sent).body.data=n,o.body.date_updated=new Date(o.body.date_updated),e.abrupt("return",o.body);case 8:case"end":return e.stop()}},e,this)}));return function(t,n,r,i){return e.apply(this,arguments)}}()},{key:"push",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){var r,i,a;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=(n||{}).ttl,p.validateOptionalTtl(r),e.next=4,this._addOrUpdateItemOnServer(this.links.items,t,void 0,r);case 4:return i=e.sent,a=Number(i.index),this._handleItemMutated(a,i.url,i.last_event_id,i.revision,t,i.date_updated,i.date_expires,!0,!1),e.abrupt("return",this.cache.get(a));case 8:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"set",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},p.validateOptionalTtl(i.ttl),e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,function(e){return a._updateItemUnconditionally(t,n,e.ttl)}));case 3:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"_updateItemUnconditionally",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return i=e.sent,e.next=5,this._addOrUpdateItemOnServer(i.uri,n,void 0,r);case 5:return a=e.sent,this._handleItemMutated(t,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,!1,!1),e.abrupt("return",this.cache.get(t));case 8:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"_updateItemWithIfMatch",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a,o,u;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:if(i=e.sent,!(a=n(p.deepClone(i.data)))){e.next=25;break}return o=i.revision,e.prev=6,e.next=9,this._addOrUpdateItemOnServer(i.uri,a,o,r);case 9:return u=e.sent,this._handleItemMutated(t,u.url,u.last_event_id,u.revision,u.data,u.date_updated,u.date_expires,!1,!1),e.abrupt("return",this.cache.get(t));case 14:if(e.prev=14,e.t0=e.catch(6),412!==e.t0.status){e.next=22;break}return e.next=19,this._getItemFromServer(t);case 19:return e.abrupt("return",this._updateItemWithIfMatch(t,n,r));case 22:throw e.t0;case 23:e.next=26;break;case 25:return e.abrupt("return",i);case 26:case"end":return e.stop()}},e,this,[[6,14]])}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"mutate",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},p.validateOptionalTtl(i.ttl),e.abrupt("return",this.updateMergingQueue.add(t,i,function(e){return a._updateItemWithIfMatch(t,n,e.ttl)}));case 3:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"update",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,function(e){return(0,i.default)(e,n)},r));case 1:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"remove",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,r,i;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=p.deepClone(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"get",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this.cache.get(t))){e.next=5;break}return e.abrupt("return",n);case 5:return e.abrupt("return",this._getItemFromServer(t));case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({index:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new b.SyncError("No item with index "+t+" found",404,54151);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"queryItems",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,r,i,a,o=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new h.UriBuilder(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Index",t.index).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map(function(e){return e.date_updated=new Date(e.date_updated),o.cache.get(e.index)?o._handleItemMutated(e.index,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):o.cache.store(Number(e.index),new y.ListItem({index:Number(e.index),uri:e.url,revision:e.revision,lastEventId:e.last_event_id,dateUpdated:e.date_updated,dateExpires:e.date_expires,data:e.data}),e.last_event_id),o.cache.get(e.index)}),a=r.body.meta,e.abrupt("return",new g.Paginator(i,function(e){return o.queryItems({pageToken:e})},a.previous_token,a.next_token));case 8:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},p.validatePageSize(t.pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getContext",value:function(){var e=(0,a.default)(s.default.mark(function e(){var t;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.context){e.next=5;break}return e.next=3,this.services.network.get(this.links.context);case 3:t=e.sent,this._updateContextIfRequired(t.body.data,t.body.last_event_id);case 5:return e.abrupt("return",this.context);case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"setTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,r;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.validateMandatoryTtl(t),e.prev=1,n={ttl:t},e.next=5,this.services.network.post(this.uri,n);case 5:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),404===e.t0.status&&this.onRemoved(!1),e.t0;case 13:case"end":return e.stop()}},e,this,[[1,9]])}));return function(t){return e.apply(this,arguments)}}()},{key:"setItemTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){var r,i,a;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.validateMandatoryTtl(n),e.next=3,this.get(t);case 3:return r=e.sent,i={ttl:n},e.next=7,this.services.network.post(r.uri,i);case 7:a=e.sent,r.updateDateExpires(a.body.date_expires);case 9:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"removeList",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){var n=Number(e.item_index);switch(e.date_created=new Date(e.date_created),e.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(n,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,void 0,"list_item_added"===e.type,!0);break;case"list_item_removed":this._handleItemRemoved(n,e.id,e.item_data,e.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(e.context_data,e.id,e.date_created);break;case"list_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.list_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,s,a,o,u){if(this.shouldIgnoreEvent(e,n))m.default.trace("Item ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(s);var c=this.cache.get(e);if(!c){var l=new y.ListItem({index:e,uri:t,lastEventId:n,revision:r,data:i,dateUpdated:s,dateExpires:a});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,o)}var d=p.deepClone(c.data);c.update(n,r,i,s),this.cache.store(e,c,n),void 0!==a&&c.updateDateExpires(a),this.emitItemMutationEvent(c,u,!1,d)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",s={item:e,isLocal:!t};n||(s.previousItemData=r),this.broadcastEventToListeners(i,s)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{index:e,isLocal:!i,previousItemData:n})}},{key:"_handleContextUpdate",value:function(e,t,n){this._updateRootDateUpdated(n),this._updateContextIfRequired(e,t)&&this.broadcastEventToListeners("contextUpdated",{context:e,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(e,t){return!this.contextEventId||t>this.contextEventId?(this.context=e,this.contextEventId=t,!0):(m.default.trace("Context update skipped, current:",this.lastEventId,", remote:",t),!1)}},{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"list"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}}],[{key:"type",get:function(){return"list"}}]),t}(v.SyncEntity);n.SyncListImpl=x;var C=function(e){function t(e){(0,u.default)(this,t);var n=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this));return n.syncListImpl=e,n.syncListImpl.attach(n),n}return(0,d.default)(t,e),(0,c.default)(t,[{key:"push",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.push(t,n));case 2:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"set",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.set(t,n,r));case 2:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"mutate",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.mutate(t,n,r));case 2:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"update",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.update(t,n,r));case 2:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"remove",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.remove(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"get",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.get(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getContext",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.getItems(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setTtl(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setItemTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"removeList",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"close",value:function(){(0,r.default)(t.prototype.__proto__||(0,o.default)(t.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}},{key:"uri",get:function(){return this.syncListImpl.uri}},{key:"revision",get:function(){return this.syncListImpl.revision}},{key:"lastEventId",get:function(){return this.syncListImpl.lastEventId}},{key:"links",get:function(){return this.syncListImpl.links}},{key:"dateExpires",get:function(){return this.syncListImpl.dateExpires}},{key:"type",get:function(){return x.type}},{key:"sid",get:function(){return this.syncListImpl.sid}},{key:"uniqueName",get:function(){return this.syncListImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncListImpl.dateUpdated}}],[{key:"type",get:function(){return x.type}}]),t}(w.default);n.SyncList=C,n.default=C},{"./cache":314,"./closeable":317,"./entity":320,"./listitem":322,"./mergingqueue":325,"./paginator":326,"./utils/logger":335,"./utils/sanitize":336,"./utils/syncerror":337,"./utils/uri":339,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/get":51,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57}],334:[function(e,t,n){"use strict";var r=f(e("babel-runtime/helpers/get")),i=f(e("babel-runtime/core-js/object/assign")),s=f(e("babel-runtime/regenerator")),a=f(e("babel-runtime/helpers/asyncToGenerator")),o=f(e("babel-runtime/core-js/object/get-prototype-of")),u=f(e("babel-runtime/helpers/classCallCheck")),c=f(e("babel-runtime/helpers/createClass")),l=f(e("babel-runtime/helpers/possibleConstructorReturn")),d=f(e("babel-runtime/helpers/inherits"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("./utils/sanitize"),h=e("./utils/uri"),b=e("./utils/syncerror"),m=e("./utils/logger"),v=e("./entity"),y=e("./mapitem"),g=e("./paginator"),_=e("./cache"),k=e("./mergingqueue"),w=e("./closeable"),x=function(e){function t(e,n,r){(0,u.default)(this,t);var i=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this,e,r));return i.updateMergingQueue=new k.NamespacedMergingQueue(function(e,t){return"number"==typeof t.ttl?{ttl:t.ttl}:e}),i.cache=new _.Cache,i.descriptor=n,i.descriptor.date_updated=new Date(i.descriptor.date_updated),n.items&&n.items.forEach(function(e){e.date_updated=new Date(e.date_updated),i.cache.store(e.key,new y.MapItem(e),e.last_event_id)}),i}return(0,d.default)(t,e),(0,c.default)(t,[{key:"set",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},p.validateOptionalTtl(i.ttl),e.abrupt("return",this.updateMergingQueue.squashAndAdd(t,i,function(e){return a._putItemUnconditionally(t,n,e.ttl)}));case 3:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"get",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=t){e.next=2;break}throw new b.SyncError("Item key may not be empty",400,54209);case 2:if(!this.cache.has(t)){e.next=6;break}return e.abrupt("return",this.cache.get(t));case 6:return e.abrupt("return",this._getItemFromServer(t));case 7:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_getItemFromServer",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.queryItems({key:t});case 2:if(!((n=e.sent).items.length<1)){e.next=7;break}throw new b.SyncError("The specified Map Item does not exist",404,54201);case 7:return e.abrupt("return",n.items[0]);case 8:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"mutate",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=r||{},p.validateOptionalTtl(i.ttl),e.abrupt("return",this.updateMergingQueue.add(t,i,function(e){return a._putItemWithIfMatch(t,n,e.ttl)}));case 3:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"update",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.mutate(t,function(e){return(0,i.default)(e,n)},r));case 1:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"_putItemUnconditionally",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._putItemToServer(t,n,void 0,r);case 2:return i=e.sent,a=i.item,this._handleItemMutated(a.key,a.url,a.last_event_id,a.revision,a.data,a.date_updated,a.date_expires,i.added,!1),e.abrupt("return",this.cache.get(a.key));case 6:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"_putItemWithIfMatch",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){var i,a,o,u,c;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t).catch(function(e){if(404===e.status)return new y.MapItem({key:t,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw e});case 2:if(i=e.sent,!(a=n(p.deepClone(i.data)))){e.next=26;break}return o=i.revision,e.prev=6,e.next=9,this._putItemToServer(t,a,o,r);case 9:return u=e.sent,c=u.item,this._handleItemMutated(c.key,c.url,c.last_event_id,c.revision,c.data,c.date_updated,c.date_expires,u.added,!1),e.abrupt("return",this.cache.get(c.key));case 15:if(e.prev=15,e.t0=e.catch(6),412!==e.t0.status){e.next=23;break}return e.next=20,this._getItemFromServer(t);case 20:return e.abrupt("return",this._putItemWithIfMatch(t,n,r));case 23:throw e.t0;case 24:e.next=27;break;case 26:return e.abrupt("return",i);case 27:case"end":return e.stop()}},e,this,[[6,15]])}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"_putItemToServer",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r,i){var a,o,u,c,l;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a=new h.UriBuilder(this.links.items).pathSegment(t).build(),o={data:n},void 0!==i&&(o.ttl=i),e.prev=3,e.next=6,this.services.network.put(a,o,r);case 6:return u=e.sent,(c=u.body).data=n,c.date_updated=new Date(c.date_updated),l=201===u.status.code,e.abrupt("return",{added:l,item:c});case 14:throw e.prev=14,e.t0=e.catch(3),404===e.t0.status&&this.onRemoved(!1),e.t0;case 18:case"end":return e.stop()}},e,this,[[3,14]])}));return function(t,n,r,i){return e.apply(this,arguments)}}()},{key:"remove",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,r,i;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return n=e.sent,r=p.deepClone(n.data),e.next=6,this.services.network.delete(n.uri);case 6:i=e.sent,this._handleItemRemoved(t,i.body.last_event_id,r,new Date(i.body.date_updated),!1);case 8:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"queryItems",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,r,i,a,o=this;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},n=new h.UriBuilder(this.links.items).queryParam("From",t.from).queryParam("PageSize",t.limit).queryParam("Key",t.key).queryParam("PageToken",t.pageToken).queryParam("Order",t.order).build(),e.next=4,this.services.network.get(n);case 4:return r=e.sent,i=r.body.items.map(function(e){return e.date_updated=new Date(e.date_updated),o.cache.get(e.key)?o._handleItemMutated(e.key,e.url,e.last_event_id,e.revision,e.data,e.date_updated,e.date_expires,!1,!0):o.cache.store(e.key,new y.MapItem(e),e.last_event_id),o.cache.get(e.key)}),a=r.body.meta,e.abrupt("return",new g.Paginator(i,function(e){return o.queryItems({pageToken:e})},a.previous_token,a.next_token));case 8:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=t||{},p.validatePageSize(t.pageSize),t.limit=t.pageSize||t.limit||50,t.order=t.order||"asc",e.abrupt("return",this.queryItems(t));case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"shouldIgnoreEvent",value:function(e,t){return this.cache.isKnown(e,t)}},{key:"_update",value:function(e,t){switch(e.date_created=new Date(e.date_created),e.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(e.item_key,e.item_url,e.id,e.item_revision,e.item_data,e.date_created,void 0,"map_item_added"===e.type,!0);break;case"map_item_removed":this._handleItemRemoved(e.item_key,e.id,e.item_data,e.date_created,!0);break;case"map_removed":this.onRemoved(!1)}t&&this._advanceLastEventId(e.id,e.map_revision)}},{key:"_advanceLastEventId",value:function(e,t){this.lastEventId<e&&(this.descriptor.last_event_id=e,t&&(this.descriptor.revision=t))}},{key:"_updateRootDateUpdated",value:function(e){(!this.descriptor.date_updated||e.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=e,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:e}))}},{key:"_handleItemMutated",value:function(e,t,n,r,i,s,a,o,u){if(this.shouldIgnoreEvent(e,n))m.default.trace("Item ",e," update skipped, current:",this.lastEventId,", remote:",n);else{this._updateRootDateUpdated(s);var c=this.cache.get(e);if(!c){var l=new y.MapItem({key:e,url:t,last_event_id:n,revision:r,data:i,date_updated:s,date_expires:a});return this.cache.store(e,l,n),void this.emitItemMutationEvent(l,u,o)}var d=p.deepClone(c.data);c.update(n,r,i,s),this.cache.store(e,c,n),void 0!==a&&c.updateDateExpires(a),this.emitItemMutationEvent(c,u,!1,d)}}},{key:"emitItemMutationEvent",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=n?"itemAdded":"itemUpdated",s={item:e,isLocal:!t};n||(s.previousItemData=r),this.broadcastEventToListeners(i,s)}},{key:"_handleItemRemoved",value:function(e,t,n,r,i){this._updateRootDateUpdated(r),this.cache.delete(e,t),this.broadcastEventToListeners("itemRemoved",{key:e,isLocal:!i,previousItemData:n})}},{key:"onRemoved",value:function(e){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:e})}},{key:"setTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t){var n,r;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.validateMandatoryTtl(t),e.prev=1,n={ttl:t},e.next=5,this.services.network.post(this.uri,n);case 5:r=e.sent,this.descriptor.date_expires=r.body.date_expires,e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),404===e.t0.status&&this.onRemoved(!1),e.t0;case 13:case"end":return e.stop()}},e,this,[[1,9]])}));return function(t){return e.apply(this,arguments)}}()},{key:"setItemTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){var r,i,a;return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.validateMandatoryTtl(n),e.next=3,this.get(t);case 3:return r=e.sent,i={ttl:n},e.next=7,this.services.network.post(r.uri,i);case 7:a=e.sent,r.updateDateExpires(a.body.date_expires);case 9:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"removeMap",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"map"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}}],[{key:"type",get:function(){return"map"}}]),t}(v.SyncEntity);n.SyncMapImpl=x;var C=function(e){function t(e){(0,u.default)(this,t);var n=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this));return n.syncMapImpl=e,n.syncMapImpl.attach(n),n}return(0,d.default)(t,e),(0,c.default)(t,[{key:"set",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.set(t,n,r));case 2:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"get",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.get(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"mutate",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.mutate(t,n,r));case 2:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"update",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n,r){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.update(t,n,r));case 2:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"remove",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.remove(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.getItems(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setTtl(t));case 2:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setItemTtl",value:function(){var e=(0,a.default)(s.default.mark(function e(t,n){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.abrupt("return",this.syncMapImpl.setItemTtl(t,n));case 2:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"removeMap",value:function(){var e=(0,a.default)(s.default.mark(function e(){return s.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.ensureNotClosed(),e.next=3,this.syncMapImpl.removeMap();case 3:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"close",value:function(){(0,r.default)(t.prototype.__proto__||(0,o.default)(t.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}},{key:"uri",get:function(){return this.syncMapImpl.uri}},{key:"links",get:function(){return this.syncMapImpl.links}},{key:"revision",get:function(){return this.syncMapImpl.revision}},{key:"lastEventId",get:function(){return this.syncMapImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncMapImpl.dateExpires}},{key:"type",get:function(){return x.type}},{key:"sid",get:function(){return this.syncMapImpl.sid}},{key:"uniqueName",get:function(){return this.syncMapImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncMapImpl.dateUpdated}}],[{key:"type",get:function(){return x.type}}]),t}(w.Closeable);n.SyncMap=C,n.default=C},{"./cache":314,"./closeable":317,"./entity":320,"./mapitem":324,"./mergingqueue":325,"./paginator":326,"./utils/logger":335,"./utils/sanitize":336,"./utils/syncerror":337,"./utils/uri":339,"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/get":51,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57}],335:[function(e,t,n){"use strict";var r,i=e("babel-runtime/core-js/array/from"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});var a=e("loglevel").getLogger("twilio-sync");function o(e,t){return[(new Date).toISOString()+" Sync "+e+":"].concat((0,s.default)(t))}n.default={setLevel:function(e){a.setLevel(e)},trace:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];a.trace.apply(null,o("T",t))},debug:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];a.debug.apply(null,o("D",t))},info:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];a.info.apply(null,o("I",t))},warn:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];a.warn.apply(null,o("W",t))},error:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];a.error.apply(null,o("E",t))}}},{"babel-runtime/core-js/array/from":29,loglevel:203}],336:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/typeof")),i=s(e("babel-runtime/core-js/json/stringify"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=e("./syncerror");function o(e,t){if(!t||void 0!==e){var n,i=void 0===e?"undefined":(0,r.default)(e);if("number"!==i||!(u(n=e)&&n>=0)){var s="object"===i?"object":"'"+e+"' of type '"+i+"'";throw new a.default("Invalid TTL, expected a positive integer of type number, was "+s,400,54011)}}}function u(e){return!isNaN(parseInt(e))&&isFinite(e)}n.deepClone=function(e){return JSON.parse((0,i.default)(e))},n.validateId=function(e){if(void 0!==e){var t=void 0===e?"undefined":(0,r.default)(e);if("string"!==t)throw new Error("Invalid ID type, expected a string, got '"+t+"'")}},n.validateOptionalTtl=function(e){o(e,!0)},n.validateMandatoryTtl=function(e){o(e,!1)},n.validatePageSize=function(e){var t;if(!(void 0===e||u(t=e)&&t>0))throw new a.default("Invalid pageSize parameter. Expected a positive integer, was '"+e+"'.",400,20007)},n.validateMode=function(e){if(!["open_or_create","open_existing","create_new"].includes(e))throw new Error("Invalid open mode. Expected one of { 'create_new', 'open_or_create', 'open_existing' }")}},{"./syncerror":337,"babel-runtime/core-js/json/stringify":32,"babel-runtime/helpers/typeof":56}],337:[function(e,t,n){"use strict";var r=d(e("babel-runtime/core-js/object/create")),i=d(e("babel-runtime/core-js/object/set-prototype-of")),s=d(e("babel-runtime/core-js/array/from")),a=d(e("babel-runtime/core-js/reflect/construct")),o=d(e("babel-runtime/core-js/object/get-prototype-of")),u=d(e("babel-runtime/helpers/classCallCheck")),c=d(e("babel-runtime/helpers/possibleConstructorReturn")),l=d(e("babel-runtime/helpers/inherits"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var f=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;(0,u.default)(this,t);var i=(0,c.default)(this,(t.__proto__||(0,o.default)(t)).call(this));return i.name=i.constructor.name,i.message=e+" (status: "+n+", code: "+r+")",i.status=n,i.code=r,i}return(0,l.default)(t,e),t}(function(e){function t(){var t=(0,a.default)(e,(0,s.default)(arguments));return(0,i.default)(t,(0,o.default)(this)),t}return t.prototype=(0,r.default)(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i.default?(0,i.default)(t,e):t.__proto__=e,t}(Error));n.SyncError=f;var p=function(e){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments[3];(0,u.default)(this,t);var s=(0,c.default)(this,(t.__proto__||(0,o.default)(t)).call(this,e,n,r));return s.body=i,s}return(0,l.default)(t,e),t}(f);n.SyncNetworkError=p,n.default=f},{"babel-runtime/core-js/array/from":29,"babel-runtime/core-js/object/create":36,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/object/set-prototype-of":41,"babel-runtime/core-js/reflect/construct":43,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],338:[function(e,t,n){"use strict";var r=u(e("babel-runtime/regenerator")),i=u(e("babel-runtime/core-js/get-iterator")),s=u(e("babel-runtime/core-js/symbol/iterator")),a=u(e("babel-runtime/helpers/classCallCheck")),o=u(e("babel-runtime/helpers/createClass"));function u(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var c=function(){function e(t,n){(0,a.default)(this,e),this.balanceFactor=0,this.key=t,this.value=n,this.parent=null,this.left=null,this.right=null}return(0,o.default)(e,[{key:"update",value:function(e){this.value=e}},{key:"replace",value:function(e,t){e&&(this.left===t?this.left=t:this.right===t&&(this.right=t))}},{key:"isRoot",get:function(){return null===this.parent}},{key:"isLeaf",get:function(){return null===this.left&&null===this.right}},{key:"isLeftChild",get:function(){return this.parent.left===this}}]),e}(),l=function(){function e(t,n){(0,a.default)(this,e),this.isLessThan=t||function(e,t){return e<t},this.isEqual=n||function(e,t){return e===t},this.root=null,this.count=null}return(0,o.default)(e,[{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(e,t){var n=this.getNode(e);n?n.update(t):this.insert(e,t)}},{key:"insert",value:function(e,t){var n=new c(e,t);if(this.count++,this.root){for(var r=this.root;;)if(this.isLessThan(e,r.key)){if(!r.left){r.left=n;break}r=r.left}else{if(!r.right){r.right=n;break}r=r.right}for(n.parent=r,r=n;r.parent;){var i=r.parent,s=i.balanceFactor;if(r.isLeftChild?i.balanceFactor++:i.balanceFactor--,Math.abs(i.balanceFactor)<Math.abs(s))break;if(i.balanceFactor<-1||i.balanceFactor>1){this.rebalance(i);break}r=i}}else this.root=n}},{key:"get",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t.value;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"delete",value:function(e){var t=this.getNode(e);if(!t||t.key!==e)return null;var n=t.parent,r=t.left,i=t.right;if(!!r!=!!i){var s=r||i;n||s?n&&!s?this.root=s:(n.replace(t,null),this.rebalance(n)):this.root=null}else{for(var a=t.left;a.right;)a=a.right;if(t.left===a)t.isRoot?(this.root=a,a.parent=null):(t.isLeftChild?t.parent.left=a:t.parent.right=a,a.parent=t.parent),a.right=t.right,a.right.parent=a,a.balanceFactor=t.balanceFactor,t={parent:a,isLeftChild:!0};else{var o=a.parent,u=a.left;o.right=u,u&&(u.parent=o),t.isRoot?(this.root=a,a.parent=null):(t.isLeftChild?t.parent.left=a:t.parent.right=a,a.parent=t.parent),a.right=t.right,a.right.parent=a,a.left=t.left,a.left.parent=a,a.balanceFactor=t.balanceFactor,t={parent:o,isLeftChild:!1}}}for(this.count--;t.parent;){var c=t.parent,l=c.balanceFactor;if(t.isLeftChild?c.balanceFactor-=1:c.balanceFactor+=1,Math.abs(c.balanceFactor)>Math.abs(l)){if(!(c.balanceFactor<-1||c.balanceFactor>1))break;if(this.rebalance(c),0!==c.parent.balanceFactor)break;t=c.parent}else t=c}return null}},{key:"getNode",value:function(e){for(var t=this.root;t;){if(this.isEqual(e,t.key))return t;t=this.isLessThan(e,t.key)?t.left:t.right}return null}},{key:"rebalance",value:function(e){e.balanceFactor<0?e.right.balanceFactor>0?(this.rotateRight(e.right),this.rotateLeft(e)):this.rotateLeft(e):e.balanceFactor>0&&(e.left.balanceFactor<0?(this.rotateLeft(e.left),this.rotateRight(e)):this.rotateRight(e))}},{key:"rotateLeft",value:function(e){var t=e.right;e.right=t.left,null!==t.left&&(t.left.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.left=e,e.parent=t,e.balanceFactor=e.balanceFactor+1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor+1-Math.max(e.balanceFactor,0)}},{key:"rotateRight",value:function(e){var t=e.left;e.left=t.right,null!==t.right&&(t.right.parent=e),t.parent=e.parent,null===t.parent?this.root=t:e.isLeftChild?t.parent.left=t:t.parent.right=t,t.right=e,e.parent=t,e.balanceFactor=e.balanceFactor-1-Math.min(t.balanceFactor,0),t.balanceFactor=t.balanceFactor-1-Math.max(e.balanceFactor,0)}},{key:s.default,value:r.default.mark(function e(){var t,n,s,a,o,u;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=!0,n=!1,s=void 0,e.prev=3,a=(0,i.default)(this.getIterator());case 5:if(t=(o=a.next()).done){e.next=12;break}return u=o.value,e.next=9,u;case 9:t=!0,e.next=5;break;case 12:e.next=18;break;case 14:e.prev=14,e.t0=e.catch(3),n=!0,s=e.t0;case 18:e.prev=18,e.prev=19,!t&&a.return&&a.return();case 21:if(e.prev=21,!n){e.next=24;break}throw s;case 24:return e.finish(21);case 25:return e.finish(18);case 26:case"end":return e.stop()}},e,this,[[3,14,18,26],[19,,21,25]])})},{key:"getIterator",value:r.default.mark(function e(){var t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=this.root;case 1:if(!t){e.next=7;break}if(!this.isEqual(i,t.key)&&(null!==i||t.left)){e.next=4;break}return e.abrupt("break",7);case 4:t=this.isLessThan(i,t.key)||null===i?t.left:t.right,e.next=1;break;case 7:if(t){e.next=9;break}return e.abrupt("return",null);case 9:n=!0;case 10:if(!n){e.next=28;break}return e.next=13,[t.key,t.value];case 13:if(n=!1,!t.right){e.next=20;break}for(t=t.right;t.left;)t=t.left;n=!0,e.next=26;break;case 20:if(!t.parent){e.next=25;break}n=t.parent.left===t,t=t.parent,e.next=26;break;case 25:return e.abrupt("break",36);case 26:e.next=34;break;case 28:if(!t.parent){e.next=33;break}n=t.parent.left===t,t=t.parent,e.next=34;break;case 33:return e.abrupt("break",36);case 34:e.next=10;break;case 36:return e.abrupt("return",null);case 37:case"end":return e.stop()}},e,this)})},{key:"getReverseIterator",value:r.default.mark(function e(){var t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=this.root;case 1:if(!t){e.next=7;break}if(!this.isEqual(i,t.key)&&(null!==i||t.right)){e.next=4;break}return e.abrupt("break",7);case 4:t=this.isLessThan(i,t.key)&&null!==i?t.left:t.right,e.next=1;break;case 7:if(t){e.next=9;break}return e.abrupt("return",null);case 9:n=!0;case 10:if(!n){e.next=28;break}return e.next=13,[t.key,t.value];case 13:if(n=!1,!t.left){e.next=20;break}for(t=t.left;t.right;)t=t.right;n=!0,e.next=26;break;case 20:if(!t.parent){e.next=25;break}n=t.parent.right===t,t=t.parent,e.next=26;break;case 25:return e.abrupt("break",36);case 26:e.next=34;break;case 28:if(!t.parent){e.next=33;break}n=t.parent.right===t,t=t.parent,e.next=34;break;case 33:return e.abrupt("break",36);case 34:e.next=10;break;case 36:return e.abrupt("return",null);case 37:case"end":return e.stop()}},e,this)})},{key:"size",get:function(){return this.count}}]),e}();n.TreeMap=l},{"babel-runtime/core-js/get-iterator":30,"babel-runtime/core-js/symbol/iterator":47,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57}],339:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(t){(0,r.default)(this,e),this.base=t,this.args=new Array,this.paths=new Array}return(0,i.default)(e,[{key:"pathSegment",value:function(e){return this.paths.push(encodeURIComponent(e)),this}},{key:"queryParam",value:function(e,t){return void 0!==t&&this.args.push(encodeURIComponent(e)+"="+encodeURIComponent(t)),this}},{key:"build",value:function(){var e=this.base;return this.paths.length&&(e+="/"+this.paths.join("/")),this.args.length&&(e+="?"+this.args.join("&")),e}}]),e}();n.UriBuilder=a},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],340:[function(e,t,n){t.exports={_from:"twilio-sync@^1.0.0",_id:"twilio-sync@1.0.0",_inBundle:!1,_integrity:"sha512-dWvUjzm06e6q9ZJpU9RhtYJz8Zi4xcAeLHfvMdpqeSEFcz0fPhbrFUC1Q+oZsWCLGPZq6UIy8nTqfICx381hEw==",_location:"/twilio-sync",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"twilio-sync@^1.0.0",name:"twilio-sync",escapedName:"twilio-sync",rawSpec:"^1.0.0",saveSpec:null,fetchSpec:"^1.0.0"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/twilio-sync/-/twilio-sync-1.0.0.tgz",_shasum:"655a8248afcf7f8d397e04bc566b841a17fb3f93",_spec:"twilio-sync@^1.0.0",_where:"/home/circleci/project",author:{name:"Twilio"},browserify:{transform:["babelify"]},bundleDependencies:!1,dependencies:{loglevel:"^1.6.3","operation-retrier":"^3.0.0",platform:"^1.3.6","twilio-notifications":"^0.5.12",twilsock:"^0.6.2",uuid:"^3.3.2"},deprecated:!1,description:"Twilio Sync client library",devDependencies:{"@types/chai":"^4.1.7","@types/chai-as-promised":"7.1.0","@types/chai-string":"^1.4.1","@types/mocha":"^5.2.7","@types/node":"^12.0.4","@types/sinon":"^7.0.12","@types/sinon-chai":"^3.2.2","async-test-tools":"^1.0.7","babel-core":"^6.26.0","babel-plugin-transform-builtin-extend":"^1.1.2","babel-plugin-transform-runtime":"^6.23.0","babel-preset-env":"^1.6.1","babel-runtime":"^6.26.0",babelify:"^8.0.0",browserify:"^16.2.3",chai:"^4.2.0","chai-as-promised":"^7.1.1","chai-string":"^1.5.0",cheerio:"^1.0.0-rc.2","cross-env":"^5.2.0",del:"^4.1.1","fancy-log":"^1.3.3",fs:"0.0.2",gulp:"^4.0.2","gulp-babel":"^7.0.1","gulp-derequire":"^2.1.0","gulp-if":"^2.0.2","gulp-insert":"^0.5.0","gulp-rename":"^1.4.0","gulp-sourcemaps":"^2.6.5","gulp-tap":"^1.0.1","gulp-tslint":"^8.1.4","gulp-typescript":"^5.0.1","gulp-uglify-es":"^1.0.4","ink-docstrap":"^1.3.2",jsdoc:"~3.5.5",jsonwebtoken:"^8.5.1",karma:"^4.1.0","karma-browserify":"^6.0.0","karma-browserstack-launcher":"^1.5.1","karma-mocha":"^1.3.0","karma-mocha-reporter":"^2.2.5",mocha:"^6.1.4",nyc:"^14.1.1",path:"^0.12.7",sinon:"^7.3.2","sinon-chai":"^3.3.0","ts-node":"^8.2.0",tslint:"^5.17.0",twilio:"^3.31.1",typescript:"^3.5.1","uglify-es":"^3.3.10","uglify-save-license":"^0.4.1",underscore:"^1.9.1","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0",watchify:"^3.11.1"},engines:{node:">=8"},license:"MIT",main:"lib/index.js",name:"twilio-sync",scripts:{integrationTest:"npx gulp integrationTest",unitTest:"npx gulp unitTest"},types:"./lib/index.d.ts",version:"1.0.0"}},{}],341:[function(e,t,n){"use strict";var r=c(e("babel-runtime/core-js/object/assign")),i=c(e("babel-runtime/core-js/object/get-prototype-of")),s=c(e("babel-runtime/helpers/classCallCheck")),a=c(e("babel-runtime/helpers/createClass")),o=c(e("babel-runtime/helpers/possibleConstructorReturn")),u=c(e("babel-runtime/helpers/inherits"));function c(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var l=e("events"),d=e("operation-retrier"),f=function(e){function t(e){(0,s.default)(this,t);var n=(0,o.default)(this,(t.__proto__||(0,i.default)(t)).call(this));return n.options=e?(0,r.default)({},e):{},n}return(0,u.default)(t,e),(0,a.default)(t,[{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function(e){this.newBackoff=e}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");this.newBackoff?!this.usedBackoff||this.usedBackoff<this.newBackoff?this.createRetrier():this.retrier.failed(new Error):this.retrier.failed(new Error)}},{key:"cancel",value:function(){this.retrier&&this.retrier.cancel()}},{key:"cleanRetrier",value:function(){this.retrier&&(this.retrier.removeAllListeners(),this.retrier.cancel(),this.retrier=null)}},{key:"getRetryPolicy",value:function(){var e=(0,r.default)({},this.options);return this.newBackoff&&(e.min=this.newBackoff,e.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),e.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,e}},{key:"createRetrier",value:function(){var e=this;this.cleanRetrier();var t=this.getRetryPolicy();this.retrier=new d.Retrier(t),this.retrier.once("attempt",function(){e.retrier.on("attempt",function(){return e.emit("attempt")}),e.retrier.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(t){return e.emit("failed",t)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start().catch(function(e){})}},{key:"inProgress",get:function(){return!!this.retrier}}]),t}(l.EventEmitter);n.BackoffRetrier=f},{"babel-runtime/core-js/object/assign":35,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,events:200,"operation-retrier":205}],342:[function(e,t,n){"use strict";var r=f(e("babel-runtime/regenerator")),i=f(e("babel-runtime/helpers/asyncToGenerator")),s=f(e("babel-runtime/core-js/json/stringify")),a=f(e("babel-runtime/core-js/object/get-prototype-of")),o=f(e("babel-runtime/helpers/createClass")),u=f(e("babel-runtime/helpers/possibleConstructorReturn")),c=f(e("babel-runtime/helpers/get")),l=f(e("babel-runtime/helpers/inherits")),d=f(e("babel-runtime/helpers/classCallCheck"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("events"),h=e("./logger"),b=e("./configuration"),m=e("./twilsock"),v=e("./packetinterface"),y=e("./websocketchannel"),g=e("./services/registrations"),_=e("./services/upstream"),k=e("./deferred"),w=e("./error/twilsockerror"),x=e("./offlinestorage"),C=e("./tokenStorage"),j=e("./services/telemetrytracker"),S=function e(){(0,d.default)(this,e)};n.TelemetryEvents=S,S.TWILSOCK_CONNECT="twilsock.sdk.connect",S.TWILSOCK_INIT="twilsock.sdk.init";var T=function(e){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};(0,d.default)(this,t);var i=(0,u.default)(this,(t.__proto__||(0,a.default)(t)).call(this));i.offlineStorageDeferred=new k.Deferred,r.continuationToken=r.continuationToken?r.continuationToken:C.TokenStorage.getStoredToken(n);var s=i.config=new b.Configuration(e,n,r);h.log.setLevel(s.logLevel);var o=new y.WebSocketChannel(s.url),c=r.transport?r.transport:new v.PacketInterface(o,s);return i.channel=r.channel?r.channel:new m.TwilsockImpl(o,c,s),i.registrations=r.registrations?r.registrations:new g.Registrations(c),i.upstream=new _.Upstream(c,i.channel,s),i.telemetryTracker=new j.TelemetryTracker(s,c),i.channel.on("initialized",function(){return i.telemetryTracker.canSendTelemetry=!0}),o.on("disconnected",function(){return i.telemetryTracker.canSendTelemetry=!1}),i.registrations.on("registered",function(e){return i.emit("registered",e)}),i.channel.on("message",function(e,t){return setTimeout(function(){return i.emit("message",e,t)},0)}),i.channel.on("stateChanged",function(e){return setTimeout(function(){return i.emit("stateChanged",e)},0)}),i.channel.on("connectionError",function(e){return setTimeout(function(){return i.emit("connectionError",e)},0)}),i.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return i.emit("tokenAboutToExpire")},0)}),i.channel.on("tokenExpired",function(){return setTimeout(function(){return i.emit("tokenExpired")},0)}),i.channel.on("connected",function(){return i.registrations.updateRegistrations()}),i.channel.on("connected",function(){return i.upstream.sendPendingMessages()}),i.channel.on("connected",function(){return setTimeout(function(){return i.emit("connected")},0)}),i.channel.on("beforeConnect",function(){return i.telemetryTracker.addPartialEvent(new j.TelemetryEventDescription("Establish WebSocket connection","",new Date),S.TWILSOCK_CONNECT,j.TelemetryPoint.Start)}),i.channel.on("connected",function(){return i.telemetryTracker.addPartialEvent(new j.TelemetryEventDescription("Establish WebSocket connection","",new Date,new Date),S.TWILSOCK_CONNECT,j.TelemetryPoint.End)}),i.channel.on("beforeSendInit",function(){return i.telemetryTracker.addPartialEvent(new j.TelemetryEventDescription("Send Twilsock init","",new Date),S.TWILSOCK_INIT,j.TelemetryPoint.Start)}),i.channel.on("initialized",function(){return i.telemetryTracker.addPartialEvent(new j.TelemetryEventDescription("Send Twilsock init","Succeeded",new Date,new Date),S.TWILSOCK_INIT,j.TelemetryPoint.End)}),i.channel.on("sendInitFailed",function(){return i.telemetryTracker.addPartialEvent(new j.TelemetryEventDescription("Send Twilsock init","Failed",new Date,new Date),S.TWILSOCK_INIT,j.TelemetryPoint.End)}),i.channel.on("initialized",function(e){i.handleStorageId(n,e),C.TokenStorage.storeToken(e.continuationToken,n),setTimeout(function(){return i.emit("initialized",e)},0)}),i.channel.on("disconnected",function(){return setTimeout(function(){return i.emit("disconnected")},0)}),i.channel.on("disconnected",function(){return i.upstream.rejectPendingMessages()}),i.channel.on("disconnected",function(){return i.offlineStorageDeferred.fail(new w.TwilsockError("Client disconnected"))}),i.offlineStorageDeferred.promise.catch(function(){}),i}return(0,l.default)(t,e),(0,o.default)(t,[{key:"emit",value:function(e){for(var n,r=arguments.length,i=Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return h.log.debug("Emitting "+e.toString()+"("+i.map(function(e){return(0,s.default)(e)}).join(", ")+")"),(n=(0,c.default)(t.prototype.__proto__||(0,a.default)(t.prototype),"emit",this)).call.apply(n,[this,e].concat(i))}},{key:"handleStorageId",value:function(e,t){if(t.offlineStorage)if(t.offlineStorage.hasOwnProperty(e))try{this.offlineStorageDeferred.set(x.OfflineProductStorage.create(t.offlineStorage[e])),h.log.debug("Offline storage for '"+e+"' product: "+(0,s.default)(t.offlineStorage[e])+".")}catch(n){this.offlineStorageDeferred.fail(new w.TwilsockError("Failed to parse offline storage for "+e+" "+(0,s.default)(t.offlineStorage[e])+". "+n+"."))}else this.offlineStorageDeferred.fail(new w.TwilsockError("No offline storage id for '"+e+"' product: "+(0,s.default)(t.offlineStorage)));else this.offlineStorageDeferred.fail(new w.TwilsockError("No offline storage id"))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"updateToken",value:function(){var e=(0,i.default)(r.default.mark(function e(t){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(h.log.trace("updating token '"+t+"'"),this.config.token!==t){e.next=3;break}return e.abrupt("return");case 3:return this.config.updateToken(t),e.abrupt("return",this.channel.updateToken(t));case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setNotificationsContext",value:function(e,t){this.registrations.setNotificationsContext(e,t)}},{key:"removeNotificationsContext",value:function(e){this.registrations.removeNotificationsContext(e)}},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){return this.telemetryTracker.sendTelemetry(j.EventSendingLimitation.AnyEventsIncludingUnfinished),this.channel.disconnect()}},{key:"get",value:function(e,t,n){return this.telemetryTracker.sendTelemetry(j.EventSendingLimitation.AnyEvents),this.upstream.send("GET",e,t,void 0,n)}},{key:"post",value:function(e,t,n,r){return this.telemetryTracker.sendTelemetry(j.EventSendingLimitation.AnyEvents),this.upstream.send("POST",e,t,n,r)}},{key:"put",value:function(e,t,n,r){return this.telemetryTracker.sendTelemetry(j.EventSendingLimitation.AnyEvents),this.upstream.send("PUT",e,t,n,r)}},{key:"delete",value:function(e,t,n){return this.telemetryTracker.sendTelemetry(j.EventSendingLimitation.AnyEvents),this.upstream.send("DELETE",e,t,void 0,n)}},{key:"addTelemetryEvent",value:function(e){this.telemetryTracker.addTelemetryEvent(e),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(e,t,n){this.telemetryTracker.addPartialEvent(e,t,n),n===j.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}}]),t}(p.EventEmitter);n.TwilsockClient=T,n.Twilsock=T},{"./configuration":343,"./deferred":344,"./error/twilsockerror":346,"./logger":350,"./offlinestorage":352,"./packetinterface":353,"./services/registrations":364,"./services/telemetrytracker":365,"./services/upstream":366,"./tokenStorage":367,"./twilsock":368,"./websocketchannel":369,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/get":51,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200}],343:[function(e,t,n){"use strict";var r=a(e("babel-runtime/core-js/set")),i=a(e("babel-runtime/helpers/classCallCheck")),s=a(e("babel-runtime/helpers/createClass"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o="0.6.2",u=function(){function e(t,n){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};(0,i.default)(this,e),this.confirmedCapabilities=new r.default,this.activeGrant=n,this._token=t;var a="wss://tsock."+(s.region||"us1")+".twilio.com/v3/wsconnect",u=s.twilsock||s.Twilsock||{};this.url=u.uri||a,this._continuationToken=s.continuationToken?s.continuationToken:null,this.logLevel=s.logLevel?s.logLevel:"error",this.retryPolicy=s.retryPolicy?s.retryPolicy:{min:1e3,max:12e4,randomness:.2},this.clientMetadata=s.clientMetadata?s.clientMetadata:{},this.clientMetadata.ver=o,this.initRegistrations=s.initRegistrations?s.initRegistrations:null,this.tweaks=s.tweaks?s.tweaks:null}return(0,s.default)(e,[{key:"updateToken",value:function(e){this._token=e}},{key:"updateContinuationToken",value:function(e){this._continuationToken=e}},{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}}]),e}();n.Configuration=u},{"babel-runtime/core-js/set":45,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],344:[function(e,t,n){"use strict";var r=a(e("babel-runtime/core-js/promise")),i=a(e("babel-runtime/helpers/classCallCheck")),s=a(e("babel-runtime/helpers/createClass"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(){var t=this;(0,i.default)(this,e),this._promise=new r.default(function(e,n){t._resolve=e,t._reject=n})}return(0,s.default)(e,[{key:"update",value:function(e){this._resolve(e)}},{key:"set",value:function(e){this.current=e,this._resolve(e)}},{key:"fail",value:function(e){this._reject(e)}},{key:"promise",get:function(){return this._promise}}]),e}();n.Deferred=o},{"babel-runtime/core-js/promise":42,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],345:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(e){return(0,i.default)(this,t),(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this,e))}return(0,a.default)(t,e),t}(e("./twilsockerror").TwilsockError);n.TransportUnavailableError=u},{"./twilsockerror":346,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],346:[function(e,t,n){"use strict";var r=d(e("babel-runtime/core-js/object/create")),i=d(e("babel-runtime/core-js/object/set-prototype-of")),s=d(e("babel-runtime/core-js/array/from")),a=d(e("babel-runtime/core-js/reflect/construct")),o=d(e("babel-runtime/core-js/object/get-prototype-of")),u=d(e("babel-runtime/helpers/classCallCheck")),c=d(e("babel-runtime/helpers/possibleConstructorReturn")),l=d(e("babel-runtime/helpers/inherits"));function d(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var f=function(e){function t(e){return(0,u.default)(this,t),(0,c.default)(this,(t.__proto__||(0,o.default)(t)).call(this,e))}return(0,l.default)(t,e),t}(function(e){function t(){var t=(0,a.default)(e,(0,s.default)(arguments));return(0,i.default)(t,(0,o.default)(this)),t}return t.prototype=(0,r.default)(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i.default?(0,i.default)(t,e):t.__proto__=e,t}(Error));n.TwilsockError=f},{"babel-runtime/core-js/array/from":29,"babel-runtime/core-js/object/create":36,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/object/set-prototype-of":41,"babel-runtime/core-js/reflect/construct":43,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],347:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(e,n){(0,i.default)(this,t);var a=(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this,e));return a.reply=n,a}return(0,a.default)(t,e),t}(e("./twilsockerror").TwilsockError);n.TwilsockReplyError=u},{"./twilsockerror":346,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],348:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(e,n,a){(0,i.default)(this,t);var o=(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this,n));return o.status=e,o.description=n,o.body=a,o}return(0,a.default)(t,e),t}(e("./twilsockerror").TwilsockError);n.TwilsockUpstreamError=u},{"./twilsockerror":346,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],349:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./client");n.TwilsockClient=r.TwilsockClient,n.Twilsock=r.TwilsockClient;var i=e("./error/twilsockerror");n.TwilsockError=i.TwilsockError;var s=e("./error/transportunavailableerror");n.TransportUnavailableError=s.TransportUnavailableError},{"./client":342,"./error/transportunavailableerror":345,"./error/twilsockerror":346}],350:[function(e,t,n){"use strict";var r=a(e("babel-runtime/helpers/classCallCheck")),i=a(e("babel-runtime/helpers/createClass")),s=a(e("babel-runtime/core-js/array/from"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("loglevel").getLogger("twilsock");function u(e,t){return[(new Date).toISOString()+" Twilsock "+e+":"].concat((0,s.default)(t))}var c=function(){function e(t){(0,r.default)(this,e),this.prefix="",this.prefix=null!=t&&t.length>0?" "+t+":":""}return(0,i.default)(e,[{key:"setLevel",value:function(e){o.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.debug.apply(null,u("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.debug.apply(null,u("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.info.apply(null,u("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.warn.apply(null,u("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.error.apply(null,u("E",t))}}],[{key:"setLevel",value:function(e){o.setLevel(e)}},{key:"trace",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.trace.apply(null,u("T",t))}},{key:"debug",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.debug.apply(null,u("D",t))}},{key:"info",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.info.apply(null,u("I",t))}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.warn.apply(null,u("W",t))}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];o.error.apply(null,u("E",t))}}]),e}();n.Logger=c;var l=new c("");n.log=l},{"babel-runtime/core-js/array/from":29,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,loglevel:203}],351:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=e("platform"),o=function(){function e(){(0,r.default)(this,e)}return(0,i.default)(e,null,[{key:"getMetadata",value:function(e){"undefined"!=typeof navigator&&a.parse(navigator.userAgent);var t=e&&e.clientMetadata?e.clientMetadata:{},n={env:a.name,envv:a.version,os:a.os.family,osv:a.os.version,osa:a.os.architecture,sdk:"js-default"},r={};return["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"].filter(function(e){return e in t||e in n}).forEach(function(e){return r[e]=e in t?t[e]:n[e]}),r}}]),e}();n.Metadata=o},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,platform:207}],352:[function(e,t,n){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=e("./error/twilsockerror"),o=function(){function e(t){(0,r.default)(this,e),this.id=t}return(0,i.default)(e,null,[{key:"create",value:function(t){if(t instanceof Object&&"storage_id"in t)return new e(t.storage_id);throw new a.TwilsockError('Field "storage_id" is missing')}}]),e}();n.OfflineProductStorage=o},{"./error/twilsockerror":346,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],353:[function(e,t,n){"use strict";var r=f(e("babel-runtime/core-js/promise")),i=f(e("babel-runtime/regenerator")),s=f(e("babel-runtime/core-js/set")),a=f(e("babel-runtime/helpers/asyncToGenerator")),o=f(e("babel-runtime/core-js/map")),u=f(e("babel-runtime/helpers/createClass")),c=f(e("babel-runtime/helpers/classCallCheck")),l=f(e("babel-runtime/core-js/json/stringify")),d=f(e("babel-runtime/helpers/typeof"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("./logger"),h=e("uuid"),b=e("./error/twilsockerror"),m=e("./error/twilsockreplyerror"),v=e("./parser"),y=e("./protocol/messages"),g=e("./metadata");n.PacketResponse=function e(){(0,c.default)(this,e)};var _=function(){function e(t,n){var r=this;(0,c.default)(this,e),this.config=n,this.activeRequests=new o.default,this.channel=t,this.channel.on("reply",function(e){return r.processReply(e)}),this.channel.on("disconnected",function(){r.activeRequests.forEach(function(e){clearTimeout(e.timeout),e.reject(new b.TwilsockError("disconnected"))}),r.activeRequests.clear()})}return(0,u.default)(e,[{key:"processReply",value:function(e){var t,n=this.activeRequests.get(e.id);n&&(clearTimeout(n.timeout),this.activeRequests.delete(e.id),(t=e.status.code)>=200&&t<300?n.resolve(e):(n.reject(new m.TwilsockReplyError("Transport failure: "+e.status.status,e)),p.log.trace("message rejected")))}},{key:"storeRequest",value:function(e,t,n){var r={resolve:t,reject:n,timeout:setTimeout(function(){p.log.trace("request",e,"is timed out"),n(new b.TwilsockError("Twilsock: request timeout: "+e))},3e4)};this.activeRequests.set(e,r)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(e){clearTimeout(e.timeout),e.reject(new b.TwilsockError("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var e=(0,a.default)(i.default.mark(function e(){var t,n,r;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.log.trace("sendInit"),t=g.Metadata.getMetadata(this.config),n=new y.Init(this.config.token,this.config.continuationToken,t,this.config.initRegistrations,this.config.tweaks),e.next=5,this.sendWithReply(n);case 5:return r=e.sent,e.abrupt("return",new y.InitReply(r.id,r.header.continuation_token,r.header.continuation_token_status,r.header.offline_storage,r.header.init_registrations,r.header.debug_info,new s.default(r.header.capabilities)));case 7:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"sendClose",value:function(){var e=new y.Close;this.send(e)}},{key:"sendWithReply",value:function(e,t){var n=this;return new r.default(function(r,i){var s=n.send(e,t);n.storeRequest(s,r,i)})}},{key:"send",value:function(e,t){e.id=e.id||"TM"+h.v4();var n=v.Parser.createPacket(e,function(e){switch(void 0===e?"undefined":(0,d.default)(e)){case"undefined":return"";case"object":return(0,l.default)(e);default:return e}}(t));try{return this.channel.send(n),e.id}catch(t){throw p.log.debug("failed to send ",e,t),p.log.trace(t.stack),t}}},{key:"isConnected",get:function(){return this.channel.isConnected}}]),e}();n.PacketInterface=_},{"./error/twilsockerror":346,"./error/twilsockreplyerror":347,"./logger":350,"./metadata":351,"./parser":354,"./protocol/messages":357,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/map":33,"babel-runtime/core-js/promise":42,"babel-runtime/core-js/set":45,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/typeof":56,"babel-runtime/regenerator":57,uuid:370}],354:[function(e,t,n){"use strict";var r=a(e("babel-runtime/core-js/json/stringify")),i=a(e("babel-runtime/helpers/classCallCheck")),s=a(e("babel-runtime/helpers/createClass"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o=e("./logger");function u(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}).length}function c(e){var t=Array.prototype.map.call(e,function(e){return String.fromCharCode(e)}).join("").replace(/(.)/g,function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n});return decodeURIComponent(t)}function l(e){return JSON.parse(c(e))}var d=function(){function e(){(0,i.default)(this,e)}return(0,s.default)(e,null,[{key:"parse",value:function(e){var t=new Uint8Array(e),n=function(e){for(var t="",n=0;n<e.length;++n){var r=String.fromCharCode(e[n]);if(t+=r,"\r"===r){n+=2;break}}var i=t.split(" ");return{size:n,protocol:i[0],version:i[1],headerSize:Number(i[2])}}(t);if("TWILSOCK"===n.protocol&&"V3.0"===n.version){var r=null;try{r=l(t.subarray(n.size,n.size+n.headerSize))}catch(t){return void o.log.error("failed to parse message header",t,e)}o.log.debug("message received: ",r.method),o.log.trace("message received: ",r);var i=null;if(r.payload_size>0){var s=2+n.size+n.headerSize,a=r.payload_size;if(r.hasOwnProperty("payload_type")&&0!==r.payload_type.indexOf("application/json"))0===r.payload_type.indexOf("text/plain")&&(i=c(t.subarray(s,s+a)));else try{i=l(t.subarray(s,s+a))}catch(t){return void o.log.error("failed to parse message body",t,e)}}return{method:r.method,header:r,payload:i}}o.log.error("unsupported protocol: "+n.protocol+" ver "+n.version)}},{key:"createPacket",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";e.payload_size=u(t);var n,i,s=(0,r.default)(e)+"\r\n",a="TWILSOCK V3.0 "+(u(s)-2)+"\r\n";return o.log.debug("send request:",a+s+t),(n=encodeURIComponent(a+s+t).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}),i=new Uint8Array(n.length),Array.prototype.forEach.call(n,function(e,t){i[t]=e.charCodeAt(0)}),i).buffer}}]),e}();n.Parser=d},{"./logger":350,"babel-runtime/core-js/json/stringify":32,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],355:[function(e,t,n){"use strict";var r,i=e("babel-runtime/helpers/classCallCheck"),s=(r=i)&&r.__esModule?r:{default:r};Object.defineProperty(n,"__esModule",{value:!0});var a=e("uuid");n.AbstractMessage=function e(t){(0,s.default)(this,e),this.id=t||"TM"+a.v4()}},{"babel-runtime/helpers/classCallCheck":49,uuid:370}],356:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(){(0,i.default)(this,t);var e=(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this));return e.method="close",e}return(0,a.default)(t,e),t}(e("./abstractmessage").AbstractMessage);n.Close=u},{"./abstractmessage":355,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],357:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./init");n.Init=r.Init;var i=e("./initReply");n.InitReply=i.InitReply;var s=e("./update");n.Update=s.Update;var a=e("./message");n.Message=a.Message;var o=e("./reply");n.Reply=o.Reply;var u=e("./close");n.Close=u.Close;var c=e("./telemetry");n.Telemetry=c.Telemetry},{"./close":356,"./init":358,"./initReply":359,"./message":360,"./reply":361,"./telemetry":362,"./update":363}],358:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(e,n,a){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;(0,i.default)(this,t);var c=(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this));return c.method="init",c.token=e,c.continuation_token=n,c.metadata=a,c.registrations=o,c.tweaks=u,c.capabilities=["client_update","offline_storage","telemetry.v1"],c}return(0,a.default)(t,e),t}(e("./abstractmessage").AbstractMessage);n.Init=u},{"./abstractmessage":355,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],359:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/possibleConstructorReturn")),s=o(e("babel-runtime/helpers/inherits")),a=o(e("babel-runtime/helpers/classCallCheck"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=e("./abstractmessage");n.ContinuationTokenStatus=function e(){(0,a.default)(this,e)};var c=function(e){function t(e,n,s,o,u,c,l){(0,a.default)(this,t);var d=(0,i.default)(this,(t.__proto__||(0,r.default)(t)).call(this,e));return d.continuationToken=n,d.continuationTokenStatus=s,d.offlineStorage=o,d.initRegistrations=u,d.debugInfo=c,d.confirmedCapabilities=l,d}return(0,s.default)(t,e),t}(u.AbstractMessage);n.InitReply=c},{"./abstractmessage":355,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],360:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(e,n,a){(0,i.default)(this,t);var o=(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this));return o.method="message",o.active_grant=e,o.payload_type=n,o.http_request=a,o}return(0,a.default)(t,e),t}(e("./abstractmessage").AbstractMessage);n.Message=u},{"./abstractmessage":355,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],361:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(e){(0,i.default)(this,t);var n=(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this,e));return n.method="reply",n.payload_type="application/json",n.status={code:200,status:"OK"},n}return(0,a.default)(t,e),t}(e("./abstractmessage").AbstractMessage);n.Reply=u},{"./abstractmessage":355,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],362:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/possibleConstructorReturn")),s=o(e("babel-runtime/helpers/inherits")),a=o(e("babel-runtime/helpers/classCallCheck"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=e("./abstractmessage");n.TelemetryEvent=function e(t,n,r,i,s,o){(0,a.default)(this,e),this.start=t,this.end=n,this.title=r,this.details=i,this.id=s,this.type=o};var c=function(e){function t(e){(0,a.default)(this,t);var n=(0,i.default)(this,(t.__proto__||(0,r.default)(t)).call(this));return n.method="telemetry.v1",n.events=e,n}return(0,s.default)(t,e),t}(u.AbstractMessage);n.Telemetry=c},{"./abstractmessage":355,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],363:[function(e,t,n){"use strict";var r=o(e("babel-runtime/core-js/object/get-prototype-of")),i=o(e("babel-runtime/helpers/classCallCheck")),s=o(e("babel-runtime/helpers/possibleConstructorReturn")),a=o(e("babel-runtime/helpers/inherits"));function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=function(e){function t(e){(0,i.default)(this,t);var n=(0,s.default)(this,(t.__proto__||(0,r.default)(t)).call(this));return n.method="update",n.token=e,n}return(0,a.default)(t,e),t}(e("./abstractmessage").AbstractMessage);n.Update=u},{"./abstractmessage":355,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53}],364:[function(e,t,n){"use strict";var r=f(e("babel-runtime/core-js/set")),i=f(e("babel-runtime/regenerator")),s=f(e("babel-runtime/helpers/asyncToGenerator")),a=f(e("babel-runtime/core-js/map")),o=f(e("babel-runtime/core-js/object/get-prototype-of")),u=f(e("babel-runtime/helpers/classCallCheck")),c=f(e("babel-runtime/helpers/createClass")),l=f(e("babel-runtime/helpers/possibleConstructorReturn")),d=f(e("babel-runtime/helpers/inherits"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("../logger"),h=e("events"),b=e("uuid"),m=e("../error/twilsockerror"),v=function(e){function t(e){(0,u.default)(this,t);var n=(0,l.default)(this,(t.__proto__||(0,o.default)(t)).call(this));return n.transport=e,n.registrations=new a.default,n.registrationsInProgress=new a.default,n}return(0,d.default)(t,e),(0,c.default)(t,[{key:"putNotificationContext",value:function(){var e=(0,s.default)(i.default.mark(function e(t,n){var r;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r={method:"put_notification_ctx",notification_ctx_id:t},e.next=3,this.transport.sendWithReply(r,n);case 3:e.sent;case 4:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"deleteNotificationContext",value:function(){var e=(0,s.default)(i.default.mark(function e(t){var n;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n={method:"delete_notification_ctx",notification_ctx_id:t},e.next=3,this.transport.sendWithReply(n);case 3:e.sent;case 4:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateRegistration",value:function(){var e=(0,s.default)(i.default.mark(function e(t,n){var s,a;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p.log.debug("update registration for context",t),(s=this.registrationsInProgress.get(t))||(s=new r.default,this.registrationsInProgress.set(t,s)),a=b.v4(),s.add(a),e.prev=5,e.next=8,this.putNotificationContext(t,n);case 8:p.log.debug("registration attempt succeeded for context",n),s.delete(a),0===s.size&&(this.registrationsInProgress.delete(t),this.emit("registered",t)),e.next=19;break;case 13:e.prev=13,e.t0=e.catch(5),p.log.warn("registration attempt failed for context",n),p.log.debug(e.t0),s.delete(a),0===s.size&&(this.registrationsInProgress.delete(t),this.emit("registrationFailed",t,e.t0));case 19:case"end":return e.stop()}},e,this,[[5,13]])}));return function(t,n){return e.apply(this,arguments)}}()},{key:"updateRegistrations",value:function(){var e=this;p.log.trace("refreshing "+this.registrations.size+" registrations"),this.registrations.forEach(function(t,n){e.updateRegistration(n,t)})}},{key:"setNotificationsContext",value:function(e,t){if(!e||!t)throw new m.TwilsockError("Invalid arguments provided");this.registrations.set(e,t),this.transport.isConnected&&this.updateRegistration(e,t)}},{key:"removeNotificationsContext",value:function(){var e=(0,s.default)(i.default.mark(function e(t){return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.registrations.has(t)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this.deleteNotificationContext(t);case 4:this.transport.isConnected&&this.registrations.delete(t);case 5:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()}]),t}(h.EventEmitter);n.Registrations=v},{"../error/twilsockerror":346,"../logger":350,"babel-runtime/core-js/map":33,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/set":45,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/regenerator":57,events:200,uuid:370}],365:[function(e,t,n){"use strict";var r=a(e("babel-runtime/core-js/map")),i=a(e("babel-runtime/helpers/classCallCheck")),s=a(e("babel-runtime/helpers/createClass"));function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var o,u,c=e("../protocol/messages/telemetry"),l=e("../logger"),d=function(){function e(t,n,r,s,a,o){(0,i.default)(this,e),this.title=t,this.details=n,this.start=r,this.type=a,this.id=o,this.end=s}return(0,s.default)(e,[{key:"toTelemetryEvent",value:function(){var e=new Date,t=this.start,n=this.end?this.end:e;if(n<t){var r=n;n=t,t=r}var i=t.getTime()-e.getTime(),s=n.getTime()-e.getTime();return new c.TelemetryEvent(i,s,this.title,this.details,this.id,this.type)}}]),e}();n.TelemetryEventDescription=d,function(e){e[e.Start=0]="Start",e[e.End=1]="End"}(o||(o={})),n.TelemetryPoint=o,function(e){e[e.MinEventsPortion=0]="MinEventsPortion",e[e.AnyEvents=1]="AnyEvents",e[e.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(u||(u={})),n.EventSendingLimitation=u;var f=function(){function e(t,n){(0,i.default)(this,e),this.minEventsPortionToSend=50,this.maxEventsPortionToSend=100,this.pendingEvents=new r.default,this.readyEvents=[],this.hasInitializationFinished=!1,this._canSendTelemetry=!1,this.config=t,this.packetInterface=n}return(0,s.default)(e,[{key:"addTelemetryEvent",value:function(e){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(e)}},{key:"addPartialEvent",value:function(e,t,n){l.log.debug("Adding "+(n===o.Start?"starting":"ending")+" timepoint for '"+t+"' event");var r=this.pendingEvents.has(t);if(n===o.Start)r&&l.log.debug("Overwriting starting point for '"+t+"' event"),this.pendingEvents.set(t,e);else{if(!r)return void l.log.info("Could not find started event for '"+t+"' event");this.addTelemetryEvent(this.merge(this.pendingEvents.get(t),e)),this.pendingEvents.delete(t)}}},{key:"getTelemetryToSend",value:function(e){return this.canSendTelemetry&&0!=this.readyEvents.length?e==u.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(e==u.AnyEventsIncludingUnfinished):[]}},{key:"getTelemetryPortion",value:function(e){var t=this,n=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),r=this.readyEvents.splice(0,n);return e&&r.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(e,n){if(!(r.length>=t.maxEventsPortionToSend)){var i=t.pendingEvents.get(n);t.pendingEvents.delete(n),r.push(new d("[UNFINISHED] "+i.title,i.details,i.start,null,i.type,i.id))}}),r}},{key:"merge",value:function(e,t){return new d(t.title?t.title:e.title,t.details?t.details:e.details,e.start,t.end,t.type?t.type:e.type,t.id?t.id:e.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(u.MinEventsPortion)}},{key:"sendTelemetry",value:function(e){var t=this.getTelemetryToSend(e);if(0!==t.length)try{this.packetInterface.send(new c.Telemetry(t.map(function(e){return e.toTelemetryEvent()})))}catch(e){l.log.debug("Error while sending "+t.length+" telemetry events due to "+e+"; they will be resubmitted"),this.readyEvents=this.readyEvents.concat(t)}}},{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(e){l.log.debug("TelemetryTracker.canSendTelemetry: "+e+" TelemetryTracker.isTelemetryEnabled: "+this.isTelemetryEnabled),this._canSendTelemetry&&!e&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=e,e&&this.sendTelemetry(u.AnyEvents),e&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}}]),e}();n.TelemetryTracker=f},{"../logger":350,"../protocol/messages/telemetry":362,"babel-runtime/core-js/map":33,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],366:[function(e,t,n){"use strict";var r=u(e("babel-runtime/regenerator")),i=u(e("babel-runtime/helpers/asyncToGenerator")),s=u(e("babel-runtime/core-js/promise")),a=u(e("babel-runtime/helpers/createClass")),o=u(e("babel-runtime/helpers/classCallCheck"));function u(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var c=e("../logger"),l=e("../error/twilsockerror"),d=e("../error/twilsockupstreamerror"),f=e("../protocol/messages"),p=e("../error/transportunavailableerror");function h(e,t){var n=function(e){var t=e.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(t){var n={protocol:t[1],host:t[2],hostname:t[3],port:t[4],pathname:t[5],search:t[6],hash:t[7],params:null};if(n.search.length>0){var r=n.search.substring(1);n.params=r.split("&").map(function(e){return e.split("=")}).reduce(function(e,t){return e.hasOwnProperty(t[0])?Array.isArray(e[t[0]])?e[t[0]].push(t[1]):e[t[0]]=[e[t[0]],t[1]]:e[t[0]]=t[1],e},{})}return n}throw new l.TwilsockError("Incorrect URI: "+e)}(t),r={method:e,host:n.host,path:n.pathname};return n.params&&(r.params=n.params),r}var b=function(){function e(t,n,r){(0,o.default)(this,e),this.config=r,this.transport=t,this.pendingMessages=[],this.twilsock=n}return(0,a.default)(e,[{key:"saveMessage",value:function(e){var t=this;return new s.default(function(n,r){var i={message:e,resolve:n,reject:r,alreadyRejected:!1,timeout:setTimeout(function(){c.log.debug("request is timed out"),r(new l.TwilsockError("request '"+e.to.method+"' to '"+e.to.host+"' timed out")),i.alreadyRejected=!0},2e4)};t.pendingMessages.push(i)})}},{key:"sendPendingMessages",value:function(){for(var e=this,t=function(){var t=e.pendingMessages[0];if(!t.alreadyRejected)try{var n=t.message;e.actualSend(n).then(function(e){return t.resolve(e)}).catch(function(e){return t.reject(e)}),clearTimeout(t.timeout)}catch(e){return c.log.debug("Failed to send pending message",e),"break"}e.pendingMessages.splice(0,1)};this.pendingMessages.length;){if("break"===t())break}}},{key:"rejectPendingMessages",value:function(){var e=this;this.pendingMessages.forEach(function(t){t.reject(new p.TransportUnavailableError("Unable to connect: "+e.twilsock.getTerminationReason)),clearTimeout(t.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var e=(0,i.default)(r.default.mark(function e(t){var n,i,s,a,o,u,c;return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.to,i=t.headers,s=t.body,a=t.grant?t.grant:this.config.activeGrant,o={host:n.host,path:n.path,method:n.method,params:n.params,headers:i},u=new f.Message(a,i["Content-Type"]||"application/json",o),e.next=8,this.transport.sendWithReply(u,s);case 8:if(c=e.sent,!((l=c)&&l.header&&l.header.http_status)||(r=c.header.http_status.code)>=200&&r<300){e.next=11;break}throw new d.TwilsockUpstreamError(c.header.http_status.code,c.header.http_status.status,c.body);case 11:return e.abrupt("return",{status:c.header.http_status,headers:c.header.http_headers,body:c.body});case 12:case"end":return e.stop()}var r,l},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"send",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments[3],i=arguments[4];if(this.twilsock.isTerminalState)return s.default.reject(new p.TransportUnavailableError("Unable to connect: "+this.twilsock.getTerminationReason));var a=function(e,t,n,r,i){return{to:h(e,t),headers:n,body:r,grant:i}}(e,t,n,r,i);return this.twilsock.isConnected?this.actualSend(a):this.saveMessage(a)}}]),e}();n.Upstream=b},{"../error/transportunavailableerror":345,"../error/twilsockerror":346,"../error/twilsockupstreamerror":348,"../logger":350,"../protocol/messages":357,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/regenerator":57}],367:[function(e,t,n){(function(t){"use strict";var r=s(e("babel-runtime/helpers/classCallCheck")),i=s(e("babel-runtime/helpers/createClass"));function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function e(){(0,r.default)(this,e)}return(0,i.default)(e,null,[{key:"storeToken",value:function(t,n){e.canStore&&e.sessionStorage.setItem(e.getKeyName(n),t)}},{key:"getStoredToken",value:function(t){return e.canStore?e.sessionStorage.getItem(e.getKeyName(t)):null}},{key:"initialize",value:function(){e.canStore&&(e.sessionStorage.getItem(e.initializedFlag)&&this.clear(),e.sessionStorage.setItem(e.initializedFlag,"true"),e.window.addEventListener("unload",function(){e.sessionStorage.removeItem(e.initializedFlag)}))}},{key:"clear",value:function(){if(e.canStore){for(var t=[],n=0;n<e.sessionStorage.length;n++){var r=e.sessionStorage.key(n);0===r.indexOf(e.tokenStoragePrefix)&&t.push(r)}t.forEach(function(t){return e.sessionStorage.removeItem(t)}),e.sessionStorage.removeItem(e.initializedFlag)}}},{key:"getKeyName",value:function(t){return""+e.tokenStoragePrefix+t}},{key:"sessionStorage",get:function(){try{return t.sessionStorage}catch(e){return null}}},{key:"window",get:function(){try{return t.window}catch(e){return null}}},{key:"canStore",get:function(){return e.sessionStorage&&e.window}}]),e}();n.TokenStorage=a,a.initializedFlag="twilio_twilsock_token_storage",a.tokenStoragePrefix="twilio_continuation_token_",a.initialize()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50}],368:[function(e,t,n){"use strict";var r=f(e("babel-runtime/core-js/promise")),i=f(e("babel-runtime/regenerator")),s=f(e("babel-runtime/helpers/asyncToGenerator")),a=f(e("babel-runtime/core-js/object/get-prototype-of")),o=f(e("babel-runtime/helpers/createClass")),u=f(e("babel-runtime/helpers/possibleConstructorReturn")),c=f(e("babel-runtime/helpers/inherits")),l=f(e("babel-runtime/helpers/classCallCheck")),d=f(e("babel-runtime/core-js/json/stringify"));f(e("babel-runtime/helpers/typeof"));function f(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var p=e("events"),h=e("javascript-state-machine"),b=e("./logger"),m=e("./protocol/messages"),v=e("./parser"),y=e("./error/twilsockreplyerror"),g=e("./backoffretrier");n.Response=function e(){(0,l.default)(this,e)};var _=function(e){function t(e,n,r){(0,l.default)(this,t);var i=(0,u.default)(this,(t.__proto__||(0,a.default)(t)).call(this));return i.terminalStates=["disconnected","rejected"],i.lastEmittedState=void 0,i.tokenExpiredSasCode=20104,i.terminationReason="Connection is not initialized",i.websocket=e,i.websocket.on("connected",function(){return i.fsm.socketConnected()}),i.websocket.on("disconnected",function(e){return i.fsm.socketClosed()}),i.websocket.on("message",function(e){return i.onIncomingMessage(e)}),i.websocket.on("socketError",function(e){return i.emit("connectionError",{terminal:!1,message:"Socket error: "+e.message,httpStatusCode:null,errorCode:null})}),i.transport=n,i.config=r,i.retrier=new g.BackoffRetrier(r.retryPolicy),i.retrier.on("attempt",function(){return i.retry()}),i.retrier.on("failed",function(e){b.log.warn("Retrying failed: "+e.message),i.disconnect()}),"undefined"!=typeof window&&void 0!==window.addEventListener&&(window.addEventListener("online",function(){b.log.debug("Browser reported connectivity state: online"),i.resetBackoff(),i.fsm.systemOnline()}),window.addEventListener("offline",function(){b.log.debug("Browser reported connectivity state: offline"),i.websocket.close(),i.fsm.socketClosed()})),i.fsm=new h({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){i.setupSocket(),i.emit("connecting")},onEnterInitialising:function(){i.sendInit()},onLeaveInitialising:function(){i.cancelInit()},onEnterUpdating:function(){i.sendUpdate()},onLeaveUpdating:function(){i.cancelUpdate()},onEnterRetrying:function(){i.initRetry(),i.emit("connecting")},onEnterConnected:function(){i.resetBackoff(),i.onConnected()},onUserUpdateToken:function(){i.resetBackoff()},onTokenRejected:function(){i.resetBackoff(),i.closeSocket(!0),i.finalizeSocket()},onUserDisconnect:function(){i.closeSocket(!0)},onEnterDisconnecting:function(){i.startDisconnectTimer()},onLeaveDisconnecting:function(){i.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){i.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){i.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){i.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){i.cancelDisconnectTimer()},onDisconnected:function(){i.resetBackoff(),i.finalizeSocket()},onReceiveClose:function(e,t){i.onCloseReceived(t)},onReceiveOffload:function(e,t){b.log.debug("onreceiveoffload: ",t),i.modifyBackoff(t.body),i.onCloseReceived(t.status)},onUnsupported:function(){i.closeSocket(!0),i.finalizeSocket()},onError:function(e,t){i.closeSocket(t),i.finalizeSocket()},onEnterState:function(e){"none"!==e.from&&i.changeState(e)},onInvalidTransition:function(e,t,n){b.log.warn("FSM: unexpected transition",t,n)}}}),i}return(0,c.default)(t,e),(0,o.default)(t,[{key:"changeState",value:function(e){b.log.debug("FSM: "+e.transition+": "+e.from+" --\x3e "+e.to),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){b.log.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(e){b.log.trace("modifyBackoff",e);var t=e?e.backoff_policy:null;t&&"number"==typeof t.reconnect_min_ms&&this.retrier.modifyBackoff(t.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var e=this;b.log.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){b.log.debug("disconnecting is timed out"),e.closeSocket(!0)},3e3)}},{key:"cancelDisconnectTimer",value:function(){b.log.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"initRetry",value:function(){b.log.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){"connecting"!=this.fsm.state?(b.log.trace("retry"),this.websocket.close(),this.fsm.userRetry()):b.log.trace("can\t retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){b.log.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){b.log.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(e){var t=v.Parser.parse(e),n=t.method,r=t.header,i=t.payload;if("reply"!==n&&this.confirmReceiving(r),"notification"===n)this.emit("message",r.message_type,i);else if("reply"===r.method)this.transport.processReply({id:r.id,status:r.status,header:r,body:i});else if("client_update"===r.method)"token_about_to_expire"===r.client_update_type&&this.emit("tokenAboutToExpire");else if("close"===r.method)if(308===r.status.code)b.log.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:r.status.status,body:i});else if(406===r.status.code){var s="Server closed connection because can't parse protocol: "+(0,d.default)(r.status);this.emitReplyConnectionError(s,r,!0),b.log.error(s),this.fsm.receiveFatalClose()}else 417===r.status.code?(b.log.error("Server closed connection because can't parse client reply: "+(0,d.default)(r.status)),this.fsm.receiveFatalClose(r.status.status)):410===r.status.code?(b.log.warn("Server closed connection: "+(0,d.default)(r.status)),this.fsm.receiveClose(r.status.status),this.emit("tokenExpired")):401===r.status.code?(b.log.error("Server closed connection: "+(0,d.default)(r.status)),this.fsm.receiveClose(r.status.status)):(b.log.warn("unexpected message: ",r.status),this.fsm.receiveOffload({status:r.status.status,body:null}))}},{key:"sendInit",value:function(){var e=(0,s.default)(i.default.mark(function e(){var t,n;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return b.log.trace("sendInit"),e.prev=1,this.emit("beforeSendInit"),e.next=5,this.transport.sendInit();case 5:t=e.sent,this.config.updateContinuationToken(t.continuationToken),this.config.confirmedCapabilities=t.confirmedCapabilities,this.fsm.initSuccess(t),this.emit("initialized",t),this.emit("tokenUpdated"),e.next=17;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof y.TwilsockReplyError?(n=!1,b.log.warn("Init rejected by server: "+(0,d.default)(e.t0.reply.status)),this.emit("sendInitFailed"),401===e.t0.reply.status.code||403===e.t0.reply.status.code?(n=!0,this.fsm.tokenRejected(e.t0.reply.status),e.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):429===e.t0.reply.status.code?(this.modifyBackoff(e.t0.reply.body),this.fsm.initError(!0)):500===e.t0.reply.status.code?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(e.t0.message,e.t0.reply,n)):(this.terminationReason=e.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: "+e.t0.message+"\n"+(0,d.default)(e.t0,null,2),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",e.t0);case 17:case"end":return e.stop()}},e,this,[[1,13]])}));return function(){return e.apply(this,arguments)}}()},{key:"sendUpdate",value:function(){var e=(0,s.default)(i.default.mark(function e(){var t,n,r;return i.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return b.log.trace("sendUpdate"),t=new m.Update(this.config.token),e.prev=2,e.next=5,this.transport.sendWithReply(t);case 5:n=e.sent,this.fsm.updateSuccess(n.body),this.emit("tokenUpdated"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(2),e.t0 instanceof y.TwilsockReplyError?(r=!1,b.log.warn("Token update rejected by server: "+(0,d.default)(e.t0.reply.status)),401===e.t0.reply.status.code||403===e.t0.reply.status.code?(r=!0,this.fsm.tokenRejected(e.t0.reply.status),e.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):429===e.t0.reply.status.code?(this.modifyBackoff(e.t0.reply.body),this.fsm.updateError(e.t0.reply.status)):this.fsm.updateError(e.t0.reply.status),this.emitReplyConnectionError(e.t0.message,e.t0.reply,r)):(this.emit("error",!1,e.t0.message,null,null),this.fsm.updateError(e.t0)),this.emit("tokenUpdated",e.t0);case 14:case"end":return e.stop()}},e,this,[[2,10]])}));return function(){return e.apply(this,arguments)}}()},{key:"emitReplyConnectionError",value:function(e,t,n){var r=t.status&&t.status.description?t.status.description:e,i=t.status.code,s=t.status&&t.status.errorCode?t.status.errorCode:null;n&&(this.terminationReason=r),this.emit("connectionError",{terminal:n,message:"Connection error: "+r,httpStatusCode:i,errorCode:s})}},{key:"cancelInit",value:function(){b.log.trace("cancelInit")}},{key:"cancelUpdate",value:function(){b.log.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(e){b.log.trace("confirmReceiving");try{this.transport.send(new m.Reply(e.id))}catch(e){b.log.debug("failed to confirm packet receiving",e)}}},{key:"closeSocket",value:function(e){var t=this;b.log.trace("closeSocket (graceful: "+e+")"),e&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),setTimeout(function(){return t.fsm.socketClosed()},0)}},{key:"connect",value:function(){b.log.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var e=this;return b.log.trace("disconnect"),this.fsm.is("disconnected")?r.default.resolve():new r.default(function(t){e.disconnectedPromiseResolve=t,e.fsm.userDisconnect()})}},{key:"updateToken",value:function(e){var t=this;return b.log.trace("updateToken:",e),new r.default(function(e,n){t.once("tokenUpdated",function(t){t?n(t):e()}),t.fsm.userUpdateToken()})}},{key:"onCloseReceived",value:function(e){this.websocket.close()}},{key:"isConnected",get:function(){return"connected"===this.state&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"rejected";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"isTerminalState",get:function(){return-1!==this.terminalStates.indexOf(this.fsm.state)}},{key:"getTerminationReason",get:function(){return this.terminationReason}}]),t}(p.EventEmitter);n.TwilsockChannel=_,n.TwilsockImpl=_},{"./backoffretrier":341,"./error/twilsockreplyerror":347,"./logger":350,"./parser":354,"./protocol/messages":357,"babel-runtime/core-js/json/stringify":32,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/core-js/promise":42,"babel-runtime/helpers/asyncToGenerator":48,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,"babel-runtime/helpers/typeof":56,"babel-runtime/regenerator":57,events:200,"javascript-state-machine":202}],369:[function(e,t,n){(function(t){"use strict";var r=u(e("babel-runtime/core-js/object/get-prototype-of")),i=u(e("babel-runtime/helpers/classCallCheck")),s=u(e("babel-runtime/helpers/createClass")),a=u(e("babel-runtime/helpers/possibleConstructorReturn")),o=u(e("babel-runtime/helpers/inherits"));function u(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var c=e("events"),l=e("./logger"),d=function(n){function u(n){(0,i.default)(this,u);var s=(0,a.default)(this,(u.__proto__||(0,r.default)(u)).call(this));return s.url=n,s.WebSocket=t.WebSocket||t.MozWebSocket||e("ws"),s}return(0,o.default)(u,n),(0,s.default)(u,[{key:"connect",value:function(){var e=this;l.log.trace("connecting to socket");var t=void 0;try{t=new this.WebSocket(this.url)}catch(e){return l.log.debug("Socket error: "+this.url),void this.emit("socketError",e)}t.binaryType="arraybuffer",t.onopen=function(){l.log.debug("socket opened "+e.url),e.emit("connected")},t.onclose=function(t){l.log.debug("socket closed",t),e.emit("disconnected",t)},t.onerror=function(t){l.log.debug("Socket error:",t),e.emit("socketError",t)},t.onmessage=function(t){e.emit("message",t.data)},this.socket=t}},{key:"send",value:function(e){this.socket.send(e)}},{key:"close",value:function(){if(l.log.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}},{key:"isConnected",get:function(){return this.socket&&1===this.socket.readyState}}]),u}(c.EventEmitter);n.WebSocketChannel=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./logger":350,"babel-runtime/core-js/object/get-prototype-of":39,"babel-runtime/helpers/classCallCheck":49,"babel-runtime/helpers/createClass":50,"babel-runtime/helpers/inherits":52,"babel-runtime/helpers/possibleConstructorReturn":53,events:200,ws:58}],370:[function(e,t,n){var r=e("./v1"),i=e("./v4"),s=i;s.v1=r,s.v4=i,t.exports=s},{"./v1":373,"./v4":374}],371:[function(e,t,n){for(var r=[],i=0;i<256;++i)r[i]=(i+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,i=r;return[i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]]].join("")}},{}],372:[function(e,t,n){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var i=new Uint8Array(16);t.exports=function(){return r(i),i}}else{var s=new Array(16);t.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),s[t]=e>>>((3&t)<<3)&255;return s}}},{}],373:[function(e,t,n){var r,i,s=e("./lib/rng"),a=e("./lib/bytesToUuid"),o=0,u=0;t.exports=function(e,t,n){var c=t&&n||0,l=t||[],d=(e=e||{}).node||r,f=void 0!==e.clockseq?e.clockseq:i;if(null==d||null==f){var p=s();null==d&&(d=r=[1|p[0],p[1],p[2],p[3],p[4],p[5]]),null==f&&(f=i=16383&(p[6]<<8|p[7]))}var h=void 0!==e.msecs?e.msecs:(new Date).getTime(),b=void 0!==e.nsecs?e.nsecs:u+1,m=h-o+(b-u)/1e4;if(m<0&&void 0===e.clockseq&&(f=f+1&16383),(m<0||h>o)&&void 0===e.nsecs&&(b=0),b>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");o=h,u=b,i=f;var v=(1e4*(268435455&(h+=122192928e5))+b)%4294967296;l[c++]=v>>>24&255,l[c++]=v>>>16&255,l[c++]=v>>>8&255,l[c++]=255&v;var y=h/4294967296*1e4&268435455;l[c++]=y>>>8&255,l[c++]=255&y,l[c++]=y>>>24&15|16,l[c++]=y>>>16&255,l[c++]=f>>>8|128,l[c++]=255&f;for(var g=0;g<6;++g)l[c+g]=d[g];return t||a(l)}},{"./lib/bytesToUuid":371,"./lib/rng":372}],374:[function(e,t,n){var r=e("./lib/rng"),i=e("./lib/bytesToUuid");t.exports=function(e,t,n){var s=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||r)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var o=0;o<16;++o)t[s+o]=a[o];return t||i(a)}},{"./lib/bytesToUuid":371,"./lib/rng":372}],375:[function(e,t,n){t.exports={name:"@twilio/conversations",version:"1.3.0-rc8",description:"Twilio Conversations client library",main:"lib/index.js",browser:"browser/index.js",types:"./lib/client.d.ts",author:"Twilio",license:"MIT",dependencies:{"twilio-mcs-client":"=0.5.0-rc2","twilio-notifications":"^0.5.11","twilio-sdk-type-validator":"0.1.0","twilio-sync":"^1.0.0",twilsock:"^0.6.1","babel-runtime":"^6.26.0","iso8601-duration":"^1.2.0",loglevel:"^1.6.6","operation-retrier":"^3.0.0",platform:"^1.3.6",rfc6902:"^3.0.2",uuid:"^3.3.2"},devDependencies:{"@types/chai":"^4.2.5","@types/chai-as-promised":"^7.1.2","@types/chai-string":"^1.4.1","@types/core-js":"^2.5.0","@types/mocha":"^5.2.7","@types/node":"^12.12.12","@types/sinon":"^7.5.1","@types/sinon-chai":"^3.2.2",async:"^3.0.1","async-test-tools":"^1.0.7","babel-core":"^6.26.0","babel-plugin-transform-builtin-extend":"^1.1.2","babel-plugin-transform-runtime":"^6.23.0","babel-preset-env":"^1.6.1",babelify:"^8.0.0",backoff:"^2.5.0",browserify:"^16.2.3","browserify-replace":"^1.0.0",browserslist:"^4.13.0",chai:"^4.2.0","chai-as-promised":"^7.1.1","chai-string":"^1.5.0",cheerio:"^1.0.0-rc.2","cross-env":"^5.2.0",del:"^5.1.0","dotenv-override-true":"^6.2.2","fancy-log":"^1.3.3",fs:"0.0.2",gulp:"^4.0.2","gulp-babel":"^7.0.1","gulp-derequire":"^2.1.0","gulp-if":"^2.0.2","gulp-insert":"^0.5.0","gulp-rename":"^1.4.0","gulp-sourcemaps":"^2.6.5","gulp-sri":"^0.3.1","gulp-tap":"^1.0.1","gulp-tslint":"^8.1.4","gulp-typescript":"^5.0.1","gulp-uglify-es":"^1.0.4","ink-docstrap":"^1.3.2","isomorphic-form-data":"^2.0.0",jsdoc:"~3.5.5","jsdoc-strip-async-await":"^0.1.0",mocha:"^6.2.2","mocha.parallel":"^0.15.6","node-fetch":"^2.6.1",nyc:"^14.1.1",path:"^0.12.7",sinon:"^7.5.0","sinon-chai":"^3.3.0","ts-node":"^8.5.2",tslint:"^5.20.1",twilio:"^3.37.1",typescript:"^3.7.2","uglify-save-license":"^0.4.1","vinyl-buffer":"^1.0.1","vinyl-source-stream":"^2.0.0"},scripts:{unitTest:"npx gulp unitTest",integrationTest:"npx gulp integrationTest"},engines:{node:">=6"},browserslist:["IE 11","last 3 Chrome versions","last 3 Firefox versions","last 3 Safari versions","last 3 Edge versions","last 2 iOS version","last 2 ChromeAndroid version","last 2 FirefoxAndroid version","last 2 Samsung versions","last 2 UCAndroid versions"]}},{}]},{},[2])(2)});