@cloudbase/js-sdk 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apis/dist/index.d.ts +1 -0
- package/apis/dist/index.esm.js +3 -0
- package/apis/dist/index.js +21 -0
- package/apis/package.json +6 -0
- package/auth/dist/index.esm.js +5 -1
- package/auth/dist/index.js +6 -2
- package/container/dist/index.esm.js +5 -1
- package/container/dist/index.js +6 -2
- package/database/dist/index.esm.js +5 -1
- package/database/dist/index.js +6 -2
- package/dist/index.cjs.js +6 -3
- package/dist/index.esm.js +6 -3
- package/functions/dist/index.esm.js +5 -1
- package/functions/dist/index.js +6 -2
- package/index.d.ts +841 -328
- package/miniprogram_dist/ai.js +1 -1
- package/miniprogram_dist/analytics.js +1 -1
- package/miniprogram_dist/apis.js +1 -0
- package/miniprogram_dist/app.js +1 -1
- package/miniprogram_dist/auth.js +1 -1
- package/miniprogram_dist/cloudrun.js +1 -1
- package/miniprogram_dist/container.js +1 -1
- package/miniprogram_dist/database.js +1 -2
- package/miniprogram_dist/functions.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/miniprogram_dist/model.js +1 -1
- package/miniprogram_dist/mysql.js +1 -0
- package/miniprogram_dist/oauth.js +1 -1
- package/miniprogram_dist/realtime.js +1 -1
- package/miniprogram_dist/storage.js +1 -1
- package/mysql/dist/index.d.ts +1 -0
- package/mysql/dist/index.esm.js +3 -0
- package/mysql/dist/index.js +21 -0
- package/mysql/package.json +6 -0
- package/package.json +16 -14
- package/realtime/dist/index.esm.js +5 -1
- package/realtime/dist/index.js +6 -2
|
@@ -1,2 +1 @@
|
|
|
1
|
-
/*! For license information please see database.js.LICENSE.txt */
|
|
2
|
-
!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,(()=>(()=>{"use strict";var t={258:function(t,e,n){var r=this&&this.__assign||function(){return r=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},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var o=n(358),i={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,i=e.runtime;return o.Db.reqClass=this.request.constructor,o.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},o.Db.runtime=i,this.wsClientClass&&(o.Db.wsClass=n.wsClass,o.Db.wsClientClass=this.wsClientClass),o.Db.ws||(o.Db.ws=null),new o.Db(r(r(r({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(i)}catch(t){}e.registerDatabase=function(t){try{t.registerComponent(i)}catch(t){console.warn(t)}}},358:(t,e,n)=>{n.r(e),n.d(e,{CollectionReference:()=>dn,Db:()=>Un,DocumentReference:()=>$t,Query:()=>qt});var r,o,i={};n.r(i),n.d(i,{LineString:()=>Q,MultiLineString:()=>et,MultiPoint:()=>K,MultiPolygon:()=>rt,Point:()=>W,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 u,s,a="Object",f="GeoPoint",c="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",l="GeoMultiLineString",d="GeoMultiPolygon",y="Date",g="ServerDate",m=["desc","asc"],w=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(u||(u={})),(r={})[u.eq]="$eq",r[u.lt]="$lt",r[u.lte]="$lte",r[u.gt]="$gt",r[u.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(s||(s={}));var b=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=[],_={},E=function(t){function e(e,n){if(n!==_)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return b(e,t),e.for=function(t){for(var n=0,r=v.length;n<r;n++)if(v[n].target===t)return v[n].instance;var o=new e(t,_);return v.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})}));const O=E;var S=O.for("UNSET_FIELD_NAME"),N=O.for("UPDATE_COMMAND"),x=O.for("QUERY_COMMAND"),I=O.for("LOGIC_COMMAND"),T=O.for("GEO_POINT"),A=O.for("SYMBOL_GEO_LINE_STRING"),B=O.for("SYMBOL_GEO_POLYGON"),j=O.for("SYMBOL_GEO_MULTI_POINT"),P=O.for("SYMBOL_GEO_MULTI_LINE_STRING"),L=O.for("SYMBOL_GEO_MULTI_POLYGON"),U=O.for("SERVER_DATE"),$=O.for("REGEXP"),R=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 U},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function M(t){return new R(t)}var D,q=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.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 u},C=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 f:o=new W(i.coordinates[0],i.coordinates[1]);break;case c:o=new Q(i.coordinates.map((function(t){return new W(t[0],t[1])})));break;case h:o=new X(i.coordinates.map((function(t){return new Q(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new W(n,r)})))})));break;case p:o=new K(i.coordinates.map((function(t){return new W(t[0],t[1])})));break;case l:o=new et(i.coordinates.map((function(t){return new Q(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new W(n,r)})))})));break;case d:o=new rt(i.coordinates.map((function(t){return new X(t.map((function(t){return new Q(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new W(n,r)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case a: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===a){if(t instanceof W)return f;if(t instanceof Date)return y;if(t instanceof R)return g;t.$timestamp?e=y:t.$date?e=g:W.validate(t)?e=f:Q.validate(t)?e=c:X.validate(t)?e=h:K.validate(t)?e=p:et.validate(t)?e=l:rt.validate(t)&&(e=d)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),k=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==C.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===w.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}(),J=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},F=function(t){return"object"===J(t)},V=function(t){return"number"===J(t)},H=function(t){return Array.isArray(t)},G=function(t){return"date"===J(t)},Z=function(t){return"regexp"===J(t)},Y=function(t){return t&&t._internalType instanceof E},W=function(){function t(t,e){k.isGeopoint("longitude",t),k.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"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&H(t.coordinates)&&k.isGeopoint("longitude",t.coordinates[0])&&k.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return T},enumerable:!0,configurable:!0}),t}(),Q=function(){function t(t){if(!H(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach((function(t){if(!(t instanceof W))throw new TypeError('"points" must be of type Point[]. Received type '+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(!V(i[0])||!V(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 A},enumerable:!0,configurable:!0}),t}(),z=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 '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof Q))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!Q.isClosed(t))throw new Error("LineString "+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=z(t.coordinates),u=i.next();!u.done;u=i.next()){var s=u.value;if(!this.isCloseLineString(s))return!1;try{for(var a=(r=void 0,z(s)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!V(c[0])||!V(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.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 L},enumerable:!0,configurable:!0}),t}(),K=function(){function t(t){if(!H(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach((function(t){if(!(t instanceof W))throw new TypeError('"points" must be of type Point[]. Received type '+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(!V(i[0])||!V(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 j},enumerable:!0,configurable:!0}),t}(),tt=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.")},et=function(){function t(t){if(!H(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof Q))throw new TypeError('"lines" must be of type LineString[]. Received type '+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=tt(t.coordinates),u=i.next();!u.done;u=i.next()){var s=u.value;try{for(var a=(r=void 0,tt(s)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!V(c[0])||!V(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),t}(),nt=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.")},rt=function(){function t(t){var e,n;if(!H(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=nt(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 '+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,u;if("MultiPolygon"!==t.type||!H(t.coordinates))return!1;try{for(var s=nt(t.coordinates),a=s.next();!a.done;a=s.next()){var f=a.value;try{for(var c=(r=void 0,nt(f)),h=c.next();!h.done;h=c.next()){var p=h.value;try{for(var l=(i=void 0,nt(p)),d=l.next();!d.done;d=l.next()){var y=d.value;if(!V(y[0])||!V(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(u=l.return)&&u.call(l)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return B},enumerable:!0,configurable:!0}),t}(),ot=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 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"}(D||(D={}));var it,ut=function(){function t(t,e,n){this._internalType=N,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function st(t){return t&&t instanceof ut&&t._internalType===N}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(it||(it={}));var at=function(){function t(t,e,n){if(this._internalType=I,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S,this.fieldName!==S)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(ft(i=e[r])||lt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(ft(i=e)||lt(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(it.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(it.OR,r,this.fieldName)},t}();function ft(t){return t&&t instanceof at&&t._internalType===I}var ct,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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){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"}(ct||(ct={}));var pt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=x,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case ct.IN:case ct.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(ct.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(ct.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(ct.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(ct.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(ct.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(ct.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(ct.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(ct.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof W))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!V(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!V(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(ct.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof rt||t.geometry instanceof X))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(ct.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof W||t.geometry instanceof Q||t.geometry instanceof X||t.geometry instanceof K||t.geometry instanceof et||t.geometry instanceof rt))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(ct.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(at);function lt(t){return t&&t instanceof pt&&t._internalType===x}function dt(t){return lt(t)}var yt={};for(var gt in ct)yt[gt]="$"+gt;for(var gt in it)yt[gt]="$"+gt;for(var gt in D)yt[gt]="$"+gt;function mt(t){return yt[t]||"$"+t}yt[ct.NEQ]="$ne",yt[D.REMOVE]="$unset",yt[D.SHIFT]="$pop",yt[D.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)},bt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.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 u},vt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bt(arguments[e]));return t};function _t(t){return Et(t,[t])}function Et(t,e){if(!Y(t)){if(G(t))return{$date:+t};if(Z(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,vt(e,[t]))}));if(F(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],vt(e,[n[r]]))}return n}return t}switch(t._internalType){case T:return t.toJSON();case U:case $:return t.parse();default:return t.toJSON?t.toJSON():t}}var Ot=function(){return Ot=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},Ot.apply(this,arguments)},St=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.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 u},Nt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(St(arguments[e]));return t};function xt(t,e,n,r){var o=Ot({},t);for(var i in t)if(!/^\$/.test(i)){var u=t[i];if(u&&F(u)&&!e(u)){if(r.indexOf(u)>-1)throw new Error("Cannot convert circular structure to JSON");var s=xt(u,e,Nt(n,[i]),Nt(r,[u]));o[i]=s;var a=!1;for(var f in s)/^\$/.test(f)?a=!0:(o[i+"."+f]=s[f],delete o[i][f]);a||delete o[i]}}return o}function It(t){return xt(t,At,[],[t])}function Tt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?H(t[r])?t[r].push(e[r]):F(t[r])?F(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is "+J(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+J(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function At(t){return Y(t)||G(t)||Z(t)}function Bt(t){return _t(t)}var jt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return st(t)?this.encodeUpdateCommand(t):"object"===J(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===S)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case D.PUSH:case D.PULL:case D.PULL_ALL:case D.POP:case D.SHIFT:case D.UNSHIFT:case D.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=mt(t.operator);return t.operator===D.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,u,s,a,f,c,h=mt(t.operator);switch(t.operator){case D.PUSH:var p=void 0;return p=H(t.operands)?{$each:t.operands.map(Bt)}:t.operands,(e={})[h]=((n={})[t.fieldName]=p,n),e;case D.UNSHIFT:return p={$each:t.operands.map(Bt),$position:0},(r={})[h]=((o={})[t.fieldName]=p,o),r;case D.POP:return(i={})[h]=((u={})[t.fieldName]=1,u),i;case D.SHIFT:return(s={})[h]=((a={})[t.fieldName]=-1,a),s;default:return(f={})[h]=((c={})[t.fieldName]=Bt(t.operands),c),f}},t.prototype.encodeUpdateObject=function(t){var e=It(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(st(r))e[n]=r._setFieldName(n),Tt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Bt(r);var o=new ut(D.SET,[r],n);Tt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Pt={};function Lt(t){if(!Un.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Pt[e]||(Pt[e]=new Un.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Un.reqClass(t.config)}}})),Pt[e]}for(var Ut=function(){return Ut=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},Ut.apply(this,arguments)},$t=function(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return Lt(o._db).watch(Ut(Ut({},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=new Un.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||ot();var n={collectionName:this._coll,data:_t(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||ot(),!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 ut?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:s.DOC,data:_t(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||ot(),!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:jt.encode(t),query:n,queryType:s.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||ot();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:s.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||ot();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:s.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=C.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}(),Rt=function(){function t(){}return t.encode=function(t){return(new Mt).encodeQuery(t)},t}(),Mt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return At(t)?ft(t)?this.encodeLogicCommand(t):lt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):F(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,u,s,a=this;switch(t.operator){case it.NOR:case it.AND:case it.OR:var f=mt(t.operator),c=t.operands.map((function(e){return a.encodeQuery(e,t.fieldName)}));return(e={})[f]=c,e;case it.NOT:f=mt(t.operator);var h=t.operands[0];return Z(h)?((n={})[t.fieldName]=((r={})[f]=this.encodeRegExp(h),r),n):(c=this.encodeQuery(h)[t.fieldName],(o={})[t.fieldName]=((i={})[f]=c,i),o);default:if(f=mt(t.operator),1===t.operands.length){var p=this.encodeQuery(t.operands[0]);return(u={})[f]=p,u}return c=t.operands.map(this.encodeQuery.bind(this)),(s={})[f]=c,s}},t.prototype.encodeQueryCommand=function(t){return dt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,u,s,a,f;if(t.fieldName===S)throw new Error("Cannot encode a comparison command with unset field name");var c=mt(t.operator);switch(t.operator){case ct.EQ:case ct.NEQ:case ct.LT:case ct.LTE:case ct.GT:case ct.GTE:case ct.ELEM_MATCH:case ct.EXISTS:case ct.SIZE:case ct.MOD:return(e={})[t.fieldName]=((n={})[c]=Bt(t.operands[0]),n),e;case ct.IN:case ct.NIN:case ct.ALL:return(r={})[t.fieldName]=((o={})[c]=Bt(t.operands),o),r;case ct.GEO_NEAR:var h=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:h.geometry.toJSON(),$maxDistance:h.maxDistance,$minDistance:h.minDistance}},i;case ct.GEO_WITHIN:return h=t.operands[0],(u={})[t.fieldName]={$geoWithin:{$geometry:h.geometry.toJSON()}},u;case ct.GEO_INTERSECTS:return h=t.operands[0],(s={})[t.fieldName]={$geoIntersects:{$geometry:h.geometry.toJSON()}},s;default:return(a={})[t.fieldName]=((f={})[c]=Bt(t.operands[0]),f),a}},t.prototype.encodeQueryObject=function(t){var e=It(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 dt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):At(r)&&(e[n]=Bt(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]):F(t[r])?F(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+J(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+J(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),Dt=function(){return Dt=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},Dt.apply(this,arguments)},qt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Lt(i._db).watch(Dt(Dt({},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=new Un.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||ot();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:s.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:C.formatResDocumentData(e.data.list),requestId:e.requestId};e.total&&(n.total=e.total),e.limit&&(n.limit=e.limit),e.offset&&(n.offset=e.offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||ot();var e={collectionName:this._coll,queryType:s.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,Rt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){k.isFieldPath(e),k.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){k.isInteger("limit",e);var n=Dt({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){k.isInteger("offset",e);var n=Dt({},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||ot(),!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:s.WHERE,multi:!0,merge:!0,upsert:!1,data:jt.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=Dt({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||ot(),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:Rt.encode(this._fieldFilters),queryType:s.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}(),Ct=[],kt=[],Jt="undefined"!=typeof Uint8Array?Uint8Array:Array,Ft="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vt=0;Vt<64;++Vt)Ct[Vt]=Ft[Vt],kt[Ft.charCodeAt(Vt)]=Vt;function Ht(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function Gt(t,e,n){for(var r,o,i=[],u=e;u<n;u+=3)r=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),i.push(Ct[(o=r)>>18&63]+Ct[o>>12&63]+Ct[o>>6&63]+Ct[63&o]);return i.join("")}kt["-".charCodeAt(0)]=62,kt["_".charCodeAt(0)]=63;var Zt=function(t){var e,n,r=Ht(t),o=r[0],i=r[1],u=new Jt(function(t,e,n){return 3*(e+n)/4-n}(0,o,i)),s=0,a=i>0?o-4:o;for(n=0;n<a;n+=4)e=kt[t.charCodeAt(n)]<<18|kt[t.charCodeAt(n+1)]<<12|kt[t.charCodeAt(n+2)]<<6|kt[t.charCodeAt(n+3)],u[s++]=e>>16&255,u[s++]=e>>8&255,u[s++]=255&e;return 2===i&&(e=kt[t.charCodeAt(n)]<<2|kt[t.charCodeAt(n+1)]>>4,u[s++]=255&e),1===i&&(e=kt[t.charCodeAt(n)]<<10|kt[t.charCodeAt(n+1)]<<4|kt[t.charCodeAt(n+2)]>>2,u[s++]=e>>8&255,u[s++]=255&e),u},Yt=function(t){for(var e,n=t.length,r=n%3,o=[],i=16383,u=0,s=n-r;u<s;u+=i)o.push(Gt(t,u,u+i>s?s:u+i));return 1===r?(e=t[n-1],o.push(Ct[e>>2]+Ct[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],o.push(Ct[e>>10]+Ct[e>>4&63]+Ct[e<<2&63]+"=")),o.join("")},Wt=function(t,e,n,r,o){var i,u,s=8*o-r-1,a=(1<<s)-1,f=a>>1,c=-7,h=n?o-1:0,p=n?-1:1,l=t[e+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=s;c>0;i=256*i+t[e+h],h+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=r;c>0;u=256*u+t[e+h],h+=p,c-=8);if(0===i)i=1-f;else{if(i===a)return u?NaN:1/0*(l?-1:1);u+=Math.pow(2,r),i-=f}return(l?-1:1)*u*Math.pow(2,i-r)},Qt=function(t,e,n,r,o,i){var u,s,a,f=8*i-o-1,c=(1<<f)-1,h=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=c):(u=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-u))<1&&(u--,a*=2),(e+=u+h>=1?p/a:p*Math.pow(2,1-h))*a>=2&&(u++,a/=2),u+h>=c?(s=0,u=c):u+h>=1?(s=(e*a-1)*Math.pow(2,o),u+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),u=0));o>=8;t[n+l]=255&s,l+=d,s/=256,o-=8);for(u=u<<o|s,f+=o;f>0;t[n+l]=255&u,l+=d,u/=256,f-=8);t[n+l-d]|=128*y},zt=function(t,e){return function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;var r=2147483647;function o(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return u(t,e,n)}function u(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|p(t,e),r=o(n),u=r.write(t,e);return u!==n&&(r=r.slice(0,u)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(D(t,Uint8Array)){var e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(D(t,ArrayBuffer)||t&&D(t.buffer,ArrayBuffer))return c(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(D(t,SharedArrayBuffer)||t&&D(t.buffer,SharedArrayBuffer)))return c(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,e,n);var u=function(t){if(i.isBuffer(t)){var e=0|h(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?o(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return s(t),o(t<0?0:0|h(t))}function f(t){for(var e=t.length<0?0:0|h(t.length),n=o(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function c(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function h(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function p(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||D(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return R(t).length;default:if(o)return r?-1:$(t).length;e=(""+e).toLowerCase(),o=!0}}function l(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return N(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return E(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=i.from(e,r)),i.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,o){var i,u=1,s=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,s/=2,a/=2,n/=2}function f(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var c=-1;for(i=n;i<s;i++)if(f(t,i)===f(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===a)return c*u}else-1!==c&&(i-=i-c),c=-1}else for(n+a>s&&(n=s-a),i=n;i>=0;i--){for(var h=!0,p=0;p<a;p++)if(f(t,i+p)!==f(e,p)){h=!1;break}if(h)return i}return-1}function m(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var u=0;u<r;++u){var s=parseInt(e.substr(2*u,2),16);if(q(s))return u;t[n+u]=s}return u}function w(t,e,n,r){return M($(e,t.length-n),t,n,r)}function b(t,e,n,r){return M(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function v(t,e,n,r){return M(R(e),t,n,r)}function _(t,e,n,r){return M(function(t,e){for(var n,r,o,i=[],u=0;u<t.length&&!((e-=2)<0);++u)r=(n=t.charCodeAt(u))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function E(t,e,n){return 0===e&&n===t.length?Yt(t):Yt(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,u,s,a,f=t[o],c=null,h=f>239?4:f>223?3:f>191?2:1;if(o+h<=n)switch(h){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(c=a);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(a=(15&f)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&f)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(c=a)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),o+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=S));return n}(r)}e.kMaxLength=r,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,n){return u(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,n){return function(t,e,n){return s(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},i.allocUnsafe=function(t){return a(t)},i.allocUnsafeSlow=function(t){return a(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(D(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),D(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,o=0,u=Math.min(n,r);o<u;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var u=t[n];if(D(u,Uint8Array))o+u.length>r.length?i.from(u).copy(r,o):Uint8Array.prototype.set.call(r,u,o);else{if(!i.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(r,o)}o+=u.length}return r},i.byteLength=p,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):l.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(D(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var u=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(u,s),f=this.slice(r,o),c=t.slice(e,n),h=0;h<a;++h)if(f[h]!==c[h]){u=f[h],s=c[h];break}return u<s?-1:s<u?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return v(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function N(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function x(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function I(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=C[t[i]];return o}function T(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function A(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,n,r,o,u){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<u)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function j(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,r,o){return e=+e,n>>>=0,o||j(t,0,n,4),Qt(t,e,n,r,23,4),n+4}function L(t,e,n,r,o){return e=+e,n>>>=0,o||j(t,0,n,8),Qt(t,e,n,r,52,8),n+8}i.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||A(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||A(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){t>>>=0,e||A(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||A(t,4,this.length),Wt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||A(t,4,this.length),Wt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||A(t,8,this.length),Wt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||A(t,8,this.length),Wt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=0,u=1,s=0;for(this[e]=255&t;++i<n&&(u*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/u|0)-s&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=n-1,u=1,s=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/u|0)-s&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return L(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return L(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var o=t.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var u;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(u=e;u<n;++u)this[u]=t;else{var s=i.isBuffer(t)?t:i.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(u=0;u<n-e;++u)this[u+e]=s[u%a]}return this};var U=/[^+/0-9A-Za-z-_]/g;function $(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],u=0;u<r;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function R(t){return Zt(function(t){if((t=(t=t.split("=")[0]).trim().replace(U,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function M(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function D(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}var C=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,o=0;o<16;++o)e[r+o]=t[n]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),Xt=zt.Buffer;zt.SlowBuffer,zt.INSPECT_MAX_BYTES,zt.kMaxLength;var Kt=function(t,e){return Kt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},Kt(t,e)};function te(t,e){function n(){this.constructor=t}Kt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var ee=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return te(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),ne=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return te(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function re(t){return t&&t.Math==Math&&t}function oe(){return re("object"==typeof globalThis&&globalThis)||re("object"==typeof window&&window)||re("object"==typeof self&&self)||re("object"==typeof n.g&&n.g)||Function("return this")()}var ie=function(t){var e,n="object"==typeof(e=oe()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=Xt.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},ue=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(Xt.alloc(e))}}return void 0!==n.g&&n.g.crypto&&n.g.crypto.getRandomValues?function(t){return n.g.crypto.getRandomValues(Xt.alloc(t))}:ie}();function se(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function ae(t){return"object"==typeof t&&null!==t}function fe(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function ce(t){if(ArrayBuffer.isView(t))return Xt.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return Xt.from(t);var e;throw new ne("Must use either Buffer or TypedArray")}var he=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,pe=function(t){return"string"==typeof t&&he.test(t)},le=function(t){if(!pe(t))throw new ne('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return Xt.from(e,"hex")},de=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},ye=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),ge=-Math.pow(2,53),me=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new ne("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=Xt.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=Xt.from(e,"binary"):Array.isArray(e)?this.buffer=Xt.from(e):this.buffer=ce(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new ne("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new ne("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new ne("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=Xt.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=Xt.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(ce(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),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}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new we(this.buffer.slice(0,this.position));throw new ee('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=Xt.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=Xt.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=le(e.$uuid)),!r)throw new ne("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new we(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(me.prototype,"_bsontype",{value:"Binary"});var we=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=Xt.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=ce(n);else{if("string"!=typeof n)throw new ne("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).");r=le(n)}return(i=t.call(this,r,4)||this).__id=o,i}return te(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=de(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=de(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new me(this.id,me.SUBTYPE_UUID)},e.generate=function(){var t=ue(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,Xt.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?pe(t):!(!se(t)||16!==t.length||64!=(240&t[6])||128&~t[8])))},e.createFromHexString=function(t){return new e(le(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(me),be=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();Object.defineProperty(be.prototype,"_bsontype",{value:"Code"});var ve=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(ve.prototype,"_bsontype",{value:"DBRef"});var _e=void 0;try{_e=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(r){}var Ee=4294967296,Oe=0x10000000000000000,Se=Oe/2,Ne={},xe={},Ie=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=xe[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(xe[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=Ne[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(Ne[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=Oe)return t.MAX_UNSIGNED_VALUE}else{if(e<=-Se)return t.MIN_VALUE;if(e+1>=Se)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%Ee|0,e/Ee|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),u=t.ZERO,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),f=parseInt(e.substring(s,s+a),r);if(a<8){var c=t.fromNumber(Math.pow(r,a));u=u.mul(c).add(t.fromNumber(f))}else u=(u=u.mul(i)).add(t.fromNumber(f))}return u.unsigned=n,u},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return ae(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,u=e.high>>>16,s=65535&e.high,a=e.low>>>16,f=0,c=0,h=0,p=0;return h+=(p+=i+(65535&e.low))>>>16,p&=65535,c+=(h+=o+a)>>>16,h&=65535,f+=(c+=r+s)>>>16,c&=65535,f+=n+u,f&=65535,t.fromBits(h<<16|p,f<<16|c,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(_e){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?_e.div_u:_e.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,_e.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var u=Math.ceil(Math.log(r)/Math.LN2),s=u<=48?1:Math.pow(2,u-48),a=t.fromNumber(r),f=a.mul(e);f.isNegative()||f.gt(o);)r-=s,f=(a=t.fromNumber(r,this.unsigned)).mul(e);a.isZero()&&(a=t.ONE),i=i.add(a),o=o.sub(f)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&!(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return!(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return!(1&~this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),_e){var n=(this.unsigned?_e.rem_u:_e.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,_e.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),_e){var n=_e.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,_e.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,u=65535&this.low,s=e.high>>>16,a=65535&e.high,f=e.low>>>16,c=65535&e.low,h=0,p=0,l=0,d=0;return l+=(d+=u*c)>>>16,d&=65535,p+=(l+=i*c)>>>16,l&=65535,p+=(l+=u*f)>>>16,l&=65535,h+=(p+=o*c)>>>16,p&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=u*a)>>>16,p&=65535,h+=r*c+o*f+i*a+u*s,h&=65535,t.fromBits(l<<16|d,h<<16|p,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*Ee+(this.low>>>0):this.high*Ee+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var 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]},t.prototype.toBytesBE=function(){var 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]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),u=this,s="";;){var a=u.div(i),f=(u.sub(a.mul(i)).toInt()>>>0).toString(e);if((u=a).isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(16777216),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(Ie.prototype,"__isLong__",{value:!0}),Object.defineProperty(Ie.prototype,"_bsontype",{value:"Long"});var Te=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Ae=/^(\+|-)?(Infinity|inf)$/i,Be=/^(\+|-)?NaN$/i,je=6111,Pe=-6176,Le=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Ue=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),$e=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Re=/^([-+])?(\d+)?$/;function Me(t){return!isNaN(parseInt(t,10))}function De(t){var e=Ie.fromNumber(1e9),n=Ie.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new Ie(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function qe(t,e){throw new ne('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var Ce=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!se(e))throw new ne("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new ne("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,u=0,s=0,a=0,f=0,c=0,h=[0],p=0,l=0,d=0,y=0,g=0,m=0,w=new Ie(0,0),b=new Ie(0,0),v=0;if(e.length>=7e3)throw new ne(e+" not a valid Decimal128 string");var _=e.match(Te),E=e.match(Ae),O=e.match(Be);if(!_&&!E&&!O||0===e.length)throw new ne(e+" not a valid Decimal128 string");if(_){var S=_[2],N=_[4],x=_[5],I=_[6];N&&void 0===I&&qe(e,"missing exponent power"),N&&void 0===S&&qe(e,"missing exponent base"),void 0===N&&(x||I)&&qe(e,"missing e before exponent")}if("+"!==e[v]&&"-"!==e[v]||(r="-"===e[v++]),!Me(e[v])&&"."!==e[v]){if("i"===e[v]||"I"===e[v])return new t(Xt.from(r?Ue:$e));if("N"===e[v])return new t(Xt.from(Le))}for(;Me(e[v])||"."===e[v];)"."!==e[v]?(p<34&&("0"!==e[v]||i)&&(i||(c=s),i=!0,h[l++]=parseInt(e[v],10),p+=1),i&&(a+=1),o&&(f+=1),s+=1,v+=1):(o&&qe(e,"contains multiple periods"),o=!0,v+=1);if(o&&!s)throw new ne(e+" not a valid Decimal128 string");if("e"===e[v]||"E"===e[v]){var T=e.substr(++v).match(Re);if(!T||!T[2])return new t(Xt.from(Le));g=parseInt(T[0],10),v+=T[0].length}if(e[v])return new t(Xt.from(Le));if(d=0,p){if(y=p-1,1!==(u=a))for(;0===h[c+u-1];)u-=1}else d=0,y=0,h[0]=0,a=1,p=1,u=0;for(g<=f&&f-g>16384?g=Pe:g-=f;g>je;){if((y+=1)-d>34){if(h.join("").match(/^0+$/)){g=je;break}qe(e,"overflow")}g-=1}for(;g<Pe||p<a;){if(0===y&&u<p){g=Pe,u=0;break}if(p<a?a-=1:y-=1,g<je)g+=1;else{if(h.join("").match(/^0+$/)){g=je;break}qe(e,"overflow")}}if(y-d+1<u){var A=s;o&&(c+=1,A+=1),r&&(c+=1,A+=1);var B=parseInt(e[c+y+1],10),j=0;if(B>=5&&(j=1,5===B))for(j=h[y]%2==1?1:0,m=c+y+2;m<A;m++)if(parseInt(e[m],10)){j=1;break}if(j)for(var P=y;P>=0;P--)if(++h[P]>9&&(h[P]=0,0===P)){if(!(g<je))return new t(Xt.from(r?Ue:$e));g+=1,h[P]=1}}if(w=Ie.fromNumber(0),b=Ie.fromNumber(0),0===u)w=Ie.fromNumber(0),b=Ie.fromNumber(0);else if(y-d<17)for(P=d,b=Ie.fromNumber(h[P++]),w=new Ie(0,0);P<=y;P++)b=(b=b.multiply(Ie.fromNumber(10))).add(Ie.fromNumber(h[P]));else{for(P=d,w=Ie.fromNumber(h[P++]);P<=y-17;P++)w=(w=w.multiply(Ie.fromNumber(10))).add(Ie.fromNumber(h[P]));for(b=Ie.fromNumber(h[P++]);P<=y;P++)b=(b=b.multiply(Ie.fromNumber(10))).add(Ie.fromNumber(h[P]))}var L,U,$,R,M=function(t,e){if(!t&&!e)return{high:Ie.fromNumber(0),low:Ie.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new Ie(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Ie(e.getLowBits(),0),u=n.multiply(o),s=n.multiply(i),a=r.multiply(o),f=r.multiply(i);return u=u.add(s.shiftRightUnsigned(32)),s=new Ie(s.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),{high:u=u.add(s.shiftRightUnsigned(32)),low:f=s.shiftLeft(32).add(new Ie(f.getLowBits(),0))}}(w,Ie.fromString("100000000000000000"));M.low=M.low.add(b),U=b,(($=(L=M.low).high>>>0)<(R=U.high>>>0)||$===R&&L.low>>>0<U.low>>>0)&&(M.high=M.high.add(Ie.fromNumber(1))),n=g+6176;var D={low:Ie.fromNumber(0),high:Ie.fromNumber(0)};M.high.shiftRightUnsigned(49).and(Ie.fromNumber(1)).equals(Ie.fromNumber(1))?(D.high=D.high.or(Ie.fromNumber(3).shiftLeft(61)),D.high=D.high.or(Ie.fromNumber(n).and(Ie.fromNumber(16383).shiftLeft(47))),D.high=D.high.or(M.high.and(Ie.fromNumber(0x7fffffffffff)))):(D.high=D.high.or(Ie.fromNumber(16383&n).shiftLeft(49)),D.high=D.high.or(M.high.and(Ie.fromNumber(562949953421311)))),D.low=M.low,r&&(D.high=D.high.or(Ie.fromString("9223372036854775808")));var q=Xt.alloc(16);return v=0,q[v++]=255&D.low.low,q[v++]=D.low.low>>8&255,q[v++]=D.low.low>>16&255,q[v++]=D.low.low>>24&255,q[v++]=255&D.low.high,q[v++]=D.low.high>>8&255,q[v++]=D.low.high>>16&255,q[v++]=D.low.high>>24&255,q[v++]=255&D.high.low,q[v++]=D.high.low>>8&255,q[v++]=D.high.low>>16&255,q[v++]=D.high.low>>24&255,q[v++]=255&D.high.high,q[v++]=D.high.high>>8&255,q[v++]=D.high.high>>16&255,q[v++]=D.high.high>>24&255,new t(q)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,u,s=0,a=!1,f={parts:[0,0,0,0]},c=[];s=0;var h=this.bytes,p=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,l=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,d=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,y=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24;s=0,(new Ie(p,l),new Ie(d,y)).lessThan(Ie.ZERO)&&c.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return c.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var m=t-6176;if(f.parts[0]=(16383&y)+((15&o)<<14),f.parts[1]=d,f.parts[2]=l,f.parts[3]=p,0===f.parts[0]&&0===f.parts[1]&&0===f.parts[2]&&0===f.parts[3])a=!0;else for(u=3;u>=0;u--){var w=0,b=De(f);if(f=b.quotient,w=b.rem.low)for(i=8;i>=0;i--)n[9*u+i]=w%10,w=Math.floor(w/10)}if(a)e=1,n[s]=0;else for(e=36;!n[s];)e-=1,s+=1;var v=e-1+m;if(v>=34||v<=-7||m>0){if(e>34)return c.push("".concat(0)),m>0?c.push("E+".concat(m)):m<0&&c.push("E".concat(m)),c.join("");for(c.push("".concat(n[s++])),(e-=1)&&c.push("."),r=0;r<e;r++)c.push("".concat(n[s++]));c.push("E"),v>0?c.push("+".concat(v)):c.push("".concat(v))}else if(m>=0)for(r=0;r<e;r++)c.push("".concat(n[s++]));else{var _=e+m;if(_>0)for(r=0;r<_;r++)c.push("".concat(n[s++]));else c.push("0");for(c.push(".");_++<0;)c.push("0");for(r=0;r<e-Math.max(_-1,0);r++)c.push("".concat(n[s++]))}return c.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(Ce.prototype,"_bsontype",{value:"Decimal128"});var ke=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty(ke.prototype,"_bsontype",{value:"Double"});var Je=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty(Je.prototype,"_bsontype",{value:"Int32"});var Fe=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(Fe.prototype,"_bsontype",{value:"MaxKey"});var Ve=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(Ve.prototype,"_bsontype",{value:"MinKey"});var He=new RegExp("^[0-9a-fA-F]{24}$"),Ge=null,Ze=Symbol("id"),Ye=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new ne("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?Xt.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[Ze]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[Ze]=n instanceof Xt?n:ce(n);else{if("string"!=typeof n)throw new ne("Argument passed in does not match the accepted types");if(12===n.length){var r=Xt.from(n);if(12!==r.byteLength)throw new ne("Argument passed in must be a string of 12 bytes");this[Ze]=r}else{if(24!==n.length||!He.test(n))throw new ne("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Ze]=Xt.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Ze]},set:function(e){this[Ze]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=Xt.alloc(12);return r.writeUInt32BE(e,0),null===Ge&&(Ge=ue(5)),r[4]=Ge[0],r[5]=Ge[1],r[6]=Ge[2],r[7]=Ge[3],r[8]=Ge[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[Ze][11]===e[Ze][11]&&this[Ze].equals(e[Ze]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&se(this.id))return e===Xt.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return Xt.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=Xt.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new ne("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(Xt.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(Ye.prototype,"generate",{value:fe((function(t){return Ye.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(Ye.prototype,"getInc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye,"get_inc",{value:fe((function(){return Ye.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Ye.prototype,"_bsontype",{value:"ObjectID"});var We=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new ee("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new ee("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new ee("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new ne("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(We.prototype,"_bsontype",{value:"BSONRegExp"});var Qe=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(Qe.prototype,"_bsontype",{value:"Symbol"});var ze=function(t){function e(n,r){var o=this;return o instanceof e?(o=Ie.isLong(n)?t.call(this,n.low,n.high,!0)||this:ae(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return te(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Ie.fromInt(t,!0))},e.fromNumber=function(t){return new e(Ie.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(Ie.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=Ie.MAX_UNSIGNED_VALUE,e}(Ie);var Xe=2147483647,Ke=-2147483648,tn=0x8000000000000000,en=-0x8000000000000000,nn={$oid:Ye,$binary:me,$uuid:me,$symbol:Qe,$numberInt:Je,$numberDecimal:Ce,$numberDouble:ke,$numberLong:Ie,$minKey:Ve,$maxKey:Fe,$regex:We,$regularExpression:We,$timestamp:ze};function rn(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=Ke&&t<=Xe)return new Je(t);if(t>=en&&t<=tn)return Ie.fromNumber(t)}return new ke(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var n=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),r=0;r<n.length;r++){var o=nn[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){var i=t.$date,u=new Date;return e.legacy?"number"==typeof i?u.setTime(i):"string"==typeof i&&u.setTime(Date.parse(i)):"string"==typeof i?u.setTime(Date.parse(i)):Ie.isLong(i)?u.setTime(i.toNumber()):"number"==typeof i&&e.relaxed&&u.setTime(i),u}if(null!=t.$code){var s=Object.assign({},t);return t.$scope&&(s.$scope=rn(t.$scope)),be.fromExtendedJSON(t)}if(function(t){return ae(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var a=t.$ref?t:t.$dbPointer;if(a instanceof ve)return a;var f=Object.keys(a).filter((function(t){return t.startsWith("$")})),c=!0;if(f.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(c=!1)})),c)return ve.fromExtendedJSON(a)}return t}function on(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function un(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],u=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),s=r[r.length-1],a=" ".repeat(o.length+i.length/2),f="-".repeat(u.length+(i.length+s.length)/2-1);throw new ne("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(u).concat(s,"\n")+" ".concat(a,"\\").concat(f,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return un(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||ae(p=t)&&"[object Date]"===Object.prototype.toString.call(p)){var c=t.getTime(),h=c>-1&&c<2534023188e5;return e.legacy?e.relaxed&&h?{$date:t.getTime()}:{$date:on(t)}:e.relaxed&&h?{$date:on(t)}:{$date:{$numberLong:t.getTime().toString()}}}var p;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var l=t>=en&&t<=tn;if(t>=Ke&&t<=Xe)return{$numberInt:t.toString()};if(l)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var d=t.flags;if(void 0===d){var y=t.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new We(t.source,d).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new ee("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=un(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(function(t){return ae(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var u=t;if("function"!=typeof u.toExtendedJSON){var s=an[t._bsontype];if(!s)throw new ne("Unrecognized or invalid _bsontype: "+t._bsontype);u=s(u)}return"Code"===n&&u.scope?u=new be(u.code,un(u.scope,e)):"DBRef"===n&&u.oid&&(u=new ve(un(u.collection,e),un(u.oid,e),un(u.db,e),un(u.fields,e))),u.toExtendedJSON(e)}throw new ee("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var sn,an={Binary:function(t){return new me(t.value(),t.sub_type)},Code:function(t){return new be(t.code,t.scope)},DBRef:function(t){return new ve(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new Ce(t.bytes)},Double:function(t){return new ke(t.value)},Int32:function(t){return new Je(t.value)},Long:function(t){return Ie.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new Fe},MinKey:function(){return new Ve},ObjectID:function(t){return new Ye(t)},ObjectId:function(t){return new Ye(t)},BSONRegExp:function(t){return new We(t.pattern,t.options)},Symbol:function(t){return new Qe(t.value)},Timestamp:function(t){return ze.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new ee("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return rn(e,n)}))}function n(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);var o=un(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(sn||(sn={}));var fn=oe();fn.Map?fn.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Ie.fromNumber(ye),Ie.fromNumber(ge),new Set(["$db","$ref","$id","$clusterTime"]);var cn=new Uint8Array(8);new DataView(cn.buffer,cn.byteOffset,cn.byteLength);Xt.alloc(17825792);var hn=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new Un.reqClass(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,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(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(sn.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((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:"$"+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=Rt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new W(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",Rt.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 pn=hn;var ln=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),dn=function(t){function e(e,n){return t.call(this,e,n)||this}return ln(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new $t(this._db,this._coll,t)},e.prototype.add=function(t,e){return new $t(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new pn(this._db,this._coll)},e}(qt),yn={eq:function(t){return new pt(ct.EQ,[t])},neq:function(t){return new pt(ct.NEQ,[t])},lt:function(t){return new pt(ct.LT,[t])},lte:function(t){return new pt(ct.LTE,[t])},gt:function(t){return new pt(ct.GT,[t])},gte:function(t){return new pt(ct.GTE,[t])},in:function(t){return new pt(ct.IN,t)},nin:function(t){return new pt(ct.NIN,t)},all:function(t){return new pt(ct.ALL,t)},elemMatch:function(t){return new pt(ct.ELEM_MATCH,[t])},exists:function(t){return new pt(ct.EXISTS,[t])},size:function(t){return new pt(ct.SIZE,[t])},mod:function(t){return new pt(ct.MOD,[t])},geoNear:function(t){return new pt(ct.GEO_NEAR,[t])},geoWithin:function(t){return new pt(ct.GEO_WITHIN,[t])},geoIntersects:function(t){return new pt(ct.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 at(it.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 at(it.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 at(it.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 at(it.NOT,n)},set:function(t){return new ut(D.SET,[t])},remove:function(){return new ut(D.REMOVE,[])},inc:function(t){return new ut(D.INC,[t])},mul:function(t){return new ut(D.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(F(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 ut(D.PUSH,t)},pull:function(t){return new ut(D.PULL,t)},pullAll:function(t){return new ut(D.PULL_ALL,t)},pop:function(){return new ut(D.POP,[])},shift:function(){return new ut(D.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 ut(D.UNSHIFT,n)},addToSet:function(t){return new ut(D.ADD_TO_SET,t)},rename:function(t){return new ut(D.RENAME,[t])},bit:function(t){return new ut(D.BIT,[t])},max:function(t){return new ut(D.MAX,[t])},min:function(t){return new ut(D.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===J(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new pn},abs:function(t){return new gn("abs",t)},add:function(t){return new gn("add",t)},ceil:function(t){return new gn("ceil",t)},divide:function(t){return new gn("divide",t)},exp:function(t){return new gn("exp",t)},floor:function(t){return new gn("floor",t)},ln:function(t){return new gn("ln",t)},log:function(t){return new gn("log",t)},log10:function(t){return new gn("log10",t)},mod:function(t){return new gn("mod",t)},multiply:function(t){return new gn("multiply",t)},pow:function(t){return new gn("pow",t)},sqrt:function(t){return new gn("sqrt",t)},subtract:function(t){return new gn("subtract",t)},trunc:function(t){return new gn("trunc",t)},arrayElemAt:function(t){return new gn("arrayElemAt",t)},arrayToObject:function(t){return new gn("arrayToObject",t)},concatArrays:function(t){return new gn("concatArrays",t)},filter:function(t){return new gn("filter",t)},in:function(t){return new gn("in",t)},indexOfArray:function(t){return new gn("indexOfArray",t)},isArray:function(t){return new gn("isArray",t)},map:function(t){return new gn("map",t)},range:function(t){return new gn("range",t)},reduce:function(t){return new gn("reduce",t)},reverseArray:function(t){return new gn("reverseArray",t)},size:function(t){return new gn("size",t)},slice:function(t){return new gn("slice",t)},zip:function(t){return new gn("zip",t)},and:function(t){return new gn("and",t)},not:function(t){return new gn("not",t)},or:function(t){return new gn("or",t)},cmp:function(t){return new gn("cmp",t)},eq:function(t){return new gn("eq",t)},gt:function(t){return new gn("gt",t)},gte:function(t){return new gn("gte",t)},lt:function(t){return new gn("lt",t)},lte:function(t){return new gn("lte",t)},neq:function(t){return new gn("ne",t)},cond:function(t){return new gn("cond",t)},ifNull:function(t){return new gn("ifNull",t)},switch:function(t){return new gn("switch",t)},dateFromParts:function(t){return new gn("dateFromParts",t)},dateFromString:function(t){return new gn("dateFromString",t)},dayOfMonth:function(t){return new gn("dayOfMonth",t)},dayOfWeek:function(t){return new gn("dayOfWeek",t)},dayOfYear:function(t){return new gn("dayOfYear",t)},isoDayOfWeek:function(t){return new gn("isoDayOfWeek",t)},isoWeek:function(t){return new gn("isoWeek",t)},isoWeekYear:function(t){return new gn("isoWeekYear",t)},millisecond:function(t){return new gn("millisecond",t)},minute:function(t){return new gn("minute",t)},month:function(t){return new gn("month",t)},second:function(t){return new gn("second",t)},hour:function(t){return new gn("hour",t)},week:function(t){return new gn("week",t)},year:function(t){return new gn("year",t)},literal:function(t){return new gn("literal",t)},mergeObjects:function(t){return new gn("mergeObjects",t)},objectToArray:function(t){return new gn("objectToArray",t)},allElementsTrue:function(t){return new gn("allElementsTrue",t)},anyElementTrue:function(t){return new gn("anyElementTrue",t)},setDifference:function(t){return new gn("setDifference",t)},setEquals:function(t){return new gn("setEquals",t)},setIntersection:function(t){return new gn("setIntersection",t)},setIsSubset:function(t){return new gn("setIsSubset",t)},setUnion:function(t){return new gn("setUnion",t)},concat:function(t){return new gn("concat",t)},dateToString:function(t){return new gn("dateToString",t)},indexOfBytes:function(t){return new gn("indexOfBytes",t)},indexOfCP:function(t){return new gn("indexOfCP",t)},split:function(t){return new gn("split",t)},strLenBytes:function(t){return new gn("strLenBytes",t)},strLenCP:function(t){return new gn("strLenCP",t)},strcasecmp:function(t){return new gn("strcasecmp",t)},substr:function(t){return new gn("substr",t)},substrBytes:function(t){return new gn("substrBytes",t)},substrCP:function(t){return new gn("substrCP",t)},toLower:function(t){return new gn("toLower",t)},toUpper:function(t){return new gn("toUpper",t)},meta:function(t){return new gn("meta",t)},addToSet:function(t){return new gn("addToSet",t)},avg:function(t){return new gn("avg",t)},first:function(t){return new gn("first",t)},last:function(t){return new gn("last",t)},max:function(t){return new gn("max",t)},min:function(t){return new gn("min",t)},push:function(t){return new gn("push",t)},stdDevPop:function(t){return new gn("stdDevPop",t)},stdDevSamp:function(t){return new gn("stdDevSamp",t)},sum:function(t){return new gn("sum",t)},let:function(t){return new gn("let",t)}},project:{slice:function(t){return new mn("slice",t)},elemMatch:function(t){return new mn("elemMatch",t)}}},gn=function(t,e){this["$"+t]=e},mn=function(t,e){this["$"+t]=e},wn=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 $},enumerable:!0,configurable:!0}),t}();function bn(t){return new wn(t)}var vn="insert document failed",_n="DATABASE_TRANSACTION_CONFLICT",En=function(){return En=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},En.apply(this,arguments)},On=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},Sn=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},Nn="database.updateDocInTransaction",xn=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 On(this,void 0,void 0,(function(){var e,n,r,o;return Sn(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:sn.stringify(_t(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=sn.parse(n.inserted),1==(o=sn.parse(n.ok))&&1==r)return[2,En(En({},n),{ok:o,inserted:r})];throw new Error(vn)}}))}))},t.prototype.get=function(){return On(this,void 0,void 0,(function(){var t,e;return Sn(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?C.formatField(sn.parse(e.data)):sn.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return On(this,void 0,void 0,(function(){var e,n;return Sn(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:sn.stringify(_t(t),{relaxed:!1}),upsert:!0},[4,this._request.send(Nn,e)];case 1:if((n=r.sent()).code)throw n;return[2,En(En({},n),{updated:sn.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return On(this,void 0,void 0,(function(){var e,n;return Sn(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:sn.stringify(jt.encode(t),{relaxed:!1})},[4,this._request.send(Nn,e)];case 1:if((n=r.sent()).code)throw n;return[2,En(En({},n),{updated:sn.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return On(this,void 0,void 0,(function(){var t,e;return Sn(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,En(En({},e),{deleted:sn.parse(e.deleted)})]}}))}))},t}(),In=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)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Tn=function(t){function e(e,n){return t.call(this,e,n)||this}return In(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new xn(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new xn(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),An=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},Bn=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},jn=function(){function t(t){this._db=t,this._request=new Un.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return An(this,void 0,void 0,(function(){var t;return Bn(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 Tn(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return An(this,void 0,void 0,(function(){var t,e;return Bn(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 An(this,void 0,void 0,(function(){var e,n;return Bn(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 Pn(){return An(this,void 0,void 0,(function(){var t;return Bn(this,(function(e){switch(e.label){case 0:return[4,(t=new jn(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function Ln(t,e){return void 0===e&&(e=3),An(this,void 0,void 0,(function(){var n,r,o,i,u=this;return Bn(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,10]),[4,(n=new jn(this)).init()];case 1:return s.sent(),[4,t(n)];case 2:if(r=s.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return s.sent(),[2,r];case 4:if(o=s.sent(),!1===n.inited)throw o;return i=function(t){return An(u,void 0,void 0,(function(){return Bn(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:s.sent(),s.label=6;case 6:return o&&o.code===_n?[4,Ln.bind(this)(t,--e)]:[3,8];case 7:return[2,s.sent()];case 8:return[4,i(o)];case 9:return s.sent(),[3,10];case 10:return[2]}}))}))}var Un=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=M,this.command=yn,this.RegExp=bn,this.startTransaction=Pn,this.runTransaction=Ln,this.logicCommand=at,this.updateCommand=ut,this.queryCommand=pt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new dn(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}()}},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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),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(258)})()));
|
|
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,(()=>(()=>{"use strict";var t={258:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var i=n(836),o={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,o=e.runtime;return i.Db.reqClass=this.request.constructor,i.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},i.Db.runtime=o,this.wsClientClass&&(i.Db.wsClass=n.wsClass,i.Db.wsClientClass=this.wsClientClass),i.Db.ws||(i.Db.ws=null),new i.Db(r(r(r({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(o)}catch(t){}function s(t){try{t.registerComponent(o)}catch(t){console.warn(t)}}e.registerDatabase=s;try{window.registerDatabase=s}catch(t){}},836:(t,e,n)=>{n.r(e),n.d(e,{CollectionReference:()=>En,Db:()=>Jn,DocumentReference:()=>Rt,Query:()=>Mt});var r,i,o={};n.r(o),n.d(o,{LineString:()=>Q,MultiLineString:()=>nt,MultiPoint:()=>tt,MultiPolygon:()=>it,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"}(i||(i={}));var s,u,a="Object",f="GeoPoint",c="GeoLineString",l="GeoPolygon",h="GeoMultiPoint",d="GeoMultiLineString",p="GeoMultiPolygon",y="Date",m="ServerDate",g=["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"}(u||(u={}));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 i=new e(t,O);return _.push({target:t,instance:i}),i},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})}));const N=E;var S=N.for("UNSET_FIELD_NAME"),x=N.for("UPDATE_COMMAND"),T=N.for("QUERY_COMMAND"),I=N.for("LOGIC_COMMAND"),$=N.for("GEO_POINT"),B=N.for("SYMBOL_GEO_LINE_STRING"),A=N.for("SYMBOL_GEO_POLYGON"),L=N.for("SYMBOL_GEO_MULTI_POINT"),U=N.for("SYMBOL_GEO_MULTI_LINE_STRING"),P=N.for("SYMBOL_GEO_MULTI_POLYGON"),j=N.for("SERVER_DATE"),R=N.for("REGEXP"),q=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 D(t){return new q(t)}var C,M=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},F=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 i,o=e[n];switch(t.whichType(o)){case f:i=new z(o.coordinates[0],o.coordinates[1]);break;case c:i=new Q(o.coordinates.map((function(t){return new z(t[0],t[1])})));break;case l:i=new X(o.coordinates.map((function(t){return new Q(t.map((function(t){var e=M(t,2),n=e[0],r=e[1];return new z(n,r)})))})));break;case h:i=new tt(o.coordinates.map((function(t){return new z(t[0],t[1])})));break;case d:i=new nt(o.coordinates.map((function(t){return new Q(t.map((function(t){var e=M(t,2),n=e[0],r=e[1];return new z(n,r)})))})));break;case p:i=new it(o.coordinates.map((function(t){return new X(t.map((function(t){return new Q(t.map((function(t){var e=M(t,2),n=e[0],r=e[1];return new z(n,r)})))})))})));break;case y:i=new Date(1e3*o.$timestamp);break;case a:case"Array":i=t.formatField(o);break;case m:i=new Date(o.$date);break;default:i=o}Array.isArray(r)?r.push(i):r[n]=i})),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===y)return"BsonDate";if(e===a){if(t instanceof z)return f;if(t instanceof Date)return y;if(t instanceof q)return m;t.$timestamp?e=y:t.$date?e=m:z.validate(t)?e=f:Q.validate(t)?e=c:X.validate(t)?e=l:tt.validate(t)?e=h:nt.validate(t)?e=d:it.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}(),V=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==F.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+i.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===g.indexOf(t))throw new Error(i.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(i.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(i.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(i.DocIDError);return!0},t}(),J=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},k=function(t){return"object"===J(t)},H=function(t){return"number"===J(t)},Y=function(t){return Array.isArray(t)},G=function(t){return"date"===J(t)},Z=function(t){return"regexp"===J(t)},W=function(t){return t&&t._internalType instanceof E},z=function(){function t(t,e){V.isGeopoint("longitude",t),V.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&&Y(t.coordinates)&&V.isGeopoint("longitude",t.coordinates[0])&&V.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return $},enumerable:!1,configurable:!0}),t}(),Q=function(){function t(t){if(!Y(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||!Y(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),i=r.next();!i.done;i=r.next()){var o=i.value;if(!H(o[0])||!H(o[1]))return!1}}catch(t){e={error:t}}finally{try{i&&!i.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 B},enumerable:!1,configurable:!0}),t}(),K=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(!Y(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 Q))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"));if(!Q.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,i;if("Polygon"!==t.type||!Y(t.coordinates))return!1;try{for(var o=K(t.coordinates),s=o.next();!s.done;s=o.next()){var u=s.value;if(!this.isCloseLineString(u))return!1;try{for(var a=(r=void 0,K(u)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}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(!Y(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||!Y(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),i=r.next();!i.done;i=r.next()){var o=i.value;if(!H(o[0])||!H(o[1]))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},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(!Y(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 Q))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,i;if("MultiLineString"!==t.type||!Y(t.coordinates))return!1;try{for(var o=et(t.coordinates),s=o.next();!s.done;s=o.next()){var u=s.value;try{for(var a=(r=void 0,et(u)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}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.")},it=function(){function t(t){var e,n;if(!Y(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),i=r.next();!i.done;i=r.next()){var o=i.value;if(!(o instanceof X))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof o,"[]"))}}catch(t){e={error:t}}finally{try{i&&!i.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,i,o,s;if("MultiPolygon"!==t.type||!Y(t.coordinates))return!1;try{for(var u=rt(t.coordinates),a=u.next();!a.done;a=u.next()){var f=a.value;try{for(var c=(r=void 0,rt(f)),l=c.next();!l.done;l=c.next()){var h=l.value;try{for(var d=(o=void 0,rt(h)),p=d.next();!p.done;p=d.next()){var y=p.value;if(!H(y[0])||!H(y[1]))return!1}}catch(t){o={error:t}}finally{try{p&&!p.done&&(s=d.return)&&s.call(d)}finally{if(o)throw o.error}}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return A},enumerable:!1,configurable:!0}),t}(),ot=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,ut=function(){function t(t,e,n){this._internalType=x,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function at(t){return t&&t instanceof ut&&t._internalType===x}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ft=function(){function t(t,e,n){if(this._internalType=I,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S,this.fieldName!==S)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,i=e.length;r<i;r++)(ct(o=e[r])||pt(o))&&(e[r]=o._setFieldName(this.fieldName))}else{var o;(ct(o=e)||pt(o))&&(e=o._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 ct(t){return t&&t instanceof ft&&t._internalType===I}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 i=t.call(this,e,n,r)||this;return i.operator=e,i._internalType=T,i}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&&!H(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof t.maxDistance));if(void 0!==t.minDistance&&!H(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 it||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 Q||t.geometry instanceof X||t.geometry instanceof tt||t.geometry instanceof nt||t.geometry instanceof it))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}(ft);function pt(t){return t&&t instanceof dt&&t._internalType===T}function yt(t){return pt(t)}var mt={};for(var gt in lt)mt[gt]="$"+gt;for(var gt in st)mt[gt]="$"+gt;for(var gt in C)mt[gt]="$"+gt;function bt(t){return mt[t]||"$"+t}mt[lt.NEQ]="$ne",mt[C.REMOVE]="$unset",mt[C.SHIFT]="$pop",mt[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 i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},wt.apply(this,arguments)},vt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},_t=function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))};function Ot(t){return Et(t,[t])}function Et(t,e){if(!W(t)){if(G(t))return{$date:+t};if(Z(t))return{$regex:t.source,$options:t.flags};if(Y(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(k(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 $:return t.toJSON();case j:case R:return t.parse();default:return t.toJSON?t.toJSON():t}}var Nt=function(){return Nt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Nt.apply(this,arguments)},St=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s},xt=function(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))};function Tt(t,e,n,r){var i=Nt({},t);for(var o in t)if(!/^\$/.test(o)){var s=t[o];if(s&&k(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var u=Tt(s,e,xt(xt([],St(n),!1),[o],!1),xt(xt([],St(r),!1),[s],!1));i[o]=u;var a=!1;for(var f in u)/^\$/.test(f)?a=!0:(i["".concat(o,".").concat(f)]=u[f],delete i[o][f]);a||delete i[o]}}return i}function It(t){return Tt(t,Bt,[],[t])}function $t(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?Y(t[r])?t[r].push(e[r]):k(t[r])?k(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is ".concat(J(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(J(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]}function Bt(t){return W(t)||G(t)||Z(t)}function At(t){return Ot(t)}var Lt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return at(t)?this.encodeUpdateCommand(t):"object"===J(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===S)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,i,o=bt(t.operator);return t.operator===C.REMOVE?((e={})[o]=((n={})[t.fieldName]="",n),e):((r={})[o]=((i={})[t.fieldName]=t.operands[0],i),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,i,o,s,u,a,f,c,l=bt(t.operator);switch(t.operator){case C.PUSH:var h=void 0;return h=Y(t.operands)?{$each:t.operands.map(At)}:t.operands,(e={})[l]=((n={})[t.fieldName]=h,n),e;case C.UNSHIFT:return h={$each:t.operands.map(At),$position:0},(r={})[l]=((i={})[t.fieldName]=h,i),r;case C.POP:return(o={})[l]=((s={})[t.fieldName]=1,s),o;case C.SHIFT:return(u={})[l]=((a={})[t.fieldName]=-1,a),u;default:return(f={})[l]=((c={})[t.fieldName]=At(t.operands),c),f}},t.prototype.encodeUpdateObject=function(t){var e=It(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(at(r))e[n]=r._setFieldName(n),$t(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=At(r);var i=new ut(C.SET,[r],n);$t(e,this.encodeUpdateCommand(i),n)}}return e},t}(),Ut={};function Pt(t){if(!Jn.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Ut[e]||(Ut[e]=new Jn.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:Jn.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 i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},jt.apply(this,arguments)},Rt=function(){function t(t,e,n,r){void 0===r&&(r={});var i=this;this.watch=function(t){return Pt(i._db).watch(jt(jt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify({_id:i.id})}))},this._db=t,this._coll=e,this.id=n,this.request=Jn.createRequest(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||ot();var n={collectionName:this._coll,data:Ot(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||ot(),!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 ut?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 i={collectionName:this._coll,queryType:u.DOC,data:Ot(t),multi:!1,merge:!1,upsert:!0};return this.id&&(i.query={_id:this.id}),this.request.send("database.updateDocument",i).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||ot(),!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:Lt.encode(t),query:n,queryType:u.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||ot();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:u.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||ot();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:u.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=F.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}(),qt=function(){function t(){}return t.encode=function(t){return(new Dt).encodeQuery(t)},t}(),Dt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Bt(t)?ct(t)?this.encodeLogicCommand(t):pt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):k(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,i,o,s,u,a=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var f=bt(t.operator),c=t.operands.map((function(e){return a.encodeQuery(e,t.fieldName)}));return(e={})[f]=c,e;case st.NOT:f=bt(t.operator);var l=t.operands[0];return Z(l)?((n={})[t.fieldName]=((r={})[f]=this.encodeRegExp(l),r),n):(c=this.encodeQuery(l)[t.fieldName],(i={})[t.fieldName]=((o={})[f]=c,o),i);default:if(f=bt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[f]=h,s}return c=t.operands.map(this.encodeQuery.bind(this)),(u={})[f]=c,u}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,i,o,s,u,a,f;if(t.fieldName===S)throw new Error("Cannot encode a comparison command with unset field name");var c=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={})[c]=At(t.operands[0]),n),e;case lt.IN:case lt.NIN:case lt.ALL:return(r={})[t.fieldName]=((i={})[c]=At(t.operands),i),r;case lt.GEO_NEAR:var l=t.operands[0];return(o={})[t.fieldName]={$nearSphere:{$geometry:l.geometry.toJSON(),$maxDistance:l.maxDistance,$minDistance:l.minDistance}},o;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],(u={})[t.fieldName]={$geoIntersects:{$geometry:l.geometry.toJSON()}},u;default:return(a={})[t.fieldName]=((f={})[c]=At(t.operands[0]),f),a}},t.prototype.encodeQueryObject=function(t){var e=It(t);for(var n in e){var r=e[n];if(ct(r)){e[n]=r._setFieldName(n);var i=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,i,n)}else yt(r)?(e[n]=r._setFieldName(n),i=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,i,n)):Bt(r)&&(e[n]=At(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?Y(t[r])?t[r]=t[r].concat(e[r]):k(t[r])?k(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is ".concat(J(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(J(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 i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Ct.apply(this,arguments)},Mt=function(){function t(t,e,n,r,i){var o=this;this.watch=function(t){return Pt(o._db).watch(Ct(Ct({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify(o._fieldFilters||{}),limit:o._queryOptions.limit,orderBy:o._fieldOrders?o._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=i||{},this._request=Jn.createRequest(this._db.config)}return t.prototype.get=function(t){t=t||ot();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:u.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:F.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||ot();var e={collectionName:this._coll,queryType:u.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(i.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(i.QueryParamValueError);return new t(this._db,this._coll,qt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){V.isFieldPath(e),V.isFieldOrder(n);var r={field:e,direction:n},i=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,i,this._queryOptions)},t.prototype.limit=function(e){V.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){V.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||ot(),!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:u.WHERE,multi:!0,merge:!0,upsert:!1,data:Lt.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||ot(),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:qt.encode(this._fieldFilters),queryType:u.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}();const Ft=(()=>{const t=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return e=>t.call(e)})();function Vt(t){return"Uint8Array"===Ft(t)}function Jt(t){return"object"==typeof t&&null!=t&&Symbol.toStringTag in t&&"Map"===t[Symbol.toStringTag]}function kt(t,e){return JSON.stringify(t,((t,e)=>"bigint"==typeof e?{$numberLong:`${e}`}:Jt(e)?Object.fromEntries(e):e))}const Ht=7,Yt=Symbol.for("@@mdb.bson.version"),Gt=2147483647,Zt=-2147483648,Wt=Math.pow(2,63)-1,zt=-Math.pow(2,63),Qt=Math.pow(2,53),Kt=-Math.pow(2,53);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 Xt 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 te extends Xt{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${Ht}.x.x`)}}class ee extends Xt{get name(){return"BSONRuntimeError"}constructor(t){super(t)}}class ne extends Xt{get name(){return"BSONOffsetError"}offset;constructor(t,e,n){super(`${t}. offset: ${e}`,n),this.offset=e}}let re,ie;function oe(t,e,n,r){if(r){re??=new TextDecoder("utf8",{fatal:!0});try{return re.decode(t.subarray(e,n))}catch(t){throw new Xt("Invalid UTF-8 string in BSON document",{cause:t})}}return ie??=new TextDecoder("utf8",{fatal:!1}),ie.decode(t.subarray(e,n))}function se(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 i=[];for(let r=e;r<n;r++){const e=t[r];if(e>127)return null;i.push(e)}return String.fromCharCode(...i)}function ue(t){return ce.fromNumberArray(Array.from({length:t},(()=>Math.floor(256*Math.random()))))}function ae(t){return crypto.getRandomValues(ce.allocate(t))}const fe=(()=>{const{crypto:t}=globalThis;return null!=t&&"function"==typeof t.getRandomValues?ae:ue})(),ce={isUint8Array:Vt,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 Xt("Cannot create Buffer from the passed potentialBuffer.")},allocate:t=>Buffer.alloc(t),allocateUnsafe:t=>Buffer.allocUnsafe(t),compare:(t,e)=>ce.toLocalBufferType(t).compare(e),concat:t=>Buffer.concat(t),equals:(t,e)=>ce.toLocalBufferType(t).equals(e),fromNumberArray:t=>Buffer.from(t),fromBase64:t=>Buffer.from(t,"base64"),fromUTF8:t=>Buffer.from(t,"utf8"),toBase64:t=>ce.toLocalBufferType(t).toString("base64"),fromISO88591:t=>Buffer.from(t,"binary"),toISO88591:t=>ce.toLocalBufferType(t).toString("binary"),fromHex:t=>Buffer.from(t,"hex"),toHex:t=>ce.toLocalBufferType(t).toString("hex"),toUTF8(t,e,n,r){const i=n-e<=20?se(t,e,n):null;if(null!=i)return i;const o=ce.toLocalBufferType(t).toString("utf8",e,n);if(r)for(let r=0;r<o.length;r++)if(65533===o.charCodeAt(r)){oe(t,e,n,!0);break}return o},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,i=n;r<e.length;r++,i++){const n=e.charCodeAt(r);if(n>127)return null;t[i]=n}return e.length}(t,e,n);return null!=r?r:ce.toLocalBufferType(t).write(e,n,void 0,"utf8")},randomBytes:fe,swap32:t=>ce.toLocalBufferType(t).swap32()};function le(t){if(t<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${t}`);return pe.fromNumberArray(Array.from({length:t},(()=>Math.floor(256*Math.random()))))}const he=(()=>{const{crypto:t}=globalThis;if(null!=t&&"function"==typeof t.getRandomValues)return e=>t.getRandomValues(pe.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 le})(),de=/(\d|[a-f])/i,pe={isUint8Array:Vt,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 Xt("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=>pe.allocate(t),compare(t,e){if(t===e)return 0;const n=Math.min(t.length,e.length);for(let r=0;r<n;r++){if(t[r]<e[r])return-1;if(t[r]>e[r])return 1}return t.length<e.length?-1:t.length>e.length?1:0},concat(t){if(0===t.length)return pe.allocate(0);let e=0;for(const n of t)e+=n.length;const n=pe.allocate(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n},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))),fromUTF8:t=>(new TextEncoder).encode(t),toBase64:t=>btoa(pe.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],i=e[t+1];if(!de.test(r))break;if(!de.test(i))break;const o=Number.parseInt(`${r}${i}`,16);n.push(o)}return Uint8Array.from(n)},toHex:t=>Array.from(t,(t=>t.toString(16).padStart(2,"0"))).join(""),toUTF8(t,e,n,r){const i=n-e<=20?se(t,e,n):null;return null!=i?i:oe(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:he,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],i=t[e+2],o=t[e+3];t[e]=o,t[e+1]=i,t[e+2]=r,t[e+3]=n}return t}},ye="function"==typeof Buffer&&!0!==Buffer.prototype?._isBuffer?ce:pe,me=Symbol.for("@@mdb.bson.type");class ge{get[me](){return this._bsontype}get[Yt](){return Ht}[Symbol.for("nodejs.util.inspect.custom")](t,e,n){return this.inspect(t,e,n)}}const be=new Float64Array(1),we=new Uint8Array(be.buffer,0,8);be[0]=-1;const ve=0===we[7],_e={isBigEndian:ve,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)=>(BigInt(t[e+4]+256*t[e+5]+65536*t[e+6]+(t[e+7]<<24))<<32n)+BigInt(t[e]+256*t[e+1]+65536*t[e+2]+16777216*t[e+3]),getFloat64LE:ve?(t,e)=>(we[7]=t[e],we[6]=t[e+1],we[5]=t[e+2],we[4]=t[e+3],we[3]=t[e+4],we[2]=t[e+5],we[1]=t[e+6],we[0]=t[e+7],be[0]):(t,e)=>(we[0]=t[e],we[1]=t[e+1],we[2]=t[e+2],we[3]=t[e+3],we[4]=t[e+4],we[5]=t[e+5],we[6]=t[e+6],we[7]=t[e+7],be[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=0xffffffffn;let i=Number(n&r);t[e]=i,i>>=8,t[e+1]=i,i>>=8,t[e+2]=i,i>>=8,t[e+3]=i;let o=Number(n>>32n&r);return t[e+4]=o,o>>=8,t[e+5]=o,o>>=8,t[e+6]=o,o>>=8,t[e+7]=o,8},setFloat64LE:ve?(t,e,n)=>(be[0]=n,t[e]=we[7],t[e+1]=we[6],t[e+2]=we[5],t[e+3]=we[4],t[e+4]=we[3],t[e+5]=we[2],t[e+6]=we[1],t[e+7]=we[0],8):(t,e,n)=>(be[0]=n,t[e]=we[0],t[e+1]=we[1],t[e+2]=we[2],t[e+3]=we[3],t[e+4]=we[4],t[e+5]=we[5],t[e+6]=we[6],t[e+7]=we[7],8)};class Oe extends ge{get _bsontype(){return"Binary"}static BSON_BINARY_SUBTYPE_DEFAULT=0;static BUFFER_SIZE=256;static SUBTYPE_DEFAULT=0;static SUBTYPE_FUNCTION=1;static SUBTYPE_BYTE_ARRAY=2;static SUBTYPE_UUID_OLD=3;static SUBTYPE_UUID=4;static SUBTYPE_MD5=5;static SUBTYPE_ENCRYPTED=6;static SUBTYPE_COLUMN=7;static SUBTYPE_SENSITIVE=8;static SUBTYPE_VECTOR=9;static SUBTYPE_USER_DEFINED=128;static VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});buffer;sub_type;position;constructor(t,e){if(super(),null!=t&&"string"==typeof t&&!ArrayBuffer.isView(t)&&("object"!=typeof(n=t)||null==n||!(Symbol.toStringTag in n)||"ArrayBuffer"!==n[Symbol.toStringTag]&&"SharedArrayBuffer"!==n[Symbol.toStringTag])&&!Array.isArray(t))throw new Xt("Binary can only be constructed from Uint8Array or number[]");var n;this.sub_type=e??Oe.BSON_BINARY_SUBTYPE_DEFAULT,null==t?(this.buffer=ye.allocate(Oe.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?ye.fromNumberArray(t):ye.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if("string"==typeof t&&1!==t.length)throw new Xt("only accepts single character String");if("number"!=typeof t&&1!==t.length)throw new Xt("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 Xt("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=ye.allocate(Oe.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=ye.allocate(this.buffer.byteLength+t.length);e.set(this.buffer,0),this.buffer=e}if(ArrayBuffer.isView(t))this.buffer.set(ye.toLocalBufferType(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position;else if("string"==typeof t)throw new Xt("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 ye.toBase64(this.buffer.subarray(0,this.position))}toString(t){return"hex"===t?ye.toHex(this.buffer.subarray(0,this.position)):"base64"===t?ye.toBase64(this.buffer.subarray(0,this.position)):ye.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(t){t=t||{},this.sub_type===Oe.SUBTYPE_VECTOR&&Ee(this);const e=ye.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===Oe.SUBTYPE_UUID)return new xe(this.buffer.subarray(0,this.position));throw new Xt(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Oe.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,e){return new Oe(ye.fromHex(t),e)}static createFromBase64(t,e){return new Oe(ye.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=ye.fromBase64(t.$binary)):"string"!=typeof t.$binary&&(r=t.$binary.subType?parseInt(t.$binary.subType,16):0,n=ye.fromBase64(t.$binary.base64)):"$uuid"in t&&(r=4,n=xe.bytesFromString(t.$uuid)),!n)throw new Xt(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return 4===r?new xe(n):new Oe(n,r)}inspect(t,e,n){return n??=kt,`Binary.createFromBase64(${n(ye.toBase64(this.buffer.subarray(0,this.position)),e)}, ${n(this.sub_type,e)})`}toInt8Array(){if(this.sub_type!==Oe.SUBTYPE_VECTOR)throw new Xt("Binary sub_type is not Vector");if(this.buffer[0]!==Oe.VECTOR_TYPE.Int8)throw new Xt("Binary datatype field is not Int8");return Ee(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==Oe.SUBTYPE_VECTOR)throw new Xt("Binary sub_type is not Vector");if(this.buffer[0]!==Oe.VECTOR_TYPE.Float32)throw new Xt("Binary datatype field is not Float32");Ee(this);const t=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return _e.isBigEndian&&ye.swap32(t),new Float32Array(t.buffer)}toPackedBits(){if(this.sub_type!==Oe.SUBTYPE_VECTOR)throw new Xt("Binary sub_type is not Vector");if(this.buffer[0]!==Oe.VECTOR_TYPE.PackedBit)throw new Xt("Binary datatype field is not packed bit");return Ee(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==Oe.SUBTYPE_VECTOR)throw new Xt("Binary sub_type is not Vector");if(this.buffer[0]!==Oe.VECTOR_TYPE.PackedBit)throw new Xt("Binary datatype field is not packed bit");Ee(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=ye.allocate(t.byteLength+2);e[0]=Oe.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 Ee(r),r}static fromFloat32Array(t){const e=ye.allocate(t.byteLength+2);e[0]=Oe.VECTOR_TYPE.Float32,e[1]=0;const n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);e.set(n,2),_e.isBigEndian&&ye.swap32(new Uint8Array(e.buffer,2));const r=new this(e,this.SUBTYPE_VECTOR);return Ee(r),r}static fromPackedBits(t,e=0){const n=ye.allocate(t.byteLength+2);n[0]=Oe.VECTOR_TYPE.PackedBit,n[1]=e,n.set(t,2);const r=new this(n,this.SUBTYPE_VECTOR);return Ee(r),r}static fromBits(t){const e=t.length+7>>>3,n=new Uint8Array(e+2);n[0]=Oe.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,i=t[e];if(0!==i&&1!==i)throw new Xt(`Invalid bit value at ${e}: must be 0 or 1, found ${t[e]}`);if(0===i)continue;const o=7-e%8;n[r+2]|=i<<o}return new this(n,Oe.SUBTYPE_VECTOR)}}function Ee(t){if(t.sub_type!==Oe.SUBTYPE_VECTOR)return;const e=t.position,n=t.buffer[0],r=t.buffer[1];if((n===Oe.VECTOR_TYPE.Float32||n===Oe.VECTOR_TYPE.Int8)&&0!==r)throw new Xt("Invalid Vector: padding must be zero for int8 and float32 vectors");if(n===Oe.VECTOR_TYPE.Float32&&0!==e&&e-2!=0&&(e-2)%4!=0)throw new Xt("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(n===Oe.VECTOR_TYPE.PackedBit&&0!==r&&2===e)throw new Xt("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(n===Oe.VECTOR_TYPE.PackedBit&&r>7)throw new Xt(`Invalid Vector: padding must be a value between 0 and 7. found: ${r}`)}const Ne=/^[0-9A-F]{32}$/i,Se=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class xe extends Oe{constructor(t){let e;if(null==t)e=xe.generate();else if(t instanceof xe)e=ye.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&16===t.byteLength)e=ye.toLocalBufferType(t);else{if("string"!=typeof t)throw new Xt("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=xe.bytesFromString(t)}super(e,4)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[ye.toHex(this.buffer.subarray(0,4)),ye.toHex(this.buffer.subarray(4,6)),ye.toHex(this.buffer.subarray(6,8)),ye.toHex(this.buffer.subarray(8,10)),ye.toHex(this.buffer.subarray(10,16))].join("-"):ye.toHex(this.buffer)}toString(t){return"hex"===t?ye.toHex(this.id):"base64"===t?ye.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof xe)return ye.equals(t.id,this.id);try{return ye.equals(new xe(t).id,this.id)}catch{return!1}}toBinary(){return new Oe(this.id,Oe.SUBTYPE_UUID)}static generate(){const t=ye.randomBytes(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,t}static isValid(t){return!!t&&("string"==typeof t?xe.isValidUUIDString(t):Vt(t)?16===t.byteLength:"Binary"===t._bsontype&&t.sub_type===this.SUBTYPE_UUID&&16===t.buffer.byteLength)}static createFromHexString(t){const e=xe.bytesFromString(t);return new xe(e)}static createFromBase64(t){return new xe(ye.fromBase64(t))}static bytesFromString(t){if(!xe.isValidUUIDString(t))throw new Xt("UUID string representation must be 32 hex digits or canonical hyphenated representation");return ye.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return Ne.test(t)||Se.test(t)}inspect(t,e,n){return n??=kt,`new UUID(${n(this.toHexString(),e)})`}}class Te extends ge{get _bsontype(){return"Code"}code;scope;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 Te(t.$code,t.$scope)}inspect(t,e,n){n??=kt;let r=n(this.code,e);const i=r.includes("\n");return null!=this.scope&&(r+=`,${i?"\n":" "}${n(this.scope,e)}`),`new Code(${i?"\n":""}${r}${i&&null===this.scope?"\n":""})`}}class Ie extends ge{get _bsontype(){return"DBRef"}collection;oid;db;fields;constructor(t,e,n,r){super();const i=t.split(".");2===i.length&&(n=i.shift(),t=i.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 Ie(t.$ref,t.$id,t.$db,e)}inspect(t,e,n){n??=kt;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===kt?`new ObjectId(${r[1]})`:r[1],`new DBRef(${r.join(", ")})`}}function $e(t){if(""===t)return t;let e=0;const n="-"===t[e],r="+"===t[e];(r||n)&&(e+=1);let i=!1;for(;e<t.length&&"0"===t[e];++e)i=!0;return i?`${n?"-":""}${t.length===e?"0":t.slice(e)}`:r?t.slice(1):t}let Be;try{Be=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 Ae=4294967296,Le=0x10000000000000000,Ue=Le/2,Pe={},je={},Re=/^(\+?0|(\+|-)?[1-9][0-9]*)$/;class qe extends ge{get _bsontype(){return"Long"}get __isLong__(){return!0}high;low;unsigned;constructor(t=0,e,n){super();const r="boolean"==typeof e?e:Boolean(n),i="number"==typeof e?e:0,o="string"==typeof t?qe.fromString(t,r):"bigint"==typeof t?qe.fromBigInt(t,r):{low:0|t,high:0|i,unsigned:r};this.low=o.low,this.high=o.high,this.unsigned=o.unsigned}static TWO_PWR_24=qe.fromInt(16777216);static MAX_UNSIGNED_VALUE=qe.fromBits(-1,-1,!0);static ZERO=qe.fromInt(0);static UZERO=qe.fromInt(0,!0);static ONE=qe.fromInt(1);static UONE=qe.fromInt(1,!0);static NEG_ONE=qe.fromInt(-1);static MAX_VALUE=qe.fromBits(-1,2147483647,!1);static MIN_VALUE=qe.fromBits(0,-2147483648,!1);static fromBits(t,e,n){return new qe(t,e,n)}static fromInt(t,e){let n,r,i;return e?(i=0<=(t>>>=0)&&t<256)&&(r=je[t],r)?r:(n=qe.fromBits(t,(0|t)<0?-1:0,!0),i&&(je[t]=n),n):(i=-128<=(t|=0)&&t<128)&&(r=Pe[t],r)?r:(n=qe.fromBits(t,t<0?-1:0,!1),i&&(Pe[t]=n),n)}static fromNumber(t,e){if(isNaN(t))return e?qe.UZERO:qe.ZERO;if(e){if(t<0)return qe.UZERO;if(t>=Le)return qe.MAX_UNSIGNED_VALUE}else{if(t<=-Ue)return qe.MIN_VALUE;if(t+1>=Ue)return qe.MAX_VALUE}return t<0?qe.fromNumber(-t,e).neg():qe.fromBits(t%Ae|0,t/Ae|0,e)}static fromBigInt(t,e){const n=0xffffffffn;return new qe(Number(t&n),Number(t>>32n&n),e)}static _fromString(t,e,n){if(0===t.length)throw new Xt("empty string");if(n<2||36<n)throw new Xt("radix");let r;if((r=t.indexOf("-"))>0)throw new Xt("interior hyphen");if(0===r)return qe._fromString(t.substring(1),e,n).neg();const i=qe.fromNumber(Math.pow(n,8));let o=qe.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=qe.fromNumber(Math.pow(n,r));o=o.mul(t).add(qe.fromNumber(s))}else o=o.mul(i),o=o.add(qe.fromNumber(s))}return o.unsigned=e,o}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 Xt(`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 Xt(`Input: '${t}' contains invalid characters for radix: ${n}`);const i=$e(t),o=qe._fromString(i,r,n);if(o.toString(n).toLowerCase()!==i.toLowerCase())throw new Xt(`Input: ${t} is not representable as ${o.unsigned?"an unsigned":"a signed"} 64-bit Long ${null!=n?`with radix: ${n}`:""}`);return o}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?qe.ZERO:qe._fromString(t,r,n)}static fromBytes(t,e,n){return n?qe.fromBytesLE(t,e):qe.fromBytesBE(t,e)}static fromBytesLE(t,e){return new qe(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 qe(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?qe.fromNumber(t,e):"string"==typeof t?qe.fromString(t,e):qe.fromBits(t.low,t.high,"boolean"==typeof e?e:t.unsigned)}add(t){qe.isLong(t)||(t=qe.fromValue(t));const e=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=t.high>>>16,s=65535&t.high,u=t.low>>>16;let a=0,f=0,c=0,l=0;return l+=i+(65535&t.low),c+=l>>>16,l&=65535,c+=r+u,f+=c>>>16,c&=65535,f+=n+s,a+=f>>>16,f&=65535,a+=e+o,a&=65535,qe.fromBits(c<<16|l,a<<16|f,this.unsigned)}and(t){return qe.isLong(t)||(t=qe.fromValue(t)),qe.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(qe.isLong(t)||(t=qe.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(qe.isLong(t)||(t=qe.fromValue(t)),t.isZero())throw new Xt("division by zero");if(Be){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;const e=(this.unsigned?Be.div_u:Be.div_s)(this.low,this.high,t.low,t.high);return qe.fromBits(e,Be.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?qe.UZERO:qe.ZERO;let e,n,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return qe.UZERO;if(t.gt(this.shru(1)))return qe.UONE;r=qe.UZERO}else{if(this.eq(qe.MIN_VALUE))return t.eq(qe.ONE)||t.eq(qe.NEG_ONE)?qe.MIN_VALUE:t.eq(qe.MIN_VALUE)?qe.ONE:(e=this.shr(1).div(t).shl(1),e.eq(qe.ZERO)?t.isNegative()?qe.ONE:qe.NEG_ONE:(n=this.sub(t.mul(e)),r=e.add(n.div(t)),r));if(t.eq(qe.MIN_VALUE))return this.unsigned?qe.UZERO:qe.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=qe.ZERO}for(n=this;n.gte(t);){e=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));const i=Math.ceil(Math.log(e)/Math.LN2),o=i<=48?1:Math.pow(2,i-48);let s=qe.fromNumber(e),u=s.mul(t);for(;u.isNegative()||u.gt(n);)e-=o,s=qe.fromNumber(e,this.unsigned),u=s.mul(t);s.isZero()&&(s=qe.ONE),r=r.add(s),n=n.sub(u)}return r}div(t){return this.divide(t)}equals(t){return qe.isLong(t)||(t=qe.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(qe.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(qe.isLong(t)||(t=qe.fromValue(t)),Be){const e=(this.unsigned?Be.rem_u:Be.rem_s)(this.low,this.high,t.low,t.high);return qe.fromBits(e,Be.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 qe.ZERO;if(qe.isLong(t)||(t=qe.fromValue(t)),Be){const e=Be.mul(this.low,this.high,t.low,t.high);return qe.fromBits(e,Be.get_high(),this.unsigned)}if(t.isZero())return qe.ZERO;if(this.eq(qe.MIN_VALUE))return t.isOdd()?qe.MIN_VALUE:qe.ZERO;if(t.eq(qe.MIN_VALUE))return this.isOdd()?qe.MIN_VALUE:qe.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(qe.TWO_PWR_24)&&t.lt(qe.TWO_PWR_24))return qe.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);const e=this.high>>>16,n=65535&this.high,r=this.low>>>16,i=65535&this.low,o=t.high>>>16,s=65535&t.high,u=t.low>>>16,a=65535&t.low;let f=0,c=0,l=0,h=0;return h+=i*a,l+=h>>>16,h&=65535,l+=r*a,c+=l>>>16,l&=65535,l+=i*u,c+=l>>>16,l&=65535,c+=n*a,f+=c>>>16,c&=65535,c+=r*u,f+=c>>>16,c&=65535,c+=i*s,f+=c>>>16,c&=65535,f+=e*a+n*u+r*s+i*o,f&=65535,qe.fromBits(l<<16|h,f<<16|c,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(qe.MIN_VALUE)?qe.MIN_VALUE:this.not().add(qe.ONE)}neg(){return this.negate()}not(){return qe.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 qe.isLong(t)||(t=qe.fromValue(t)),qe.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return qe.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?qe.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):qe.fromBits(0,this.low<<t-32,this.unsigned)}shl(t){return this.shiftLeft(t)}shiftRight(t){return qe.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?qe.fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):qe.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(qe.isLong(t)&&(t=t.toInt()),0==(t&=63))return this;{const e=this.high;if(t<32){const n=this.low;return qe.fromBits(n>>>t|e<<32-t,e>>>t,this.unsigned)}return 32===t?qe.fromBits(e,0,this.unsigned):qe.fromBits(e>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return qe.isLong(t)||(t=qe.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)*Ae+(this.low>>>0):this.high*Ae+(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?qe.fromBits(this.low,this.high,!1):this}toString(t){if((t=t||10)<2||36<t)throw new Xt("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(qe.MIN_VALUE)){const e=qe.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=qe.fromNumber(Math.pow(t,6),this.unsigned);let n=this,r="";for(;;){const i=n.div(e);let o=(n.sub(i.mul(e)).toInt()>>>0).toString(t);if(n=i,n.isZero())return o+r;for(;o.length<6;)o="0"+o;r=""+o+r}}toUnsigned(){return this.unsigned?this:qe.fromBits(this.low,this.high,!0)}xor(t){return qe.isLong(t)||(t=qe.fromValue(t)),qe.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 Xt("$numberLong string is too long");if(!Re.test(t.$numberLong))throw new Xt(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(n){const e=BigInt(t.$numberLong);return BigInt.asIntN(64,e)}const i=qe.fromString(t.$numberLong);return r?i.toNumber():i}inspect(t,e,n){return n??=kt,`new Long(${n(this.toString(),e)}${this.unsigned?`, ${n(this.unsigned,e)}`:""})`}}const De=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Ce=/^(\+|-)?(Infinity|inf)$/i,Me=/^(\+|-)?NaN$/i,Fe=6111,Ve=-6176,Je=ye.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ke=ye.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),He=ye.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Ye=/^([-+])?(\d+)?$/;function Ge(t){return!isNaN(parseInt(t,10))}function Ze(t){const e=qe.fromNumber(1e9);let n=qe.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 qe(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function We(t,e){throw new Xt(`"${t}" is not a valid Decimal128 string - ${e}`)}class ze extends ge{get _bsontype(){return"Decimal128"}bytes;constructor(t){if(super(),"string"==typeof t)this.bytes=ze.fromString(t).bytes;else{if(!(t instanceof Uint8Array||Vt(t)))throw new Xt("Decimal128 must take a Buffer or string");if(16!==t.byteLength)throw new Xt("Decimal128 must take a Buffer of 16 bytes");this.bytes=t}}static fromString(t){return ze._fromString(t,{allowRounding:!1})}static fromStringWithRounding(t){return ze._fromString(t,{allowRounding:!0})}static _fromString(t,e){let n=!1,r=!1,i=!1,o=!1,s=0,u=0,a=0,f=0,c=0;const l=[0];let h=0,d=0,p=0,y=0,m=new qe(0,0),g=new qe(0,0),b=0,w=0;if(t.length>=7e3)throw new Xt(t+" not a valid Decimal128 string");const v=t.match(De),_=t.match(Ce),O=t.match(Me);if(!v&&!_&&!O||0===t.length)throw new Xt(t+" not a valid Decimal128 string");if(v){const e=v[2],n=v[4],r=v[5],i=v[6];n&&void 0===i&&We(t,"missing exponent power"),n&&void 0===e&&We(t,"missing exponent base"),void 0===n&&(r||i)&&We(t,"missing e before exponent")}if("+"!==t[w]&&"-"!==t[w]||(r=!0,n="-"===t[w++]),!Ge(t[w])&&"."!==t[w]){if("i"===t[w]||"I"===t[w])return new ze(n?ke:He);if("N"===t[w])return new ze(Je)}for(;Ge(t[w])||"."===t[w];)"."!==t[w]?(h<34&&("0"!==t[w]||o)&&(o||(c=u),o=!0,l[d++]=parseInt(t[w],10),h+=1),o&&(a+=1),i&&(f+=1),u+=1,w+=1):(i&&We(t,"contains multiple periods"),i=!0,w+=1);if(i&&!u)throw new Xt(t+" not a valid Decimal128 string");if("e"===t[w]||"E"===t[w]){const e=t.substr(++w).match(Ye);if(!e||!e[2])return new ze(Je);y=parseInt(e[0],10),w+=e[0].length}if(t[w])return new ze(Je);if(h){if(p=h-1,s=a,1!==s)for(;"0"===t[c+s-1+Number(r)+Number(i)];)s-=1}else l[0]=0,a=1,h=1,s=0;for(y<=f&&f>y+16384?y=Ve:y-=f;y>Fe;){if(p+=1,p>=34){if(0===s){y=Fe;break}We(t,"overflow")}y-=1}if(e.allowRounding){for(;y<Ve||h<a;){if(0===p&&s<h){y=Ve,s=0;break}if(h<a?a-=1:p-=1,y<Fe)y+=1;else{if(l.join("").match(/^0+$/)){y=Fe;break}We(t,"overflow")}}if(p+1<s){let e=u;i&&(c+=1,e+=1),r&&(c+=1,e+=1);const o=parseInt(t[c+p+1],10);let s=0;if(o>=5&&(s=1,5===o)){s=l[p]%2==1?1:0;for(let n=c+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<Fe))return new ze(n?ke:He);y+=1,l[t]=1}}}}else{for(;y<Ve||h<a;){if(0===p){if(0===s){y=Ve;break}We(t,"exponent underflow")}h<a?("0"!==t[a-1+Number(r)+Number(i)]&&0!==s&&We(t,"inexact rounding"),a-=1):(0!==l[p]&&We(t,"inexact rounding"),p-=1),y<Fe?y+=1:We(t,"overflow")}p+1<s&&(i&&(c+=1),r&&(c+=1),0!==parseInt(t[c+p+1],10)&&We(t,"inexact rounding"))}if(m=qe.fromNumber(0),g=qe.fromNumber(0),0===s)m=qe.fromNumber(0),g=qe.fromNumber(0);else if(p<17){let t=0;for(g=qe.fromNumber(l[t++]),m=new qe(0,0);t<=p;t++)g=g.multiply(qe.fromNumber(10)),g=g.add(qe.fromNumber(l[t]))}else{let t=0;for(m=qe.fromNumber(l[t++]);t<=p-17;t++)m=m.multiply(qe.fromNumber(10)),m=m.add(qe.fromNumber(l[t]));for(g=qe.fromNumber(l[t++]);t<=p;t++)g=g.multiply(qe.fromNumber(10)),g=g.add(qe.fromNumber(l[t]))}const E=function(t,e){if(!t&&!e)return{high:qe.fromNumber(0),low:qe.fromNumber(0)};const n=t.shiftRightUnsigned(32),r=new qe(t.getLowBits(),0),i=e.shiftRightUnsigned(32),o=new qe(e.getLowBits(),0);let s=n.multiply(i),u=n.multiply(o);const a=r.multiply(i);let f=r.multiply(o);return s=s.add(u.shiftRightUnsigned(32)),u=new qe(u.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),s=s.add(u.shiftRightUnsigned(32)),f=u.shiftLeft(32).add(new qe(f.getLowBits(),0)),{high:s,low:f}}(m,qe.fromString("100000000000000000"));E.low=E.low.add(g),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,g)&&(E.high=E.high.add(qe.fromNumber(1))),b=y+6176;const N={low:qe.fromNumber(0),high:qe.fromNumber(0)};E.high.shiftRightUnsigned(49).and(qe.fromNumber(1)).equals(qe.fromNumber(1))?(N.high=N.high.or(qe.fromNumber(3).shiftLeft(61)),N.high=N.high.or(qe.fromNumber(b).and(qe.fromNumber(16383).shiftLeft(47))),N.high=N.high.or(E.high.and(qe.fromNumber(0x7fffffffffff)))):(N.high=N.high.or(qe.fromNumber(16383&b).shiftLeft(49)),N.high=N.high.or(E.high.and(qe.fromNumber(562949953421311)))),N.low=E.low,n&&(N.high=N.high.or(qe.fromString("9223372036854775808")));const S=ye.allocateUnsafe(16);return w=0,S[w++]=255&N.low.low,S[w++]=N.low.low>>8&255,S[w++]=N.low.low>>16&255,S[w++]=N.low.low>>24&255,S[w++]=255&N.low.high,S[w++]=N.low.high>>8&255,S[w++]=N.low.high>>16&255,S[w++]=N.low.high>>24&255,S[w++]=255&N.high.low,S[w++]=N.high.low>>8&255,S[w++]=N.high.low>>16&255,S[w++]=N.high.low>>24&255,S[w++]=255&N.high.high,S[w++]=N.high.high>>8&255,S[w++]=N.high.high>>16&255,S[w++]=N.high.high>>24&255,new ze(S)}toString(){let t,e=0;const n=new Array(36);for(let t=0;t<n.length;t++)n[t]=0;let r,i,o,s=0,u=!1,a={parts:[0,0,0,0]};const f=[];s=0;const c=this.bytes,l=c[s++]|c[s++]<<8|c[s++]<<16|c[s++]<<24,h=c[s++]|c[s++]<<8|c[s++]<<16|c[s++]<<24,d=c[s++]|c[s++]<<8|c[s++]<<16|c[s++]<<24,p=c[s++]|c[s++]<<8|c[s++]<<16|c[s++]<<24;s=0,(new qe(l,h),new qe(d,p)).lessThan(qe.ZERO)&&f.push("-");const y=p>>26&31;if(y>>3==3){if(30===y)return f.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 m=t-6176;if(a.parts[0]=(16383&p)+((15&r)<<14),a.parts[1]=d,a.parts[2]=h,a.parts[3]=l,0===a.parts[0]&&0===a.parts[1]&&0===a.parts[2]&&0===a.parts[3])u=!0;else for(o=3;o>=0;o--){let t=0;const e=Ze(a);if(a=e.quotient,t=e.rem.low,t)for(i=8;i>=0;i--)n[9*o+i]=t%10,t=Math.floor(t/10)}if(u)e=1,n[s]=0;else for(e=36;!n[s];)e-=1,s+=1;const g=e-1+m;if(g>=34||g<=-7||m>0){if(e>34)return f.push("0"),m>0?f.push(`E+${m}`):m<0&&f.push(`E${m}`),f.join("");f.push(`${n[s++]}`),e-=1,e&&f.push(".");for(let t=0;t<e;t++)f.push(`${n[s++]}`);f.push("E"),g>0?f.push(`+${g}`):f.push(`${g}`)}else if(m>=0)for(let t=0;t<e;t++)f.push(`${n[s++]}`);else{let t=e+m;if(t>0)for(let e=0;e<t;e++)f.push(`${n[s++]}`);else f.push("0");for(f.push(".");t++<0;)f.push("0");for(let r=0;r<e-Math.max(t-1,0);r++)f.push(`${n[s++]}`)}return f.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(t){return ze.fromString(t.$numberDecimal)}inspect(t,e,n){return n??=kt,`new Decimal128(${n(this.toString(),e)})`}}class Qe extends ge{get _bsontype(){return"Double"}value;constructor(t){super(),t instanceof Number&&(t=t.valueOf()),this.value=+t}static fromString(t){const e=Number(t);if("NaN"===t)return new Qe(NaN);if("Infinity"===t)return new Qe(1/0);if("-Infinity"===t)return new Qe(-1/0);if(!Number.isFinite(e))throw new Xt(`Input: ${t} is not representable as a Double`);if(t.trim()!==t)throw new Xt(`Input: '${t}' contains whitespace`);if(""===t)throw new Xt("Input is an empty string");if(/[^-0-9.+eE]/.test(t))throw new Xt(`Input: '${t}' is not in decimal or exponential notation`);return new Qe(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 Qe(n)}inspect(t,e,n){return n??=kt,`new Double(${n(this.value,e)})`}}class Ke extends ge{get _bsontype(){return"Int32"}value;constructor(t){super(),t instanceof Number&&(t=t.valueOf()),this.value=0|+t}static fromString(t){const e=$e(t),n=Number(t);if(Gt<n)throw new Xt(`Input: '${t}' is larger than the maximum value for Int32`);if(Zt>n)throw new Xt(`Input: '${t}' is smaller than the minimum value for Int32`);if(!Number.isSafeInteger(n))throw new Xt(`Input: '${t}' is not a safe integer`);if(n.toString()!==e)throw new Xt(`Input: '${t}' is not a valid Int32 string`);return new Ke(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 Ke(t.$numberInt)}inspect(t,e,n){return n??=kt,`new Int32(${n(this.value,e)})`}}class Xe extends ge{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new Xe}inspect(){return"new MaxKey()"}}class tn extends ge{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new tn}inspect(){return"new MinKey()"}}let en=null;const nn=new WeakMap;class rn extends ge{get _bsontype(){return"ObjectId"}static index=Math.floor(16777215*Math.random());static cacheHexString;buffer;constructor(t){let e;if(super(),"object"==typeof t&&t&&"id"in t){if("string"!=typeof t.id&&!ArrayBuffer.isView(t.id))throw new Xt("Argument passed in must have an id that is of type string or Buffer");e="toHexString"in t&&"function"==typeof t.toHexString?ye.fromHex(t.toHexString()):t.id}else e=t;if(null==e)this.buffer=rn.generate();else if(ArrayBuffer.isView(e)&&12===e.byteLength)this.buffer=ye.toLocalBufferType(e);else{if("string"!=typeof e)throw new Xt("Argument passed in does not match the accepted types");if(!rn.validateHexString(e))throw new Xt("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");this.buffer=ye.fromHex(e),rn.cacheHexString&&nn.set(this,e)}}get id(){return this.buffer}set id(t){this.buffer=t,rn.cacheHexString&&nn.set(this,ye.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(rn.cacheHexString){const t=nn.get(this);if(t)return t}const t=ye.toHex(this.id);return rn.cacheHexString&&nn.set(this,t),t}static getInc(){return rn.index=(rn.index+1)%16777215}static generate(t){"number"!=typeof t&&(t=Math.floor(Date.now()/1e3));const e=rn.getInc(),n=ye.allocateUnsafe(12);return _e.setInt32BE(n,0,t),null===en&&(en=ye.randomBytes(5)),n[4]=en[0],n[5]=en[1],n[6]=en[2],n[7]=en[3],n[8]=en[4],n[11]=255&e,n[10]=e>>8&255,n[9]=e>>16&255,n}toString(t){return"base64"===t?ye.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(rn.is(t))return this.buffer[11]===t.buffer[11]&&ye.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=_e.getUint32BE(this.buffer,0);return t.setTime(1e3*Math.floor(e)),t}static createPk(){return new rn}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=ye.allocate(12);for(let t=11;t>=4;t--)e[t]=0;return _e.setInt32BE(e,0,t),new rn(e)}static createFromHexString(t){if(24!==t?.length)throw new Xt("hex string must be 24 characters");return new rn(ye.fromHex(t))}static createFromBase64(t){if(16!==t?.length)throw new Xt("base64 string must be 16 characters");return new rn(ye.fromBase64(t))}static isValid(t){if(null==t)return!1;if("string"==typeof t)return rn.validateHexString(t);try{return new rn(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new rn(t.$oid)}isCached(){return rn.cacheHexString&&nn.has(this)}inspect(t,e,n){return n??=kt,`new ObjectId(${n(this.toHexString(),e)})`}}class on extends ge{get _bsontype(){return"BSONRegExp"}pattern;options;constructor(t,e){if(super(),this.pattern=t,this.options=(e??"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new Xt(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(-1!==this.options.indexOf("\0"))throw new Xt(`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 Xt(`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 on(t.$regex,on.parseOptions(t.$options));if("BSONRegExp"===t.$regex._bsontype)return t}if("$regularExpression"in t)return new on(t.$regularExpression.pattern,on.parseOptions(t.$regularExpression.options));throw new Xt(`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??=kt,`new BSONRegExp(${r(n(this.pattern),"regexp")}, ${r(n(this.options),"regexp")})`}}class sn extends ge{get _bsontype(){return"BSONSymbol"}value;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 sn(t.$symbol)}inspect(t,e,n){return n??=kt,`new BSONSymbol(${n(this.value,e)})`}}const un=qe;class an extends un{get _bsontype(){return"Timestamp"}get[me](){return"Timestamp"}static MAX_VALUE=qe.MAX_UNSIGNED_VALUE;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(qe.isLong(t))super(t.low,t.high,!0);else{if("object"!=typeof t||!("t"in t)||!("i"in t))throw new Xt("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 Xt("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 Xt("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 Xt("Timestamp constructed from { t, i } must provide a positive t");if(n<0||Number.isNaN(n))throw new Xt("Timestamp constructed from { t, i } must provide a positive i");if(e>4294967295)throw new Xt("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n>4294967295)throw new Xt("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 an(qe.fromInt(t,!0))}static fromNumber(t){return new an(qe.fromNumber(t,!0))}static fromBits(t,e){return new an({i:t,t:e})}static fromString(t,e){return new an(qe.fromString(t,!0,e))}toExtendedJSON(){return{$timestamp:{t:this.t,i:this.i}}}static fromExtendedJSON(t){const e=qe.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,n=qe.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new an({t:n,i:e})}inspect(t,e,n){return n??=kt,`new Timestamp({ t: ${n(this.t,e)}, i: ${n(this.i,e)} })`}}qe.fromNumber(Qt),qe.fromNumber(Kt),new Set(["$db","$ref","$id","$clusterTime"]);const fn={$oid:rn,$binary:Oe,$uuid:Oe,$symbol:sn,$numberInt:Ke,$numberDecimal:ze,$numberDouble:Qe,$numberLong:qe,$minKey:tn,$maxKey:Xe,$regex:on,$regularExpression:on,$timestamp:an};function cn(t,e={}){if("number"==typeof t){const n=t<=Gt&&t>=Zt,r=t<=Wt&&t>=zt;if(e.relaxed||e.legacy)return t;if(Number.isInteger(t)&&!Object.is(t,-0)){if(n)return new Ke(t);if(r)return e.useBigInt64?BigInt(t):qe.fromNumber(t)}return new Qe(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 i=fn[n[r]];if(i)return i.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 ee("Unrecognized type for EJSON date: "+typeof n);r.setTime(Number(n))}else if("string"==typeof n)r.setTime(Date.parse(n));else if(qe.isLong(n))r.setTime(n.toNumber());else if("number"==typeof n&&e.relaxed)r.setTime(n);else{if("bigint"!=typeof n)throw new ee("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=cn(t.$scope)),Te.fromExtendedJSON(t)}if(function(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)}(t)||t.$dbPointer){const e=t.$ref?t:t.$dbPointer;if(e instanceof Ie)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 Ie.fromExtendedJSON(e)}return t}function ln(t){const e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function hn(t,e){if(t instanceof Map||Jt(t)){const n=Object.create(null);for(const[e,r]of t){if("string"!=typeof e)throw new Xt("Can only serialize maps with string keys");n[e]=r}return hn(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(""),i=t[n],o=" -> "+t.slice(n+1,t.length-1).map((t=>`${t} -> `)).join(""),s=t[t.length-1],u=" ".repeat(r.length+i.length/2),a="-".repeat(o.length+(i.length+s.length)/2-1);throw new Xt(`Converting circular structure to EJSON:\n ${r}${i}${o}${s}\n ${u}\\${a}/`)}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 hn(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||((n=t)instanceof Date||"[object Date]"===Object.prototype.toString.call(n))){const n=t.getTime(),r=n>-1&&n<2534023188e5;return e.legacy?e.relaxed&&r?{$date:t.getTime()}:{$date:ln(t)}:e.relaxed&&r?{$date:ln(t)}:{$date:{$numberLong:t.getTime().toString()}}}var n,r;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Number.isInteger(t)&&!Object.is(t,-0)){if(t>=Zt&&t<=Gt)return{$numberInt:t.toString()};if(t>=zt&&t<=Wt)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||((r=t)instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(r))){let n=t.flags;if(void 0===n){const e=t.toString().match(/[gimuy]*$/);e&&(n=e[0])}return new on(t.source,n).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new Xt("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 i=hn(t[r],e);"__proto__"===r?Object.defineProperty(n,r,{value:i,writable:!0,enumerable:!0,configurable:!0}):n[r]=i}finally{e.seenObjects.pop()}}return n}if(null!=t&&"object"==typeof t&&"string"==typeof t._bsontype&&t[Yt]!==Ht)throw new te;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=dn[t._bsontype];if(!e)throw new Xt("Unrecognized or invalid _bsontype: "+t._bsontype);r=e(r)}return"Code"===n&&r.scope?r=new Te(r.code,hn(r.scope,e)):"DBRef"===n&&r.oid&&(r=new Ie(hn(r.collection,e),hn(r.oid,e),hn(r.db,e),hn(r.fields,e))),r.toExtendedJSON(e)}throw new Xt("_bsontype must be a string, but was: "+typeof n)}(t,e):t}const dn={Binary:t=>new Oe(t.value(),t.sub_type),Code:t=>new Te(t.code,t.scope),DBRef:t=>new Ie(t.collection||t.namespace,t.oid,t.db,t.fields),Decimal128:t=>new ze(t.bytes),Double:t=>new Qe(t.value),Int32:t=>new Ke(t.value),Long:t=>qe.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_),MaxKey:()=>new Xe,MinKey:()=>new tn,ObjectId:t=>new rn(t),BSONRegExp:t=>new on(t.pattern,t.options),BSONSymbol:t=>new sn(t.value),Timestamp:t=>an.fromBits(t.low,t.high)};function pn(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 Xt(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(t)}`);return cn(e,n)}))}function yn(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 i=hn(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(i,e,n)}const mn=Object.create(null);mn.parse=pn,mn.stringify=yn,mn.serialize=function(t,e){return e=e||{},JSON.parse(yn(t,e))},mn.deserialize=function(t,e){return e=e||{},pn(JSON.stringify(t),e)},Object.freeze(mn);function gn(t,e){try{return _e.getNonnegativeInt32LE(t,e)}catch(t){throw new ne("BSON size cannot be negative",e,{cause:t})}}function bn(t,e){let n=e;for(;0!==t[n];n++);if(n===t.length-1)throw new ne("Null terminator not found",e);return n}const wn=Object.create(null);wn.parseToElements=function(t,e=0){if(e??=0,t.length<5)throw new ne(`Input must be at least 5 bytes, got ${t.length} bytes`,e);const n=gn(t,e);if(n>t.length-e)throw new ne(`Parsed documentSize (${n} bytes) does not match input length (${t.length} bytes)`,e);if(0!==t[e+n-1])throw new ne("BSON documents must end in 0x00",e+n);const r=[];let i=e+4;for(;i<=n+e;){const o=t[i];if(i+=1,0===o){if(i-e!==n)throw new ne("Invalid 0x00 type byte",i);break}const s=i,u=bn(t,i)-s;let a;if(i+=u+1,1===o||18===o||9===o||17===o)a=8;else if(16===o)a=4;else if(7===o)a=12;else if(19===o)a=16;else if(8===o)a=1;else if(10===o||6===o||127===o||255===o)a=0;else if(11===o)a=bn(t,bn(t,i)+1)+1-i;else if(3===o||4===o||15===o)a=gn(t,i);else{if(2!==o&&5!==o&&12!==o&&13!==o&&14!==o)throw new ne(`Invalid 0x${o.toString(16).padStart(2,"0")} type byte`,i);a=gn(t,i)+4,5===o&&(a+=1),12===o&&(a+=12)}if(a>n)throw new ne("value reports length larger than document",i);r.push([o,s,u,i,a]),i+=a}return r},wn.ByteUtils=ye,wn.NumberUtils=_e,Object.freeze(wn);ye.allocate(17825792);var vn=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=Jn.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,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){s.label=u[1];break}if(6===u[0]&&s.label<i[1]){s.label=i[1],i=u;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(u);break}i[2]&&s.ops.pop(),s.trys.pop();continue}u=e.call(t,s)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}(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(mn.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((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=qt.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",qt.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 _n=vn;var On=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)}}(),En=function(t){function e(e,n){return t.call(this,e,n)||this}return On(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 _n(this._db,this._coll)},e}(Mt),Nn={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=Y(arguments[0])?arguments[0]:Array.from(arguments);return new ft(st.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new ft(st.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new ft(st.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new ft(st.NOT,n)},set:function(t){return new ut(C.SET,[t])},remove:function(){return new ut(C.REMOVE,[])},inc:function(t){return new ut(C.INC,[t])},mul:function(t){return new ut(C.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(k(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=Y(e[0])?e[0]:Array.from(e);return new ut(C.PUSH,t)},pull:function(t){return new ut(C.PULL,t)},pullAll:function(t){return new ut(C.PULL_ALL,t)},pop:function(){return new ut(C.POP,[])},shift:function(){return new ut(C.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Y(arguments[0])?arguments[0]:Array.from(arguments);return new ut(C.UNSHIFT,n)},addToSet:function(t){return new ut(C.ADD_TO_SET,t)},rename:function(t){return new ut(C.RENAME,[t])},bit:function(t){return new ut(C.BIT,[t])},max:function(t){return new ut(C.MAX,[t])},min:function(t){return new ut(C.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===J(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new _n},abs:function(t){return new Sn("abs",t)},add:function(t){return new Sn("add",t)},ceil:function(t){return new Sn("ceil",t)},divide:function(t){return new Sn("divide",t)},exp:function(t){return new Sn("exp",t)},floor:function(t){return new Sn("floor",t)},ln:function(t){return new Sn("ln",t)},log:function(t){return new Sn("log",t)},log10:function(t){return new Sn("log10",t)},mod:function(t){return new Sn("mod",t)},multiply:function(t){return new Sn("multiply",t)},pow:function(t){return new Sn("pow",t)},sqrt:function(t){return new Sn("sqrt",t)},subtract:function(t){return new Sn("subtract",t)},trunc:function(t){return new Sn("trunc",t)},arrayElemAt:function(t){return new Sn("arrayElemAt",t)},arrayToObject:function(t){return new Sn("arrayToObject",t)},concatArrays:function(t){return new Sn("concatArrays",t)},filter:function(t){return new Sn("filter",t)},in:function(t){return new Sn("in",t)},indexOfArray:function(t){return new Sn("indexOfArray",t)},isArray:function(t){return new Sn("isArray",t)},map:function(t){return new Sn("map",t)},range:function(t){return new Sn("range",t)},reduce:function(t){return new Sn("reduce",t)},reverseArray:function(t){return new Sn("reverseArray",t)},size:function(t){return new Sn("size",t)},slice:function(t){return new Sn("slice",t)},zip:function(t){return new Sn("zip",t)},and:function(t){return new Sn("and",t)},not:function(t){return new Sn("not",t)},or:function(t){return new Sn("or",t)},cmp:function(t){return new Sn("cmp",t)},eq:function(t){return new Sn("eq",t)},gt:function(t){return new Sn("gt",t)},gte:function(t){return new Sn("gte",t)},lt:function(t){return new Sn("lt",t)},lte:function(t){return new Sn("lte",t)},neq:function(t){return new Sn("ne",t)},cond:function(t){return new Sn("cond",t)},ifNull:function(t){return new Sn("ifNull",t)},switch:function(t){return new Sn("switch",t)},dateFromParts:function(t){return new Sn("dateFromParts",t)},dateFromString:function(t){return new Sn("dateFromString",t)},dayOfMonth:function(t){return new Sn("dayOfMonth",t)},dayOfWeek:function(t){return new Sn("dayOfWeek",t)},dayOfYear:function(t){return new Sn("dayOfYear",t)},isoDayOfWeek:function(t){return new Sn("isoDayOfWeek",t)},isoWeek:function(t){return new Sn("isoWeek",t)},isoWeekYear:function(t){return new Sn("isoWeekYear",t)},millisecond:function(t){return new Sn("millisecond",t)},minute:function(t){return new Sn("minute",t)},month:function(t){return new Sn("month",t)},second:function(t){return new Sn("second",t)},hour:function(t){return new Sn("hour",t)},week:function(t){return new Sn("week",t)},year:function(t){return new Sn("year",t)},literal:function(t){return new Sn("literal",t)},mergeObjects:function(t){return new Sn("mergeObjects",t)},objectToArray:function(t){return new Sn("objectToArray",t)},allElementsTrue:function(t){return new Sn("allElementsTrue",t)},anyElementTrue:function(t){return new Sn("anyElementTrue",t)},setDifference:function(t){return new Sn("setDifference",t)},setEquals:function(t){return new Sn("setEquals",t)},setIntersection:function(t){return new Sn("setIntersection",t)},setIsSubset:function(t){return new Sn("setIsSubset",t)},setUnion:function(t){return new Sn("setUnion",t)},concat:function(t){return new Sn("concat",t)},dateToString:function(t){return new Sn("dateToString",t)},indexOfBytes:function(t){return new Sn("indexOfBytes",t)},indexOfCP:function(t){return new Sn("indexOfCP",t)},split:function(t){return new Sn("split",t)},strLenBytes:function(t){return new Sn("strLenBytes",t)},strLenCP:function(t){return new Sn("strLenCP",t)},strcasecmp:function(t){return new Sn("strcasecmp",t)},substr:function(t){return new Sn("substr",t)},substrBytes:function(t){return new Sn("substrBytes",t)},substrCP:function(t){return new Sn("substrCP",t)},toLower:function(t){return new Sn("toLower",t)},toUpper:function(t){return new Sn("toUpper",t)},meta:function(t){return new Sn("meta",t)},addToSet:function(t){return new Sn("addToSet",t)},avg:function(t){return new Sn("avg",t)},first:function(t){return new Sn("first",t)},last:function(t){return new Sn("last",t)},max:function(t){return new Sn("max",t)},min:function(t){return new Sn("min",t)},push:function(t){return new Sn("push",t)},stdDevPop:function(t){return new Sn("stdDevPop",t)},stdDevSamp:function(t){return new Sn("stdDevSamp",t)},sum:function(t){return new Sn("sum",t)},let:function(t){return new Sn("let",t)}},project:{slice:function(t){return new xn("slice",t)},elemMatch:function(t){return new xn("elemMatch",t)}}},Sn=function(t,e){this["$"+t]=e},xn=function(t,e){this["$"+t]=e},Tn=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 In(t){return new Tn(t)}var $n="insert document failed",Bn="DATABASE_TRANSACTION_CONFLICT",An=function(){return An=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},An.apply(this,arguments)},Ln=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))},Un=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){s.label=u[1];break}if(6===u[0]&&s.label<i[1]){s.label=i[1],i=u;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(u);break}i[2]&&s.ops.pop(),s.trys.pop();continue}u=e.call(t,s)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}},Pn="database.updateDocInTransaction",jn=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 Ln(this,void 0,void 0,(function(){var e,n,r,i;return Un(this,(function(o){switch(o.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:mn.stringify(Ot(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=o.sent()).code)throw n;if(r=mn.parse(n.inserted),1==(i=mn.parse(n.ok))&&1==r)return[2,An(An({},n),{ok:i,inserted:r})];throw new Error($n)}}))}))},t.prototype.get=function(){return Ln(this,void 0,void 0,(function(){var t,e;return Un(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?F.formatField(mn.parse(e.data)):mn.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return Ln(this,void 0,void 0,(function(){var e,n;return Un(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:mn.stringify(Ot(t),{relaxed:!1}),upsert:!0},[4,this._request.send(Pn,e)];case 1:if((n=r.sent()).code)throw n;return[2,An(An({},n),{updated:mn.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return Ln(this,void 0,void 0,(function(){var e,n;return Un(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:mn.stringify(Lt.encode(t),{relaxed:!1})},[4,this._request.send(Pn,e)];case 1:if((n=r.sent()).code)throw n;return[2,An(An({},n),{updated:mn.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return Ln(this,void 0,void 0,(function(){var t,e;return Un(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,An(An({},e),{deleted:mn.parse(e.deleted)})]}}))}))},t}(),Rn=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)}}(),qn=function(t){function e(e,n){return t.call(this,e,n)||this}return Rn(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 jn(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new jn(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),Dn=function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))},Cn=function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){s.label=u[1];break}if(6===u[0]&&s.label<i[1]){s.label=i[1],i=u;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(u);break}i[2]&&s.ops.pop(),s.trys.pop();continue}u=e.call(t,s)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}},Mn=function(){function t(t){this._db=t,this._request=Jn.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return Dn(this,void 0,void 0,(function(){var t;return Cn(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 qn(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return Dn(this,void 0,void 0,(function(){var t,e;return Cn(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 Dn(this,void 0,void 0,(function(){var e,n;return Cn(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 Fn(){return Dn(this,void 0,void 0,(function(){var t;return Cn(this,(function(e){switch(e.label){case 0:return[4,(t=new Mn(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function Vn(t,e){return void 0===e&&(e=3),Dn(this,void 0,void 0,(function(){var n,r,i,o,s=this;return Cn(this,(function(u){switch(u.label){case 0:return u.trys.push([0,4,,10]),[4,(n=new Mn(this)).init()];case 1:return u.sent(),[4,t(n)];case 2:if(r=u.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return u.sent(),[2,r];case 4:if(i=u.sent(),!1===n.inited)throw i;return o=function(t){return Dn(s,void 0,void 0,(function(){return Cn(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,o(i)]:[3,6];case 5:u.sent(),u.label=6;case 6:return i&&i.code===Bn?[4,Vn.bind(this)(t,--e)]:[3,8];case 7:return[2,u.sent()];case 8:return[4,o(i)];case 9:return u.sent(),[3,10];case 10:return[2]}}))}))}var Jn=function(){function t(t){this.config=t,this.Geo=o,this.serverDate=D,this.command=Nn,this.RegExp=In,this.startTransaction=Fn,this.runTransaction=Vn,this.logicCommand=ft,this.updateCommand=ut,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 En(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return t.createRequest(this.config).send("database.addCollection",n)},t}()}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.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(258)})()));
|