@cloudbase/oauth 0.1.1-alpha → 0.1.1-alpha.2

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 (332) hide show
  1. package/Dockerfile +15 -0
  2. package/README.md +1 -1
  3. package/_exmaple/assets/scripts/function/function.ts +99 -0
  4. package/_exmaple/assets/scripts/index.ts +99 -0
  5. package/_exmaple/assets/scripts/request.ts +11 -0
  6. package/_exmaple/index.html +15 -0
  7. package/_exmaple/package.json +33 -0
  8. package/_exmaple/tsconfig.json +71 -0
  9. package/_exmaple/typings.d.ts +0 -0
  10. package/_exmaple/webpack.config.js +42 -0
  11. package/cdnjs/1.0.0/cloudbase.auth.js +1 -0
  12. package/cdnjs/1.0.0/cloudbase.database.js +8 -0
  13. package/cdnjs/1.0.0/cloudbase.full.js +8 -0
  14. package/cdnjs/1.0.0/cloudbase.functions.js +1 -0
  15. package/cdnjs/1.0.0/cloudbase.js +1 -0
  16. package/cdnjs/1.0.0/cloudbase.storage.js +1 -0
  17. package/cdnjs/1.0.1/cloudbase.auth.js +1 -0
  18. package/cdnjs/1.0.1/cloudbase.database.js +8 -0
  19. package/cdnjs/1.0.1/cloudbase.full.js +8 -0
  20. package/cdnjs/1.0.1/cloudbase.functions.js +1 -0
  21. package/cdnjs/1.0.1/cloudbase.js +1 -0
  22. package/cdnjs/1.0.1/cloudbase.storage.js +1 -0
  23. package/cdnjs/1.0.2/cloudbase.auth.js +1 -0
  24. package/cdnjs/1.0.2/cloudbase.database.js +8 -0
  25. package/cdnjs/1.0.2/cloudbase.full.js +8 -0
  26. package/cdnjs/1.0.2/cloudbase.functions.js +1 -0
  27. package/cdnjs/1.0.2/cloudbase.js +1 -0
  28. package/cdnjs/1.0.2/cloudbase.storage.js +1 -0
  29. package/cdnjs/1.0.3/cloudbase.auth.js +1 -0
  30. package/cdnjs/1.0.3/cloudbase.database.js +8 -0
  31. package/cdnjs/1.0.3/cloudbase.full.js +8 -0
  32. package/cdnjs/1.0.3/cloudbase.functions.js +1 -0
  33. package/cdnjs/1.0.3/cloudbase.js +1 -0
  34. package/cdnjs/1.0.3/cloudbase.storage.js +1 -0
  35. package/cdnjs/1.0.4/cloudbase.auth.js +1 -0
  36. package/cdnjs/1.0.4/cloudbase.database.js +8 -0
  37. package/cdnjs/1.0.4/cloudbase.full.js +8 -0
  38. package/cdnjs/1.0.4/cloudbase.functions.js +1 -0
  39. package/cdnjs/1.0.4/cloudbase.js +1 -0
  40. package/cdnjs/1.0.4/cloudbase.storage.js +1 -0
  41. package/cdnjs/1.1.0/cloudbase.auth.js +1 -0
  42. package/cdnjs/1.1.0/cloudbase.database.js +8 -0
  43. package/cdnjs/1.1.0/cloudbase.full.js +8 -0
  44. package/cdnjs/1.1.0/cloudbase.functions.js +1 -0
  45. package/cdnjs/1.1.0/cloudbase.js +1 -0
  46. package/cdnjs/1.1.0/cloudbase.storage.js +1 -0
  47. package/cdnjs/1.1.1/cloudbase.auth.js +1 -0
  48. package/cdnjs/1.1.1/cloudbase.database.js +8 -0
  49. package/cdnjs/1.1.1/cloudbase.full.js +8 -0
  50. package/cdnjs/1.1.1/cloudbase.functions.js +1 -0
  51. package/cdnjs/1.1.1/cloudbase.js +1 -0
  52. package/cdnjs/1.1.1/cloudbase.storage.js +1 -0
  53. package/cdnjs/1.1.2/cloudbase.auth.js +1 -0
  54. package/cdnjs/1.1.2/cloudbase.database.js +8 -0
  55. package/cdnjs/1.1.2/cloudbase.full.js +8 -0
  56. package/cdnjs/1.1.2/cloudbase.functions.js +1 -0
  57. package/cdnjs/1.1.2/cloudbase.js +1 -0
  58. package/cdnjs/1.1.2/cloudbase.storage.js +1 -0
  59. package/cdnjs/1.1.3/cloudbase.auth.js +1 -0
  60. package/cdnjs/1.1.3/cloudbase.database.js +8 -0
  61. package/cdnjs/1.1.3/cloudbase.full.js +8 -0
  62. package/cdnjs/1.1.3/cloudbase.functions.js +1 -0
  63. package/cdnjs/1.1.3/cloudbase.js +1 -0
  64. package/cdnjs/1.1.3/cloudbase.storage.js +1 -0
  65. package/cdnjs/1.1.4/cloudbase.auth.js +1 -0
  66. package/cdnjs/1.1.4/cloudbase.database.js +8 -0
  67. package/cdnjs/1.1.4/cloudbase.full.js +8 -0
  68. package/cdnjs/1.1.4/cloudbase.functions.js +1 -0
  69. package/cdnjs/1.1.4/cloudbase.js +1 -0
  70. package/cdnjs/1.1.4/cloudbase.storage.js +1 -0
  71. package/cdnjs/1.2.1/cloudbase.auth.js +1 -0
  72. package/cdnjs/1.2.1/cloudbase.database.js +8 -0
  73. package/cdnjs/1.2.1/cloudbase.full.js +8 -0
  74. package/cdnjs/1.2.1/cloudbase.functions.js +1 -0
  75. package/cdnjs/1.2.1/cloudbase.js +1 -0
  76. package/cdnjs/1.2.1/cloudbase.storage.js +1 -0
  77. package/cdnjs/1.2.2/cloudbase.auth.js +1 -0
  78. package/cdnjs/1.2.2/cloudbase.database.js +8 -0
  79. package/cdnjs/1.2.2/cloudbase.full.js +8 -0
  80. package/cdnjs/1.2.2/cloudbase.functions.js +1 -0
  81. package/cdnjs/1.2.2/cloudbase.js +1 -0
  82. package/cdnjs/1.2.2/cloudbase.storage.js +1 -0
  83. package/cdnjs/1.2.3/cloudbase.auth.js +1 -0
  84. package/cdnjs/1.2.3/cloudbase.database.js +8 -0
  85. package/cdnjs/1.2.3/cloudbase.full.js +8 -0
  86. package/cdnjs/1.2.3/cloudbase.functions.js +1 -0
  87. package/cdnjs/1.2.3/cloudbase.js +1 -0
  88. package/cdnjs/1.2.3/cloudbase.storage.js +1 -0
  89. package/cdnjs/1.3.0/cloudbase.auth.js +1 -0
  90. package/cdnjs/1.3.0/cloudbase.database.js +8 -0
  91. package/cdnjs/1.3.0/cloudbase.full.js +8 -0
  92. package/cdnjs/1.3.0/cloudbase.functions.js +1 -0
  93. package/cdnjs/1.3.0/cloudbase.js +1 -0
  94. package/cdnjs/1.3.0/cloudbase.realtime.js +1 -0
  95. package/cdnjs/1.3.0/cloudbase.storage.js +1 -0
  96. package/cdnjs/1.3.1/cloudbase.auth.js +1 -0
  97. package/cdnjs/1.3.1/cloudbase.database.js +8 -0
  98. package/cdnjs/1.3.1/cloudbase.full.js +8 -0
  99. package/cdnjs/1.3.1/cloudbase.functions.js +1 -0
  100. package/cdnjs/1.3.1/cloudbase.js +1 -0
  101. package/cdnjs/1.3.1/cloudbase.realtime.js +1 -0
  102. package/cdnjs/1.3.1/cloudbase.storage.js +1 -0
  103. package/cdnjs/1.3.2/cloudbase.auth.js +1 -0
  104. package/cdnjs/1.3.2/cloudbase.database.js +8 -0
  105. package/cdnjs/1.3.2/cloudbase.full.js +8 -0
  106. package/cdnjs/1.3.2/cloudbase.functions.js +1 -0
  107. package/cdnjs/1.3.2/cloudbase.js +1 -0
  108. package/cdnjs/1.3.2/cloudbase.realtime.js +1 -0
  109. package/cdnjs/1.3.2/cloudbase.storage.js +1 -0
  110. package/cdnjs/1.3.3/cloudbase.auth.js +1 -0
  111. package/cdnjs/1.3.3/cloudbase.database.js +8 -0
  112. package/cdnjs/1.3.3/cloudbase.full.js +8 -0
  113. package/cdnjs/1.3.3/cloudbase.functions.js +1 -0
  114. package/cdnjs/1.3.3/cloudbase.js +1 -0
  115. package/cdnjs/1.3.3/cloudbase.realtime.js +1 -0
  116. package/cdnjs/1.3.3/cloudbase.storage.js +1 -0
  117. package/cdnjs/1.3.4-alpha.0/cloudbase.auth.js +1 -0
  118. package/cdnjs/1.3.4-alpha.0/cloudbase.database.js +8 -0
  119. package/cdnjs/1.3.4-alpha.0/cloudbase.full.js +8 -0
  120. package/cdnjs/1.3.4-alpha.0/cloudbase.functions.js +1 -0
  121. package/cdnjs/1.3.4-alpha.0/cloudbase.js +1 -0
  122. package/cdnjs/1.3.4-alpha.0/cloudbase.realtime.js +1 -0
  123. package/cdnjs/1.3.4-alpha.0/cloudbase.storage.js +1 -0
  124. package/cdnjs/1.3.5/cloudbase.analytics.js +1 -0
  125. package/cdnjs/1.3.5/cloudbase.auth.js +1 -0
  126. package/cdnjs/1.3.5/cloudbase.database.js +10 -0
  127. package/cdnjs/1.3.5/cloudbase.full.js +10 -0
  128. package/cdnjs/1.3.5/cloudbase.functions.js +1 -0
  129. package/cdnjs/1.3.5/cloudbase.js +1 -0
  130. package/cdnjs/1.3.5/cloudbase.realtime.js +1 -0
  131. package/cdnjs/1.3.5/cloudbase.storage.js +1 -0
  132. package/cdnjs/1.3.5-alpha.0/cloudbase.auth.js +1 -0
  133. package/cdnjs/1.3.5-alpha.0/cloudbase.database.js +10 -0
  134. package/cdnjs/1.3.5-alpha.0/cloudbase.full.js +10 -0
  135. package/cdnjs/1.3.5-alpha.0/cloudbase.functions.js +1 -0
  136. package/cdnjs/1.3.5-alpha.0/cloudbase.js +1 -0
  137. package/cdnjs/1.3.5-alpha.0/cloudbase.realtime.js +1 -0
  138. package/cdnjs/1.3.5-alpha.0/cloudbase.storage.js +1 -0
  139. package/cdnjs/1.4.0/cloudbase.analytics.js +1 -0
  140. package/cdnjs/1.4.0/cloudbase.auth.js +1 -0
  141. package/cdnjs/1.4.0/cloudbase.database.js +10 -0
  142. package/cdnjs/1.4.0/cloudbase.full.js +10 -0
  143. package/cdnjs/1.4.0/cloudbase.functions.js +1 -0
  144. package/cdnjs/1.4.0/cloudbase.js +1 -0
  145. package/cdnjs/1.4.0/cloudbase.realtime.js +1 -0
  146. package/cdnjs/1.4.0/cloudbase.storage.js +1 -0
  147. package/cdnjs/1.4.1/cloudbase.analytics.js +1 -0
  148. package/cdnjs/1.4.1/cloudbase.auth.js +1 -0
  149. package/cdnjs/1.4.1/cloudbase.database.js +10 -0
  150. package/cdnjs/1.4.1/cloudbase.full.js +10 -0
  151. package/cdnjs/1.4.1/cloudbase.functions.js +1 -0
  152. package/cdnjs/1.4.1/cloudbase.js +1 -0
  153. package/cdnjs/1.4.1/cloudbase.realtime.js +1 -0
  154. package/cdnjs/1.4.1/cloudbase.storage.js +1 -0
  155. package/cdnjs/1.4.1-alpha.0/cloudbase.analytics.js +1 -0
  156. package/cdnjs/1.4.1-alpha.0/cloudbase.auth.js +1 -0
  157. package/cdnjs/1.4.1-alpha.0/cloudbase.database.js +10 -0
  158. package/cdnjs/1.4.1-alpha.0/cloudbase.full.js +10 -0
  159. package/cdnjs/1.4.1-alpha.0/cloudbase.functions.js +1 -0
  160. package/cdnjs/1.4.1-alpha.0/cloudbase.js +1 -0
  161. package/cdnjs/1.4.1-alpha.0/cloudbase.realtime.js +1 -0
  162. package/cdnjs/1.4.1-alpha.0/cloudbase.storage.js +1 -0
  163. package/cdnjs/1.4.2-alpha.0/cloudbase.analytics.js +1 -0
  164. package/cdnjs/1.4.2-alpha.0/cloudbase.auth.js +1 -0
  165. package/cdnjs/1.4.2-alpha.0/cloudbase.database.js +10 -0
  166. package/cdnjs/1.4.2-alpha.0/cloudbase.full.js +10 -0
  167. package/cdnjs/1.4.2-alpha.0/cloudbase.functions.js +1 -0
  168. package/cdnjs/1.4.2-alpha.0/cloudbase.js +1 -0
  169. package/cdnjs/1.4.2-alpha.0/cloudbase.realtime.js +1 -0
  170. package/cdnjs/1.4.2-alpha.0/cloudbase.storage.js +1 -0
  171. package/cdnjs/1.5.0/cloudbase.analytics.js +1 -0
  172. package/cdnjs/1.5.0/cloudbase.auth.js +1 -0
  173. package/cdnjs/1.5.0/cloudbase.database.js +10 -0
  174. package/cdnjs/1.5.0/cloudbase.full.js +10 -0
  175. package/cdnjs/1.5.0/cloudbase.functions.js +1 -0
  176. package/cdnjs/1.5.0/cloudbase.js +1 -0
  177. package/cdnjs/1.5.0/cloudbase.realtime.js +1 -0
  178. package/cdnjs/1.5.0/cloudbase.storage.js +1 -0
  179. package/cdnjs/1.5.1/cloudbase.analytics.js +1 -0
  180. package/cdnjs/1.5.1/cloudbase.auth.js +1 -0
  181. package/cdnjs/1.5.1/cloudbase.database.js +26 -0
  182. package/cdnjs/1.5.1/cloudbase.full.js +26 -0
  183. package/cdnjs/1.5.1/cloudbase.functions.js +1 -0
  184. package/cdnjs/1.5.1/cloudbase.js +1 -0
  185. package/cdnjs/1.5.1/cloudbase.realtime.js +1 -0
  186. package/cdnjs/1.5.1/cloudbase.storage.js +1 -0
  187. package/cdnjs/1.5.1-alpha.0/cloudbase.analytics.js +1 -0
  188. package/cdnjs/1.5.1-alpha.0/cloudbase.auth.js +1 -0
  189. package/cdnjs/1.5.1-alpha.0/cloudbase.database.js +10 -0
  190. package/cdnjs/1.5.1-alpha.0/cloudbase.full.js +10 -0
  191. package/cdnjs/1.5.1-alpha.0/cloudbase.functions.js +1 -0
  192. package/cdnjs/1.5.1-alpha.0/cloudbase.js +1 -0
  193. package/cdnjs/1.5.1-alpha.0/cloudbase.realtime.js +1 -0
  194. package/cdnjs/1.5.1-alpha.0/cloudbase.storage.js +1 -0
  195. package/cdnjs/1.5.3-alpha.0/cloudbase.analytics.js +1 -0
  196. package/cdnjs/1.5.3-alpha.0/cloudbase.auth.js +1 -0
  197. package/cdnjs/1.5.3-alpha.0/cloudbase.database.js +26 -0
  198. package/cdnjs/1.5.3-alpha.0/cloudbase.full.js +26 -0
  199. package/cdnjs/1.5.3-alpha.0/cloudbase.functions.js +1 -0
  200. package/cdnjs/1.5.3-alpha.0/cloudbase.js +1 -0
  201. package/cdnjs/1.5.3-alpha.0/cloudbase.realtime.js +1 -0
  202. package/cdnjs/1.5.3-alpha.0/cloudbase.storage.js +1 -0
  203. package/cdnjs/1.6.0/cloudbase.analytics.js +1 -0
  204. package/cdnjs/1.6.0/cloudbase.auth.js +1 -0
  205. package/cdnjs/1.6.0/cloudbase.database.js +26 -0
  206. package/cdnjs/1.6.0/cloudbase.full.js +26 -0
  207. package/cdnjs/1.6.0/cloudbase.functions.js +1 -0
  208. package/cdnjs/1.6.0/cloudbase.js +1 -0
  209. package/cdnjs/1.6.0/cloudbase.realtime.js +1 -0
  210. package/cdnjs/1.6.0/cloudbase.storage.js +1 -0
  211. package/{CHANGELOG.md → changelog.md} +0 -0
  212. package/dist/README.md +153 -0
  213. package/{app → dist/app}/index.d.ts +1 -0
  214. package/{app → dist/app}/index.js +0 -0
  215. package/dist/app/index.js.map +1 -0
  216. package/{app → dist/app}/internal.d.ts +0 -0
  217. package/{app → dist/app}/internal.js +0 -0
  218. package/{app → dist/app}/internal.js.map +0 -0
  219. package/{app → dist/app}/openuri.d.ts +0 -0
  220. package/{app → dist/app}/openuri.js +2 -1
  221. package/{app → dist/app}/openuri.js.map +1 -1
  222. package/{app → dist/app}/request.d.ts +4 -3
  223. package/{app → dist/app}/request.js +20 -12
  224. package/dist/app/request.js.map +1 -0
  225. package/{app → dist/app}/storage.d.ts +0 -0
  226. package/{app → dist/app}/storage.js +0 -0
  227. package/{app → dist/app}/storage.js.map +0 -0
  228. package/{auth → dist/auth}/consts.d.ts +21 -4
  229. package/{auth → dist/auth}/consts.js +27 -5
  230. package/dist/auth/consts.js.map +1 -0
  231. package/{auth → dist/auth}/index.d.ts +83 -34
  232. package/{auth → dist/auth}/index.js +239 -92
  233. package/dist/auth/index.js.map +1 -0
  234. package/dist/auth/models.d.ts +284 -0
  235. package/{oauthclient → dist/auth}/models.js +1 -0
  236. package/dist/auth/models.js.map +1 -0
  237. package/{captcha → dist/captcha}/index.d.ts +0 -0
  238. package/{captcha → dist/captcha}/index.js +4 -2
  239. package/dist/captcha/index.js.map +1 -0
  240. package/dist/changelog.md +30 -0
  241. package/dist/function/index.d.ts +38 -0
  242. package/dist/function/index.js +80 -0
  243. package/dist/function/index.js.map +1 -0
  244. package/dist/index.d.ts +14 -0
  245. package/dist/index.js +24 -0
  246. package/dist/index.js.map +1 -0
  247. package/{oauthclient → dist/oauthclient}/consts.d.ts +0 -0
  248. package/{oauthclient → dist/oauthclient}/consts.js +0 -0
  249. package/{oauthclient → dist/oauthclient}/consts.js.map +0 -0
  250. package/{oauthclient → dist/oauthclient}/index.d.ts +0 -0
  251. package/{oauthclient → dist/oauthclient}/index.js +2 -2
  252. package/dist/oauthclient/index.js.map +1 -0
  253. package/{oauthclient → dist/oauthclient}/interface.d.ts +4 -0
  254. package/{oauthclient → dist/oauthclient}/interface.js +0 -0
  255. package/{oauthclient → dist/oauthclient}/interface.js.map +1 -1
  256. package/{oauthclient → dist/oauthclient}/models.d.ts +12 -11
  257. package/{auth → dist/oauthclient}/models.js +0 -0
  258. package/{oauthclient → dist/oauthclient}/models.js.map +0 -0
  259. package/{oauthclient → dist/oauthclient}/oauthclient.d.ts +11 -7
  260. package/{oauthclient → dist/oauthclient}/oauthclient.js +27 -12
  261. package/dist/oauthclient/oauthclient.js.map +1 -0
  262. package/dist/package.json +32 -0
  263. package/{utils/single-promise.d.ts → dist/utils/promise.d.ts} +3 -3
  264. package/{utils/single-promise.js → dist/utils/promise.js} +6 -6
  265. package/dist/utils/promise.js.map +1 -0
  266. package/{utils → dist/utils}/uuid.d.ts +0 -0
  267. package/{utils → dist/utils}/uuid.js +0 -0
  268. package/{utils → dist/utils}/uuid.js.map +0 -0
  269. package/docs/dev.md +71 -0
  270. package/docs/errlog.md +79 -0
  271. package/package.json +3 -2
  272. package/publish.sh +2 -0
  273. package/src/app/index.ts +83 -0
  274. package/src/app/internal.ts +26 -0
  275. package/src/app/openuri.ts +111 -0
  276. package/src/app/request.ts +66 -0
  277. package/src/app/storage.ts +58 -0
  278. package/src/auth/consts.ts +74 -0
  279. package/src/auth/index.ts +718 -0
  280. package/src/auth/models.ts +352 -0
  281. package/src/captcha/index.ts +170 -0
  282. package/src/function/index.ts +103 -0
  283. package/src/index.ts +32 -0
  284. package/src/oauthclient/consts.ts +48 -0
  285. package/src/oauthclient/index.ts +33 -0
  286. package/src/oauthclient/interface.ts +34 -0
  287. package/src/oauthclient/models.ts +50 -0
  288. package/src/oauthclient/oauthclient.ts +487 -0
  289. package/src/utils/promise.ts +41 -0
  290. package/src/utils/uuid.ts +11 -0
  291. package/test/e2e/cases/custom-login.test.js +122 -0
  292. package/test/e2e/cases/index.test.js +61 -0
  293. package/test/e2e/cases/login-state.test.js +89 -0
  294. package/test/e2e/environment.js +39 -0
  295. package/test/e2e/global_setup.js +33 -0
  296. package/test/e2e/global_teardown.js +15 -0
  297. package/test/e2e/setup.js +37 -0
  298. package/test/unit/index.test.js +89 -0
  299. package/test/web/cases/auth/index.js +256 -0
  300. package/test/web/cases/database/collection.js +173 -0
  301. package/test/web/cases/database/command.js +754 -0
  302. package/test/web/cases/database/date.js +122 -0
  303. package/test/web/cases/database/db.js +20 -0
  304. package/test/web/cases/database/document.js +160 -0
  305. package/test/web/cases/database/geo-advanced.js +327 -0
  306. package/test/web/cases/database/geo.js +105 -0
  307. package/test/web/cases/database/index.js +315 -0
  308. package/test/web/cases/database/order.js +83 -0
  309. package/test/web/cases/database/realtime.js +102 -0
  310. package/test/web/cases/database/regex.js +140 -0
  311. package/test/web/cases/ext/index.js +88 -0
  312. package/test/web/cases/function/index.js +77 -0
  313. package/test/web/cases/storage/cos.jpeg +0 -0
  314. package/test/web/cases/storage/index.js +207 -0
  315. package/test/web/index.html +63 -0
  316. package/test/web/index.js +109 -0
  317. package/test/web/util.js +80 -0
  318. package/tsconfig.json +35 -0
  319. package/wiki/README.md +75 -0
  320. package/app/index.js.map +0 -1
  321. package/app/request.js.map +0 -1
  322. package/auth/consts.js.map +0 -1
  323. package/auth/index.js.map +0 -1
  324. package/auth/models.d.ts +0 -158
  325. package/auth/models.js.map +0 -1
  326. package/captcha/index.js.map +0 -1
  327. package/index.d.ts +0 -8
  328. package/index.js +0 -17
  329. package/index.js.map +0 -1
  330. package/oauthclient/index.js.map +0 -1
  331. package/oauthclient/oauthclient.js.map +0 -1
  332. package/utils/single-promise.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_database",[],t):"object"==typeof exports?exports.cloudbase_database=t():e.cloudbase_database=t()}("undefined"!=typeof window?window:this,(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.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return 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=4)}([function(module,__webpack_exports__,__webpack_require__){"use strict";(function(global,Buffer){__webpack_require__.d(__webpack_exports__,"a",(function(){return bson_54}));var long__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(2),long__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(long__WEBPACK_IMPORTED_MODULE_0__),buffer__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),buffer__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_1__),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var map=createCommonjsModule((function(e){if(void 0!==commonjsGlobal.Map)e.exports=commonjsGlobal.Map,e.exports.Map=commonjsGlobal.Map;else{var t=function(e){this._keys=[],this._values={};for(var t=0;t<e.length;t++)if(null!=e[t]){var n=e[t],r=n[0],i=n[1];this._keys.push(r),this._values[r]={v:i,i:this._keys.length-1}}};t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(e){var t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)},t.prototype.entries=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?[n,e._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(e,t){t=t||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];e.call(t,this._values[r].v,r,t)}},t.prototype.get=function(e){return this._values[e]?this._values[e].v:void 0},t.prototype.has=function(e){return null!=this._values[e]},t.prototype.keys=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(e,t){return this._values[e]?(this._values[e].v=t,this):(this._keys.push(e),this._values[e]={v:t,i:this._keys.length-1},this)},t.prototype.values=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?e._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{enumerable:!0,get:function(){return this._keys.length}}),e.exports=t}})),map_1=map.Map;long__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.toExtendedJSON=function(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}},long__WEBPACK_IMPORTED_MODULE_0___default.a.fromExtendedJSON=function(e,t){var n=long__WEBPACK_IMPORTED_MODULE_0___default.a.fromString(e.$numberLong);return t&&t.relaxed?n.toNumber():n},Object.defineProperty(long__WEBPACK_IMPORTED_MODULE_0___default.a.prototype,"_bsontype",{value:"Long"});var long_1=long__WEBPACK_IMPORTED_MODULE_0___default.a;function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}var Double=function(){function e(t){_classCallCheck(this,e),t instanceof Number&&(t=t.valueOf()),this.value=t}return _createClass(e,[{key:"valueOf",value:function(){return this.value}},{key:"toJSON",value:function(){return this.value}},{key:"toExtendedJSON",value:function(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}}],[{key:"fromExtendedJSON",value:function(t,n){var r=parseFloat(t.$numberDouble);return n&&n.relaxed?r:new e(r)}}]),e}();Object.defineProperty(Double.prototype,"_bsontype",{value:"Double"});var double_1=Double;function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck$1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$1(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$1(e,t,n){return t&&_defineProperties$1(e.prototype,t),n&&_defineProperties$1(e,n),e}function _possibleConstructorReturn(e,t){return!t||"object"!==_typeof(t)&&"function"!=typeof t?_assertThisInitialized(e):t}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var Timestamp=function(e){function t(e,n){var r;return _classCallCheck$1(this,t),r=long_1.isLong(e)?_possibleConstructorReturn(this,_getPrototypeOf(t).call(this,e.low,e.high,!0)):_possibleConstructorReturn(this,_getPrototypeOf(t).call(this,e,n,!0)),_possibleConstructorReturn(r)}return _inherits(t,e),_createClass$1(t,[{key:"toJSON",value:function(){return{$timestamp:this.toString()}}},{key:"toExtendedJSON",value:function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}}],[{key:"fromInt",value:function(e){return new t(long_1.fromInt(e,!0))}},{key:"fromNumber",value:function(e){return new t(long_1.fromNumber(e,!0))}},{key:"fromBits",value:function(e,n){return new t(e,n)}},{key:"fromString",value:function(e,n){return new t(long_1.fromString(e,n,!0))}},{key:"fromExtendedJSON",value:function(e){return new t(e.$timestamp.i,e.$timestamp.t)}}]),t}(long_1);Object.defineProperty(Timestamp.prototype,"_bsontype",{value:"Timestamp"}),Timestamp.MAX_VALUE=Timestamp.MAX_UNSIGNED_VALUE;var timestamp=Timestamp,require$$0={};function normalizedFunctionString(e){return e.toString().replace("function(","function (")}function insecureRandomBytes(e){for(var t=new Uint8Array(e),n=0;n<e;++n)t[n]=Math.floor(256*Math.random());return t}var randomBytes=insecureRandomBytes;if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues)randomBytes=function(e){return window.crypto.getRandomValues(new Uint8Array(e))};else{try{randomBytes=require$$0.randomBytes}catch(e){}null==randomBytes&&(randomBytes=insecureRandomBytes)}var utils={normalizedFunctionString:normalizedFunctionString,randomBytes:randomBytes};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}var cachedSetTimeout=defaultSetTimout,cachedClearTimeout=defaultClearTimeout;function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}"function"==typeof global.setTimeout&&(cachedSetTimeout=setTimeout),"function"==typeof global.clearTimeout&&(cachedClearTimeout=clearTimeout);var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){draining&&currentQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(e)}}function nextTick(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];queue.push(new Item(e,t)),1!==queue.length||draining||runTimeout(drainQueue)}function Item(e,t){this.fun=e,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};var title="browser",platform="browser",browser=!0,env={},argv=[],version="",versions={},release={},config={};function noop(){}var on=noop,addListener=noop,once=noop,off=noop,removeListener=noop,removeAllListeners=noop,emit=noop;function binding(e){throw new Error("process.binding is not supported")}function cwd(){return"/"}function chdir(e){throw new Error("process.chdir is not supported")}function umask(){return 0}var performance=global.performance||{},performanceNow=performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow||function(){return(new Date).getTime()};function hrtime(e){var t=.001*performanceNow.call(performance),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]}var startTime=new Date;function uptime(){return(new Date-startTime)/1e3}var process={nextTick:nextTick,title:title,browser:browser,env:env,argv:argv,version:version,versions:versions,on:on,addListener:addListener,once:once,off:off,removeListener:removeListener,removeAllListeners:removeAllListeners,emit:emit,binding:binding,cwd:cwd,chdir:chdir,umask:umask,hrtime:hrtime,platform:platform,release:release,config:config,uptime:uptime},inherits;inherits="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e};var inherits$1=inherits;function _typeof$1(e){return(_typeof$1="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var formatRegExp=/%[sdj%]/g;function format(e){if(!isString(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(inspect(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(e).replace(formatRegExp,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<i;s=r[++n])isNull(s)||!isObject(s)?o+=" "+s:o+=" "+inspect(s);return o}function deprecate(e,t){if(isUndefined(global.process))return function(){return deprecate(e,t).apply(this,arguments)};var n=!1;return function(){return n||(console.error(t),n=!0),e.apply(this,arguments)}}var debugs={},debugEnviron;function debuglog(e){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){debugs[e]=function(){var t=format.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else debugs[e]=function(){};return debugs[e]}function inspect(e,t){var n={seen:[],stylize:stylizeNoColor};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),isBoolean(t)?n.showHidden=t:t&&_extend(n,t),isUndefined(n.showHidden)&&(n.showHidden=!1),isUndefined(n.depth)&&(n.depth=2),isUndefined(n.colors)&&(n.colors=!1),isUndefined(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=stylizeWithColor),formatValue(n,e,n.depth)}function stylizeWithColor(e,t){var n=inspect.styles[t];return n?"["+inspect.colors[n][0]+"m"+e+"["+inspect.colors[n][1]+"m":e}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}function formatValue(e,t,n){if(e.customInspect&&t&&isFunction(t.inspect)&&t.inspect!==inspect&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return isString(r)||(r=formatValue(e,r,n)),r}var i=formatPrimitive(e,t);if(i)return i;var o=Object.keys(t),s=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),isError(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(t);if(0===o.length){if(isFunction(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(isDate(t))return e.stylize(Date.prototype.toString.call(t),"date");if(isError(t))return formatError(t)}var a,f="",c=!1,l=["{","}"];(isArray(t)&&(c=!0,l=["[","]"]),isFunction(t))&&(f=" [Function"+(t.name?": "+t.name:"")+"]");return isRegExp(t)&&(f=" "+RegExp.prototype.toString.call(t)),isDate(t)&&(f=" "+Date.prototype.toUTCString.call(t)),isError(t)&&(f=" "+formatError(t)),0!==o.length||c&&0!=t.length?n<0?isRegExp(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),a=c?formatArray(e,t,n,s,o):o.map((function(r){return formatProperty(e,t,n,s,r,c)})),e.seen.pop(),reduceToSingleString(a,f,l)):l[0]+f+l[1]}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return isNumber(t)?e.stylize(""+t,"number"):isBoolean(t)?e.stylize(""+t,"boolean"):isNull(t)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,t,n,r,i){for(var o=[],s=0,u=t.length;s<u;++s)hasOwnProperty(t,String(s))?o.push(formatProperty(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(formatProperty(e,t,n,r,i,!0))})),o}function formatProperty(e,t,n,r,i,o){var s,u,a;if((a=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?u=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),hasOwnProperty(r,i)||(s="["+i+"]"),u||(e.seen.indexOf(a.value)<0?(u=isNull(n)?formatValue(e,a.value,null):formatValue(e,a.value,n-1)).indexOf("\n")>-1&&(u=o?u.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+u.split("\n").map((function(e){return" "+e})).join("\n")):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,t,n){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"===_typeof$1(e)}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"===_typeof$1(e)&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===_typeof$1(e)||void 0===e}function isBuffer(e){return Buffer.isBuffer(e)}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp$1(){var e=new Date,t=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],t].join(" ")}function log(){console.log("%s - %s",timestamp$1(),format.apply(null,arguments))}function _extend(e,t){if(!t||!isObject(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function hasOwnProperty(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var util={inherits:inherits$1,_extend:_extend,log:log,isBuffer:isBuffer,isPrimitive:isPrimitive,isFunction:isFunction,isError:isError,isDate:isDate,isObject:isObject,isRegExp:isRegExp,isUndefined:isUndefined,isSymbol:isSymbol,isString:isString,isNumber:isNumber,isNullOrUndefined:isNullOrUndefined,isNull:isNull,isBoolean:isBoolean,isArray:isArray,inspect:inspect,deprecate:deprecate,format:format,debuglog:debuglog};function _classCallCheck$2(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$2(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$2(e,t,n){return t&&_defineProperties$2(e.prototype,t),n&&_defineProperties$2(e,n),e}var Buffer$1=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,randomBytes$1=utils.randomBytes,deprecate$1=util.deprecate,PROCESS_UNIQUE=randomBytes$1(5),checkForHexRegExp=new RegExp("^[0-9a-fA-F]{24}$"),hasBufferType=!1;try{Buffer$1&&Buffer$1.from&&(hasBufferType=!0)}catch(e){hasBufferType=!1}for(var hexTable=[],_i=0;_i<256;_i++)hexTable[_i]=(_i<=15?"0":"")+_i.toString(16);for(var decodeLookup=[],i=0;i<10;)decodeLookup[48+i]=i++;for(;i<16;)decodeLookup[55+i]=decodeLookup[87+i]=i++;var _Buffer=Buffer$1;function convertToHex(e){return e.toString("hex")}function makeObjectIdError(e,t){var n=e[t];return new TypeError('ObjectId string "'.concat(e,'" contains invalid character "').concat(n,'" with character code (').concat(e.charCodeAt(t),"). All character codes for a non-hex string must be less than 256."))}var ObjectId=function(){function e(t){if(_classCallCheck$2(this,e),t instanceof e)return t;if(null==t||"number"==typeof t)return this.id=e.generate(t),void(e.cacheHexString&&(this.__id=this.toString("hex")));var n=e.isValid(t);if(!n&&null!=t)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(n&&"string"==typeof t&&24===t.length&&hasBufferType)return new e(Buffer$1.from(t,"hex"));if(n&&"string"==typeof t&&24===t.length)return e.createFromHexString(t);if(null==t||12!==t.length){if(null!=t&&t.toHexString)return e.createFromHexString(t.toHexString());throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters")}this.id=t,e.cacheHexString&&(this.__id=this.toString("hex"))}return _createClass$2(e,[{key:"toHexString",value:function(){if(e.cacheHexString&&this.__id)return this.__id;var t="";if(!this.id||!this.id.length)throw new TypeError("invalid ObjectId, ObjectId.id must be either a string or a Buffer, but is ["+JSON.stringify(this.id)+"]");if(this.id instanceof _Buffer)return t=convertToHex(this.id),e.cacheHexString&&(this.__id=t),t;for(var n=0;n<this.id.length;n++){var r=hexTable[this.id.charCodeAt(n)];if("string"!=typeof r)throw makeObjectIdError(this.id,n);t+=r}return e.cacheHexString&&(this.__id=t),t}},{key:"toString",value:function(e){return this.id&&this.id.copy?this.id.toString("string"==typeof e?e:"hex"):this.toHexString()}},{key:"toJSON",value:function(){return this.toHexString()}},{key:"equals",value:function(t){return t instanceof e?this.toString()===t.toString():"string"==typeof t&&e.isValid(t)&&12===t.length&&this.id instanceof _Buffer?t===this.id.toString("binary"):"string"==typeof t&&e.isValid(t)&&24===t.length?t.toLowerCase()===this.toHexString():"string"==typeof t&&e.isValid(t)&&12===t.length?t===this.id:!(null==t||!(t instanceof e||t.toHexString))&&t.toHexString()===this.toHexString()}},{key:"getTimestamp",value:function(){var e=new Date,t=this.id.readUInt32BE(0);return e.setTime(1e3*Math.floor(t)),e}},{key:"toExtendedJSON",value:function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}}],[{key:"getInc",value:function(){return e.index=(e.index+1)%16777215}},{key:"generate",value:function(t){"number"!=typeof t&&(t=~~(Date.now()/1e3));var n=e.getInc(),r=Buffer$1.alloc(12);return r[3]=255&t,r[2]=t>>8&255,r[1]=t>>16&255,r[0]=t>>24&255,r[4]=PROCESS_UNIQUE[0],r[5]=PROCESS_UNIQUE[1],r[6]=PROCESS_UNIQUE[2],r[7]=PROCESS_UNIQUE[3],r[8]=PROCESS_UNIQUE[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r}},{key:"createPk",value:function(){return new e}},{key:"createFromTime",value:function(t){var n=Buffer$1.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n[3]=255&t,n[2]=t>>8&255,n[1]=t>>16&255,n[0]=t>>24&255,new e(n)}},{key:"createFromHexString",value:function(t){if(void 0===t||null!=t&&24!==t.length)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(hasBufferType)return new e(Buffer$1.from(t,"hex"));for(var n=new _Buffer(12),r=0,i=0;i<24;)n[r++]=decodeLookup[t.charCodeAt(i++)]<<4|decodeLookup[t.charCodeAt(i++)];return new e(n)}},{key:"isValid",value:function(t){return null!=t&&("number"==typeof t||("string"==typeof t?12===t.length||24===t.length&&checkForHexRegExp.test(t):t instanceof e||(t instanceof _Buffer&&12===t.length||!!t.toHexString&&(12===t.id.length||24===t.id.length&&checkForHexRegExp.test(t.id)))))}},{key:"fromExtendedJSON",value:function(t){return new e(t.$oid)}}]),e}();ObjectId.get_inc=deprecate$1((function(){return ObjectId.getInc()}),"Please use the static `ObjectId.getInc()` instead"),ObjectId.prototype.get_inc=deprecate$1((function(){return ObjectId.getInc()}),"Please use the static `ObjectId.getInc()` instead"),ObjectId.prototype.getInc=deprecate$1((function(){return ObjectId.getInc()}),"Please use the static `ObjectId.getInc()` instead"),ObjectId.prototype.generate=deprecate$1((function(e){return ObjectId.generate(e)}),"Please use the static `ObjectId.generate(time)` instead"),Object.defineProperty(ObjectId.prototype,"generationTime",{enumerable:!0,get:function(){return this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24},set:function(e){this.id[3]=255&e,this.id[2]=e>>8&255,this.id[1]=e>>16&255,this.id[0]=e>>24&255}}),ObjectId.prototype[util.inspect.custom||"inspect"]=ObjectId.prototype.toString,ObjectId.index=~~(16777215*Math.random()),Object.defineProperty(ObjectId.prototype,"_bsontype",{value:"ObjectID"});var objectid=ObjectId;function _classCallCheck$3(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$3(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$3(e,t,n){return t&&_defineProperties$3(e.prototype,t),n&&_defineProperties$3(e,n),e}function alphabetize(e){return e.split("").sort().join("")}var BSONRegExp=function(){function e(t,n){_classCallCheck$3(this,e),this.pattern=t||"",this.options=n?alphabetize(n):"";for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new Error("The regular expression option [".concat(this.options[r],"] is not supported"))}return _createClass$3(e,[{key:"toExtendedJSON",value:function(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}}],[{key:"parseOptions",value:function(e){return e?e.split("").sort().join(""):""}},{key:"fromExtendedJSON",value:function(t){return t.$regex?"BSONRegExp"===t.$regex._bsontype?t:new e(t.$regex,e.parseOptions(t.$options)):new e(t.$regularExpression.pattern,e.parseOptions(t.$regularExpression.options))}}]),e}();Object.defineProperty(BSONRegExp.prototype,"_bsontype",{value:"BSONRegExp"});var regexp=BSONRegExp;function _classCallCheck$4(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$4(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$4(e,t,n){return t&&_defineProperties$4(e.prototype,t),n&&_defineProperties$4(e,n),e}var BSONSymbol=function(){function e(t){_classCallCheck$4(this,e),this.value=t}return _createClass$4(e,[{key:"valueOf",value:function(){return this.value}},{key:"toString",value:function(){return this.value}},{key:"inspect",value:function(){return this.value}},{key:"toJSON",value:function(){return this.value}},{key:"toExtendedJSON",value:function(){return{$symbol:this.value}}}],[{key:"fromExtendedJSON",value:function(t){return new e(t.$symbol)}}]),e}();Object.defineProperty(BSONSymbol.prototype,"_bsontype",{value:"Symbol"});var symbol=BSONSymbol;function _classCallCheck$5(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$5(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$5(e,t,n){return t&&_defineProperties$5(e.prototype,t),n&&_defineProperties$5(e,n),e}var Int32=function(){function e(t){_classCallCheck$5(this,e),t instanceof Number&&(t=t.valueOf()),this.value=t}return _createClass$5(e,[{key:"valueOf",value:function(){return this.value}},{key:"toJSON",value:function(){return this.value}},{key:"toExtendedJSON",value:function(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}}],[{key:"fromExtendedJSON",value:function(t,n){return n&&n.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)}}]),e}();Object.defineProperty(Int32.prototype,"_bsontype",{value:"Int32"});var int_32=Int32;function _classCallCheck$6(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$6(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$6(e,t,n){return t&&_defineProperties$6(e.prototype,t),n&&_defineProperties$6(e,n),e}var Code=function(){function e(t,n){_classCallCheck$6(this,e),this.code=t,this.scope=n}return _createClass$6(e,[{key:"toJSON",value:function(){return{scope:this.scope,code:this.code}}},{key:"toExtendedJSON",value:function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}}],[{key:"fromExtendedJSON",value:function(t){return new e(t.$code,t.$scope)}}]),e}();Object.defineProperty(Code.prototype,"_bsontype",{value:"Code"});var code=Code,Buffer$2=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,PARSE_STRING_REGEXP=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,PARSE_INF_REGEXP=/^(\+|-)?(Infinity|inf)$/i,PARSE_NAN_REGEXP=/^(\+|-)?NaN$/i,EXPONENT_MAX=6111,EXPONENT_MIN=-6176,EXPONENT_BIAS=6176,MAX_DIGITS=34,NAN_BUFFER=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),INF_NEGATIVE_BUFFER=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),INF_POSITIVE_BUFFER=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),EXPONENT_REGEX=/^([-+])?(\d+)?$/;function isDigit(e){return!isNaN(parseInt(e,10))}function divideu128(e){var t=long_1.fromNumber(1e9),n=long_1.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new long_1(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function multiply64x2(e,t){if(!e&&!t)return{high:long_1.fromNumber(0),low:long_1.fromNumber(0)};var n=e.shiftRightUnsigned(32),r=new long_1(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new long_1(t.getLowBits(),0),s=n.multiply(i),u=n.multiply(o),a=r.multiply(i),f=r.multiply(o);return s=s.add(u.shiftRightUnsigned(32)),u=new long_1(u.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),{high:s=s.add(u.shiftRightUnsigned(32)),low:f=u.shiftLeft(32).add(new long_1(f.getLowBits(),0))}}function lessThan(e,t){var n=e.high>>>0,r=t.high>>>0;return n<r||n===r&&e.low>>>0<t.low>>>0}function invalidErr(e,t){throw new TypeError('"'.concat(e,'" is not a valid Decimal128 string - ').concat(t))}function Decimal128(e){this.bytes=e}Decimal128.fromString=function(e){var t,n=!1,r=!1,i=!1,o=0,s=0,u=0,a=0,f=0,c=[0],l=0,h=0,p=0,d=0,y=0,_=0,g=[0,0],b=[0,0],m=0;if(e.length>=7e3)throw new TypeError(e+" not a valid Decimal128 string");var w=e.match(PARSE_STRING_REGEXP),v=e.match(PARSE_INF_REGEXP),E=e.match(PARSE_NAN_REGEXP);if(!w&&!v&&!E||0===e.length)throw new TypeError(e+" not a valid Decimal128 string");if(w){var N=w[2],O=w[4],S=w[5],A=w[6];O&&void 0===A&&invalidErr(e,"missing exponent power"),O&&void 0===N&&invalidErr(e,"missing exponent base"),void 0===O&&(S||A)&&invalidErr(e,"missing e before exponent")}if("+"!==e[m]&&"-"!==e[m]||(n="-"===e[m++]),!isDigit(e[m])&&"."!==e[m]){if("i"===e[m]||"I"===e[m])return new Decimal128(Buffer$2.from(n?INF_NEGATIVE_BUFFER:INF_POSITIVE_BUFFER));if("N"===e[m])return new Decimal128(Buffer$2.from(NAN_BUFFER))}for(;isDigit(e[m])||"."===e[m];)"."!==e[m]?(l<34&&("0"!==e[m]||i)&&(i||(f=s),i=!0,c[h++]=parseInt(e[m],10),l+=1),i&&(u+=1),r&&(a+=1),s+=1,m+=1):(r&&invalidErr(e,"contains multiple periods"),r=!0,m+=1);if(r&&!s)throw new TypeError(e+" not a valid Decimal128 string");if("e"===e[m]||"E"===e[m]){var T=e.substr(++m).match(EXPONENT_REGEX);if(!T||!T[2])return new Decimal128(Buffer$2.from(NAN_BUFFER));y=parseInt(T[0],10),m+=T[0].length}if(e[m])return new Decimal128(Buffer$2.from(NAN_BUFFER));if(p=0,l){if(d=l-1,1!==(o=u))for(;"0"===e[f+o-1];)o-=1}else p=0,d=0,c[0]=0,u=1,l=1,o=0;for(y<=a&&a-y>16384?y=EXPONENT_MIN:y-=a;y>EXPONENT_MAX;){if((d+=1)-p>MAX_DIGITS){if(c.join("").match(/^0+$/)){y=EXPONENT_MAX;break}invalidErr(e,"overflow")}y-=1}for(;y<EXPONENT_MIN||l<u;){if(0===d&&o<l){y=EXPONENT_MIN,o=0;break}if(l<u?u-=1:d-=1,y<EXPONENT_MAX)y+=1;else{if(c.join("").match(/^0+$/)){y=EXPONENT_MAX;break}invalidErr(e,"overflow")}}if(d-p+1<o){var B=s;r&&(f+=1,B+=1),n&&(f+=1,B+=1);var I=parseInt(e[f+d+1],10),D=0;if(I>=5&&(D=1,5===I))for(D=c[d]%2==1,_=f+d+2;_<B;_++)if(parseInt(e[_],10)){D=1;break}if(D)for(var P=d;P>=0;P--)if(++c[P]>9&&(c[P]=0,0===P)){if(!(y<EXPONENT_MAX))return new Decimal128(Buffer$2.from(n?INF_NEGATIVE_BUFFER:INF_POSITIVE_BUFFER));y+=1,c[P]=1}}if(g=long_1.fromNumber(0),b=long_1.fromNumber(0),0===o)g=long_1.fromNumber(0),b=long_1.fromNumber(0);else if(d-p<17){var $=p;for(b=long_1.fromNumber(c[$++]),g=new long_1(0,0);$<=d;$++)b=(b=b.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(c[$]))}else{var R=p;for(g=long_1.fromNumber(c[R++]);R<=d-17;R++)g=(g=g.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(c[R]));for(b=long_1.fromNumber(c[R++]);R<=d;R++)b=(b=b.multiply(long_1.fromNumber(10))).add(long_1.fromNumber(c[R]))}var x=multiply64x2(g,long_1.fromString("100000000000000000"));x.low=x.low.add(b),lessThan(x.low,b)&&(x.high=x.high.add(long_1.fromNumber(1))),t=y+EXPONENT_BIAS;var M={low:long_1.fromNumber(0),high:long_1.fromNumber(0)};x.high.shiftRightUnsigned(49).and(long_1.fromNumber(1)).equals(long_1.fromNumber(1))?(M.high=M.high.or(long_1.fromNumber(3).shiftLeft(61)),M.high=M.high.or(long_1.fromNumber(t).and(long_1.fromNumber(16383).shiftLeft(47))),M.high=M.high.or(x.high.and(long_1.fromNumber(0x7fffffffffff)))):(M.high=M.high.or(long_1.fromNumber(16383&t).shiftLeft(49)),M.high=M.high.or(x.high.and(long_1.fromNumber(562949953421311)))),M.low=x.low,n&&(M.high=M.high.or(long_1.fromString("9223372036854775808")));var C=Buffer$2.alloc(16);return m=0,C[m++]=255&M.low.low,C[m++]=M.low.low>>8&255,C[m++]=M.low.low>>16&255,C[m++]=M.low.low>>24&255,C[m++]=255&M.low.high,C[m++]=M.low.high>>8&255,C[m++]=M.low.high>>16&255,C[m++]=M.low.high>>24&255,C[m++]=255&M.high.low,C[m++]=M.high.low>>8&255,C[m++]=M.high.low>>16&255,C[m++]=M.high.low>>24&255,C[m++]=255&M.high.high,C[m++]=M.high.high>>8&255,C[m++]=M.high.high>>16&255,C[m++]=M.high.high>>24&255,new Decimal128(C)};var COMBINATION_MASK=31,EXPONENT_MASK=16383,COMBINATION_INFINITY=30,COMBINATION_NAN=31;Decimal128.prototype.toString=function(){for(var e,t,n,r,i,o,s=0,u=new Array(36),a=0;a<u.length;a++)u[a]=0;var f,c,l,h,p,d=0,y=!1,_={parts:new Array(4)},g=[];d=0;var b=this.bytes;if(r=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,n=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,t=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,e=b[d++]|b[d++]<<8|b[d++]<<16|b[d++]<<24,d=0,{low:new long_1(r,n),high:new long_1(t,e)}.high.lessThan(long_1.ZERO)&&g.push("-"),(i=e>>26&COMBINATION_MASK)>>3==3){if(i===COMBINATION_INFINITY)return g.join("")+"Infinity";if(i===COMBINATION_NAN)return"NaN";o=e>>15&EXPONENT_MASK,l=8+(e>>14&1)}else l=e>>14&7,o=e>>17&EXPONENT_MASK;if(f=o-EXPONENT_BIAS,_.parts[0]=(16383&e)+((15&l)<<14),_.parts[1]=t,_.parts[2]=n,_.parts[3]=r,0===_.parts[0]&&0===_.parts[1]&&0===_.parts[2]&&0===_.parts[3])y=!0;else for(p=3;p>=0;p--){var m=0,w=divideu128(_);if(_=w.quotient,m=w.rem.low)for(h=8;h>=0;h--)u[9*p+h]=m%10,m=Math.floor(m/10)}if(y)s=1,u[d]=0;else for(s=36;!u[d];)s-=1,d+=1;if((c=s-1+f)>=34||c<=-7||f>0){if(s>34)return g.push(0),f>0?g.push("E+"+f):f<0&&g.push("E"+f),g.join("");g.push(u[d++]),(s-=1)&&g.push(".");for(var v=0;v<s;v++)g.push(u[d++]);g.push("E"),c>0?g.push("+"+c):g.push(c)}else if(f>=0)for(var E=0;E<s;E++)g.push(u[d++]);else{var N=s+f;if(N>0)for(var O=0;O<N;O++)g.push(u[d++]);else g.push("0");for(g.push(".");N++<0;)g.push("0");for(var S=0;S<s-Math.max(N-1,0);S++)g.push(u[d++])}return g.join("")},Decimal128.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},Decimal128.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},Decimal128.fromExtendedJSON=function(e){return Decimal128.fromString(e.$numberDecimal)},Object.defineProperty(Decimal128.prototype,"_bsontype",{value:"Decimal128"});var decimal128=Decimal128;function _classCallCheck$7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$7(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$7(e,t,n){return t&&_defineProperties$7(e.prototype,t),n&&_defineProperties$7(e,n),e}var MinKey=function(){function e(){_classCallCheck$7(this,e)}return _createClass$7(e,[{key:"toExtendedJSON",value:function(){return{$minKey:1}}}],[{key:"fromExtendedJSON",value:function(){return new e}}]),e}();Object.defineProperty(MinKey.prototype,"_bsontype",{value:"MinKey"});var min_key=MinKey;function _classCallCheck$8(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$8(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$8(e,t,n){return t&&_defineProperties$8(e.prototype,t),n&&_defineProperties$8(e,n),e}var MaxKey=function(){function e(){_classCallCheck$8(this,e)}return _createClass$8(e,[{key:"toExtendedJSON",value:function(){return{$maxKey:1}}}],[{key:"fromExtendedJSON",value:function(){return new e}}]),e}();Object.defineProperty(MaxKey.prototype,"_bsontype",{value:"MaxKey"});var max_key=MaxKey;function _classCallCheck$9(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$9(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$9(e,t,n){return t&&_defineProperties$9(e.prototype,t),n&&_defineProperties$9(e,n),e}var DBRef=function(){function e(t,n,r,i){_classCallCheck$9(this,e);var o=t.split(".");2===o.length&&(r=o.shift(),t=o.shift()),this.collection=t,this.oid=n,this.db=r,this.fields=i||{}}return _createClass$9(e,[{key:"toJSON",value:function(){var e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e}},{key:"toExtendedJSON",value:function(e){e=e||{};var t={$ref:this.collection,$id:this.oid};return e.legacy?t:(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields))}}],[{key:"fromExtendedJSON",value:function(t){var n=Object.assign({},t);return["$ref","$id","$db"].forEach((function(e){return delete n[e]})),new e(t.$ref,t.$id,t.$db,n)}}]),e}();Object.defineProperty(DBRef.prototype,"_bsontype",{value:"DBRef"}),Object.defineProperty(DBRef.prototype,"namespace",{get:function(){return this.collection},set:function(e){this.collection=e},configurable:!1});var db_ref=DBRef;function _classCallCheck$a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties$a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _createClass$a(e,t,n){return t&&_defineProperties$a(e.prototype,t),n&&_defineProperties$a(e,n),e}var Buffer$3=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,Binary=function(){function e(t,n){if(_classCallCheck$a(this,e),!(null==t||"string"==typeof t||Buffer$3.isBuffer(t)||t instanceof Uint8Array||Array.isArray(t)))throw new TypeError("only String, Buffer, Uint8Array or Array accepted");if(this.sub_type=null==n?BSON_BINARY_SUBTYPE_DEFAULT:n,this.position=0,null==t||t instanceof Number)void 0!==Buffer$3?this.buffer=Buffer$3.alloc(e.BUFFER_SIZE):"undefined"!=typeof Uint8Array?this.buffer=new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE)):this.buffer=new Array(e.BUFFER_SIZE);else{if("string"==typeof t)if(void 0!==Buffer$3)this.buffer=Buffer$3.from(t);else{if("undefined"==typeof Uint8Array&&!Array.isArray(t))throw new TypeError("only String, Buffer, Uint8Array or Array accepted");this.buffer=writeStringToArray(t)}else this.buffer=t;this.position=t.length}}return _createClass$a(e,[{key:"put",value:function(t){if(null!=t.length&&"number"!=typeof t&&1!==t.length)throw new TypeError("only accepts single character String, Uint8Array or Array");if("number"!=typeof t&&t<0||t>255)throw new TypeError("only accepts number in a valid unsigned byte range 0-255");var n=null;if(n="string"==typeof t?t.charCodeAt(0):null!=t.length?t[0]:t,this.buffer.length>this.position)this.buffer[this.position++]=n;else if(void 0!==Buffer$3&&Buffer$3.isBuffer(this.buffer)){var r=Buffer$3.alloc(e.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}else{var i=null;i=isUint8Array(this.buffer)?new Uint8Array(new ArrayBuffer(e.BUFFER_SIZE+this.buffer.length)):new Array(e.BUFFER_SIZE+this.buffer.length);for(var o=0;o<this.buffer.length;o++)i[o]=this.buffer[o];this.buffer=i,this.buffer[this.position++]=n}}},{key:"write",value:function(e,t){if(t="number"==typeof t?t:this.position,this.buffer.length<t+e.length){var n=null;if(void 0!==Buffer$3&&Buffer$3.isBuffer(this.buffer))n=Buffer$3.alloc(this.buffer.length+e.length),this.buffer.copy(n,0,0,this.buffer.length);else if(isUint8Array(this.buffer)){n=new Uint8Array(new ArrayBuffer(this.buffer.length+e.length));for(var r=0;r<this.position;r++)n[r]=this.buffer[r]}this.buffer=n}if(void 0!==Buffer$3&&Buffer$3.isBuffer(e)&&Buffer$3.isBuffer(this.buffer))e.copy(this.buffer,t,0,e.length),this.position=t+e.length>this.position?t+e.length:this.position;else if(void 0!==Buffer$3&&"string"==typeof e&&Buffer$3.isBuffer(this.buffer))this.buffer.write(e,t,"binary"),this.position=t+e.length>this.position?t+e.length:this.position;else if(isUint8Array(e)||Array.isArray(e)&&"string"!=typeof e){for(var i=0;i<e.length;i++)this.buffer[t++]=e[i];this.position=t>this.position?t:this.position}else if("string"==typeof e){for(var o=0;o<e.length;o++)this.buffer[t++]=e.charCodeAt(o);this.position=t>this.position?t:this.position}}},{key:"read",value:function(e,t){if(t=t&&t>0?t:this.position,this.buffer.slice)return this.buffer.slice(e,e+t);for(var n="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(t)):new Array(t),r=0;r<t;r++)n[r]=this.buffer[e++];return n}},{key:"value",value:function(e){if((e=null!=e&&e)&&void 0!==Buffer$3&&Buffer$3.isBuffer(this.buffer)&&this.buffer.length===this.position)return this.buffer;if(void 0!==Buffer$3&&Buffer$3.isBuffer(this.buffer))return e?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position);if(e){if(null!=this.buffer.slice)return this.buffer.slice(0,this.position);for(var t=isUint8Array(this.buffer)?new Uint8Array(new ArrayBuffer(this.position)):new Array(this.position),n=0;n<this.position;n++)t[n]=this.buffer[n];return t}return convertArraytoUtf8BinaryString(this.buffer,0,this.position)}},{key:"length",value:function(){return this.position}},{key:"toJSON",value:function(){return null!=this.buffer?this.buffer.toString("base64"):""}},{key:"toString",value:function(e){return null!=this.buffer?this.buffer.slice(0,this.position).toString(e):""}},{key:"toExtendedJSON",value:function(e){e=e||{};var t=Buffer$3.isBuffer(this.buffer)?this.buffer.toString("base64"):Buffer$3.from(this.buffer).toString("base64"),n=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===n.length?"0"+n:n}:{$binary:{base64:t,subType:1===n.length?"0"+n:n}}}}],[{key:"fromExtendedJSON",value:function(t,n){var r,i;return(n=n||{}).legacy?(i=t.$type?parseInt(t.$type,16):0,r=Buffer$3.from(t.$binary,"base64")):(i=t.$binary.subType?parseInt(t.$binary.subType,16):0,r=Buffer$3.from(t.$binary.base64,"base64")),new e(r,i)}}]),e}(),BSON_BINARY_SUBTYPE_DEFAULT=0;function isUint8Array(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function writeStringToArray(e){for(var t="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(e.length)):new Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function convertArraytoUtf8BinaryString(e,t,n){for(var r="",i=t;i<n;i++)r+=String.fromCharCode(e[i]);return r}Binary.BUFFER_SIZE=256,Binary.SUBTYPE_DEFAULT=0,Binary.SUBTYPE_FUNCTION=1,Binary.SUBTYPE_BYTE_ARRAY=2,Binary.SUBTYPE_UUID_OLD=3,Binary.SUBTYPE_UUID=4,Binary.SUBTYPE_MD5=5,Binary.SUBTYPE_USER_DEFINED=128,Object.defineProperty(Binary.prototype,"_bsontype",{value:"Binary"});var binary=Binary,constants={BSON_INT32_MAX:2147483647,BSON_INT32_MIN:-2147483648,BSON_INT64_MAX:Math.pow(2,63)-1,BSON_INT64_MIN:-Math.pow(2,63),JS_INT_MAX:9007199254740992,JS_INT_MIN:-9007199254740992,BSON_DATA_NUMBER:1,BSON_DATA_STRING:2,BSON_DATA_OBJECT:3,BSON_DATA_ARRAY:4,BSON_DATA_BINARY:5,BSON_DATA_UNDEFINED:6,BSON_DATA_OID:7,BSON_DATA_BOOLEAN:8,BSON_DATA_DATE:9,BSON_DATA_NULL:10,BSON_DATA_REGEXP:11,BSON_DATA_DBPOINTER:12,BSON_DATA_CODE:13,BSON_DATA_SYMBOL:14,BSON_DATA_CODE_W_SCOPE:15,BSON_DATA_INT:16,BSON_DATA_TIMESTAMP:17,BSON_DATA_LONG:18,BSON_DATA_DECIMAL128:19,BSON_DATA_MIN_KEY:255,BSON_DATA_MAX_KEY:127,BSON_BINARY_SUBTYPE_DEFAULT:0,BSON_BINARY_SUBTYPE_FUNCTION:1,BSON_BINARY_SUBTYPE_BYTE_ARRAY:2,BSON_BINARY_SUBTYPE_UUID:3,BSON_BINARY_SUBTYPE_MD5:4,BSON_BINARY_SUBTYPE_USER_DEFINED:128};function _typeof$2(e){return(_typeof$2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var keysToCodecs={$oid:objectid,$binary:binary,$symbol:symbol,$numberInt:int_32,$numberDecimal:decimal128,$numberDouble:double_1,$numberLong:long_1,$minKey:min_key,$maxKey:max_key,$regex:regexp,$regularExpression:regexp,$timestamp:timestamp};function deserializeValue(e,t,n,r){if("number"==typeof n){if(r.relaxed||r.legacy)return n;if(Math.floor(n)===n){if(n>=BSON_INT32_MIN&&n<=BSON_INT32_MAX)return new int_32(n);if(n>=BSON_INT64_MIN&&n<=BSON_INT64_MAX)return new long_1.fromNumber(n)}return new double_1(n)}if(null==n||"object"!==_typeof$2(n))return n;if(n.$undefined)return null;for(var i=Object.keys(n).filter((function(e){return e.startsWith("$")&&null!=n[e]})),o=0;o<i.length;o++){var s=keysToCodecs[i[o]];if(s)return s.fromExtendedJSON(n,r)}if(null!=n.$date){var u=n.$date,a=new Date;return r.legacy?"number"==typeof u?a.setTime(u):"string"==typeof u&&a.setTime(Date.parse(u)):"string"==typeof u?a.setTime(Date.parse(u)):long_1.isLong(u)?a.setTime(u.toNumber()):"number"==typeof u&&r.relaxed&&a.setTime(u),a}if(null!=n.$code){var f=Object.assign({},n);return n.$scope&&(f.$scope=deserializeValue(e,null,n.$scope)),code.fromExtendedJSON(n)}if(null!=n.$ref||null!=n.$dbPointer){var c=n.$ref?n:n.$dbPointer;if(c instanceof db_ref)return c;var l=Object.keys(c).filter((function(e){return e.startsWith("$")})),h=!0;if(l.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(h=!1)})),h)return db_ref.fromExtendedJSON(c)}return n}function parse(e,t){var n=this;return"boolean"==typeof(t=Object.assign({},{relaxed:!0,legacy:!1},t)).relaxed&&(t.strict=!t.relaxed),"boolean"==typeof t.strict&&(t.relaxed=!t.strict),JSON.parse(e,(function(e,r){return deserializeValue(n,e,r,t)}))}var BSON_INT32_MAX=2147483647,BSON_INT32_MIN=-2147483648,BSON_INT64_MAX=0x8000000000000000,BSON_INT64_MIN=-0x8000000000000000;function stringify(e,t,n,r){null!=n&&"object"===_typeof$2(n)&&(r=n,n=0),null==t||"object"!==_typeof$2(t)||Array.isArray(t)||(r=t,t=null,n=0),r=Object.assign({},{relaxed:!0,legacy:!1},r);var i=Array.isArray(e)?serializeArray(e,r):serializeDocument(e,r);return JSON.stringify(i,t,n)}function serialize(e,t){return t=t||{},JSON.parse(stringify(e,t))}function deserialize(e,t){return t=t||{},parse(JSON.stringify(e),t)}function serializeArray(e,t){return e.map((function(e){return serializeValue(e,t)}))}function getISOString(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function serializeValue(e,t){if(Array.isArray(e))return serializeArray(e,t);if(void 0===e)return null;if(e instanceof Date){var n=e.getTime(),r=n>-1&&n<2534023188e5;return t.legacy?t.relaxed&&r?{$date:e.getTime()}:{$date:getISOString(e)}:t.relaxed&&r?{$date:getISOString(e)}:{$date:{$numberLong:e.getTime().toString()}}}if("number"==typeof e&&!t.relaxed){if(Math.floor(e)===e){var i=e>=BSON_INT64_MIN&&e<=BSON_INT64_MAX;if(e>=BSON_INT32_MIN&&e<=BSON_INT32_MAX)return{$numberInt:e.toString()};if(i)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}if(e instanceof RegExp){var o=e.flags;return void 0===o&&(o=e.toString().match(/[gimuy]*$/)[0]),new regexp(e.source,o).toExtendedJSON(t)}return null!=e&&"object"===_typeof$2(e)?serializeDocument(e,t):e}var BSON_TYPE_MAPPINGS={Binary:function(e){return new binary(e.value(),e.subtype)},Code:function(e){return new code(e.code,e.scope)},DBRef:function(e){return new db_ref(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new decimal128(e.bytes)},Double:function(e){return new double_1(e.value)},Int32:function(e){return new int_32(e.value)},Long:function(e){return long_1.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_)},MaxKey:function(){return new max_key},MinKey:function(){return new min_key},ObjectID:function(e){return new objectid(e)},ObjectId:function(e){return new objectid(e)},BSONRegExp:function(e){return new regexp(e.pattern,e.options)},Symbol:function(e){return new symbol(e.value)},Timestamp:function(e){return timestamp.fromBits(e.low,e.high)}};function serializeDocument(e,t){if(null==e||"object"!==_typeof$2(e))throw new Error("not an object instance");var n=e._bsontype;if(void 0===n){var r={};for(var i in e)r[i]=serializeValue(e[i],t);return r}if("string"==typeof n){var o=e;if("function"!=typeof o.toExtendedJSON){var s=BSON_TYPE_MAPPINGS[n];if(!s)throw new TypeError("Unrecognized or invalid _bsontype: "+n);o=s(o)}return"Code"===n&&o.scope?o=new code(o.code,serializeValue(o.scope,t)):"DBRef"===n&&o.oid&&(o=new db_ref(o.collection,serializeValue(o.oid,t),o.db,o.fields)),o.toExtendedJSON(t)}throw new Error("_bsontype must be a string, but was: "+_typeof$2(n))}var extended_json={parse:parse,deserialize:deserialize,serialize:serialize,stringify:stringify},FIRST_BIT=128,FIRST_TWO_BITS=192,FIRST_THREE_BITS=224,FIRST_FOUR_BITS=240,FIRST_FIVE_BITS=248,TWO_BIT_CHAR=192,THREE_BIT_CHAR=224,FOUR_BIT_CHAR=240,CONTINUING_CHAR=128;function validateUtf8(e,t,n){for(var r=0,i=t;i<n;i+=1){var o=e[i];if(r){if((o&FIRST_TWO_BITS)!==CONTINUING_CHAR)return!1;r-=1}else if(o&FIRST_BIT)if((o&FIRST_THREE_BITS)===TWO_BIT_CHAR)r=1;else if((o&FIRST_FOUR_BITS)===THREE_BIT_CHAR)r=2;else{if((o&FIRST_FIVE_BITS)!==FOUR_BIT_CHAR)return!1;r=3}}return!r}var validateUtf8_1=validateUtf8,validate_utf8={validateUtf8:validateUtf8_1},Buffer$4=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,validateUtf8$1=validate_utf8.validateUtf8,JS_INT_MAX_LONG=long_1.fromNumber(constants.JS_INT_MAX),JS_INT_MIN_LONG=long_1.fromNumber(constants.JS_INT_MIN),functionCache={};function deserialize$1(e,t,n){var r=(t=null==t?{}:t)&&t.index?t.index:0,i=e[r]|e[r+1]<<8|e[r+2]<<16|e[r+3]<<24;if(i<5)throw new Error("bson size must be >= 5, is ".concat(i));if(t.allowObjectSmallerThanBufferSize&&e.length<i)throw new Error("buffer length ".concat(e.length," must be >= bson size ").concat(i));if(!t.allowObjectSmallerThanBufferSize&&e.length!==i)throw new Error("buffer length ".concat(e.length," must === bson size ").concat(i));if(i+r>e.length)throw new Error("(bson size ".concat(i," + options.index ").concat(r," must be <= buffer length ").concat(Buffer$4.byteLength(e),")"));if(0!==e[r+i-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return deserializeObject(e,r,t,n)}function deserializeObject(e,t,n,r){var i=null!=n.evalFunctions&&n.evalFunctions,o=null!=n.cacheFunctions&&n.cacheFunctions,s=null!=n.cacheFunctionsCrc32&&n.cacheFunctionsCrc32;if(!s)var u=null;var a=null==n.fieldsAsRaw?null:n.fieldsAsRaw,f=null!=n.raw&&n.raw,c="boolean"==typeof n.bsonRegExp&&n.bsonRegExp,l=null!=n.promoteBuffers&&n.promoteBuffers,h=null==n.promoteLongs||n.promoteLongs,p=null==n.promoteValues||n.promoteValues,d=t;if(e.length<5)throw new Error("corrupt bson message < 5 bytes long");var y=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(y<5||y>e.length)throw new Error("corrupt bson message");for(var _=r?[]:{},g=0;;){var b=e[t++];if(0===b)break;for(var m=t;0!==e[m]&&m<e.length;)m++;if(m>=Buffer$4.byteLength(e))throw new Error("Bad BSON Document: illegal CString");var w=r?g++:e.toString("utf8",t,m);if(t=m+1,b===constants.BSON_DATA_STRING){var v=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(v<=0||v>e.length-t||0!==e[t+v-1])throw new Error("bad string length in bson");if(!validateUtf8$1(e,t,t+v-1))throw new Error("Invalid UTF-8 string in BSON document");var E=e.toString("utf8",t,t+v-1);_[w]=E,t+=v}else if(b===constants.BSON_DATA_OID){var N=Buffer$4.alloc(12);e.copy(N,0,t,t+12),_[w]=new objectid(N),t+=12}else if(b===constants.BSON_DATA_INT&&!1===p)_[w]=new int_32(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(b===constants.BSON_DATA_INT)_[w]=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(b===constants.BSON_DATA_NUMBER&&!1===p)_[w]=new double_1(e.readDoubleLE(t)),t+=8;else if(b===constants.BSON_DATA_NUMBER)_[w]=e.readDoubleLE(t),t+=8;else if(b===constants.BSON_DATA_DATE){var O=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,S=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;_[w]=new Date(new long_1(O,S).toNumber())}else if(b===constants.BSON_DATA_BOOLEAN){if(0!==e[t]&&1!==e[t])throw new Error("illegal boolean type value");_[w]=1===e[t++]}else if(b===constants.BSON_DATA_OBJECT){var A=t,T=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(T<=0||T>e.length-t)throw new Error("bad embedded document length in bson");_[w]=f?e.slice(t,t+T):deserializeObject(e,A,n,!1),t+=T}else if(b===constants.BSON_DATA_ARRAY){var B=t,I=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,D=n,P=t+I;if(a&&a[w]){for(var $ in D={},n)D[$]=n[$];D.raw=!0}if(_[w]=deserializeObject(e,B,D,!0),0!==e[(t+=I)-1])throw new Error("invalid array terminator byte");if(t!==P)throw new Error("corrupted array bson")}else if(b===constants.BSON_DATA_UNDEFINED)_[w]=void 0;else if(b===constants.BSON_DATA_NULL)_[w]=null;else if(b===constants.BSON_DATA_LONG){var R=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,x=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,M=new long_1(R,x);_[w]=h&&!0===p&&M.lessThanOrEqual(JS_INT_MAX_LONG)&&M.greaterThanOrEqual(JS_INT_MIN_LONG)?M.toNumber():M}else if(b===constants.BSON_DATA_DECIMAL128){var C=Buffer$4.alloc(16);e.copy(C,0,t,t+16),t+=16;var U=new decimal128(C);_[w]=U.toObject?U.toObject():U}else if(b===constants.BSON_DATA_BINARY){var j=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,L=j,z=e[t++];if(j<0)throw new Error("Negative binary type element size found");if(j>Buffer$4.byteLength(e))throw new Error("Binary type size larger than document size");if(null!=e.slice){if(z===binary.SUBTYPE_BYTE_ARRAY){if((j=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(j>L-4)throw new Error("Binary type with subtype 0x02 contains to long binary size");if(j<L-4)throw new Error("Binary type with subtype 0x02 contains to short binary size")}_[w]=l&&p?e.slice(t,t+j):new binary(e.slice(t,t+j),z)}else{var k="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(j)):new Array(j);if(z===binary.SUBTYPE_BYTE_ARRAY){if((j=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(j>L-4)throw new Error("Binary type with subtype 0x02 contains to long binary size");if(j<L-4)throw new Error("Binary type with subtype 0x02 contains to short binary size")}for(m=0;m<j;m++)k[m]=e[t+m];_[w]=l&&p?k:new binary(k,z)}t+=j}else if(b===constants.BSON_DATA_REGEXP&&!1===c){for(m=t;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var F=e.toString("utf8",t,m);for(m=t=m+1;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var q=e.toString("utf8",t,m);t=m+1;var Y=new Array(q.length);for(m=0;m<q.length;m++)switch(q[m]){case"m":Y[m]="m";break;case"s":Y[m]="g";break;case"i":Y[m]="i"}_[w]=new RegExp(F,Y.join(""))}else if(b===constants.BSON_DATA_REGEXP&&!0===c){for(m=t;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var J=e.toString("utf8",t,m);for(m=t=m+1;0!==e[m]&&m<e.length;)m++;if(m>=e.length)throw new Error("Bad BSON Document: illegal CString");var G=e.toString("utf8",t,m);t=m+1,_[w]=new regexp(J,G)}else if(b===constants.BSON_DATA_SYMBOL){var X=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(X<=0||X>e.length-t||0!==e[t+X-1])throw new Error("bad string length in bson");var H=e.toString("utf8",t,t+X-1);_[w]=p?H:new symbol(H),t+=X}else if(b===constants.BSON_DATA_TIMESTAMP){var K=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,W=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;_[w]=new timestamp(K,W)}else if(b===constants.BSON_DATA_MIN_KEY)_[w]=new min_key;else if(b===constants.BSON_DATA_MAX_KEY)_[w]=new max_key;else if(b===constants.BSON_DATA_CODE){var V=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(V<=0||V>e.length-t||0!==e[t+V-1])throw new Error("bad string length in bson");var Q=e.toString("utf8",t,t+V-1);if(i)if(o){var Z=s?u(Q):Q;_[w]=isolateEvalWithHash(functionCache,Z,Q,_)}else _[w]=isolateEval(Q);else _[w]=new code(Q);t+=V}else if(b===constants.BSON_DATA_CODE_W_SCOPE){var ee=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(ee<13)throw new Error("code_w_scope total size shorter minimum expected length");var te=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(te<=0||te>e.length-t||0!==e[t+te-1])throw new Error("bad string length in bson");var ne=e.toString("utf8",t,t+te-1),re=t+=te,ie=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,oe=deserializeObject(e,re,n,!1);if(t+=ie,ee<8+ie+te)throw new Error("code_w_scope total size is to short, truncating scope");if(ee>8+ie+te)throw new Error("code_w_scope total size is to long, clips outer document");if(i){if(o){var se=s?u(ne):ne;_[w]=isolateEvalWithHash(functionCache,se,ne,_)}else _[w]=isolateEval(ne);_[w].scope=oe}else _[w]=new code(ne,oe)}else{if(b!==constants.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+b.toString(16)+' for fieldname "'+w+'", are you using the latest BSON parser?');var ue=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(ue<=0||ue>e.length-t||0!==e[t+ue-1])throw new Error("bad string length in bson");if(!validateUtf8$1(e,t,t+ue-1))throw new Error("Invalid UTF-8 string in BSON document");var ae=e.toString("utf8",t,t+ue-1);t+=ue;var fe=Buffer$4.alloc(12);e.copy(fe,0,t,t+12);var ce=new objectid(fe);t+=12,_[w]=new db_ref(ae,ce)}}if(y!==t-d){if(r)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}var le=Object.keys(_).filter((function(e){return e.startsWith("$")})),he=!0;if(le.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(he=!1)})),!he)return _;if(null!=_.$id&&null!=_.$ref){var pe=Object.assign({},_);return delete pe.$ref,delete pe.$id,delete pe.$db,new db_ref(_.$ref,_.$id,_.$db||null,pe)}return _}function isolateEvalWithHash(functionCache,hash,functionString,object){var value=null;return null==functionCache[hash]&&(eval("value = "+functionString),functionCache[hash]=value),functionCache[hash].bind(object)}function isolateEval(functionString){var value=null;return eval("value = "+functionString),value}var deserializer=deserialize$1;function readIEEE754(e,t,n,r,i){var o,s,u="big"===n,a=8*i-r-1,f=(1<<a)-1,c=f>>1,l=-7,h=u?0:i-1,p=u?1:-1,d=e[t+h];for(h+=p,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+e[t+h],h+=p,l-=8);if(0===o)o=1-c;else{if(o===f)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)}function writeIEEE754(e,t,n,r,i,o){var s,u,a,f="big"===r,c=8*o-i-1,l=(1<<c)-1,h=l>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=f?o-1:0,y=f?-1:1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+h>=1?p/a:p*Math.pow(2,1-h))*a>=2&&(s++,a/=2),s+h>=l?(u=0,s=l):s+h>=1?(u=(t*a-1)*Math.pow(2,i),s+=h):(u=t*Math.pow(2,h-1)*Math.pow(2,i),s=0)),isNaN(t)&&(u=0);i>=8;)e[n+d]=255&u,d+=y,u/=256,i-=8;for(s=s<<i|u,isNaN(t)&&(s+=8),c+=i;c>0;)e[n+d]=255&s,d+=y,s/=256,c-=8;e[n+d-y]|=128*_}var float_parser={readIEEE754:readIEEE754,writeIEEE754:writeIEEE754};function _typeof$3(e){return(_typeof$3="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var Buffer$5=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,writeIEEE754$1=float_parser.writeIEEE754,normalizedFunctionString$1=utils.normalizedFunctionString,regexp$1=/\x00/,ignoreKeys=new Set(["$db","$ref","$id","$clusterTime"]),isDate$1=function(e){return"object"===_typeof$3(e)&&"[object Date]"===Object.prototype.toString.call(e)},isRegExp$1=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)};function serializeString(e,t,n,r,i){e[r++]=constants.BSON_DATA_STRING;var o=i?e.write(t,r,"ascii"):e.write(t,r,"utf8");e[(r=r+o+1)-1]=0;var s=e.write(n,r+4,"utf8");return e[r+3]=s+1>>24&255,e[r+2]=s+1>>16&255,e[r+1]=s+1>>8&255,e[r]=s+1&255,r=r+4+s,e[r++]=0,r}function serializeNumber(e,t,n,r,i){if(Math.floor(n)===n&&n>=constants.JS_INT_MIN&&n<=constants.JS_INT_MAX)if(n>=constants.BSON_INT32_MIN&&n<=constants.BSON_INT32_MAX)e[r++]=constants.BSON_DATA_INT,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255;else if(n>=constants.JS_INT_MIN&&n<=constants.JS_INT_MAX){e[r++]=constants.BSON_DATA_NUMBER,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,writeIEEE754$1(e,n,r,"little",52,8),r+=8}else{e[r++]=constants.BSON_DATA_LONG,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=long_1.fromNumber(n),s=o.getLowBits(),u=o.getHighBits();e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=255&u,e[r++]=u>>8&255,e[r++]=u>>16&255,e[r++]=u>>24&255}else e[r++]=constants.BSON_DATA_NUMBER,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,writeIEEE754$1(e,n,r,"little",52,8),r+=8;return r}function serializeNull(e,t,n,r,i){return e[r++]=constants.BSON_DATA_NULL,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,r}function serializeBoolean(e,t,n,r,i){return e[r++]=constants.BSON_DATA_BOOLEAN,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=n?1:0,r}function serializeDate(e,t,n,r,i){e[r++]=constants.BSON_DATA_DATE,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=long_1.fromNumber(n.getTime()),s=o.getLowBits(),u=o.getHighBits();return e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=255&u,e[r++]=u>>8&255,e[r++]=u>>16&255,e[r++]=u>>24&255,r}function serializeRegExp(e,t,n,r,i){if(e[r++]=constants.BSON_DATA_REGEXP,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,n.source&&null!=n.source.match(regexp$1))throw Error("value "+n.source+" must not contain null bytes");return r+=e.write(n.source,r,"utf8"),e[r++]=0,n.ignoreCase&&(e[r++]=105),n.global&&(e[r++]=115),n.multiline&&(e[r++]=109),e[r++]=0,r}function serializeBSONRegExp(e,t,n,r,i){if(e[r++]=constants.BSON_DATA_REGEXP,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,null!=n.pattern.match(regexp$1))throw Error("pattern "+n.pattern+" must not contain null bytes");return r+=e.write(n.pattern,r,"utf8"),e[r++]=0,r+=e.write(n.options.split("").sort().join(""),r,"utf8"),e[r++]=0,r}function serializeMinMax(e,t,n,r,i){return null===n?e[r++]=constants.BSON_DATA_NULL:"MinKey"===n._bsontype?e[r++]=constants.BSON_DATA_MIN_KEY:e[r++]=constants.BSON_DATA_MAX_KEY,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,r}function serializeObjectId(e,t,n,r,i){if(e[r++]=constants.BSON_DATA_OID,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,"string"==typeof n.id)e.write(n.id,r,"binary");else{if(!n.id||!n.id.copy)throw new TypeError("object ["+JSON.stringify(n)+"] is not a valid ObjectId");n.id.copy(e,r,0,12)}return r+12}function serializeBuffer(e,t,n,r,i){e[r++]=constants.BSON_DATA_BINARY,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=n.length;return e[r++]=255&o,e[r++]=o>>8&255,e[r++]=o>>16&255,e[r++]=o>>24&255,e[r++]=constants.BSON_BINARY_SUBTYPE_DEFAULT,n.copy(e,r,0,o),r+=o}function serializeObject(e,t,n,r,i,o,s,u,a,f){for(var c=0;c<f.length;c++)if(f[c]===n)throw new Error("cyclic dependency detected");f.push(n),e[r++]=Array.isArray(n)?constants.BSON_DATA_ARRAY:constants.BSON_DATA_OBJECT,r+=a?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var l=serializeInto(e,n,i,r,o+1,s,u,f);return f.pop(),l}function serializeDecimal128(e,t,n,r,i){return e[r++]=constants.BSON_DATA_DECIMAL128,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,n.bytes.copy(e,r,0,16),r+16}function serializeLong(e,t,n,r,i){e[r++]="Long"===n._bsontype?constants.BSON_DATA_LONG:constants.BSON_DATA_TIMESTAMP,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=n.getLowBits(),s=n.getHighBits();return e[r++]=255&o,e[r++]=o>>8&255,e[r++]=o>>16&255,e[r++]=o>>24&255,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,r}function serializeInt32(e,t,n,r,i){return e[r++]=constants.BSON_DATA_INT,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255,r}function serializeDouble(e,t,n,r,i){return e[r++]=constants.BSON_DATA_NUMBER,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,writeIEEE754$1(e,n.value,r,"little",52,8),r+=8}function serializeFunction(e,t,n,r,i,o,s){e[r++]=constants.BSON_DATA_CODE,r+=s?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var u=normalizedFunctionString$1(n),a=e.write(u,r+4,"utf8")+1;return e[r]=255&a,e[r+1]=a>>8&255,e[r+2]=a>>16&255,e[r+3]=a>>24&255,r=r+4+a-1,e[r++]=0,r}function serializeCode(e,t,n,r,i,o,s,u,a){if(n.scope&&"object"===_typeof$3(n.scope)){e[r++]=constants.BSON_DATA_CODE_W_SCOPE,r+=a?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var f=r,c="string"==typeof n.code?n.code:n.code.toString();r+=4;var l=e.write(c,r+4,"utf8")+1;e[r]=255&l,e[r+1]=l>>8&255,e[r+2]=l>>16&255,e[r+3]=l>>24&255,e[r+4+l-1]=0,r=r+l+4;var h=serializeInto(e,n.scope,i,r,o+1,s,u);r=h-1;var p=h-f;e[f++]=255&p,e[f++]=p>>8&255,e[f++]=p>>16&255,e[f++]=p>>24&255,e[r++]=0}else{e[r++]=constants.BSON_DATA_CODE,r+=a?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var d=n.code.toString(),y=e.write(d,r+4,"utf8")+1;e[r]=255&y,e[r+1]=y>>8&255,e[r+2]=y>>16&255,e[r+3]=y>>24&255,r=r+4+y-1,e[r++]=0}return r}function serializeBinary(e,t,n,r,i){e[r++]=constants.BSON_DATA_BINARY,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=n.value(!0),s=n.position;return n.sub_type===binary.SUBTYPE_BYTE_ARRAY&&(s+=4),e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=n.sub_type,n.sub_type===binary.SUBTYPE_BYTE_ARRAY&&(s-=4,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255),o.copy(e,r,0,n.position),r+=n.position}function serializeSymbol(e,t,n,r,i){e[r++]=constants.BSON_DATA_SYMBOL,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var o=e.write(n.value,r+4,"utf8")+1;return e[r]=255&o,e[r+1]=o>>8&255,e[r+2]=o>>16&255,e[r+3]=o>>24&255,r=r+4+o-1,e[r++]=0,r}function serializeDBRef(e,t,n,r,i,o,s){e[r++]=constants.BSON_DATA_OBJECT,r+=s?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var u,a=r,f={$ref:n.collection||n.namespace,$id:n.oid};null!=n.db&&(f.$db=n.db);var c=(u=serializeInto(e,f=Object.assign(f,n.fields),!1,r,i+1,o))-a;return e[a++]=255&c,e[a++]=c>>8&255,e[a++]=c>>16&255,e[a++]=c>>24&255,u}function serializeInto(e,t,n,r,i,o,s,u){r=r||0,(u=u||[]).push(t);var a=r+4;if(Array.isArray(t))for(var f=0;f<t.length;f++){var c=""+f,l=t[f];if(l&&l.toBSON){if("function"!=typeof l.toBSON)throw new TypeError("toBSON is not a function");l=l.toBSON()}var h=_typeof$3(l);if("string"===h)a=serializeString(e,c,l,a,!0);else if("number"===h)a=serializeNumber(e,c,l,a,!0);else if("boolean"===h)a=serializeBoolean(e,c,l,a,!0);else if(l instanceof Date||isDate$1(l))a=serializeDate(e,c,l,a,!0);else if(void 0===l)a=serializeNull(e,c,l,a,!0);else if(null===l)a=serializeNull(e,c,l,a,!0);else if("ObjectId"===l._bsontype||"ObjectID"===l._bsontype)a=serializeObjectId(e,c,l,a,!0);else if(Buffer$5.isBuffer(l))a=serializeBuffer(e,c,l,a,!0);else if(l instanceof RegExp||isRegExp$1(l))a=serializeRegExp(e,c,l,a,!0);else if("object"===h&&null==l._bsontype)a=serializeObject(e,c,l,a,n,i,o,s,!0,u);else if("object"===h&&"Decimal128"===l._bsontype)a=serializeDecimal128(e,c,l,a,!0);else if("Long"===l._bsontype||"Timestamp"===l._bsontype)a=serializeLong(e,c,l,a,!0);else if("Double"===l._bsontype)a=serializeDouble(e,c,l,a,!0);else if("function"==typeof l&&o)a=serializeFunction(e,c,l,a,n,i,o,!0);else if("Code"===l._bsontype)a=serializeCode(e,c,l,a,n,i,o,s,!0);else if("Binary"===l._bsontype)a=serializeBinary(e,c,l,a,!0);else if("Symbol"===l._bsontype)a=serializeSymbol(e,c,l,a,!0);else if("DBRef"===l._bsontype)a=serializeDBRef(e,c,l,a,i,o,!0);else if("BSONRegExp"===l._bsontype)a=serializeBSONRegExp(e,c,l,a,!0);else if("Int32"===l._bsontype)a=serializeInt32(e,c,l,a,!0);else if("MinKey"===l._bsontype||"MaxKey"===l._bsontype)a=serializeMinMax(e,c,l,a,!0);else if(void 0!==l._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+l._bsontype)}else if(t instanceof map)for(var p=t.entries(),d=!1;!d;){var y=p.next();if(!(d=y.done)){var _=y.value[0],g=y.value[1],b=_typeof$3(g);if("string"==typeof _&&!ignoreKeys.has(_)){if(null!=_.match(regexp$1))throw Error("key "+_+" must not contain null bytes");if(n){if("$"===_[0])throw Error("key "+_+" must not start with '$'");if(~_.indexOf("."))throw Error("key "+_+" must not contain '.'")}}if("string"===b)a=serializeString(e,_,g,a);else if("number"===b)a=serializeNumber(e,_,g,a);else if("boolean"===b)a=serializeBoolean(e,_,g,a);else if(g instanceof Date||isDate$1(g))a=serializeDate(e,_,g,a);else if(null===g||void 0===g&&!1===s)a=serializeNull(e,_,g,a);else if("ObjectId"===g._bsontype||"ObjectID"===g._bsontype)a=serializeObjectId(e,_,g,a);else if(Buffer$5.isBuffer(g))a=serializeBuffer(e,_,g,a);else if(g instanceof RegExp||isRegExp$1(g))a=serializeRegExp(e,_,g,a);else if("object"===b&&null==g._bsontype)a=serializeObject(e,_,g,a,n,i,o,s,!1,u);else if("object"===b&&"Decimal128"===g._bsontype)a=serializeDecimal128(e,_,g,a);else if("Long"===g._bsontype||"Timestamp"===g._bsontype)a=serializeLong(e,_,g,a);else if("Double"===g._bsontype)a=serializeDouble(e,_,g,a);else if("Code"===g._bsontype)a=serializeCode(e,_,g,a,n,i,o,s);else if("function"==typeof g&&o)a=serializeFunction(e,_,g,a,n,i,o);else if("Binary"===g._bsontype)a=serializeBinary(e,_,g,a);else if("Symbol"===g._bsontype)a=serializeSymbol(e,_,g,a);else if("DBRef"===g._bsontype)a=serializeDBRef(e,_,g,a,i,o);else if("BSONRegExp"===g._bsontype)a=serializeBSONRegExp(e,_,g,a);else if("Int32"===g._bsontype)a=serializeInt32(e,_,g,a);else if("MinKey"===g._bsontype||"MaxKey"===g._bsontype)a=serializeMinMax(e,_,g,a);else if(void 0!==g._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+g._bsontype)}}else{if(t.toBSON){if("function"!=typeof t.toBSON)throw new TypeError("toBSON is not a function");if(null!=(t=t.toBSON())&&"object"!==_typeof$3(t))throw new TypeError("toBSON function did not return an object")}for(var m in t){var w=t[m];if(w&&w.toBSON){if("function"!=typeof w.toBSON)throw new TypeError("toBSON is not a function");w=w.toBSON()}var v=_typeof$3(w);if("string"==typeof m&&!ignoreKeys.has(m)){if(null!=m.match(regexp$1))throw Error("key "+m+" must not contain null bytes");if(n){if("$"===m[0])throw Error("key "+m+" must not start with '$'");if(~m.indexOf("."))throw Error("key "+m+" must not contain '.'")}}if("string"===v)a=serializeString(e,m,w,a);else if("number"===v)a=serializeNumber(e,m,w,a);else if("boolean"===v)a=serializeBoolean(e,m,w,a);else if(w instanceof Date||isDate$1(w))a=serializeDate(e,m,w,a);else if(void 0===w)!1===s&&(a=serializeNull(e,m,w,a));else if(null===w)a=serializeNull(e,m,w,a);else if("ObjectId"===w._bsontype||"ObjectID"===w._bsontype)a=serializeObjectId(e,m,w,a);else if(Buffer$5.isBuffer(w))a=serializeBuffer(e,m,w,a);else if(w instanceof RegExp||isRegExp$1(w))a=serializeRegExp(e,m,w,a);else if("object"===v&&null==w._bsontype)a=serializeObject(e,m,w,a,n,i,o,s,!1,u);else if("object"===v&&"Decimal128"===w._bsontype)a=serializeDecimal128(e,m,w,a);else if("Long"===w._bsontype||"Timestamp"===w._bsontype)a=serializeLong(e,m,w,a);else if("Double"===w._bsontype)a=serializeDouble(e,m,w,a);else if("Code"===w._bsontype)a=serializeCode(e,m,w,a,n,i,o,s);else if("function"==typeof w&&o)a=serializeFunction(e,m,w,a,n,i,o);else if("Binary"===w._bsontype)a=serializeBinary(e,m,w,a);else if("Symbol"===w._bsontype)a=serializeSymbol(e,m,w,a);else if("DBRef"===w._bsontype)a=serializeDBRef(e,m,w,a,i,o);else if("BSONRegExp"===w._bsontype)a=serializeBSONRegExp(e,m,w,a);else if("Int32"===w._bsontype)a=serializeInt32(e,m,w,a);else if("MinKey"===w._bsontype||"MaxKey"===w._bsontype)a=serializeMinMax(e,m,w,a);else if(void 0!==w._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+w._bsontype)}}u.pop(),e[a++]=0;var E=a-r;return e[r++]=255&E,e[r++]=E>>8&255,e[r++]=E>>16&255,e[r++]=E>>24&255,a}var serializer=serializeInto;function _typeof$4(e){return(_typeof$4="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var Buffer$6=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,normalizedFunctionString$2=utils.normalizedFunctionString;function isDate$2(e){return"object"===_typeof$4(e)&&"[object Date]"===Object.prototype.toString.call(e)}function calculateObjectSize(e,t,n){var r=5;if(Array.isArray(e))for(var i=0;i<e.length;i++)r+=calculateElement(i.toString(),e[i],t,!0,n);else for(var o in e.toBSON&&(e=e.toBSON()),e)r+=calculateElement(o,e[o],t,!1,n);return r}function calculateElement(e,t,n,r,i){switch(t&&t.toBSON&&(t=t.toBSON()),_typeof$4(t)){case"string":return 1+Buffer$6.byteLength(e,"utf8")+1+4+Buffer$6.byteLength(t,"utf8")+1;case"number":return Math.floor(t)===t&&t>=constants.JS_INT_MIN&&t<=constants.JS_INT_MAX&&t>=constants.BSON_INT32_MIN&&t<=constants.BSON_INT32_MAX?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+5:(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+9;case"undefined":return r||!i?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1;if("ObjectId"===t._bsontype||"ObjectID"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||isDate$2(t))return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+9;if(void 0!==Buffer$6&&Buffer$6.isBuffer(t))return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+6+t.length;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+4+Buffer$6.byteLength(t.code.toString(),"utf8")+1+calculateObjectSize(t.scope,n,i):(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+Buffer$6.byteLength(t.code.toString(),"utf8")+1;if("Binary"===t._bsontype)return t.sub_type===binary.SUBTYPE_BYTE_ARRAY?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if("Symbol"===t._bsontype)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+Buffer$6.byteLength(t.value,"utf8")+4+1+1;if("DBRef"===t._bsontype){var o=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&&(o.$db=t.db),(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+calculateObjectSize(o,n,i)}return t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+Buffer$6.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+Buffer$6.byteLength(t.pattern,"utf8")+1+Buffer$6.byteLength(t.options,"utf8")+1:(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+calculateObjectSize(t,n,i)+1;case"function":if(t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)||"[object RegExp]"===String.call(t))return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+Buffer$6.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1;if(n&&null!=t.scope&&Object.keys(t.scope).length>0)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+4+Buffer$6.byteLength(normalizedFunctionString$2(t),"utf8")+1+calculateObjectSize(t.scope,n,i);if(n)return(null!=e?Buffer$6.byteLength(e,"utf8")+1:0)+1+4+Buffer$6.byteLength(normalizedFunctionString$2(t),"utf8")+1}return 0}var calculate_size=calculateObjectSize,Buffer$7=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,ensure_buffer=function(e){if(e instanceof Buffer$7)return e;if(e instanceof Uint8Array)return Buffer$7.from(e.buffer);throw new TypeError("Must use either Buffer or Uint8Array")},Buffer$8=buffer__WEBPACK_IMPORTED_MODULE_1___default.a.Buffer,MAXSIZE=17825792,buffer$1=Buffer$8.alloc(MAXSIZE);function setInternalBufferSize(e){buffer$1.length<e&&(buffer$1=Buffer$8.alloc(e))}function serialize$1(e,t){var n="boolean"==typeof(t=t||{}).checkKeys&&t.checkKeys,r="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,i="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,o="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:MAXSIZE;buffer$1.length<o&&(buffer$1=Buffer$8.alloc(o));var s=serializer(buffer$1,e,n,0,0,r,i,[]),u=Buffer$8.alloc(s);return buffer$1.copy(u,0,0,u.length),u}function serializeWithBufferAndIndex(e,t,n){var r="boolean"==typeof(n=n||{}).checkKeys&&n.checkKeys,i="boolean"==typeof n.serializeFunctions&&n.serializeFunctions,o="boolean"!=typeof n.ignoreUndefined||n.ignoreUndefined,s="number"==typeof n.index?n.index:0,u=serializer(buffer$1,e,r,0,0,i,o);return buffer$1.copy(t,s,0,u),s+u-1}function deserialize$2(e,t){return e=ensure_buffer(e),deserializer(e,t)}function calculateObjectSize$1(e,t){var n="boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,r="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined;return calculate_size(e,n,r)}function deserializeStream(e,t,n,r,i,o){o=Object.assign({allowObjectSmallerThanBufferSize:!0},o),e=ensure_buffer(e);for(var s=t,u=0;u<n;u++){var a=e[s]|e[s+1]<<8|e[s+2]<<16|e[s+3]<<24;o.index=s,r[i+u]=deserializer(e,o),s+=a}return s}var bson={BSON_INT32_MAX:constants.BSON_INT32_MAX,BSON_INT32_MIN:constants.BSON_INT32_MIN,BSON_INT64_MAX:constants.BSON_INT64_MAX,BSON_INT64_MIN:constants.BSON_INT64_MIN,JS_INT_MAX:constants.JS_INT_MAX,JS_INT_MIN:constants.JS_INT_MIN,BSON_DATA_NUMBER:constants.BSON_DATA_NUMBER,BSON_DATA_STRING:constants.BSON_DATA_STRING,BSON_DATA_OBJECT:constants.BSON_DATA_OBJECT,BSON_DATA_ARRAY:constants.BSON_DATA_ARRAY,BSON_DATA_BINARY:constants.BSON_DATA_BINARY,BSON_DATA_UNDEFINED:constants.BSON_DATA_UNDEFINED,BSON_DATA_OID:constants.BSON_DATA_OID,BSON_DATA_BOOLEAN:constants.BSON_DATA_BOOLEAN,BSON_DATA_DATE:constants.BSON_DATA_DATE,BSON_DATA_NULL:constants.BSON_DATA_NULL,BSON_DATA_REGEXP:constants.BSON_DATA_REGEXP,BSON_DATA_DBPOINTER:constants.BSON_DATA_DBPOINTER,BSON_DATA_CODE:constants.BSON_DATA_CODE,BSON_DATA_SYMBOL:constants.BSON_DATA_SYMBOL,BSON_DATA_CODE_W_SCOPE:constants.BSON_DATA_CODE_W_SCOPE,BSON_DATA_INT:constants.BSON_DATA_INT,BSON_DATA_TIMESTAMP:constants.BSON_DATA_TIMESTAMP,BSON_DATA_LONG:constants.BSON_DATA_LONG,BSON_DATA_DECIMAL128:constants.BSON_DATA_DECIMAL128,BSON_DATA_MIN_KEY:constants.BSON_DATA_MIN_KEY,BSON_DATA_MAX_KEY:constants.BSON_DATA_MAX_KEY,BSON_BINARY_SUBTYPE_DEFAULT:constants.BSON_BINARY_SUBTYPE_DEFAULT,BSON_BINARY_SUBTYPE_FUNCTION:constants.BSON_BINARY_SUBTYPE_FUNCTION,BSON_BINARY_SUBTYPE_BYTE_ARRAY:constants.BSON_BINARY_SUBTYPE_BYTE_ARRAY,BSON_BINARY_SUBTYPE_UUID:constants.BSON_BINARY_SUBTYPE_UUID,BSON_BINARY_SUBTYPE_MD5:constants.BSON_BINARY_SUBTYPE_MD5,BSON_BINARY_SUBTYPE_USER_DEFINED:constants.BSON_BINARY_SUBTYPE_USER_DEFINED,Code:code,Map:map,BSONSymbol:symbol,DBRef:db_ref,Binary:binary,ObjectId:objectid,Long:long_1,Timestamp:timestamp,Double:double_1,Int32:int_32,MinKey:min_key,MaxKey:max_key,BSONRegExp:regexp,Decimal128:decimal128,serialize:serialize$1,serializeWithBufferAndIndex:serializeWithBufferAndIndex,deserialize:deserialize$2,calculateObjectSize:calculateObjectSize$1,deserializeStream:deserializeStream,setInternalBufferSize:setInternalBufferSize,ObjectID:objectid,EJSON:extended_json},bson_1=bson.BSON_INT32_MAX,bson_2=bson.BSON_INT32_MIN,bson_3=bson.BSON_INT64_MAX,bson_4=bson.BSON_INT64_MIN,bson_5=bson.JS_INT_MAX,bson_6=bson.JS_INT_MIN,bson_7=bson.BSON_DATA_NUMBER,bson_8=bson.BSON_DATA_STRING,bson_9=bson.BSON_DATA_OBJECT,bson_10=bson.BSON_DATA_ARRAY,bson_11=bson.BSON_DATA_BINARY,bson_12=bson.BSON_DATA_UNDEFINED,bson_13=bson.BSON_DATA_OID,bson_14=bson.BSON_DATA_BOOLEAN,bson_15=bson.BSON_DATA_DATE,bson_16=bson.BSON_DATA_NULL,bson_17=bson.BSON_DATA_REGEXP,bson_18=bson.BSON_DATA_DBPOINTER,bson_19=bson.BSON_DATA_CODE,bson_20=bson.BSON_DATA_SYMBOL,bson_21=bson.BSON_DATA_CODE_W_SCOPE,bson_22=bson.BSON_DATA_INT,bson_23=bson.BSON_DATA_TIMESTAMP,bson_24=bson.BSON_DATA_LONG,bson_25=bson.BSON_DATA_DECIMAL128,bson_26=bson.BSON_DATA_MIN_KEY,bson_27=bson.BSON_DATA_MAX_KEY,bson_28=bson.BSON_BINARY_SUBTYPE_DEFAULT,bson_29=bson.BSON_BINARY_SUBTYPE_FUNCTION,bson_30=bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY,bson_31=bson.BSON_BINARY_SUBTYPE_UUID,bson_32=bson.BSON_BINARY_SUBTYPE_MD5,bson_33=bson.BSON_BINARY_SUBTYPE_USER_DEFINED,bson_34=bson.Code,bson_35=bson.BSONSymbol,bson_36=bson.DBRef,bson_37=bson.Binary,bson_38=bson.ObjectId,bson_39=bson.Long,bson_40=bson.Timestamp,bson_41=bson.Double,bson_42=bson.Int32,bson_43=bson.MinKey,bson_44=bson.MaxKey,bson_45=bson.BSONRegExp,bson_46=bson.Decimal128,bson_47=bson.serialize,bson_48=bson.serializeWithBufferAndIndex,bson_49=bson.deserialize,bson_50=bson.calculateObjectSize,bson_51=bson.deserializeStream,bson_52=bson.setInternalBufferSize,bson_53=bson.ObjectID,bson_54=bson.EJSON,_unused_webpack_default_export=bson}).call(this,__webpack_require__(3),__webpack_require__(1).Buffer)},function(e,t,n){"use strict";(function(e){
2
+ /*!
3
+ * The buffer module from node.js, for the browser.
4
+ *
5
+ * @author Feross Aboukhadijeh <http://feross.org>
6
+ * @license MIT
7
+ */
8
+ var r=n(5),i=n(6),o=n(7);function s(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=a.prototype:(null===e&&(e=new a(t)),e.length=t),e}function a(e,t,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return f(this,e,t,n)}function f(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r);a.TYPED_ARRAY_SUPPORT?(e=t).__proto__=a.prototype:e=h(e,t);return e}(e,t,n,r):"string"==typeof t?function(e,t,n){"string"==typeof n&&""!==n||(n="utf8");if(!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|d(t,n),i=(e=u(e,r)).write(t,n);i!==r&&(e=e.slice(0,i));return e}(e,t,n):function(e,t){if(a.isBuffer(t)){var n=0|p(t.length);return 0===(e=u(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?u(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(c(t),e=u(e,t<0?0:0|p(t)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function h(e,t){var n=t.length<0?0:0|p(t.length);e=u(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function p(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(e).length;default:if(r)return z(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return A(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return B(this,t,n);case"base64":return S(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function g(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=a.from(t,r)),a.isBuffer(t))return 0===t.length?-1:b(e,t,n,r,i);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):b(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,n,r,i){var o,s=1,u=e.length,a=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,u/=2,a/=2,n/=2}function f(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=n;o<u;o++)if(f(e,o)===f(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===a)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(n+a>u&&(n=u-a),o=n;o>=0;o--){for(var l=!0,h=0;h<a;h++)if(f(e,o+h)!==f(t,h)){l=!1;break}if(l)return o}return-1}function m(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var u=parseInt(t.substr(2*s,2),16);if(isNaN(u))return s;e[n+s]=u}return s}function w(e,t,n,r){return F(z(t,e.length-n),e,n,r)}function v(e,t,n,r){return F(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function E(e,t,n,r){return v(e,t,n,r)}function N(e,t,n,r){return F(k(t),e,n,r)}function O(e,t,n,r){return F(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function S(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function A(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,u,a,f=e[i],c=null,l=f>239?4:f>223?3:f>191?2:1;if(i+l<=n)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(a=(31&f)<<6|63&o)>127&&(c=a);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(a=(15&f)<<12|(63&o)<<6|63&s)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:o=e[i+1],s=e[i+2],u=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(a=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&a<1114112&&(c=a)}null===c?(c=65533,l=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=4096));return n}(r)}t.Buffer=a,t.SlowBuffer=function(e){+e!=e&&(e=0);return a.alloc(+e)},t.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),a.poolSize=8192,a._augment=function(e){return e.__proto__=a.prototype,e},a.from=function(e,t,n){return f(null,e,t,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(e,t,n){return function(e,t,n,r){return c(t),t<=0?u(e,t):void 0!==n?"string"==typeof r?u(e,t).fill(n,r):u(e,t).fill(n):u(e,t)}(null,e,t,n)},a.allocUnsafe=function(e){return l(null,e)},a.allocUnsafeSlow=function(e){return l(null,e)},a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=a.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(!a.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},a.byteLength=d,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)_(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)_(this,t,t+3),_(this,t+1,t+2);return this},a.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)_(this,t,t+7),_(this,t+1,t+6),_(this,t+2,t+5),_(this,t+3,t+4);return this},a.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?A(this,0,e):y.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},a.prototype.compare=function(e,t,n,r,i){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),u=Math.min(o,s),f=this.slice(r,i),c=e.slice(t,n),l=0;l<u;++l)if(f[l]!==c[l]){o=f[l],s=c[l];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.indexOf=function(e,t,n){return g(this,e,t,n,!0)},a.prototype.lastIndexOf=function(e,t,n){return g(this,e,t,n,!1)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return m(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return v(this,e,t,n);case"latin1":case"binary":return E(this,e,t,n);case"base64":return N(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function B(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function I(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=L(e[o]);return i}function D(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function P(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function $(e,t,n,r,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function R(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function x(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function M(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function C(e,t,n,r,o){return o||M(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function U(e,t,n,r,o){return o||M(e,0,n,8),i.write(e,t,n,r,52,8),n+8}a.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),a.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=a.prototype;else{var i=t-e;n=new a(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},a.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},a.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},a.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||$(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},a.prototype.writeUIntBE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||$(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);$(this,e,t,n,i-1,-i)}var o=0,s=1,u=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===u&&0!==this[t+o-1]&&(u=1),this[t+o]=(e/s>>0)-u&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);$(this,e,t,n,i-1,-i)}var o=n-1,s=1,u=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===u&&0!==this[t+o+1]&&(u=1),this[t+o]=(e/s>>0)-u&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||$(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,n){return C(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return C(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return U(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return U(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=a.isBuffer(e)?e:z(new a(e,r).toString()),u=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%u]}return this};var j=/[^+\/0-9A-Za-z-_]/g;function L(e){return e<16?"0"+e.toString(16):e.toString(16)}function z(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function k(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(j,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(this,n(3))},function(e,t){e.exports=r;var n=null;try{n=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function r(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function i(e){return!0===(e&&e.__isLong__)}r.prototype.__isLong__,Object.defineProperty(r.prototype,"__isLong__",{value:!0}),r.isLong=i;var o={},s={};function u(e,t){var n,r,i;return t?(i=0<=(e>>>=0)&&e<256)&&(r=s[e])?r:(n=f(e,(0|e)<0?-1:0,!0),i&&(s[e]=n),n):(i=-128<=(e|=0)&&e<128)&&(r=o[e])?r:(n=f(e,e<0?-1:0,!1),i&&(o[e]=n),n)}function a(e,t){if(isNaN(e))return t?b:g;if(t){if(e<0)return b;if(e>=d)return N}else{if(e<=-y)return O;if(e+1>=y)return E}return e<0?a(-e,t).neg():f(e%p|0,e/p|0,t)}function f(e,t,n){return new r(e,t,n)}r.fromInt=u,r.fromNumber=a,r.fromBits=f;var c=Math.pow;function l(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return g;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return l(e.substring(1),t,n).neg();for(var i=a(c(n,8)),o=g,s=0;s<e.length;s+=8){var u=Math.min(8,e.length-s),f=parseInt(e.substring(s,s+u),n);if(u<8){var h=a(c(n,u));o=o.mul(h).add(a(f))}else o=(o=o.mul(i)).add(a(f))}return o.unsigned=t,o}function h(e,t){return"number"==typeof e?a(e,t):"string"==typeof e?l(e,t):f(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}r.fromString=l,r.fromValue=h;var p=4294967296,d=p*p,y=d/2,_=u(1<<24),g=u(0);r.ZERO=g;var b=u(0,!0);r.UZERO=b;var m=u(1);r.ONE=m;var w=u(1,!0);r.UONE=w;var v=u(-1);r.NEG_ONE=v;var E=f(-1,2147483647,!1);r.MAX_VALUE=E;var N=f(-1,-1,!0);r.MAX_UNSIGNED_VALUE=N;var O=f(0,-2147483648,!1);r.MIN_VALUE=O;var S=r.prototype;S.toInt=function(){return this.unsigned?this.low>>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*p+(this.low>>>0):this.high*p+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(O)){var t=a(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=a(c(e,6),this.unsigned),o=this,s="";;){var u=o.div(i),f=(o.sub(u.mul(i)).toInt()>>>0).toString(e);if((o=u).isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(O)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},S.isZero=function(){return 0===this.high&&0===this.low},S.eqz=S.isZero,S.isNegative=function(){return!this.unsigned&&this.high<0},S.isPositive=function(){return this.unsigned||this.high>=0},S.isOdd=function(){return 1==(1&this.low)},S.isEven=function(){return 0==(1&this.low)},S.equals=function(e){return i(e)||(e=h(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},S.eq=S.equals,S.notEquals=function(e){return!this.eq(e)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(e){return this.comp(e)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(e){return this.comp(e)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(e){return this.comp(e)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(e){return this.comp(e)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(e){if(i(e)||(e=h(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(O)?O:this.not().add(m)},S.neg=S.negate,S.add=function(e){i(e)||(e=h(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,s=e.high>>>16,u=65535&e.high,a=e.low>>>16,c=0,l=0,p=0,d=0;return p+=(d+=o+(65535&e.low))>>>16,l+=(p+=r+a)>>>16,c+=(l+=n+u)>>>16,c+=t+s,f((p&=65535)<<16|(d&=65535),(c&=65535)<<16|(l&=65535),this.unsigned)},S.subtract=function(e){return i(e)||(e=h(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return g;if(i(e)||(e=h(e)),n)return f(n.mul(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned);if(e.isZero())return g;if(this.eq(O))return e.isOdd()?O:g;if(e.eq(O))return this.isOdd()?O:g;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(_)&&e.lt(_))return a(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,o=this.low>>>16,s=65535&this.low,u=e.high>>>16,c=65535&e.high,l=e.low>>>16,p=65535&e.low,d=0,y=0,b=0,m=0;return b+=(m+=s*p)>>>16,y+=(b+=o*p)>>>16,b&=65535,y+=(b+=s*l)>>>16,d+=(y+=r*p)>>>16,y&=65535,d+=(y+=o*l)>>>16,y&=65535,d+=(y+=s*c)>>>16,d+=t*p+r*l+o*c+s*u,f((b&=65535)<<16|(m&=65535),(d&=65535)<<16|(y&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(i(e)||(e=h(e)),e.isZero())throw Error("division by zero");var t,r,o;if(n)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?f((this.unsigned?n.div_u:n.div_s)(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?b:g;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return b;if(e.gt(this.shru(1)))return w;o=b}else{if(this.eq(O))return e.eq(m)||e.eq(v)?O:e.eq(O)?m:(t=this.shr(1).div(e).shl(1)).eq(g)?e.isNegative()?m:v:(r=this.sub(e.mul(t)),o=t.add(r.div(e)));if(e.eq(O))return this.unsigned?b:g;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();o=g}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),u=s<=48?1:c(2,s-48),l=a(t),p=l.mul(e);p.isNegative()||p.gt(r);)p=(l=a(t-=u,this.unsigned)).mul(e);l.isZero()&&(l=m),o=o.add(l),r=r.sub(p)}return o},S.div=S.divide,S.modulo=function(e){return i(e)||(e=h(e)),n?f((this.unsigned?n.rem_u:n.rem_s)(this.low,this.high,e.low,e.high),n.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return f(~this.low,~this.high,this.unsigned)},S.and=function(e){return i(e)||(e=h(e)),f(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return i(e)||(e=h(e)),f(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return i(e)||(e=h(e)),f(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?f(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):f(0,this.low<<e-32,this.unsigned)},S.shl=S.shiftLeft,S.shiftRight=function(e){return i(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?f(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):f(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(i(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?f(this.low>>>e|t<<32-e,t>>>e,this.unsigned):f(32===e?t:t>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?f(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:f(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},S.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},r.fromBytes=function(e,t,n){return n?r.fromBytesLE(e,t):r.fromBytesBE(e,t)},r.fromBytesLE=function(e,t){return new r(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},r.fromBytesBE=function(e,t){return new r(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.registerDatabase=void 0;var i=n(8);var o={name:"database",entity:{database:function(e){var t=this.platform,n=t.adapter,o=t.runtime;return i.Db.reqClass=this.request.constructor,i.Db.getAccessToken=this.authInstance.getAccessToken.bind(this.authInstance),i.Db.runtime=o,this.wsClientClass&&(i.Db.wsClass=n.wsClass,i.Db.wsClientClass=this.wsClientClass),i.Db.ws||(i.Db.ws=null),new i.Db(r(r({},this.config),e))}}};try{cloudbase.registerComponent(o)}catch(e){}t.registerDatabase=function(e){e.registerComponent(o)}},function(e,t,n){"use strict";t.byteLength=function(e){var t=f(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,r=f(e),s=r[0],u=r[1],a=new o(function(e,t,n){return 3*(t+n)/4-n}(0,s,u)),c=0,l=u>0?s-4:s;for(n=0;n<l;n+=4)t=i[e.charCodeAt(n)]<<18|i[e.charCodeAt(n+1)]<<12|i[e.charCodeAt(n+2)]<<6|i[e.charCodeAt(n+3)],a[c++]=t>>16&255,a[c++]=t>>8&255,a[c++]=255&t;2===u&&(t=i[e.charCodeAt(n)]<<2|i[e.charCodeAt(n+1)]>>4,a[c++]=255&t);1===u&&(t=i[e.charCodeAt(n)]<<10|i[e.charCodeAt(n+1)]<<4|i[e.charCodeAt(n+2)]>>2,a[c++]=t>>8&255,a[c++]=255&t);return a},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=0,u=n-i;s<u;s+=16383)o.push(c(e,s,s+16383>u?u:s+16383));1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,a=s.length;u<a;++u)r[u]=s[u],i[s.charCodeAt(u)]=u;function f(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e,t,n){for(var i,o,s=[],u=t;u<n;u+=3)i=(e[u]<<16&16711680)+(e[u+1]<<8&65280)+(255&e[u+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,r,i){var o,s,u=8*i-r-1,a=(1<<u)-1,f=a>>1,c=-7,l=n?i-1:0,h=n?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=f}return(p?-1:1)*s*Math.pow(2,o-r)},t.write=function(e,t,n,r,i,o){var s,u,a,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+l>=1?h/a:h*Math.pow(2,1-l))*a>=2&&(s++,a/=2),s+l>=c?(u=0,s=c):s+l>=1?(u=(t*a-1)*Math.pow(2,i),s+=l):(u=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+p]=255&u,p+=d,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;e[n+p]=255&s,p+=d,s/=256,f-=8);e[n+p-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";n.r(t),n.d(t,"Query",(function(){return Ye})),n.d(t,"CollectionReference",(function(){return We})),n.d(t,"DocumentReference",(function(){return ze})),n.d(t,"Db",(function(){return gt}));var r,i,o={};n.r(o),n.d(o,"Point",(function(){return Z})),n.d(o,"LineString",(function(){return te})),n.d(o,"Polygon",(function(){return re})),n.d(o,"MultiPoint",(function(){return oe})),n.d(o,"MultiLineString",(function(){return ue})),n.d(o,"MultiPolygon",(function(){return fe})),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(i||(i={}));var s,u="Number",a="Object",f="Array",c="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",_="Date",g="ServerDate",b="BsonDate",m=["desc","asc"],w=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={}));var v;(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte";!function(e){e.WHERE="WHERE",e.DOC="DOC"}(v||(v={}));var E,N=(E=function(e,t){return(E=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}E(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),O=[],S={},A=function(e){function t(t,n){if(n!==S)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return N(t,e),t.for=function(e){for(var n=0,r=O.length;n<r;n++)if(O[n].target===e)return O[n].instance;var i=new t(e,S);return O.push({target:e,instance:i}),i},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),T=A,B=T.for("UNSET_FIELD_NAME"),I=T.for("UPDATE_COMMAND"),D=T.for("QUERY_COMMAND"),P=T.for("LOGIC_COMMAND"),$=T.for("GEO_POINT"),R=T.for("SYMBOL_GEO_LINE_STRING"),x=T.for("SYMBOL_GEO_POLYGON"),M=T.for("SYMBOL_GEO_MULTI_POINT"),C=T.for("SYMBOL_GEO_MULTI_LINE_STRING"),U=T.for("SYMBOL_GEO_MULTI_POLYGON"),j=T.for("SERVER_DATE"),L=T.for("REGEXP"),z=function(){function e(e){var t=(void 0===e?{}:e).offset,n=void 0===t?0:t;this.offset=n}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function k(e){return new z(e)}var F,q=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Y=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var n=Object.keys(t),r={};return Array.isArray(t)&&(r=[]),n.forEach((function(n){var i,o=t[n];switch(e.whichType(o)){case c:i=new Z(o.coordinates[0],o.coordinates[1]);break;case l:i=new te(o.coordinates.map((function(e){return new Z(e[0],e[1])})));break;case h:i=new re(o.coordinates.map((function(e){return new te(e.map((function(e){var t=q(e,2),n=t[0],r=t[1];return new Z(n,r)})))})));break;case p:i=new oe(o.coordinates.map((function(e){return new Z(e[0],e[1])})));break;case d:i=new ue(o.coordinates.map((function(e){return new te(e.map((function(e){var t=q(e,2),n=t[0],r=t[1];return new Z(n,r)})))})));break;case y:i=new fe(o.coordinates.map((function(e){return new re(e.map((function(e){return new te(e.map((function(e){var t=q(e,2),n=t[0],r=t[1];return new Z(n,r)})))})))})));break;case _:i=new Date(1e3*o.$timestamp);break;case a:case f:i=e.formatField(o);break;case g:i=new Date(o.$date);break;default:i=o}Array.isArray(r)?r.push(i):r[n]=i})),r},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===_)return b;if(t===a){if(e instanceof Z)return c;if(e instanceof Date)return _;if(e instanceof z)return g;e.$timestamp?t=_:e.$date?t=g:Z.validate(e)?t=c:te.validate(e)?t=l:re.validate(e)?t=h:oe.validate(e)?t=p:ue.validate(e)?t=d:fe.validate(e)&&(t=y)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",n=0;n<24;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},e}(),J=function(){function e(){}return e.isGeopoint=function(e,t){if(Y.whichType(t)!==u)throw new Error("Geo Point must be number type");var n=Math.abs(t);if("latitude"===e&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+i.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===m.indexOf(e))throw new Error(i.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===w.indexOf(e))throw new Error(i.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(i.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(i.DocIDError);return!0},e}(),G=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},X=function(e){return"object"===G(e)},H=function(e){return"number"===G(e)},K=function(e){return Array.isArray(e)},W=function(e){return"date"===G(e)},V=function(e){return"regexp"===G(e)},Q=function(e){return e&&e._internalType instanceof A},Z=function(){function e(e,t){J.isGeopoint("longitude",e),J.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},e.validate=function(e){return"Point"===e.type&&K(e.coordinates)&&J.isGeopoint("longitude",e.coordinates[0])&&J.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return $},enumerable:!0,configurable:!0}),e}(),ee=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},te=function(){function e(e){if(!K(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof Z))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("LineString"!==e.type||!K(e.coordinates))return!1;try{for(var r=ee(e.coordinates),i=r.next();!i.done;i=r.next()){var o=i.value;if(!H(o[0])||!H(o[1]))return!1}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],n=e.points[e.points.length-1];if(t.latitude===n.latitude&&t.longitude===n.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return R},enumerable:!0,configurable:!0}),e}(),ne=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},re=function(){function e(e){if(!K(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof te))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]");if(!te.isClosed(e))throw new Error("LineString "+e.points.map((function(e){return e.toReadableString()}))+" is not a closed cycle")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,i;if("Polygon"!==e.type||!K(e.coordinates))return!1;try{for(var o=ne(e.coordinates),s=o.next();!s.done;s=o.next()){var u=s.value;if(!this.isCloseLineString(u))return!1;try{for(var a=(r=void 0,ne(u)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],n=e[e.length-1];return t[0]===n[0]&&t[1]===n[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),e}(),ie=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},oe=function(){function e(e){if(!K(e))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e);if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof Z))throw new TypeError('"points" must be of type Point[]. Received type '+typeof e+"[]")})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,n;if("MultiPoint"!==e.type||!K(e.coordinates))return!1;try{for(var r=ie(e.coordinates),i=r.next();!i.done;i=r.next()){var o=i.value;if(!H(o[0])||!H(o[1]))return!1}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return M},enumerable:!0,configurable:!0}),e}(),se=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ue=function(){function e(e){if(!K(e))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e);if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof te))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof e+"[]")})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,n,r,i;if("MultiLineString"!==e.type||!K(e.coordinates))return!1;try{for(var o=se(e.coordinates),s=o.next();!s.done;s=o.next()){var u=s.value;try{for(var a=(r=void 0,se(u)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!0,configurable:!0}),e}(),ae=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},fe=function(){function e(e){var t,n;if(!K(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof e);if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=ae(e),i=r.next();!i.done;i=r.next()){var o=i.value;if(!(o instanceof re))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof o+"[]")}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,n,r,i,o,s;if("MultiPolygon"!==e.type||!K(e.coordinates))return!1;try{for(var u=ae(e.coordinates),a=u.next();!a.done;a=u.next()){var f=a.value;try{for(var c=(r=void 0,ae(f)),l=c.next();!l.done;l=c.next()){var h=l.value;try{for(var p=(o=void 0,ae(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!H(y[0])||!H(y[1]))return!1}}catch(e){o={error:e}}finally{try{d&&!d.done&&(s=p.return)&&s.call(p)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),e}(),ce=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(F||(F={}));var le=function(){function e(e,t,n){this._internalType=I,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||B}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function he(e){return e&&e instanceof le&&e._internalType===I}var pe;!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(pe||(pe={}));var de=function(){function e(e,t,n){if(this._internalType=P,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=n||B,this.fieldName!==B)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var r=0,i=t.length;r<i;r++){(ye(o=t[r])||me(o))&&(t[r]=o._setFieldName(this.fieldName))}}else{var o;(ye(o=t)||me(o))&&(t=o._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var n=this.operands.map((function(n){return n instanceof e?n._setFieldName(t):n}));return new e(this.operator,n,t)},e.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(pe.AND,r,this.fieldName)},e.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new e(pe.OR,r,this.fieldName)},e}();function ye(e){return e&&e instanceof de&&e._internalType===P}var _e,ge=function(){var e=function(t,n){return(e=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])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(_e||(_e={}));var be=function(e){function t(t,n,r){var i=e.call(this,t,n,r)||this;return i.operator=t,i._internalType=D,i}return ge(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case _e.IN:case _e.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var n=new t(_e.EQ,[e],this.fieldName);return this.and(n)},t.prototype.neq=function(e){var n=new t(_e.NEQ,[e],this.fieldName);return this.and(n)},t.prototype.gt=function(e){var n=new t(_e.GT,[e],this.fieldName);return this.and(n)},t.prototype.gte=function(e){var n=new t(_e.GTE,[e],this.fieldName);return this.and(n)},t.prototype.lt=function(e){var n=new t(_e.LT,[e],this.fieldName);return this.and(n)},t.prototype.lte=function(e){var n=new t(_e.LTE,[e],this.fieldName);return this.and(n)},t.prototype.in=function(e){var n=new t(_e.IN,e,this.fieldName);return this.and(n)},t.prototype.nin=function(e){var n=new t(_e.NIN,e,this.fieldName);return this.and(n)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof Z))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!H(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!H(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var n=new t(_e.GEO_NEAR,[e],this.fieldName);return this.and(n)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof fe||e.geometry instanceof re))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var n=new t(_e.GEO_WITHIN,[e],this.fieldName);return this.and(n)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof Z||e.geometry instanceof te||e.geometry instanceof re||e.geometry instanceof oe||e.geometry instanceof ue||e.geometry instanceof fe))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var n=new t(_e.GEO_INTERSECTS,[e],this.fieldName);return this.and(n)},t}(de);function me(e){return e&&e instanceof be&&e._internalType===D}function we(e){return me(e)}var ve={};for(var Ee in _e)ve[Ee]="$"+Ee;for(var Ee in pe)ve[Ee]="$"+Ee;for(var Ee in F)ve[Ee]="$"+Ee;function Ne(e){return ve[e]||"$"+e}ve[_e.NEQ]="$ne",ve[F.REMOVE]="$unset",ve[F.SHIFT]="$pop",ve[F.UNSHIFT]="$push";var Oe=function(){return(Oe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Se=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},Ae=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Se(arguments[t]));return e};function Te(e){return function e(t,n){if(!Q(t)){if(W(t))return{$date:+t};if(V(t))return{$regex:t.source,$options:t.flags};if(K(t))return t.map((function(t){if(n.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return e(t,Ae(n,[t]))}));if(X(t)){var r=Oe({},t);for(var i in r){if(n.indexOf(r[i])>-1)throw new Error("Cannot convert circular structure to JSON");r[i]=e(r[i],Ae(n,[r[i]]))}return r}return t}switch(t._internalType){case $:return t.toJSON();case j:case L:return t.parse();default:return t.toJSON?t.toJSON():t}}(e,[e])}var Be=function(){return(Be=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Ie=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},De=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ie(arguments[t]));return e};function Pe(e,t,n,r){var i=Be({},e);for(var o in e)if(!/^\$/.test(o)){var s=e[o];if(s&&X(s)&&!t(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var u=Pe(s,t,De(n,[o]),De(r,[s]));i[o]=u;var a=!1;for(var f in u)/^\$/.test(f)?a=!0:(i[o+"."+f]=u[f],delete i[o][f]);a||delete i[o]}}return i}function $e(e){return Pe(e,xe,[],[e])}function Re(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?K(e[r])?e[r].push(t[r]):X(e[r])?X(t[r])?Object.assign(e[r],t[r]):(console.warn("unmergable condition, query is object but condition is "+G(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+G(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]}function xe(e){return Q(e)||W(e)||V(e)}function Me(e){return Te(e)}var Ce=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return he(e)?this.encodeUpdateCommand(e):"object"===G(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===B)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case F.PUSH:case F.PULL:case F.PULL_ALL:case F.POP:case F.SHIFT:case F.UNSHIFT:case F.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,n,r,i,o=Ne(e.operator);switch(e.operator){case F.REMOVE:return(t={})[o]=((n={})[e.fieldName]="",n),t;default:return(r={})[o]=((i={})[e.fieldName]=e.operands[0],i),r}},e.prototype.encodeArrayUpdateCommand=function(e){var t,n,r,i,o,s,u,a,f,c,l=Ne(e.operator);switch(e.operator){case F.PUSH:var h=void 0;return h=K(e.operands)?{$each:e.operands.map(Me)}:e.operands,(t={})[l]=((n={})[e.fieldName]=h,n),t;case F.UNSHIFT:h={$each:e.operands.map(Me),$position:0};return(r={})[l]=((i={})[e.fieldName]=h,i),r;case F.POP:return(o={})[l]=((s={})[e.fieldName]=1,s),o;case F.SHIFT:return(u={})[l]=((a={})[e.fieldName]=-1,a),u;default:return(f={})[l]=((c={})[e.fieldName]=Me(e.operands),c),f}},e.prototype.encodeUpdateObject=function(e){var t=$e(e);for(var n in t)if(!/^\$/.test(n)){var r=t[n];if(he(r)){t[n]=r._setFieldName(n),Re(t,this.encodeUpdateCommand(t[n]),n)}else{t[n]=r=Me(r);var i=new le(F.SET,[r],n);Re(t,this.encodeUpdateCommand(i),n)}}return t},e}(),Ue={};function je(e){if(!gt.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Ue[t]||(Ue[t]=new gt.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new gt.reqClass(e.config)}}})),Ue[t]}var Le=function(){return(Le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ze=function(){function e(e,t,n,r){var i=this;void 0===r&&(r={}),this.watch=function(e){return je(i._db).watch(Le(Le({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=e,this._coll=t,this.id=n,this.request=new gt.reqClass(this._db.config),this.projection=r}return e.prototype.create=function(e,t){t=t||ce();var n={collectionName:this._coll,data:Te(e)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){e.code?t(0,e):t(0,{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||ce(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof le?n=!0:"object"==typeof e[t]&&r(e[t])};if(r(e),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var i={collectionName:this._coll,queryType:v.DOC,data:Te(e),multi:!1,merge:!1,upsert:!0};return this.id&&(i.query={_id:this.id}),this.request.send("database.updateDocument",i).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||ce(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Ce.encode(e),query:n,queryType:v.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||ce();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:v.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||ce();var t={_id:this.id},n={collectionName:this._coll,query:t,queryType:v.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n=Y.formatResDocumentData(t.data.list);e(0,{data:n,requestId:t.requestId,total:t.TotalCount,limit:t.Limit,offset:t.Offset})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var n in t)t[n]?t[n]=1:t[n]=0;return new e(this._db,this._coll,this.id,t)},e}(),ke=function(){function e(){}return e.encode=function(e){return(new Fe).encodeQuery(e)},e}(),Fe=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var n;return xe(e)?ye(e)?this.encodeLogicCommand(e):me(e)?this.encodeQueryCommand(e):((n={})[t]=this.encodeQueryObject(e),n):X(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,n,r,i,o,s,u,a=this;switch(e.operator){case pe.NOR:case pe.AND:case pe.OR:var f=Ne(e.operator),c=e.operands.map((function(t){return a.encodeQuery(t,e.fieldName)}));return(t={})[f]=c,t;case pe.NOT:f=Ne(e.operator);var l=e.operands[0];if(V(l))return(n={})[e.fieldName]=((r={})[f]=this.encodeRegExp(l),r),n;c=this.encodeQuery(l)[e.fieldName];return(i={})[e.fieldName]=((o={})[f]=c,o),i;default:f=Ne(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[f]=h,s}c=e.operands.map(this.encodeQuery.bind(this));return(u={})[f]=c,u}},e.prototype.encodeQueryCommand=function(e){return we(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,n,r,i,o,s,u,a,f;if(e.fieldName===B)throw new Error("Cannot encode a comparison command with unset field name");var c=Ne(e.operator);switch(e.operator){case _e.EQ:case _e.NEQ:case _e.LT:case _e.LTE:case _e.GT:case _e.GTE:case _e.ELEM_MATCH:case _e.EXISTS:case _e.SIZE:case _e.MOD:return(t={})[e.fieldName]=((n={})[c]=Me(e.operands[0]),n),t;case _e.IN:case _e.NIN:case _e.ALL:return(r={})[e.fieldName]=((i={})[c]=Me(e.operands),i),r;case _e.GEO_NEAR:var l=e.operands[0];return(o={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},o;case _e.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case _e.GEO_INTERSECTS:l=e.operands[0];return(u={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},u;default:return(a={})[e.fieldName]=((f={})[c]=Me(e.operands[0]),f),a}},e.prototype.encodeQueryObject=function(e){var t=$e(e);for(var n in t){var r=t[n];if(ye(r)){t[n]=r._setFieldName(n);var i=this.encodeLogicCommand(t[n]);this.mergeConditionAfterEncode(t,i,n)}else if(we(r)){t[n]=r._setFieldName(n);i=this.encodeComparisonCommand(t[n]);this.mergeConditionAfterEncode(t,i,n)}else xe(r)&&(t[n]=Me(r))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,n){for(var r in t[n]||delete e[n],t)e[r]?K(e[r])?e[r]=e[r].concat(t[r]):X(e[r])?X(t[r])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+G(t)+", can only overwrite",t,n),e[r]=t[r]):(console.warn("to-merge query is of type "+G(e)+", can only overwrite",e,t,n),e[r]=t[r]):e[r]=t[r]},e}(),qe=function(){return(qe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Ye=function(){function e(e,t,n,r,i){var o=this;this.watch=function(e){return je(o._db).watch(qe(qe({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify(o._fieldFilters||{}),limit:o._queryOptions.limit,orderBy:o._fieldOrders?o._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=i||{},this._request=new gt.reqClass(this._db.config)}return e.prototype.get=function(e){e=e||ce();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var n={collectionName:this._coll,queryType:v.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),t.length>0&&(n.order=t),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(t){if(t.code)e(0,t);else{var n={data:Y.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(n.total=t.TotalCount),t.Limit&&(n.limit=t.Limit),t.Offset&&(n.offset=t.Offset),e(0,n)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ce();var t={collectionName:this._coll,queryType:v.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(i.QueryParamTypeError);var n=Object.keys(t),r=n.some((function(e){return void 0!==t[e]}));if(n.length&&!r)throw Error(i.QueryParamValueError);return new e(this._db,this._coll,ke.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,n){J.isFieldPath(t),J.isFieldOrder(n);var r={field:t,direction:n},i=this._fieldOrders.concat(r);return new e(this._db,this._coll,this._fieldFilters,i,this._queryOptions)},e.prototype.limit=function(t){J.isInteger("limit",t);var n=qe({},this._queryOptions);return n.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.skip=function(t){J.isInteger("offset",t);var n=qe({},this._queryOptions);return n.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.update=function(e,t){if(t=t||ce(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:v.WHERE,multi:!0,merge:!0,upsert:!1,data:Ce.encode(e)};return this._request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var n in t)t[n]?"object"!=typeof t[n]&&(t[n]=1):t[n]=0;var r=qe({},this._queryOptions);return r.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.remove=function(e){e=e||ce(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:ke.encode(this._fieldFilters),queryType:v.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),Je=n(0),Ge=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},Xe=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},He=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new gt.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Ge(this,void 0,void 0,(function(){var e;return Xe(this,(function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(Je.a.parse)}]:[2,e]}}))}))},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,n=e.stageKey,r=e.stageValue;return(t={})[n]=JSON.parse(r),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$"+e,stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",ke.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),Ke=function(){var e=function(t,n){return(e=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])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),We=function(e){function t(t,n){return e.call(this,t,n)||this}return Ke(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new ze(this._db,this._coll,e)},t.prototype.add=function(e,t){return new ze(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new He(this._db,this._coll)},t}(Ye),Ve={eq:function(e){return new be(_e.EQ,[e])},neq:function(e){return new be(_e.NEQ,[e])},lt:function(e){return new be(_e.LT,[e])},lte:function(e){return new be(_e.LTE,[e])},gt:function(e){return new be(_e.GT,[e])},gte:function(e){return new be(_e.GTE,[e])},in:function(e){return new be(_e.IN,e)},nin:function(e){return new be(_e.NIN,e)},all:function(e){return new be(_e.ALL,e)},elemMatch:function(e){return new be(_e.ELEM_MATCH,[e])},exists:function(e){return new be(_e.EXISTS,[e])},size:function(e){return new be(_e.SIZE,[e])},mod:function(e){return new be(_e.MOD,[e])},geoNear:function(e){return new be(_e.GEO_NEAR,[e])},geoWithin:function(e){return new be(_e.GEO_WITHIN,[e])},geoIntersects:function(e){return new be(_e.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.AND,n)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOR,n)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.OR,n)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOT,n)},set:function(e){return new le(F.SET,[e])},remove:function(){return new le(F.REMOVE,[])},inc:function(e){return new le(F.INC,[e])},mul:function(e){return new le(F.MUL,[e])},push:function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(X(t[0])&&t[0].hasOwnProperty("each")){var r=t[0];e={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else e=K(t[0])?t[0]:Array.from(t);return new le(F.PUSH,e)},pull:function(e){return new le(F.PULL,e)},pullAll:function(e){return new le(F.PULL_ALL,e)},pop:function(){return new le(F.POP,[])},shift:function(){return new le(F.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=K(arguments[0])?arguments[0]:Array.from(arguments);return new le(F.UNSHIFT,n)},addToSet:function(e){return new le(F.ADD_TO_SET,e)},rename:function(e){return new le(F.RENAME,[e])},bit:function(e){return new le(F.BIT,[e])},max:function(e){return new le(F.MAX,[e])},min:function(e){return new le(F.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===G(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new He},abs:function(e){return new Qe("abs",e)},add:function(e){return new Qe("add",e)},ceil:function(e){return new Qe("ceil",e)},divide:function(e){return new Qe("divide",e)},exp:function(e){return new Qe("exp",e)},floor:function(e){return new Qe("floor",e)},ln:function(e){return new Qe("ln",e)},log:function(e){return new Qe("log",e)},log10:function(e){return new Qe("log10",e)},mod:function(e){return new Qe("mod",e)},multiply:function(e){return new Qe("multiply",e)},pow:function(e){return new Qe("pow",e)},sqrt:function(e){return new Qe("sqrt",e)},subtract:function(e){return new Qe("subtract",e)},trunc:function(e){return new Qe("trunc",e)},arrayElemAt:function(e){return new Qe("arrayElemAt",e)},arrayToObject:function(e){return new Qe("arrayToObject",e)},concatArrays:function(e){return new Qe("concatArrays",e)},filter:function(e){return new Qe("filter",e)},in:function(e){return new Qe("in",e)},indexOfArray:function(e){return new Qe("indexOfArray",e)},isArray:function(e){return new Qe("isArray",e)},map:function(e){return new Qe("map",e)},range:function(e){return new Qe("range",e)},reduce:function(e){return new Qe("reduce",e)},reverseArray:function(e){return new Qe("reverseArray",e)},size:function(e){return new Qe("size",e)},slice:function(e){return new Qe("slice",e)},zip:function(e){return new Qe("zip",e)},and:function(e){return new Qe("and",e)},not:function(e){return new Qe("not",e)},or:function(e){return new Qe("or",e)},cmp:function(e){return new Qe("cmp",e)},eq:function(e){return new Qe("eq",e)},gt:function(e){return new Qe("gt",e)},gte:function(e){return new Qe("gte",e)},lt:function(e){return new Qe("lt",e)},lte:function(e){return new Qe("lte",e)},neq:function(e){return new Qe("ne",e)},cond:function(e){return new Qe("cond",e)},ifNull:function(e){return new Qe("ifNull",e)},switch:function(e){return new Qe("switch",e)},dateFromParts:function(e){return new Qe("dateFromParts",e)},dateFromString:function(e){return new Qe("dateFromString",e)},dayOfMonth:function(e){return new Qe("dayOfMonth",e)},dayOfWeek:function(e){return new Qe("dayOfWeek",e)},dayOfYear:function(e){return new Qe("dayOfYear",e)},isoDayOfWeek:function(e){return new Qe("isoDayOfWeek",e)},isoWeek:function(e){return new Qe("isoWeek",e)},isoWeekYear:function(e){return new Qe("isoWeekYear",e)},millisecond:function(e){return new Qe("millisecond",e)},minute:function(e){return new Qe("minute",e)},month:function(e){return new Qe("month",e)},second:function(e){return new Qe("second",e)},hour:function(e){return new Qe("hour",e)},week:function(e){return new Qe("week",e)},year:function(e){return new Qe("year",e)},literal:function(e){return new Qe("literal",e)},mergeObjects:function(e){return new Qe("mergeObjects",e)},objectToArray:function(e){return new Qe("objectToArray",e)},allElementsTrue:function(e){return new Qe("allElementsTrue",e)},anyElementTrue:function(e){return new Qe("anyElementTrue",e)},setDifference:function(e){return new Qe("setDifference",e)},setEquals:function(e){return new Qe("setEquals",e)},setIntersection:function(e){return new Qe("setIntersection",e)},setIsSubset:function(e){return new Qe("setIsSubset",e)},setUnion:function(e){return new Qe("setUnion",e)},concat:function(e){return new Qe("concat",e)},dateToString:function(e){return new Qe("dateToString",e)},indexOfBytes:function(e){return new Qe("indexOfBytes",e)},indexOfCP:function(e){return new Qe("indexOfCP",e)},split:function(e){return new Qe("split",e)},strLenBytes:function(e){return new Qe("strLenBytes",e)},strLenCP:function(e){return new Qe("strLenCP",e)},strcasecmp:function(e){return new Qe("strcasecmp",e)},substr:function(e){return new Qe("substr",e)},substrBytes:function(e){return new Qe("substrBytes",e)},substrCP:function(e){return new Qe("substrCP",e)},toLower:function(e){return new Qe("toLower",e)},toUpper:function(e){return new Qe("toUpper",e)},meta:function(e){return new Qe("meta",e)},addToSet:function(e){return new Qe("addToSet",e)},avg:function(e){return new Qe("avg",e)},first:function(e){return new Qe("first",e)},last:function(e){return new Qe("last",e)},max:function(e){return new Qe("max",e)},min:function(e){return new Qe("min",e)},push:function(e){return new Qe("push",e)},stdDevPop:function(e){return new Qe("stdDevPop",e)},stdDevSamp:function(e){return new Qe("stdDevSamp",e)},sum:function(e){return new Qe("sum",e)},let:function(e){return new Qe("let",e)}},project:{slice:function(e){return new Ze("slice",e)},elemMatch:function(e){return new Ze("elemMatch",e)}}},Qe=function(e,t){this["$"+e]=t},Ze=function(e,t){this["$"+e]=t},et=function(){function e(e){var t=e.regexp,n=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=n}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),e}();function tt(e){return new et(e)}var nt={code:"INSERT_DOC_FAIL",message:"insert document failed"},rt={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},it=function(){return(it=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ot=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},st=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},ut="database.updateDocInTransaction",at=function(){function e(e,t,n){this._coll=t,this.id=n,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return ot(this,void 0,void 0,(function(){var t,n,r,i;return st(this,(function(o){switch(o.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:Je.a.stringify(Te(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((n=o.sent()).code)throw n;if(r=Je.a.parse(n.inserted),1==(i=Je.a.parse(n.ok))&&1==r)return[2,it(it({},n),{ok:i,inserted:r})];throw new Error(nt.message)}}))}))},e.prototype.get=function(){return ot(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,{data:"null"!==t.data?Y.formatField(Je.a.parse(t.data)):Je.a.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return ot(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Je.a.stringify(Te(e),{relaxed:!1}),upsert:!0},[4,this._request.send(ut,t)];case 1:if((n=r.sent()).code)throw n;return[2,it(it({},n),{updated:Je.a.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},e.prototype.update=function(e){return ot(this,void 0,void 0,(function(){var t,n;return st(this,(function(r){switch(r.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Je.a.stringify(Ce.encode(e),{relaxed:!1})},[4,this._request.send(ut,t)];case 1:if((n=r.sent()).code)throw n;return[2,it(it({},n),{updated:Je.a.parse(n.updated)})]}}))}))},e.prototype.delete=function(){return ot(this,void 0,void 0,(function(){var e,t;return st(this,(function(n){switch(n.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=n.sent()).code)throw t;return[2,it(it({},t),{deleted:Je.a.parse(t.deleted)})]}}))}))},e}(),ft=function(e,t){this._coll=t,this._transaction=e},ct=function(){var e=function(t,n){return(e=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])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),lt=function(e){function t(t,n){return e.call(this,t,n)||this}return ct(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new at(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new at(this._transaction,this._coll,t).create(e)},t}(ft),ht=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{a(r.next(e))}catch(e){o(e)}}function u(e){try{a(r.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}a((r=r.apply(e,t||[])).next())}))},pt=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},dt=function(){function e(e){this._db=e,this._request=new gt.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new lt(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return ht(this,void 0,void 0,(function(){var e,t;return pt(this,(function(n){switch(n.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=n.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return ht(this,void 0,void 0,(function(){var t,n;return pt(this,(function(r){switch(r.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=e,[2,n]}}))}))},e}();function yt(){return ht(this,void 0,void 0,(function(){var e;return pt(this,(function(t){switch(t.label){case 0:return[4,(e=new dt(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function _t(e,t){return void 0===t&&(t=3),ht(this,void 0,void 0,(function(){var n,r,i,o,s=this;return pt(this,(function(u){switch(u.label){case 0:return u.trys.push([0,4,,10]),[4,(n=new dt(this)).init()];case 1:return u.sent(),[4,e(n)];case 2:if(r=u.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return u.sent(),[2,r];case 4:if(i=u.sent(),!1===n.inited)throw i;return o=function(e){return ht(s,void 0,void 0,(function(){return pt(this,(function(t){switch(t.label){case 0:if(n.aborted||n.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,n.rollback()];case 2:return t.sent(),[3,4];case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===n.aborted)throw n.abortReason;throw e}}))}))},t<=0?[4,o(i)]:[3,6];case 5:u.sent(),u.label=6;case 6:return i&&i.code===rt.code?[4,_t.bind(this)(e,--t)]:[3,8];case 7:return[2,u.sent()];case 8:return[4,o(i)];case 9:return u.sent(),[3,10];case 10:return[2]}}))}))}var gt=function(){function e(e){this.config=e,this.Geo=o,this.serverDate=k,this.command=Ve,this.RegExp=tt,this.startTransaction=yt,this.runTransaction=_t,this.logicCommand=de,this.updateCommand=le,this.queryCommand=be}return e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new We(this,e)},e.prototype.createCollection=function(t){var n={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",n)},e}()}])}));