@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.
- package/Dockerfile +15 -0
- package/README.md +1 -1
- package/_exmaple/assets/scripts/function/function.ts +99 -0
- package/_exmaple/assets/scripts/index.ts +99 -0
- package/_exmaple/assets/scripts/request.ts +11 -0
- package/_exmaple/index.html +15 -0
- package/_exmaple/package.json +33 -0
- package/_exmaple/tsconfig.json +71 -0
- package/_exmaple/typings.d.ts +0 -0
- package/_exmaple/webpack.config.js +42 -0
- package/cdnjs/1.0.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.0/cloudbase.database.js +8 -0
- package/cdnjs/1.0.0/cloudbase.full.js +8 -0
- package/cdnjs/1.0.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.0/cloudbase.js +1 -0
- package/cdnjs/1.0.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.1/cloudbase.database.js +8 -0
- package/cdnjs/1.0.1/cloudbase.full.js +8 -0
- package/cdnjs/1.0.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.1/cloudbase.js +1 -0
- package/cdnjs/1.0.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.2/cloudbase.database.js +8 -0
- package/cdnjs/1.0.2/cloudbase.full.js +8 -0
- package/cdnjs/1.0.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.2/cloudbase.js +1 -0
- package/cdnjs/1.0.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.3/cloudbase.database.js +8 -0
- package/cdnjs/1.0.3/cloudbase.full.js +8 -0
- package/cdnjs/1.0.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.3/cloudbase.js +1 -0
- package/cdnjs/1.0.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.0.4/cloudbase.auth.js +1 -0
- package/cdnjs/1.0.4/cloudbase.database.js +8 -0
- package/cdnjs/1.0.4/cloudbase.full.js +8 -0
- package/cdnjs/1.0.4/cloudbase.functions.js +1 -0
- package/cdnjs/1.0.4/cloudbase.js +1 -0
- package/cdnjs/1.0.4/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.0/cloudbase.database.js +8 -0
- package/cdnjs/1.1.0/cloudbase.full.js +8 -0
- package/cdnjs/1.1.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.0/cloudbase.js +1 -0
- package/cdnjs/1.1.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.1/cloudbase.database.js +8 -0
- package/cdnjs/1.1.1/cloudbase.full.js +8 -0
- package/cdnjs/1.1.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.1/cloudbase.js +1 -0
- package/cdnjs/1.1.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.2/cloudbase.database.js +8 -0
- package/cdnjs/1.1.2/cloudbase.full.js +8 -0
- package/cdnjs/1.1.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.2/cloudbase.js +1 -0
- package/cdnjs/1.1.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.3/cloudbase.database.js +8 -0
- package/cdnjs/1.1.3/cloudbase.full.js +8 -0
- package/cdnjs/1.1.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.3/cloudbase.js +1 -0
- package/cdnjs/1.1.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.1.4/cloudbase.auth.js +1 -0
- package/cdnjs/1.1.4/cloudbase.database.js +8 -0
- package/cdnjs/1.1.4/cloudbase.full.js +8 -0
- package/cdnjs/1.1.4/cloudbase.functions.js +1 -0
- package/cdnjs/1.1.4/cloudbase.js +1 -0
- package/cdnjs/1.1.4/cloudbase.storage.js +1 -0
- package/cdnjs/1.2.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.2.1/cloudbase.database.js +8 -0
- package/cdnjs/1.2.1/cloudbase.full.js +8 -0
- package/cdnjs/1.2.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.2.1/cloudbase.js +1 -0
- package/cdnjs/1.2.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.2.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.2.2/cloudbase.database.js +8 -0
- package/cdnjs/1.2.2/cloudbase.full.js +8 -0
- package/cdnjs/1.2.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.2.2/cloudbase.js +1 -0
- package/cdnjs/1.2.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.2.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.2.3/cloudbase.database.js +8 -0
- package/cdnjs/1.2.3/cloudbase.full.js +8 -0
- package/cdnjs/1.2.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.2.3/cloudbase.js +1 -0
- package/cdnjs/1.2.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.0/cloudbase.database.js +8 -0
- package/cdnjs/1.3.0/cloudbase.full.js +8 -0
- package/cdnjs/1.3.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.0/cloudbase.js +1 -0
- package/cdnjs/1.3.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.1/cloudbase.database.js +8 -0
- package/cdnjs/1.3.1/cloudbase.full.js +8 -0
- package/cdnjs/1.3.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.1/cloudbase.js +1 -0
- package/cdnjs/1.3.1/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.2/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.2/cloudbase.database.js +8 -0
- package/cdnjs/1.3.2/cloudbase.full.js +8 -0
- package/cdnjs/1.3.2/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.2/cloudbase.js +1 -0
- package/cdnjs/1.3.2/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.2/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.3/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.3/cloudbase.database.js +8 -0
- package/cdnjs/1.3.3/cloudbase.full.js +8 -0
- package/cdnjs/1.3.3/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.3/cloudbase.js +1 -0
- package/cdnjs/1.3.3/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.3/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.database.js +8 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.full.js +8 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.4-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.5/cloudbase.analytics.js +1 -0
- package/cdnjs/1.3.5/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.5/cloudbase.database.js +10 -0
- package/cdnjs/1.3.5/cloudbase.full.js +10 -0
- package/cdnjs/1.3.5/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.5/cloudbase.js +1 -0
- package/cdnjs/1.3.5/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.5/cloudbase.storage.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.3.5-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.0/cloudbase.database.js +10 -0
- package/cdnjs/1.4.0/cloudbase.full.js +10 -0
- package/cdnjs/1.4.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.0/cloudbase.js +1 -0
- package/cdnjs/1.4.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.1/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.1/cloudbase.database.js +10 -0
- package/cdnjs/1.4.1/cloudbase.full.js +10 -0
- package/cdnjs/1.4.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.1/cloudbase.js +1 -0
- package/cdnjs/1.4.1/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.1-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.4.2-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.0/cloudbase.database.js +10 -0
- package/cdnjs/1.5.0/cloudbase.full.js +10 -0
- package/cdnjs/1.5.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.0/cloudbase.js +1 -0
- package/cdnjs/1.5.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.1/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.1/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.1/cloudbase.database.js +26 -0
- package/cdnjs/1.5.1/cloudbase.full.js +26 -0
- package/cdnjs/1.5.1/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.1/cloudbase.js +1 -0
- package/cdnjs/1.5.1/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.1/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.database.js +10 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.full.js +10 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.1-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.database.js +26 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.full.js +26 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.5.3-alpha.0/cloudbase.storage.js +1 -0
- package/cdnjs/1.6.0/cloudbase.analytics.js +1 -0
- package/cdnjs/1.6.0/cloudbase.auth.js +1 -0
- package/cdnjs/1.6.0/cloudbase.database.js +26 -0
- package/cdnjs/1.6.0/cloudbase.full.js +26 -0
- package/cdnjs/1.6.0/cloudbase.functions.js +1 -0
- package/cdnjs/1.6.0/cloudbase.js +1 -0
- package/cdnjs/1.6.0/cloudbase.realtime.js +1 -0
- package/cdnjs/1.6.0/cloudbase.storage.js +1 -0
- package/{CHANGELOG.md → changelog.md} +0 -0
- package/dist/README.md +153 -0
- package/{app → dist/app}/index.d.ts +1 -0
- package/{app → dist/app}/index.js +0 -0
- package/dist/app/index.js.map +1 -0
- package/{app → dist/app}/internal.d.ts +0 -0
- package/{app → dist/app}/internal.js +0 -0
- package/{app → dist/app}/internal.js.map +0 -0
- package/{app → dist/app}/openuri.d.ts +0 -0
- package/{app → dist/app}/openuri.js +2 -1
- package/{app → dist/app}/openuri.js.map +1 -1
- package/{app → dist/app}/request.d.ts +4 -3
- package/{app → dist/app}/request.js +20 -12
- package/dist/app/request.js.map +1 -0
- package/{app → dist/app}/storage.d.ts +0 -0
- package/{app → dist/app}/storage.js +0 -0
- package/{app → dist/app}/storage.js.map +0 -0
- package/{auth → dist/auth}/consts.d.ts +21 -4
- package/{auth → dist/auth}/consts.js +27 -5
- package/dist/auth/consts.js.map +1 -0
- package/{auth → dist/auth}/index.d.ts +83 -34
- package/{auth → dist/auth}/index.js +239 -92
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/models.d.ts +284 -0
- package/{oauthclient → dist/auth}/models.js +1 -0
- package/dist/auth/models.js.map +1 -0
- package/{captcha → dist/captcha}/index.d.ts +0 -0
- package/{captcha → dist/captcha}/index.js +4 -2
- package/dist/captcha/index.js.map +1 -0
- package/dist/changelog.md +30 -0
- package/dist/function/index.d.ts +38 -0
- package/dist/function/index.js +80 -0
- package/dist/function/index.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/{oauthclient → dist/oauthclient}/consts.d.ts +0 -0
- package/{oauthclient → dist/oauthclient}/consts.js +0 -0
- package/{oauthclient → dist/oauthclient}/consts.js.map +0 -0
- package/{oauthclient → dist/oauthclient}/index.d.ts +0 -0
- package/{oauthclient → dist/oauthclient}/index.js +2 -2
- package/dist/oauthclient/index.js.map +1 -0
- package/{oauthclient → dist/oauthclient}/interface.d.ts +4 -0
- package/{oauthclient → dist/oauthclient}/interface.js +0 -0
- package/{oauthclient → dist/oauthclient}/interface.js.map +1 -1
- package/{oauthclient → dist/oauthclient}/models.d.ts +12 -11
- package/{auth → dist/oauthclient}/models.js +0 -0
- package/{oauthclient → dist/oauthclient}/models.js.map +0 -0
- package/{oauthclient → dist/oauthclient}/oauthclient.d.ts +11 -7
- package/{oauthclient → dist/oauthclient}/oauthclient.js +27 -12
- package/dist/oauthclient/oauthclient.js.map +1 -0
- package/dist/package.json +32 -0
- package/{utils/single-promise.d.ts → dist/utils/promise.d.ts} +3 -3
- package/{utils/single-promise.js → dist/utils/promise.js} +6 -6
- package/dist/utils/promise.js.map +1 -0
- package/{utils → dist/utils}/uuid.d.ts +0 -0
- package/{utils → dist/utils}/uuid.js +0 -0
- package/{utils → dist/utils}/uuid.js.map +0 -0
- package/docs/dev.md +71 -0
- package/docs/errlog.md +79 -0
- package/package.json +3 -2
- package/publish.sh +2 -0
- package/src/app/index.ts +83 -0
- package/src/app/internal.ts +26 -0
- package/src/app/openuri.ts +111 -0
- package/src/app/request.ts +66 -0
- package/src/app/storage.ts +58 -0
- package/src/auth/consts.ts +74 -0
- package/src/auth/index.ts +718 -0
- package/src/auth/models.ts +352 -0
- package/src/captcha/index.ts +170 -0
- package/src/function/index.ts +103 -0
- package/src/index.ts +32 -0
- package/src/oauthclient/consts.ts +48 -0
- package/src/oauthclient/index.ts +33 -0
- package/src/oauthclient/interface.ts +34 -0
- package/src/oauthclient/models.ts +50 -0
- package/src/oauthclient/oauthclient.ts +487 -0
- package/src/utils/promise.ts +41 -0
- package/src/utils/uuid.ts +11 -0
- package/test/e2e/cases/custom-login.test.js +122 -0
- package/test/e2e/cases/index.test.js +61 -0
- package/test/e2e/cases/login-state.test.js +89 -0
- package/test/e2e/environment.js +39 -0
- package/test/e2e/global_setup.js +33 -0
- package/test/e2e/global_teardown.js +15 -0
- package/test/e2e/setup.js +37 -0
- package/test/unit/index.test.js +89 -0
- package/test/web/cases/auth/index.js +256 -0
- package/test/web/cases/database/collection.js +173 -0
- package/test/web/cases/database/command.js +754 -0
- package/test/web/cases/database/date.js +122 -0
- package/test/web/cases/database/db.js +20 -0
- package/test/web/cases/database/document.js +160 -0
- package/test/web/cases/database/geo-advanced.js +327 -0
- package/test/web/cases/database/geo.js +105 -0
- package/test/web/cases/database/index.js +315 -0
- package/test/web/cases/database/order.js +83 -0
- package/test/web/cases/database/realtime.js +102 -0
- package/test/web/cases/database/regex.js +140 -0
- package/test/web/cases/ext/index.js +88 -0
- package/test/web/cases/function/index.js +77 -0
- package/test/web/cases/storage/cos.jpeg +0 -0
- package/test/web/cases/storage/index.js +207 -0
- package/test/web/index.html +63 -0
- package/test/web/index.js +109 -0
- package/test/web/util.js +80 -0
- package/tsconfig.json +35 -0
- package/wiki/README.md +75 -0
- package/app/index.js.map +0 -1
- package/app/request.js.map +0 -1
- package/auth/consts.js.map +0 -1
- package/auth/index.js.map +0 -1
- package/auth/models.d.ts +0 -158
- package/auth/models.js.map +0 -1
- package/captcha/index.js.map +0 -1
- package/index.d.ts +0 -8
- package/index.js +0 -17
- package/index.js.map +0 -1
- package/oauthclient/index.js.map +0 -1
- package/oauthclient/oauthclient.js.map +0 -1
- package/utils/single-promise.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
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 r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";(function(e,n){r.d(t,"a",(function(){return Se}));var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{};function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(e,t){return e(t={exports:{}},t.exports),t.exports}for(var u=function(e){var t=g(e),r=t[0],n=t[1];return 3*(r+n)/4-n},f=function(e){var t,r,n=g(e),i=n[0],o=n[1],s=new h(function(e,t,r){return 3*(t+r)/4-r}(0,i,o)),u=0,f=o>0?i-4:i;for(r=0;r<f;r+=4)t=l[e.charCodeAt(r)]<<18|l[e.charCodeAt(r+1)]<<12|l[e.charCodeAt(r+2)]<<6|l[e.charCodeAt(r+3)],s[u++]=t>>16&255,s[u++]=t>>8&255,s[u++]=255&t;2===o&&(t=l[e.charCodeAt(r)]<<2|l[e.charCodeAt(r+1)]>>4,s[u++]=255&t);1===o&&(t=l[e.charCodeAt(r)]<<10|l[e.charCodeAt(r+1)]<<4|l[e.charCodeAt(r+2)]>>2,s[u++]=t>>8&255,s[u++]=255&t);return s},a=function(e){for(var t,r=e.length,n=r%3,i=[],o=0,s=r-n;o<s;o+=16383)i.push(_(e,o,o+16383>s?s:o+16383));1===n?(t=e[r-1],i.push(c[t>>2]+c[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],i.push(c[t>>10]+c[t>>4&63]+c[t<<2&63]+"="));return i.join("")},c=[],l=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=0,y=p.length;d<y;++d)c[d]=p[d],l[p.charCodeAt(d)]=d;function g(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function _(e,t,r){for(var n,i,o=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),o.push(c[(i=n)>>18&63]+c[i>>12&63]+c[i>>6&63]+c[63&i]);return o.join("")}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63;var b={byteLength:u,toByteArray:f,fromByteArray:a},m=function(e,t,r,n,i){var o,s,u=8*i-n-1,f=(1<<u)-1,a=f>>1,c=-7,l=r?i-1:0,h=r?-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+=n;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-a;else{if(o===f)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=a}return(p?-1:1)*s*Math.pow(2,o-n)},w=function(e,t,r,n,i,o){var s,u,f,a=8*o-i-1,c=(1<<a)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?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*(f=Math.pow(2,-s))<1&&(s--,f*=2),(t+=s+l>=1?h/f:h*Math.pow(2,1-l))*f>=2&&(s++,f/=2),s+l>=c?(u=0,s=c):s+l>=1?(u=(t*f-1)*Math.pow(2,i),s+=l):(u=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&u,p+=d,u/=256,i-=8);for(s=s<<i|u,a+=i;a>0;e[r+p]=255&s,p+=d,s/=256,a-=8);e[r+p-d]|=128*y},O=s((function(e,t){var r="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=i,t.SlowBuffer=function(e){+e!=e&&(e=0);return i.alloc(+e)},t.INSPECT_MAX_BYTES=50;function n(e){if(e>2147483647)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,i.prototype),t}function i(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return o(e,t,r)}function o(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!i.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|l(e,t),o=n(r),s=o.write(e,t);s!==r&&(o=o.slice(0,s));return o}(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(e));if($(e,ArrayBuffer)||e&&$(e.buffer,ArrayBuffer))return a(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&($(e,SharedArrayBuffer)||e&&$(e.buffer,SharedArrayBuffer)))return a(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var o=e.valueOf&&e.valueOf();if(null!=o&&o!==e)return i.from(o,t,r);var s=function(e){if(i.isBuffer(e)){var t=0|c(e.length),r=n(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||q(e.length)?n(0):f(e);if("Buffer"===e.type&&Array.isArray(e.data))return f(e.data)}(e);if(s)return s;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return i.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(e))}function s(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return s(e),n(e<0?0:0|c(e))}function f(e){for(var t=e.length<0?0:0|c(e.length),r=n(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function a(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,i.prototype),n}function c(e){if(e>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647..toString(16)+" bytes");return 0|e}function l(e,t){if(i.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||$(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(e));var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return x(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return C(e).length;default:if(o)return n?-1:x(e).length;t=(""+t).toLowerCase(),o=!0}}function h(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return B(this,t,r);case"ascii":return E(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function p(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function d(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),q(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=i.from(t,n)),i.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var o,s=1,u=e.length,f=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,u/=2,f/=2,r/=2}function a(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<u;o++)if(a(e,o)===a(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===f)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+f>u&&(r=u-f),o=r;o>=0;o--){for(var l=!0,h=0;h<f;h++)if(a(e,o+h)!==a(t,h)){l=!1;break}if(l)return o}return-1}function g(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var u=parseInt(t.substr(2*s,2),16);if(q(u))return s;e[r+s]=u}return s}function _(e,t,r,n){return Y(x(t,e.length-r),e,r,n)}function O(e,t,r,n){return Y(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function N(e,t,r,n){return O(e,t,r,n)}function S(e,t,r,n){return Y(C(t),e,r,n)}function v(e,t,r,n){return Y(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?b.fromByteArray(e):b.fromByteArray(e.slice(t,r))}function B(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,u,f,a=e[i],c=null,l=a>239?4:a>223?3:a>191?2:1;if(i+l<=r)switch(l){case 1:a<128&&(c=a);break;case 2:128==(192&(o=e[i+1]))&&(f=(31&a)<<6|63&o)>127&&(c=f);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(f=(15&a)<<12|(63&o)<<6|63&s)>2047&&(f<55296||f>57343)&&(c=f);break;case 4:o=e[i+1],s=e[i+2],u=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(f=(15&a)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&f<1114112&&(c=f)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.kMaxLength=2147483647,i.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(e,t,r){return o(e,t,r)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(e,t,r){return function(e,t,r){return s(e),e<=0?n(e):void 0!==t?"string"==typeof r?n(e).fill(t,r):n(e).fill(t):n(e)}(e,t,r)},i.allocUnsafe=function(e){return u(e)},i.allocUnsafeSlow=function(e){return u(e)},i.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==i.prototype},i.compare=function(e,t){if($(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),$(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(e)||!i.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,o=0,s=Math.min(r,n);o<s;++o)if(e[o]!==t[o]){r=e[o],n=t[o];break}return r<n?-1:n<r?1:0},i.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}},i.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return i.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=i.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){var s=e[r];if($(s,Uint8Array)&&(s=i.from(s)),!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},i.byteLength=l,i.prototype._isBuffer=!0,i.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)p(this,t,t+1);return this},i.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)p(this,t,t+3),p(this,t+1,t+2);return this},i.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)p(this,t,t+7),p(this,t+1,t+6),p(this,t+2,t+5),p(this,t+3,t+4);return this},i.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?B(this,0,e):h.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(e){if(!i.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===i.compare(this,e)},i.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},r&&(i.prototype[r]=i.prototype.inspect),i.prototype.compare=function(e,t,r,n,o){if($(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(e));if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(o>>>=0)-(n>>>=0),u=(r>>>=0)-(t>>>=0),f=Math.min(s,u),a=this.slice(n,o),c=e.slice(t,r),l=0;l<f;++l)if(a[l]!==c[l]){s=a[l],u=c[l];break}return s<u?-1:u<s?1:0},i.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},i.prototype.indexOf=function(e,t,r){return d(this,e,t,r,!0)},i.prototype.lastIndexOf=function(e,t,r){return d(this,e,t,r,!1)},i.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return O(this,e,t,r);case"latin1":case"binary":return N(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function I(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=F[e[o]];return i}function D(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,o,s){if(!i.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function L(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,i){return t=+t,r>>>=0,i||L(e,0,r,4),w(e,t,r,n,23,4),r+4}function M(e,t,r,n,i){return t=+t,r>>>=0,i||L(e,0,r,8),w(e,t,r,n,52,8),r+8}i.prototype.slice=function(e,t){var r=this.length;(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);var n=this.subarray(e,t);return Object.setPrototypeOf(n,i.prototype),n},i.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},i.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},i.prototype.readUInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},i.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},i.prototype.readInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(e,t){e>>>=0,t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return e>>>=0,t||R(e,4,this.length),m(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||R(e,4,this.length),m(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||R(e,8,this.length),m(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||R(e,8,this.length),m(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},i.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},i.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},i.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0,s=1,u=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===u&&0!==this[t+o-1]&&(u=1),this[t+o]=(e/s>>0)-u&255;return t+r},i.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-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+r},i.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},i.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},i.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},i.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},i.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},i.prototype.copy=function(e,t,r,n){if(!i.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var o=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var s=o-1;s>=0;--s)e[s+t]=this[s+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return o},i.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var u=i.isBuffer(e)?e:i.from(e,n),f=u.length;if(0===f)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=u[s%f]}return this};var j=/[^+/0-9A-Za-z-_]/g;function x(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function C(e){return b.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function $(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function q(e){return e!=e}var F=function(){for(var e=new Array(256),t=0;t<16;++t)for(var r=16*t,n=0;n<16;++n)e[r+n]="0123456789abcdef"[t]+"0123456789abcdef"[n];return e}()})),N=(O.Buffer,O.SlowBuffer,O.INSPECT_MAX_BYTES,O.kMaxLength,{}),S="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 r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e},v=/%[sdj%]/g;function A(e){if(!C(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(T(arguments[r]));return t.join(" ")}r=1;for(var n=arguments,i=n.length,o=String(e).replace(v,(function(e){if("%%"===e)return"%";if(r>=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r<i;s=n[++r])j(s)||!q(s)?o+=" "+s:o+=" "+T(s);return o}var B,E={};function T(e,t){var r={seen:[],stylize:D};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),M(t)?r.showHidden=t:t&&V(r,t),Y(r.showHidden)&&(r.showHidden=!1),Y(r.depth)&&(r.depth=2),Y(r.colors)&&(r.colors=!1),Y(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=I),R(r,e,r.depth)}function I(e,t){var r=T.styles[t];return r?"["+T.colors[r][0]+"m"+e+"["+T.colors[r][1]+"m":e}function D(e,t){return e}function R(e,t,r){if(e.customInspect&&t&&z(t.inspect)&&t.inspect!==T&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return C(n)||(n=R(e,n,r)),n}var i=function(e,t){if(Y(t))return e.stylize("undefined","undefined");if(C(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(x(t))return e.stylize(""+t,"number");if(M(t))return e.stylize(""+t,"boolean");if(j(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),k(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return P(t);if(0===o.length){if(z(t)){var u=t.name?": "+t.name:"";return e.stylize("[Function"+u+"]","special")}if($(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(F(t))return e.stylize(Date.prototype.toString.call(t),"date");if(k(t))return P(t)}var f,a="",c=!1,l=["{","}"];(U(t)&&(c=!0,l=["[","]"]),z(t))&&(a=" [Function"+(t.name?": "+t.name:"")+"]");return $(t)&&(a=" "+RegExp.prototype.toString.call(t)),F(t)&&(a=" "+Date.prototype.toUTCString.call(t)),k(t)&&(a=" "+P(t)),0!==o.length||c&&0!=t.length?r<0?$(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),f=c?function(e,t,r,n,i){for(var o=[],s=0,u=t.length;s<u;++s)W(t,String(s))?o.push(L(e,t,r,n,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(L(e,t,r,n,i,!0))})),o}(e,t,r,s,o):o.map((function(n){return L(e,t,r,s,n,c)})),e.seen.pop(),function(e,t,r){if(e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(f,a,l)):l[0]+a+l[1]}function P(e){return"["+Error.prototype.toString.call(e)+"]"}function L(e,t,r,n,i,o){var s,u,f;if((f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?u=f.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):f.set&&(u=e.stylize("[Setter]","special")),W(n,i)||(s="["+i+"]"),u||(e.seen.indexOf(f.value)<0?(u=j(r)?R(e,f.value,null):R(e,f.value,r-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")),Y(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 U(e){return Array.isArray(e)}function M(e){return"boolean"==typeof e}function j(e){return null===e}function x(e){return"number"==typeof e}function C(e){return"string"==typeof e}function Y(e){return void 0===e}function $(e){return q(e)&&"[object RegExp]"===J(e)}function q(e){return"object"===babelHelpers.typeof(e)&&null!==e}function F(e){return q(e)&&"[object Date]"===J(e)}function k(e){return q(e)&&("[object Error]"===J(e)||e instanceof Error)}function z(e){return"function"==typeof e}function J(e){return Object.prototype.toString.call(e)}function G(e){return e<10?"0"+e.toString(10):e.toString(10)}T.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]},T.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(){var e=new Date,t=[G(e.getHours()),G(e.getMinutes()),G(e.getSeconds())].join(":");return[e.getDate(),H[e.getMonth()],t].join(" ")}function V(e,t){if(!t||!q(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function W(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var X={inherits:S,_extend:V,log:function(){console.log("%s - %s",K(),A.apply(null,arguments))},isBuffer:function(e){return n.isBuffer(e)},isPrimitive:function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===babelHelpers.typeof(e)||void 0===e},isFunction:z,isError:k,isDate:F,isObject:q,isRegExp:$,isUndefined:Y,isSymbol:function(e){return"symbol"===babelHelpers.typeof(e)},isString:C,isNumber:x,isNullOrUndefined:function(e){return null==e},isNull:j,isBoolean:M,isArray:U,inspect:T,deprecate:function t(r,n){if(Y(e.process))return function(){return t(r,n).apply(this,arguments)};var i=!1;return function(){return i||(console.error(n),i=!0),r.apply(this,arguments)}},format:A,debuglog:function(e){if(Y(B)&&(B=""),e=e.toUpperCase(),!E[e])if(new RegExp("\\b"+e+"\\b","i").test(B)){E[e]=function(){var t=A.apply(null,arguments);console.error("%s %d: %s",e,0,t)}}else E[e]=function(){};return E[e]}},Z=s((function(e,t){function r(e){const t=O.Buffer.alloc(e);for(let r=0;r<e;++r)t[r]=Math.floor(256*Math.random());return t}if(Object.defineProperty(t,"__esModule",{value:!0}),t.deprecate=t.isObjectLike=t.isDate=t.isBuffer=t.haveBuffer=t.isBigUInt64Array=t.isBigInt64Array=t.isUint8Array=t.randomBytes=t.normalizedFunctionString=void 0,t.normalizedFunctionString=function(e){return e.toString().replace("function(","function (")},t.randomBytes=r,"undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues)t.randomBytes=e=>window.crypto.getRandomValues(O.Buffer.alloc(e));else{try{t.randomBytes=N.randomBytes}catch(e){}null==t.randomBytes&&(t.randomBytes=r)}function n(e){return"object"==typeof e&&null!==e}t.isUint8Array=function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},t.isBigInt64Array=function(e){return"[object BigInt64Array]"===Object.prototype.toString.call(e)},t.isBigUInt64Array=function(e){return"[object BigUint64Array]"===Object.prototype.toString.call(e)},t.haveBuffer=function(){return void 0!==i&&void 0!==i.Buffer},t.isBuffer=function(e){var t;return"object"==typeof e&&"Buffer"===(null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name)},t.isDate=function(e){return n(e)&&"[object Date]"===Object.prototype.toString.call(e)},t.isObjectLike=n,t.deprecate=function(e,t){if("undefined"==typeof window||"undefined"==typeof self)return X.deprecate(e,t);let r=!1;return function(...n){return r||(console.warn(t),r=!0),e.apply(this,...n)}}}));o(Z);Z.deprecate,Z.isObjectLike,Z.isDate,Z.isBuffer,Z.haveBuffer,Z.isBigUInt64Array,Z.isBigInt64Array,Z.isUint8Array,Z.randomBytes,Z.normalizedFunctionString;var Q=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ensureBuffer=void 0,t.ensureBuffer=function(e){if(Z.isBuffer(e))return e;if(ArrayBuffer.isView(e))return O.Buffer.from(e.buffer);if(e instanceof ArrayBuffer)return O.Buffer.from(e);throw new TypeError("Must use either Buffer or TypedArray")}}));o(Q);Q.ensureBuffer;var ee=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.parseUUID=void 0;const r=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;t.parseUUID=function(e){if("string"!=typeof e)throw new TypeError("Invalid type for UUID, expected string but got "+typeof e);if(!r.test(e))throw new TypeError("Invalid format for UUID: "+e);let t;const n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}}));o(ee);ee.parseUUID;var te=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Binary=void 0;class r{constructor(e,t){if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new TypeError("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=t?t:r.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=O.Buffer.alloc(r.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=O.Buffer.from(e,"binary"):Array.isArray(e)?this.buffer=O.Buffer.from(e):this.buffer=Q.ensureBuffer(e),this.position=this.buffer.byteLength)}put(e){if("string"==typeof e&&1!==e.length)throw new TypeError("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new TypeError("only accepts single character Uint8Array or Array");let t;if(t="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0],t<0||t>255)throw new TypeError("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=t;else{const e=O.Buffer.alloc(r.BUFFER_SIZE+this.buffer.length);this.buffer.copy(e,0,0,this.buffer.length),this.buffer=e,this.buffer[this.position++]=t}}write(e,t){if(t="number"==typeof t?t:this.position,this.buffer.length<t+e.length){const t=O.Buffer.alloc(this.buffer.length+e.length);this.buffer.copy(t,0,0,this.buffer.length),this.buffer=t}ArrayBuffer.isView(e)?(this.buffer.set(Q.ensureBuffer(e),t),this.position=t+e.byteLength>this.position?t+e.length:this.position):"string"==typeof e&&(this.buffer.write(e,t,e.length,"binary"),this.position=t+e.length>this.position?t+e.length:this.position)}read(e,t){return t=t&&t>0?t:this.position,this.buffer.slice(e,e+t)}value(e){return(e=!!e)&&this.buffer.length===this.position?this.buffer:e?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)}length(){return this.position}toJSON(){return this.buffer.toString("base64")}toString(e){return this.buffer.toString(e)}toExtendedJSON(e){e=e||{};const t=this.buffer.toString("base64"),r=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===r.length?"0"+r:r}:{$binary:{base64:t,subType:1===r.length?"0"+r:r}}}static fromExtendedJSON(e,t){let n,i;if(t=t||{},"$binary"in e?t.legacy&&"string"==typeof e.$binary&&"$type"in e?(i=e.$type?parseInt(e.$type,16):0,n=O.Buffer.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(i=e.$binary.subType?parseInt(e.$binary.subType,16):0,n=O.Buffer.from(e.$binary.base64,"base64")):"$uuid"in e&&(i=4,n=O.Buffer.from(ee.parseUUID(e.$uuid))),!n)throw new TypeError("Unexpected Binary Extended JSON format "+JSON.stringify(e));return new r(n,i)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Binary("${this.value(!0).toString("hex")}", ${this.sub_type})`}}t.Binary=r,r.BSON_BINARY_SUBTYPE_DEFAULT=0,r.BUFFER_SIZE=256,r.SUBTYPE_DEFAULT=0,r.SUBTYPE_FUNCTION=1,r.SUBTYPE_BYTE_ARRAY=2,r.SUBTYPE_UUID_OLD=3,r.SUBTYPE_UUID=4,r.SUBTYPE_MD5=5,r.SUBTYPE_USER_DEFINED=128,Object.defineProperty(r.prototype,"_bsontype",{value:"Binary"})}));o(te);te.Binary;var re=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Code=void 0;class r{constructor(e,t){this.code=e,this.scope=t}toJSON(){return{code:this.code,scope:this.scope}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(e){return new r(e.$code,e.$scope)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){const e=this.toJSON();return`Code("${e.code}"${e.scope?", "+JSON.stringify(e.scope):""})`}}t.Code=r,Object.defineProperty(r.prototype,"_bsontype",{value:"Code"})}));o(re);re.Code;var ne=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DBRef=t.isDBRefLike=void 0,t.isDBRefLike=function(e){return Z.isObjectLike(e)&&null!=e.$id&&null!=e.$ref};class r{constructor(e,t,r,n){const i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=t,this.db=r,this.fields=n||{}}get namespace(){return this.collection}set namespace(e){this.collection=e}toJSON(){const e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e}toExtendedJSON(e){e=e||{};let t={$ref:this.collection,$id:this.oid};return e.legacy||(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields)),t}static fromExtendedJSON(e){const t=Object.assign({},e);return delete t.$ref,delete t.$id,delete t.$db,new r(e.$ref,e.$id,e.$db,t)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){const e=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return`DBRef("${this.namespace}", "${e}"${this.db?`, "${this.db}"`:""})`}}t.DBRef=r,Object.defineProperty(r.prototype,"_bsontype",{value:"DBRef"})}));o(ne);ne.DBRef,ne.isDBRefLike;var ie=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Long=void 0;let r=void 0;try{r=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){}const n={},i={};class o{constructor(e=0,t=0,r){this.low=0|e,this.high=0|t,this.unsigned=!!r,Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}static fromBits(e,t,r){return new o(e,t,r)}static fromInt(e,t){let r,s,u;return t?(u=0<=(e>>>=0)&&e<256)&&(s=i[e],s)?s:(r=o.fromBits(e,(0|e)<0?-1:0,!0),u&&(i[e]=r),r):(u=-128<=(e|=0)&&e<128)&&(s=n[e],s)?s:(r=o.fromBits(e,e<0?-1:0,!1),u&&(n[e]=r),r)}static fromNumber(e,t){if(isNaN(e))return t?o.UZERO:o.ZERO;if(t){if(e<0)return o.UZERO;if(e>=0x10000000000000000)return o.MAX_UNSIGNED_VALUE}else{if(e<=-0x8000000000000000)return o.MIN_VALUE;if(e+1>=0x8000000000000000)return o.MAX_VALUE}return e<0?o.fromNumber(-e,t).neg():o.fromBits(e%4294967296|0,e/4294967296|0,t)}static fromBigInt(e,t){return o.fromString(e.toString(),t)}static fromString(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return o.ZERO;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||36<r)throw RangeError("radix");let n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return o.fromString(e.substring(1),t,r).neg();const i=o.fromNumber(Math.pow(r,8));let s=o.ZERO;for(let t=0;t<e.length;t+=8){const n=Math.min(8,e.length-t),u=parseInt(e.substring(t,t+n),r);if(n<8){const e=o.fromNumber(Math.pow(r,n));s=s.mul(e).add(o.fromNumber(u))}else s=s.mul(i),s=s.add(o.fromNumber(u))}return s.unsigned=t,s}static fromBytes(e,t,r){return r?o.fromBytesLE(e,t):o.fromBytesBE(e,t)}static fromBytesLE(e,t){return new o(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)}static fromBytesBE(e,t){return new o(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}static isLong(e){return Z.isObjectLike(e)&&!0===e.__isLong__}static fromValue(e,t){return"number"==typeof e?o.fromNumber(e,t):"string"==typeof e?o.fromString(e,t):o.fromBits(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}add(e){o.isLong(e)||(e=o.fromValue(e));const t=this.high>>>16,r=65535&this.high,n=this.low>>>16,i=65535&this.low,s=e.high>>>16,u=65535&e.high,f=e.low>>>16;let a=0,c=0,l=0,h=0;return h+=i+(65535&e.low),l+=h>>>16,h&=65535,l+=n+f,c+=l>>>16,l&=65535,c+=r+u,a+=c>>>16,c&=65535,a+=t+s,a&=65535,o.fromBits(l<<16|h,a<<16|c,this.unsigned)}and(e){return o.isLong(e)||(e=o.fromValue(e)),o.fromBits(this.low&e.low,this.high&e.high,this.unsigned)}compare(e){if(o.isLong(e)||(e=o.fromValue(e)),this.eq(e))return 0;const t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?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}comp(e){return this.compare(e)}divide(e){if(o.isLong(e)||(e=o.fromValue(e)),e.isZero())throw Error("division by zero");if(r){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;const t=(this.unsigned?r.div_u:r.div_s)(this.low,this.high,e.low,e.high);return o.fromBits(t,r.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?o.UZERO:o.ZERO;let t,n,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return o.UZERO;if(e.gt(this.shru(1)))return o.UONE;i=o.UZERO}else{if(this.eq(o.MIN_VALUE)){if(e.eq(o.ONE)||e.eq(o.NEG_ONE))return o.MIN_VALUE;if(e.eq(o.MIN_VALUE))return o.ONE;return t=this.shr(1).div(e).shl(1),t.eq(o.ZERO)?e.isNegative()?o.ONE:o.NEG_ONE:(n=this.sub(e.mul(t)),i=t.add(n.div(e)),i)}if(e.eq(o.MIN_VALUE))return this.unsigned?o.UZERO:o.ZERO;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();i=o.ZERO}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));const r=Math.ceil(Math.log(t)/Math.LN2),s=r<=48?1:Math.pow(2,r-48);let u=o.fromNumber(t),f=u.mul(e);for(;f.isNegative()||f.gt(n);)t-=s,u=o.fromNumber(t,this.unsigned),f=u.mul(e);u.isZero()&&(u=o.ONE),i=i.add(u),n=n.sub(f)}return i}div(e){return this.divide(e)}equals(e){return o.isLong(e)||(e=o.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)}eq(e){return this.equals(e)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(o.MIN_VALUE)?64:this.neg().getNumBitsAbs();const e=0!==this.high?this.high:this.low;let t;for(t=31;t>0&&0==(e&1<<t);t--);return 0!==this.high?t+33:t+1}greaterThan(e){return this.comp(e)>0}gt(e){return this.greaterThan(e)}greaterThanOrEqual(e){return this.comp(e)>=0}gte(e){return this.greaterThanOrEqual(e)}ge(e){return this.greaterThanOrEqual(e)}isEven(){return 0==(1&this.low)}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return 1==(1&this.low)}isPositive(){return this.unsigned||this.high>=0}isZero(){return 0===this.high&&0===this.low}lessThan(e){return this.comp(e)<0}lt(e){return this.lessThan(e)}lessThanOrEqual(e){return this.comp(e)<=0}lte(e){return this.lessThanOrEqual(e)}modulo(e){if(o.isLong(e)||(e=o.fromValue(e)),r){const t=(this.unsigned?r.rem_u:r.rem_s)(this.low,this.high,e.low,e.high);return o.fromBits(t,r.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))}mod(e){return this.modulo(e)}rem(e){return this.modulo(e)}multiply(e){if(this.isZero())return o.ZERO;if(o.isLong(e)||(e=o.fromValue(e)),r){const t=r.mul(this.low,this.high,e.low,e.high);return o.fromBits(t,r.get_high(),this.unsigned)}if(e.isZero())return o.ZERO;if(this.eq(o.MIN_VALUE))return e.isOdd()?o.MIN_VALUE:o.ZERO;if(e.eq(o.MIN_VALUE))return this.isOdd()?o.MIN_VALUE:o.ZERO;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(o.TWO_PWR_24)&&e.lt(o.TWO_PWR_24))return o.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);const t=this.high>>>16,n=65535&this.high,i=this.low>>>16,s=65535&this.low,u=e.high>>>16,f=65535&e.high,a=e.low>>>16,c=65535&e.low;let l=0,h=0,p=0,d=0;return d+=s*c,p+=d>>>16,d&=65535,p+=i*c,h+=p>>>16,p&=65535,p+=s*a,h+=p>>>16,p&=65535,h+=n*c,l+=h>>>16,h&=65535,h+=i*a,l+=h>>>16,h&=65535,h+=s*f,l+=h>>>16,h&=65535,l+=t*c+n*a+i*f+s*u,l&=65535,o.fromBits(p<<16|d,l<<16|h,this.unsigned)}mul(e){return this.multiply(e)}negate(){return!this.unsigned&&this.eq(o.MIN_VALUE)?o.MIN_VALUE:this.not().add(o.ONE)}neg(){return this.negate()}not(){return o.fromBits(~this.low,~this.high,this.unsigned)}notEquals(e){return!this.equals(e)}neq(e){return this.notEquals(e)}ne(e){return this.notEquals(e)}or(e){return o.isLong(e)||(e=o.fromValue(e)),o.fromBits(this.low|e.low,this.high|e.high,this.unsigned)}shiftLeft(e){return o.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):o.fromBits(0,this.low<<e-32,this.unsigned)}shl(e){return this.shiftLeft(e)}shiftRight(e){return o.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?o.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):o.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)}shr(e){return this.shiftRight(e)}shiftRightUnsigned(e){if(o.isLong(e)&&(e=e.toInt()),0===(e&=63))return this;{const t=this.high;if(e<32){const r=this.low;return o.fromBits(r>>>e|t<<32-e,t>>>e,this.unsigned)}return 32===e?o.fromBits(t,0,this.unsigned):o.fromBits(t>>>e-32,0,this.unsigned)}}shr_u(e){return this.shiftRightUnsigned(e)}shru(e){return this.shiftRightUnsigned(e)}subtract(e){return o.isLong(e)||(e=o.fromValue(e)),this.add(e.neg())}sub(e){return this.subtract(e)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?4294967296*(this.high>>>0)+(this.low>>>0):4294967296*this.high+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(e){return e?this.toBytesLE():this.toBytesBE()}toBytesLE(){const 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]}toBytesBE(){const 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]}toSigned(){return this.unsigned?o.fromBits(this.low,this.high,!1):this}toString(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(o.MIN_VALUE)){const t=o.fromNumber(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}const t=o.fromNumber(Math.pow(e,6),this.unsigned);let r=this,n="";for(;;){const i=r.div(t);let o=(r.sub(i.mul(t)).toInt()>>>0).toString(e);if(r=i,r.isZero())return o+n;for(;o.length<6;)o="0"+o;n=""+o+n}}toUnsigned(){return this.unsigned?this:o.fromBits(this.low,this.high,!0)}xor(e){return o.isLong(e)||(e=o.fromValue(e)),o.fromBits(this.low^e.low,this.high^e.high,this.unsigned)}eqz(){return this.isZero()}le(e){return this.lessThanOrEqual(e)}toExtendedJSON(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(e,t){const r=o.fromString(e.$numberLong);return t&&t.relaxed?r.toNumber():r}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Long("${this.toString()}")`}}t.Long=o,o.TWO_PWR_24=o.fromInt(1<<24),o.MAX_UNSIGNED_VALUE=o.fromBits(-1,-1,!0),o.ZERO=o.fromInt(0),o.UZERO=o.fromInt(0,!0),o.ONE=o.fromInt(1),o.UONE=o.fromInt(1,!0),o.NEG_ONE=o.fromInt(-1),o.MAX_VALUE=o.fromBits(-1,2147483647,!1),o.MIN_VALUE=o.fromBits(0,-2147483648,!1),Object.defineProperty(o.prototype,"__isLong__",{value:!0}),Object.defineProperty(o.prototype,"_bsontype",{value:"Long"})}));o(ie);ie.Long;var oe=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Decimal128=void 0;const r=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,n=/^(\+|-)?(Infinity|inf)$/i,i=/^(\+|-)?NaN$/i,o=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),s=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),u=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),f=/^([-+])?(\d+)?$/;function a(e){return!isNaN(parseInt(e,10))}function c(e){const t=ie.Long.fromNumber(1e9);let r=ie.Long.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:r};for(let n=0;n<=3;n++)r=r.shiftLeft(32),r=r.add(new ie.Long(e.parts[n],0)),e.parts[n]=r.div(t).low,r=r.modulo(t);return{quotient:e,rem:r}}function l(e,t){throw new TypeError(`"${e}" is not a valid Decimal128 string - ${t}`)}class h{constructor(e){this.bytes=e}static fromString(e){let t=!1,c=!1,p=!1,d=0,y=0,g=0,_=0,b=0;const m=[0];let w=0,N=0,S=0,v=0,A=0,B=0,E=new ie.Long(0,0),T=new ie.Long(0,0),I=0,D=0;if(e.length>=7e3)throw new TypeError(e+" not a valid Decimal128 string");const R=e.match(r),P=e.match(n),L=e.match(i);if(!R&&!P&&!L||0===e.length)throw new TypeError(e+" not a valid Decimal128 string");if(R){const t=R[2],r=R[4],n=R[5],i=R[6];r&&void 0===i&&l(e,"missing exponent power"),r&&void 0===t&&l(e,"missing exponent base"),void 0===r&&(n||i)&&l(e,"missing e before exponent")}if("+"!==e[D]&&"-"!==e[D]||(t="-"===e[D++]),!a(e[D])&&"."!==e[D]){if("i"===e[D]||"I"===e[D])return new h(O.Buffer.from(t?s:u));if("N"===e[D])return new h(O.Buffer.from(o))}for(;a(e[D])||"."===e[D];)"."!==e[D]?(w<34&&("0"!==e[D]||p)&&(p||(b=y),p=!0,m[N++]=parseInt(e[D],10),w+=1),p&&(g+=1),c&&(_+=1),y+=1,D+=1):(c&&l(e,"contains multiple periods"),c=!0,D+=1);if(c&&!y)throw new TypeError(e+" not a valid Decimal128 string");if("e"===e[D]||"E"===e[D]){const t=e.substr(++D).match(f);if(!t||!t[2])return new h(O.Buffer.from(o));A=parseInt(t[0],10),D+=t[0].length}if(e[D])return new h(O.Buffer.from(o));if(S=0,w){if(v=w-1,d=g,1!==d)for(;"0"===e[b+d-1];)d-=1}else S=0,v=0,m[0]=0,g=1,w=1,d=0;for(A<=_&&_-A>16384?A=-6176:A-=_;A>6111;){if(v+=1,v-S>34){if(m.join("").match(/^0+$/)){A=6111;break}l(e,"overflow")}A-=1}for(;A<-6176||w<g;){if(0===v&&d<w){A=-6176,d=0;break}if(w<g?g-=1:v-=1,A<6111)A+=1;else{if(m.join("").match(/^0+$/)){A=6111;break}l(e,"overflow")}}if(v-S+1<d){let r=y;c&&(b+=1,r+=1),t&&(b+=1,r+=1);const n=parseInt(e[b+v+1],10);let i=0;if(n>=5&&(i=1,5===n))for(i=m[v]%2==1?1:0,B=b+v+2;B<r;B++)if(parseInt(e[B],10)){i=1;break}if(i){let e=v;for(;e>=0;e--)if(++m[e]>9&&(m[e]=0,0===e)){if(!(A<6111))return new h(O.Buffer.from(t?s:u));A+=1,m[e]=1}}}if(E=ie.Long.fromNumber(0),T=ie.Long.fromNumber(0),0===d)E=ie.Long.fromNumber(0),T=ie.Long.fromNumber(0);else if(v-S<17){let e=S;for(T=ie.Long.fromNumber(m[e++]),E=new ie.Long(0,0);e<=v;e++)T=T.multiply(ie.Long.fromNumber(10)),T=T.add(ie.Long.fromNumber(m[e]))}else{let e=S;for(E=ie.Long.fromNumber(m[e++]);e<=v-17;e++)E=E.multiply(ie.Long.fromNumber(10)),E=E.add(ie.Long.fromNumber(m[e]));for(T=ie.Long.fromNumber(m[e++]);e<=v;e++)T=T.multiply(ie.Long.fromNumber(10)),T=T.add(ie.Long.fromNumber(m[e]))}const U=function(e,t){if(!e&&!t)return{high:ie.Long.fromNumber(0),low:ie.Long.fromNumber(0)};const r=e.shiftRightUnsigned(32),n=new ie.Long(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new ie.Long(t.getLowBits(),0);let s=r.multiply(i),u=r.multiply(o);const f=n.multiply(i);let a=n.multiply(o);return s=s.add(u.shiftRightUnsigned(32)),u=new ie.Long(u.getLowBits(),0).add(f).add(a.shiftRightUnsigned(32)),s=s.add(u.shiftRightUnsigned(32)),a=u.shiftLeft(32).add(new ie.Long(a.getLowBits(),0)),{high:s,low:a}}(E,ie.Long.fromString("100000000000000000"));U.low=U.low.add(T),function(e,t){const r=e.high>>>0,n=t.high>>>0;if(r<n)return!0;if(r===n){if(e.low>>>0<t.low>>>0)return!0}return!1}(U.low,T)&&(U.high=U.high.add(ie.Long.fromNumber(1))),I=A+6176;const M={low:ie.Long.fromNumber(0),high:ie.Long.fromNumber(0)};U.high.shiftRightUnsigned(49).and(ie.Long.fromNumber(1)).equals(ie.Long.fromNumber(1))?(M.high=M.high.or(ie.Long.fromNumber(3).shiftLeft(61)),M.high=M.high.or(ie.Long.fromNumber(I).and(ie.Long.fromNumber(16383).shiftLeft(47))),M.high=M.high.or(U.high.and(ie.Long.fromNumber(0x7fffffffffff)))):(M.high=M.high.or(ie.Long.fromNumber(16383&I).shiftLeft(49)),M.high=M.high.or(U.high.and(ie.Long.fromNumber(562949953421311)))),M.low=U.low,t&&(M.high=M.high.or(ie.Long.fromString("9223372036854775808")));const j=O.Buffer.alloc(16);return D=0,j[D++]=255&M.low.low,j[D++]=M.low.low>>8&255,j[D++]=M.low.low>>16&255,j[D++]=M.low.low>>24&255,j[D++]=255&M.low.high,j[D++]=M.low.high>>8&255,j[D++]=M.low.high>>16&255,j[D++]=M.low.high>>24&255,j[D++]=255&M.high.low,j[D++]=M.high.low>>8&255,j[D++]=M.high.low>>16&255,j[D++]=M.high.low>>24&255,j[D++]=255&M.high.high,j[D++]=M.high.high>>8&255,j[D++]=M.high.high>>16&255,j[D++]=M.high.high>>24&255,new h(j)}toString(){let e,t=0;const r=new Array(36);for(let e=0;e<r.length;e++)r[e]=0;let n,i,o,s=0,u=!1,f={parts:[0,0,0,0]};const a=[];s=0;const l=this.bytes,h=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,p=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,d=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,y=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24;s=0;({low:new ie.Long(h,p),high:new ie.Long(d,y)}).high.lessThan(ie.Long.ZERO)&&a.push("-");const g=y>>26&31;if(g>>3==3){if(30===g)return a.join("")+"Infinity";if(31===g)return"NaN";e=y>>15&16383,n=8+(y>>14&1)}else n=y>>14&7,e=y>>17&16383;const _=e-6176;if(f.parts[0]=(16383&y)+((15&n)<<14),f.parts[1]=d,f.parts[2]=p,f.parts[3]=h,0===f.parts[0]&&0===f.parts[1]&&0===f.parts[2]&&0===f.parts[3])u=!0;else for(o=3;o>=0;o--){let e=0;const t=c(f);if(f=t.quotient,e=t.rem.low,e)for(i=8;i>=0;i--)r[9*o+i]=e%10,e=Math.floor(e/10)}if(u)t=1,r[s]=0;else for(t=36;!r[s];)t-=1,s+=1;const b=t-1+_;if(b>=34||b<=-7||_>0){if(t>34)return a.push("0"),_>0?a.push("E+"+_):_<0&&a.push("E"+_),a.join("");a.push(""+r[s++]),t-=1,t&&a.push(".");for(let e=0;e<t;e++)a.push(""+r[s++]);a.push("E"),b>0?a.push("+"+b):a.push(""+b)}else if(_>=0)for(let e=0;e<t;e++)a.push(""+r[s++]);else{let e=t+_;if(e>0)for(let t=0;t<e;t++)a.push(""+r[s++]);else a.push("0");for(a.push(".");e++<0;)a.push("0");for(let n=0;n<t-Math.max(e-1,0);n++)a.push(""+r[s++])}return a.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(e){return h.fromString(e.$numberDecimal)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Decimal128("${this.toString()}")`}}t.Decimal128=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Decimal128"})}));o(oe);oe.Decimal128;var se=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Double=void 0;class r{constructor(e){e instanceof Number&&(e=e.valueOf()),this.value=+e}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(e){if(e&&(e.legacy||e.relaxed&&isFinite(this.value)))return this.value;if(Object.is(Math.sign(this.value),-0))return{$numberDouble:"-"+this.value.toFixed(1)};let t;return Number.isInteger(this.value)?(t=this.value.toFixed(1),t.length>=13&&(t=this.value.toExponential(13).toUpperCase())):t=this.value.toString(),{$numberDouble:t}}static fromExtendedJSON(e,t){const n=parseFloat(e.$numberDouble);return t&&t.relaxed?n:new r(n)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Double(${this.toExtendedJSON().$numberDouble})`}}t.Double=r,Object.defineProperty(r.prototype,"_bsontype",{value:"Double"})}));o(se);se.Double;var ue=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Int32=void 0;class r{constructor(e){e instanceof Number&&(e=e.valueOf()),this.value=+e}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(e,t){return t&&t.relaxed?parseInt(e.$numberInt,10):new r(e.$numberInt)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Int32(${this.valueOf()})`}}t.Int32=r,Object.defineProperty(r.prototype,"_bsontype",{value:"Int32"})}));o(ue);ue.Int32;var fe=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MaxKey=void 0;class r{toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new r}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return"MaxKey()"}}t.MaxKey=r,Object.defineProperty(r.prototype,"_bsontype",{value:"MaxKey"})}));o(fe);fe.MaxKey;var ae=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MinKey=void 0;class r{toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new r}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return"MinKey()"}}t.MinKey=r,Object.defineProperty(r.prototype,"_bsontype",{value:"MinKey"})}));o(ae);ae.MinKey;var ce=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectId=void 0;const r=Z.randomBytes(5),n=new RegExp("^[0-9a-fA-F]{24}$"),i=[];for(let e=0;e<256;e++)i[e]=(e<=15?"0":"")+e.toString(16);const o=[];let s=0;for(;s<10;)o[48+s]=s++;for(;s<16;)o[55+s]=o[87+s]=s++;const u=Symbol("id");class f{constructor(e){if(e instanceof f&&(this[u]=e.id,this.__id=e.__id),"object"==typeof e&&e&&"id"in e&&("toHexString"in e&&"function"==typeof e.toHexString?this[u]=O.Buffer.from(e.toHexString(),"hex"):this[u]="string"==typeof e.id?O.Buffer.from(e.id):e.id),null!=e&&"number"!=typeof e||(this[u]=f.generate("number"==typeof e?e:void 0),f.cacheHexString&&(this.__id=this.id.toString("hex"))),ArrayBuffer.isView(e)&&12===e.byteLength&&(this[u]=Q.ensureBuffer(e)),"string"==typeof e)if(12===e.length){const t=O.Buffer.from(e);12===t.byteLength&&(this[u]=t)}else{if(24!==e.length||!n.test(e))throw new TypeError("Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters");this[u]=O.Buffer.from(e,"hex")}f.cacheHexString&&(this.__id=this.id.toString("hex"))}get id(){return this[u]}set id(e){this[u]=e,f.cacheHexString&&(this.__id=e.toString("hex"))}get generationTime(){return this.id.readInt32BE(0)}set generationTime(e){this.id.writeUInt32BE(e,0)}toHexString(){if(f.cacheHexString&&this.__id)return this.__id;const e=this.id.toString("hex");return f.cacheHexString&&!this.__id&&(this.__id=e),e}static getInc(){return f.index=(f.index+1)%16777215}static generate(e){"number"!=typeof e&&(e=~~(Date.now()/1e3));const t=f.getInc(),n=O.Buffer.alloc(12);return n.writeUInt32BE(e,0),n[4]=r[0],n[5]=r[1],n[6]=r[2],n[7]=r[3],n[8]=r[4],n[11]=255&t,n[10]=t>>8&255,n[9]=t>>16&255,n}toString(e){return e?this.id.toString(e):this.toHexString()}toJSON(){return this.toHexString()}equals(e){return null!=e&&(e instanceof f?this.toString()===e.toString():"string"==typeof e&&f.isValid(e)&&12===e.length&&this.id instanceof O.Buffer?e===this.id.toString("binary"):"string"==typeof e&&f.isValid(e)&&24===e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&f.isValid(e)&&12===e.length?O.Buffer.from(e).equals(this.id):"object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString&&e.toHexString()===this.toHexString())}getTimestamp(){const e=new Date,t=this.id.readUInt32BE(0);return e.setTime(1e3*Math.floor(t)),e}static createPk(){return new f}static createFromTime(e){const t=O.Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0]);return t.writeUInt32BE(e,0),new f(t)}static createFromHexString(e){if(void 0===e||null!=e&&24!==e.length)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new f(O.Buffer.from(e,"hex"))}static isValid(e){return null!=e&&("number"==typeof e||("string"==typeof e?12===e.length||24===e.length&&n.test(e):e instanceof f||(e instanceof O.Buffer&&12===e.length||"object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString&&("string"==typeof e.id?12===e.id.length:24===e.toHexString().length&&n.test(e.id.toString("hex"))))))}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(e){return new f(e.$oid)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`ObjectId("${this.toHexString()}")`}}t.ObjectId=f,f.index=~~(16777215*Math.random()),Object.defineProperty(f.prototype,"generate",{value:Z.deprecate(e=>f.generate(e),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(f.prototype,"getInc",{value:Z.deprecate(()=>f.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(f.prototype,"get_inc",{value:Z.deprecate(()=>f.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(f,"get_inc",{value:Z.deprecate(()=>f.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(f.prototype,"_bsontype",{value:"ObjectID"})}));o(ce);ce.ObjectId;var le=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONRegExp=void 0;class r{constructor(e,t){this.pattern=e,this.options=null!=t?t:"",this.options.split("").sort().join("");for(let e=0;e<this.options.length;e++)if("i"!==this.options[e]&&"m"!==this.options[e]&&"x"!==this.options[e]&&"l"!==this.options[e]&&"s"!==this.options[e]&&"u"!==this.options[e])throw new Error(`The regular expression option [${this.options[e]}] is not supported`)}static parseOptions(e){return e?e.split("").sort().join(""):""}toExtendedJSON(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(e){if("$regex"in e){if("string"==typeof e.$regex)return new r(e.$regex,r.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new r(e.$regularExpression.pattern,r.parseOptions(e.$regularExpression.options));throw new TypeError("Unexpected BSONRegExp EJSON object form: "+JSON.stringify(e))}}t.BSONRegExp=r,Object.defineProperty(r.prototype,"_bsontype",{value:"BSONRegExp"})}));o(le);le.BSONRegExp;var he=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONSymbol=void 0;class r{constructor(e){this.value=e}valueOf(){return this.value}toString(){return this.value}inspect(){return`BSONSymbol("${this.value}")`}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(e){return new r(e.$symbol)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}}t.BSONSymbol=r,Object.defineProperty(r.prototype,"_bsontype",{value:"Symbol"})}));o(he);he.BSONSymbol;var pe=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Timestamp=t.LongWithoutOverridesClass=void 0,t.LongWithoutOverridesClass=ie.Long;class r extends t.LongWithoutOverridesClass{constructor(e,t){ie.Long.isLong(e)?super(e.low,e.high,!0):super(e,t,!0),Object.defineProperty(this,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1})}toJSON(){return{$timestamp:this.toString()}}static fromInt(e){return new r(ie.Long.fromInt(e,!0))}static fromNumber(e){return new r(ie.Long.fromNumber(e,!0))}static fromBits(e,t){return new r(e,t)}static fromString(e,t){return new r(ie.Long.fromString(e,!0,t))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(e){return new r(e.$timestamp.i,e.$timestamp.t)}[Symbol.for("nodejs.util.inspect.custom")](){return this.inspect()}inspect(){return`Timestamp(${this.getLowBits().toString()}, ${this.getHighBits().toString()})`}}t.Timestamp=r,r.MAX_VALUE=ie.Long.MAX_UNSIGNED_VALUE}));o(pe);pe.Timestamp,pe.LongWithoutOverridesClass;var de=s((function(e,t){function r(e){return Z.isObjectLike(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}Object.defineProperty(t,"__esModule",{value:!0}),t.EJSON=t.isBSONType=void 0,t.isBSONType=r;const n={$oid:ce.ObjectId,$binary:te.Binary,$uuid:te.Binary,$symbol:he.BSONSymbol,$numberInt:ue.Int32,$numberDecimal:oe.Decimal128,$numberDouble:se.Double,$numberLong:ie.Long,$minKey:ae.MinKey,$maxKey:fe.MaxKey,$regex:le.BSONRegExp,$regularExpression:le.BSONRegExp,$timestamp:pe.Timestamp};function i(e){const t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function o(e,t){if(Array.isArray(e))return function(e,t){return e.map(e=>o(e,t))}(e,t);if(void 0===e)return null;if(e instanceof Date){const r=e.getTime(),n=r>-1&&r<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:i(e)}:t.relaxed&&n?{$date:i(e)}:{$date:{$numberLong:e.getTime().toString()}}}if("number"==typeof e&&!t.relaxed){if(Math.floor(e)===e){const t=e>=-0x8000000000000000&&e<=0x8000000000000000;if(e>=-2147483648&&e<=2147483647)return{$numberInt:e.toString()};if(t)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}if(e instanceof RegExp){let r=e.flags;if(void 0===r){const t=e.toString().match(/[gimuy]*$/);t&&(r=t[0])}return new le.BSONRegExp(e.source,r).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Error("not an object instance");const n=e._bsontype;if(void 0===n){const r={};for(const n in e)r[n]=o(e[n],t);return r}if(r(e)){let r=e;if("function"!=typeof r.toExtendedJSON){const t=s[e._bsontype];if(!t)throw new TypeError("Unrecognized or invalid _bsontype: "+e._bsontype);r=t(r)}return"Code"===n&&r.scope?r=new re.Code(r.code,o(r.scope,t)):"DBRef"===n&&r.oid&&(r=new ne.DBRef(r.collection,o(r.oid,t),r.db,r.fields)),r.toExtendedJSON(t)}throw new Error("_bsontype must be a string, but was: "+typeof n)}(e,t):e}const s={Binary:e=>new te.Binary(e.value(),e.sub_type),Code:e=>new re.Code(e.code,e.scope),DBRef:e=>new ne.DBRef(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new oe.Decimal128(e.bytes),Double:e=>new se.Double(e.value),Int32:e=>new ue.Int32(e.value),Long:e=>ie.Long.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_),MaxKey:()=>new fe.MaxKey,MinKey:()=>new ae.MinKey,ObjectID:e=>new ce.ObjectId(e),ObjectId:e=>new ce.ObjectId(e),BSONRegExp:e=>new le.BSONRegExp(e.pattern,e.options),Symbol:e=>new he.BSONSymbol(e.value),Timestamp:e=>pe.Timestamp.fromBits(e.low,e.high)};!function(e){function t(e,t){const r=Object.assign({},{relaxed:!0,legacy:!1},t);return"boolean"==typeof r.relaxed&&(r.strict=!r.relaxed),"boolean"==typeof r.strict&&(r.relaxed=!r.strict),JSON.parse(e,(e,t)=>function e(t,r={}){if("number"==typeof t){if(r.relaxed||r.legacy)return t;if(Math.floor(t)===t){if(t>=-2147483648&&t<=2147483647)return new ue.Int32(t);if(t>=-0x8000000000000000&&t<=0x8000000000000000)return ie.Long.fromNumber(t)}return new se.Double(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;const i=Object.keys(t).filter(e=>e.startsWith("$")&&null!=t[e]);for(let e=0;e<i.length;e++){const o=n[i[e]];if(o)return o.fromExtendedJSON(t,r)}if(null!=t.$date){const e=t.$date,n=new Date;return r.legacy?"number"==typeof e?n.setTime(e):"string"==typeof e&&n.setTime(Date.parse(e)):"string"==typeof e?n.setTime(Date.parse(e)):ie.Long.isLong(e)?n.setTime(e.toNumber()):"number"==typeof e&&r.relaxed&&n.setTime(e),n}if(null!=t.$code){const r=Object.assign({},t);return t.$scope&&(r.$scope=e(t.$scope)),re.Code.fromExtendedJSON(t)}if(null!=t.$ref||null!=t.$dbPointer){const e=t.$ref?t:t.$dbPointer;if(e instanceof ne.DBRef)return e;const r=Object.keys(e).filter(e=>e.startsWith("$"));let n=!0;if(r.forEach(e=>{-1===["$ref","$id","$db"].indexOf(e)&&(n=!1)}),n)return ne.DBRef.fromExtendedJSON(e)}return t}(t,r))}function r(e,t,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==t||"object"!=typeof t||Array.isArray(t)||(n=t,t=void 0,r=0);const i=o(e,n=Object.assign({},{relaxed:!0,legacy:!1},n));return JSON.stringify(i,t,r)}e.parse=t,e.stringify=r,e.serialize=function(e,t){return t=t||{},JSON.parse(r(e,t))},e.deserialize=function(e,r){return r=r||{},t(JSON.stringify(e),r)}}(t.EJSON||(t.EJSON={}))}));o(de);de.EJSON,de.isBSONType;var ye=s((function(e,t){let r;Object.defineProperty(t,"__esModule",{value:!0}),t.Map=void 0,t.Map=r;const n=function(e){return e&&e.Math==Math&&e};const o=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof i&&i)||Function("return this")();Object.prototype.hasOwnProperty.call(o,"Map")?t.Map=r=o.Map:t.Map=r=class{constructor(e=[]){this._keys=[],this._values={};for(let t=0;t<e.length;t++){if(null==e[t])continue;const r=e[t],n=r[0],i=r[1];this._keys.push(n),this._values[n]={v:i,i:this._keys.length-1}}}clear(){this._keys=[],this._values={}}delete(e){const t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)}entries(){let e=0;return{next:()=>{const t=this._keys[e++];return{value:void 0!==t?[t,this._values[t].v]:void 0,done:void 0===t}}}}forEach(e,t){t=t||this;for(let r=0;r<this._keys.length;r++){const n=this._keys[r];e.call(t,this._values[n].v,n,t)}}get(e){return this._values[e]?this._values[e].v:void 0}has(e){return null!=this._values[e]}keys(){let e=0;return{next:()=>{const t=this._keys[e++];return{value:void 0!==t?t:void 0,done:void 0===t}}}}set(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)}values(){let e=0;return{next:()=>{const t=this._keys[e++];return{value:void 0!==t?this._values[t].v:void 0,done:void 0===t}}}}get size(){return this._keys.length}}}));o(ye);ye.Map;var ge=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_DATA_MAX_KEY=t.BSON_DATA_MIN_KEY=t.BSON_DATA_DECIMAL128=t.BSON_DATA_LONG=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_INT=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_SYMBOL=t.BSON_DATA_CODE=t.BSON_DATA_DBPOINTER=t.BSON_DATA_REGEXP=t.BSON_DATA_NULL=t.BSON_DATA_DATE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_OID=t.BSON_DATA_UNDEFINED=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_DATA_OBJECT=t.BSON_DATA_STRING=t.BSON_DATA_NUMBER=t.JS_INT_MIN=t.JS_INT_MAX=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=void 0,t.BSON_INT32_MAX=2147483647,t.BSON_INT32_MIN=-2147483648,t.BSON_INT64_MAX=Math.pow(2,63)-1,t.BSON_INT64_MIN=-Math.pow(2,63),t.JS_INT_MAX=Math.pow(2,53),t.JS_INT_MIN=-Math.pow(2,53),t.BSON_DATA_NUMBER=1,t.BSON_DATA_STRING=2,t.BSON_DATA_OBJECT=3,t.BSON_DATA_ARRAY=4,t.BSON_DATA_BINARY=5,t.BSON_DATA_UNDEFINED=6,t.BSON_DATA_OID=7,t.BSON_DATA_BOOLEAN=8,t.BSON_DATA_DATE=9,t.BSON_DATA_NULL=10,t.BSON_DATA_REGEXP=11,t.BSON_DATA_DBPOINTER=12,t.BSON_DATA_CODE=13,t.BSON_DATA_SYMBOL=14,t.BSON_DATA_CODE_W_SCOPE=15,t.BSON_DATA_INT=16,t.BSON_DATA_TIMESTAMP=17,t.BSON_DATA_LONG=18,t.BSON_DATA_DECIMAL128=19,t.BSON_DATA_MIN_KEY=255,t.BSON_DATA_MAX_KEY=127,t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BSON_BINARY_SUBTYPE_FUNCTION=1,t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,t.BSON_BINARY_SUBTYPE_UUID=3,t.BSON_BINARY_SUBTYPE_UUID_NEW=4,t.BSON_BINARY_SUBTYPE_MD5=5,t.BSON_BINARY_SUBTYPE_USER_DEFINED=128}));o(ge);ge.BSON_BINARY_SUBTYPE_USER_DEFINED,ge.BSON_BINARY_SUBTYPE_MD5,ge.BSON_BINARY_SUBTYPE_UUID_NEW,ge.BSON_BINARY_SUBTYPE_UUID,ge.BSON_BINARY_SUBTYPE_BYTE_ARRAY,ge.BSON_BINARY_SUBTYPE_FUNCTION,ge.BSON_BINARY_SUBTYPE_DEFAULT,ge.BSON_DATA_MAX_KEY,ge.BSON_DATA_MIN_KEY,ge.BSON_DATA_DECIMAL128,ge.BSON_DATA_LONG,ge.BSON_DATA_TIMESTAMP,ge.BSON_DATA_INT,ge.BSON_DATA_CODE_W_SCOPE,ge.BSON_DATA_SYMBOL,ge.BSON_DATA_CODE,ge.BSON_DATA_DBPOINTER,ge.BSON_DATA_REGEXP,ge.BSON_DATA_NULL,ge.BSON_DATA_DATE,ge.BSON_DATA_BOOLEAN,ge.BSON_DATA_OID,ge.BSON_DATA_UNDEFINED,ge.BSON_DATA_BINARY,ge.BSON_DATA_ARRAY,ge.BSON_DATA_OBJECT,ge.BSON_DATA_STRING,ge.BSON_DATA_NUMBER,ge.JS_INT_MIN,ge.JS_INT_MAX,ge.BSON_INT64_MIN,ge.BSON_INT64_MAX,ge.BSON_INT32_MIN,ge.BSON_INT32_MAX;var _e=s((function(e,t){function r(e,t,r){let i=5;if(Array.isArray(e))for(let o=0;o<e.length;o++)i+=n(o.toString(),e[o],t,!0,r);else{e.toBSON&&(e=e.toBSON());for(const o in e)i+=n(o,e[o],t,!1,r)}return i}function n(e,t,n=!1,i=!1,o=!1){switch(t&&t.toBSON&&(t=t.toBSON()),typeof t){case"string":return 1+O.Buffer.byteLength(e,"utf8")+1+4+O.Buffer.byteLength(t,"utf8")+1;case"number":return Math.floor(t)===t&&t>=ge.JS_INT_MIN&&t<=ge.JS_INT_MAX&&t>=ge.BSON_INT32_MIN&&t<=ge.BSON_INT32_MAX?(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+5:(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+9;case"undefined":return i||!o?(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1;if("ObjectId"===t._bsontype||"ObjectID"===t._bsontype)return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||Z.isDate(t))return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+9;if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer)return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+6+t.byteLength;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+O.Buffer.byteLength(t.code.toString(),"utf8")+1+r(t.scope,n,o):(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1+4+O.Buffer.byteLength(t.code.toString(),"utf8")+1;if("Binary"===t._bsontype)return t.sub_type===te.Binary.SUBTYPE_BYTE_ARRAY?(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if("Symbol"===t._bsontype)return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+O.Buffer.byteLength(t.value,"utf8")+4+1+1;if("DBRef"===t._bsontype){const i=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&&(i.$db=t.db),(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1+r(i,n,o)}return t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)?(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1+O.Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1+O.Buffer.byteLength(t.pattern,"utf8")+1+O.Buffer.byteLength(t.options,"utf8")+1:(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+r(t,n,o)+1;case"function":if(t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)||"[object RegExp]"===String.call(t))return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1+O.Buffer.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?O.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+O.Buffer.byteLength(Z.normalizedFunctionString(t),"utf8")+1+r(t.scope,n,o);if(n)return(null!=e?O.Buffer.byteLength(e,"utf8")+1:0)+1+4+O.Buffer.byteLength(Z.normalizedFunctionString(t),"utf8")+1}return 0}Object.defineProperty(t,"__esModule",{value:!0}),t.calculateObjectSize=void 0,t.calculateObjectSize=r}));o(_e);_e.calculateObjectSize;var be=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateUtf8=void 0;t.validateUtf8=function(e,t,r){let n=0;for(let i=t;i<r;i+=1){const t=e[i];if(n){if(128!=(192&t))return!1;n-=1}else if(128&t)if(192==(224&t))n=1;else if(224==(240&t))n=2;else{if(240!=(248&t))return!1;n=3}}return!n}}));o(be);be.validateUtf8;var me=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserialize=void 0;const r=ie.Long.fromNumber(ge.JS_INT_MAX),n=ie.Long.fromNumber(ge.JS_INT_MIN),i={};function o(e,t,u,f=!1){const a=null!=u.evalFunctions&&u.evalFunctions,c=null!=u.cacheFunctions&&u.cacheFunctions,l=null==u.fieldsAsRaw?null:u.fieldsAsRaw,h=null!=u.raw&&u.raw,p="boolean"==typeof u.bsonRegExp&&u.bsonRegExp,d=null!=u.promoteBuffers&&u.promoteBuffers,y=null==u.promoteLongs||u.promoteLongs,g=null==u.promoteValues||u.promoteValues,_=t;if(e.length<5)throw new Error("corrupt bson message < 5 bytes long");const b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(b<5||b>e.length)throw new Error("corrupt bson message");const m=f?[]:{};let w=0;for(;;){const _=e[t++];if(0===_)break;let b=t;for(;0!==e[b]&&b<e.length;)b++;if(b>=e.byteLength)throw new Error("Bad BSON Document: illegal CString");const N=f?w++:e.toString("utf8",t,b);if(t=b+1,_===ge.BSON_DATA_STRING){const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(r<=0||r>e.length-t||0!==e[t+r-1])throw new Error("bad string length in bson");if(!be.validateUtf8(e,t,t+r-1))throw new Error("Invalid UTF-8 string in BSON document");const n=e.toString("utf8",t,t+r-1);m[N]=n,t+=r}else if(_===ge.BSON_DATA_OID){const r=O.Buffer.alloc(12);e.copy(r,0,t,t+12),m[N]=new ce.ObjectId(r),t+=12}else if(_===ge.BSON_DATA_INT&&!1===g)m[N]=new ue.Int32(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(_===ge.BSON_DATA_INT)m[N]=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(_===ge.BSON_DATA_NUMBER&&!1===g)m[N]=new se.Double(e.readDoubleLE(t)),t+=8;else if(_===ge.BSON_DATA_NUMBER)m[N]=e.readDoubleLE(t),t+=8;else if(_===ge.BSON_DATA_DATE){const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;m[N]=new Date(new ie.Long(r,n).toNumber())}else if(_===ge.BSON_DATA_BOOLEAN){if(0!==e[t]&&1!==e[t])throw new Error("illegal boolean type value");m[N]=1===e[t++]}else if(_===ge.BSON_DATA_OBJECT){const r=t,n=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(n<=0||n>e.length-t)throw new Error("bad embedded document length in bson");m[N]=h?e.slice(t,t+n):o(e,r,u,!1),t+=n}else if(_===ge.BSON_DATA_ARRAY){const r=t,n=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;let i=u;const s=t+n;if(l&&l[N]){i={};for(const e in u)i[e]=u[e];i.raw=!0}if(m[N]=o(e,r,i,!0),0!==e[(t+=n)-1])throw new Error("invalid array terminator byte");if(t!==s)throw new Error("corrupted array bson")}else if(_===ge.BSON_DATA_UNDEFINED)m[N]=void 0;else if(_===ge.BSON_DATA_NULL)m[N]=null;else if(_===ge.BSON_DATA_LONG){const i=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,o=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,s=new ie.Long(i,o);m[N]=y&&!0===g&&s.lessThanOrEqual(r)&&s.greaterThanOrEqual(n)?s.toNumber():s}else if(_===ge.BSON_DATA_DECIMAL128){const r=O.Buffer.alloc(16);e.copy(r,0,t,t+16),t+=16;const n=new oe.Decimal128(r);"toObject"in n&&"function"==typeof n.toObject?m[N]=n.toObject():m[N]=n}else if(_===ge.BSON_DATA_BINARY){let r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;const n=r,i=e[t++];if(r<0)throw new Error("Negative binary type element size found");if(r>e.byteLength)throw new Error("Binary type size larger than document size");if(null!=e.slice){if(i===te.Binary.SUBTYPE_BYTE_ARRAY){if(r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,r<0)throw new Error("Negative binary type element size found for subtype 0x02");if(r>n-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(r<n-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}m[N]=d&&g?e.slice(t,t+r):new te.Binary(e.slice(t,t+r),i)}else{const o=O.Buffer.alloc(r);if(i===te.Binary.SUBTYPE_BYTE_ARRAY){if(r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,r<0)throw new Error("Negative binary type element size found for subtype 0x02");if(r>n-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(r<n-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(b=0;b<r;b++)o[b]=e[t+b];m[N]=d&&g?o:new te.Binary(o,i)}t+=r}else if(_===ge.BSON_DATA_REGEXP&&!1===p){for(b=t;0!==e[b]&&b<e.length;)b++;if(b>=e.length)throw new Error("Bad BSON Document: illegal CString");const r=e.toString("utf8",t,b);for(b=t=b+1;0!==e[b]&&b<e.length;)b++;if(b>=e.length)throw new Error("Bad BSON Document: illegal CString");const n=e.toString("utf8",t,b);t=b+1;const i=new Array(n.length);for(b=0;b<n.length;b++)switch(n[b]){case"m":i[b]="m";break;case"s":i[b]="g";break;case"i":i[b]="i"}m[N]=new RegExp(r,i.join(""))}else if(_===ge.BSON_DATA_REGEXP&&!0===p){for(b=t;0!==e[b]&&b<e.length;)b++;if(b>=e.length)throw new Error("Bad BSON Document: illegal CString");const r=e.toString("utf8",t,b);for(b=t=b+1;0!==e[b]&&b<e.length;)b++;if(b>=e.length)throw new Error("Bad BSON Document: illegal CString");const n=e.toString("utf8",t,b);t=b+1,m[N]=new le.BSONRegExp(r,n)}else if(_===ge.BSON_DATA_SYMBOL){const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(r<=0||r>e.length-t||0!==e[t+r-1])throw new Error("bad string length in bson");const n=e.toString("utf8",t,t+r-1);m[N]=g?n:new he.BSONSymbol(n),t+=r}else if(_===ge.BSON_DATA_TIMESTAMP){const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;m[N]=new pe.Timestamp(r,n)}else if(_===ge.BSON_DATA_MIN_KEY)m[N]=new ae.MinKey;else if(_===ge.BSON_DATA_MAX_KEY)m[N]=new fe.MaxKey;else if(_===ge.BSON_DATA_CODE){const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(r<=0||r>e.length-t||0!==e[t+r-1])throw new Error("bad string length in bson");const n=e.toString("utf8",t,t+r-1);m[N]=a?c?s(n,i,m):s(n):new re.Code(n),t+=r}else if(_===ge.BSON_DATA_CODE_W_SCOPE){const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(r<13)throw new Error("code_w_scope total size shorter minimum expected length");const n=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(n<=0||n>e.length-t||0!==e[t+n-1])throw new Error("bad string length in bson");const f=e.toString("utf8",t,t+n-1),l=t+=n,h=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,p=o(e,l,u,!1);if(t+=h,r<8+h+n)throw new Error("code_w_scope total size is too short, truncating scope");if(r>8+h+n)throw new Error("code_w_scope total size is too long, clips outer document");a?(m[N]=c?s(f,i,m):s(f),m[N].scope=p):m[N]=new re.Code(f,p)}else{if(_!==ge.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+_.toString(16)+' for fieldname "'+N+'"');{const r=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(r<=0||r>e.length-t||0!==e[t+r-1])throw new Error("bad string length in bson");if(!be.validateUtf8(e,t,t+r-1))throw new Error("Invalid UTF-8 string in BSON document");const n=e.toString("utf8",t,t+r-1);t+=r;const i=O.Buffer.alloc(12);e.copy(i,0,t,t+12);const o=new ce.ObjectId(i);t+=12,m[N]=new ne.DBRef(n,o)}}}if(b!==t-_){if(f)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}const N=Object.keys(m).filter(e=>e.startsWith("$"));let S=!0;if(N.forEach(e=>{-1===["$ref","$id","$db"].indexOf(e)&&(S=!1)}),!S)return m;if(ne.isDBRefLike(m)){const e=Object.assign({},m);return delete e.$ref,delete e.$id,delete e.$db,new ne.DBRef(m.$ref,m.$id,m.$db,e)}return m}function s(e,t,r){return t?(null==t[e]&&(t[e]=new Function(e)),t[e].bind(r)):new Function(e)}t.deserialize=function(e,t,r){const n=(t=null==t?{}:t)&&t.index?t.index:0,i=e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24;if(i<5)throw new Error("bson size must be >= 5, is "+i);if(t.allowObjectSmallerThanBufferSize&&e.length<i)throw new Error(`buffer length ${e.length} must be >= bson size ${i}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==i)throw new Error(`buffer length ${e.length} must === bson size ${i}`);if(i+n>e.byteLength)throw new Error(`(bson size ${i} + options.index ${n} must be <= buffer length ${e.byteLength})`);if(0!==e[n+i-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return o(e,n,t,r)}}));o(me);me.deserialize;var we=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.writeIEEE754=t.readIEEE754=void 0,t.readIEEE754=function(e,t,r,n,i){let o,s;const u="big"===r,f=8*i-n-1,a=(1<<f)-1,c=a>>1;let l=-7,h=u?0:i-1;const p=u?1:-1;let d=e[t+h];for(h+=p,o=d&(1<<-l)-1,d>>=-l,l+=f;l>0;o=256*o+e[t+h],h+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+h],h+=p,l-=8);if(0===o)o=1-c;else{if(o===a)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},t.writeIEEE754=function(e,t,r,n,i,o){let s,u,f;const a="big"===n;let c=8*o-i-1;const l=(1<<c)-1,h=l>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0;let d=a?o-1:0;const y=a?-1:1,g=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*(f=Math.pow(2,-s))<1&&(s--,f*=2),(t+=s+h>=1?p/f:p*Math.pow(2,1-h))*f>=2&&(s++,f/=2),s+h>=l?(u=0,s=l):s+h>=1?(u=(t*f-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[r+d]=255&u,d+=y,u/=256,i-=8;for(s=s<<i|u,isNaN(t)&&(s+=8),c+=i;c>0;)e[r+d]=255&s,d+=y,s/=256,c-=8;e[r+d-y]|=128*g}}));o(we);we.writeIEEE754,we.readIEEE754;var Oe=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeInto=void 0;const r=/\x00/,n=new Set(["$db","$ref","$id","$clusterTime"]);function i(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function o(e,t,r,n,i){e[n++]=ge.BSON_DATA_STRING;const o=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8");e[(n=n+o+1)-1]=0;const s=e.write(r,n+4,void 0,"utf8");return e[n+3]=s+1>>24&255,e[n+2]=s+1>>16&255,e[n+1]=s+1>>8&255,e[n]=s+1&255,n=n+4+s,e[n++]=0,n}function s(e,t,r,n,i){if(Number.isInteger(r)&&r>=ge.BSON_INT32_MIN&&r<=ge.BSON_INT32_MAX){e[n++]=ge.BSON_DATA_INT;n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,e[n++]=255&r,e[n++]=r>>8&255,e[n++]=r>>16&255,e[n++]=r>>24&255}else{e[n++]=ge.BSON_DATA_NUMBER;n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,we.writeIEEE754(e,r,n,"little",52,8),n+=8}return n}function u(e,t,r,n,i){e[n++]=ge.BSON_DATA_NULL;return n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,n}function f(e,t,r,n,i){e[n++]=ge.BSON_DATA_BOOLEAN;return n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,e[n++]=r?1:0,n}function a(e,t,r,n,i){e[n++]=ge.BSON_DATA_DATE;n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const o=ie.Long.fromNumber(r.getTime()),s=o.getLowBits(),u=o.getHighBits();return e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,e[n++]=255&u,e[n++]=u>>8&255,e[n++]=u>>16&255,e[n++]=u>>24&255,n}function c(e,t,n,i,o){e[i++]=ge.BSON_DATA_REGEXP;if(i+=o?e.write(t,i,void 0,"ascii"):e.write(t,i,void 0,"utf8"),e[i++]=0,n.source&&null!=n.source.match(r))throw Error("value "+n.source+" must not contain null bytes");return i+=e.write(n.source,i,void 0,"utf8"),e[i++]=0,n.ignoreCase&&(e[i++]=105),n.global&&(e[i++]=115),n.multiline&&(e[i++]=109),e[i++]=0,i}function l(e,t,n,i,o){e[i++]=ge.BSON_DATA_REGEXP;if(i+=o?e.write(t,i,void 0,"ascii"):e.write(t,i,void 0,"utf8"),e[i++]=0,null!=n.pattern.match(r))throw Error("pattern "+n.pattern+" must not contain null bytes");return i+=e.write(n.pattern,i,void 0,"utf8"),e[i++]=0,i+=e.write(n.options.split("").sort().join(""),i,void 0,"utf8"),e[i++]=0,i}function h(e,t,r,n,i){null===r?e[n++]=ge.BSON_DATA_NULL:"MinKey"===r._bsontype?e[n++]=ge.BSON_DATA_MIN_KEY:e[n++]=ge.BSON_DATA_MAX_KEY;return n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,n}function p(e,t,r,n,i){e[n++]=ge.BSON_DATA_OID;if(n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,"string"==typeof r.id)e.write(r.id,n,void 0,"binary");else{if(!r.id||!r.id.copy)throw new TypeError("object ["+JSON.stringify(r)+"] is not a valid ObjectId");r.id.copy(e,n,0,12)}return n+12}function d(e,t,r,n,i){e[n++]=ge.BSON_DATA_BINARY;n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const o=r.length;return e[n++]=255&o,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=ge.BSON_BINARY_SUBTYPE_DEFAULT,e.set(Q.ensureBuffer(r),n),n+=o}function y(e,t,r,n,i=!1,o=0,s=!1,u=!0,f=!1,a=[]){for(let e=0;e<a.length;e++)if(a[e]===r)throw new Error("cyclic dependency detected");a.push(r),e[n++]=Array.isArray(r)?ge.BSON_DATA_ARRAY:ge.BSON_DATA_OBJECT;n+=f?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const c=A(e,r,i,n,o+1,s,u,a);return a.pop(),c}function g(e,t,r,n,i){e[n++]=ge.BSON_DATA_DECIMAL128;return n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,r.bytes.copy(e,n,0,16),n+16}function _(e,t,r,n,i){e[n++]="Long"===r._bsontype?ge.BSON_DATA_LONG:ge.BSON_DATA_TIMESTAMP;n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const o=r.getLowBits(),s=r.getHighBits();return e[n++]=255&o,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,n}function b(e,t,r,n,i){r=r.valueOf(),e[n++]=ge.BSON_DATA_INT;return n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,e[n++]=255&r,e[n++]=r>>8&255,e[n++]=r>>16&255,e[n++]=r>>24&255,n}function m(e,t,r,n,i){e[n++]=ge.BSON_DATA_NUMBER;return n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,we.writeIEEE754(e,r.value,n,"little",52,8),n+=8}function w(e,t,r,n,i=!1,o=0,s){e[n++]=ge.BSON_DATA_CODE;n+=s?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const u=Z.normalizedFunctionString(r),f=e.write(u,n+4,void 0,"utf8")+1;return e[n]=255&f,e[n+1]=f>>8&255,e[n+2]=f>>16&255,e[n+3]=f>>24&255,n=n+4+f-1,e[n++]=0,n}function O(e,t,r,n,i=!1,o=0,s=!1,u=!0,f=!1){if(r.scope&&"object"==typeof r.scope){e[n++]=ge.BSON_DATA_CODE_W_SCOPE;n+=f?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;let a=n;const c="string"==typeof r.code?r.code:r.code.toString();n+=4;const l=e.write(c,n+4,void 0,"utf8")+1;e[n]=255&l,e[n+1]=l>>8&255,e[n+2]=l>>16&255,e[n+3]=l>>24&255,e[n+4+l-1]=0,n=n+l+4;const h=A(e,r.scope,i,n,o+1,s,u);n=h-1;const p=h-a;e[a++]=255&p,e[a++]=p>>8&255,e[a++]=p>>16&255,e[a++]=p>>24&255,e[n++]=0}else{e[n++]=ge.BSON_DATA_CODE;n+=f?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const i=r.code.toString(),o=e.write(i,n+4,void 0,"utf8")+1;e[n]=255&o,e[n+1]=o>>8&255,e[n+2]=o>>16&255,e[n+3]=o>>24&255,n=n+4+o-1,e[n++]=0}return n}function N(e,t,r,n,i){e[n++]=ge.BSON_DATA_BINARY;n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const o=r.value(!0);let s=r.position;return r.sub_type===te.Binary.SUBTYPE_BYTE_ARRAY&&(s+=4),e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,e[n++]=r.sub_type,r.sub_type===te.Binary.SUBTYPE_BYTE_ARRAY&&(s-=4,e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255),e.set(o,n),n+=r.position}function S(e,t,r,n,i){e[n++]=ge.BSON_DATA_SYMBOL;n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;const o=e.write(r.value,n+4,void 0,"utf8")+1;return e[n]=255&o,e[n+1]=o>>8&255,e[n+2]=o>>16&255,e[n+3]=o>>24&255,n=n+4+o-1,e[n++]=0,n}function v(e,t,r,n,i,o,s){e[n++]=ge.BSON_DATA_OBJECT;n+=s?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;let u=n,f={$ref:r.collection||r.namespace,$id:r.oid};null!=r.db&&(f.$db=r.db),f=Object.assign(f,r.fields);const a=A(e,f,!1,n,i+1,o),c=a-u;return e[u++]=255&c,e[u++]=c>>8&255,e[u++]=c>>16&255,e[u++]=c>>24&255,a}function A(e,t,A=!1,B=0,E=0,T=!1,I=!0,D=[]){B=B||0,(D=D||[]).push(t);let R=B+4;if(Array.isArray(t))for(let r=0;r<t.length;r++){const n=""+r;let B=t[r];if(B&&B.toBSON){if("function"!=typeof B.toBSON)throw new TypeError("toBSON is not a function");B=B.toBSON()}if("string"==typeof B)R=o(e,n,B,R,!0);else if("number"==typeof B)R=s(e,n,B,R,!0);else{if("bigint"==typeof B)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"==typeof B)R=f(e,n,B,R,!0);else if(B instanceof Date||Z.isDate(B))R=a(e,n,B,R,!0);else if(void 0===B)R=u(e,n,0,R,!0);else if(null===B)R=u(e,n,0,R,!0);else if("ObjectId"===B._bsontype||"ObjectID"===B._bsontype)R=p(e,n,B,R,!0);else if(Z.isBuffer(B)||Z.isUint8Array(B))R=d(e,n,B,R,!0);else if(B instanceof RegExp||i(B))R=c(e,n,B,R,!0);else if("object"==typeof B&&null==B._bsontype)R=y(e,n,B,R,A,E,T,I,!0,D);else if("object"==typeof B&&de.isBSONType(B)&&"Decimal128"===B._bsontype)R=g(e,n,B,R,!0);else if("Long"===B._bsontype||"Timestamp"===B._bsontype)R=_(e,n,B,R,!0);else if("Double"===B._bsontype)R=m(e,n,B,R,!0);else if("function"==typeof B&&T)R=w(e,n,B,R,A,E,!0);else if("Code"===B._bsontype)R=O(e,n,B,R,A,E,T,I,!0);else if("Binary"===B._bsontype)R=N(e,n,B,R,!0);else if("Symbol"===B._bsontype)R=S(e,n,B,R,!0);else if("DBRef"===B._bsontype)R=v(e,n,B,R,E,T,!0);else if("BSONRegExp"===B._bsontype)R=l(e,n,B,R,!0);else if("Int32"===B._bsontype)R=b(e,n,B,R,!0);else if("MinKey"===B._bsontype||"MaxKey"===B._bsontype)R=h(e,n,B,R,!0);else if(void 0!==B._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+B._bsontype)}}else if(t instanceof ye.Map){const B=t.entries();let P=!1;for(;!P;){const t=B.next();if(P=!!t.done,P)continue;const L=t.value[0],U=t.value[1],M=typeof U;if("string"==typeof L&&!n.has(L)){if(null!=L.match(r))throw Error("key "+L+" must not contain null bytes");if(A){if("$"===L[0])throw Error("key "+L+" must not start with '$'");if(~L.indexOf("."))throw Error("key "+L+" must not contain '.'")}}if("string"===M)R=o(e,L,U,R);else if("number"===M)R=s(e,L,U,R);else{if("bigint"===M||Z.isBigInt64Array(U)||Z.isBigUInt64Array(U))throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===M)R=f(e,L,U,R);else if(U instanceof Date||Z.isDate(U))R=a(e,L,U,R);else if(null===U||void 0===U&&!1===I)R=u(e,L,0,R);else if("ObjectId"===U._bsontype||"ObjectID"===U._bsontype)R=p(e,L,U,R);else if(Z.isBuffer(U)||Z.isUint8Array(U))R=d(e,L,U,R);else if(U instanceof RegExp||i(U))R=c(e,L,U,R);else if("object"===M&&null==U._bsontype)R=y(e,L,U,R,A,E,T,I,!1,D);else if("object"===M&&"Decimal128"===U._bsontype)R=g(e,L,U,R);else if("Long"===U._bsontype||"Timestamp"===U._bsontype)R=_(e,L,U,R);else if("Double"===U._bsontype)R=m(e,L,U,R);else if("Code"===U._bsontype)R=O(e,L,U,R,A,E,T,I);else if("function"==typeof U&&T)R=w(e,L,U,R,A,E,T);else if("Binary"===U._bsontype)R=N(e,L,U,R);else if("Symbol"===U._bsontype)R=S(e,L,U,R);else if("DBRef"===U._bsontype)R=v(e,L,U,R,E,T);else if("BSONRegExp"===U._bsontype)R=l(e,L,U,R);else if("Int32"===U._bsontype)R=b(e,L,U,R);else if("MinKey"===U._bsontype||"MaxKey"===U._bsontype)R=h(e,L,U,R);else if(void 0!==U._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+U._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 t)throw new TypeError("toBSON function did not return an object")}for(const B in t){let P=t[B];if(P&&P.toBSON){if("function"!=typeof P.toBSON)throw new TypeError("toBSON is not a function");P=P.toBSON()}const L=typeof P;if("string"==typeof B&&!n.has(B)){if(null!=B.match(r))throw Error("key "+B+" must not contain null bytes");if(A){if("$"===B[0])throw Error("key "+B+" must not start with '$'");if(~B.indexOf("."))throw Error("key "+B+" must not contain '.'")}}if("string"===L)R=o(e,B,P,R);else if("number"===L)R=s(e,B,P,R);else{if("bigint"===L)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===L)R=f(e,B,P,R);else if(P instanceof Date||Z.isDate(P))R=a(e,B,P,R);else if(void 0===P)!1===I&&(R=u(e,B,0,R));else if(null===P)R=u(e,B,0,R);else if("ObjectId"===P._bsontype||"ObjectID"===P._bsontype)R=p(e,B,P,R);else if(Z.isBuffer(P)||Z.isUint8Array(P))R=d(e,B,P,R);else if(P instanceof RegExp||i(P))R=c(e,B,P,R);else if("object"===L&&null==P._bsontype)R=y(e,B,P,R,A,E,T,I,!1,D);else if("object"===L&&"Decimal128"===P._bsontype)R=g(e,B,P,R);else if("Long"===P._bsontype||"Timestamp"===P._bsontype)R=_(e,B,P,R);else if("Double"===P._bsontype)R=m(e,B,P,R);else if("Code"===P._bsontype)R=O(e,B,P,R,A,E,T,I);else if("function"==typeof P&&T)R=w(e,B,P,R,A,E,T);else if("Binary"===P._bsontype)R=N(e,B,P,R);else if("Symbol"===P._bsontype)R=S(e,B,P,R);else if("DBRef"===P._bsontype)R=v(e,B,P,R,E,T);else if("BSONRegExp"===P._bsontype)R=l(e,B,P,R);else if("Int32"===P._bsontype)R=b(e,B,P,R);else if("MinKey"===P._bsontype||"MaxKey"===P._bsontype)R=h(e,B,P,R);else if(void 0!==P._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+P._bsontype)}}}D.pop(),e[R++]=0;const P=R-B;return e[B++]=255&P,e[B++]=P>>8&255,e[B++]=P>>16&255,e[B++]=P>>24&255,R}t.serializeInto=A}));o(Oe);Oe.serializeInto;var Ne=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeStream=t.calculateObjectSize=t.deserialize=t.serializeWithBufferAndIndex=t.serialize=t.setInternalBufferSize=t.ObjectID=t.Decimal128=t.BSONRegExp=t.MaxKey=t.MinKey=t.Int32=t.Double=t.Timestamp=t.Long=t.ObjectId=t.Binary=t.DBRef=t.BSONSymbol=t.Map=t.Code=t.LongWithoutOverridesClass=t.EJSON=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=t.BSON_DATA_UNDEFINED=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_SYMBOL=t.BSON_DATA_STRING=t.BSON_DATA_REGEXP=t.BSON_DATA_OID=t.BSON_DATA_OBJECT=t.BSON_DATA_NUMBER=t.BSON_DATA_NULL=t.BSON_DATA_MIN_KEY=t.BSON_DATA_MAX_KEY=t.BSON_DATA_LONG=t.BSON_DATA_INT=t.BSON_DATA_DECIMAL128=t.BSON_DATA_DBPOINTER=t.BSON_DATA_DATE=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_CODE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=void 0,Object.defineProperty(t,"Binary",{enumerable:!0,get:function(){return te.Binary}}),Object.defineProperty(t,"Code",{enumerable:!0,get:function(){return re.Code}}),Object.defineProperty(t,"DBRef",{enumerable:!0,get:function(){return ne.DBRef}}),Object.defineProperty(t,"Decimal128",{enumerable:!0,get:function(){return oe.Decimal128}}),Object.defineProperty(t,"Double",{enumerable:!0,get:function(){return se.Double}}),Object.defineProperty(t,"Int32",{enumerable:!0,get:function(){return ue.Int32}}),Object.defineProperty(t,"Long",{enumerable:!0,get:function(){return ie.Long}}),Object.defineProperty(t,"Map",{enumerable:!0,get:function(){return ye.Map}}),Object.defineProperty(t,"MaxKey",{enumerable:!0,get:function(){return fe.MaxKey}}),Object.defineProperty(t,"MinKey",{enumerable:!0,get:function(){return ae.MinKey}}),Object.defineProperty(t,"ObjectId",{enumerable:!0,get:function(){return ce.ObjectId}}),Object.defineProperty(t,"ObjectID",{enumerable:!0,get:function(){return ce.ObjectId}}),Object.defineProperty(t,"BSONRegExp",{enumerable:!0,get:function(){return le.BSONRegExp}}),Object.defineProperty(t,"BSONSymbol",{enumerable:!0,get:function(){return he.BSONSymbol}}),Object.defineProperty(t,"Timestamp",{enumerable:!0,get:function(){return pe.Timestamp}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_BYTE_ARRAY}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_DEFAULT",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_DEFAULT}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_FUNCTION",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_FUNCTION}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_MD5",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_MD5}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_USER_DEFINED",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_USER_DEFINED}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_UUID}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID_NEW",{enumerable:!0,get:function(){return ge.BSON_BINARY_SUBTYPE_UUID_NEW}}),Object.defineProperty(t,"BSON_DATA_ARRAY",{enumerable:!0,get:function(){return ge.BSON_DATA_ARRAY}}),Object.defineProperty(t,"BSON_DATA_BINARY",{enumerable:!0,get:function(){return ge.BSON_DATA_BINARY}}),Object.defineProperty(t,"BSON_DATA_BOOLEAN",{enumerable:!0,get:function(){return ge.BSON_DATA_BOOLEAN}}),Object.defineProperty(t,"BSON_DATA_CODE",{enumerable:!0,get:function(){return ge.BSON_DATA_CODE}}),Object.defineProperty(t,"BSON_DATA_CODE_W_SCOPE",{enumerable:!0,get:function(){return ge.BSON_DATA_CODE_W_SCOPE}}),Object.defineProperty(t,"BSON_DATA_DATE",{enumerable:!0,get:function(){return ge.BSON_DATA_DATE}}),Object.defineProperty(t,"BSON_DATA_DBPOINTER",{enumerable:!0,get:function(){return ge.BSON_DATA_DBPOINTER}}),Object.defineProperty(t,"BSON_DATA_DECIMAL128",{enumerable:!0,get:function(){return ge.BSON_DATA_DECIMAL128}}),Object.defineProperty(t,"BSON_DATA_INT",{enumerable:!0,get:function(){return ge.BSON_DATA_INT}}),Object.defineProperty(t,"BSON_DATA_LONG",{enumerable:!0,get:function(){return ge.BSON_DATA_LONG}}),Object.defineProperty(t,"BSON_DATA_MAX_KEY",{enumerable:!0,get:function(){return ge.BSON_DATA_MAX_KEY}}),Object.defineProperty(t,"BSON_DATA_MIN_KEY",{enumerable:!0,get:function(){return ge.BSON_DATA_MIN_KEY}}),Object.defineProperty(t,"BSON_DATA_NULL",{enumerable:!0,get:function(){return ge.BSON_DATA_NULL}}),Object.defineProperty(t,"BSON_DATA_NUMBER",{enumerable:!0,get:function(){return ge.BSON_DATA_NUMBER}}),Object.defineProperty(t,"BSON_DATA_OBJECT",{enumerable:!0,get:function(){return ge.BSON_DATA_OBJECT}}),Object.defineProperty(t,"BSON_DATA_OID",{enumerable:!0,get:function(){return ge.BSON_DATA_OID}}),Object.defineProperty(t,"BSON_DATA_REGEXP",{enumerable:!0,get:function(){return ge.BSON_DATA_REGEXP}}),Object.defineProperty(t,"BSON_DATA_STRING",{enumerable:!0,get:function(){return ge.BSON_DATA_STRING}}),Object.defineProperty(t,"BSON_DATA_SYMBOL",{enumerable:!0,get:function(){return ge.BSON_DATA_SYMBOL}}),Object.defineProperty(t,"BSON_DATA_TIMESTAMP",{enumerable:!0,get:function(){return ge.BSON_DATA_TIMESTAMP}}),Object.defineProperty(t,"BSON_DATA_UNDEFINED",{enumerable:!0,get:function(){return ge.BSON_DATA_UNDEFINED}}),Object.defineProperty(t,"BSON_INT32_MAX",{enumerable:!0,get:function(){return ge.BSON_INT32_MAX}}),Object.defineProperty(t,"BSON_INT32_MIN",{enumerable:!0,get:function(){return ge.BSON_INT32_MIN}}),Object.defineProperty(t,"BSON_INT64_MAX",{enumerable:!0,get:function(){return ge.BSON_INT64_MAX}}),Object.defineProperty(t,"BSON_INT64_MIN",{enumerable:!0,get:function(){return ge.BSON_INT64_MIN}});var r=de;Object.defineProperty(t,"EJSON",{enumerable:!0,get:function(){return r.EJSON}});var n=pe;Object.defineProperty(t,"LongWithoutOverridesClass",{enumerable:!0,get:function(){return n.LongWithoutOverridesClass}});let i=O.Buffer.alloc(17825792);function o(e){i.length<e&&(i=O.Buffer.alloc(e))}function s(e,t={}){const r="boolean"==typeof t.checkKeys&&t.checkKeys,n="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,o="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,s="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:17825792;i.length<s&&(i=O.Buffer.alloc(s));const u=Oe.serializeInto(i,e,r,0,0,n,o,[]),f=O.Buffer.alloc(u);return i.copy(f,0,0,f.length),f}function u(e,t,r={}){const n="boolean"==typeof r.checkKeys&&r.checkKeys,o="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,s="boolean"!=typeof r.ignoreUndefined||r.ignoreUndefined,u="number"==typeof r.index?r.index:0,f=Oe.serializeInto(i,e,n,0,0,o,s);return i.copy(t,u,0,f),u+f-1}function f(e,t={}){return me.deserialize(Q.ensureBuffer(e),t)}function a(e,t={}){const r="boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,n="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined;return _e.calculateObjectSize(e,r,n)}function c(e,t,r,n,i,o){const s=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},o),u=Q.ensureBuffer(e);let f=t;for(let e=0;e<r;e++){const t=u[f]|u[f+1]<<8|u[f+2]<<16|u[f+3]<<24;s.index=f,n[i+e]=me.deserialize(u,s),f+=t}return f}t.setInternalBufferSize=o,t.serialize=s,t.serializeWithBufferAndIndex=u,t.deserialize=f,t.calculateObjectSize=a,t.deserializeStream=c;const l={Binary:te.Binary,Code:re.Code,DBRef:ne.DBRef,Decimal128:oe.Decimal128,Double:se.Double,Int32:ue.Int32,Long:ie.Long,Map:ye.Map,MaxKey:fe.MaxKey,MinKey:ae.MinKey,ObjectId:ce.ObjectId,ObjectID:ce.ObjectId,BSONRegExp:le.BSONRegExp,BSONSymbol:he.BSONSymbol,Timestamp:pe.Timestamp,EJSON:de.EJSON,setInternalBufferSize:o,serialize:s,serializeWithBufferAndIndex:u,deserialize:f,calculateObjectSize:a,deserializeStream:c};t.default=l})),Se=(o(Ne),Ne.deserializeStream,Ne.calculateObjectSize,Ne.deserialize,Ne.serializeWithBufferAndIndex,Ne.serialize,Ne.setInternalBufferSize,Ne.ObjectID,Ne.Decimal128,Ne.BSONRegExp,Ne.MaxKey,Ne.MinKey,Ne.Int32,Ne.Double,Ne.Timestamp,Ne.Long,Ne.ObjectId,Ne.Binary,Ne.DBRef,Ne.BSONSymbol,Ne.Map,Ne.Code,Ne.LongWithoutOverridesClass,Ne.EJSON);Ne.BSON_INT64_MIN,Ne.BSON_INT64_MAX,Ne.BSON_INT32_MIN,Ne.BSON_INT32_MAX,Ne.BSON_DATA_UNDEFINED,Ne.BSON_DATA_TIMESTAMP,Ne.BSON_DATA_SYMBOL,Ne.BSON_DATA_STRING,Ne.BSON_DATA_REGEXP,Ne.BSON_DATA_OID,Ne.BSON_DATA_OBJECT,Ne.BSON_DATA_NUMBER,Ne.BSON_DATA_NULL,Ne.BSON_DATA_MIN_KEY,Ne.BSON_DATA_MAX_KEY,Ne.BSON_DATA_LONG,Ne.BSON_DATA_INT,Ne.BSON_DATA_DECIMAL128,Ne.BSON_DATA_DBPOINTER,Ne.BSON_DATA_DATE,Ne.BSON_DATA_CODE_W_SCOPE,Ne.BSON_DATA_CODE,Ne.BSON_DATA_BOOLEAN,Ne.BSON_DATA_BINARY,Ne.BSON_DATA_ARRAY,Ne.BSON_BINARY_SUBTYPE_UUID_NEW,Ne.BSON_BINARY_SUBTYPE_UUID,Ne.BSON_BINARY_SUBTYPE_USER_DEFINED,Ne.BSON_BINARY_SUBTYPE_MD5,Ne.BSON_BINARY_SUBTYPE_FUNCTION,Ne.BSON_BINARY_SUBTYPE_DEFAULT,Ne.BSON_BINARY_SUBTYPE_BYTE_ARRAY}).call(this,r(1),r(3).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])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=r(7);var o={name:"database",entity:{database:function(e){var t=this.platform,r=t.adapter,o=t.runtime;return i.Db.reqClass=this.request.constructor,i.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},i.Db.runtime=o,this.wsClientClass&&(i.Db.wsClass=r.wsClass,i.Db.wsClientClass=this.wsClientClass),i.Db.ws||(i.Db.ws=null),new i.Db(n(n({},this.config),e))}}};try{cloudbase.registerComponent(o)}catch(e){}t.registerDatabase=function(e){try{e.registerComponent(o)}catch(e){console.warn(e)}}},function(e,t,r){"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 n=r(4),i=r(5),o=r(6);function s(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return f.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=f.prototype:(null===e&&(e=new f(t)),e.length=t),e}function f(e,t,r){if(!(f.TYPED_ARRAY_SUPPORT||this instanceof f))return new f(e,t,r);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 a(this,e,t,r)}function a(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n);f.TYPED_ARRAY_SUPPORT?(e=t).__proto__=f.prototype:e=h(e,t);return e}(e,t,r,n):"string"==typeof t?function(e,t,r){"string"==typeof r&&""!==r||(r="utf8");if(!f.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(t,r),i=(e=u(e,n)).write(t,r);i!==n&&(e=e.slice(0,i));return e}(e,t,r):function(e,t){if(f.isBuffer(t)){var r=0|p(t.length);return 0===(e=u(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?u(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}var n;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)),!f.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|p(t.length);e=u(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];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(f.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 r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return $(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,r);case"utf8":case"utf-8":return B(this,t,r);case"ascii":return E(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function _(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=f.from(t,n)),f.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,f.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,s=1,u=e.length,f=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,u/=2,f/=2,r/=2}function a(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<u;o++)if(a(e,o)===a(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===f)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+f>u&&(r=u-f),o=r;o>=0;o--){for(var l=!0,h=0;h<f;h++)if(a(e,o+h)!==a(t,h)){l=!1;break}if(l)return o}return-1}function m(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var u=parseInt(t.substr(2*s,2),16);if(isNaN(u))return s;e[r+s]=u}return s}function w(e,t,r,n){return F($(t,e.length-r),e,r,n)}function O(e,t,r,n){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function N(e,t,r,n){return O(e,t,r,n)}function S(e,t,r,n){return F(q(t),e,r,n)}function v(e,t,r,n){return F(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function B(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,u,f,a=e[i],c=null,l=a>239?4:a>223?3:a>191?2:1;if(i+l<=r)switch(l){case 1:a<128&&(c=a);break;case 2:128==(192&(o=e[i+1]))&&(f=(31&a)<<6|63&o)>127&&(c=f);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(f=(15&a)<<12|(63&o)<<6|63&s)>2047&&(f<55296||f>57343)&&(c=f);break;case 4:o=e[i+1],s=e[i+2],u=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(f=(15&a)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&f<1114112&&(c=f)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=4096));return r}(n)}t.Buffer=f,t.SlowBuffer=function(e){+e!=e&&(e=0);return f.alloc(+e)},t.INSPECT_MAX_BYTES=50,f.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(),f.poolSize=8192,f._augment=function(e){return e.__proto__=f.prototype,e},f.from=function(e,t,r){return a(null,e,t,r)},f.TYPED_ARRAY_SUPPORT&&(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0})),f.alloc=function(e,t,r){return function(e,t,r,n){return c(t),t<=0?u(e,t):void 0!==r?"string"==typeof n?u(e,t).fill(r,n):u(e,t).fill(r):u(e,t)}(null,e,t,r)},f.allocUnsafe=function(e){return l(null,e)},f.allocUnsafeSlow=function(e){return l(null,e)},f.isBuffer=function(e){return!(null==e||!e._isBuffer)},f.compare=function(e,t){if(!f.isBuffer(e)||!f.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},f.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}},f.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return f.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=f.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!f.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},f.byteLength=d,f.prototype._isBuffer=!0,f.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)g(this,t,t+1);return this},f.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)g(this,t,t+3),g(this,t+1,t+2);return this},f.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)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},f.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?B(this,0,e):y.apply(this,arguments)},f.prototype.equals=function(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===f.compare(this,e)},f.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},f.prototype.compare=function(e,t,r,n,i){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),u=Math.min(o,s),a=this.slice(n,i),c=e.slice(t,r),l=0;l<u;++l)if(a[l]!==c[l]){o=a[l],s=c[l];break}return o<s?-1:s<o?1:0},f.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},f.prototype.indexOf=function(e,t,r){return _(this,e,t,r,!0)},f.prototype.lastIndexOf=function(e,t,r){return _(this,e,t,r,!1)},f.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return O(this,e,t,r);case"latin1":case"binary":return N(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function I(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=Y(e[o]);return i}function D(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,o){if(!f.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(r+n>e.length)throw new RangeError("Index out of range")}function L(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function U(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function M(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function j(e,t,r,n,o){return o||M(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function x(e,t,r,n,o){return o||M(e,0,r,8),i.write(e,t,r,n,52,8),r+8}f.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),f.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=f.prototype;else{var i=t-e;r=new f(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},f.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},f.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},f.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},f.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},f.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},f.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},f.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},f.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},f.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},f.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},f.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},f.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},f.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!0,23,4)},f.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!1,23,4)},f.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!0,52,8)},f.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!1,52,8)},f.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},f.prototype.writeUIntBE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},f.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,255,0),f.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},f.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},f.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},f.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):U(this,e,t,!0),t+4},f.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):U(this,e,t,!1),t+4},f.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0,s=1,u=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===u&&0!==this[t+o-1]&&(u=1),this[t+o]=(e/s>>0)-u&255;return t+r},f.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-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+r},f.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,127,-128),f.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},f.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):L(this,e,t,!0),t+2},f.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):L(this,e,t,!1),t+2},f.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):U(this,e,t,!0),t+4},f.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),f.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):U(this,e,t,!1),t+4},f.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},f.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},f.prototype.writeDoubleLE=function(e,t,r){return x(this,e,t,!0,r)},f.prototype.writeDoubleBE=function(e,t,r){return x(this,e,t,!1,r)},f.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!f.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},f.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=f.isBuffer(e)?e:$(new f(e,n).toString()),u=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%u]}return this};var C=/[^+\/0-9A-Za-z-_]/g;function Y(e){return e<16?"0"+e.toString(16):e.toString(16)}function $(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(C,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(1))},function(e,t,r){"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=a(e),s=n[0],u=n[1],f=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,u)),c=0,l=u>0?s-4:s;for(r=0;r<l;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],f[c++]=t>>16&255,f[c++]=t>>8&255,f[c++]=255&t;2===u&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,f[c++]=255&t);1===u&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,f[c++]=t>>8&255,f[c++]=255&t);return f},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,u=r-i;s<u;s+=16383)o.push(c(e,s,s+16383>u?u:s+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,f=s.length;u<f;++u)n[u]=s[u],i[s.charCodeAt(u)]=u;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,r){for(var i,o,s=[],u=t;u<r;u+=3)i=(e[u]<<16&16711680)+(e[u+1]<<8&65280)+(255&e[u+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
9
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
10
|
+
t.read=function(e,t,r,n,i){var o,s,u=8*i-n-1,f=(1<<u)-1,a=f>>1,c=-7,l=r?i-1:0,h=r?-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+=n;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-a;else{if(o===f)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=a}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,u,f,a=8*o-i-1,c=(1<<a)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?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*(f=Math.pow(2,-s))<1&&(s--,f*=2),(t+=s+l>=1?h/f:h*Math.pow(2,1-l))*f>=2&&(s++,f/=2),s+l>=c?(u=0,s=c):s+l>=1?(u=(t*f-1)*Math.pow(2,i),s+=l):(u=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&u,p+=d,u/=256,i-=8);for(s=s<<i|u,a+=i;a>0;e[r+p]=255&s,p+=d,s/=256,a-=8);e[r+p-d]|=128*y}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";r.r(t),r.d(t,"Query",(function(){return ze})),r.d(t,"CollectionReference",(function(){return We})),r.d(t,"DocumentReference",(function(){return $e})),r.d(t,"Db",(function(){return _t}));var n,i,o={};r.r(o),r.d(o,"Point",(function(){return Q})),r.d(o,"LineString",(function(){return te})),r.d(o,"Polygon",(function(){return ne})),r.d(o,"MultiPoint",(function(){return oe})),r.d(o,"MultiLineString",(function(){return ue})),r.d(o,"MultiPolygon",(function(){return ae})),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",f="Object",a="Array",c="GeoPoint",l="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",d="GeoMultiLineString",y="GeoMultiPolygon",g="Date",_="ServerDate",b="BsonDate",m=["desc","asc"],w=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={}));var O;(n={})[s.eq]="$eq",n[s.lt]="$lt",n[s.lte]="$lte",n[s.gt]="$gt",n[s.gte]="$gte";!function(e){e.WHERE="WHERE",e.DOC="DOC"}(O||(O={}));var N,S=(N=function(e,t){return(N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}N(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),v=[],A={},B=function(e){function t(t,r){if(r!==A)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return S(t,e),t.for=function(e){for(var r=0,n=v.length;r<n;r++)if(v[r].target===e)return v[r].instance;var i=new t(e,A);return v.push({target:e,instance:i}),i},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),E=B,T=E.for("UNSET_FIELD_NAME"),I=E.for("UPDATE_COMMAND"),D=E.for("QUERY_COMMAND"),R=E.for("LOGIC_COMMAND"),P=E.for("GEO_POINT"),L=E.for("SYMBOL_GEO_LINE_STRING"),U=E.for("SYMBOL_GEO_POLYGON"),M=E.for("SYMBOL_GEO_MULTI_POINT"),j=E.for("SYMBOL_GEO_MULTI_LINE_STRING"),x=E.for("SYMBOL_GEO_MULTI_POLYGON"),C=E.for("SERVER_DATE"),Y=E.for("REGEXP"),$=function(){function e(e){var t=(void 0===e?{}:e).offset,r=void 0===t?0:t;this.offset=r}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!0,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function q(e){return new $(e)}var F,k=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},z=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var r=Object.keys(t),n={};return Array.isArray(t)&&(n=[]),r.forEach((function(r){var i,o=t[r];switch(e.whichType(o)){case c:i=new Q(o.coordinates[0],o.coordinates[1]);break;case l:i=new te(o.coordinates.map((function(e){return new Q(e[0],e[1])})));break;case h:i=new ne(o.coordinates.map((function(e){return new te(e.map((function(e){var t=k(e,2),r=t[0],n=t[1];return new Q(r,n)})))})));break;case p:i=new oe(o.coordinates.map((function(e){return new Q(e[0],e[1])})));break;case d:i=new ue(o.coordinates.map((function(e){return new te(e.map((function(e){var t=k(e,2),r=t[0],n=t[1];return new Q(r,n)})))})));break;case y:i=new ae(o.coordinates.map((function(e){return new ne(e.map((function(e){return new te(e.map((function(e){var t=k(e,2),r=t[0],n=t[1];return new Q(r,n)})))})))})));break;case g:i=new Date(1e3*o.$timestamp);break;case f:case a:i=e.formatField(o);break;case _:i=new Date(o.$date);break;default:i=o}Array.isArray(n)?n.push(i):n[r]=i})),n},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===g)return b;if(t===f){if(e instanceof Q)return c;if(e instanceof Date)return g;if(e instanceof $)return _;e.$timestamp?t=g:e.$date?t=_:Q.validate(e)?t=c:te.validate(e)?t=l:ne.validate(e)?t=h:oe.validate(e)?t=p:ue.validate(e)?t=d:ae.validate(e)&&(t=y)}return t},e.generateDocId=function(){for(var e="ABCDEFabcdef0123456789",t="",r=0;r<24;r++)t+=e.charAt(Math.floor(Math.random()*e.length));return t},e}(),J=function(){function e(){}return e.isGeopoint=function(e,t){if(z.whichType(t)!==u)throw new Error("Geo Point must be number type");var r=Math.abs(t);if("latitude"===e&&r>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&r>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()},H=function(e){return"object"===G(e)},K=function(e){return"number"===G(e)},V=function(e){return Array.isArray(e)},W=function(e){return"date"===G(e)},X=function(e){return"regexp"===G(e)},Z=function(e){return e&&e._internalType instanceof B},Q=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&&V(e.coordinates)&&J.isGeopoint("longitude",e.coordinates[0])&&J.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),e}(),ee=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},te=function(){function e(e){if(!V(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 Q))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,r;if("LineString"!==e.type||!V(e.coordinates))return!1;try{for(var n=ee(e.coordinates),i=n.next();!i.done;i=n.next()){var o=i.value;if(!K(o[0])||!K(o[1]))return!1}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],r=e.points[e.points.length-1];if(t.latitude===r.latitude&&t.longitude===r.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),e}(),re=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ne=function(){function e(e){if(!V(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,r,n,i;if("Polygon"!==e.type||!V(e.coordinates))return!1;try{for(var o=re(e.coordinates),s=o.next();!s.done;s=o.next()){var u=s.value;if(!this.isCloseLineString(u))return!1;try{for(var f=(n=void 0,re(u)),a=f.next();!a.done;a=f.next()){var c=a.value;if(!K(c[0])||!K(c[1]))return!1}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!0,configurable:!0}),e}(),ie=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},oe=function(){function e(e){if(!V(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 Q))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,r;if("MultiPoint"!==e.type||!V(e.coordinates))return!1;try{for(var n=ie(e.coordinates),i=n.next();!i.done;i=n.next()){var o=i.value;if(!K(o[0])||!K(o[1]))return!1}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}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,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ue=function(){function e(e){if(!V(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,r,n,i;if("MultiLineString"!==e.type||!V(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 f=(n=void 0,se(u)),a=f.next();!a.done;a=f.next()){var c=a.value;if(!K(c[0])||!K(c[1]))return!1}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),e}(),fe=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ae=function(){function e(e){var t,r;if(!V(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 n=fe(e),i=n.next();!i.done;i=n.next()){var o=i.value;if(!(o instanceof ne))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof o+"[]")}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}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,r,n,i,o,s;if("MultiPolygon"!==e.type||!V(e.coordinates))return!1;try{for(var u=fe(e.coordinates),f=u.next();!f.done;f=u.next()){var a=f.value;try{for(var c=(n=void 0,fe(a)),l=c.next();!l.done;l=c.next()){var h=l.value;try{for(var p=(o=void 0,fe(h)),d=p.next();!d.done;d=p.next()){var y=d.value;if(!K(y[0])||!K(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){n={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},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 r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,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,r){this._internalType=I,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||T}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,r){if(this._internalType=R,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||T,this.fieldName!==T)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var n=0,i=t.length;n<i;n++){(ye(o=t[n])||me(o))&&(t[n]=o._setFieldName(this.fieldName))}}else{var o;(ye(o=t)||me(o))&&(t=o._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var r=this.operands.map((function(r){return r instanceof e?r._setFieldName(t):r}));return new e(this.operator,r,t)},e.prototype.and=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(pe.AND,n,this.fieldName)},e.prototype.or=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(pe.OR,n,this.fieldName)},e}();function ye(e){return e&&e instanceof de&&e._internalType===R}var ge,_e=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();!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"}(ge||(ge={}));var be=function(e){function t(t,r,n){var i=e.call(this,t,r,n)||this;return i.operator=t,i._internalType=D,i}return _e(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case ge.IN:case ge.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 r=new t(ge.EQ,[e],this.fieldName);return this.and(r)},t.prototype.neq=function(e){var r=new t(ge.NEQ,[e],this.fieldName);return this.and(r)},t.prototype.gt=function(e){var r=new t(ge.GT,[e],this.fieldName);return this.and(r)},t.prototype.gte=function(e){var r=new t(ge.GTE,[e],this.fieldName);return this.and(r)},t.prototype.lt=function(e){var r=new t(ge.LT,[e],this.fieldName);return this.and(r)},t.prototype.lte=function(e){var r=new t(ge.LTE,[e],this.fieldName);return this.and(r)},t.prototype.in=function(e){var r=new t(ge.IN,e,this.fieldName);return this.and(r)},t.prototype.nin=function(e){var r=new t(ge.NIN,e,this.fieldName);return this.and(r)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point. Received type '+typeof e.geometry);if(void 0!==e.maxDistance&&!K(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof e.maxDistance);if(void 0!==e.minDistance&&!K(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof e.minDistance);var r=new t(ge.GEO_NEAR,[e],this.fieldName);return this.and(r)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof ae||e.geometry instanceof ne))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof e.geometry);var r=new t(ge.GEO_WITHIN,[e],this.fieldName);return this.and(r)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof Q||e.geometry instanceof te||e.geometry instanceof ne||e.geometry instanceof oe||e.geometry instanceof ue||e.geometry instanceof ae))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof e.geometry);var r=new t(ge.GEO_INTERSECTS,[e],this.fieldName);return this.and(r)},t}(de);function me(e){return e&&e instanceof be&&e._internalType===D}function we(e){return me(e)}var Oe={};for(var Ne in ge)Oe[Ne]="$"+Ne;for(var Ne in pe)Oe[Ne]="$"+Ne;for(var Ne in F)Oe[Ne]="$"+Ne;function Se(e){return Oe[e]||"$"+e}Oe[ge.NEQ]="$ne",Oe[F.REMOVE]="$unset",Oe[F.SHIFT]="$pop",Oe[F.UNSHIFT]="$push";var ve=function(){return(ve=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Ae=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},Be=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ae(arguments[t]));return e};function Ee(e){return function e(t,r){if(!Z(t)){if(W(t))return{$date:+t};if(X(t))return{$regex:t.source,$options:t.flags};if(V(t))return t.map((function(t){if(r.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return e(t,Be(r,[t]))}));if(H(t)){var n=ve({},t);for(var i in n){if(r.indexOf(n[i])>-1)throw new Error("Cannot convert circular structure to JSON");n[i]=e(n[i],Be(r,[n[i]]))}return n}return t}switch(t._internalType){case P:return t.toJSON();case C:case Y:return t.parse();default:return t.toJSON?t.toJSON():t}}(e,[e])}var Te=function(){return(Te=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},Ie=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.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 Re(e,t,r,n){var i=Te({},e);for(var o in e)if(!/^\$/.test(o)){var s=e[o];if(s&&H(s)&&!t(s)){if(n.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var u=Re(s,t,De(r,[o]),De(n,[s]));i[o]=u;var f=!1;for(var a in u)/^\$/.test(a)?f=!0:(i[o+"."+a]=u[a],delete i[o][a]);f||delete i[o]}}return i}function Pe(e){return Re(e,Ue,[],[e])}function Le(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?V(e[n])?e[n].push(t[n]):H(e[n])?H(t[n])?Object.assign(e[n],t[n]):(console.warn("unmergable condition, query is object but condition is "+G(t)+", can only overwrite",t,r),e[n]=t[n]):(console.warn("to-merge query is of type "+G(e)+", can only overwrite",e,t,r),e[n]=t[n]):e[n]=t[n]}function Ue(e){return Z(e)||W(e)||X(e)}function Me(e){return Ee(e)}var je=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===T)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,r,n,i,o=Se(e.operator);switch(e.operator){case F.REMOVE:return(t={})[o]=((r={})[e.fieldName]="",r),t;default:return(n={})[o]=((i={})[e.fieldName]=e.operands[0],i),n}},e.prototype.encodeArrayUpdateCommand=function(e){var t,r,n,i,o,s,u,f,a,c,l=Se(e.operator);switch(e.operator){case F.PUSH:var h=void 0;return h=V(e.operands)?{$each:e.operands.map(Me)}:e.operands,(t={})[l]=((r={})[e.fieldName]=h,r),t;case F.UNSHIFT:h={$each:e.operands.map(Me),$position:0};return(n={})[l]=((i={})[e.fieldName]=h,i),n;case F.POP:return(o={})[l]=((s={})[e.fieldName]=1,s),o;case F.SHIFT:return(u={})[l]=((f={})[e.fieldName]=-1,f),u;default:return(a={})[l]=((c={})[e.fieldName]=Me(e.operands),c),a}},e.prototype.encodeUpdateObject=function(e){var t=Pe(e);for(var r in t)if(!/^\$/.test(r)){var n=t[r];if(he(n)){t[r]=n._setFieldName(r),Le(t,this.encodeUpdateCommand(t[r]),r)}else{t[r]=n=Me(n);var i=new le(F.SET,[n],r);Le(t,this.encodeUpdateCommand(i),r)}}return t},e}(),xe={};function Ce(e){if(!_t.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return xe[t]||(xe[t]=new _t.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new _t.reqClass(e.config)}}})),xe[t]}var Ye=function(){return(Ye=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},$e=function(){function e(e,t,r,n){var i=this;void 0===n&&(n={}),this.watch=function(e){return Ce(i._db).watch(Ye(Ye({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=e,this._coll=t,this.id=r,this.request=new _t.reqClass(this._db.config),this.projection=n}return e.prototype.create=function(e,t){t=t||ce();var r={collectionName:this._coll,data:Ee(e)};return this.id&&(r._id=this.id),this.request.send("database.addDocument",r).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 r=!1,n=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof le?r=!0:"object"==typeof e[t]&&n(e[t])};if(n(e),r)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var i={collectionName:this._coll,queryType:O.DOC,data:Ee(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 r={_id:this.id},n={collectionName:this._coll,data:je.encode(e),query:r,queryType:O.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",n).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},r={collectionName:this._coll,query:t,queryType:O.DOC,multi:!1};return this.request.send("database.deleteDocument",r).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},r={collectionName:this._coll,query:t,queryType:O.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",r).then((function(t){if(t.code)e(0,t);else{var r=z.formatResDocumentData(t.data.list);e(0,{data:r,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 r in t)t[r]?t[r]=1:t[r]=0;return new e(this._db,this._coll,this.id,t)},e}(),qe=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 r;return Ue(e)?ye(e)?this.encodeLogicCommand(e):me(e)?this.encodeQueryCommand(e):((r={})[t]=this.encodeQueryObject(e),r):H(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,r,n,i,o,s,u,f=this;switch(e.operator){case pe.NOR:case pe.AND:case pe.OR:var a=Se(e.operator),c=e.operands.map((function(t){return f.encodeQuery(t,e.fieldName)}));return(t={})[a]=c,t;case pe.NOT:a=Se(e.operator);var l=e.operands[0];if(X(l))return(r={})[e.fieldName]=((n={})[a]=this.encodeRegExp(l),n),r;c=this.encodeQuery(l)[e.fieldName];return(i={})[e.fieldName]=((o={})[a]=c,o),i;default:a=Se(e.operator);if(1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[a]=h,s}c=e.operands.map(this.encodeQuery.bind(this));return(u={})[a]=c,u}},e.prototype.encodeQueryCommand=function(e){return we(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,r,n,i,o,s,u,f,a;if(e.fieldName===T)throw new Error("Cannot encode a comparison command with unset field name");var c=Se(e.operator);switch(e.operator){case ge.EQ:case ge.NEQ:case ge.LT:case ge.LTE:case ge.GT:case ge.GTE:case ge.ELEM_MATCH:case ge.EXISTS:case ge.SIZE:case ge.MOD:return(t={})[e.fieldName]=((r={})[c]=Me(e.operands[0]),r),t;case ge.IN:case ge.NIN:case ge.ALL:return(n={})[e.fieldName]=((i={})[c]=Me(e.operands),i),n;case ge.GEO_NEAR:var l=e.operands[0];return(o={})[e.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},o;case ge.GEO_WITHIN:l=e.operands[0];return(s={})[e.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case ge.GEO_INTERSECTS:l=e.operands[0];return(u={})[e.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},u;default:return(f={})[e.fieldName]=((a={})[c]=Me(e.operands[0]),a),f}},e.prototype.encodeQueryObject=function(e){var t=Pe(e);for(var r in t){var n=t[r];if(ye(n)){t[r]=n._setFieldName(r);var i=this.encodeLogicCommand(t[r]);this.mergeConditionAfterEncode(t,i,r)}else if(we(n)){t[r]=n._setFieldName(r);i=this.encodeComparisonCommand(t[r]);this.mergeConditionAfterEncode(t,i,r)}else Ue(n)&&(t[r]=Me(n))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?V(e[n])?e[n]=e[n].concat(t[n]):H(e[n])?H(t[n])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is "+G(t)+", can only overwrite",t,r),e[n]=t[n]):(console.warn("to-merge query is of type "+G(e)+", can only overwrite",e,t,r),e[n]=t[n]):e[n]=t[n]},e}(),ke=function(){return(ke=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ze=function(){function e(e,t,r,n,i){var o=this;this.watch=function(e){return Ce(o._db).watch(ke(ke({},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=r,this._fieldOrders=n||[],this._queryOptions=i||{},this._request=new _t.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 r={collectionName:this._coll,queryType:O.WHERE};return this._fieldFilters&&(r.query=this._fieldFilters),t.length>0&&(r.order=t),this._queryOptions.offset&&(r.offset=this._queryOptions.offset),this._queryOptions.limit?r.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:r.limit=100,this._queryOptions.projection&&(r.projection=this._queryOptions.projection),this._request.send("database.queryDocument",r).then((function(t){if(t.code)e(0,t);else{var r={data:z.formatResDocumentData(t.data.list),requestId:t.requestId};t.TotalCount&&(r.total=t.TotalCount),t.Limit&&(r.limit=t.Limit),t.Offset&&(r.offset=t.Offset),e(0,r)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ce();var t={collectionName:this._coll,queryType:O.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 r=Object.keys(t),n=r.some((function(e){return void 0!==t[e]}));if(r.length&&!n)throw Error(i.QueryParamValueError);return new e(this._db,this._coll,qe.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,r){J.isFieldPath(t),J.isFieldOrder(r);var n={field:t,direction:r},i=this._fieldOrders.concat(n);return new e(this._db,this._coll,this._fieldFilters,i,this._queryOptions)},e.prototype.limit=function(t){J.isInteger("limit",t);var r=ke({},this._queryOptions);return r.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.skip=function(t){J.isInteger("offset",t);var r=ke({},this._queryOptions);return r.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},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 r={collectionName:this._coll,query:this._fieldFilters,queryType:O.WHERE,multi:!0,merge:!0,upsert:!1,data:je.encode(e)};return this._request.send("database.updateDocument",r).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 r in t)t[r]?"object"!=typeof t[r]&&(t[r]=1):t[r]=0;var n=ke({},this._queryOptions);return n.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},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:qe.encode(this._fieldFilters),queryType:O.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=r(0),Ge=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{f(n.next(e))}catch(e){o(e)}}function u(e){try{f(n.throw(e))}catch(e){o(e)}}function f(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}f((n=n.apply(e,t||[])).next())}))},He=function(e,t){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},Ke=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=new _t.reqClass(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return Ge(this,void 0,void 0,(function(){var e;return He(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,r=e.stageKey,n=e.stageValue;return(t={})[r]=JSON.parse(n),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",qe.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}(),Ve=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),We=function(e){function t(t,r){return e.call(this,t,r)||this}return Ve(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 $e(this._db,this._coll,e)},t.prototype.add=function(e,t){return new $e(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new Ke(this._db,this._coll)},t}(ze),Xe={eq:function(e){return new be(ge.EQ,[e])},neq:function(e){return new be(ge.NEQ,[e])},lt:function(e){return new be(ge.LT,[e])},lte:function(e){return new be(ge.LTE,[e])},gt:function(e){return new be(ge.GT,[e])},gte:function(e){return new be(ge.GTE,[e])},in:function(e){return new be(ge.IN,e)},nin:function(e){return new be(ge.NIN,e)},all:function(e){return new be(ge.ALL,e)},elemMatch:function(e){return new be(ge.ELEM_MATCH,[e])},exists:function(e){return new be(ge.EXISTS,[e])},size:function(e){return new be(ge.SIZE,[e])},mod:function(e){return new be(ge.MOD,[e])},geoNear:function(e){return new be(ge.GEO_NEAR,[e])},geoWithin:function(e){return new be(ge.GEO_WITHIN,[e])},geoIntersects:function(e){return new be(ge.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=V(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.AND,r)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=V(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOR,r)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=V(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.OR,r)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=V(arguments[0])?arguments[0]:Array.from(arguments);return new de(pe.NOT,r)},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=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(H(t[0])&&t[0].hasOwnProperty("each")){var n=t[0];e={$each:n.each,$position:n.position,$sort:n.sort,$slice:n.slice}}else e=V(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 r=V(arguments[0])?arguments[0]:Array.from(arguments);return new le(F.UNSHIFT,r)},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 Ke},abs:function(e){return new Ze("abs",e)},add:function(e){return new Ze("add",e)},ceil:function(e){return new Ze("ceil",e)},divide:function(e){return new Ze("divide",e)},exp:function(e){return new Ze("exp",e)},floor:function(e){return new Ze("floor",e)},ln:function(e){return new Ze("ln",e)},log:function(e){return new Ze("log",e)},log10:function(e){return new Ze("log10",e)},mod:function(e){return new Ze("mod",e)},multiply:function(e){return new Ze("multiply",e)},pow:function(e){return new Ze("pow",e)},sqrt:function(e){return new Ze("sqrt",e)},subtract:function(e){return new Ze("subtract",e)},trunc:function(e){return new Ze("trunc",e)},arrayElemAt:function(e){return new Ze("arrayElemAt",e)},arrayToObject:function(e){return new Ze("arrayToObject",e)},concatArrays:function(e){return new Ze("concatArrays",e)},filter:function(e){return new Ze("filter",e)},in:function(e){return new Ze("in",e)},indexOfArray:function(e){return new Ze("indexOfArray",e)},isArray:function(e){return new Ze("isArray",e)},map:function(e){return new Ze("map",e)},range:function(e){return new Ze("range",e)},reduce:function(e){return new Ze("reduce",e)},reverseArray:function(e){return new Ze("reverseArray",e)},size:function(e){return new Ze("size",e)},slice:function(e){return new Ze("slice",e)},zip:function(e){return new Ze("zip",e)},and:function(e){return new Ze("and",e)},not:function(e){return new Ze("not",e)},or:function(e){return new Ze("or",e)},cmp:function(e){return new Ze("cmp",e)},eq:function(e){return new Ze("eq",e)},gt:function(e){return new Ze("gt",e)},gte:function(e){return new Ze("gte",e)},lt:function(e){return new Ze("lt",e)},lte:function(e){return new Ze("lte",e)},neq:function(e){return new Ze("ne",e)},cond:function(e){return new Ze("cond",e)},ifNull:function(e){return new Ze("ifNull",e)},switch:function(e){return new Ze("switch",e)},dateFromParts:function(e){return new Ze("dateFromParts",e)},dateFromString:function(e){return new Ze("dateFromString",e)},dayOfMonth:function(e){return new Ze("dayOfMonth",e)},dayOfWeek:function(e){return new Ze("dayOfWeek",e)},dayOfYear:function(e){return new Ze("dayOfYear",e)},isoDayOfWeek:function(e){return new Ze("isoDayOfWeek",e)},isoWeek:function(e){return new Ze("isoWeek",e)},isoWeekYear:function(e){return new Ze("isoWeekYear",e)},millisecond:function(e){return new Ze("millisecond",e)},minute:function(e){return new Ze("minute",e)},month:function(e){return new Ze("month",e)},second:function(e){return new Ze("second",e)},hour:function(e){return new Ze("hour",e)},week:function(e){return new Ze("week",e)},year:function(e){return new Ze("year",e)},literal:function(e){return new Ze("literal",e)},mergeObjects:function(e){return new Ze("mergeObjects",e)},objectToArray:function(e){return new Ze("objectToArray",e)},allElementsTrue:function(e){return new Ze("allElementsTrue",e)},anyElementTrue:function(e){return new Ze("anyElementTrue",e)},setDifference:function(e){return new Ze("setDifference",e)},setEquals:function(e){return new Ze("setEquals",e)},setIntersection:function(e){return new Ze("setIntersection",e)},setIsSubset:function(e){return new Ze("setIsSubset",e)},setUnion:function(e){return new Ze("setUnion",e)},concat:function(e){return new Ze("concat",e)},dateToString:function(e){return new Ze("dateToString",e)},indexOfBytes:function(e){return new Ze("indexOfBytes",e)},indexOfCP:function(e){return new Ze("indexOfCP",e)},split:function(e){return new Ze("split",e)},strLenBytes:function(e){return new Ze("strLenBytes",e)},strLenCP:function(e){return new Ze("strLenCP",e)},strcasecmp:function(e){return new Ze("strcasecmp",e)},substr:function(e){return new Ze("substr",e)},substrBytes:function(e){return new Ze("substrBytes",e)},substrCP:function(e){return new Ze("substrCP",e)},toLower:function(e){return new Ze("toLower",e)},toUpper:function(e){return new Ze("toUpper",e)},meta:function(e){return new Ze("meta",e)},addToSet:function(e){return new Ze("addToSet",e)},avg:function(e){return new Ze("avg",e)},first:function(e){return new Ze("first",e)},last:function(e){return new Ze("last",e)},max:function(e){return new Ze("max",e)},min:function(e){return new Ze("min",e)},push:function(e){return new Ze("push",e)},stdDevPop:function(e){return new Ze("stdDevPop",e)},stdDevSamp:function(e){return new Ze("stdDevSamp",e)},sum:function(e){return new Ze("sum",e)},let:function(e){return new Ze("let",e)}},project:{slice:function(e){return new Qe("slice",e)},elemMatch:function(e){return new Qe("elemMatch",e)}}},Ze=function(e,t){this["$"+e]=t},Qe=function(e,t){this["$"+e]=t},et=function(){function e(e){var t=e.regexp,r=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=r}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return Y},enumerable:!0,configurable:!0}),e}();function tt(e){return new et(e)}var rt={code:"INSERT_DOC_FAIL",message:"insert document failed"},nt={code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"},it=function(){return(it=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},ot=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{f(n.next(e))}catch(e){o(e)}}function u(e){try{f(n.throw(e))}catch(e){o(e)}}function f(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}f((n=n.apply(e,t||[])).next())}))},st=function(e,t){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},ut="database.updateDocInTransaction",ft=function(){function e(e,t,r){this._coll=t,this.id=r,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,r,n,i;return st(this,(function(o){switch(o.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:Je.a.stringify(Ee(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((r=o.sent()).code)throw r;if(n=Je.a.parse(r.inserted),1==(i=Je.a.parse(r.ok))&&1==n)return[2,it(it({},r),{ok:i,inserted:n})];throw new Error(rt.message)}}))}))},e.prototype.get=function(){return ot(this,void 0,void 0,(function(){var e,t;return st(this,(function(r){switch(r.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=r.sent()).code)throw t;return[2,{data:"null"!==t.data?z.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,r;return st(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Je.a.stringify(Ee(e),{relaxed:!1}),upsert:!0},[4,this._request.send(ut,t)];case 1:if((r=n.sent()).code)throw r;return[2,it(it({},r),{updated:Je.a.parse(r.updated),upserted:r.upserted?JSON.parse(r.upserted):null})]}}))}))},e.prototype.update=function(e){return ot(this,void 0,void 0,(function(){var t,r;return st(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Je.a.stringify(je.encode(e),{relaxed:!1})},[4,this._request.send(ut,t)];case 1:if((r=n.sent()).code)throw r;return[2,it(it({},r),{updated:Je.a.parse(r.updated)})]}}))}))},e.prototype.delete=function(){return ot(this,void 0,void 0,(function(){var e,t;return st(this,(function(r){switch(r.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=r.sent()).code)throw t;return[2,it(it({},t),{deleted:Je.a.parse(t.deleted)})]}}))}))},e}(),at=function(e,t){this._coll=t,this._transaction=e},ct=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),lt=function(e){function t(t,r){return e.call(this,t,r)||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 ft(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new ft(this._transaction,this._coll,t).create(e)},t}(at),ht=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{f(n.next(e))}catch(e){o(e)}}function u(e){try{f(n.throw(e))}catch(e){o(e)}}function f(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}f((n=n.apply(e,t||[])).next())}))},pt=function(e,t){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=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++,n=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],n=0}finally{r=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 _t.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(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=r.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,r;return pt(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((r=n.sent()).code)throw r;return this.aborted=!0,this.abortReason=e,[2,r]}}))}))},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 gt(e,t){return void 0===t&&(t=3),ht(this,void 0,void 0,(function(){var r,n,i,o,s=this;return pt(this,(function(u){switch(u.label){case 0:return u.trys.push([0,4,,10]),[4,(r=new dt(this)).init()];case 1:return u.sent(),[4,e(r)];case 2:if(n=u.sent(),!0===r.aborted)throw r.abortReason;return[4,r.commit()];case 3:return u.sent(),[2,n];case 4:if(i=u.sent(),!1===r.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(r.aborted||r.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.rollback()];case 2:return t.sent(),[3,4];case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===r.aborted)throw r.abortReason;throw e}}))}))},t<=0?[4,o(i)]:[3,6];case 5:u.sent(),u.label=6;case 6:return i&&i.code===nt.code?[4,gt.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 _t=function(){function e(e){this.config=e,this.Geo=o,this.serverDate=q,this.command=Xe,this.RegExp=tt,this.startTransaction=yt,this.runTransaction=gt,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 r={collectionName:t};return new e.reqClass(this.config).send("database.addCollection",r)},e}()}])}));
|