@cloudbase/js-sdk 4.0.0 → 4.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +398 -0
- package/ai/dist/index.esm.js +2 -3
- package/ai/dist/index.esm.js.map +1 -0
- package/ai/dist/index.js +2 -21
- package/ai/dist/index.js.map +1 -0
- package/apis/dist/index.d.ts +1 -0
- package/apis/dist/index.esm.js +2 -0
- package/apis/dist/index.esm.js.map +1 -0
- package/apis/dist/index.js +2 -0
- package/apis/dist/index.js.map +1 -0
- package/{analytics → apis}/package.json +1 -1
- package/app/dist/index.esm.js +2 -11
- package/app/dist/index.esm.js.map +1 -0
- package/app/dist/index.js +2 -18
- package/app/dist/index.js.map +1 -0
- package/app/dist/index.node.esm.js +3 -0
- package/app/dist/index.node.esm.js.LICENSE.txt +13 -0
- package/app/dist/index.node.esm.js.map +1 -0
- package/app/dist/index.node.js +3 -0
- package/app/dist/index.node.js.LICENSE.txt +13 -0
- package/app/dist/index.node.js.map +1 -0
- package/app/package.json +12 -1
- package/auth/dist/index.d.ts +2 -2
- package/auth/dist/index.esm.js +3 -4
- package/auth/dist/index.esm.js.LICENSE.txt +12 -0
- package/auth/dist/index.esm.js.map +1 -0
- package/auth/dist/index.js +3 -9
- package/auth/dist/index.js.LICENSE.txt +12 -0
- package/auth/dist/index.js.map +1 -0
- package/cloudrun/dist/index.esm.js +2 -3
- package/cloudrun/dist/index.esm.js.map +1 -0
- package/cloudrun/dist/index.js +2 -21
- package/cloudrun/dist/index.js.map +1 -0
- package/container/dist/index.d.ts +2 -2
- package/container/dist/index.esm.js +2 -4
- package/container/dist/index.esm.js.map +1 -0
- package/container/dist/index.js +2 -9
- package/container/dist/index.js.map +1 -0
- package/core.d.ts +4331 -0
- package/core.node.d.ts +294 -0
- package/database/dist/index.esm.js +2 -47
- package/database/dist/index.esm.js.map +1 -0
- package/database/dist/index.js +2 -53
- package/database/dist/index.js.map +1 -0
- package/database/package.json +34 -4
- package/dist/index.cjs.js +3 -37
- package/dist/index.cjs.js.LICENSE.txt +12 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.js +3 -32
- package/dist/index.esm.js.LICENSE.txt +12 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.node.cjs.js +3 -0
- package/dist/index.node.cjs.js.LICENSE.txt +26 -0
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/index.node.esm.js +3 -0
- package/dist/index.node.esm.js.LICENSE.txt +26 -0
- package/dist/index.node.esm.js.map +1 -0
- package/functions/dist/index.d.ts +2 -2
- package/functions/dist/index.esm.js +2 -4
- package/functions/dist/index.esm.js.map +1 -0
- package/functions/dist/index.js +2 -9
- package/functions/dist/index.js.map +1 -0
- package/index.d.ts +7 -1785
- package/index.node.d.ts +13 -0
- package/miniprogram_dist/ai/index.d.ts +42 -0
- package/miniprogram_dist/ai/index.js +2 -0
- package/miniprogram_dist/apis/index.d.ts +5 -0
- package/miniprogram_dist/apis/index.js +1 -0
- package/miniprogram_dist/app/index.d.ts +67 -0
- package/miniprogram_dist/app/index.js +2 -0
- package/miniprogram_dist/auth/index.d.ts +269 -0
- package/miniprogram_dist/auth/index.js +2 -0
- package/miniprogram_dist/cloudrun/index.d.ts +4 -0
- package/miniprogram_dist/cloudrun/index.js +1 -0
- package/miniprogram_dist/container/index.d.ts +13 -0
- package/miniprogram_dist/container/index.js +1 -0
- package/miniprogram_dist/database/index.d.ts +3 -0
- package/miniprogram_dist/database/index.js +1 -0
- package/miniprogram_dist/functions/index.d.ts +2 -0
- package/miniprogram_dist/functions/index.js +1 -0
- package/miniprogram_dist/index.js +1 -1
- package/miniprogram_dist/model/index.d.ts +5 -0
- package/miniprogram_dist/model/index.js +1 -0
- package/miniprogram_dist/mysql/index.d.ts +3 -0
- package/miniprogram_dist/mysql/index.js +1 -0
- package/miniprogram_dist/oauth/index.d.ts +22 -0
- package/miniprogram_dist/oauth/index.js +2 -0
- package/miniprogram_dist/realtime/index.d.ts +2 -0
- package/miniprogram_dist/realtime/index.js +1 -0
- package/miniprogram_dist/storage/index.d.ts +13 -0
- package/miniprogram_dist/storage/index.js +1 -0
- package/model/dist/index.esm.js +2 -3
- package/model/dist/index.esm.js.map +1 -0
- package/model/dist/index.js +2 -21
- package/model/dist/index.js.map +1 -0
- package/mysql/dist/index.d.ts +1 -0
- package/mysql/dist/index.esm.js +2 -0
- package/mysql/dist/index.esm.js.map +1 -0
- package/mysql/dist/index.js +2 -0
- package/mysql/dist/index.js.map +1 -0
- package/mysql/package.json +6 -0
- package/oauth/dist/index.esm.js +3 -3
- package/oauth/dist/index.esm.js.LICENSE.txt +12 -0
- package/oauth/dist/index.esm.js.map +1 -0
- package/oauth/dist/index.js +3 -21
- package/oauth/dist/index.js.LICENSE.txt +12 -0
- package/oauth/dist/index.js.map +1 -0
- package/package.json +144 -18
- package/realtime/dist/index.d.ts +2 -2
- package/realtime/dist/index.esm.js +2 -4
- package/realtime/dist/index.esm.js.map +1 -0
- package/realtime/dist/index.js +2 -9
- package/realtime/dist/index.js.map +1 -0
- package/storage/dist/index.d.ts +2 -2
- package/storage/dist/index.esm.js +2 -4
- package/storage/dist/index.esm.js.map +1 -0
- package/storage/dist/index.js +2 -9
- package/storage/dist/index.js.map +1 -0
- package/types/analytics.d.ts +51 -0
- package/types/auth.d.ts +166 -0
- package/types/cache.d.ts +26 -0
- package/types/cloudrun.d.ts +9 -0
- package/types/component.d.ts +17 -0
- package/types/container.d.ts +93 -0
- package/types/database.d.ts +31 -0
- package/types/error.d.ts +40 -0
- package/types/events.d.ts +13 -0
- package/types/functions.d.ts +49 -0
- package/types/index.d.ts +269 -0
- package/types/package.json +47 -0
- package/types/realtime.d.ts +350 -0
- package/types/request.d.ts +30 -0
- package/types/result.d.ts +48 -0
- package/types/storage.d.ts +144 -0
- package/utilities/dist/cjs/adapters/index.d.ts +45 -0
- package/utilities/dist/cjs/adapters/index.js +68 -0
- package/utilities/dist/cjs/adapters/platforms/web.d.ts +20 -0
- package/utilities/dist/cjs/adapters/platforms/web.js +286 -0
- package/utilities/dist/cjs/constants/common.d.ts +6 -0
- package/utilities/dist/cjs/constants/common.js +24 -0
- package/utilities/dist/cjs/constants/errors.d.ts +8 -0
- package/utilities/dist/cjs/constants/errors.js +12 -0
- package/utilities/dist/cjs/constants/index.d.ts +3 -0
- package/utilities/dist/cjs/constants/index.js +21 -0
- package/utilities/dist/cjs/helpers/decorators.d.ts +11 -0
- package/utilities/dist/cjs/helpers/decorators.js +238 -0
- package/utilities/dist/cjs/helpers/index.d.ts +1 -0
- package/utilities/dist/cjs/helpers/index.js +18 -0
- package/utilities/dist/cjs/index.d.ts +13 -0
- package/utilities/dist/cjs/index.js +51 -0
- package/utilities/dist/cjs/libs/abortController.d.ts +9 -0
- package/utilities/dist/cjs/libs/abortController.js +25 -0
- package/utilities/dist/cjs/libs/cache.d.ts +17 -0
- package/utilities/dist/cjs/libs/cache.js +261 -0
- package/utilities/dist/cjs/libs/events.d.ts +27 -0
- package/utilities/dist/cjs/libs/events.js +108 -0
- package/utilities/dist/cjs/libs/langEvent.d.ts +3 -0
- package/utilities/dist/cjs/libs/langEvent.js +7 -0
- package/utilities/dist/cjs/libs/util.d.ts +49 -0
- package/utilities/dist/cjs/libs/util.js +282 -0
- package/utilities/dist/esm/adapters/index.d.ts +45 -0
- package/utilities/dist/esm/adapters/index.js +40 -0
- package/utilities/dist/esm/adapters/platforms/web.d.ts +20 -0
- package/utilities/dist/esm/adapters/platforms/web.js +282 -0
- package/utilities/dist/esm/constants/common.d.ts +6 -0
- package/utilities/dist/esm/constants/common.js +17 -0
- package/utilities/dist/esm/constants/errors.d.ts +8 -0
- package/utilities/dist/esm/constants/errors.js +9 -0
- package/utilities/dist/esm/constants/index.d.ts +3 -0
- package/utilities/dist/esm/constants/index.js +4 -0
- package/utilities/dist/esm/helpers/decorators.d.ts +11 -0
- package/utilities/dist/esm/helpers/decorators.js +234 -0
- package/utilities/dist/esm/helpers/index.d.ts +1 -0
- package/utilities/dist/esm/helpers/index.js +2 -0
- package/utilities/dist/esm/index.d.ts +13 -0
- package/utilities/dist/esm/index.js +14 -0
- package/utilities/dist/esm/libs/abortController.d.ts +9 -0
- package/utilities/dist/esm/libs/abortController.js +23 -0
- package/utilities/dist/esm/libs/cache.d.ts +17 -0
- package/utilities/dist/esm/libs/cache.js +258 -0
- package/utilities/dist/esm/libs/events.d.ts +27 -0
- package/utilities/dist/esm/libs/events.js +102 -0
- package/utilities/dist/esm/libs/langEvent.d.ts +3 -0
- package/utilities/dist/esm/libs/langEvent.js +4 -0
- package/utilities/dist/esm/libs/util.d.ts +49 -0
- package/utilities/dist/esm/libs/util.js +254 -0
- package/utilities/dist/miniprogram/index.js +1 -0
- package/utilities/package.json +26 -0
- package/analytics/dist/index.d.ts +0 -2
- package/analytics/dist/index.esm.js +0 -4
- package/analytics/dist/index.js +0 -9
- package/miniprogram_dist/ai.js +0 -2
- package/miniprogram_dist/analytics.js +0 -1
- package/miniprogram_dist/app.js +0 -2
- package/miniprogram_dist/auth.js +0 -2
- package/miniprogram_dist/cloudrun.js +0 -1
- package/miniprogram_dist/container.js +0 -1
- package/miniprogram_dist/database.js +0 -2
- package/miniprogram_dist/functions.js +0 -1
- package/miniprogram_dist/model.js +0 -1
- package/miniprogram_dist/oauth.js +0 -1
- package/miniprogram_dist/realtime.js +0 -1
- package/miniprogram_dist/storage.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_database",[],e):"object"==typeof exports?exports.cloudbase_database=e():t.cloudbase_database=e()}("undefined"!=typeof window?window:this,()=>(()=>{var t={198:function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}u((r=r.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var u=n(543),c=n(804),f={filterRes:function(t){return delete t.header,delete t.statusCode,t},flattenResData:function(t){if("object"==typeof t.data&&null!==t.data){var e=i(i({},t),t.data);return delete e.data,e}return t},safeParseEJSON:function(t){if("string"!=typeof t)return t;try{return c.EJSON.parse(t)}catch(e){return t}},buildQueryParams:function(t){return Object.entries(t).filter(function(t){t[0];var e=t[1];return null!=e&&""!==e}).map(function(t){var e=t[0],n=t[1],r="object"==typeof n?JSON.stringify(n):String(n);return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r))}).join("&")},getUrlPrefix:function(t){var e=(null==t?void 0:t.instance)||"(default)",n=(null==t?void 0:t.database)||"(default)";return"/database/instances/".concat(e,"/databases/").concat(n)},"database.queryDocument":function(t){var e,n,r,o,u,l,h,d;return s(this,void 0,Promise,function(){var s,p,y,g;return a(this,function(a){switch(a.label){case 0:return s=!!(null===(n=null===(e=t.query)||void 0===e?void 0:e._id)||void 0===n?void 0:n.$eq),p=f.buildQueryParams(i({projection:t.projection,transactionId:t.transactionId},s?{}:{offset:null!==(r=t.offset)&&void 0!==r?r:0,limit:null!==(o=t.limit)&&void 0!==o?o:100,order:t.order,query:t.query?c.EJSON.stringify(t.query,{relaxed:!1}):void 0})),y="".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(p),s&&(y="".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/").concat((null===(u=t.query._id)||void 0===u?void 0:u.$eq)||t.query._id,"?").concat(p)),[4,this.gateWay({url:y,method:"GET"})];case 1:return(g=a.sent()).data=f.safeParseEJSON(JSON.stringify(g.data)),!s||g.code||(null===(l=g.data)||void 0===l?void 0:l.code)?(g.code||(null===(h=g.data)||void 0===h?void 0:h.code)?g=i(i({},g),{code:g.code||(null===(d=g.data)||void 0===d?void 0:d.code),data:i(i({},g.data),{list:[]})}):Array.isArray(g.data)?g=i(i({},g),{data:{list:g.data}}):g.data&&!Array.isArray(g.data.list)&&(g=i(i({},g),{data:i(i({},g.data),{list:[]})})),[2,f.filterRes(g)]):[2,i(i({},g),{data:{list:[g.data]}})]}})})},"database.addDocument":function(t){var e,n,r;return s(this,void 0,Promise,function(){var o;return a(this,function(s){switch(s.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"POST",data:i({data:Array.isArray(t.data)?t.data:[t.data]},t.transactionId&&{transactionId:t.transactionId})})];case 1:return o=s.sent(),Array.isArray(t.data)?o=i(i({},o),{data:i({ids:(null===(e=o.data)||void 0===e?void 0:e.insertedIds)||[]},o.data)}):(null===(r=null===(n=o.data)||void 0===n?void 0:n.insertedIds)||void 0===r?void 0:r[0])&&(o=i(i({},o),{data:i({_id:o.data.insertedIds[0]},o.data)})),[2,f.filterRes(o)]}})})},"database.updateDocument":function(t){return s(this,void 0,Promise,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"PATCH",data:i({query:t.query,data:t.data,multi:!!t.multi,upsert:!!t.upsert,replaceMode:!!t.replaceMode},t.transactionId&&{transactionId:t.transactionId})})];case 1:return e=n.sent(),[2,f.filterRes(e)]}})})},"database.deleteDocument":function(t){return s(this,void 0,Promise,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/remove"),method:"POST",data:i({query:t.query,multi:!!t.multi},t.transactionId&&{transactionId:t.transactionId})})];case 1:return e=n.sent(),[2,f.filterRes(e)]}})})},"database.countDocument":function(t){return s(this,void 0,Promise,function(){var e,n;return a(this,function(r){switch(r.label){case 0:return e=f.buildQueryParams({count:!0,query:t.query?c.EJSON.stringify(t.query,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(e),method:"GET"})];case 1:return n=r.sent(),[2,f.filterRes(n)]}})})},"database.addCollection":function(t){return s(this,void 0,Promise,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections"),method:"POST",data:{collectionName:t.collectionName}})];case 1:return e=n.sent(),[2,f.filterRes(e)]}})})},"database.aggregate":function(t){var e;return s(this,void 0,Promise,function(){var n,r;return a(this,function(o){switch(o.label){case 0:return n=t.stages.map(function(t){var e,n;try{var r="string"==typeof t.stageValue?JSON.parse(t.stageValue):t.stageValue;return(e={})[t.stageKey]=c.EJSON.serialize(r),e}catch(e){return(n={})[t.stageKey]=t.stageValue,n}}),[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:n}})];case 1:return r=o.sent(),Array.isArray(null===(e=r.data)||void 0===e?void 0:e.list)&&(r.data.list=JSON.stringify(r.data.list.map(function(t){return JSON.stringify(t)}))),[2,f.filterRes(r)]}})})},"database.startTransaction":function(t){return s(this,void 0,void 0,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/transactions"),method:"POST"})];case 1:return e=n.sent(),[2,f.filterRes(f.flattenResData(e))]}})})},"database.commitTransaction":function(t){return s(this,void 0,void 0,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/commit"),method:"POST"})];case 1:return e=n.sent(),[2,f.filterRes(e)]}})})},"database.abortTransaction":function(t){return s(this,void 0,void 0,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/rollback"),method:"POST"})];case 1:return e=n.sent(),[2,f.filterRes(e)]}})})},"database.getInTransaction":function(t){var e;return s(this,void 0,void 0,function(){var n;return a(this,function(r){switch(r.label){case 0:return[4,f["database.queryDocument"].call(this,t)];case 1:return"object"==typeof(n=r.sent()).data&&null!==n.data?(null===(e=n.data)||void 0===e?void 0:e.code)?[2,f.flattenResData(n)]:[2,i(i({},n),{data:JSON.stringify(n.data)})]:[2,n]}})})},"database.updateDocInTransaction":function(t){return s(this,void 0,void 0,function(){var e;return a(this,function(n){switch(n.label){case 0:return t.data=f.safeParseEJSON(t.data),[4,f["database.updateDocument"].call(this,t)];case 1:return e=n.sent(),[2,f.flattenResData(e)]}})})},"database.deleteDocInTransaction":function(t){return s(this,void 0,void 0,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,f["database.deleteDocument"].call(this,t)];case 1:return e=n.sent(),[2,f.flattenResData(e)]}})})},"database.insertDocInTransaction":function(t){var e;return s(this,void 0,Promise,function(){var n,r;return a(this,function(o){switch(o.label){case 0:return t.data=f.safeParseEJSON(t.data),[4,f["database.addDocument"].call(this,t)];case 1:return"object"==typeof(n=o.sent()).data&&null!==n.data?(r=!!(null===(e=n.data)||void 0===e?void 0:e._id),n=i(i(i({},n),{inserted:r?1:0,ok:r?1:0}),n.data)):n=i({inserted:0,ok:0},n),delete n.data,[2,n]}})})},"database.runCommands":function(t){return s(this,void 0,Promise,function(){var e;return a(this,function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(f.getUrlPrefix(t),"/commands"),method:"POST",data:i({commands:c.EJSON.serialize(t.commands)},t.transactionId&&{transactionId:t.transactionId})})];case 1:"object"==typeof(e=n.sent()).data&&null!==e.data&&(delete(e=i(i({},e),e.data)).data,delete e.request_id);try{e=c.EJSON.deserialize(e)}catch(t){}return[2,f.filterRes(e)]}})})}},l={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime,c=function(t){function e(e){return t.call(this,e)||this}return o(e,t),e.prototype.send=function(e,n){return s(this,void 0,void 0,function(){var r;return a(this,function(o){switch(o.label){case 0:return r=null,"GATEWAY"===this.config.endPointMode&&f[e]?[4,f[e].call(this,n)]:[3,2];case 1:return r=o.sent(),[3,4];case 2:return[4,t.prototype.send.call(this,e,n)];case 3:r=o.sent(),o.label=4;case 4:return[2,r]}})})},e}(this.request.constructor);return u.Db.reqClass=c,u.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},u.Db.runtime=r,this.wsClientClass&&(u.Db.wsClass=n.wsClass,u.Db.wsClientClass=this.wsClientClass),u.Db.ws||(u.Db.ws=null),new(function(t){function e(e){return t.call(this,e)||this}return o(e,t),e.prototype.runCommands=function(t){return s(this,void 0,Promise,function(){return a(this,function(e){return[2,u.Db.createRequest(this.config).send("database.runCommands",t)]})})},e}(u.Db))(i(i(i({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(l)}catch(t){}function h(t){try{t.registerComponent(l)}catch(t){console.warn(t)}}e.registerDatabase=h;try{window.registerDatabase=h}catch(t){}},543:(t,e,n)=>{"use strict";n.r(e),n.d(e,{CollectionReference:()=>zt,Db:()=>ge,DocumentReference:()=>Rt,Query:()=>Ft});var r,o,i={};n.r(i),n.d(i,{LineString:()=>K,MultiLineString:()=>nt,MultiPoint:()=>tt,MultiPolygon:()=>ot,Point:()=>Z,Polygon:()=>X}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,u="Object",c="GeoPoint",f="GeoLineString",l="GeoPolygon",h="GeoMultiPoint",d="GeoMultiLineString",p="GeoMultiPolygon",y="Date",g="ServerDate",m=["desc","asc"],b=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={})),(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(a||(a={}));var w,v=(w=function(t,e){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},w(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}w(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),_=[],O={},E=function(t){function e(e,n){if(n!==O)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return v(e,t),e.for=function(t){for(var n=0,r=_.length;n<r;n++)if(_[n].target===t)return _[n].instance;var o=new e(t,O);return _.push({target:t,instance:o}),o},e}(function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})});const S=E;var N=S.for("UNSET_FIELD_NAME"),I=S.for("UPDATE_COMMAND"),T=S.for("QUERY_COMMAND"),B=S.for("LOGIC_COMMAND"),x=S.for("GEO_POINT"),L=S.for("SYMBOL_GEO_LINE_STRING"),$=S.for("SYMBOL_GEO_POLYGON"),A=S.for("SYMBOL_GEO_MULTI_POINT"),U=S.for("SYMBOL_GEO_MULTI_LINE_STRING"),P=S.for("SYMBOL_GEO_MULTI_POLYGON"),j=S.for("SERVER_DATE"),R=S.for("REGEXP"),D=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!1,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function q(t){return new D(t)}var C,F=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},M=function(){function t(){}return t.formatResDocumentData=function(e){return e.map(function(e){return t.formatField(e)})},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach(function(n){var o,i=e[n];switch(t.whichType(i)){case c:o=new Z(i.coordinates[0],i.coordinates[1]);break;case f:o=new K(i.coordinates.map(function(t){return new Z(t[0],t[1])}));break;case l:o=new X(i.coordinates.map(function(t){return new K(t.map(function(t){var e=F(t,2),n=e[0],r=e[1];return new Z(n,r)}))}));break;case h:o=new tt(i.coordinates.map(function(t){return new Z(t[0],t[1])}));break;case d:o=new nt(i.coordinates.map(function(t){return new K(t.map(function(t){var e=F(t,2),n=e[0],r=e[1];return new Z(n,r)}))}));break;case p:o=new ot(i.coordinates.map(function(t){return new X(t.map(function(t){return new K(t.map(function(t){var e=F(t,2),n=e[0],r=e[1];return new Z(n,r)}))}))}));break;case y:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=t.formatField(i);break;case g:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o}),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===y)return"BsonDate";if(e===u){if(t instanceof Z)return c;if(t instanceof Date)return y;if(t instanceof D)return g;t.$timestamp?e=y:t.$date?e=g:Z.validate(t)?e=c:K.validate(t)?e=f:X.validate(t)?e=l:tt.validate(t)?e=h:nt.validate(t)?e=d:ot.validate(t)&&(e=p)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),J=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==M.whichType(e))throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===m.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===b.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t}(),k=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},V=function(t){return"object"===k(t)},z=function(t){return"number"===k(t)},H=function(t){return Array.isArray(t)},Y=function(t){return"date"===k(t)},G=function(t){return"regexp"===k(t)},W=function(t){return t&&t._internalType instanceof E},Z=function(){function t(t,e){J.isGeopoint("longitude",t),J.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},t.validate=function(t){return"Point"===t.type&&H(t.coordinates)&&J.isGeopoint("longitude",t.coordinates[0])&&J.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),t}(),K=function(){function t(t){if(!H(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach(function(t){if(!(t instanceof Z))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))}),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map(function(t){return t.toJSON().coordinates})},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map(function(t){return t.toJSON().coordinates})}},t.validate=function(t){var e,n;if("LineString"!==t.type||!H(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!z(i[0])||!z(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),t}(),Q=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},X=function(){function t(t){if(!H(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach(function(t){if(!(t instanceof K))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"));if(!K.isClosed(t))throw new Error("LineString ".concat(t.points.map(function(t){return t.toReadableString()})," is not a closed cycle"))}),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!H(t.coordinates))return!1;try{for(var i=Q(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(r=void 0,Q(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!z(f[0])||!z(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!1,configurable:!0}),t}(),tt=function(){function t(t){if(!H(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach(function(t){if(!(t instanceof Z))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))}),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map(function(t){return t.toJSON().coordinates})},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map(function(t){return t.toJSON().coordinates})}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!H(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!z(i[0])||!z(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return A},enumerable:!1,configurable:!0}),t}(),et=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nt=function(){function t(t){if(!H(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach(function(t){if(!(t instanceof K))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"))}),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!H(t.coordinates))return!1;try{for(var i=et(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(r=void 0,et(a)),c=u.next();!c.done;c=u.next()){var f=c.value;if(!z(f[0])||!z(f[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!1,configurable:!0}),t}(),rt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ot=function(){function t(t){var e,n;if(!H(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=rt(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof X))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map(function(t){return t.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})})},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map(function(t){return t.lines.map(function(t){return t.points.map(function(t){return[t.longitude,t.latitude]})})})}},t.validate=function(t){var e,n,r,o,i,s;if("MultiPolygon"!==t.type||!H(t.coordinates))return!1;try{for(var a=rt(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var f=(r=void 0,rt(c)),l=f.next();!l.done;l=f.next()){var h=l.value;try{for(var d=(i=void 0,rt(h)),p=d.next();!p.done;p=d.next()){var y=p.value;if(!z(y[0])||!z(y[1]))return!1}}catch(t){i={error:t}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return $},enumerable:!1,configurable:!0}),t}(),it=function(){var t=function(){};if(!Promise){t.promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise(function(e,n){t=function(t,r){return t?n(t):e(r)}});return t.promise=n,t};!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(C||(C={}));var st,at=function(){function t(t,e,n){this._internalType=I,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ut(t){return t&&t instanceof at&&t._internalType===I}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ct=function(){function t(t,e,n){if(this._internalType=B,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||N,this.fieldName!==N)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(ft(i=e[r])||pt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(ft(i=e)||pt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map(function(n){return n instanceof t?n._setFieldName(e):n});return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(st.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(st.OR,r,this.fieldName)},t}();function ft(t){return t&&t instanceof ct&&t._internalType===B}var lt,ht=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(lt||(lt={}));var dt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=T,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case lt.IN:case lt.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(lt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(lt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(lt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(lt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(lt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(lt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(lt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(lt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof Z))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof t.geometry));if(void 0!==t.maxDistance&&!z(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof t.maxDistance));if(void 0!==t.minDistance&&!z(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof t.minDistance));var n=new e(lt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof X))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(lt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof Z||t.geometry instanceof K||t.geometry instanceof X||t.geometry instanceof tt||t.geometry instanceof nt||t.geometry instanceof ot))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(lt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(ct);function pt(t){return t&&t instanceof dt&&t._internalType===T}function yt(t){return pt(t)}var gt={};for(var mt in lt)gt[mt]="$"+mt;for(var mt in st)gt[mt]="$"+mt;for(var mt in C)gt[mt]="$"+mt;function bt(t){return gt[t]||"$"+t}gt[lt.NEQ]="$ne",gt[C.REMOVE]="$unset",gt[C.SHIFT]="$pop",gt[C.UNSHIFT]="$push";var wt=function(){return wt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},wt.apply(this,arguments)},vt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},_t=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Ot(t){return Et(t,[t])}function Et(t,e){if(!W(t)){if(Y(t))return{$date:+t};if(G(t))return{$regex:t.source,$options:t.flags};if(H(t))return t.map(function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return Et(t,_t(_t([],vt(e),!1),[t],!1))});if(V(t)){var n=wt({},t);for(var r in n){if(e.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=Et(n[r],_t(_t([],vt(e),!1),[n[r]],!1))}return n}return t}switch(t._internalType){case x:return t.toJSON();case j:case R:return t.parse();default:return t.toJSON?t.toJSON():t}}var St=function(){return St=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},St.apply(this,arguments)},Nt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},It=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Tt(t,e,n,r){var o=St({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&V(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Tt(s,e,It(It([],Nt(n),!1),[i],!1),It(It([],Nt(r),!1),[s],!1));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o["".concat(i,".").concat(c)]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Bt(t){return Tt(t,Lt,[],[t])}function xt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?H(t[r])?t[r].push(e[r]):V(t[r])?V(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is ".concat(k(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(k(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]}function Lt(t){return W(t)||Y(t)||G(t)}function $t(t){return Ot(t)}var At=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ut(t)?this.encodeUpdateCommand(t):"object"===k(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case C.PUSH:case C.PULL:case C.PULL_ALL:case C.POP:case C.SHIFT:case C.UNSHIFT:case C.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=bt(t.operator);return t.operator===C.REMOVE?((e={})[i]=((n={})[t.fieldName]="",n),e):((r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,s,a,u,c,f,l=bt(t.operator);switch(t.operator){case C.PUSH:var h=void 0;return h=H(t.operands)?{$each:t.operands.map($t)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case C.UNSHIFT:return h={$each:t.operands.map($t),$position:0},(r={})[l]=((o={})[t.fieldName]=h,o),r;case C.POP:return(i={})[l]=((s={})[t.fieldName]=1,s),i;case C.SHIFT:return(a={})[l]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[l]=((f={})[t.fieldName]=$t(t.operands),f),c}},t.prototype.encodeUpdateObject=function(t){var e=Bt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ut(r))e[n]=r._setFieldName(n),xt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=$t(r);var o=new at(C.SET,[r],n);xt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Ut={};function Pt(t){if(!ge.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Ut[e]||(Ut[e]=new ge.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:ge.createRequest(t.config)}}})),Ut[e]}var jt=function(){return jt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},jt.apply(this,arguments)},Rt=function(){function t(t,e,n,r){void 0===r&&(r={});var o=this;this.watch=function(t){return Pt(o._db).watch(jt(jt({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=ge.createRequest(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||it();var n=Array.isArray(t),r={collectionName:this._coll,data:n?t.map(function(t){return Ot(t)}):Ot(t)};return!n&&this.id&&(r._id=this.id),this.request.send("database.addDocument",r).then(function(t){var r;t.code?e(0,t):e(0,n?{ids:(null===(r=t.data)||void 0===r?void 0:r.insertedIds)||[],requestId:t.requestId}:{id:t.data._id,requestId:t.requestId})}).catch(function(t){e(t)}),e.promise},t.prototype.set=function(t,e){if(e=e||it(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof at?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Ot(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then(function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})}).catch(function(t){e(t)}),e.promise},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:At.encode(t),query:n,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then(function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})}).catch(function(t){e(t)}),e.promise},t.prototype.remove=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then(function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})}).catch(function(e){t(e)}),t.promise},t.prototype.get=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then(function(e){if(e.code)t(0,e);else{var n=M.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId})}}).catch(function(e){t(e)}),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),Dt=function(){function t(){}return t.encode=function(t){return(new qt).encodeQuery(t)},t}(),qt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Lt(t)?ft(t)?this.encodeLogicCommand(t):pt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):V(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,s,a,u=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var c=bt(t.operator),f=t.operands.map(function(e){return u.encodeQuery(e,t.fieldName)});return(e={})[c]=f,e;case st.NOT:c=bt(t.operator);var l=t.operands[0];return G(l)?((n={})[t.fieldName]=((r={})[c]=this.encodeRegExp(l),r),n):(f=this.encodeQuery(l)[t.fieldName],(o={})[t.fieldName]=((i={})[c]=f,i),o);default:if(c=bt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}return f=t.operands.map(this.encodeQuery.bind(this)),(a={})[c]=f,a}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,u,c;if(t.fieldName===N)throw new Error("Cannot encode a comparison command with unset field name");var f=bt(t.operator);switch(t.operator){case lt.EQ:case lt.NEQ:case lt.LT:case lt.LTE:case lt.GT:case lt.GTE:case lt.ELEM_MATCH:case lt.EXISTS:case lt.SIZE:case lt.MOD:return(e={})[t.fieldName]=((n={})[f]=$t(t.operands[0]),n),e;case lt.IN:case lt.NIN:case lt.ALL:return(r={})[t.fieldName]=((o={})[f]=$t(t.operands),o),r;case lt.GEO_NEAR:var l=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},i;case lt.GEO_WITHIN:return l=t.operands[0],(s={})[t.fieldName]={$geoWithin:{$geometry:l.geometry.toJSON()}},s;case lt.GEO_INTERSECTS:return l=t.operands[0],(a={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[f]=$t(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=Bt(t);for(var n in e){var r=e[n];if(ft(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else yt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Lt(r)&&(e[n]=$t(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?H(t[r])?t[r]=t[r].concat(e[r]):V(t[r])?V(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is ".concat(k(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(k(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),Ct=function(){return Ct=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ct.apply(this,arguments)},Ft=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Pt(i._db).watch(Ct(Ct({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce(function(t,e){return t[e.field]=e.direction,t},{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=ge.createRequest(this._db.config)}return t.prototype.get=function(t){t=t||it();var e=[];this._fieldOrders&&this._fieldOrders.forEach(function(t){e.push(t)});var n={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then(function(e){if(e.code)t(0,e);else{var n={data:M.formatResDocumentData(e.data.list),requestId:e.requestId};void 0!==e.total&&(n.total=e.total),void 0!==e.limit&&(n.limit=e.limit),void 0!==e.offset&&(n.offset=e.offset),t(0,n)}}).catch(function(e){t(e)}),t.promise},t.prototype.count=function(t){t=t||it();var e={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then(function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})}).catch(function(e){t(e)}),t.promise},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some(function(t){return void 0!==e[t]});if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Dt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){J.isFieldPath(e),J.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){J.isInteger("limit",e);var n=Ct({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){J.isInteger("offset",e);var n=Ct({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:At.encode(t)};return this._request.send("database.updateDocument",n).then(function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})}).catch(function(t){e(t)}),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=Ct({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||it(),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 e={collectionName:this._coll,query:Dt.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then(function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})}).catch(function(e){t(e)}),t.promise},t}(),Mt=n(804),Jt=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=ge.createRequest(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,function(e){switch(e.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(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(Mt.EJSON.parse)}]:[2,t]}})},new((n=void 0)||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}u((r=r.apply(t,e||[])).next())});var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map(function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e})},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$".concat(t),stageValue:JSON.stringify(e)}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=Dt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new Z(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",Dt.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}();const kt=Jt;var Vt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),zt=function(t){function e(e,n){return t.call(this,e,n)||this}return Vt(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new Rt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new Rt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new kt(this._db,this._coll)},e}(Ft),Ht={eq:function(t){return new dt(lt.EQ,[t])},neq:function(t){return new dt(lt.NEQ,[t])},lt:function(t){return new dt(lt.LT,[t])},lte:function(t){return new dt(lt.LTE,[t])},gt:function(t){return new dt(lt.GT,[t])},gte:function(t){return new dt(lt.GTE,[t])},in:function(t){return new dt(lt.IN,t)},nin:function(t){return new dt(lt.NIN,t)},all:function(t){return new dt(lt.ALL,t)},elemMatch:function(t){return new dt(lt.ELEM_MATCH,[t])},exists:function(t){return new dt(lt.EXISTS,[t])},size:function(t){return new dt(lt.SIZE,[t])},mod:function(t){return new dt(lt.MOD,[t])},geoNear:function(t){return new dt(lt.GEO_NEAR,[t])},geoWithin:function(t){return new dt(lt.GEO_WITHIN,[t])},geoIntersects:function(t){return new dt(lt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOT,n)},set:function(t){return new at(C.SET,[t])},remove:function(){return new at(C.REMOVE,[])},inc:function(t){return new at(C.INC,[t])},mul:function(t){return new at(C.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(V(e[0])&&e[0].hasOwnProperty("each")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=H(e[0])?e[0]:Array.from(e);return new at(C.PUSH,t)},pull:function(t){return new at(C.PULL,t)},pullAll:function(t){return new at(C.PULL_ALL,t)},pop:function(){return new at(C.POP,[])},shift:function(){return new at(C.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=H(arguments[0])?arguments[0]:Array.from(arguments);return new at(C.UNSHIFT,n)},addToSet:function(t){return new at(C.ADD_TO_SET,t)},rename:function(t){return new at(C.RENAME,[t])},bit:function(t){return new at(C.BIT,[t])},max:function(t){return new at(C.MAX,[t])},min:function(t){return new at(C.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===k(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new kt},abs:function(t){return new Yt("abs",t)},add:function(t){return new Yt("add",t)},ceil:function(t){return new Yt("ceil",t)},divide:function(t){return new Yt("divide",t)},exp:function(t){return new Yt("exp",t)},floor:function(t){return new Yt("floor",t)},ln:function(t){return new Yt("ln",t)},log:function(t){return new Yt("log",t)},log10:function(t){return new Yt("log10",t)},mod:function(t){return new Yt("mod",t)},multiply:function(t){return new Yt("multiply",t)},pow:function(t){return new Yt("pow",t)},sqrt:function(t){return new Yt("sqrt",t)},subtract:function(t){return new Yt("subtract",t)},trunc:function(t){return new Yt("trunc",t)},arrayElemAt:function(t){return new Yt("arrayElemAt",t)},arrayToObject:function(t){return new Yt("arrayToObject",t)},concatArrays:function(t){return new Yt("concatArrays",t)},filter:function(t){return new Yt("filter",t)},in:function(t){return new Yt("in",t)},indexOfArray:function(t){return new Yt("indexOfArray",t)},isArray:function(t){return new Yt("isArray",t)},map:function(t){return new Yt("map",t)},range:function(t){return new Yt("range",t)},reduce:function(t){return new Yt("reduce",t)},reverseArray:function(t){return new Yt("reverseArray",t)},size:function(t){return new Yt("size",t)},slice:function(t){return new Yt("slice",t)},zip:function(t){return new Yt("zip",t)},and:function(t){return new Yt("and",t)},not:function(t){return new Yt("not",t)},or:function(t){return new Yt("or",t)},cmp:function(t){return new Yt("cmp",t)},eq:function(t){return new Yt("eq",t)},gt:function(t){return new Yt("gt",t)},gte:function(t){return new Yt("gte",t)},lt:function(t){return new Yt("lt",t)},lte:function(t){return new Yt("lte",t)},neq:function(t){return new Yt("ne",t)},cond:function(t){return new Yt("cond",t)},ifNull:function(t){return new Yt("ifNull",t)},switch:function(t){return new Yt("switch",t)},dateFromParts:function(t){return new Yt("dateFromParts",t)},dateFromString:function(t){return new Yt("dateFromString",t)},dayOfMonth:function(t){return new Yt("dayOfMonth",t)},dayOfWeek:function(t){return new Yt("dayOfWeek",t)},dayOfYear:function(t){return new Yt("dayOfYear",t)},isoDayOfWeek:function(t){return new Yt("isoDayOfWeek",t)},isoWeek:function(t){return new Yt("isoWeek",t)},isoWeekYear:function(t){return new Yt("isoWeekYear",t)},millisecond:function(t){return new Yt("millisecond",t)},minute:function(t){return new Yt("minute",t)},month:function(t){return new Yt("month",t)},second:function(t){return new Yt("second",t)},hour:function(t){return new Yt("hour",t)},week:function(t){return new Yt("week",t)},year:function(t){return new Yt("year",t)},literal:function(t){return new Yt("literal",t)},mergeObjects:function(t){return new Yt("mergeObjects",t)},objectToArray:function(t){return new Yt("objectToArray",t)},allElementsTrue:function(t){return new Yt("allElementsTrue",t)},anyElementTrue:function(t){return new Yt("anyElementTrue",t)},setDifference:function(t){return new Yt("setDifference",t)},setEquals:function(t){return new Yt("setEquals",t)},setIntersection:function(t){return new Yt("setIntersection",t)},setIsSubset:function(t){return new Yt("setIsSubset",t)},setUnion:function(t){return new Yt("setUnion",t)},concat:function(t){return new Yt("concat",t)},dateToString:function(t){return new Yt("dateToString",t)},indexOfBytes:function(t){return new Yt("indexOfBytes",t)},indexOfCP:function(t){return new Yt("indexOfCP",t)},split:function(t){return new Yt("split",t)},strLenBytes:function(t){return new Yt("strLenBytes",t)},strLenCP:function(t){return new Yt("strLenCP",t)},strcasecmp:function(t){return new Yt("strcasecmp",t)},substr:function(t){return new Yt("substr",t)},substrBytes:function(t){return new Yt("substrBytes",t)},substrCP:function(t){return new Yt("substrCP",t)},toLower:function(t){return new Yt("toLower",t)},toUpper:function(t){return new Yt("toUpper",t)},meta:function(t){return new Yt("meta",t)},addToSet:function(t){return new Yt("addToSet",t)},avg:function(t){return new Yt("avg",t)},first:function(t){return new Yt("first",t)},last:function(t){return new Yt("last",t)},max:function(t){return new Yt("max",t)},min:function(t){return new Yt("min",t)},push:function(t){return new Yt("push",t)},stdDevPop:function(t){return new Yt("stdDevPop",t)},stdDevSamp:function(t){return new Yt("stdDevSamp",t)},sum:function(t){return new Yt("sum",t)},let:function(t){return new Yt("let",t)}},project:{slice:function(t){return new Gt("slice",t)},elemMatch:function(t){return new Gt("elemMatch",t)}}},Yt=function(t,e){this["$"+t]=e},Gt=function(t,e){this["$"+t]=e},Wt=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!1,configurable:!0}),t}();function Zt(t){return new Wt(t)}var Kt="insert document failed",Qt="DATABASE_TRANSACTION_CONFLICT",Xt=function(){return Xt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Xt.apply(this,arguments)},te=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}u((r=r.apply(t,e||[])).next())})},ee=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ne="database.updateDocInTransaction",re=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return te(this,void 0,void 0,function(){var e,n,r,o;return ee(this,function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:Mt.EJSON.stringify(Ot(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=Mt.EJSON.parse(n.inserted),1==(o=Mt.EJSON.parse(n.ok))&&1==r)return[2,Xt(Xt({},n),{ok:o,inserted:r})];throw new Error(Kt)}})})},t.prototype.get=function(){return te(this,void 0,void 0,function(){var t,e;return ee(this,function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?M.formatField(Mt.EJSON.parse(e.data)):Mt.EJSON.parse(e.data),requestId:e.requestId}]}})})},t.prototype.set=function(t){return te(this,void 0,void 0,function(){var e,n;return ee(this,function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Mt.EJSON.stringify(Ot(t),{relaxed:!1}),upsert:!0},[4,this._request.send(ne,e)];case 1:if((n=r.sent()).code)throw n;return[2,Xt(Xt({},n),{updated:Mt.EJSON.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}})})},t.prototype.update=function(t){return te(this,void 0,void 0,function(){var e,n;return ee(this,function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Mt.EJSON.stringify(At.encode(t),{relaxed:!1})},[4,this._request.send(ne,e)];case 1:if((n=r.sent()).code)throw n;return[2,Xt(Xt({},n),{updated:Mt.EJSON.parse(n.updated)})]}})})},t.prototype.delete=function(){return te(this,void 0,void 0,function(){var t,e;return ee(this,function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,Xt(Xt({},e),{deleted:Mt.EJSON.parse(e.deleted)})]}})})},t}(),oe=function(){return oe=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},oe.apply(this,arguments)},ie=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}u((r=r.apply(t,e||[])).next())})},se=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ae="database.getInTransaction",ue=function(){function t(t,e,n,r,o){this._coll=e,this._transaction=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some(function(t){return void 0!==e[t]});if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._transaction,this._coll,Dt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){J.isFieldPath(e),J.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._transaction,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){J.isInteger("limit",e);var n=oe({},this._queryOptions);return n.limit=e,new t(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){J.isInteger("offset",e);var n=oe({},this._queryOptions);return n.offset=e,new t(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=oe({},this._queryOptions);return r.projection=e,new t(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.get=function(){return ie(this,void 0,void 0,function(){var t,e,n,r,o,i;return se(this,function(s){switch(s.label){case 0:return t=[],this._fieldOrders&&this._fieldOrders.forEach(function(e){t.push(e)}),e={collectionName:this._coll,transactionId:this._transactionId},this._fieldFilters&&(e.query=this._fieldFilters),t.length>0&&(e.order=t),this._queryOptions.offset&&(e.offset=this._queryOptions.offset),this._queryOptions.limit?e.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:e.limit=100,this._queryOptions.projection&&(e.projection=this._queryOptions.projection),[4,this._request.send(ae,e)];case 1:if((n=s.sent()).code)throw n;return r="null"!==n.data?Mt.EJSON.parse(n.data):null,o=r?Array.isArray(r)?M.formatResDocumentData(r):[M.formatField(r)]:[],i={data:o,requestId:n.requestId},void 0!==n.total&&(i.total=n.total),void 0!==n.limit&&(i.limit=n.limit),void 0!==n.offset&&(i.offset=n.offset),[2,i]}})})},t.prototype.count=function(){return ie(this,void 0,void 0,function(){var t,e,n,r;return se(this,function(o){switch(o.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId},this._fieldFilters&&(t.query=this._fieldFilters),[4,this._request.send(ae,t)];case 1:if((e=o.sent()).code)throw e;return n="null"!==e.data?Mt.EJSON.parse(e.data):null,r=Array.isArray(n)?n.length:n?1:0,[2,{requestId:e.requestId,total:void 0!==e.total?e.total:r}]}})})},t.prototype.update=function(t){return ie(this,void 0,void 0,function(){var e,n;return se(this,function(r){switch(r.label){case 0:if(!t||"object"!=typeof t)throw new Error("参数必需是非空对象");if(t.hasOwnProperty("_id"))throw new Error("不能更新_id的值");return e={collectionName:this._coll,transactionId:this._transactionId,query:this._fieldFilters,data:Mt.EJSON.stringify(At.encode(t),{relaxed:!1})},[4,this._request.send("database.updateDocInTransaction",e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Mt.EJSON.parse(n.updated)})]}})})},t.prototype.remove=function(){return ie(this,void 0,void 0,function(){var t,e;return se(this,function(n){switch(n.label){case 0:return 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"),t={collectionName:this._coll,transactionId:this._transactionId,query:this._fieldFilters},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,oe(oe({},e),{deleted:Mt.EJSON.parse(e.deleted)})]}})})},t}(),ce=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),fe=function(t){function e(e,n){return t.call(this,e,n)||this}return ce(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new re(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new re(this._transaction,this._coll,e).create(t)},e}(ue),le=function(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}u((r=r.apply(t,e||[])).next())})},he=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},de=function(){function t(t){this._db=t,this._request=ge.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return le(this,void 0,void 0,function(){var t;return he(this,function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}})})},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new fe(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return le(this,void 0,void 0,function(){var t,e;return he(this,function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}})})},t.prototype.rollback=function(t){return le(this,void 0,void 0,function(){var e,n;return he(this,function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}})})},t}();function pe(){return le(this,void 0,void 0,function(){var t;return he(this,function(e){switch(e.label){case 0:return[4,(t=new de(this)).init()];case 1:return e.sent(),[2,t]}})})}function ye(t,e){return void 0===e&&(e=3),le(this,void 0,void 0,function(){var n,r,o,i,s=this;return he(this,function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new de(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return le(s,void 0,void 0,function(){return he(this,function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}})})},e<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===Qt?[4,ye.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}})})}var ge=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=q,this.command=Ht,this.RegExp=Zt,this.startTransaction=pe,this.runTransaction=ye,this.logicCommand=ct,this.updateCommand=at,this.queryCommand=dt}return t.createRequest=function(e){var n=new t.reqClass(e),r=n.send;return n.send=function(t,n){return e.instance&&(n.instance=e.instance),e.database&&(n.database=e.database),r.call(this,t,n)},n},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new zt(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return t.createRequest(this.config).send("database.addCollection",n)},t}()},273:()=>{},804:(t,e,n)=>{"use strict";n.r(e),n.d(e,{BSON:()=>ze,BSONError:()=>k,BSONOffsetError:()=>H,BSONRegExp:()=>Yt,BSONRuntimeError:()=>z,BSONSymbol:()=>Gt,BSONType:()=>J,BSONValue:()=>rt,BSONVersionError:()=>V,Binary:()=>ut,Code:()=>dt,DBRef:()=>yt,Decimal128:()=>Dt,Double:()=>qt,EJSON:()=>Ue,Int32:()=>Ct,Long:()=>St,MaxKey:()=>Ft,MinKey:()=>Mt,ObjectId:()=>Vt,Timestamp:()=>Zt,UUID:()=>ht,calculateObjectSize:()=>ke,deserialize:()=>Je,deserializeStream:()=>Ve,onDemand:()=>Re,serialize:()=>Fe,serializeWithBufferAndIndex:()=>Me,setInternalBufferSize:()=>Ce});var r=n(273);const o=(()=>{const t=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return e=>t.call(e)})();function i(t){return"Uint8Array"===o(t)}function s(t){return"object"==typeof t&&null!=t&&Symbol.toStringTag in t&&("ArrayBuffer"===t[Symbol.toStringTag]||"SharedArrayBuffer"===t[Symbol.toStringTag])}function a(t){return t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)}function u(t){return"object"==typeof t&&null!=t&&Symbol.toStringTag in t&&"Map"===t[Symbol.toStringTag]}function c(t){return t instanceof Date||"[object Date]"===Object.prototype.toString.call(t)}function f(t,e){return JSON.stringify(t,(t,e)=>"bigint"==typeof e?{$numberLong:`${e}`}:u(e)?Object.fromEntries(e):e)}const l=6,h=Symbol.for("@@mdb.bson.version"),d=2147483647,p=-2147483648,y=Math.pow(2,63)-1,g=-Math.pow(2,63),m=Math.pow(2,53),b=-Math.pow(2,53),w=1,v=2,_=3,O=4,E=5,S=6,N=7,I=8,T=9,B=10,x=11,L=12,$=13,A=14,U=15,P=16,j=17,R=18,D=19,q=255,C=127,F=0,M=4,J=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127});class k extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,e){super(t,e)}static isBSONError(t){return null!=t&&"object"==typeof t&&"bsonError"in t&&!0===t.bsonError&&"name"in t&&"message"in t&&"stack"in t}}class V extends k{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${l}.x.x`)}}class z extends k{get name(){return"BSONRuntimeError"}constructor(t){super(t)}}class H extends k{get name(){return"BSONOffsetError"}constructor(t,e,n){super(`${t}. offset: ${e}`,n),this.offset=e}}let Y,G;function W(t,e,n,r){if(r){Y??=new TextDecoder("utf8",{fatal:!0});try{return Y.decode(t.subarray(e,n))}catch(t){throw new k("Invalid UTF-8 string in BSON document",{cause:t})}}return G??=new TextDecoder("utf8",{fatal:!1}),G.decode(t.subarray(e,n))}function Z(t,e,n){if(0===t.length)return"";const r=n-e;if(0===r)return"";if(r>20)return null;if(1===r&&t[e]<128)return String.fromCharCode(t[e]);if(2===r&&t[e]<128&&t[e+1]<128)return String.fromCharCode(t[e])+String.fromCharCode(t[e+1]);if(3===r&&t[e]<128&&t[e+1]<128&&t[e+2]<128)return String.fromCharCode(t[e])+String.fromCharCode(t[e+1])+String.fromCharCode(t[e+2]);const o=[];for(let r=e;r<n;r++){const e=t[r];if(e>127)return null;o.push(e)}return String.fromCharCode(...o)}const K={toLocalBufferType(t){if(Buffer.isBuffer(t))return t;if(ArrayBuffer.isView(t))return Buffer.from(t.buffer,t.byteOffset,t.byteLength);const e=t?.[Symbol.toStringTag]??Object.prototype.toString.call(t);if("ArrayBuffer"===e||"SharedArrayBuffer"===e||"[object ArrayBuffer]"===e||"[object SharedArrayBuffer]"===e)return Buffer.from(t);throw new k("Cannot create Buffer from the passed potentialBuffer.")},allocate:t=>Buffer.alloc(t),allocateUnsafe:t=>Buffer.allocUnsafe(t),equals:(t,e)=>K.toLocalBufferType(t).equals(e),fromNumberArray:t=>Buffer.from(t),fromBase64:t=>Buffer.from(t,"base64"),toBase64:t=>K.toLocalBufferType(t).toString("base64"),fromISO88591:t=>Buffer.from(t,"binary"),toISO88591:t=>K.toLocalBufferType(t).toString("binary"),fromHex:t=>Buffer.from(t,"hex"),toHex:t=>K.toLocalBufferType(t).toString("hex"),toUTF8(t,e,n,r){const o=n-e<=20?Z(t,e,n):null;if(null!=o)return o;const i=K.toLocalBufferType(t).toString("utf8",e,n);if(r)for(let r=0;r<i.length;r++)if(65533===i.charCodeAt(r)){W(t,e,n,!0);break}return i},utf8ByteLength:t=>Buffer.byteLength(t,"utf8"),encodeUTF8Into(t,e,n){const r=function(t,e,n){if(0===e.length)return 0;if(e.length>25)return null;if(t.length-n<e.length)return null;for(let r=0,o=n;r<e.length;r++,o++){const n=e.charCodeAt(r);if(n>127)return null;t[o]=n}return e.length}(t,e,n);return null!=r?r:K.toLocalBufferType(t).write(e,n,void 0,"utf8")},randomBytes:r.randomBytes,swap32:t=>K.toLocalBufferType(t).swap32()};function Q(t){if(t<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${t}`);return et.fromNumberArray(Array.from({length:t},()=>Math.floor(256*Math.random())))}const X=(()=>{const{crypto:t}=globalThis;if(null!=t&&"function"==typeof t.getRandomValues)return e=>t.getRandomValues(et.allocate(e));if(function(){const{navigator:t}=globalThis;return"object"==typeof t&&"ReactNative"===t.product}()){const{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return Q})(),tt=/(\d|[a-f])/i,et={toLocalBufferType(t){const e=t?.[Symbol.toStringTag]??Object.prototype.toString.call(t);if("Uint8Array"===e)return t;if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength));if("ArrayBuffer"===e||"SharedArrayBuffer"===e||"[object ArrayBuffer]"===e||"[object SharedArrayBuffer]"===e)return new Uint8Array(t);throw new k("Cannot make a Uint8Array from passed potentialBuffer.")},allocate(t){if("number"!=typeof t)throw new TypeError(`The "size" argument must be of type number. Received ${String(t)}`);return new Uint8Array(t)},allocateUnsafe:t=>et.allocate(t),equals(t,e){if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.byteLength;n++)if(t[n]!==e[n])return!1;return!0},fromNumberArray:t=>Uint8Array.from(t),fromBase64:t=>Uint8Array.from(atob(t),t=>t.charCodeAt(0)),toBase64:t=>btoa(et.toISO88591(t)),fromISO88591:t=>Uint8Array.from(t,t=>255&t.charCodeAt(0)),toISO88591:t=>Array.from(Uint16Array.from(t),t=>String.fromCharCode(t)).join(""),fromHex(t){const e=t.length%2==0?t:t.slice(0,t.length-1),n=[];for(let t=0;t<e.length;t+=2){const r=e[t],o=e[t+1];if(!tt.test(r))break;if(!tt.test(o))break;const i=Number.parseInt(`${r}${o}`,16);n.push(i)}return Uint8Array.from(n)},toHex:t=>Array.from(t,t=>t.toString(16).padStart(2,"0")).join(""),toUTF8(t,e,n,r){const o=n-e<=20?Z(t,e,n):null;return null!=o?o:W(t,e,n,r)},utf8ByteLength:t=>(new TextEncoder).encode(t).byteLength,encodeUTF8Into(t,e,n){const r=(new TextEncoder).encode(e);return t.set(r,n),r.byteLength},randomBytes:X,swap32(t){if(t.length%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t.length;e+=4){const n=t[e],r=t[e+1],o=t[e+2],i=t[e+3];t[e]=i,t[e+1]=o,t[e+2]=r,t[e+3]=n}return t}},nt="function"==typeof Buffer&&!0!==Buffer.prototype?._isBuffer?K:et;class rt{get[h](){return l}[Symbol.for("nodejs.util.inspect.custom")](t,e,n){return this.inspect(t,e,n)}}const ot=new Float64Array(1),it=new Uint8Array(ot.buffer,0,8);ot[0]=-1;const st=0===it[7],at={isBigEndian:st,getNonnegativeInt32LE(t,e){if(t[e+3]>127)throw new RangeError(`Size cannot be negative at offset: ${e}`);return t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24},getInt32LE:(t,e)=>t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,getUint32LE:(t,e)=>t[e]+256*t[e+1]+65536*t[e+2]+16777216*t[e+3],getUint32BE:(t,e)=>t[e+3]+256*t[e+2]+65536*t[e+1]+16777216*t[e],getBigInt64LE(t,e){const n=BigInt(t[e+4]+256*t[e+5]+65536*t[e+6]+(t[e+7]<<24)),r=BigInt(t[e]+256*t[e+1]+65536*t[e+2]+16777216*t[e+3]);return(n<<BigInt(32))+r},getFloat64LE:st?(t,e)=>(it[7]=t[e],it[6]=t[e+1],it[5]=t[e+2],it[4]=t[e+3],it[3]=t[e+4],it[2]=t[e+5],it[1]=t[e+6],it[0]=t[e+7],ot[0]):(t,e)=>(it[0]=t[e],it[1]=t[e+1],it[2]=t[e+2],it[3]=t[e+3],it[4]=t[e+4],it[5]=t[e+5],it[6]=t[e+6],it[7]=t[e+7],ot[0]),setInt32BE:(t,e,n)=>(t[e+3]=n,n>>>=8,t[e+2]=n,n>>>=8,t[e+1]=n,n>>>=8,t[e]=n,4),setInt32LE:(t,e,n)=>(t[e]=n,n>>>=8,t[e+1]=n,n>>>=8,t[e+2]=n,n>>>=8,t[e+3]=n,4),setBigInt64LE(t,e,n){const r=BigInt(4294967295);let o=Number(n&r);t[e]=o,o>>=8,t[e+1]=o,o>>=8,t[e+2]=o,o>>=8,t[e+3]=o;let i=Number(n>>BigInt(32)&r);return t[e+4]=i,i>>=8,t[e+5]=i,i>>=8,t[e+6]=i,i>>=8,t[e+7]=i,8},setFloat64LE:st?(t,e,n)=>(ot[0]=n,t[e]=it[7],t[e+1]=it[6],t[e+2]=it[5],t[e+3]=it[4],t[e+4]=it[3],t[e+5]=it[2],t[e+6]=it[1],t[e+7]=it[0],8):(t,e,n)=>(ot[0]=n,t[e]=it[0],t[e+1]=it[1],t[e+2]=it[2],t[e+3]=it[3],t[e+4]=it[4],t[e+5]=it[5],t[e+6]=it[6],t[e+7]=it[7],8)};class ut extends rt{get _bsontype(){return"Binary"}constructor(t,e){if(super(),null!=t&&"string"==typeof t&&!ArrayBuffer.isView(t)&&!s(t)&&!Array.isArray(t))throw new k("Binary can only be constructed from Uint8Array or number[]");this.sub_type=e??ut.BSON_BINARY_SUBTYPE_DEFAULT,null==t?(this.buffer=nt.allocate(ut.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?nt.fromNumberArray(t):nt.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if("string"==typeof t&&1!==t.length)throw new k("only accepts single character String");if("number"!=typeof t&&1!==t.length)throw new k("only accepts single character Uint8Array or Array");let e;if(e="string"==typeof t?t.charCodeAt(0):"number"==typeof t?t:t[0],e<0||e>255)throw new k("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=e;else{const t=nt.allocate(ut.BUFFER_SIZE+this.buffer.length);t.set(this.buffer,0),this.buffer=t,this.buffer[this.position++]=e}}write(t,e){if(e="number"==typeof e?e:this.position,this.buffer.byteLength<e+t.length){const e=nt.allocate(this.buffer.byteLength+t.length);e.set(this.buffer,0),this.buffer=e}if(ArrayBuffer.isView(t))this.buffer.set(nt.toLocalBufferType(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position;else if("string"==typeof t)throw new k("input cannot be string")}read(t,e){const n=t+(e=e&&e>0?e:this.position);return this.buffer.subarray(t,n>this.position?this.position:n)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return nt.toBase64(this.buffer.subarray(0,this.position))}toString(t){return"hex"===t?nt.toHex(this.buffer.subarray(0,this.position)):"base64"===t?nt.toBase64(this.buffer.subarray(0,this.position)):nt.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(t){t=t||{},this.sub_type===ut.SUBTYPE_VECTOR&&ct(this);const e=nt.toBase64(this.buffer),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}}toUUID(){if(this.sub_type===ut.SUBTYPE_UUID)return new ht(this.buffer.subarray(0,this.position));throw new k(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${ut.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,e){return new ut(nt.fromHex(t),e)}static createFromBase64(t,e){return new ut(nt.fromBase64(t),e)}static fromExtendedJSON(t,e){let n,r;if(e=e||{},"$binary"in t?e.legacy&&"string"==typeof t.$binary&&"$type"in t?(r=t.$type?parseInt(t.$type,16):0,n=nt.fromBase64(t.$binary)):"string"!=typeof t.$binary&&(r=t.$binary.subType?parseInt(t.$binary.subType,16):0,n=nt.fromBase64(t.$binary.base64)):"$uuid"in t&&(r=4,n=ht.bytesFromString(t.$uuid)),!n)throw new k(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return r===M?new ht(n):new ut(n,r)}inspect(t,e,n){return n??=f,`Binary.createFromBase64(${n(nt.toBase64(this.buffer.subarray(0,this.position)),e)}, ${n(this.sub_type,e)})`}toInt8Array(){if(this.sub_type!==ut.SUBTYPE_VECTOR)throw new k("Binary sub_type is not Vector");if(this.buffer[0]!==ut.VECTOR_TYPE.Int8)throw new k("Binary datatype field is not Int8");return ct(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==ut.SUBTYPE_VECTOR)throw new k("Binary sub_type is not Vector");if(this.buffer[0]!==ut.VECTOR_TYPE.Float32)throw new k("Binary datatype field is not Float32");ct(this);const t=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return at.isBigEndian&&nt.swap32(t),new Float32Array(t.buffer)}toPackedBits(){if(this.sub_type!==ut.SUBTYPE_VECTOR)throw new k("Binary sub_type is not Vector");if(this.buffer[0]!==ut.VECTOR_TYPE.PackedBit)throw new k("Binary datatype field is not packed bit");return ct(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==ut.SUBTYPE_VECTOR)throw new k("Binary sub_type is not Vector");if(this.buffer[0]!==ut.VECTOR_TYPE.PackedBit)throw new k("Binary datatype field is not packed bit");ct(this);const t=8*(this.length()-2)-this.buffer[1],e=new Int8Array(t);for(let t=0;t<e.length;t++){const n=t/8|0,r=this.buffer[n+2]>>7-t%8&1;e[t]=r}return e}static fromInt8Array(t){const e=nt.allocate(t.byteLength+2);e[0]=ut.VECTOR_TYPE.Int8,e[1]=0;const n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.set(n,2);const r=new this(e,this.SUBTYPE_VECTOR);return ct(r),r}static fromFloat32Array(t){const e=nt.allocate(t.byteLength+2);e[0]=ut.VECTOR_TYPE.Float32,e[1]=0;const n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.set(n,2),at.isBigEndian&&nt.swap32(new Uint8Array(e.buffer,2));const r=new this(e,this.SUBTYPE_VECTOR);return ct(r),r}static fromPackedBits(t,e=0){const n=nt.allocate(t.byteLength+2);n[0]=ut.VECTOR_TYPE.PackedBit,n[1]=e,n.set(t,2);const r=new this(n,this.SUBTYPE_VECTOR);return ct(r),r}static fromBits(t){const e=t.length+7>>>3,n=new Uint8Array(e+2);n[0]=ut.VECTOR_TYPE.PackedBit;const r=t.length%8;n[1]=0===r?0:8-r;for(let e=0;e<t.length;e++){const r=e>>>3,o=t[e];if(0!==o&&1!==o)throw new k(`Invalid bit value at ${e}: must be 0 or 1, found ${t[e]}`);if(0===o)continue;const i=7-e%8;n[r+2]|=o<<i}return new this(n,ut.SUBTYPE_VECTOR)}}function ct(t){if(t.sub_type!==ut.SUBTYPE_VECTOR)return;const e=t.position,n=t.buffer[0],r=t.buffer[1];if((n===ut.VECTOR_TYPE.Float32||n===ut.VECTOR_TYPE.Int8)&&0!==r)throw new k("Invalid Vector: padding must be zero for int8 and float32 vectors");if(n===ut.VECTOR_TYPE.Float32&&0!==e&&e-2!=0&&(e-2)%4!=0)throw new k("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(n===ut.VECTOR_TYPE.PackedBit&&0!==r&&2===e)throw new k("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(n===ut.VECTOR_TYPE.PackedBit&&r>7)throw new k(`Invalid Vector: padding must be a value between 0 and 7. found: ${r}`)}ut.BSON_BINARY_SUBTYPE_DEFAULT=0,ut.BUFFER_SIZE=256,ut.SUBTYPE_DEFAULT=0,ut.SUBTYPE_FUNCTION=1,ut.SUBTYPE_BYTE_ARRAY=2,ut.SUBTYPE_UUID_OLD=3,ut.SUBTYPE_UUID=4,ut.SUBTYPE_MD5=5,ut.SUBTYPE_ENCRYPTED=6,ut.SUBTYPE_COLUMN=7,ut.SUBTYPE_SENSITIVE=8,ut.SUBTYPE_VECTOR=9,ut.SUBTYPE_USER_DEFINED=128,ut.VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});const ft=/^[0-9A-F]{32}$/i,lt=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class ht extends ut{constructor(t){let e;if(null==t)e=ht.generate();else if(t instanceof ht)e=nt.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&16===t.byteLength)e=nt.toLocalBufferType(t);else{if("string"!=typeof t)throw new k("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");e=ht.bytesFromString(t)}super(e,M)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[nt.toHex(this.buffer.subarray(0,4)),nt.toHex(this.buffer.subarray(4,6)),nt.toHex(this.buffer.subarray(6,8)),nt.toHex(this.buffer.subarray(8,10)),nt.toHex(this.buffer.subarray(10,16))].join("-"):nt.toHex(this.buffer)}toString(t){return"hex"===t?nt.toHex(this.id):"base64"===t?nt.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof ht)return nt.equals(t.id,this.id);try{return nt.equals(new ht(t).id,this.id)}catch{return!1}}toBinary(){return new ut(this.id,ut.SUBTYPE_UUID)}static generate(){const t=nt.randomBytes(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,t}static isValid(t){return!!t&&("string"==typeof t?ht.isValidUUIDString(t):i(t)?16===t.byteLength:"Binary"===t._bsontype&&t.sub_type===this.SUBTYPE_UUID&&16===t.buffer.byteLength)}static createFromHexString(t){const e=ht.bytesFromString(t);return new ht(e)}static createFromBase64(t){return new ht(nt.fromBase64(t))}static bytesFromString(t){if(!ht.isValidUUIDString(t))throw new k("UUID string representation must be 32 hex digits or canonical hyphenated representation");return nt.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return ft.test(t)||lt.test(t)}inspect(t,e,n){return n??=f,`new UUID(${n(this.toHexString(),e)})`}}class dt extends rt{get _bsontype(){return"Code"}constructor(t,e){super(),this.code=t.toString(),this.scope=e??null}toJSON(){return null!=this.scope?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new dt(t.$code,t.$scope)}inspect(t,e,n){n??=f;let r=n(this.code,e);const o=r.includes("\n");return null!=this.scope&&(r+=`,${o?"\n":" "}${n(this.scope,e)}`),`new Code(${o?"\n":""}${r}${o&&null===this.scope?"\n":""})`}}function pt(t){return null!=t&&"object"==typeof t&&"$id"in t&&null!=t.$id&&"$ref"in t&&"string"==typeof t.$ref&&(!("$db"in t)||"$db"in t&&"string"==typeof t.$db)}class yt extends rt{get _bsontype(){return"DBRef"}constructor(t,e,n,r){super();const o=t.split(".");2===o.length&&(n=o.shift(),t=o.shift()),this.collection=t,this.oid=e,this.db=n,this.fields=r||{}}get namespace(){return this.collection}set namespace(t){this.collection=t}toJSON(){const t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t}toExtendedJSON(t){t=t||{};let e={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields)),e}static fromExtendedJSON(t){const e=Object.assign({},t);return delete e.$ref,delete e.$id,delete e.$db,new yt(t.$ref,t.$id,t.$db,e)}inspect(t,e,n){n??=f;const r=[n(this.namespace,e),n(this.oid,e),...this.db?[n(this.db,e)]:[],...Object.keys(this.fields).length>0?[n(this.fields,e)]:[]];return r[1]=n===f?`new ObjectId(${r[1]})`:r[1],`new DBRef(${r.join(", ")})`}}function gt(t){if(""===t)return t;let e=0;const n="-"===t[e],r="+"===t[e];(r||n)&&(e+=1);let o=!1;for(;e<t.length&&"0"===t[e];++e)o=!0;return o?`${n?"-":""}${t.length===e?"0":t.slice(e)}`:r?t.slice(1):t}let mt;try{mt=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{}const bt=4294967296,wt=0x10000000000000000,vt=wt/2,_t={},Ot={},Et=/^(\+?0|(\+|-)?[1-9][0-9]*)$/;class St extends rt{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(t=0,e,n){super();const r="boolean"==typeof e?e:Boolean(n),o="number"==typeof e?e:0,i="string"==typeof t?St.fromString(t,r):"bigint"==typeof t?St.fromBigInt(t,r):{low:0|t,high:0|o,unsigned:r};this.low=i.low,this.high=i.high,this.unsigned=i.unsigned}static fromBits(t,e,n){return new St(t,e,n)}static fromInt(t,e){let n,r,o;return e?(o=0<=(t>>>=0)&&t<256)&&(r=Ot[t],r)?r:(n=St.fromBits(t,(0|t)<0?-1:0,!0),o&&(Ot[t]=n),n):(o=-128<=(t|=0)&&t<128)&&(r=_t[t],r)?r:(n=St.fromBits(t,t<0?-1:0,!1),o&&(_t[t]=n),n)}static fromNumber(t,e){if(isNaN(t))return e?St.UZERO:St.ZERO;if(e){if(t<0)return St.UZERO;if(t>=wt)return St.MAX_UNSIGNED_VALUE}else{if(t<=-0x8000000000000000)return St.MIN_VALUE;if(t+1>=vt)return St.MAX_VALUE}return t<0?St.fromNumber(-t,e).neg():St.fromBits(t%bt|0,t/bt|0,e)}static fromBigInt(t,e){const n=BigInt(4294967295),r=BigInt(32);return new St(Number(t&n),Number(t>>r&n),e)}static _fromString(t,e,n){if(0===t.length)throw new k("empty string");if(n<2||36<n)throw new k("radix");let r;if((r=t.indexOf("-"))>0)throw new k("interior hyphen");if(0===r)return St._fromString(t.substring(1),e,n).neg();const o=St.fromNumber(Math.pow(n,8));let i=St.ZERO;for(let e=0;e<t.length;e+=8){const r=Math.min(8,t.length-e),s=parseInt(t.substring(e,e+r),n);if(r<8){const t=St.fromNumber(Math.pow(n,r));i=i.mul(t).add(St.fromNumber(s))}else i=i.mul(o),i=i.add(St.fromNumber(s))}return i.unsigned=e,i}static fromStringStrict(t,e,n){let r=!1;if("number"==typeof e?(n=e,e=!1):r=!!e,n??=10,t.trim()!==t)throw new k(`Input: '${t}' contains leading and/or trailing whitespace`);if(!function(t,e){const n="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,e=e??10);return!new RegExp(`[^-+${n}]`,"i").test(t)&&t}(t,n))throw new k(`Input: '${t}' contains invalid characters for radix: ${n}`);const o=gt(t),i=St._fromString(o,r,n);if(i.toString(n).toLowerCase()!==o.toLowerCase())throw new k(`Input: ${t} is not representable as ${i.unsigned?"an unsigned":"a signed"} 64-bit Long ${null!=n?`with radix: ${n}`:""}`);return i}static fromString(t,e,n){let r=!1;return"number"==typeof e?(n=e,e=!1):r=!!e,n??=10,"NaN"===t&&n<24||("Infinity"===t||"+Infinity"===t||"-Infinity"===t)&&n<35?St.ZERO:St._fromString(t,r,n)}static fromBytes(t,e,n){return n?St.fromBytesLE(t,e):St.fromBytesBE(t,e)}static fromBytesLE(t,e){return new St(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)}static fromBytesBE(t,e){return new St(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}static isLong(t){return null!=t&&"object"==typeof t&&"__isLong__"in t&&!0===t.__isLong__}static fromValue(t,e){return"number"==typeof t?St.fromNumber(t,e):"string"==typeof t?St.fromString(t,e):St.fromBits(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}add(t){St.isLong(t)||(t=St.fromValue(t));const e=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,i=t.high>>>16,s=65535&t.high,a=t.low>>>16;let u=0,c=0,f=0,l=0;return l+=o+(65535&t.low),f+=l>>>16,l&=65535,f+=r+a,c+=f>>>16,f&=65535,c+=n+s,u+=c>>>16,c&=65535,u+=e+i,u&=65535,St.fromBits(f<<16|l,u<<16|c,this.unsigned)}and(t){return St.isLong(t)||(t=St.fromValue(t)),St.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(St.isLong(t)||(t=St.fromValue(t)),this.eq(t))return 0;const e=this.isNegative(),n=t.isNegative();return e&&!n?-1:!e&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1}comp(t){return this.compare(t)}divide(t){if(St.isLong(t)||(t=St.fromValue(t)),t.isZero())throw new k("division by zero");if(mt){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;const e=(this.unsigned?mt.div_u:mt.div_s)(this.low,this.high,t.low,t.high);return St.fromBits(e,mt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?St.UZERO:St.ZERO;let e,n,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return St.UZERO;if(t.gt(this.shru(1)))return St.UONE;r=St.UZERO}else{if(this.eq(St.MIN_VALUE))return t.eq(St.ONE)||t.eq(St.NEG_ONE)?St.MIN_VALUE:t.eq(St.MIN_VALUE)?St.ONE:(e=this.shr(1).div(t).shl(1),e.eq(St.ZERO)?t.isNegative()?St.ONE:St.NEG_ONE:(n=this.sub(t.mul(e)),r=e.add(n.div(t)),r));if(t.eq(St.MIN_VALUE))return this.unsigned?St.UZERO:St.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=St.ZERO}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));const o=Math.ceil(Math.log(e)/Math.LN2),i=o<=48?1:Math.pow(2,o-48);let s=St.fromNumber(e),a=s.mul(t);for(;a.isNegative()||a.gt(n);)e-=i,s=St.fromNumber(e,this.unsigned),a=s.mul(t);s.isZero()&&(s=St.ONE),r=r.add(s),n=n.sub(a)}return r}div(t){return this.divide(t)}equals(t){return St.isLong(t)||(t=St.fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low}eq(t){return this.equals(t)}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(St.MIN_VALUE)?64:this.neg().getNumBitsAbs();const t=0!==this.high?this.high:this.low;let e;for(e=31;e>0&&!(t&1<<e);e--);return 0!==this.high?e+33:e+1}greaterThan(t){return this.comp(t)>0}gt(t){return this.greaterThan(t)}greaterThanOrEqual(t){return this.comp(t)>=0}gte(t){return this.greaterThanOrEqual(t)}ge(t){return this.greaterThanOrEqual(t)}isEven(){return!(1&this.low)}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return!(1&~this.low)}isPositive(){return this.unsigned||this.high>=0}isZero(){return 0===this.high&&0===this.low}lessThan(t){return this.comp(t)<0}lt(t){return this.lessThan(t)}lessThanOrEqual(t){return this.comp(t)<=0}lte(t){return this.lessThanOrEqual(t)}modulo(t){if(St.isLong(t)||(t=St.fromValue(t)),mt){const e=(this.unsigned?mt.rem_u:mt.rem_s)(this.low,this.high,t.low,t.high);return St.fromBits(e,mt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))}mod(t){return this.modulo(t)}rem(t){return this.modulo(t)}multiply(t){if(this.isZero())return St.ZERO;if(St.isLong(t)||(t=St.fromValue(t)),mt){const e=mt.mul(this.low,this.high,t.low,t.high);return St.fromBits(e,mt.get_high(),this.unsigned)}if(t.isZero())return St.ZERO;if(this.eq(St.MIN_VALUE))return t.isOdd()?St.MIN_VALUE:St.ZERO;if(t.eq(St.MIN_VALUE))return this.isOdd()?St.MIN_VALUE:St.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(St.TWO_PWR_24)&&t.lt(St.TWO_PWR_24))return St.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);const e=this.high>>>16,n=65535&this.high,r=this.low>>>16,o=65535&this.low,i=t.high>>>16,s=65535&t.high,a=t.low>>>16,u=65535&t.low;let c=0,f=0,l=0,h=0;return h+=o*u,l+=h>>>16,h&=65535,l+=r*u,f+=l>>>16,l&=65535,l+=o*a,f+=l>>>16,l&=65535,f+=n*u,c+=f>>>16,f&=65535,f+=r*a,c+=f>>>16,f&=65535,f+=o*s,c+=f>>>16,f&=65535,c+=e*u+n*a+r*s+o*i,c&=65535,St.fromBits(l<<16|h,c<<16|f,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(St.MIN_VALUE)?St.MIN_VALUE:this.not().add(St.ONE)}neg(){return this.negate()}not(){return St.fromBits(~this.low,~this.high,this.unsigned)}notEquals(t){return!this.equals(t)}neq(t){return this.notEquals(t)}ne(t){return this.notEquals(t)}or(t){return St.isLong(t)||(t=St.fromValue(t)),St.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return St.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?St.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):St.fromBits(0,this.low<<t-32,this.unsigned)}shl(t){return this.shiftLeft(t)}shiftRight(t){return St.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?St.fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):St.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(St.isLong(t)&&(t=t.toInt()),0==(t&=63))return this;{const e=this.high;if(t<32){const n=this.low;return St.fromBits(n>>>t|e<<32-t,e>>>t,this.unsigned)}return 32===t?St.fromBits(e,0,this.unsigned):St.fromBits(e>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return St.isLong(t)||(t=St.fromValue(t)),this.add(t.neg())}sub(t){return this.subtract(t)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*bt+(this.low>>>0):this.high*bt+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){const t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]}toBytesBE(){const t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]}toSigned(){return this.unsigned?St.fromBits(this.low,this.high,!1):this}toString(t){if((t=t||10)<2||36<t)throw new k("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(St.MIN_VALUE)){const e=St.fromNumber(t),n=this.div(e),r=n.mul(e).sub(this);return n.toString(t)+r.toInt().toString(t)}return"-"+this.neg().toString(t)}const e=St.fromNumber(Math.pow(t,6),this.unsigned);let n=this,r="";for(;;){const o=n.div(e);let i=(n.sub(o.mul(e)).toInt()>>>0).toString(t);if(n=o,n.isZero())return i+r;for(;i.length<6;)i="0"+i;r=""+i+r}}toUnsigned(){return this.unsigned?this:St.fromBits(this.low,this.high,!0)}xor(t){return St.isLong(t)||(t=St.fromValue(t)),St.fromBits(this.low^t.low,this.high^t.high,this.unsigned)}eqz(){return this.isZero()}le(t){return this.lessThanOrEqual(t)}toExtendedJSON(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(t,e){const{useBigInt64:n=!1,relaxed:r=!0}={...e};if(t.$numberLong.length>20)throw new k("$numberLong string is too long");if(!Et.test(t.$numberLong))throw new k(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(n){const e=BigInt(t.$numberLong);return BigInt.asIntN(64,e)}const o=St.fromString(t.$numberLong);return r?o.toNumber():o}inspect(t,e,n){return n??=f,`new Long(${n(this.toString(),e)}${this.unsigned?`, ${n(this.unsigned,e)}`:""})`}}St.TWO_PWR_24=St.fromInt(1<<24),St.MAX_UNSIGNED_VALUE=St.fromBits(-1,-1,!0),St.ZERO=St.fromInt(0),St.UZERO=St.fromInt(0,!0),St.ONE=St.fromInt(1),St.UONE=St.fromInt(1,!0),St.NEG_ONE=St.fromInt(-1),St.MAX_VALUE=St.fromBits(-1,2147483647,!1),St.MIN_VALUE=St.fromBits(0,-2147483648,!1);const Nt=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,It=/^(\+|-)?(Infinity|inf)$/i,Tt=/^(\+|-)?NaN$/i,Bt=6111,xt=-6176,Lt=nt.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),$t=nt.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),At=nt.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Ut=/^([-+])?(\d+)?$/;function Pt(t){return!isNaN(parseInt(t,10))}function jt(t){const e=St.fromNumber(1e9);let n=St.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(let r=0;r<=3;r++)n=n.shiftLeft(32),n=n.add(new St(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function Rt(t,e){throw new k(`"${t}" is not a valid Decimal128 string - ${e}`)}class Dt extends rt{get _bsontype(){return"Decimal128"}constructor(t){if(super(),"string"==typeof t)this.bytes=Dt.fromString(t).bytes;else{if(!(t instanceof Uint8Array||i(t)))throw new k("Decimal128 must take a Buffer or string");if(16!==t.byteLength)throw new k("Decimal128 must take a Buffer of 16 bytes");this.bytes=t}}static fromString(t){return Dt._fromString(t,{allowRounding:!1})}static fromStringWithRounding(t){return Dt._fromString(t,{allowRounding:!0})}static _fromString(t,e){let n=!1,r=!1,o=!1,i=!1,s=0,a=0,u=0,c=0,f=0;const l=[0];let h=0,d=0,p=0,y=0,g=new St(0,0),m=new St(0,0),b=0,w=0;if(t.length>=7e3)throw new k(t+" not a valid Decimal128 string");const v=t.match(Nt),_=t.match(It),O=t.match(Tt);if(!v&&!_&&!O||0===t.length)throw new k(t+" not a valid Decimal128 string");if(v){const e=v[2],n=v[4],r=v[5],o=v[6];n&&void 0===o&&Rt(t,"missing exponent power"),n&&void 0===e&&Rt(t,"missing exponent base"),void 0===n&&(r||o)&&Rt(t,"missing e before exponent")}if("+"!==t[w]&&"-"!==t[w]||(r=!0,n="-"===t[w++]),!Pt(t[w])&&"."!==t[w]){if("i"===t[w]||"I"===t[w])return new Dt(n?$t:At);if("N"===t[w])return new Dt(Lt)}for(;Pt(t[w])||"."===t[w];)"."!==t[w]?(h<34&&("0"!==t[w]||i)&&(i||(f=a),i=!0,l[d++]=parseInt(t[w],10),h+=1),i&&(u+=1),o&&(c+=1),a+=1,w+=1):(o&&Rt(t,"contains multiple periods"),o=!0,w+=1);if(o&&!a)throw new k(t+" not a valid Decimal128 string");if("e"===t[w]||"E"===t[w]){const e=t.substr(++w).match(Ut);if(!e||!e[2])return new Dt(Lt);y=parseInt(e[0],10),w+=e[0].length}if(t[w])return new Dt(Lt);if(h){if(p=h-1,s=u,1!==s)for(;"0"===t[f+s-1+Number(r)+Number(o)];)s-=1}else l[0]=0,u=1,h=1,s=0;for(y<=c&&c>y+16384?y=xt:y-=c;y>Bt;){if(p+=1,p>=34){if(0===s){y=Bt;break}Rt(t,"overflow")}y-=1}if(e.allowRounding){for(;y<xt||h<u;){if(0===p&&s<h){y=xt,s=0;break}if(h<u?u-=1:p-=1,y<Bt)y+=1;else{if(l.join("").match(/^0+$/)){y=Bt;break}Rt(t,"overflow")}}if(p+1<s){let e=a;o&&(f+=1,e+=1),r&&(f+=1,e+=1);const i=parseInt(t[f+p+1],10);let s=0;if(i>=5&&(s=1,5===i)){s=l[p]%2==1?1:0;for(let n=f+p+2;n<e;n++)if(parseInt(t[n],10)){s=1;break}}if(s){let t=p;for(;t>=0&&++l[t]>9;t--)if(l[t]=0,0===t){if(!(y<Bt))return new Dt(n?$t:At);y+=1,l[t]=1}}}}else{for(;y<xt||h<u;){if(0===p){if(0===s){y=xt;break}Rt(t,"exponent underflow")}h<u?("0"!==t[u-1+Number(r)+Number(o)]&&0!==s&&Rt(t,"inexact rounding"),u-=1):(0!==l[p]&&Rt(t,"inexact rounding"),p-=1),y<Bt?y+=1:Rt(t,"overflow")}p+1<s&&(o&&(f+=1),r&&(f+=1),0!==parseInt(t[f+p+1],10)&&Rt(t,"inexact rounding"))}if(g=St.fromNumber(0),m=St.fromNumber(0),0===s)g=St.fromNumber(0),m=St.fromNumber(0);else if(p<17){let t=0;for(m=St.fromNumber(l[t++]),g=new St(0,0);t<=p;t++)m=m.multiply(St.fromNumber(10)),m=m.add(St.fromNumber(l[t]))}else{let t=0;for(g=St.fromNumber(l[t++]);t<=p-17;t++)g=g.multiply(St.fromNumber(10)),g=g.add(St.fromNumber(l[t]));for(m=St.fromNumber(l[t++]);t<=p;t++)m=m.multiply(St.fromNumber(10)),m=m.add(St.fromNumber(l[t]))}const E=function(t,e){if(!t&&!e)return{high:St.fromNumber(0),low:St.fromNumber(0)};const n=t.shiftRightUnsigned(32),r=new St(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new St(e.getLowBits(),0);let s=n.multiply(o),a=n.multiply(i);const u=r.multiply(o);let c=r.multiply(i);return s=s.add(a.shiftRightUnsigned(32)),a=new St(a.getLowBits(),0).add(u).add(c.shiftRightUnsigned(32)),s=s.add(a.shiftRightUnsigned(32)),c=a.shiftLeft(32).add(new St(c.getLowBits(),0)),{high:s,low:c}}(g,St.fromString("100000000000000000"));E.low=E.low.add(m),function(t,e){const n=t.high>>>0,r=e.high>>>0;return n<r||n===r&&t.low>>>0<e.low>>>0}(E.low,m)&&(E.high=E.high.add(St.fromNumber(1))),b=y+6176;const S={low:St.fromNumber(0),high:St.fromNumber(0)};E.high.shiftRightUnsigned(49).and(St.fromNumber(1)).equals(St.fromNumber(1))?(S.high=S.high.or(St.fromNumber(3).shiftLeft(61)),S.high=S.high.or(St.fromNumber(b).and(St.fromNumber(16383).shiftLeft(47))),S.high=S.high.or(E.high.and(St.fromNumber(0x7fffffffffff)))):(S.high=S.high.or(St.fromNumber(16383&b).shiftLeft(49)),S.high=S.high.or(E.high.and(St.fromNumber(562949953421311)))),S.low=E.low,n&&(S.high=S.high.or(St.fromString("9223372036854775808")));const N=nt.allocateUnsafe(16);return w=0,N[w++]=255&S.low.low,N[w++]=S.low.low>>8&255,N[w++]=S.low.low>>16&255,N[w++]=S.low.low>>24&255,N[w++]=255&S.low.high,N[w++]=S.low.high>>8&255,N[w++]=S.low.high>>16&255,N[w++]=S.low.high>>24&255,N[w++]=255&S.high.low,N[w++]=S.high.low>>8&255,N[w++]=S.high.low>>16&255,N[w++]=S.high.low>>24&255,N[w++]=255&S.high.high,N[w++]=S.high.high>>8&255,N[w++]=S.high.high>>16&255,N[w++]=S.high.high>>24&255,new Dt(N)}toString(){let t,e=0;const n=new Array(36);for(let t=0;t<n.length;t++)n[t]=0;let r,o,i,s=0,a=!1,u={parts:[0,0,0,0]};const c=[];s=0;const f=this.bytes,l=f[s++]|f[s++]<<8|f[s++]<<16|f[s++]<<24,h=f[s++]|f[s++]<<8|f[s++]<<16|f[s++]<<24,d=f[s++]|f[s++]<<8|f[s++]<<16|f[s++]<<24,p=f[s++]|f[s++]<<8|f[s++]<<16|f[s++]<<24;s=0,(new St(l,h),new St(d,p)).lessThan(St.ZERO)&&c.push("-");const y=p>>26&31;if(y>>3==3){if(30===y)return c.join("")+"Infinity";if(31===y)return"NaN";t=p>>15&16383,r=8+(p>>14&1)}else r=p>>14&7,t=p>>17&16383;const g=t-6176;if(u.parts[0]=(16383&p)+((15&r)<<14),u.parts[1]=d,u.parts[2]=h,u.parts[3]=l,0===u.parts[0]&&0===u.parts[1]&&0===u.parts[2]&&0===u.parts[3])a=!0;else for(i=3;i>=0;i--){let t=0;const e=jt(u);if(u=e.quotient,t=e.rem.low,t)for(o=8;o>=0;o--)n[9*i+o]=t%10,t=Math.floor(t/10)}if(a)e=1,n[s]=0;else for(e=36;!n[s];)e-=1,s+=1;const m=e-1+g;if(m>=34||m<=-7||g>0){if(e>34)return c.push("0"),g>0?c.push(`E+${g}`):g<0&&c.push(`E${g}`),c.join("");c.push(`${n[s++]}`),e-=1,e&&c.push(".");for(let t=0;t<e;t++)c.push(`${n[s++]}`);c.push("E"),m>0?c.push(`+${m}`):c.push(`${m}`)}else if(g>=0)for(let t=0;t<e;t++)c.push(`${n[s++]}`);else{let t=e+g;if(t>0)for(let e=0;e<t;e++)c.push(`${n[s++]}`);else c.push("0");for(c.push(".");t++<0;)c.push("0");for(let r=0;r<e-Math.max(t-1,0);r++)c.push(`${n[s++]}`)}return c.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(t){return Dt.fromString(t.$numberDecimal)}inspect(t,e,n){return n??=f,`new Decimal128(${n(this.toString(),e)})`}}class qt extends rt{get _bsontype(){return"Double"}constructor(t){super(),t instanceof Number&&(t=t.valueOf()),this.value=+t}static fromString(t){const e=Number(t);if("NaN"===t)return new qt(NaN);if("Infinity"===t)return new qt(1/0);if("-Infinity"===t)return new qt(-1/0);if(!Number.isFinite(e))throw new k(`Input: ${t} is not representable as a Double`);if(t.trim()!==t)throw new k(`Input: '${t}' contains whitespace`);if(""===t)throw new k("Input is an empty string");if(/[^-0-9.+eE]/.test(t))throw new k(`Input: '${t}' is not in decimal or exponential notation`);return new qt(e)}valueOf(){return this.value}toJSON(){return this.value}toString(t){return this.value.toString(t)}toExtendedJSON(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-0.0"}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}static fromExtendedJSON(t,e){const n=parseFloat(t.$numberDouble);return e&&e.relaxed?n:new qt(n)}inspect(t,e,n){return n??=f,`new Double(${n(this.value,e)})`}}class Ct extends rt{get _bsontype(){return"Int32"}constructor(t){super(),t instanceof Number&&(t=t.valueOf()),this.value=0|+t}static fromString(t){const e=gt(t),n=Number(t);if(d<n)throw new k(`Input: '${t}' is larger than the maximum value for Int32`);if(p>n)throw new k(`Input: '${t}' is smaller than the minimum value for Int32`);if(!Number.isSafeInteger(n))throw new k(`Input: '${t}' is not a safe integer`);if(n.toString()!==e)throw new k(`Input: '${t}' is not a valid Int32 string`);return new Ct(n)}valueOf(){return this.value}toString(t){return this.value.toString(t)}toJSON(){return this.value}toExtendedJSON(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(t,e){return e&&e.relaxed?parseInt(t.$numberInt,10):new Ct(t.$numberInt)}inspect(t,e,n){return n??=f,`new Int32(${n(this.value,e)})`}}class Ft extends rt{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new Ft}inspect(){return"new MaxKey()"}}class Mt extends rt{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new Mt}inspect(){return"new MinKey()"}}let Jt=null;const kt=new WeakMap;class Vt extends rt{get _bsontype(){return"ObjectId"}constructor(t){let e;if(super(),"object"==typeof t&&t&&"id"in t){if("string"!=typeof t.id&&!ArrayBuffer.isView(t.id))throw new k("Argument passed in must have an id that is of type string or Buffer");e="toHexString"in t&&"function"==typeof t.toHexString?nt.fromHex(t.toHexString()):t.id}else e=t;if(null==e||"number"==typeof e)this.buffer=Vt.generate("number"==typeof e?e:void 0);else if(ArrayBuffer.isView(e)&&12===e.byteLength)this.buffer=nt.toLocalBufferType(e);else{if("string"!=typeof e)throw new k("Argument passed in does not match the accepted types");if(!Vt.validateHexString(e))throw new k("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");this.buffer=nt.fromHex(e),Vt.cacheHexString&&kt.set(this,e)}}get id(){return this.buffer}set id(t){this.buffer=t,Vt.cacheHexString&&kt.set(this,nt.toHex(t))}static validateHexString(t){if(24!==t?.length)return!1;for(let e=0;e<24;e++){const n=t.charCodeAt(e);if(!(n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70))return!1}return!0}toHexString(){if(Vt.cacheHexString){const t=kt.get(this);if(t)return t}const t=nt.toHex(this.id);return Vt.cacheHexString&&kt.set(this,t),t}static getInc(){return Vt.index=(Vt.index+1)%16777215}static generate(t){"number"!=typeof t&&(t=Math.floor(Date.now()/1e3));const e=Vt.getInc(),n=nt.allocateUnsafe(12);return at.setInt32BE(n,0,t),null===Jt&&(Jt=nt.randomBytes(5)),n[4]=Jt[0],n[5]=Jt[1],n[6]=Jt[2],n[7]=Jt[3],n[8]=Jt[4],n[11]=255&e,n[10]=e>>8&255,n[9]=e>>16&255,n}toString(t){return"base64"===t?nt.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}static is(t){return null!=t&&"object"==typeof t&&"_bsontype"in t&&"ObjectId"===t._bsontype}equals(t){if(null==t)return!1;if(Vt.is(t))return this.buffer[11]===t.buffer[11]&&nt.equals(this.buffer,t.buffer);if("string"==typeof t)return t.toLowerCase()===this.toHexString();if("object"==typeof t&&"function"==typeof t.toHexString){const e=t.toHexString(),n=this.toHexString();return"string"==typeof e&&e.toLowerCase()===n}return!1}getTimestamp(){const t=new Date,e=at.getUint32BE(this.buffer,0);return t.setTime(1e3*Math.floor(e)),t}static createPk(){return new Vt}serializeInto(t,e){return t[e]=this.buffer[0],t[e+1]=this.buffer[1],t[e+2]=this.buffer[2],t[e+3]=this.buffer[3],t[e+4]=this.buffer[4],t[e+5]=this.buffer[5],t[e+6]=this.buffer[6],t[e+7]=this.buffer[7],t[e+8]=this.buffer[8],t[e+9]=this.buffer[9],t[e+10]=this.buffer[10],t[e+11]=this.buffer[11],12}static createFromTime(t){const e=nt.allocate(12);for(let t=11;t>=4;t--)e[t]=0;return at.setInt32BE(e,0,t),new Vt(e)}static createFromHexString(t){if(24!==t?.length)throw new k("hex string must be 24 characters");return new Vt(nt.fromHex(t))}static createFromBase64(t){if(16!==t?.length)throw new k("base64 string must be 16 characters");return new Vt(nt.fromBase64(t))}static isValid(t){if(null==t)return!1;if("string"==typeof t)return Vt.validateHexString(t);try{return new Vt(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new Vt(t.$oid)}isCached(){return Vt.cacheHexString&&kt.has(this)}inspect(t,e,n){return n??=f,`new ObjectId(${n(this.toHexString(),e)})`}}function zt(t,e,n){let r=5;if(Array.isArray(t))for(let o=0;o<t.length;o++)r+=Ht(o.toString(),t[o],e,!0,n);else{"function"==typeof t?.toBSON&&(t=t.toBSON());for(const o of Object.keys(t))r+=Ht(o,t[o],e,!1,n)}return r}function Ht(t,e,n=!1,r=!1,o=!1){switch("function"==typeof e?.toBSON&&(e=e.toBSON()),typeof e){case"string":return 1+nt.utf8ByteLength(t)+1+4+nt.utf8ByteLength(e)+1;case"number":return Math.floor(e)===e&&e>=b&&e<=m&&e>=p&&e<=d?(null!=t?nt.utf8ByteLength(t)+1:0)+5:(null!=t?nt.utf8ByteLength(t)+1:0)+9;case"undefined":return r||!o?(null!=t?nt.utf8ByteLength(t)+1:0)+1:0;case"boolean":return(null!=t?nt.utf8ByteLength(t)+1:0)+2;case"object":if(null!=e&&"string"==typeof e._bsontype&&e[h]!==l)throw new V;if(null==e||"MinKey"===e._bsontype||"MaxKey"===e._bsontype)return(null!=t?nt.utf8ByteLength(t)+1:0)+1;if("ObjectId"===e._bsontype)return(null!=t?nt.utf8ByteLength(t)+1:0)+13;if(e instanceof Date||c(e))return(null!=t?nt.utf8ByteLength(t)+1:0)+9;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||s(e))return(null!=t?nt.utf8ByteLength(t)+1:0)+6+e.byteLength;if("Long"===e._bsontype||"Double"===e._bsontype||"Timestamp"===e._bsontype)return(null!=t?nt.utf8ByteLength(t)+1:0)+9;if("Decimal128"===e._bsontype)return(null!=t?nt.utf8ByteLength(t)+1:0)+17;if("Code"===e._bsontype)return null!=e.scope&&Object.keys(e.scope).length>0?(null!=t?nt.utf8ByteLength(t)+1:0)+1+4+4+nt.utf8ByteLength(e.code.toString())+1+zt(e.scope,n,o):(null!=t?nt.utf8ByteLength(t)+1:0)+1+4+nt.utf8ByteLength(e.code.toString())+1;if("Binary"===e._bsontype){const n=e;return n.sub_type===ut.SUBTYPE_BYTE_ARRAY?(null!=t?nt.utf8ByteLength(t)+1:0)+(n.position+1+4+1+4):(null!=t?nt.utf8ByteLength(t)+1:0)+(n.position+1+4+1)}if("Symbol"===e._bsontype)return(null!=t?nt.utf8ByteLength(t)+1:0)+nt.utf8ByteLength(e.value)+4+1+1;if("DBRef"===e._bsontype){const r=Object.assign({$ref:e.collection,$id:e.oid},e.fields);return null!=e.db&&(r.$db=e.db),(null!=t?nt.utf8ByteLength(t)+1:0)+1+zt(r,n,o)}return e instanceof RegExp||a(e)?(null!=t?nt.utf8ByteLength(t)+1:0)+1+nt.utf8ByteLength(e.source)+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1:"BSONRegExp"===e._bsontype?(null!=t?nt.utf8ByteLength(t)+1:0)+1+nt.utf8ByteLength(e.pattern)+1+nt.utf8ByteLength(e.options)+1:(null!=t?nt.utf8ByteLength(t)+1:0)+zt(e,n,o)+1;case"function":return n?(null!=t?nt.utf8ByteLength(t)+1:0)+1+4+nt.utf8ByteLength(e.toString())+1:0;case"bigint":return(null!=t?nt.utf8ByteLength(t)+1:0)+9;case"symbol":return 0;default:throw new k("Unrecognized JS type: "+typeof e)}}Vt.index=Math.floor(16777215*Math.random());class Yt extends rt{get _bsontype(){return"BSONRegExp"}constructor(t,e){if(super(),this.pattern=t,this.options=(e??"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new k(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(-1!==this.options.indexOf("\0"))throw new k(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let t=0;t<this.options.length;t++)if("i"!==this.options[t]&&"m"!==this.options[t]&&"x"!==this.options[t]&&"l"!==this.options[t]&&"s"!==this.options[t]&&"u"!==this.options[t])throw new k(`The regular expression option [${this.options[t]}] is not supported`)}static parseOptions(t){return t?t.split("").sort().join(""):""}toExtendedJSON(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(t){if("$regex"in t){if("string"==typeof t.$regex)return new Yt(t.$regex,Yt.parseOptions(t.$options));if("BSONRegExp"===t.$regex._bsontype)return t}if("$regularExpression"in t)return new Yt(t.$regularExpression.pattern,Yt.parseOptions(t.$regularExpression.options));throw new k(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(t)}`)}inspect(t,e,n){const r=function(t){if(null!=t&&"object"==typeof t&&"stylize"in t&&"function"==typeof t.stylize)return t.stylize}(e)??(t=>t);return n??=f,`new BSONRegExp(${r(n(this.pattern),"regexp")}, ${r(n(this.options),"regexp")})`}}class Gt extends rt{get _bsontype(){return"BSONSymbol"}constructor(t){super(),this.value=t}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(t){return new Gt(t.$symbol)}inspect(t,e,n){return n??=f,`new BSONSymbol(${n(this.value,e)})`}}const Wt=St;class Zt extends Wt{get _bsontype(){return"Timestamp"}get i(){return this.low>>>0}get t(){return this.high>>>0}constructor(t){if(null==t)super(0,0,!0);else if("bigint"==typeof t)super(t,!0);else if(St.isLong(t))super(t.low,t.high,!0);else{if("object"!=typeof t||!("t"in t)||!("i"in t))throw new k("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }");{if("number"!=typeof t.t&&("object"!=typeof t.t||"Int32"!==t.t._bsontype))throw new k("Timestamp constructed from { t, i } must provide t as a number");if("number"!=typeof t.i&&("object"!=typeof t.i||"Int32"!==t.i._bsontype))throw new k("Timestamp constructed from { t, i } must provide i as a number");const e=Number(t.t),n=Number(t.i);if(e<0||Number.isNaN(e))throw new k("Timestamp constructed from { t, i } must provide a positive t");if(n<0||Number.isNaN(n))throw new k("Timestamp constructed from { t, i } must provide a positive i");if(e>4294967295)throw new k("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n>4294967295)throw new k("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(n,e,!0)}}}toJSON(){return{$timestamp:this.toString()}}static fromInt(t){return new Zt(St.fromInt(t,!0))}static fromNumber(t){return new Zt(St.fromNumber(t,!0))}static fromBits(t,e){return new Zt({i:t,t:e})}static fromString(t,e){return new Zt(St.fromString(t,!0,e))}toExtendedJSON(){return{$timestamp:{t:this.t,i:this.i}}}static fromExtendedJSON(t){const e=St.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,n=St.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new Zt({t:n,i:e})}inspect(t,e,n){return n??=f,`new Timestamp({ t: ${n(this.t,e)}, i: ${n(this.i,e)} })`}}Zt.MAX_VALUE=St.MAX_UNSIGNED_VALUE;const Kt=St.fromNumber(m),Qt=St.fromNumber(b);function Xt(t,e,n){const r=(e=null==e?{}:e)&&e.index?e.index:0,o=at.getInt32LE(t,r);if(o<5)throw new k(`bson size must be >= 5, is ${o}`);if(e.allowObjectSmallerThanBufferSize&&t.length<o)throw new k(`buffer length ${t.length} must be >= bson size ${o}`);if(!e.allowObjectSmallerThanBufferSize&&t.length!==o)throw new k(`buffer length ${t.length} must === bson size ${o}`);if(o+r>t.byteLength)throw new k(`(bson size ${o} + options.index ${r} must be <= buffer length ${t.byteLength})`);if(0!==t[r+o-1])throw new k("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return ee(t,r,e,n)}const te=/^\$ref$|^\$id$|^\$db$/;function ee(t,e,n,r=!1){const o=null==n.fieldsAsRaw?null:n.fieldsAsRaw,i=null!=n.raw&&n.raw,s="boolean"==typeof n.bsonRegExp&&n.bsonRegExp,a=n.promoteBuffers??!1,u=n.promoteLongs??!0,c=n.promoteValues??!0,f=n.useBigInt64??!1;if(f&&!c)throw new k("Must either request bigint or Long for int64 deserialization");if(f&&!u)throw new k("Must either request bigint or Long for int64 deserialization");let l,h,d=!0;const p=(null==n.validation?{utf8:!0}:n.validation).utf8;if("boolean"==typeof p)l=p;else{d=!1;const t=Object.keys(p).map(function(t){return p[t]});if(0===t.length)throw new k("UTF-8 validation setting cannot be empty");if("boolean"!=typeof t[0])throw new k("Invalid UTF-8 validation option, must specify boolean values");if(l=t[0],!t.every(t=>t===l))throw new k("Invalid UTF-8 validation option - keys must be all true or all false")}if(!d){h=new Set;for(const t of Object.keys(p))h.add(t)}const y=e;if(t.length<5)throw new k("corrupt bson message < 5 bytes long");const g=at.getInt32LE(t,e);if(e+=4,g<5||g>t.length)throw new k("corrupt bson message");const m=r?[]:{};let b=0,F=!r&&null;for(;;){const p=t[e++];if(0===p)break;let y=e;for(;0!==t[y]&&y<t.length;)y++;if(y>=t.byteLength)throw new k("Bad BSON Document: illegal CString");const g=r?b++:nt.toUTF8(t,e,y,!1);let J,V=!0;if(V=d||h?.has(g)?l:!l,!1!==F&&"$"===g[0]&&(F=te.test(g)),e=y+1,p===v){const n=at.getInt32LE(t,e);if(e+=4,n<=0||n>t.length-e||0!==t[e+n-1])throw new k("bad string length in bson");J=nt.toUTF8(t,e,e+n-1,V),e+=n}else if(p===N){const n=nt.allocateUnsafe(12);for(let r=0;r<12;r++)n[r]=t[e+r];J=new Vt(n),e+=12}else if(p===P&&!1===c)J=new Ct(at.getInt32LE(t,e)),e+=4;else if(p===P)J=at.getInt32LE(t,e),e+=4;else if(p===w)J=at.getFloat64LE(t,e),e+=8,!1===c&&(J=new qt(J));else if(p===T){const n=at.getInt32LE(t,e),r=at.getInt32LE(t,e+4);e+=8,J=new Date(new St(n,r).toNumber())}else if(p===I){if(0!==t[e]&&1!==t[e])throw new k("illegal boolean type value");J=1===t[e++]}else if(p===_){const r=e,o=at.getInt32LE(t,e);if(o<=0||o>t.length-e)throw new k("bad embedded document length in bson");if(i)J=t.subarray(e,e+o);else{let e=n;d||(e={...n,validation:{utf8:V}}),J=ee(t,r,e,!1)}e+=o}else if(p===O){const r=e,i=at.getInt32LE(t,e);let s=n;const a=e+i;if(o&&o[g]&&(s={...n,raw:!0}),d||(s={...s,validation:{utf8:V}}),J=ee(t,r,s,!0),0!==t[(e+=i)-1])throw new k("invalid array terminator byte");if(e!==a)throw new k("corrupted array bson")}else if(p===S)J=void 0;else if(p===B)J=null;else if(p===R)if(f)J=at.getBigInt64LE(t,e),e+=8;else{const n=at.getInt32LE(t,e),r=at.getInt32LE(t,e+4);e+=8;const o=new St(n,r);J=u&&!0===c&&o.lessThanOrEqual(Kt)&&o.greaterThanOrEqual(Qt)?o.toNumber():o}else if(p===D){const n=nt.allocateUnsafe(16);for(let r=0;r<16;r++)n[r]=t[e+r];e+=16,J=new Dt(n)}else if(p===E){let n=at.getInt32LE(t,e);e+=4;const r=n,o=t[e++];if(n<0)throw new k("Negative binary type element size found");if(n>t.byteLength)throw new k("Binary type size larger than document size");if(o===ut.SUBTYPE_BYTE_ARRAY){if(n=at.getInt32LE(t,e),e+=4,n<0)throw new k("Negative binary type element size found for subtype 0x02");if(n>r-4)throw new k("Binary type with subtype 0x02 contains too long binary size");if(n<r-4)throw new k("Binary type with subtype 0x02 contains too short binary size")}a&&c?J=nt.toLocalBufferType(t.subarray(e,e+n)):(J=new ut(t.subarray(e,e+n),o),o===M&&ht.isValid(J)&&(J=J.toUUID())),e+=n}else if(p===x&&!1===s){for(y=e;0!==t[y]&&y<t.length;)y++;if(y>=t.length)throw new k("Bad BSON Document: illegal CString");const n=nt.toUTF8(t,e,y,!1);for(y=e=y+1;0!==t[y]&&y<t.length;)y++;if(y>=t.length)throw new k("Bad BSON Document: illegal CString");const r=nt.toUTF8(t,e,y,!1);e=y+1;const o=new Array(r.length);for(y=0;y<r.length;y++)switch(r[y]){case"m":o[y]="m";break;case"s":o[y]="g";break;case"i":o[y]="i"}J=new RegExp(n,o.join(""))}else if(p===x&&!0===s){for(y=e;0!==t[y]&&y<t.length;)y++;if(y>=t.length)throw new k("Bad BSON Document: illegal CString");const n=nt.toUTF8(t,e,y,!1);for(y=e=y+1;0!==t[y]&&y<t.length;)y++;if(y>=t.length)throw new k("Bad BSON Document: illegal CString");const r=nt.toUTF8(t,e,y,!1);e=y+1,J=new Yt(n,r)}else if(p===A){const n=at.getInt32LE(t,e);if(e+=4,n<=0||n>t.length-e||0!==t[e+n-1])throw new k("bad string length in bson");const r=nt.toUTF8(t,e,e+n-1,V);J=c?r:new Gt(r),e+=n}else if(p===j)J=new Zt({i:at.getUint32LE(t,e),t:at.getUint32LE(t,e+4)}),e+=8;else if(p===q)J=new Mt;else if(p===C)J=new Ft;else if(p===$){const n=at.getInt32LE(t,e);if(e+=4,n<=0||n>t.length-e||0!==t[e+n-1])throw new k("bad string length in bson");const r=nt.toUTF8(t,e,e+n-1,V);J=new dt(r),e+=n}else if(p===U){const r=at.getInt32LE(t,e);if(e+=4,r<13)throw new k("code_w_scope total size shorter minimum expected length");const o=at.getInt32LE(t,e);if(e+=4,o<=0||o>t.length-e||0!==t[e+o-1])throw new k("bad string length in bson");const i=nt.toUTF8(t,e,e+o-1,V),s=e+=o,a=at.getInt32LE(t,e),u=ee(t,s,n,!1);if(e+=a,r<8+a+o)throw new k("code_w_scope total size is too short, truncating scope");if(r>8+a+o)throw new k("code_w_scope total size is too long, clips outer document");J=new dt(i,u)}else{if(p!==L)throw new k(`Detected unknown BSON type ${p.toString(16)} for fieldname "${g}"`);{const n=at.getInt32LE(t,e);if(e+=4,n<=0||n>t.length-e||0!==t[e+n-1])throw new k("bad string length in bson");const r=nt.toUTF8(t,e,e+n-1,V);e+=n;const o=nt.allocateUnsafe(12);for(let n=0;n<12;n++)o[n]=t[e+n];const i=new Vt(o);e+=12,J=new yt(r,i)}}"__proto__"===g?Object.defineProperty(m,g,{value:J,writable:!0,enumerable:!0,configurable:!0}):m[g]=J}if(g!==e-y){if(r)throw new k("corrupt array bson");throw new k("corrupt object bson")}if(!F)return m;if(pt(m)){const t=Object.assign({},m);return delete t.$ref,delete t.$id,delete t.$db,new yt(m.$ref,m.$id,m.$db,t)}return m}const ne=/\x00/,re=new Set(["$db","$ref","$id","$clusterTime"]);function oe(t,e,n,r){t[r++]=v,t[(r=r+nt.encodeUTF8Into(t,e,r)+1)-1]=0;const o=nt.encodeUTF8Into(t,n,r+4);return at.setInt32LE(t,r,o+1),r=r+4+o,t[r++]=0,r}function ie(t,e,n,r){const o=!Object.is(n,-0)&&Number.isSafeInteger(n)&&n<=d&&n>=p?P:w;return t[r++]=o,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,r+(o===P?at.setInt32LE(t,r,n):at.setFloat64LE(t,r,n))}function se(t,e,n,r){return t[r++]=R,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,r+at.setBigInt64LE(t,r,n)}function ae(t,e,n,r){return t[r++]=B,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,r}function ue(t,e,n,r){return t[r++]=I,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,t[r++]=n?1:0,r}function ce(t,e,n,r){t[r++]=T,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const o=St.fromNumber(n.getTime()),i=o.getLowBits(),s=o.getHighBits();return(r+=at.setInt32LE(t,r,i))+at.setInt32LE(t,r,s)}function fe(t,e,n,r){if(t[r++]=x,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,n.source&&null!=n.source.match(ne))throw new k("value "+n.source+" must not contain null bytes");return r+=nt.encodeUTF8Into(t,n.source,r),t[r++]=0,n.ignoreCase&&(t[r++]=105),n.global&&(t[r++]=115),n.multiline&&(t[r++]=109),t[r++]=0,r}function le(t,e,n,r){if(t[r++]=x,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,null!=n.pattern.match(ne))throw new k("pattern "+n.pattern+" must not contain null bytes");r+=nt.encodeUTF8Into(t,n.pattern,r),t[r++]=0;const o=n.options.split("").sort().join("");return r+=nt.encodeUTF8Into(t,o,r),t[r++]=0,r}function he(t,e,n,r){return null===n?t[r++]=B:"MinKey"===n._bsontype?t[r++]=q:t[r++]=C,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,r}function de(t,e,n,r){return t[r++]=N,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,r+n.serializeInto(t,r)}function pe(t,e,n,r){t[r++]=E,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const o=n.length;if(r+=at.setInt32LE(t,r,o),t[r++]=F,o<=16)for(let e=0;e<o;e++)t[r+e]=n[e];else t.set(n,r);return r+o}function ye(t,e,n,r,o,i,s,a,u){if(u.has(n))throw new k("Cannot convert circular structure to BSON");u.add(n),t[r++]=Array.isArray(n)?O:_,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const c=Ne(t,n,o,r,i+1,s,a,u);return u.delete(n),c}function ge(t,e,n,r){t[r++]=D,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;for(let e=0;e<16;e++)t[r+e]=n.bytes[e];return r+16}function me(t,e,n,r){t[r++]="Long"===n._bsontype?R:j,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const o=n.getLowBits(),i=n.getHighBits();return(r+=at.setInt32LE(t,r,o))+at.setInt32LE(t,r,i)}function be(t,e,n,r){return n=n.valueOf(),t[r++]=P,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,r+at.setInt32LE(t,r,n)}function we(t,e,n,r){return t[r++]=w,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0,r+at.setFloat64LE(t,r,n.value)}function ve(t,e,n,r){t[r++]=$,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const o=n.toString(),i=nt.encodeUTF8Into(t,o,r+4)+1;return at.setInt32LE(t,r,i),r=r+4+i-1,t[r++]=0,r}function _e(t,e,n,r,o=!1,i=0,s=!1,a=!0,u){if(n.scope&&"object"==typeof n.scope){t[r++]=U,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;let c=r;const f=n.code;r+=4;const l=nt.encodeUTF8Into(t,f,r+4)+1;at.setInt32LE(t,r,l),t[r+4+l-1]=0,r=r+l+4;const h=Ne(t,n.scope,o,r,i+1,s,a,u);r=h-1;const d=h-c;c+=at.setInt32LE(t,c,d),t[r++]=0}else{t[r++]=$,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const o=n.code.toString(),i=nt.encodeUTF8Into(t,o,r+4)+1;at.setInt32LE(t,r,i),r=r+4+i-1,t[r++]=0}return r}function Oe(t,e,n,r){t[r++]=E,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const o=n.buffer;let i=n.position;if(n.sub_type===ut.SUBTYPE_BYTE_ARRAY&&(i+=4),r+=at.setInt32LE(t,r,i),t[r++]=n.sub_type,n.sub_type===ut.SUBTYPE_BYTE_ARRAY&&(i-=4,r+=at.setInt32LE(t,r,i)),n.sub_type===ut.SUBTYPE_VECTOR&&ct(n),i<=16)for(let e=0;e<i;e++)t[r+e]=o[e];else t.set(o,r);return r+n.position}function Ee(t,e,n,r){t[r++]=A,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;const o=nt.encodeUTF8Into(t,n.value,r+4)+1;return at.setInt32LE(t,r,o),r=r+4+o-1,t[r++]=0,r}function Se(t,e,n,r,o,i,s){t[r++]=_,r+=nt.encodeUTF8Into(t,e,r),t[r++]=0;let a=r,u={$ref:n.collection||n.namespace,$id:n.oid};null!=n.db&&(u.$db=n.db),u=Object.assign(u,n.fields);const c=Ne(t,u,!1,r,o+1,i,!0,s),f=c-a;return a+=at.setInt32LE(t,r,f),c}function Ne(t,e,n,r,o,f,d,p){if(null==p){if(null==e)return t[0]=5,t[1]=0,t[2]=0,t[3]=0,t[4]=0,5;if(Array.isArray(e))throw new k("serialize does not support an array as the root input");if("object"!=typeof e)throw new k("serialize does not support non-object as the root input");if("_bsontype"in e&&"string"==typeof e._bsontype)throw new k("BSON types cannot be serialized as a document");if(c(e)||a(e)||i(e)||s(e))throw new k("date, regexp, typedarray, and arraybuffer cannot be BSON documents");p=new Set}p.add(e);let y=r+4;if(Array.isArray(e))for(let r=0;r<e.length;r++){const s=`${r}`;let u=e[r];"function"==typeof u?.toBSON&&(u=u.toBSON());const g=typeof u;if(void 0===u)y=ae(t,s,0,y);else if(null===u)y=ae(t,s,0,y);else if("string"===g)y=oe(t,s,u,y);else if("number"===g)y=ie(t,s,u,y);else if("bigint"===g)y=se(t,s,u,y);else if("boolean"===g)y=ue(t,s,u,y);else if("object"===g&&null==u._bsontype)y=u instanceof Date||c(u)?ce(t,s,u,y):u instanceof Uint8Array||i(u)?pe(t,s,u,y):u instanceof RegExp||a(u)?fe(t,s,u,y):ye(t,s,u,y,n,o,f,d,p);else if("object"===g){if(u[h]!==l)throw new V;if("ObjectId"===u._bsontype)y=de(t,s,u,y);else if("Decimal128"===u._bsontype)y=ge(t,s,u,y);else if("Long"===u._bsontype||"Timestamp"===u._bsontype)y=me(t,s,u,y);else if("Double"===u._bsontype)y=we(t,s,u,y);else if("Code"===u._bsontype)y=_e(t,s,u,y,n,o,f,d,p);else if("Binary"===u._bsontype)y=Oe(t,s,u,y);else if("BSONSymbol"===u._bsontype)y=Ee(t,s,u,y);else if("DBRef"===u._bsontype)y=Se(t,s,u,y,o,f,p);else if("BSONRegExp"===u._bsontype)y=le(t,s,u,y);else if("Int32"===u._bsontype)y=be(t,s,u,y);else if("MinKey"===u._bsontype||"MaxKey"===u._bsontype)y=he(t,s,u,y);else if(void 0!==u._bsontype)throw new k(`Unrecognized or invalid _bsontype: ${String(u._bsontype)}`)}else"function"===g&&f&&(y=ve(t,s,u,y))}else if(e instanceof Map||u(e)){const r=e.entries();let s=!1;for(;!s;){const e=r.next();if(s=!!e.done,s)continue;const u=e.value?e.value[0]:void 0;let g=e.value?e.value[1]:void 0;"function"==typeof g?.toBSON&&(g=g.toBSON());const m=typeof g;if("string"==typeof u&&!re.has(u)){if(null!=u.match(ne))throw new k("key "+u+" must not contain null bytes");if(n){if("$"===u[0])throw new k("key "+u+" must not start with '$'");if(u.includes("."))throw new k("key "+u+" must not contain '.'")}}if(void 0===g)!1===d&&(y=ae(t,u,0,y));else if(null===g)y=ae(t,u,0,y);else if("string"===m)y=oe(t,u,g,y);else if("number"===m)y=ie(t,u,g,y);else if("bigint"===m)y=se(t,u,g,y);else if("boolean"===m)y=ue(t,u,g,y);else if("object"===m&&null==g._bsontype)y=g instanceof Date||c(g)?ce(t,u,g,y):g instanceof Uint8Array||i(g)?pe(t,u,g,y):g instanceof RegExp||a(g)?fe(t,u,g,y):ye(t,u,g,y,n,o,f,d,p);else if("object"===m){if(g[h]!==l)throw new V;if("ObjectId"===g._bsontype)y=de(t,u,g,y);else if("Decimal128"===g._bsontype)y=ge(t,u,g,y);else if("Long"===g._bsontype||"Timestamp"===g._bsontype)y=me(t,u,g,y);else if("Double"===g._bsontype)y=we(t,u,g,y);else if("Code"===g._bsontype)y=_e(t,u,g,y,n,o,f,d,p);else if("Binary"===g._bsontype)y=Oe(t,u,g,y);else if("BSONSymbol"===g._bsontype)y=Ee(t,u,g,y);else if("DBRef"===g._bsontype)y=Se(t,u,g,y,o,f,p);else if("BSONRegExp"===g._bsontype)y=le(t,u,g,y);else if("Int32"===g._bsontype)y=be(t,u,g,y);else if("MinKey"===g._bsontype||"MaxKey"===g._bsontype)y=he(t,u,g,y);else if(void 0!==g._bsontype)throw new k(`Unrecognized or invalid _bsontype: ${String(g._bsontype)}`)}else"function"===m&&f&&(y=ve(t,u,g,y))}}else{if("function"==typeof e?.toBSON&&null!=(e=e.toBSON())&&"object"!=typeof e)throw new k("toBSON function did not return an object");for(const r of Object.keys(e)){let s=e[r];"function"==typeof s?.toBSON&&(s=s.toBSON());const u=typeof s;if("string"==typeof r&&!re.has(r)){if(null!=r.match(ne))throw new k("key "+r+" must not contain null bytes");if(n){if("$"===r[0])throw new k("key "+r+" must not start with '$'");if(r.includes("."))throw new k("key "+r+" must not contain '.'")}}if(void 0===s)!1===d&&(y=ae(t,r,0,y));else if(null===s)y=ae(t,r,0,y);else if("string"===u)y=oe(t,r,s,y);else if("number"===u)y=ie(t,r,s,y);else if("bigint"===u)y=se(t,r,s,y);else if("boolean"===u)y=ue(t,r,s,y);else if("object"===u&&null==s._bsontype)y=s instanceof Date||c(s)?ce(t,r,s,y):s instanceof Uint8Array||i(s)?pe(t,r,s,y):s instanceof RegExp||a(s)?fe(t,r,s,y):ye(t,r,s,y,n,o,f,d,p);else if("object"===u){if(s[h]!==l)throw new V;if("ObjectId"===s._bsontype)y=de(t,r,s,y);else if("Decimal128"===s._bsontype)y=ge(t,r,s,y);else if("Long"===s._bsontype||"Timestamp"===s._bsontype)y=me(t,r,s,y);else if("Double"===s._bsontype)y=we(t,r,s,y);else if("Code"===s._bsontype)y=_e(t,r,s,y,n,o,f,d,p);else if("Binary"===s._bsontype)y=Oe(t,r,s,y);else if("BSONSymbol"===s._bsontype)y=Ee(t,r,s,y);else if("DBRef"===s._bsontype)y=Se(t,r,s,y,o,f,p);else if("BSONRegExp"===s._bsontype)y=le(t,r,s,y);else if("Int32"===s._bsontype)y=be(t,r,s,y);else if("MinKey"===s._bsontype||"MaxKey"===s._bsontype)y=he(t,r,s,y);else if(void 0!==s._bsontype)throw new k(`Unrecognized or invalid _bsontype: ${String(s._bsontype)}`)}else"function"===u&&f&&(y=ve(t,r,s,y))}}p.delete(e),t[y++]=0;const g=y-r;return r+=at.setInt32LE(t,r,g),y}const Ie={$oid:Vt,$binary:ut,$uuid:ut,$symbol:Gt,$numberInt:Ct,$numberDecimal:Dt,$numberDouble:qt,$numberLong:St,$minKey:Mt,$maxKey:Ft,$regex:Yt,$regularExpression:Yt,$timestamp:Zt};function Te(t,e={}){if("number"==typeof t){const n=t<=d&&t>=p,r=t<=y&&t>=g;if(e.relaxed||e.legacy)return t;if(Number.isInteger(t)&&!Object.is(t,-0)){if(n)return new Ct(t);if(r)return e.useBigInt64?BigInt(t):St.fromNumber(t)}return new qt(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;const n=Object.keys(t).filter(e=>e.startsWith("$")&&null!=t[e]);for(let r=0;r<n.length;r++){const o=Ie[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){const n=t.$date,r=new Date;if(e.legacy)if("number"==typeof n)r.setTime(n);else if("string"==typeof n)r.setTime(Date.parse(n));else{if("bigint"!=typeof n)throw new z("Unrecognized type for EJSON date: "+typeof n);r.setTime(Number(n))}else if("string"==typeof n)r.setTime(Date.parse(n));else if(St.isLong(n))r.setTime(n.toNumber());else if("number"==typeof n&&e.relaxed)r.setTime(n);else{if("bigint"!=typeof n)throw new z("Unrecognized type for EJSON date: "+typeof n);r.setTime(Number(n))}return r}if(null!=t.$code){const e=Object.assign({},t);return t.$scope&&(e.$scope=Te(t.$scope)),dt.fromExtendedJSON(t)}if(pt(t)||t.$dbPointer){const e=t.$ref?t:t.$dbPointer;if(e instanceof yt)return e;const n=Object.keys(e).filter(t=>t.startsWith("$"));let r=!0;if(n.forEach(t=>{-1===["$ref","$id","$db"].indexOf(t)&&(r=!1)}),r)return yt.fromExtendedJSON(e)}return t}function Be(t){const e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function xe(t,e){if(t instanceof Map||u(t)){const n=Object.create(null);for(const[e,r]of t){if("string"!=typeof e)throw new k("Can only serialize maps with string keys");n[e]=r}return xe(n,e)}if(("object"==typeof t||"function"==typeof t)&&null!==t){const n=e.seenObjects.findIndex(e=>e.obj===t);if(-1!==n){const t=e.seenObjects.map(t=>t.propertyName),r=t.slice(0,n).map(t=>`${t} -> `).join(""),o=t[n],i=" -> "+t.slice(n+1,t.length-1).map(t=>`${t} -> `).join(""),s=t[t.length-1],a=" ".repeat(r.length+o.length/2),u="-".repeat(i.length+(o.length+s.length)/2-1);throw new k(`Converting circular structure to EJSON:\n ${r}${o}${i}${s}\n ${a}\\${u}/`)}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((t,n)=>{e.seenObjects.push({propertyName:`index ${n}`,obj:null});try{return xe(t,e)}finally{e.seenObjects.pop()}})}(t,e);if(void 0===t)return null;if(t instanceof Date||c(t)){const n=t.getTime(),r=n>-1&&n<2534023188e5;return e.legacy?e.relaxed&&r?{$date:t.getTime()}:{$date:Be(t)}:e.relaxed&&r?{$date:Be(t)}:{$date:{$numberLong:t.getTime().toString()}}}if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Number.isInteger(t)&&!Object.is(t,-0)){if(t>=p&&t<=d)return{$numberInt:t.toString()};if(t>=g&&t<=y)return{$numberLong:t.toString()}}return{$numberDouble:Object.is(t,-0)?"-0.0":t.toString()}}if("bigint"==typeof t)return e.relaxed?Number(BigInt.asIntN(64,t)):{$numberLong:BigInt.asIntN(64,t).toString()};if(t instanceof RegExp||a(t)){let n=t.flags;if(void 0===n){const e=t.toString().match(/[gimuy]*$/);e&&(n=e[0])}return new Yt(t.source,n).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new k("not an object instance");const n=t._bsontype;if(void 0===n){const n={};for(const r of Object.keys(t)){e.seenObjects.push({propertyName:r,obj:null});try{const o=xe(t[r],e);"__proto__"===r?Object.defineProperty(n,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):n[r]=o}finally{e.seenObjects.pop()}}return n}if(null!=t&&"object"==typeof t&&"string"==typeof t._bsontype&&t[h]!==l)throw new V;if(function(t){return null!=t&&"object"==typeof t&&"_bsontype"in t&&"string"==typeof t._bsontype}(t)){let r=t;if("function"!=typeof r.toExtendedJSON){const e=Le[t._bsontype];if(!e)throw new k("Unrecognized or invalid _bsontype: "+t._bsontype);r=e(r)}return"Code"===n&&r.scope?r=new dt(r.code,xe(r.scope,e)):"DBRef"===n&&r.oid&&(r=new yt(xe(r.collection,e),xe(r.oid,e),xe(r.db,e),xe(r.fields,e))),r.toExtendedJSON(e)}throw new k("_bsontype must be a string, but was: "+typeof n)}(t,e):t}const Le={Binary:t=>new ut(t.value(),t.sub_type),Code:t=>new dt(t.code,t.scope),DBRef:t=>new yt(t.collection||t.namespace,t.oid,t.db,t.fields),Decimal128:t=>new Dt(t.bytes),Double:t=>new qt(t.value),Int32:t=>new Ct(t.value),Long:t=>St.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_),MaxKey:()=>new Ft,MinKey:()=>new Mt,ObjectId:t=>new Vt(t),BSONRegExp:t=>new Yt(t.pattern,t.options),BSONSymbol:t=>new Gt(t.value),Timestamp:t=>Zt.fromBits(t.low,t.high)};function $e(t,e){const n={useBigInt64:e?.useBigInt64??!1,relaxed:e?.relaxed??!0,legacy:e?.legacy??!1};return JSON.parse(t,(t,e)=>{if(-1!==t.indexOf("\0"))throw new k(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(t)}`);return Te(e,n)})}function Ae(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);const o=xe(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}const Ue=Object.create(null);Ue.parse=$e,Ue.stringify=Ae,Ue.serialize=function(t,e){return e=e||{},JSON.parse(Ae(t,e))},Ue.deserialize=function(t,e){return e=e||{},$e(JSON.stringify(t),e)},Object.freeze(Ue);function Pe(t,e){try{return at.getNonnegativeInt32LE(t,e)}catch(t){throw new H("BSON size cannot be negative",e,{cause:t})}}function je(t,e){let n=e;for(;0!==t[n];n++);if(n===t.length-1)throw new H("Null terminator not found",e);return n}const Re=Object.create(null);Re.parseToElements=function(t,e=0){if(e??=0,t.length<5)throw new H(`Input must be at least 5 bytes, got ${t.length} bytes`,e);const n=Pe(t,e);if(n>t.length-e)throw new H(`Parsed documentSize (${n} bytes) does not match input length (${t.length} bytes)`,e);if(0!==t[e+n-1])throw new H("BSON documents must end in 0x00",e+n);const r=[];let o=e+4;for(;o<=n+e;){const i=t[o];if(o+=1,0===i){if(o-e!==n)throw new H("Invalid 0x00 type byte",o);break}const s=o,a=je(t,o)-s;let u;if(o+=a+1,1===i||18===i||9===i||17===i)u=8;else if(16===i)u=4;else if(7===i)u=12;else if(19===i)u=16;else if(8===i)u=1;else if(10===i||6===i||127===i||255===i)u=0;else if(11===i)u=je(t,je(t,o)+1)+1-o;else if(3===i||4===i||15===i)u=Pe(t,o);else{if(2!==i&&5!==i&&12!==i&&13!==i&&14!==i)throw new H(`Invalid 0x${i.toString(16).padStart(2,"0")} type byte`,o);u=Pe(t,o)+4,5===i&&(u+=1),12===i&&(u+=12)}if(u>n)throw new H("value reports length larger than document",o);r.push([i,s,a,o,u]),o+=u}return r},Re.ByteUtils=nt,Re.NumberUtils=at,Object.freeze(Re);const De=17825792;let qe=nt.allocate(De);function Ce(t){qe.length<t&&(qe=nt.allocate(t))}function Fe(t,e={}){const n="boolean"==typeof e.checkKeys&&e.checkKeys,r="boolean"==typeof e.serializeFunctions&&e.serializeFunctions,o="boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined,i="number"==typeof e.minInternalBufferSize?e.minInternalBufferSize:De;qe.length<i&&(qe=nt.allocate(i));const s=Ne(qe,t,n,0,0,r,o,null),a=nt.allocateUnsafe(s);return a.set(qe.subarray(0,s),0),a}function Me(t,e,n={}){const r="boolean"==typeof n.checkKeys&&n.checkKeys,o="boolean"==typeof n.serializeFunctions&&n.serializeFunctions,i="boolean"!=typeof n.ignoreUndefined||n.ignoreUndefined,s="number"==typeof n.index?n.index:0,a=Ne(qe,t,r,0,0,o,i,null);return e.set(qe.subarray(0,a),s),s+a-1}function Je(t,e={}){return Xt(nt.toLocalBufferType(t),e)}function ke(t,e={}){return zt(t,"boolean"==typeof(e=e||{}).serializeFunctions&&e.serializeFunctions,"boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined)}function Ve(t,e,n,r,o,i){const s=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},i),a=nt.toLocalBufferType(t);let u=e;for(let t=0;t<n;t++){const e=at.getInt32LE(a,u);s.index=u,r[o+t]=Xt(a,s),u+=e}return u}var ze=Object.freeze({__proto__:null,BSONError:k,BSONOffsetError:H,BSONRegExp:Yt,BSONRuntimeError:z,BSONSymbol:Gt,BSONType:J,BSONValue:rt,BSONVersionError:V,Binary:ut,Code:dt,DBRef:yt,Decimal128:Dt,Double:qt,EJSON:Ue,Int32:Ct,Long:St,MaxKey:Ft,MinKey:Mt,ObjectId:Vt,Timestamp:Zt,UUID:ht,calculateObjectSize:ke,deserialize:Je,deserializeStream:Ve,onDemand:Re,serialize:Fe,serializeWithBufferAndIndex:Me,setInternalBufferSize:Ce})}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}return n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(198)})());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_functions",[],e):"object"==typeof exports?exports.cloudbase_functions=e():t.cloudbase_functions=e()}("undefined"!=typeof window?window:this,()=>(()=>{var t={829:(t,e,r)=>{"use strict";var n;r.r(e),r.d(e,{AbstractSDKRequest:()=>o,AbstractStorage:()=>a,StorageType:()=>n,formatUrl:()=>i}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},a=function(){};function i(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var a in r)""===o?!n&&(e+="?"):o+="&",o+=a+"="+encodeURIComponent(r[a]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},253:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(i,c)}s((n=n.apply(t,e||[])).next())})},a=this&&this.__generator||function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerCloudrun=e.requestContainer=void 0;var i=r(877).constants.ERRORS,c="cloudrun",s=function(){function t(){}return t.prototype.callContainer=function(t,e){return o(this,void 0,void 0,function(){var r,o,s;return a(this,function(a){switch(a.label){case 0:if(r=t.name,o=t.data,!r)throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"[".concat(c,".callContainer] invalid name")}));try{s=o?JSON.stringify(o):""}catch(t){throw new Error(JSON.stringify({code:i.INVALID_PARAMS,msg:"[".concat(c,".callContainer] invalid data")}))}return[4,u.call(this,n(n({},t),{data:s}),e)];case 1:return[2,a.sent()]}})})},t}();function u(t,e){var r;return o(this,void 0,void 0,function(){var o,i,c,s,u,l,f,d,p,h,v,y,b,g,m;return a(this,function(a){switch(a.label){case 0:if(o=t.name,i=t.data,c=t.path,s=void 0===c?"":c,u=t.method,l=t.header,f=void 0===l?{}:l,d=this.getEndPointWithKey("GATEWAY"),p=d.BASE_URL,h=d.PROTOCOL,v="".concat(h).concat(p,"/cloudrun/").concat(o),y=s.startsWith("/")?s:"/".concat(s),b=["GET","HEAD"].includes(null===(r=null==u?void 0:u.toUpperCase)||void 0===r?void 0:r.call(u)))try{g={};try{g=JSON.parse(i)}catch(t){g=i||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(g).map(function(t){return"".concat(t,"=").concat(g[t])}).join("&"))}catch(t){}return[4,this.request.fetch(n(n({method:u||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},f)},b?{}:{body:i}),{url:"".concat(v).concat(y),customReqOpts:e}))];case 1:return m=a.sent(),"node-sdk"===(null==e?void 0:e.from)?[2,m]:[4,m.data];case 2:return[2,a.sent()]}})})}e.requestContainer=u;var l=new s,f={name:c,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(f)}catch(t){}function d(t){try{t.registerComponent(f)}catch(t){console.warn(t)}}e.registerCloudrun=d;try{window.registerCloudrun=d}catch(t){}},60:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__decorate||function(t,e,r,n){var o,a=arguments.length,i=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(t,e,r,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(i=(a<3?o(i):a>3?o(e,r,i):o(e,r))||i);return a>3&&i&&Object.defineProperty(e,r,i),i},a=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(i,c)}s((n=n.apply(t,e||[])).next())})},c=this&&this.__generator||function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerFunctions=void 0;var s=r(388),u=r(877),l=r(253),f=u.constants.getSdkName,d=u.constants.ERRORS,p=u.constants.COMMUNITY_SITE_URL,h=u.utils.execCallback,v=u.helpers.catchErrorsDecorator,y="functions",b=new(function(){function t(){}var e,r,b;return t.prototype.callFunction=function(t,e,r){var o,a,s;return i(this,void 0,void 0,function(){var i,p,v,b,g,m,_,w,O,S,E,I,j,P,R,x,A,N,C,k,M,T,L;return c(this,function(c){switch(c.label){case 0:if(i=t.name,p=t.data,v=t.query,b=t.parse,g=t.search,m=t.type,_=t.path,w=void 0===_?"":_,O=t.method,S=t.header,E=void 0===S?{}:S,!i)throw new Error(JSON.stringify({code:d.INVALID_PARAMS,msg:"[".concat(y,".callFunction] invalid function name")}));try{I=p?JSON.stringify(p):""}catch(t){throw new Error(JSON.stringify({code:d.INVALID_PARAMS,msg:"[".concat(y,".callFunction] invalid data")}))}return"cloudrun"!==m?[3,2]:(j=u.utils.generateRequestId(),[4,l.requestContainer.call(this,{name:i,data:I,path:w,method:O,header:n(n({},E),{"X-Request-Id":j})})]);case 1:return[2,{result:T=c.sent(),requestId:j}];case 2:R=(P=this).request,x=P.config,A="functions.invokeFunction",N={inQuery:v,parse:b,search:g,function_name:i,request_data:I},C={},k=!("GATEWAY"!==x.endPointMode||(D=i,"lcap-common-service"===D||"lcap-datasource-test"===D||D.startsWith("lcap-data")||D.startsWith("lowcode-datasource")||"cloudbase_module"===D)||function(t){return"lowcode-wx-datasource"===t}(i)),c.label=3;case 3:return c.trys.push([3,8,,9]),k?[4,R.gateWay(n(n({},t),{path:"functions"}),r)]:[3,5];case 4:return M=c.sent(),C=n({requestId:M.requestId},(null===(o=M.data)||void 0===o?void 0:o.code)?M.data:{data:{response_data:M.data}}),[3,7];case 5:return[4,R.send(A,N,{endPointMode:"CLOUD_API",defaultQuery:(null===(a=null==p?void 0:p.params)||void 0===a?void 0:a.action)?{action:null===(s=null==p?void 0:p.params)||void 0===s?void 0:s.action}:{}},r)];case 6:C=c.sent(),c.label=7;case 7:if(C.code)return[2,h(e,null,C)];if(T=C.data.response_data,b||k)return[2,h(e,null,{result:T,requestId:C.requestId})];try{return T=JSON.parse(C.data.response_data),[2,h(e,null,{result:T,requestId:C.requestId})]}catch(t){h(e,new Error("[".concat(f(),"][").concat(d.INVALID_PARAMS,"][").concat(y,".callFunction] response data must be json")))}return[3,9];case 8:return L=c.sent(),h(e,L),[3,9];case 9:return[2]}var D})})},o([v({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(p)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(e=void 0!==s.ICallFunctionOptions&&s.ICallFunctionOptions)?e:Object,"function"==typeof(r="undefined"!=typeof Function&&Function)?r:Object,"function"==typeof(b=void 0!==s.ICustomReqOpts&&s.ICustomReqOpts)?b:Object]),a("design:returntype",Promise)],t.prototype,"callFunction",null),t}()),g={name:y,entity:{callFunction:b.callFunction}};try{cloudbase.registerComponent(g)}catch(t){}e.registerFunctions=function(t){try{t.registerComponent(g)}catch(t){console.warn(t)}}},563:function(t,e,r){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),a=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&o(e,t,r);return a(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var c,s=i(r(92)),u=r(962);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(c=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,o=(0,u.isArray)(t)?t:[t];r<o.length;r++){var a=o[r],i=a.isMatch,c=a.genAdapter,s=a.runtime;if(i())return{adapter:n({isMatch:i},c(e)),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:n({},s.genAdapter()),runtime:c.WEB}}},92:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),a=this&&this.__assign||function(){return a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(i,c)}s((n=n.apply(t,e||[])).next())})},c=this&&this.__generator||function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var s=r(829),u=r(962),l=r(464),f=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,a=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=a||["get","post","upload","download"],r}return o(e,t),e.prototype.get=function(t){return this.request(a(a({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(a(a({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(a(a({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,i=t.headers,c=void 0===i?{}:i,s={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===s?(Object.keys(e).forEach(function(t){u.append(t,e[t])}),u.append("key",n),u.append("file",r),this.request(a(a({},t),{data:u,method:s}),this.restrictedMethods.includes("upload"))):this.request(a(a({},t),{method:"put",headers:c,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return i(this,void 0,Promise,function(){var e,r,n,o;return c(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(a(a({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return i(this,void 0,Promise,function(){var r,n,o,s,u,l,f,d,p,h,v,y,b,g=this;return c(this,function(m){switch(m.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,s=void 0!==o&&o,u=t.stream,l=void 0!==u&&u,f=t.signal,d=t.timeout,p=t.shouldThrowOnError,h=void 0===p||p,v=null!=d?d:this.timeout,f&&(f.aborted&&r.abort(),f.addEventListener("abort",function(){return r.abort()})),y=null,s&&v&&(y=setTimeout(function(){console.warn(g.timeoutMsg),r.abort(new Error(g.timeoutMsg))},v)),[4,fetch(n,a(a({},t),{signal:r.signal})).then(function(t){return i(g,void 0,void 0,function(){var e,r,n;return c(this,function(o){switch(o.label){case 0:return clearTimeout(y),h?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(y),Promise.reject(t)})];case 1:return b=m.sent(),[2,{data:l?b.body:(null===(e=b.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?b.json():b.text(),statusCode:b.status,header:b.headers,response:b}]}})})},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise(function(o){var a=t.url,i=t.headers,c=void 0===i?{}:i,s=t.data,f=t.responseType,d=t.withCredentials,p=t.body,h=t.onUploadProgress,v=(0,u.formatUrl)((0,l.getProtocol)(),a,"get"===n?s:{}),y=new XMLHttpRequest;y.open(n,v),f&&(y.responseType=f);var b,g,m=t.signal;m&&(m.aborted?y.abort():m.addEventListener("abort",function(){return y.abort()},{once:!0})),Object.keys(c).forEach(function(t){y.setRequestHeader(t,c[t])}),h&&y.upload.addEventListener("progress",h),y.onreadystatechange=function(){var t={};if(4===y.readyState){var e=y.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach(function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o}),t.header=r,t.statusCode=y.status;try{t.data="blob"===f?y.response:JSON.parse(y.responseText)}catch(e){t.data="blob"===f?y.response:y.responseText}clearTimeout(b),o(t)}},e&&r.timeout&&(b=setTimeout(function(){console.warn(r.timeoutMsg),y.abort()},r.timeout)),g=(0,u.isFormData)(s)?s:"application/x-www-form-urlencoded"===c["content-type"]?(0,u.toQueryString)(s):p||(s?JSON.stringify(s):void 0),d&&(y.withCredentials=!0),y.send(g)})},e}(s.AbstractSDKRequest);e.WebRequest=f,e.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage}}},464:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},778:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(464),e),o(r(519),e),e.OATUH_LOGINTYPE="constants"},517:function(t,e,r){"use strict";var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(i,c)}s((n=n.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var a=r(962),i=r(778),c=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(c=-1!==navigator.userAgent.indexOf("Firefox"));var s=c?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var a,i=e.stack.split("\n"),s=c?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=c?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),f=i.findIndex(function(t){return s.test(t)});if(-1!==f){var d=i.filter(function(t,e){return e>f});d.unshift(i[f].replace(l,"".concat(r,".").concat(n)).replace(u,o)),(a=new Error).stack="".concat(c?"@debugger":"Error","\n").concat(d.join("\n"))}return a}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,c=t.customInfo,f=void 0===c?{}:c,d=t.title,p=t.messages,h=void 0===p?[]:p;return function(t,e,c){if(i.IS_DEBUG_MODE){var p=f.className||t.constructor.name,v=f.methodName||e,y=c.value,b=function(){var t="",e=(new Error).stack.split("\n"),r=e.findIndex(function(t){return s.test(t)});if(-1!==r){var n=u.exec(e[r+1]||"");t=n?n[0]:""}return t}();c.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=l({err:new Error,className:p,methodName:v,sourceLink:b});try{return y.apply(this,t)}catch(t){var n=t,o=t.message,i=t.error,c=t.error_description,s={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);s.subtitle=o,u.code&&(r?(r.code=u.code,r.msg=u.msg):(t.code=u.code,t.message=u.msg),n=r||t,s.content=h.map(function(t){return{type:"info",body:t}}))}throw i&&c&&(s.subtitle=c,r?(r.code=i,r.msg=c):(t.code=i,t.message=c),n=r||t,s.content=h.map(function(t){return{type:"info",body:t}})),(0,a.printGroupLog)(s),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,function(){var e,r,n,i,c,s,u,f;return o(this,function(o){switch(o.label){case 0:e=l({err:new Error,className:p,methodName:v,sourceLink:b}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,t)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,i=r.message,c=r.error,s=r.error_description,u={title:d||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:r}]},i&&/^\{.*\}$/.test(i)&&(f=JSON.parse(i),u.subtitle=f,f.code&&(e?(e.code=f.code,e.message=f.msg):(r.code=f.code,r.message=f.msg),n=e||r,u.content=h.map(function(t){return{type:"info",body:t}}))),c&&s&&(u.subtitle=s,e?(e.code=c,e.msg=s):(r.code=c,r.message=s),n=e||r,u.content=h.map(function(t){return{type:"info",body:t}})),(0,a.printGroupLog)(u),n;case 4:return[2]}})})}}}}},260:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(517),e)},877:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&n(e,t,r);return o(e,t),e},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.langEvent=e.AbortController=e.jwt=e.helpers=e.utils=e.events=e.cache=e.adapters=e.constants=void 0;var c=a(r(778));e.constants=c;var s=a(r(563));e.adapters=s;var u=a(r(865));e.cache=u;var l=a(r(940));e.events=l;var f=a(r(991));e.langEvent=f;var d=a(r(962));e.utils=d;var p=a(r(260));e.helpers=p;var h=i(r(644));e.AbortController=h.default;var v={decode:i(r(949)).default};e.jwt=v},644:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,r){"abort"===e&&t.listeners.push(r)}}}return t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach(function(t){return t()}))},t}();e.default=r},865:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),a=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(i,c)}s((n=n.apply(t,e||[])).next())})},i=this&&this.__generator||function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var c=r(829),s=r(962),u=r(778),l=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(c.AbstractStorage),f=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,a=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:((0,s.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(e.root));case"none":return new l(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=a)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,s.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return a(this,void 0,void 0,function(){var n;return i(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,s.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return a(this,void 0,void 0,function(){var n;return i(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,s.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return a(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})},t}();e.CloudbaseCache=f},940:function(t,e,r){"use strict";var n,o=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),a=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var i=r(962),c=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=c;var s=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(c);e.IErrorEvent=s;var u=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,i.isInstanceOf)(t,s))return console.error(t.error),this;var r=(0,i.isString)(t)?new c(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,u=this.listeners[n]?a([],this.listeners[n],!0):[];o<u.length;o++)u[o].call(this,r)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var l=new u;e.addEventListener=function(t,e){l.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),l.fire(t,e)},e.removeEventListener=function(t,e){l.off(t,e)}},991:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LANG_CHANGE_EVENT=e.bus=void 0;var n=r(940);e.bus=new n.CloudbaseEventEmitter,e.LANG_CHANGE_EVENT="lang_change"},962:function(t,e,r){"use strict";var n=this&&this.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(778);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)})},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach(function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))}),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))}),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var a=(n=o.split("&")).length-1;a>=0;a-=1)n[a].split("=")[0]===t&&n.splice(a,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise(function(e,r){t=function(t,n){return t?r(t):e(n)}});return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,a=t.content,i=void 0===a?[]:a,c=t.printTrace,s=void 0!==c&&c,u=t.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,f=i;l<f.length;l++){var d=f[l],p=d.type,h=d.body;switch(p){case"info":console.log(h);break;case"warn":console.warn(h);break;case"error":console.error(h)}}s&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)},e.sleep=function(t){return void 0===t&&(t=0),new Promise(function(e){return setTimeout(e,t)})},e.transformPhone=function(t){return"+86".concat(t)},e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach(function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)}),e},e.parseCaptcha=function(t){var r={},o=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){t=o[1];var a=o[2];a&&(r=(0,e.parseQueryString)(a))}var i=r.token,c=n(r,["token"]);return/^data:/.test(t)&&!i?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:i?{state:c.state,token:i,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},388:t=>{t.exports={}},949:(t,e,r)=>{"use strict";function n(t){this.message=t}r.r(e),r.d(e,{InvalidTokenError:()=>i,default:()=>c}),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,a=0,i=0,c="";o=e.charAt(i++);~o&&(r=a%4?64*r+o:o,a++%4)?c+=String.fromCharCode(255&r>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function a(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(o(t).replace(/(.)/g,function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(e)}catch(t){return o(e)}}function i(t){this.message=t}i.prototype=new Error,i.prototype.name="InvalidTokenError";const c=function(t,e){if("string"!=typeof t)throw new i("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(a(t.split(".")[r]))}catch(t){throw new i("Invalid token specified: "+t.message)}}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={exports:{}};return t[n].call(a.exports,a,a.exports,r),a.exports}return r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r(60)})());
|