@loaders.gl/bson 4.4.0-alpha.16 → 4.4.0-alpha.17

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.
@@ -5,7 +5,7 @@ import { parseBSONSync } from "./lib/parsers/parse-bson.js";
5
5
  import { BSONFormat } from "./bson-format.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.4.0-alpha.16" !== 'undefined' ? "4.4.0-alpha.16" : 'latest';
8
+ const VERSION = typeof "4.4.0-alpha.17" !== 'undefined' ? "4.4.0-alpha.17" : 'latest';
9
9
  export const BSONLoader = {
10
10
  ...BSONFormat,
11
11
  dataType: null,
@@ -5,7 +5,7 @@ import { encodeBSONSync } from "./lib/encoders/encode-bson.js";
5
5
  import { BSONFormat } from "./bson-format.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.4.0-alpha.16" !== 'undefined' ? "4.4.0-alpha.16" : 'latest';
8
+ const VERSION = typeof "4.4.0-alpha.17" !== 'undefined' ? "4.4.0-alpha.17" : 'latest';
9
9
  export const BSONWriter = {
10
10
  ...BSONFormat,
11
11
  name: 'BSON',
package/dist/dist.min.js CHANGED
@@ -13,6 +13,6 @@
13
13
  `))):m=B.stylize("[Circular]","special")),gt(u)){if(f&&l.match(/^\d+$/))return m;u=JSON.stringify(""+l),u.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=B.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=B.stylize(u,"string"))}return u+": "+m}function hr(B,t,h){var d=B.reduce(function(l,f){return f.indexOf(`
14
14
  `)>=0,l+f.replace(/\u001b\[\d\d?m/g,"").length+1},0);return d>60?h[0]+(t===""?"":t+`
15
15
  `)+" "+B.join(`,
16
- `)+" "+h[1]:h[0]+t+" "+B.join(", ")+" "+h[1]}function de(B){return Array.isArray(B)}function _e(B){return typeof B=="boolean"}function qt(B){return B===null}function _r(B){return B==null}function Ie(B){return typeof B=="number"}function Qt(B){return typeof B=="string"}function yr(B){return babelHelpers.typeof(B)==="symbol"}function gt(B){return B===void 0}function kt(B){return Pt(B)&&ye(B)==="[object RegExp]"}function Pt(B){return babelHelpers.typeof(B)==="object"&&B!==null}function le(B){return Pt(B)&&ye(B)==="[object Date]"}function Xt(B){return Pt(B)&&(ye(B)==="[object Error]"||B instanceof Error)}function Kt(B){return typeof B=="function"}function Br(B){return B===null||typeof B=="boolean"||typeof B=="number"||typeof B=="string"||babelHelpers.typeof(B)==="symbol"||typeof B>"u"}function pr(B){return Buffer.isBuffer(B)}function ye(B){return Object.prototype.toString.call(B)}function fe(B){return B<10?"0"+B.toString(10):B.toString(10)}var Nr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function gr(){var B=new Date,t=[fe(B.getHours()),fe(B.getMinutes()),fe(B.getSeconds())].join(":");return[B.getDate(),Nr[B.getMonth()],t].join(" ")}function Ar(){console.log("%s - %s",gr(),he.apply(null,arguments))}function De(B,t){if(!t||!Pt(t))return B;for(var h=Object.keys(t),d=h.length;d--;)B[h[d]]=t[h[d]];return B}function Re(B,t){return Object.prototype.hasOwnProperty.call(B,t)}var Sr={inherits:ir,_extend:De,log:Ar,isBuffer:pr,isPrimitive:Br,isFunction:Kt,isError:Xt,isDate:le,isObject:Pt,isRegExp:kt,isUndefined:gt,isSymbol:yr,isString:Qt,isNumber:Ie,isNullOrUndefined:_r,isNull:qt,isBoolean:_e,isArray:de,inspect:At,deprecate:be,format:he,debuglog:sr},rt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deprecate=t.isObjectLike=t.isDate=t.isBuffer=t.haveBuffer=t.isBigUInt64Array=t.isBigInt64Array=t.isUint8Array=t.randomBytes=t.normalizedFunctionString=void 0;function h(n){return n.toString().replace("function(","function (")}t.normalizedFunctionString=h;function d(n){let w=C.Buffer.alloc(n);for(let U=0;U<n;++U)w[U]=Math.floor(Math.random()*256);return w}if(t.randomBytes=d,typeof window<"u"&&window.crypto&&window.crypto.getRandomValues)t.randomBytes=n=>window.crypto.getRandomValues(C.Buffer.alloc(n));else{try{t.randomBytes=nr.randomBytes}catch{}t.randomBytes==null&&(t.randomBytes=d)}function l(n){return Object.prototype.toString.call(n)==="[object Uint8Array]"}t.isUint8Array=l;function f(n){return Object.prototype.toString.call(n)==="[object BigInt64Array]"}t.isBigInt64Array=f;function u(n){return Object.prototype.toString.call(n)==="[object BigUint64Array]"}t.isBigUInt64Array=u;function m(){return typeof Vt<"u"&&typeof Vt.Buffer<"u"}t.haveBuffer=m;function o(n){return m()&&C.Buffer.isBuffer(n)}t.isBuffer=o;function c(n){return _(n)&&Object.prototype.toString.call(n)==="[object Date]"}t.isDate=c;function _(n){return typeof n=="object"&&n!==null}t.isObjectLike=_;function g(n,w){if(typeof window>"u"||typeof self>"u")return Sr.deprecate(n,w);let U=!1;function p(...F){return U||(console.warn(w),U=!0),n.apply(this,...F)}return p}t.deprecate=g});st(rt);var Fr=rt.deprecate,Yr=rt.isObjectLike,Lr=rt.isDate,vr=rt.isBuffer,Cr=rt.haveBuffer,zr=rt.isBigUInt64Array,Jr=rt.isBigInt64Array,Wr=rt.isUint8Array,kr=rt.randomBytes,Xr=rt.normalizedFunctionString,pt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DBRef=t.isDBRefLike=void 0;function h(l){return rt.isObjectLike(l)&&l.$id!=null&&l.$ref!=null}t.isDBRefLike=h;class d{constructor(f,u,m,o){let c=f.split(".");c.length===2&&(m=c.shift(),f=c.shift()),this.collection=f,this.oid=u,this.db=m,this.fields=o||{}}get namespace(){return this.collection}set namespace(f){this.collection=f}toJSON(){let f=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(f.$db=this.db),f}toExtendedJSON(f){f=f||{};let u={$ref:this.collection,$id:this.oid};return f.legacy||(this.db&&(u.$db=this.db),u=Object.assign(u,this.fields)),u}static fromExtendedJSON(f){let u=Object.assign({},f);return delete u.$ref,delete u.$id,delete u.$db,new d(f.$ref,f.$id,f.$db,u)}}t.DBRef=d,Object.defineProperty(d.prototype,"_bsontype",{value:"DBRef"})});st(pt);var Kr=pt.DBRef,Vr=pt.isDBRefLike,K=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Long=void 0;let h;try{h=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{}let d=1<<16,l=1<<24,f=d*d,u=f*f,m=u/2,o={},c={};class _{constructor(n=0,w=0,U){this.comp=_.prototype.compare,this.div=_.prototype.divide,this.eq=_.prototype.equals,this.gt=_.prototype.greaterThan,this.gte=_.prototype.greaterThanOrEqual,this.ge=_.prototype.greaterThanOrEqual,this.lt=_.prototype.lessThan,this.lte=_.prototype.lessThanOrEqual,this.mod=_.prototype.modulo,this.rem=_.prototype.modulo,this.mul=_.prototype.multiply,this.neg=_.prototype.negate,this.neq=_.prototype.notEquals,this.ne=_.prototype.notEquals,this.shl=_.prototype.shiftLeft,this.shr=_.prototype.shiftRight,this.shr_u=_.prototype.shiftRightUnsigned,this.shru=_.prototype.shiftRightUnsigned,this.sub=_.prototype.subtract,this.eqz=_.prototype.isZero,this.le=_.prototype.lessThanOrEqual,this.low=n|0,this.high=w|0,this.unsigned=!!U,Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}static fromBits(n,w,U){return new _(n,w,U)}static fromInt(n,w){let U,p,F;return w?(n>>>=0,(F=0<=n&&n<256)&&(p=c[n],p)?p:(U=_.fromBits(n,(n|0)<0?-1:0,!0),F&&(c[n]=U),U)):(n|=0,(F=-128<=n&&n<128)&&(p=o[n],p)?p:(U=_.fromBits(n,n<0?-1:0,!1),F&&(o[n]=U),U))}static fromNumber(n,w){if(isNaN(n))return w?_.UZERO:_.ZERO;if(w){if(n<0)return _.UZERO;if(n>=u)return _.MAX_UNSIGNED_VALUE}else{if(n<=-m)return _.MIN_VALUE;if(n+1>=m)return _.MAX_VALUE}return n<0?_.fromNumber(-n,w).neg():_.fromBits(n%f|0,n/f|0,w)}static fromBigInt(n,w){return _.fromString(n.toString(),w)}static fromString(n,w,U){if(n.length===0)throw Error("empty string");if(n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return _.ZERO;if(typeof w=="number"?(U=w,w=!1):w=!!w,U=U||10,U<2||36<U)throw RangeError("radix");let p;if((p=n.indexOf("-"))>0)throw Error("interior hyphen");if(p===0)return _.fromString(n.substring(1),w,U).neg();let F=_.fromNumber(Math.pow(U,8)),J=_.ZERO;for(let R=0;R<n.length;R+=8){let W=Math.min(8,n.length-R),Q=parseInt(n.substring(R,R+W),U);if(W<8){let H=_.fromNumber(Math.pow(U,W));J=J.mul(H).add(_.fromNumber(Q))}else J=J.mul(F),J=J.add(_.fromNumber(Q))}return J.unsigned=w,J}static fromBytes(n,w,U){return U?_.fromBytesLE(n,w):_.fromBytesBE(n,w)}static fromBytesLE(n,w){return new _(n[0]|n[1]<<8|n[2]<<16|n[3]<<24,n[4]|n[5]<<8|n[6]<<16|n[7]<<24,w)}static fromBytesBE(n,w){return new _(n[4]<<24|n[5]<<16|n[6]<<8|n[7],n[0]<<24|n[1]<<16|n[2]<<8|n[3],w)}static isLong(n){return rt.isObjectLike(n)&&n.__isLong__===!0}static fromValue(n,w){return typeof n=="number"?_.fromNumber(n,w):typeof n=="string"?_.fromString(n,w):_.fromBits(n.low,n.high,typeof w=="boolean"?w:n.unsigned)}add(n){_.isLong(n)||(n=_.fromValue(n));let w=this.high>>>16,U=this.high&65535,p=this.low>>>16,F=this.low&65535,J=n.high>>>16,R=n.high&65535,W=n.low>>>16,Q=n.low&65535,H=0,M=0,G=0,z=0;return z+=F+Q,G+=z>>>16,z&=65535,G+=p+W,M+=G>>>16,G&=65535,M+=U+R,H+=M>>>16,M&=65535,H+=w+J,H&=65535,_.fromBits(G<<16|z,H<<16|M,this.unsigned)}and(n){return _.isLong(n)||(n=_.fromValue(n)),_.fromBits(this.low&n.low,this.high&n.high,this.unsigned)}compare(n){if(_.isLong(n)||(n=_.fromValue(n)),this.eq(n))return 0;let w=this.isNegative(),U=n.isNegative();return w&&!U?-1:!w&&U?1:this.unsigned?n.high>>>0>this.high>>>0||n.high===this.high&&n.low>>>0>this.low>>>0?-1:1:this.sub(n).isNegative()?-1:1}divide(n){if(_.isLong(n)||(n=_.fromValue(n)),n.isZero())throw Error("division by zero");if(h){if(!this.unsigned&&this.high===-2147483648&&n.low===-1&&n.high===-1)return this;let F=(this.unsigned?h.div_u:h.div_s)(this.low,this.high,n.low,n.high);return _.fromBits(F,h.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?_.UZERO:_.ZERO;let w,U,p;if(this.unsigned){if(n.unsigned||(n=n.toUnsigned()),n.gt(this))return _.UZERO;if(n.gt(this.shru(1)))return _.UONE;p=_.UZERO}else{if(this.eq(_.MIN_VALUE))return n.eq(_.ONE)||n.eq(_.NEG_ONE)?_.MIN_VALUE:n.eq(_.MIN_VALUE)?_.ONE:(w=this.shr(1).div(n).shl(1),w.eq(_.ZERO)?n.isNegative()?_.ONE:_.NEG_ONE:(U=this.sub(n.mul(w)),p=w.add(U.div(n)),p));if(n.eq(_.MIN_VALUE))return this.unsigned?_.UZERO:_.ZERO;if(this.isNegative())return n.isNegative()?this.neg().div(n.neg()):this.neg().div(n).neg();if(n.isNegative())return this.div(n.neg()).neg();p=_.ZERO}for(U=this;U.gte(n);){w=Math.max(1,Math.floor(U.toNumber()/n.toNumber()));let F=Math.ceil(Math.log(w)/Math.LN2),J=F<=48?1:Math.pow(2,F-48),R=_.fromNumber(w),W=R.mul(n);for(;W.isNegative()||W.gt(U);)w-=J,R=_.fromNumber(w,this.unsigned),W=R.mul(n);R.isZero()&&(R=_.ONE),p=p.add(R),U=U.sub(W)}return p}equals(n){return _.isLong(n)||(n=_.fromValue(n)),this.unsigned!==n.unsigned&&this.high>>>31===1&&n.high>>>31===1?!1:this.high===n.high&&this.low===n.low}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(_.MIN_VALUE)?64:this.neg().getNumBitsAbs();let n=this.high!==0?this.high:this.low,w;for(w=31;w>0&&!(n&1<<w);w--);return this.high!==0?w+33:w+1}greaterThan(n){return this.comp(n)>0}greaterThanOrEqual(n){return this.comp(n)>=0}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(n){return this.comp(n)<0}lessThanOrEqual(n){return this.comp(n)<=0}modulo(n){if(_.isLong(n)||(n=_.fromValue(n)),h){let w=(this.unsigned?h.rem_u:h.rem_s)(this.low,this.high,n.low,n.high);return _.fromBits(w,h.get_high(),this.unsigned)}return this.sub(this.div(n).mul(n))}multiply(n){if(this.isZero())return _.ZERO;if(_.isLong(n)||(n=_.fromValue(n)),h){let x=h.mul(this.low,this.high,n.low,n.high);return _.fromBits(x,h.get_high(),this.unsigned)}if(n.isZero())return _.ZERO;if(this.eq(_.MIN_VALUE))return n.isOdd()?_.MIN_VALUE:_.ZERO;if(n.eq(_.MIN_VALUE))return this.isOdd()?_.MIN_VALUE:_.ZERO;if(this.isNegative())return n.isNegative()?this.neg().mul(n.neg()):this.neg().mul(n).neg();if(n.isNegative())return this.mul(n.neg()).neg();if(this.lt(_.TWO_PWR_24)&&n.lt(_.TWO_PWR_24))return _.fromNumber(this.toNumber()*n.toNumber(),this.unsigned);let w=this.high>>>16,U=this.high&65535,p=this.low>>>16,F=this.low&65535,J=n.high>>>16,R=n.high&65535,W=n.low>>>16,Q=n.low&65535,H=0,M=0,G=0,z=0;return z+=F*Q,G+=z>>>16,z&=65535,G+=p*Q,M+=G>>>16,G&=65535,G+=F*W,M+=G>>>16,G&=65535,M+=U*Q,H+=M>>>16,M&=65535,M+=p*W,H+=M>>>16,M&=65535,M+=F*R,H+=M>>>16,M&=65535,H+=w*Q+U*W+p*R+F*J,H&=65535,_.fromBits(G<<16|z,H<<16|M,this.unsigned)}negate(){return!this.unsigned&&this.eq(_.MIN_VALUE)?_.MIN_VALUE:this.not().add(_.ONE)}not(){return _.fromBits(~this.low,~this.high,this.unsigned)}notEquals(n){return!this.equals(n)}or(n){return _.isLong(n)||(n=_.fromValue(n)),_.fromBits(this.low|n.low,this.high|n.high,this.unsigned)}shiftLeft(n){return _.isLong(n)&&(n=n.toInt()),(n&=63)===0?this:n<32?_.fromBits(this.low<<n,this.high<<n|this.low>>>32-n,this.unsigned):_.fromBits(0,this.low<<n-32,this.unsigned)}shiftRight(n){return _.isLong(n)&&(n=n.toInt()),(n&=63)===0?this:n<32?_.fromBits(this.low>>>n|this.high<<32-n,this.high>>n,this.unsigned):_.fromBits(this.high>>n-32,this.high>=0?0:-1,this.unsigned)}shiftRightUnsigned(n){if(_.isLong(n)&&(n=n.toInt()),n&=63,n===0)return this;{let w=this.high;if(n<32){let U=this.low;return _.fromBits(U>>>n|w<<32-n,w>>>n,this.unsigned)}else return n===32?_.fromBits(w,0,this.unsigned):_.fromBits(w>>>n-32,0,this.unsigned)}}subtract(n){return _.isLong(n)||(n=_.fromValue(n)),this.add(n.neg())}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(n){return n?this.toBytesLE():this.toBytesBE()}toBytesLE(){let n=this.high,w=this.low;return[w&255,w>>>8&255,w>>>16&255,w>>>24,n&255,n>>>8&255,n>>>16&255,n>>>24]}toBytesBE(){let n=this.high,w=this.low;return[n>>>24,n>>>16&255,n>>>8&255,n&255,w>>>24,w>>>16&255,w>>>8&255,w&255]}toSigned(){return this.unsigned?_.fromBits(this.low,this.high,!1):this}toString(n){if(n=n||10,n<2||36<n)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(_.MIN_VALUE)){let F=_.fromNumber(n),J=this.div(F),R=J.mul(F).sub(this);return J.toString(n)+R.toInt().toString(n)}else return"-"+this.neg().toString(n);let w=_.fromNumber(Math.pow(n,6),this.unsigned),U=this,p="";for(;;){let F=U.div(w),R=(U.sub(F.mul(w)).toInt()>>>0).toString(n);if(U=F,U.isZero())return R+p;for(;R.length<6;)R="0"+R;p=""+R+p}}toUnsigned(){return this.unsigned?this:_.fromBits(this.low,this.high,!0)}xor(n){return _.isLong(n)||(n=_.fromValue(n)),_.fromBits(this.low^n.low,this.high^n.high,this.unsigned)}toExtendedJSON(n){return n&&n.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(n,w){let U=_.fromString(n.$numberLong);return w&&w.relaxed?U.toNumber():U}}t.Long=_,_.TWO_PWR_24=_.fromInt(l),_.MAX_UNSIGNED_VALUE=_.fromBits(-1,-1,!0),_.ZERO=_.fromInt(0),_.UZERO=_.fromInt(0,!0),_.ONE=_.fromInt(1),_.UONE=_.fromInt(1,!0),_.NEG_ONE=_.fromInt(-1),_.MAX_VALUE=_.fromBits(-1,2147483647,!1),_.MIN_VALUE=_.fromBits(0,-2147483648,!1),Object.defineProperty(_.prototype,"__isLong__",{value:!0}),Object.defineProperty(_.prototype,"_bsontype",{value:"Long"})});st(K);var Hr=K.Long,Dt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Decimal128=void 0;let h=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,d=/^(\+|-)?(Infinity|inf)$/i,l=/^(\+|-)?NaN$/i,f=6111,u=-6176,m=6176,o=34,c=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),_=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),g=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),n=/^([-+])?(\d+)?$/,w=31,U=16383,p=30,F=31;function J(G){return!isNaN(parseInt(G,10))}function R(G){let z=K.Long.fromNumber(1e9),x=K.Long.fromNumber(0);if(!G.parts[0]&&!G.parts[1]&&!G.parts[2]&&!G.parts[3])return{quotient:G,rem:x};for(let s=0;s<=3;s++)x=x.shiftLeft(32),x=x.add(new K.Long(G.parts[s],0)),G.parts[s]=x.div(z).low,x=x.modulo(z);return{quotient:G,rem:x}}function W(G,z){if(!G&&!z)return{high:K.Long.fromNumber(0),low:K.Long.fromNumber(0)};let x=G.shiftRightUnsigned(32),s=new K.Long(G.getLowBits(),0),O=z.shiftRightUnsigned(32),A=new K.Long(z.getLowBits(),0),i=x.multiply(O),E=x.multiply(A),I=s.multiply(O),j=s.multiply(A);return i=i.add(E.shiftRightUnsigned(32)),E=new K.Long(E.getLowBits(),0).add(I).add(j.shiftRightUnsigned(32)),i=i.add(E.shiftRightUnsigned(32)),j=E.shiftLeft(32).add(new K.Long(j.getLowBits(),0)),{high:i,low:j}}function Q(G,z){let x=G.high>>>0,s=z.high>>>0;if(x<s)return!0;if(x===s){let O=G.low>>>0,A=z.low>>>0;if(O<A)return!0}return!1}function H(G,z){throw new TypeError(`"${G}" is not a valid Decimal128 string - ${z}`)}class M{constructor(z){this.bytes=z}static fromString(z){let x=!1,s=!1,O=!1,A=0,i=0,E=0,I=0,j=0,L=[0],N=0,$=0,v=0,T=0,D=0,Z=0,k=new K.Long(0,0),et=new K.Long(0,0),Bt=0,X=0;if(z.length>=7e3)throw new TypeError(""+z+" not a valid Decimal128 string");let lt=z.match(h),re=z.match(d),Lt=z.match(l);if(!lt&&!re&&!Lt||z.length===0)throw new TypeError(""+z+" not a valid Decimal128 string");if(lt){let nt=lt[2],a=lt[4],e=lt[5],r=lt[6];a&&r===void 0&&H(z,"missing exponent power"),a&&nt===void 0&&H(z,"missing exponent base"),a===void 0&&(e||r)&&H(z,"missing e before exponent")}if((z[X]==="+"||z[X]==="-")&&(x=z[X++]==="-"),!J(z[X])&&z[X]!=="."){if(z[X]==="i"||z[X]==="I")return new M(C.Buffer.from(x?_:g));if(z[X]==="N")return new M(C.Buffer.from(c))}for(;J(z[X])||z[X]===".";){if(z[X]==="."){s&&H(z,"contains multiple periods"),s=!0,X=X+1;continue}N<34&&(z[X]!=="0"||O)&&(O||(j=i),O=!0,L[$++]=parseInt(z[X],10),N=N+1),O&&(E=E+1),s&&(I=I+1),i=i+1,X=X+1}if(s&&!i)throw new TypeError(""+z+" not a valid Decimal128 string");if(z[X]==="e"||z[X]==="E"){let nt=z.substr(++X).match(n);if(!nt||!nt[2])return new M(C.Buffer.from(c));D=parseInt(nt[0],10),X=X+nt[0].length}if(z[X])return new M(C.Buffer.from(c));if(v=0,!N)v=0,T=0,L[0]=0,E=1,N=1,A=0;else if(T=N-1,A=E,A!==1)for(;z[j+A-1]==="0";)A=A-1;for(D<=I&&I-D>1<<14?D=u:D=D-I;D>f;){if(T=T+1,T-v>o){if(L.join("").match(/^0+$/)){D=f;break}H(z,"overflow")}D=D-1}for(;D<u||N<E;){if(T===0&&A<N){D=u,A=0;break}if(N<E?E=E-1:T=T-1,D<f)D=D+1;else{if(L.join("").match(/^0+$/)){D=f;break}H(z,"overflow")}}if(T-v+1<A){let nt=i;s&&(j=j+1,nt=nt+1),x&&(j=j+1,nt=nt+1);let a=parseInt(z[j+T+1],10),e=0;if(a>=5&&(e=1,a===5)){for(e=L[T]%2===1?1:0,Z=j+T+2;Z<nt;Z++)if(parseInt(z[Z],10)){e=1;break}}if(e){let r=T;for(;r>=0;r--)if(++L[r]>9&&(L[r]=0,r===0))if(D<f)D=D+1,L[r]=1;else return new M(C.Buffer.from(x?_:g))}}if(k=K.Long.fromNumber(0),et=K.Long.fromNumber(0),A===0)k=K.Long.fromNumber(0),et=K.Long.fromNumber(0);else if(T-v<17){let nt=v;for(et=K.Long.fromNumber(L[nt++]),k=new K.Long(0,0);nt<=T;nt++)et=et.multiply(K.Long.fromNumber(10)),et=et.add(K.Long.fromNumber(L[nt]))}else{let nt=v;for(k=K.Long.fromNumber(L[nt++]);nt<=T-17;nt++)k=k.multiply(K.Long.fromNumber(10)),k=k.add(K.Long.fromNumber(L[nt]));for(et=K.Long.fromNumber(L[nt++]);nt<=T;nt++)et=et.multiply(K.Long.fromNumber(10)),et=et.add(K.Long.fromNumber(L[nt]))}let ht=W(k,K.Long.fromString("100000000000000000"));ht.low=ht.low.add(et),Q(ht.low,et)&&(ht.high=ht.high.add(K.Long.fromNumber(1))),Bt=D+m;let q={low:K.Long.fromNumber(0),high:K.Long.fromNumber(0)};ht.high.shiftRightUnsigned(49).and(K.Long.fromNumber(1)).equals(K.Long.fromNumber(1))?(q.high=q.high.or(K.Long.fromNumber(3).shiftLeft(61)),q.high=q.high.or(K.Long.fromNumber(Bt).and(K.Long.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(ht.high.and(K.Long.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(K.Long.fromNumber(Bt&16383).shiftLeft(49)),q.high=q.high.or(ht.high.and(K.Long.fromNumber(562949953421311)))),q.low=ht.low,x&&(q.high=q.high.or(K.Long.fromString("9223372036854775808")));let ut=C.Buffer.alloc(16);return X=0,ut[X++]=q.low.low&255,ut[X++]=q.low.low>>8&255,ut[X++]=q.low.low>>16&255,ut[X++]=q.low.low>>24&255,ut[X++]=q.low.high&255,ut[X++]=q.low.high>>8&255,ut[X++]=q.low.high>>16&255,ut[X++]=q.low.high>>24&255,ut[X++]=q.high.low&255,ut[X++]=q.high.low>>8&255,ut[X++]=q.high.low>>16&255,ut[X++]=q.high.low>>24&255,ut[X++]=q.high.high&255,ut[X++]=q.high.high>>8&255,ut[X++]=q.high.high>>16&255,ut[X++]=q.high.high>>24&255,new M(ut)}toString(){let z,x=0,s=new Array(36);for(let X=0;X<s.length;X++)s[X]=0;let O=0,A=!1,i,E={parts:[0,0,0,0]},I,j,L=[];O=0;let N=this.bytes,$=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24,v=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24,T=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24,D=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24;O=0,{low:new K.Long($,v),high:new K.Long(T,D)}.high.lessThan(K.Long.ZERO)&&L.push("-");let k=D>>26&w;if(k>>3===3){if(k===p)return L.join("")+"Infinity";if(k===F)return"NaN";z=D>>15&U,i=8+(D>>14&1)}else i=D>>14&7,z=D>>17&U;let et=z-m;if(E.parts[0]=(D&16383)+((i&15)<<14),E.parts[1]=T,E.parts[2]=v,E.parts[3]=$,E.parts[0]===0&&E.parts[1]===0&&E.parts[2]===0&&E.parts[3]===0)A=!0;else for(j=3;j>=0;j--){let X=0,lt=R(E);if(E=lt.quotient,X=lt.rem.low,!!X)for(I=8;I>=0;I--)s[j*9+I]=X%10,X=Math.floor(X/10)}if(A)x=1,s[O]=0;else for(x=36;!s[O];)x=x-1,O=O+1;let Bt=x-1+et;if(Bt>=34||Bt<=-7||et>0){if(x>34)return L.push(`${0}`),et>0?L.push("E+"+et):et<0&&L.push("E"+et),L.join("");L.push(`${s[O++]}`),x=x-1,x&&L.push(".");for(let X=0;X<x;X++)L.push(`${s[O++]}`);L.push("E"),Bt>0?L.push("+"+Bt):L.push(`${Bt}`)}else if(et>=0)for(let X=0;X<x;X++)L.push(`${s[O++]}`);else{let X=x+et;if(X>0)for(let lt=0;lt<X;lt++)L.push(`${s[O++]}`);else L.push("0");for(L.push(".");X++<0;)L.push("0");for(let lt=0;lt<x-Math.max(X-1,0);lt++)L.push(`${s[O++]}`)}return L.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(z){return M.fromString(z.$numberDecimal)}}t.Decimal128=M,Object.defineProperty(M.prototype,"_bsontype",{value:"Decimal128"})});st(Dt);var Gr=Dt.Decimal128,bt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Double=void 0;class h{constructor(l){l instanceof Number&&(l=l.valueOf()),this.value=+l}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(l){if(l&&(l.legacy||l.relaxed&&isFinite(this.value)))return this.value;if(Object.is(Math.sign(this.value),-0))return{$numberDouble:`-${this.value.toFixed(1)}`};let f;return Number.isInteger(this.value)?(f=this.value.toFixed(1),f.length>=13&&(f=this.value.toExponential(13).toUpperCase())):f=this.value.toString(),{$numberDouble:f}}static fromExtendedJSON(l,f){let u=parseFloat(l.$numberDouble);return f&&f.relaxed?u:new h(u)}}t.Double=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Double"})});st(bt);var xr=bt.Double,dt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Int32=void 0;class h{constructor(l){l instanceof Number&&(l=l.valueOf()),this.value=+l}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(l){return l&&(l.relaxed||l.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(l,f){return f&&f.relaxed?parseInt(l.$numberInt,10):new h(l.$numberInt)}}t.Int32=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Int32"})});st(dt);var Zr=dt.Int32,$t=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Map=void 0;let h;t.Map=h;let d=function(u){return u&&u.Math==Math&&u};function l(){return d(typeof globalThis=="object"&&globalThis)||d(typeof window=="object"&&window)||d(typeof self=="object"&&self)||d(typeof Vt=="object"&&Vt)||Function("return this")()}let f=l();Object.prototype.hasOwnProperty.call(f,"Map")?t.Map=h=f.Map:t.Map=h=class{constructor(m=[]){this._keys=[],this._values={};for(let o=0;o<m.length;o++){if(m[o]==null)continue;let c=m[o],_=c[0],g=c[1];this._keys.push(_),this._values[_]={v:g,i:this._keys.length-1}}}clear(){this._keys=[],this._values={}}delete(m){let o=this._values[m];return o==null?!1:(delete this._values[m],this._keys.splice(o.i,1),!0)}entries(){let m=0;return{next:()=>{let o=this._keys[m++];return{value:o!==void 0?[o,this._values[o].v]:void 0,done:o===void 0}}}}forEach(m,o){o=o||this;for(let c=0;c<this._keys.length;c++){let _=this._keys[c];m.call(o,this._values[_].v,_,o)}}get(m){return this._values[m]?this._values[m].v:void 0}has(m){return this._values[m]!=null}keys(){let m=0;return{next:()=>{let o=this._keys[m++];return{value:o!==void 0?o:void 0,done:o===void 0}}}}set(m,o){return this._values[m]?(this._values[m].v=o,this):(this._keys.push(m),this._values[m]={v:o,i:this._keys.length-1},this)}values(){let m=0;return{next:()=>{let o=this._keys[m++];return{value:o!==void 0?this._values[o].v:void 0,done:o===void 0}}}}get size(){return this._keys.length}}});st($t);var Qr=$t.Map,Rt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MaxKey=void 0;class h{toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new h}}t.MaxKey=h,Object.defineProperty(h.prototype,"_bsontype",{value:"MaxKey"})});st(Rt);var $r=Rt.MaxKey,Ut=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MinKey=void 0;class h{toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new h}}t.MinKey=h,Object.defineProperty(h.prototype,"_bsontype",{value:"MinKey"})});st(Ut);var tn=Ut.MinKey,St=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectId=void 0;let h=rt.randomBytes(5),d=new RegExp("^[0-9a-fA-F]{24}$"),l=[];for(let _=0;_<256;_++)l[_]=(_<=15?"0":"")+_.toString(16);let f=[],u=0;for(;u<10;)f[48+u]=u++;for(;u<16;)f[65-10+u]=f[97-10+u]=u++;let m=Symbol("id");class o{constructor(g){if(g instanceof o&&(this[m]=g.id,this.__id=g.__id),typeof g=="object"&&g&&"id"in g&&("toHexString"in g&&typeof g.toHexString=="function"?this[m]=C.Buffer.from(g.toHexString(),"hex"):this[m]=typeof g.id=="string"?C.Buffer.from(g.id):g.id),(g==null||typeof g=="number")&&(this[m]=o.generate(typeof g=="number"?g:void 0),o.cacheHexString&&(this.__id=this.id.toString("hex"))),ArrayBuffer.isView(g)&&g.byteLength===12&&(this[m]=Et.ensureBuffer(g)),typeof g=="string")if(g.length===12){let n=C.Buffer.from(g);n.byteLength===12&&(this[m]=n)}else if(g.length===24&&d.test(g))this[m]=C.Buffer.from(g,"hex");else throw new TypeError("Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters");o.cacheHexString&&(this.__id=this.id.toString("hex"))}get id(){return this[m]}set id(g){this[m]=g,o.cacheHexString&&(this.__id=g.toString("hex"))}get generationTime(){return this.id.readInt32BE(0)}set generationTime(g){this.id.writeUInt32BE(g,0)}toHexString(){if(o.cacheHexString&&this.__id)return this.__id;let g=this.id.toString("hex");return o.cacheHexString&&!this.__id&&(this.__id=g),g}static getInc(){return o.index=(o.index+1)%16777215}static generate(g){typeof g!="number"&&(g=~~(Date.now()/1e3));let n=o.getInc(),w=C.Buffer.alloc(12);return w.writeUInt32BE(g,0),w[4]=h[0],w[5]=h[1],w[6]=h[2],w[7]=h[3],w[8]=h[4],w[11]=n&255,w[10]=n>>8&255,w[9]=n>>16&255,w}toString(g){return g?this.id.toString(g):this.toHexString()}toJSON(){return this.toHexString()}equals(g){return g==null?!1:g instanceof o?this.toString()===g.toString():typeof g=="string"&&o.isValid(g)&&g.length===12&&this.id instanceof C.Buffer?g===this.id.toString("binary"):typeof g=="string"&&o.isValid(g)&&g.length===24?g.toLowerCase()===this.toHexString():typeof g=="string"&&o.isValid(g)&&g.length===12?C.Buffer.from(g).equals(this.id):typeof g=="object"&&"toHexString"in g&&typeof g.toHexString=="function"?g.toHexString()===this.toHexString():!1}getTimestamp(){let g=new Date,n=this.id.readUInt32BE(0);return g.setTime(Math.floor(n)*1e3),g}static createPk(){return new o}static createFromTime(g){let n=C.Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(g,0),new o(n)}static createFromHexString(g){if(typeof g>"u"||g!=null&&g.length!==24)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new o(C.Buffer.from(g,"hex"))}static isValid(g){return g==null?!1:typeof g=="number"?!0:typeof g=="string"?g.length===12||g.length===24&&d.test(g):g instanceof o||g instanceof C.Buffer&&g.length===12?!0:typeof g=="object"&&"toHexString"in g&&typeof g.toHexString=="function"?typeof g.id=="string"?g.id.length===12:g.toHexString().length===24&&d.test(g.id.toString("hex")):!1}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(g){return new o(g.$oid)}}t.ObjectId=o,o.index=~~(Math.random()*16777215),Object.defineProperty(o.prototype,"generate",{value:rt.deprecate(_=>o.generate(_),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(o.prototype,"getInc",{value:rt.deprecate(()=>o.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(o.prototype,"get_inc",{value:rt.deprecate(()=>o.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(o,"get_inc",{value:rt.deprecate(()=>o.getInc(),"Please use the static `ObjectId.getInc()` instead")});let c=Symbol.for("nodejs.util.inspect.custom");Object.defineProperty(o.prototype,c,o.prototype.toString),Object.defineProperty(o.prototype,"inspect",o.prototype.toString),Object.defineProperty(o.prototype,"_bsontype",{value:"ObjectID"})});st(St);var en=St.ObjectId,b=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_DATA_MAX_KEY=t.BSON_DATA_MIN_KEY=t.BSON_DATA_DECIMAL128=t.BSON_DATA_LONG=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_INT=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_SYMBOL=t.BSON_DATA_CODE=t.BSON_DATA_DBPOINTER=t.BSON_DATA_REGEXP=t.BSON_DATA_NULL=t.BSON_DATA_DATE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_OID=t.BSON_DATA_UNDEFINED=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_DATA_OBJECT=t.BSON_DATA_STRING=t.BSON_DATA_NUMBER=t.JS_INT_MIN=t.JS_INT_MAX=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=void 0,t.BSON_INT32_MAX=2147483647,t.BSON_INT32_MIN=-2147483648,t.BSON_INT64_MAX=Math.pow(2,63)-1,t.BSON_INT64_MIN=-Math.pow(2,63),t.JS_INT_MAX=Math.pow(2,53),t.JS_INT_MIN=-Math.pow(2,53),t.BSON_DATA_NUMBER=1,t.BSON_DATA_STRING=2,t.BSON_DATA_OBJECT=3,t.BSON_DATA_ARRAY=4,t.BSON_DATA_BINARY=5,t.BSON_DATA_UNDEFINED=6,t.BSON_DATA_OID=7,t.BSON_DATA_BOOLEAN=8,t.BSON_DATA_DATE=9,t.BSON_DATA_NULL=10,t.BSON_DATA_REGEXP=11,t.BSON_DATA_DBPOINTER=12,t.BSON_DATA_CODE=13,t.BSON_DATA_SYMBOL=14,t.BSON_DATA_CODE_W_SCOPE=15,t.BSON_DATA_INT=16,t.BSON_DATA_TIMESTAMP=17,t.BSON_DATA_LONG=18,t.BSON_DATA_DECIMAL128=19,t.BSON_DATA_MIN_KEY=255,t.BSON_DATA_MAX_KEY=127,t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BSON_BINARY_SUBTYPE_FUNCTION=1,t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,t.BSON_BINARY_SUBTYPE_UUID=3,t.BSON_BINARY_SUBTYPE_UUID_NEW=4,t.BSON_BINARY_SUBTYPE_MD5=5,t.BSON_BINARY_SUBTYPE_USER_DEFINED=128});st(b);var rn=b.BSON_BINARY_SUBTYPE_USER_DEFINED,nn=b.BSON_BINARY_SUBTYPE_MD5,on=b.BSON_BINARY_SUBTYPE_UUID_NEW,sn=b.BSON_BINARY_SUBTYPE_UUID,fn=b.BSON_BINARY_SUBTYPE_BYTE_ARRAY,an=b.BSON_BINARY_SUBTYPE_FUNCTION,un=b.BSON_BINARY_SUBTYPE_DEFAULT,ln=b.BSON_DATA_MAX_KEY,cn=b.BSON_DATA_MIN_KEY,hn=b.BSON_DATA_DECIMAL128,_n=b.BSON_DATA_LONG,yn=b.BSON_DATA_TIMESTAMP,Bn=b.BSON_DATA_INT,pn=b.BSON_DATA_CODE_W_SCOPE,Nn=b.BSON_DATA_SYMBOL,gn=b.BSON_DATA_CODE,An=b.BSON_DATA_DBPOINTER,Sn=b.BSON_DATA_REGEXP,On=b.BSON_DATA_NULL,mn=b.BSON_DATA_DATE,En=b.BSON_DATA_BOOLEAN,wn=b.BSON_DATA_OID,Tn=b.BSON_DATA_UNDEFINED,bn=b.BSON_DATA_BINARY,dn=b.BSON_DATA_ARRAY,In=b.BSON_DATA_OBJECT,Dn=b.BSON_DATA_STRING,Rn=b.BSON_DATA_NUMBER,Un=b.JS_INT_MIN,Mn=b.JS_INT_MAX,Pn=b.BSON_INT64_MIN,jn=b.BSON_INT64_MAX,Fn=b.BSON_INT32_MIN,Yn=b.BSON_INT32_MAX,Be=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.calculateObjectSize=void 0;function h(l,f,u){let m=5;if(Array.isArray(l))for(let o=0;o<l.length;o++)m+=d(o.toString(),l[o],f,!0,u);else{l.toBSON&&(l=l.toBSON());for(let o in l)m+=d(o,l[o],f,!1,u)}return m}t.calculateObjectSize=h;function d(l,f,u=!1,m=!1,o=!1){switch(f&&f.toBSON&&(f=f.toBSON()),typeof f){case"string":return 1+C.Buffer.byteLength(l,"utf8")+1+4+C.Buffer.byteLength(f,"utf8")+1;case"number":return Math.floor(f)===f&&f>=b.JS_INT_MIN&&f<=b.JS_INT_MAX&&f>=b.BSON_INT32_MIN&&f<=b.BSON_INT32_MAX?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(4+1):(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(8+1);case"undefined":return m||!o?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1:0;case"boolean":return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(1+1);case"object":if(f==null||f._bsontype==="MinKey"||f._bsontype==="MaxKey")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1;if(f._bsontype==="ObjectId"||f._bsontype==="ObjectID")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(12+1);if(f instanceof Date||rt.isDate(f))return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(8+1);if(ArrayBuffer.isView(f)||f instanceof ArrayBuffer)return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(1+4+1)+f.byteLength;if(f._bsontype==="Long"||f._bsontype==="Double"||f._bsontype==="Timestamp")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(8+1);if(f._bsontype==="Decimal128")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(16+1);if(f._bsontype==="Code")return f.scope!=null&&Object.keys(f.scope).length>0?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+4+C.Buffer.byteLength(f.code.toString(),"utf8")+1+h(f.scope,u,o):(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+C.Buffer.byteLength(f.code.toString(),"utf8")+1;if(f._bsontype==="Binary")return f.sub_type===_t.Binary.SUBTYPE_BYTE_ARRAY?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(f.position+1+4+1+4):(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(f.position+1+4+1);if(f._bsontype==="Symbol")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+C.Buffer.byteLength(f.value,"utf8")+4+1+1;if(f._bsontype==="DBRef"){let c=Object.assign({$ref:f.collection,$id:f.oid},f.fields);return f.db!=null&&(c.$db=f.db),(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+h(c,u,o)}else return f instanceof RegExp||Object.prototype.toString.call(f)==="[object RegExp]"?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+C.Buffer.byteLength(f.source,"utf8")+1+(f.global?1:0)+(f.ignoreCase?1:0)+(f.multiline?1:0)+1:f._bsontype==="BSONRegExp"?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+C.Buffer.byteLength(f.pattern,"utf8")+1+C.Buffer.byteLength(f.options,"utf8")+1:(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+h(f,u,o)+1;case"function":if(f instanceof RegExp||Object.prototype.toString.call(f)==="[object RegExp]"||String.call(f)==="[object RegExp]")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+C.Buffer.byteLength(f.source,"utf8")+1+(f.global?1:0)+(f.ignoreCase?1:0)+(f.multiline?1:0)+1;if(u&&f.scope!=null&&Object.keys(f.scope).length>0)return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+4+C.Buffer.byteLength(rt.normalizedFunctionString(f),"utf8")+1+h(f.scope,u,o);if(u)return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+C.Buffer.byteLength(rt.normalizedFunctionString(f),"utf8")+1}return 0}});st(Be);var Ln=Be.calculateObjectSize,Ot=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONRegExp=void 0;function h(l){return l.split("").sort().join("")}class d{constructor(f,u){this.pattern=f,this.options=u??"",h(this.options);for(let m=0;m<this.options.length;m++)if(!(this.options[m]==="i"||this.options[m]==="m"||this.options[m]==="x"||this.options[m]==="l"||this.options[m]==="s"||this.options[m]==="u"))throw new Error(`The regular expression option [${this.options[m]}] is not supported`)}static parseOptions(f){return f?f.split("").sort().join(""):""}toExtendedJSON(f){return f=f||{},f.legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(f){if("$regex"in f)if(typeof f.$regex!="string"){if(f.$regex._bsontype==="BSONRegExp")return f}else return new d(f.$regex,d.parseOptions(f.$options));if("$regularExpression"in f)return new d(f.$regularExpression.pattern,d.parseOptions(f.$regularExpression.options));throw new TypeError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(f)}`)}}t.BSONRegExp=d,Object.defineProperty(d.prototype,"_bsontype",{value:"BSONRegExp"})});st(Ot);var vn=Ot.BSONRegExp,Mt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONSymbol=void 0;class h{constructor(l){this.value=l}valueOf(){return this.value}toString(){return this.value}inspect(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(l){return new h(l.$symbol)}}t.BSONSymbol=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Symbol"})});st(Mt);var Cn=Mt.BSONSymbol,wt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Timestamp=t.LongWithoutOverridesClass=void 0,t.LongWithoutOverridesClass=K.Long;class h extends t.LongWithoutOverridesClass{constructor(l,f){K.Long.isLong(l)?super(l.low,l.high,!0):super(l,f,!0),Object.defineProperty(this,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1})}toJSON(){return{$timestamp:this.toString()}}static fromInt(l){return new h(K.Long.fromInt(l,!0))}static fromNumber(l){return new h(K.Long.fromNumber(l,!0))}static fromBits(l,f){return new h(l,f)}static fromString(l,f){return new h(K.Long.fromString(l,!0,f))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(l){return new h(l.$timestamp.i,l.$timestamp.t)}}t.Timestamp=h,h.MAX_VALUE=K.Long.MAX_UNSIGNED_VALUE});st(wt);var zn=wt.Timestamp,Jn=wt.LongWithoutOverridesClass,Gt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateUtf8=void 0;let h=128,d=192,l=224,f=240,u=248,m=192,o=224,c=240,_=128;function g(n,w,U){let p=0;for(let F=w;F<U;F+=1){let J=n[F];if(p){if((J&d)!==_)return!1;p-=1}else if(J&h)if((J&l)===m)p=1;else if((J&f)===o)p=2;else if((J&u)===c)p=3;else return!1}return!p}t.validateUtf8=g});st(Gt);var Wn=Gt.validateUtf8,xt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserialize=void 0;let h=K.Long.fromNumber(b.JS_INT_MAX),d=K.Long.fromNumber(b.JS_INT_MIN),l={};function f(o,c,_){c=c??{};let g=c&&c.index?c.index:0,n=o[g]|o[g+1]<<8|o[g+2]<<16|o[g+3]<<24;if(n<5)throw new Error(`bson size must be >= 5, is ${n}`);if(c.allowObjectSmallerThanBufferSize&&o.length<n)throw new Error(`buffer length ${o.length} must be >= bson size ${n}`);if(!c.allowObjectSmallerThanBufferSize&&o.length!==n)throw new Error(`buffer length ${o.length} must === bson size ${n}`);if(n+g>o.byteLength)throw new Error(`(bson size ${n} + options.index ${g} must be <= buffer length ${o.byteLength})`);if(o[g+n-1]!==0)throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return u(o,g,c,_)}t.deserialize=f;function u(o,c,_,g=!1){let n=_.evalFunctions==null?!1:_.evalFunctions,w=_.cacheFunctions==null?!1:_.cacheFunctions,U=_.fieldsAsRaw==null?null:_.fieldsAsRaw,p=_.raw==null?!1:_.raw,F=typeof _.bsonRegExp=="boolean"?_.bsonRegExp:!1,J=_.promoteBuffers==null?!1:_.promoteBuffers,R=_.promoteLongs==null?!0:_.promoteLongs,W=_.promoteValues==null?!0:_.promoteValues,Q=c;if(o.length<5)throw new Error("corrupt bson message < 5 bytes long");let H=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(H<5||H>o.length)throw new Error("corrupt bson message");let M=g?[]:{},G=0,z=!1;for(;!z;){let O=o[c++];if(O===0)break;let A=c;for(;o[A]!==0&&A<o.length;)A++;if(A>=o.byteLength)throw new Error("Bad BSON Document: illegal CString");let i=g?G++:o.toString("utf8",c,A);if(c=A+1,O===b.BSON_DATA_STRING){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");if(!Gt.validateUtf8(o,c,c+E-1))throw new Error("Invalid UTF-8 string in BSON document");let I=o.toString("utf8",c,c+E-1);M[i]=I,c=c+E}else if(O===b.BSON_DATA_OID){let E=C.Buffer.alloc(12);o.copy(E,0,c,c+12),M[i]=new St.ObjectId(E),c=c+12}else if(O===b.BSON_DATA_INT&&W===!1)M[i]=new dt.Int32(o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24);else if(O===b.BSON_DATA_INT)M[i]=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;else if(O===b.BSON_DATA_NUMBER&&W===!1)M[i]=new bt.Double(o.readDoubleLE(c)),c=c+8;else if(O===b.BSON_DATA_NUMBER)M[i]=o.readDoubleLE(c),c=c+8;else if(O===b.BSON_DATA_DATE){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;M[i]=new Date(new K.Long(E,I).toNumber())}else if(O===b.BSON_DATA_BOOLEAN){if(o[c]!==0&&o[c]!==1)throw new Error("illegal boolean type value");M[i]=o[c++]===1}else if(O===b.BSON_DATA_OBJECT){let E=c,I=o[c]|o[c+1]<<8|o[c+2]<<16|o[c+3]<<24;if(I<=0||I>o.length-c)throw new Error("bad embedded document length in bson");p?M[i]=o.slice(c,c+I):M[i]=u(o,E,_,!1),c=c+I}else if(O===b.BSON_DATA_ARRAY){let E=c,I=o[c]|o[c+1]<<8|o[c+2]<<16|o[c+3]<<24,j=_,L=c+I;if(U&&U[i]){j={};for(let N in _)j[N]=_[N];j.raw=!0}if(M[i]=u(o,E,j,!0),c=c+I,o[c-1]!==0)throw new Error("invalid array terminator byte");if(c!==L)throw new Error("corrupted array bson")}else if(O===b.BSON_DATA_UNDEFINED)M[i]=void 0;else if(O===b.BSON_DATA_NULL)M[i]=null;else if(O===b.BSON_DATA_LONG){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,j=new K.Long(E,I);R&&W===!0?M[i]=j.lessThanOrEqual(h)&&j.greaterThanOrEqual(d)?j.toNumber():j:M[i]=j}else if(O===b.BSON_DATA_DECIMAL128){let E=C.Buffer.alloc(16);o.copy(E,0,c,c+16),c=c+16;let I=new Dt.Decimal128(E);"toObject"in I&&typeof I.toObject=="function"?M[i]=I.toObject():M[i]=I}else if(O===b.BSON_DATA_BINARY){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=E,j=o[c++];if(E<0)throw new Error("Negative binary type element size found");if(E>o.byteLength)throw new Error("Binary type size larger than document size");if(o.slice!=null){if(j===_t.Binary.SUBTYPE_BYTE_ARRAY){if(E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,E<0)throw new Error("Negative binary type element size found for subtype 0x02");if(E>I-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(E<I-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}J&&W?M[i]=o.slice(c,c+E):M[i]=new _t.Binary(o.slice(c,c+E),j)}else{let L=C.Buffer.alloc(E);if(j===_t.Binary.SUBTYPE_BYTE_ARRAY){if(E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,E<0)throw new Error("Negative binary type element size found for subtype 0x02");if(E>I-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(E<I-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(A=0;A<E;A++)L[A]=o[c+A];J&&W?M[i]=L:M[i]=new _t.Binary(L,j)}c=c+E}else if(O===b.BSON_DATA_REGEXP&&F===!1){for(A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let E=o.toString("utf8",c,A);for(c=A+1,A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let I=o.toString("utf8",c,A);c=A+1;let j=new Array(I.length);for(A=0;A<I.length;A++)switch(I[A]){case"m":j[A]="m";break;case"s":j[A]="g";break;case"i":j[A]="i";break}M[i]=new RegExp(E,j.join(""))}else if(O===b.BSON_DATA_REGEXP&&F===!0){for(A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let E=o.toString("utf8",c,A);for(c=A+1,A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let I=o.toString("utf8",c,A);c=A+1,M[i]=new Ot.BSONRegExp(E,I)}else if(O===b.BSON_DATA_SYMBOL){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");let I=o.toString("utf8",c,c+E-1);M[i]=W?I:new Mt.BSONSymbol(I),c=c+E}else if(O===b.BSON_DATA_TIMESTAMP){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;M[i]=new wt.Timestamp(E,I)}else if(O===b.BSON_DATA_MIN_KEY)M[i]=new Ut.MinKey;else if(O===b.BSON_DATA_MAX_KEY)M[i]=new Rt.MaxKey;else if(O===b.BSON_DATA_CODE){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");let I=o.toString("utf8",c,c+E-1);n?w?M[i]=m(I,l,M):M[i]=m(I):M[i]=new mt.Code(I),c=c+E}else if(O===b.BSON_DATA_CODE_W_SCOPE){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<4+4+4+1)throw new Error("code_w_scope total size shorter minimum expected length");let I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(I<=0||I>o.length-c||o[c+I-1]!==0)throw new Error("bad string length in bson");let j=o.toString("utf8",c,c+I-1);c=c+I;let L=c,N=o[c]|o[c+1]<<8|o[c+2]<<16|o[c+3]<<24,$=u(o,L,_,!1);if(c=c+N,E<4+4+N+I)throw new Error("code_w_scope total size is too short, truncating scope");if(E>4+4+N+I)throw new Error("code_w_scope total size is too long, clips outer document");n?(w?M[i]=m(j,l,M):M[i]=m(j),M[i].scope=$):M[i]=new mt.Code(j,$)}else if(O===b.BSON_DATA_DBPOINTER){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");if(!Gt.validateUtf8(o,c,c+E-1))throw new Error("Invalid UTF-8 string in BSON document");let I=o.toString("utf8",c,c+E-1);c=c+E;let j=C.Buffer.alloc(12);o.copy(j,0,c,c+12);let L=new St.ObjectId(j);c=c+12,M[i]=new pt.DBRef(I,L)}else throw new Error("Detected unknown BSON type "+O.toString(16)+' for fieldname "'+i+'"')}if(H!==c-Q)throw g?new Error("corrupt array bson"):new Error("corrupt object bson");let x=Object.keys(M).filter(O=>O.startsWith("$")),s=!0;if(x.forEach(O=>{["$ref","$id","$db"].indexOf(O)===-1&&(s=!1)}),!s)return M;if(pt.isDBRefLike(M)){let O=Object.assign({},M);return delete O.$ref,delete O.$id,delete O.$db,new pt.DBRef(M.$ref,M.$id,M.$db,O)}return M}function m(o,c,_){return c?(c[o]==null&&(c[o]=new Function(o)),c[o].bind(_)):new Function(o)}});st(xt);var kn=xt.deserialize,Ft=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.EJSON=t.isBSONType=void 0;function h(p){return rt.isObjectLike(p)&&Reflect.has(p,"_bsontype")&&typeof p._bsontype=="string"}t.isBSONType=h;let d=2147483647,l=-2147483648,f=9223372036854776e3,u=-9223372036854776e3,m={$oid:St.ObjectId,$binary:_t.Binary,$uuid:_t.Binary,$symbol:Mt.BSONSymbol,$numberInt:dt.Int32,$numberDecimal:Dt.Decimal128,$numberDouble:bt.Double,$numberLong:K.Long,$minKey:Ut.MinKey,$maxKey:Rt.MaxKey,$regex:Ot.BSONRegExp,$regularExpression:Ot.BSONRegExp,$timestamp:wt.Timestamp};function o(p,F={}){if(typeof p=="number"){if(F.relaxed||F.legacy)return p;if(Math.floor(p)===p){if(p>=l&&p<=d)return new dt.Int32(p);if(p>=u&&p<=f)return K.Long.fromNumber(p)}return new bt.Double(p)}if(p==null||typeof p!="object")return p;if(p.$undefined)return null;let J=Object.keys(p).filter(R=>R.startsWith("$")&&p[R]!=null);for(let R=0;R<J.length;R++){let W=m[J[R]];if(W)return W.fromExtendedJSON(p,F)}if(p.$date!=null){let R=p.$date,W=new Date;return F.legacy?typeof R=="number"?W.setTime(R):typeof R=="string"&&W.setTime(Date.parse(R)):typeof R=="string"?W.setTime(Date.parse(R)):K.Long.isLong(R)?W.setTime(R.toNumber()):typeof R=="number"&&F.relaxed&&W.setTime(R),W}if(p.$code!=null){let R=Object.assign({},p);return p.$scope&&(R.$scope=o(p.$scope)),mt.Code.fromExtendedJSON(p)}if(p.$ref!=null||p.$dbPointer!=null){let R=p.$ref?p:p.$dbPointer;if(R instanceof pt.DBRef)return R;let W=Object.keys(R).filter(H=>H.startsWith("$")),Q=!0;if(W.forEach(H=>{["$ref","$id","$db"].indexOf(H)===-1&&(Q=!1)}),Q)return pt.DBRef.fromExtendedJSON(R)}return p}function c(p,F){return p.map(J=>g(J,F))}function _(p){let F=p.toISOString();return p.getUTCMilliseconds()!==0?F:F.slice(0,-5)+"Z"}function g(p,F){if(Array.isArray(p))return c(p,F);if(p===void 0)return null;if(p instanceof Date){let J=p.getTime(),R=J>-1&&J<2534023188e5;return F.legacy?F.relaxed&&R?{$date:p.getTime()}:{$date:_(p)}:F.relaxed&&R?{$date:_(p)}:{$date:{$numberLong:p.getTime().toString()}}}if(typeof p=="number"&&!F.relaxed){if(Math.floor(p)===p){let J=p>=l&&p<=d,R=p>=u&&p<=f;if(J)return{$numberInt:p.toString()};if(R)return{$numberLong:p.toString()}}return{$numberDouble:p.toString()}}if(p instanceof RegExp){let J=p.flags;if(J===void 0){let W=p.toString().match(/[gimuy]*$/);W&&(J=W[0])}return new Ot.BSONRegExp(p.source,J).toExtendedJSON(F)}return p!=null&&typeof p=="object"?w(p,F):p}let n={Binary:p=>new _t.Binary(p.value(),p.sub_type),Code:p=>new mt.Code(p.code,p.scope),DBRef:p=>new pt.DBRef(p.collection||p.namespace,p.oid,p.db,p.fields),Decimal128:p=>new Dt.Decimal128(p.bytes),Double:p=>new bt.Double(p.value),Int32:p=>new dt.Int32(p.value),Long:p=>K.Long.fromBits(p.low!=null?p.low:p.low_,p.low!=null?p.high:p.high_,p.low!=null?p.unsigned:p.unsigned_),MaxKey:()=>new Rt.MaxKey,MinKey:()=>new Ut.MinKey,ObjectID:p=>new St.ObjectId(p),ObjectId:p=>new St.ObjectId(p),BSONRegExp:p=>new Ot.BSONRegExp(p.pattern,p.options),Symbol:p=>new Mt.BSONSymbol(p.value),Timestamp:p=>wt.Timestamp.fromBits(p.low,p.high)};function w(p,F){if(p==null||typeof p!="object")throw new Error("not an object instance");let J=p._bsontype;if(typeof J>"u"){let R={};for(let W in p)R[W]=g(p[W],F);return R}else if(h(p)){let R=p;if(typeof R.toExtendedJSON!="function"){let W=n[p._bsontype];if(!W)throw new TypeError("Unrecognized or invalid _bsontype: "+p._bsontype);R=W(R)}return J==="Code"&&R.scope?R=new mt.Code(R.code,g(R.scope,F)):J==="DBRef"&&R.oid&&(R=new pt.DBRef(R.collection,g(R.oid,F),R.db,R.fields)),R.toExtendedJSON(F)}else throw new Error("_bsontype must be a string, but was: "+typeof J)}var U;(function(p){function F(Q,H){let M=Object.assign({},{relaxed:!0,legacy:!1},H);return typeof M.relaxed=="boolean"&&(M.strict=!M.relaxed),typeof M.strict=="boolean"&&(M.relaxed=!M.strict),JSON.parse(Q,(G,z)=>o(z,M))}p.parse=F;function J(Q,H,M,G){M!=null&&typeof M=="object"&&(G=M,M=0),H!=null&&typeof H=="object"&&!Array.isArray(H)&&(G=H,H=void 0,M=0),G=Object.assign({},{relaxed:!0,legacy:!1},G);let z=g(Q,G);return JSON.stringify(z,H,M)}p.stringify=J;function R(Q,H){return H=H||{},JSON.parse(J(Q,H))}p.serialize=R;function W(Q,H){return H=H||{},F(JSON.stringify(Q),H)}p.deserialize=W})(U=t.EJSON||(t.EJSON={}))});st(Ft);var Xn=Ft.EJSON,Kn=Ft.isBSONType,jt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.writeIEEE754=t.readIEEE754=void 0;function h(l,f,u,m,o){let c,_,g=u==="big",n=o*8-m-1,w=(1<<n)-1,U=w>>1,p=-7,F=g?0:o-1,J=g?1:-1,R=l[f+F];for(F+=J,c=R&(1<<-p)-1,R>>=-p,p+=n;p>0;c=c*256+l[f+F],F+=J,p-=8);for(_=c&(1<<-p)-1,c>>=-p,p+=m;p>0;_=_*256+l[f+F],F+=J,p-=8);if(c===0)c=1-U;else{if(c===w)return _?NaN:(R?-1:1)*(1/0);_=_+Math.pow(2,m),c=c-U}return(R?-1:1)*_*Math.pow(2,c-m)}t.readIEEE754=h;function d(l,f,u,m,o,c){let _,g,n,w=m==="big",U=c*8-o-1,p=(1<<U)-1,F=p>>1,J=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=w?c-1:0,W=w?-1:1,Q=f<0||f===0&&1/f<0?1:0;for(f=Math.abs(f),isNaN(f)||f===1/0?(g=isNaN(f)?1:0,_=p):(_=Math.floor(Math.log(f)/Math.LN2),f*(n=Math.pow(2,-_))<1&&(_--,n*=2),_+F>=1?f+=J/n:f+=J*Math.pow(2,1-F),f*n>=2&&(_++,n/=2),_+F>=p?(g=0,_=p):_+F>=1?(g=(f*n-1)*Math.pow(2,o),_=_+F):(g=f*Math.pow(2,F-1)*Math.pow(2,o),_=0)),isNaN(f)&&(g=0);o>=8;)l[u+R]=g&255,R+=W,g/=256,o-=8;for(_=_<<o|g,isNaN(f)&&(_+=8),U+=o;U>0;)l[u+R]=_&255,R+=W,_/=256,U-=8;l[u+R-W]|=Q*128}t.writeIEEE754=d});st(jt);var Vn=jt.writeIEEE754,Hn=jt.readIEEE754,Zt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeInto=void 0;let h=/\x00/,d=new Set(["$db","$ref","$id","$clusterTime"]);function l(s){return Object.prototype.toString.call(s)==="[object RegExp]"}function f(s,O,A,i,E){s[i++]=b.BSON_DATA_STRING;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I+1,s[i-1]=0;let j=s.write(A,i+4,void 0,"utf8");return s[i+3]=j+1>>24&255,s[i+2]=j+1>>16&255,s[i+1]=j+1>>8&255,s[i]=j+1&255,i=i+4+j,s[i++]=0,i}function u(s,O,A,i,E){if(Number.isInteger(A)&&A>=b.BSON_INT32_MIN&&A<=b.BSON_INT32_MAX){s[i++]=b.BSON_DATA_INT;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0,s[i++]=A&255,s[i++]=A>>8&255,s[i++]=A>>16&255,s[i++]=A>>24&255}else{s[i++]=b.BSON_DATA_NUMBER;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0,jt.writeIEEE754(s,A,i,"little",52,8),i=i+8}return i}function m(s,O,A,i,E){s[i++]=b.BSON_DATA_NULL;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,i}function o(s,O,A,i,E){s[i++]=b.BSON_DATA_BOOLEAN;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,s[i++]=A?1:0,i}function c(s,O,A,i,E){s[i++]=b.BSON_DATA_DATE;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=K.Long.fromNumber(A.getTime()),L=j.getLowBits(),N=j.getHighBits();return s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255,s[i++]=N&255,s[i++]=N>>8&255,s[i++]=N>>16&255,s[i++]=N>>24&255,i}function _(s,O,A,i,E){s[i++]=b.BSON_DATA_REGEXP;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");if(i=i+I,s[i++]=0,A.source&&A.source.match(h)!=null)throw Error("value "+A.source+" must not contain null bytes");return i=i+s.write(A.source,i,void 0,"utf8"),s[i++]=0,A.ignoreCase&&(s[i++]=105),A.global&&(s[i++]=115),A.multiline&&(s[i++]=109),s[i++]=0,i}function g(s,O,A,i,E){s[i++]=b.BSON_DATA_REGEXP;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");if(i=i+I,s[i++]=0,A.pattern.match(h)!=null)throw Error("pattern "+A.pattern+" must not contain null bytes");return i=i+s.write(A.pattern,i,void 0,"utf8"),s[i++]=0,i=i+s.write(A.options.split("").sort().join(""),i,void 0,"utf8"),s[i++]=0,i}function n(s,O,A,i,E){A===null?s[i++]=b.BSON_DATA_NULL:A._bsontype==="MinKey"?s[i++]=b.BSON_DATA_MIN_KEY:s[i++]=b.BSON_DATA_MAX_KEY;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,i}function w(s,O,A,i,E){s[i++]=b.BSON_DATA_OID;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");if(i=i+I,s[i++]=0,typeof A.id=="string")s.write(A.id,i,void 0,"binary");else if(A.id&&A.id.copy)A.id.copy(s,i,0,12);else throw new TypeError("object ["+JSON.stringify(A)+"] is not a valid ObjectId");return i+12}function U(s,O,A,i,E){s[i++]=b.BSON_DATA_BINARY;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=A.length;return s[i++]=j&255,s[i++]=j>>8&255,s[i++]=j>>16&255,s[i++]=j>>24&255,s[i++]=b.BSON_BINARY_SUBTYPE_DEFAULT,s.set(Et.ensureBuffer(A),i),i=i+j,i}function p(s,O,A,i,E=!1,I=0,j=!1,L=!0,N=!1,$=[]){for(let D=0;D<$.length;D++)if($[D]===A)throw new Error("cyclic dependency detected");$.push(A),s[i++]=Array.isArray(A)?b.BSON_DATA_ARRAY:b.BSON_DATA_OBJECT;let v=N?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+v,s[i++]=0;let T=x(s,A,E,i,I+1,j,L,$);return $.pop(),T}function F(s,O,A,i,E){s[i++]=b.BSON_DATA_DECIMAL128;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,A.bytes.copy(s,i,0,16),i+16}function J(s,O,A,i,E){s[i++]=A._bsontype==="Long"?b.BSON_DATA_LONG:b.BSON_DATA_TIMESTAMP;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=A.getLowBits(),L=A.getHighBits();return s[i++]=j&255,s[i++]=j>>8&255,s[i++]=j>>16&255,s[i++]=j>>24&255,s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255,i}function R(s,O,A,i,E){A=A.valueOf(),s[i++]=b.BSON_DATA_INT;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,s[i++]=A&255,s[i++]=A>>8&255,s[i++]=A>>16&255,s[i++]=A>>24&255,i}function W(s,O,A,i,E){s[i++]=b.BSON_DATA_NUMBER;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,jt.writeIEEE754(s,A.value,i,"little",52,8),i=i+8,i}function Q(s,O,A,i,E=!1,I=0,j){s[i++]=b.BSON_DATA_CODE;let L=j?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+L,s[i++]=0;let N=rt.normalizedFunctionString(A),$=s.write(N,i+4,void 0,"utf8")+1;return s[i]=$&255,s[i+1]=$>>8&255,s[i+2]=$>>16&255,s[i+3]=$>>24&255,i=i+4+$-1,s[i++]=0,i}function H(s,O,A,i,E=!1,I=0,j=!1,L=!0,N=!1){if(A.scope&&typeof A.scope=="object"){s[i++]=b.BSON_DATA_CODE_W_SCOPE;let $=N?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+$,s[i++]=0;let v=i,T=typeof A.code=="string"?A.code:A.code.toString();i=i+4;let D=s.write(T,i+4,void 0,"utf8")+1;s[i]=D&255,s[i+1]=D>>8&255,s[i+2]=D>>16&255,s[i+3]=D>>24&255,s[i+4+D-1]=0,i=i+D+4;let Z=x(s,A.scope,E,i,I+1,j,L);i=Z-1;let k=Z-v;s[v++]=k&255,s[v++]=k>>8&255,s[v++]=k>>16&255,s[v++]=k>>24&255,s[i++]=0}else{s[i++]=b.BSON_DATA_CODE;let $=N?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+$,s[i++]=0;let v=A.code.toString(),T=s.write(v,i+4,void 0,"utf8")+1;s[i]=T&255,s[i+1]=T>>8&255,s[i+2]=T>>16&255,s[i+3]=T>>24&255,i=i+4+T-1,s[i++]=0}return i}function M(s,O,A,i,E){s[i++]=b.BSON_DATA_BINARY;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=A.value(!0),L=A.position;return A.sub_type===_t.Binary.SUBTYPE_BYTE_ARRAY&&(L=L+4),s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255,s[i++]=A.sub_type,A.sub_type===_t.Binary.SUBTYPE_BYTE_ARRAY&&(L=L-4,s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255),s.set(j,i),i=i+A.position,i}function G(s,O,A,i,E){s[i++]=b.BSON_DATA_SYMBOL;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=s.write(A.value,i+4,void 0,"utf8")+1;return s[i]=j&255,s[i+1]=j>>8&255,s[i+2]=j>>16&255,s[i+3]=j>>24&255,i=i+4+j-1,s[i++]=0,i}function z(s,O,A,i,E,I,j){s[i++]=b.BSON_DATA_OBJECT;let L=j?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+L,s[i++]=0;let N=i,$={$ref:A.collection||A.namespace,$id:A.oid};A.db!=null&&($.$db=A.db),$=Object.assign($,A.fields);let v=x(s,$,!1,i,E+1,I),T=v-N;return s[N++]=T&255,s[N++]=T>>8&255,s[N++]=T>>16&255,s[N++]=T>>24&255,v}function x(s,O,A=!1,i=0,E=0,I=!1,j=!0,L=[]){i=i||0,L=L||[],L.push(O);let N=i+4;if(Array.isArray(O))for(let v=0;v<O.length;v++){let T=""+v,D=O[v];if(D&&D.toBSON){if(typeof D.toBSON!="function")throw new TypeError("toBSON is not a function");D=D.toBSON()}if(typeof D=="string")N=f(s,T,D,N,!0);else if(typeof D=="number")N=u(s,T,D,N,!0);else{if(typeof D=="bigint")throw new TypeError("Unsupported type BigInt, please use Decimal128");if(typeof D=="boolean")N=o(s,T,D,N,!0);else if(D instanceof Date||rt.isDate(D))N=c(s,T,D,N,!0);else if(D===void 0)N=m(s,T,D,N,!0);else if(D===null)N=m(s,T,D,N,!0);else if(D._bsontype==="ObjectId"||D._bsontype==="ObjectID")N=w(s,T,D,N,!0);else if(C.Buffer.isBuffer(D)||rt.isUint8Array(D))N=U(s,T,D,N,!0);else if(D instanceof RegExp||l(D))N=_(s,T,D,N,!0);else if(typeof D=="object"&&D._bsontype==null)N=p(s,T,D,N,A,E,I,j,!0,L);else if(typeof D=="object"&&Ft.isBSONType(D)&&D._bsontype==="Decimal128")N=F(s,T,D,N,!0);else if(D._bsontype==="Long"||D._bsontype==="Timestamp")N=J(s,T,D,N,!0);else if(D._bsontype==="Double")N=W(s,T,D,N,!0);else if(typeof D=="function"&&I)N=Q(s,T,D,N,A,E,!0);else if(D._bsontype==="Code")N=H(s,T,D,N,A,E,I,j,!0);else if(D._bsontype==="Binary")N=M(s,T,D,N,!0);else if(D._bsontype==="Symbol")N=G(s,T,D,N,!0);else if(D._bsontype==="DBRef")N=z(s,T,D,N,E,I,!0);else if(D._bsontype==="BSONRegExp")N=g(s,T,D,N,!0);else if(D._bsontype==="Int32")N=R(s,T,D,N,!0);else if(D._bsontype==="MinKey"||D._bsontype==="MaxKey")N=n(s,T,D,N,!0);else if(typeof D._bsontype<"u")throw new TypeError("Unrecognized or invalid _bsontype: "+D._bsontype)}}else if(O instanceof $t.Map){let v=O.entries(),T=!1;for(;!T;){let D=v.next();if(T=!!D.done,T)continue;let Z=D.value[0],k=D.value[1],et=typeof k;if(typeof Z=="string"&&!d.has(Z)){if(Z.match(h)!=null)throw Error("key "+Z+" must not contain null bytes");if(A){if(Z[0]==="$")throw Error("key "+Z+" must not start with '$'");if(~Z.indexOf("."))throw Error("key "+Z+" must not contain '.'")}}if(et==="string")N=f(s,Z,k,N);else if(et==="number")N=u(s,Z,k,N);else{if(et==="bigint"||rt.isBigInt64Array(k)||rt.isBigUInt64Array(k))throw new TypeError("Unsupported type BigInt, please use Decimal128");if(et==="boolean")N=o(s,Z,k,N);else if(k instanceof Date||rt.isDate(k))N=c(s,Z,k,N);else if(k===null||k===void 0&&j===!1)N=m(s,Z,k,N);else if(k._bsontype==="ObjectId"||k._bsontype==="ObjectID")N=w(s,Z,k,N);else if(C.Buffer.isBuffer(k)||rt.isUint8Array(k))N=U(s,Z,k,N);else if(k instanceof RegExp||l(k))N=_(s,Z,k,N);else if(et==="object"&&k._bsontype==null)N=p(s,Z,k,N,A,E,I,j,!1,L);else if(et==="object"&&k._bsontype==="Decimal128")N=F(s,Z,k,N);else if(k._bsontype==="Long"||k._bsontype==="Timestamp")N=J(s,Z,k,N);else if(k._bsontype==="Double")N=W(s,Z,k,N);else if(k._bsontype==="Code")N=H(s,Z,k,N,A,E,I,j);else if(typeof k=="function"&&I)N=Q(s,Z,k,N,A,E,I);else if(k._bsontype==="Binary")N=M(s,Z,k,N);else if(k._bsontype==="Symbol")N=G(s,Z,k,N);else if(k._bsontype==="DBRef")N=z(s,Z,k,N,E,I);else if(k._bsontype==="BSONRegExp")N=g(s,Z,k,N);else if(k._bsontype==="Int32")N=R(s,Z,k,N);else if(k._bsontype==="MinKey"||k._bsontype==="MaxKey")N=n(s,Z,k,N);else if(typeof k._bsontype<"u")throw new TypeError("Unrecognized or invalid _bsontype: "+k._bsontype)}}}else{if(O.toBSON){if(typeof O.toBSON!="function")throw new TypeError("toBSON is not a function");if(O=O.toBSON(),O!=null&&typeof O!="object")throw new TypeError("toBSON function did not return an object")}for(let v in O){let T=O[v];if(T&&T.toBSON){if(typeof T.toBSON!="function")throw new TypeError("toBSON is not a function");T=T.toBSON()}let D=typeof T;if(typeof v=="string"&&!d.has(v)){if(v.match(h)!=null)throw Error("key "+v+" must not contain null bytes");if(A){if(v[0]==="$")throw Error("key "+v+" must not start with '$'");if(~v.indexOf("."))throw Error("key "+v+" must not contain '.'")}}if(D==="string")N=f(s,v,T,N);else if(D==="number")N=u(s,v,T,N);else{if(D==="bigint")throw new TypeError("Unsupported type BigInt, please use Decimal128");if(D==="boolean")N=o(s,v,T,N);else if(T instanceof Date||rt.isDate(T))N=c(s,v,T,N);else if(T===void 0)j===!1&&(N=m(s,v,T,N));else if(T===null)N=m(s,v,T,N);else if(T._bsontype==="ObjectId"||T._bsontype==="ObjectID")N=w(s,v,T,N);else if(C.Buffer.isBuffer(T)||rt.isUint8Array(T))N=U(s,v,T,N);else if(T instanceof RegExp||l(T))N=_(s,v,T,N);else if(D==="object"&&T._bsontype==null)N=p(s,v,T,N,A,E,I,j,!1,L);else if(D==="object"&&T._bsontype==="Decimal128")N=F(s,v,T,N);else if(T._bsontype==="Long"||T._bsontype==="Timestamp")N=J(s,v,T,N);else if(T._bsontype==="Double")N=W(s,v,T,N);else if(T._bsontype==="Code")N=H(s,v,T,N,A,E,I,j);else if(typeof T=="function"&&I)N=Q(s,v,T,N,A,E,I);else if(T._bsontype==="Binary")N=M(s,v,T,N);else if(T._bsontype==="Symbol")N=G(s,v,T,N);else if(T._bsontype==="DBRef")N=z(s,v,T,N,E,I);else if(T._bsontype==="BSONRegExp")N=g(s,v,T,N);else if(T._bsontype==="Int32")N=R(s,v,T,N);else if(T._bsontype==="MinKey"||T._bsontype==="MaxKey")N=n(s,v,T,N);else if(typeof T._bsontype<"u")throw new TypeError("Unrecognized or invalid _bsontype: "+T._bsontype)}}}L.pop(),s[N++]=0;let $=N-i;return s[i++]=$&255,s[i++]=$>>8&255,s[i++]=$>>16&255,s[i++]=$>>24&255,N}t.serializeInto=x});st(Zt);var Gn=Zt.serializeInto,V=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeStream=t.calculateObjectSize=t.deserialize=t.serializeWithBufferAndIndex=t.serialize=t.setInternalBufferSize=t.ObjectID=t.Decimal128=t.BSONRegExp=t.MaxKey=t.MinKey=t.Int32=t.Double=t.Timestamp=t.Long=t.ObjectId=t.Binary=t.DBRef=t.BSONSymbol=t.Map=t.Code=t.LongWithoutOverridesClass=t.EJSON=t.JS_INT_MIN=t.JS_INT_MAX=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=t.BSON_DATA_UNDEFINED=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_SYMBOL=t.BSON_DATA_STRING=t.BSON_DATA_REGEXP=t.BSON_DATA_OID=t.BSON_DATA_OBJECT=t.BSON_DATA_NUMBER=t.BSON_DATA_NULL=t.BSON_DATA_MIN_KEY=t.BSON_DATA_MAX_KEY=t.BSON_DATA_LONG=t.BSON_DATA_INT=t.BSON_DATA_DECIMAL128=t.BSON_DATA_DBPOINTER=t.BSON_DATA_DATE=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_CODE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=void 0,Object.defineProperty(t,"Binary",{enumerable:!0,get:function(){return _t.Binary}}),Object.defineProperty(t,"Code",{enumerable:!0,get:function(){return mt.Code}}),Object.defineProperty(t,"DBRef",{enumerable:!0,get:function(){return pt.DBRef}}),Object.defineProperty(t,"Decimal128",{enumerable:!0,get:function(){return Dt.Decimal128}}),Object.defineProperty(t,"Double",{enumerable:!0,get:function(){return bt.Double}}),Object.defineProperty(t,"Int32",{enumerable:!0,get:function(){return dt.Int32}}),Object.defineProperty(t,"Long",{enumerable:!0,get:function(){return K.Long}}),Object.defineProperty(t,"Map",{enumerable:!0,get:function(){return $t.Map}}),Object.defineProperty(t,"MaxKey",{enumerable:!0,get:function(){return Rt.MaxKey}}),Object.defineProperty(t,"MinKey",{enumerable:!0,get:function(){return Ut.MinKey}}),Object.defineProperty(t,"ObjectId",{enumerable:!0,get:function(){return St.ObjectId}}),Object.defineProperty(t,"ObjectID",{enumerable:!0,get:function(){return St.ObjectId}}),Object.defineProperty(t,"BSONRegExp",{enumerable:!0,get:function(){return Ot.BSONRegExp}}),Object.defineProperty(t,"BSONSymbol",{enumerable:!0,get:function(){return Mt.BSONSymbol}}),Object.defineProperty(t,"Timestamp",{enumerable:!0,get:function(){return wt.Timestamp}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_BYTE_ARRAY}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_DEFAULT",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_DEFAULT}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_FUNCTION",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_FUNCTION}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_MD5",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_MD5}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_USER_DEFINED",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_USER_DEFINED}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_UUID}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID_NEW",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_UUID_NEW}}),Object.defineProperty(t,"BSON_DATA_ARRAY",{enumerable:!0,get:function(){return b.BSON_DATA_ARRAY}}),Object.defineProperty(t,"BSON_DATA_BINARY",{enumerable:!0,get:function(){return b.BSON_DATA_BINARY}}),Object.defineProperty(t,"BSON_DATA_BOOLEAN",{enumerable:!0,get:function(){return b.BSON_DATA_BOOLEAN}}),Object.defineProperty(t,"BSON_DATA_CODE",{enumerable:!0,get:function(){return b.BSON_DATA_CODE}}),Object.defineProperty(t,"BSON_DATA_CODE_W_SCOPE",{enumerable:!0,get:function(){return b.BSON_DATA_CODE_W_SCOPE}}),Object.defineProperty(t,"BSON_DATA_DATE",{enumerable:!0,get:function(){return b.BSON_DATA_DATE}}),Object.defineProperty(t,"BSON_DATA_DBPOINTER",{enumerable:!0,get:function(){return b.BSON_DATA_DBPOINTER}}),Object.defineProperty(t,"BSON_DATA_DECIMAL128",{enumerable:!0,get:function(){return b.BSON_DATA_DECIMAL128}}),Object.defineProperty(t,"BSON_DATA_INT",{enumerable:!0,get:function(){return b.BSON_DATA_INT}}),Object.defineProperty(t,"BSON_DATA_LONG",{enumerable:!0,get:function(){return b.BSON_DATA_LONG}}),Object.defineProperty(t,"BSON_DATA_MAX_KEY",{enumerable:!0,get:function(){return b.BSON_DATA_MAX_KEY}}),Object.defineProperty(t,"BSON_DATA_MIN_KEY",{enumerable:!0,get:function(){return b.BSON_DATA_MIN_KEY}}),Object.defineProperty(t,"BSON_DATA_NULL",{enumerable:!0,get:function(){return b.BSON_DATA_NULL}}),Object.defineProperty(t,"BSON_DATA_NUMBER",{enumerable:!0,get:function(){return b.BSON_DATA_NUMBER}}),Object.defineProperty(t,"BSON_DATA_OBJECT",{enumerable:!0,get:function(){return b.BSON_DATA_OBJECT}}),Object.defineProperty(t,"BSON_DATA_OID",{enumerable:!0,get:function(){return b.BSON_DATA_OID}}),Object.defineProperty(t,"BSON_DATA_REGEXP",{enumerable:!0,get:function(){return b.BSON_DATA_REGEXP}}),Object.defineProperty(t,"BSON_DATA_STRING",{enumerable:!0,get:function(){return b.BSON_DATA_STRING}}),Object.defineProperty(t,"BSON_DATA_SYMBOL",{enumerable:!0,get:function(){return b.BSON_DATA_SYMBOL}}),Object.defineProperty(t,"BSON_DATA_TIMESTAMP",{enumerable:!0,get:function(){return b.BSON_DATA_TIMESTAMP}}),Object.defineProperty(t,"BSON_DATA_UNDEFINED",{enumerable:!0,get:function(){return b.BSON_DATA_UNDEFINED}}),Object.defineProperty(t,"BSON_INT32_MAX",{enumerable:!0,get:function(){return b.BSON_INT32_MAX}}),Object.defineProperty(t,"BSON_INT32_MIN",{enumerable:!0,get:function(){return b.BSON_INT32_MIN}}),Object.defineProperty(t,"BSON_INT64_MAX",{enumerable:!0,get:function(){return b.BSON_INT64_MAX}}),Object.defineProperty(t,"BSON_INT64_MIN",{enumerable:!0,get:function(){return b.BSON_INT64_MIN}}),Object.defineProperty(t,"JS_INT_MAX",{enumerable:!0,get:function(){return b.JS_INT_MAX}}),Object.defineProperty(t,"JS_INT_MIN",{enumerable:!0,get:function(){return b.JS_INT_MIN}}),Object.defineProperty(t,"EJSON",{enumerable:!0,get:function(){return Ft.EJSON}});var h=wt;Object.defineProperty(t,"LongWithoutOverridesClass",{enumerable:!0,get:function(){return h.LongWithoutOverridesClass}});let d=1024*1024*17,l=C.Buffer.alloc(d);function f(g){l.length<g&&(l=C.Buffer.alloc(g))}t.setInternalBufferSize=f;function u(g,n={}){let w=typeof n.checkKeys=="boolean"?n.checkKeys:!1,U=typeof n.serializeFunctions=="boolean"?n.serializeFunctions:!1,p=typeof n.ignoreUndefined=="boolean"?n.ignoreUndefined:!0,F=typeof n.minInternalBufferSize=="number"?n.minInternalBufferSize:d;l.length<F&&(l=C.Buffer.alloc(F));let J=Zt.serializeInto(l,g,w,0,0,U,p,[]),R=C.Buffer.alloc(J);return l.copy(R,0,0,R.length),R}t.serialize=u;function m(g,n,w={}){let U=typeof w.checkKeys=="boolean"?w.checkKeys:!1,p=typeof w.serializeFunctions=="boolean"?w.serializeFunctions:!1,F=typeof w.ignoreUndefined=="boolean"?w.ignoreUndefined:!0,J=typeof w.index=="number"?w.index:0,R=Zt.serializeInto(l,g,U,0,0,p,F);return l.copy(n,J,0,R),J+R-1}t.serializeWithBufferAndIndex=m;function o(g,n={}){return xt.deserialize(Et.ensureBuffer(g),n)}t.deserialize=o;function c(g,n={}){n=n||{};let w=typeof n.serializeFunctions=="boolean"?n.serializeFunctions:!1,U=typeof n.ignoreUndefined=="boolean"?n.ignoreUndefined:!0;return Be.calculateObjectSize(g,w,U)}t.calculateObjectSize=c;function _(g,n,w,U,p,F){let J=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},F),R=Et.ensureBuffer(g),W=n;for(let Q=0;Q<w;Q++){let H=R[W]|R[W+1]<<8|R[W+2]<<16|R[W+3]<<24;J.index=W,U[p+Q]=xt.deserialize(R,J),W=W+H}return W}t.deserializeStream=_}),xn=st(V),Zn=V.deserializeStream,qn=V.calculateObjectSize,Ue=V.deserialize,Qn=V.serializeWithBufferAndIndex,Me=V.serialize,$n=V.setInternalBufferSize,ti=V.ObjectID,ei=V.Decimal128,ri=V.BSONRegExp,ni=V.MaxKey,ii=V.MinKey,oi=V.Int32,si=V.Double,fi=V.Timestamp,ai=V.Long,ui=V.ObjectId,li=V.Binary,ci=V.DBRef,hi=V.BSONSymbol,_i=V.Map,yi=V.Code,Bi=V.LongWithoutOverridesClass,pi=V.EJSON,Ni=V.JS_INT_MIN,gi=V.JS_INT_MAX,Ai=V.BSON_INT64_MIN,Si=V.BSON_INT64_MAX,Oi=V.BSON_INT32_MIN,mi=V.BSON_INT32_MAX,Ei=V.BSON_DATA_UNDEFINED,wi=V.BSON_DATA_TIMESTAMP,Ti=V.BSON_DATA_SYMBOL,bi=V.BSON_DATA_STRING,di=V.BSON_DATA_REGEXP,Ii=V.BSON_DATA_OID,Di=V.BSON_DATA_OBJECT,Ri=V.BSON_DATA_NUMBER,Ui=V.BSON_DATA_NULL,Mi=V.BSON_DATA_MIN_KEY,Pi=V.BSON_DATA_MAX_KEY,ji=V.BSON_DATA_LONG,Fi=V.BSON_DATA_INT,Yi=V.BSON_DATA_DECIMAL128,Li=V.BSON_DATA_DBPOINTER,vi=V.BSON_DATA_DATE,Ci=V.BSON_DATA_CODE_W_SCOPE,zi=V.BSON_DATA_CODE,Ji=V.BSON_DATA_BOOLEAN,Wi=V.BSON_DATA_BINARY,ki=V.BSON_DATA_ARRAY,Xi=V.BSON_BINARY_SUBTYPE_UUID_NEW,Ki=V.BSON_BINARY_SUBTYPE_UUID,Vi=V.BSON_BINARY_SUBTYPE_USER_DEFINED,Hi=V.BSON_BINARY_SUBTYPE_MD5,Gi=V.BSON_BINARY_SUBTYPE_FUNCTION,xi=V.BSON_BINARY_SUBTYPE_DEFAULT,Zi=V.BSON_BINARY_SUBTYPE_BYTE_ARRAY;function pe(B,t){return Ue(new Uint8Array(B),t)}var te={name:"BSON",id:"bson",module:"bson",extensions:["bson"],mimeTypes:["application/bson"],category:"json",binary:!0};var Or="4.4.0-alpha.16",ee={...te,dataType:null,batchType:null,name:"BSON",id:"bson",module:"bson",version:Or,extensions:["bson"],mimeTypes:["application/bson"],category:"json",binary:!0,parse:mr,parseSync:Er,options:{bson:{}}};async function mr(B,t){let h={...ee.options.bson,...t?.bson};return pe(B,h)}function Er(B,t){let h={...ee.options.bson,...t?.bson};return pe(B,h)}var je=B=>typeof SharedArrayBuffer<"u"&&B instanceof SharedArrayBuffer;function ge(B){if(B instanceof ArrayBuffer)return B;if(je(B))return Ne(B);let{buffer:t,byteOffset:h,byteLength:d}=B;return t instanceof ArrayBuffer&&h===0&&d===t.byteLength?t:Ne(t,h,d)}function Ne(B,t=0,h=B.byteLength-t){let d=new Uint8Array(B,t,h),l=new Uint8Array(d.length);return l.set(d),l.buffer}function Ae(B,t){let h=Me(B);return ge(h)}var wr="4.4.0-alpha.16",Fe={...te,name:"BSON",id:"bson",module:"bson",version:wr,extensions:["bson"],options:{bson:{}},async encode(B,t){return Ae(B,{})},encodeSync(B,t){return Ae(B,{})}};return Xe(Yt);})();
16
+ `)+" "+h[1]:h[0]+t+" "+B.join(", ")+" "+h[1]}function de(B){return Array.isArray(B)}function _e(B){return typeof B=="boolean"}function qt(B){return B===null}function _r(B){return B==null}function Ie(B){return typeof B=="number"}function Qt(B){return typeof B=="string"}function yr(B){return babelHelpers.typeof(B)==="symbol"}function gt(B){return B===void 0}function kt(B){return Pt(B)&&ye(B)==="[object RegExp]"}function Pt(B){return babelHelpers.typeof(B)==="object"&&B!==null}function le(B){return Pt(B)&&ye(B)==="[object Date]"}function Xt(B){return Pt(B)&&(ye(B)==="[object Error]"||B instanceof Error)}function Kt(B){return typeof B=="function"}function Br(B){return B===null||typeof B=="boolean"||typeof B=="number"||typeof B=="string"||babelHelpers.typeof(B)==="symbol"||typeof B>"u"}function pr(B){return Buffer.isBuffer(B)}function ye(B){return Object.prototype.toString.call(B)}function fe(B){return B<10?"0"+B.toString(10):B.toString(10)}var Nr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function gr(){var B=new Date,t=[fe(B.getHours()),fe(B.getMinutes()),fe(B.getSeconds())].join(":");return[B.getDate(),Nr[B.getMonth()],t].join(" ")}function Ar(){console.log("%s - %s",gr(),he.apply(null,arguments))}function De(B,t){if(!t||!Pt(t))return B;for(var h=Object.keys(t),d=h.length;d--;)B[h[d]]=t[h[d]];return B}function Re(B,t){return Object.prototype.hasOwnProperty.call(B,t)}var Sr={inherits:ir,_extend:De,log:Ar,isBuffer:pr,isPrimitive:Br,isFunction:Kt,isError:Xt,isDate:le,isObject:Pt,isRegExp:kt,isUndefined:gt,isSymbol:yr,isString:Qt,isNumber:Ie,isNullOrUndefined:_r,isNull:qt,isBoolean:_e,isArray:de,inspect:At,deprecate:be,format:he,debuglog:sr},rt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deprecate=t.isObjectLike=t.isDate=t.isBuffer=t.haveBuffer=t.isBigUInt64Array=t.isBigInt64Array=t.isUint8Array=t.randomBytes=t.normalizedFunctionString=void 0;function h(n){return n.toString().replace("function(","function (")}t.normalizedFunctionString=h;function d(n){let w=C.Buffer.alloc(n);for(let U=0;U<n;++U)w[U]=Math.floor(Math.random()*256);return w}if(t.randomBytes=d,typeof window<"u"&&window.crypto&&window.crypto.getRandomValues)t.randomBytes=n=>window.crypto.getRandomValues(C.Buffer.alloc(n));else{try{t.randomBytes=nr.randomBytes}catch{}t.randomBytes==null&&(t.randomBytes=d)}function l(n){return Object.prototype.toString.call(n)==="[object Uint8Array]"}t.isUint8Array=l;function f(n){return Object.prototype.toString.call(n)==="[object BigInt64Array]"}t.isBigInt64Array=f;function u(n){return Object.prototype.toString.call(n)==="[object BigUint64Array]"}t.isBigUInt64Array=u;function m(){return typeof Vt<"u"&&typeof Vt.Buffer<"u"}t.haveBuffer=m;function o(n){return m()&&C.Buffer.isBuffer(n)}t.isBuffer=o;function c(n){return _(n)&&Object.prototype.toString.call(n)==="[object Date]"}t.isDate=c;function _(n){return typeof n=="object"&&n!==null}t.isObjectLike=_;function g(n,w){if(typeof window>"u"||typeof self>"u")return Sr.deprecate(n,w);let U=!1;function p(...F){return U||(console.warn(w),U=!0),n.apply(this,...F)}return p}t.deprecate=g});st(rt);var Fr=rt.deprecate,Yr=rt.isObjectLike,Lr=rt.isDate,vr=rt.isBuffer,Cr=rt.haveBuffer,zr=rt.isBigUInt64Array,Jr=rt.isBigInt64Array,Wr=rt.isUint8Array,kr=rt.randomBytes,Xr=rt.normalizedFunctionString,pt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DBRef=t.isDBRefLike=void 0;function h(l){return rt.isObjectLike(l)&&l.$id!=null&&l.$ref!=null}t.isDBRefLike=h;class d{constructor(f,u,m,o){let c=f.split(".");c.length===2&&(m=c.shift(),f=c.shift()),this.collection=f,this.oid=u,this.db=m,this.fields=o||{}}get namespace(){return this.collection}set namespace(f){this.collection=f}toJSON(){let f=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(f.$db=this.db),f}toExtendedJSON(f){f=f||{};let u={$ref:this.collection,$id:this.oid};return f.legacy||(this.db&&(u.$db=this.db),u=Object.assign(u,this.fields)),u}static fromExtendedJSON(f){let u=Object.assign({},f);return delete u.$ref,delete u.$id,delete u.$db,new d(f.$ref,f.$id,f.$db,u)}}t.DBRef=d,Object.defineProperty(d.prototype,"_bsontype",{value:"DBRef"})});st(pt);var Kr=pt.DBRef,Vr=pt.isDBRefLike,K=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Long=void 0;let h;try{h=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{}let d=1<<16,l=1<<24,f=d*d,u=f*f,m=u/2,o={},c={};class _{constructor(n=0,w=0,U){this.comp=_.prototype.compare,this.div=_.prototype.divide,this.eq=_.prototype.equals,this.gt=_.prototype.greaterThan,this.gte=_.prototype.greaterThanOrEqual,this.ge=_.prototype.greaterThanOrEqual,this.lt=_.prototype.lessThan,this.lte=_.prototype.lessThanOrEqual,this.mod=_.prototype.modulo,this.rem=_.prototype.modulo,this.mul=_.prototype.multiply,this.neg=_.prototype.negate,this.neq=_.prototype.notEquals,this.ne=_.prototype.notEquals,this.shl=_.prototype.shiftLeft,this.shr=_.prototype.shiftRight,this.shr_u=_.prototype.shiftRightUnsigned,this.shru=_.prototype.shiftRightUnsigned,this.sub=_.prototype.subtract,this.eqz=_.prototype.isZero,this.le=_.prototype.lessThanOrEqual,this.low=n|0,this.high=w|0,this.unsigned=!!U,Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}static fromBits(n,w,U){return new _(n,w,U)}static fromInt(n,w){let U,p,F;return w?(n>>>=0,(F=0<=n&&n<256)&&(p=c[n],p)?p:(U=_.fromBits(n,(n|0)<0?-1:0,!0),F&&(c[n]=U),U)):(n|=0,(F=-128<=n&&n<128)&&(p=o[n],p)?p:(U=_.fromBits(n,n<0?-1:0,!1),F&&(o[n]=U),U))}static fromNumber(n,w){if(isNaN(n))return w?_.UZERO:_.ZERO;if(w){if(n<0)return _.UZERO;if(n>=u)return _.MAX_UNSIGNED_VALUE}else{if(n<=-m)return _.MIN_VALUE;if(n+1>=m)return _.MAX_VALUE}return n<0?_.fromNumber(-n,w).neg():_.fromBits(n%f|0,n/f|0,w)}static fromBigInt(n,w){return _.fromString(n.toString(),w)}static fromString(n,w,U){if(n.length===0)throw Error("empty string");if(n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return _.ZERO;if(typeof w=="number"?(U=w,w=!1):w=!!w,U=U||10,U<2||36<U)throw RangeError("radix");let p;if((p=n.indexOf("-"))>0)throw Error("interior hyphen");if(p===0)return _.fromString(n.substring(1),w,U).neg();let F=_.fromNumber(Math.pow(U,8)),J=_.ZERO;for(let R=0;R<n.length;R+=8){let W=Math.min(8,n.length-R),Q=parseInt(n.substring(R,R+W),U);if(W<8){let H=_.fromNumber(Math.pow(U,W));J=J.mul(H).add(_.fromNumber(Q))}else J=J.mul(F),J=J.add(_.fromNumber(Q))}return J.unsigned=w,J}static fromBytes(n,w,U){return U?_.fromBytesLE(n,w):_.fromBytesBE(n,w)}static fromBytesLE(n,w){return new _(n[0]|n[1]<<8|n[2]<<16|n[3]<<24,n[4]|n[5]<<8|n[6]<<16|n[7]<<24,w)}static fromBytesBE(n,w){return new _(n[4]<<24|n[5]<<16|n[6]<<8|n[7],n[0]<<24|n[1]<<16|n[2]<<8|n[3],w)}static isLong(n){return rt.isObjectLike(n)&&n.__isLong__===!0}static fromValue(n,w){return typeof n=="number"?_.fromNumber(n,w):typeof n=="string"?_.fromString(n,w):_.fromBits(n.low,n.high,typeof w=="boolean"?w:n.unsigned)}add(n){_.isLong(n)||(n=_.fromValue(n));let w=this.high>>>16,U=this.high&65535,p=this.low>>>16,F=this.low&65535,J=n.high>>>16,R=n.high&65535,W=n.low>>>16,Q=n.low&65535,H=0,M=0,G=0,z=0;return z+=F+Q,G+=z>>>16,z&=65535,G+=p+W,M+=G>>>16,G&=65535,M+=U+R,H+=M>>>16,M&=65535,H+=w+J,H&=65535,_.fromBits(G<<16|z,H<<16|M,this.unsigned)}and(n){return _.isLong(n)||(n=_.fromValue(n)),_.fromBits(this.low&n.low,this.high&n.high,this.unsigned)}compare(n){if(_.isLong(n)||(n=_.fromValue(n)),this.eq(n))return 0;let w=this.isNegative(),U=n.isNegative();return w&&!U?-1:!w&&U?1:this.unsigned?n.high>>>0>this.high>>>0||n.high===this.high&&n.low>>>0>this.low>>>0?-1:1:this.sub(n).isNegative()?-1:1}divide(n){if(_.isLong(n)||(n=_.fromValue(n)),n.isZero())throw Error("division by zero");if(h){if(!this.unsigned&&this.high===-2147483648&&n.low===-1&&n.high===-1)return this;let F=(this.unsigned?h.div_u:h.div_s)(this.low,this.high,n.low,n.high);return _.fromBits(F,h.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?_.UZERO:_.ZERO;let w,U,p;if(this.unsigned){if(n.unsigned||(n=n.toUnsigned()),n.gt(this))return _.UZERO;if(n.gt(this.shru(1)))return _.UONE;p=_.UZERO}else{if(this.eq(_.MIN_VALUE))return n.eq(_.ONE)||n.eq(_.NEG_ONE)?_.MIN_VALUE:n.eq(_.MIN_VALUE)?_.ONE:(w=this.shr(1).div(n).shl(1),w.eq(_.ZERO)?n.isNegative()?_.ONE:_.NEG_ONE:(U=this.sub(n.mul(w)),p=w.add(U.div(n)),p));if(n.eq(_.MIN_VALUE))return this.unsigned?_.UZERO:_.ZERO;if(this.isNegative())return n.isNegative()?this.neg().div(n.neg()):this.neg().div(n).neg();if(n.isNegative())return this.div(n.neg()).neg();p=_.ZERO}for(U=this;U.gte(n);){w=Math.max(1,Math.floor(U.toNumber()/n.toNumber()));let F=Math.ceil(Math.log(w)/Math.LN2),J=F<=48?1:Math.pow(2,F-48),R=_.fromNumber(w),W=R.mul(n);for(;W.isNegative()||W.gt(U);)w-=J,R=_.fromNumber(w,this.unsigned),W=R.mul(n);R.isZero()&&(R=_.ONE),p=p.add(R),U=U.sub(W)}return p}equals(n){return _.isLong(n)||(n=_.fromValue(n)),this.unsigned!==n.unsigned&&this.high>>>31===1&&n.high>>>31===1?!1:this.high===n.high&&this.low===n.low}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(_.MIN_VALUE)?64:this.neg().getNumBitsAbs();let n=this.high!==0?this.high:this.low,w;for(w=31;w>0&&!(n&1<<w);w--);return this.high!==0?w+33:w+1}greaterThan(n){return this.comp(n)>0}greaterThanOrEqual(n){return this.comp(n)>=0}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(n){return this.comp(n)<0}lessThanOrEqual(n){return this.comp(n)<=0}modulo(n){if(_.isLong(n)||(n=_.fromValue(n)),h){let w=(this.unsigned?h.rem_u:h.rem_s)(this.low,this.high,n.low,n.high);return _.fromBits(w,h.get_high(),this.unsigned)}return this.sub(this.div(n).mul(n))}multiply(n){if(this.isZero())return _.ZERO;if(_.isLong(n)||(n=_.fromValue(n)),h){let x=h.mul(this.low,this.high,n.low,n.high);return _.fromBits(x,h.get_high(),this.unsigned)}if(n.isZero())return _.ZERO;if(this.eq(_.MIN_VALUE))return n.isOdd()?_.MIN_VALUE:_.ZERO;if(n.eq(_.MIN_VALUE))return this.isOdd()?_.MIN_VALUE:_.ZERO;if(this.isNegative())return n.isNegative()?this.neg().mul(n.neg()):this.neg().mul(n).neg();if(n.isNegative())return this.mul(n.neg()).neg();if(this.lt(_.TWO_PWR_24)&&n.lt(_.TWO_PWR_24))return _.fromNumber(this.toNumber()*n.toNumber(),this.unsigned);let w=this.high>>>16,U=this.high&65535,p=this.low>>>16,F=this.low&65535,J=n.high>>>16,R=n.high&65535,W=n.low>>>16,Q=n.low&65535,H=0,M=0,G=0,z=0;return z+=F*Q,G+=z>>>16,z&=65535,G+=p*Q,M+=G>>>16,G&=65535,G+=F*W,M+=G>>>16,G&=65535,M+=U*Q,H+=M>>>16,M&=65535,M+=p*W,H+=M>>>16,M&=65535,M+=F*R,H+=M>>>16,M&=65535,H+=w*Q+U*W+p*R+F*J,H&=65535,_.fromBits(G<<16|z,H<<16|M,this.unsigned)}negate(){return!this.unsigned&&this.eq(_.MIN_VALUE)?_.MIN_VALUE:this.not().add(_.ONE)}not(){return _.fromBits(~this.low,~this.high,this.unsigned)}notEquals(n){return!this.equals(n)}or(n){return _.isLong(n)||(n=_.fromValue(n)),_.fromBits(this.low|n.low,this.high|n.high,this.unsigned)}shiftLeft(n){return _.isLong(n)&&(n=n.toInt()),(n&=63)===0?this:n<32?_.fromBits(this.low<<n,this.high<<n|this.low>>>32-n,this.unsigned):_.fromBits(0,this.low<<n-32,this.unsigned)}shiftRight(n){return _.isLong(n)&&(n=n.toInt()),(n&=63)===0?this:n<32?_.fromBits(this.low>>>n|this.high<<32-n,this.high>>n,this.unsigned):_.fromBits(this.high>>n-32,this.high>=0?0:-1,this.unsigned)}shiftRightUnsigned(n){if(_.isLong(n)&&(n=n.toInt()),n&=63,n===0)return this;{let w=this.high;if(n<32){let U=this.low;return _.fromBits(U>>>n|w<<32-n,w>>>n,this.unsigned)}else return n===32?_.fromBits(w,0,this.unsigned):_.fromBits(w>>>n-32,0,this.unsigned)}}subtract(n){return _.isLong(n)||(n=_.fromValue(n)),this.add(n.neg())}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(n){return n?this.toBytesLE():this.toBytesBE()}toBytesLE(){let n=this.high,w=this.low;return[w&255,w>>>8&255,w>>>16&255,w>>>24,n&255,n>>>8&255,n>>>16&255,n>>>24]}toBytesBE(){let n=this.high,w=this.low;return[n>>>24,n>>>16&255,n>>>8&255,n&255,w>>>24,w>>>16&255,w>>>8&255,w&255]}toSigned(){return this.unsigned?_.fromBits(this.low,this.high,!1):this}toString(n){if(n=n||10,n<2||36<n)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(_.MIN_VALUE)){let F=_.fromNumber(n),J=this.div(F),R=J.mul(F).sub(this);return J.toString(n)+R.toInt().toString(n)}else return"-"+this.neg().toString(n);let w=_.fromNumber(Math.pow(n,6),this.unsigned),U=this,p="";for(;;){let F=U.div(w),R=(U.sub(F.mul(w)).toInt()>>>0).toString(n);if(U=F,U.isZero())return R+p;for(;R.length<6;)R="0"+R;p=""+R+p}}toUnsigned(){return this.unsigned?this:_.fromBits(this.low,this.high,!0)}xor(n){return _.isLong(n)||(n=_.fromValue(n)),_.fromBits(this.low^n.low,this.high^n.high,this.unsigned)}toExtendedJSON(n){return n&&n.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(n,w){let U=_.fromString(n.$numberLong);return w&&w.relaxed?U.toNumber():U}}t.Long=_,_.TWO_PWR_24=_.fromInt(l),_.MAX_UNSIGNED_VALUE=_.fromBits(-1,-1,!0),_.ZERO=_.fromInt(0),_.UZERO=_.fromInt(0,!0),_.ONE=_.fromInt(1),_.UONE=_.fromInt(1,!0),_.NEG_ONE=_.fromInt(-1),_.MAX_VALUE=_.fromBits(-1,2147483647,!1),_.MIN_VALUE=_.fromBits(0,-2147483648,!1),Object.defineProperty(_.prototype,"__isLong__",{value:!0}),Object.defineProperty(_.prototype,"_bsontype",{value:"Long"})});st(K);var Hr=K.Long,Dt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Decimal128=void 0;let h=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,d=/^(\+|-)?(Infinity|inf)$/i,l=/^(\+|-)?NaN$/i,f=6111,u=-6176,m=6176,o=34,c=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),_=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),g=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),n=/^([-+])?(\d+)?$/,w=31,U=16383,p=30,F=31;function J(G){return!isNaN(parseInt(G,10))}function R(G){let z=K.Long.fromNumber(1e9),x=K.Long.fromNumber(0);if(!G.parts[0]&&!G.parts[1]&&!G.parts[2]&&!G.parts[3])return{quotient:G,rem:x};for(let s=0;s<=3;s++)x=x.shiftLeft(32),x=x.add(new K.Long(G.parts[s],0)),G.parts[s]=x.div(z).low,x=x.modulo(z);return{quotient:G,rem:x}}function W(G,z){if(!G&&!z)return{high:K.Long.fromNumber(0),low:K.Long.fromNumber(0)};let x=G.shiftRightUnsigned(32),s=new K.Long(G.getLowBits(),0),O=z.shiftRightUnsigned(32),A=new K.Long(z.getLowBits(),0),i=x.multiply(O),E=x.multiply(A),I=s.multiply(O),j=s.multiply(A);return i=i.add(E.shiftRightUnsigned(32)),E=new K.Long(E.getLowBits(),0).add(I).add(j.shiftRightUnsigned(32)),i=i.add(E.shiftRightUnsigned(32)),j=E.shiftLeft(32).add(new K.Long(j.getLowBits(),0)),{high:i,low:j}}function Q(G,z){let x=G.high>>>0,s=z.high>>>0;if(x<s)return!0;if(x===s){let O=G.low>>>0,A=z.low>>>0;if(O<A)return!0}return!1}function H(G,z){throw new TypeError(`"${G}" is not a valid Decimal128 string - ${z}`)}class M{constructor(z){this.bytes=z}static fromString(z){let x=!1,s=!1,O=!1,A=0,i=0,E=0,I=0,j=0,L=[0],N=0,$=0,v=0,T=0,D=0,Z=0,k=new K.Long(0,0),et=new K.Long(0,0),Bt=0,X=0;if(z.length>=7e3)throw new TypeError(""+z+" not a valid Decimal128 string");let lt=z.match(h),re=z.match(d),Lt=z.match(l);if(!lt&&!re&&!Lt||z.length===0)throw new TypeError(""+z+" not a valid Decimal128 string");if(lt){let nt=lt[2],a=lt[4],e=lt[5],r=lt[6];a&&r===void 0&&H(z,"missing exponent power"),a&&nt===void 0&&H(z,"missing exponent base"),a===void 0&&(e||r)&&H(z,"missing e before exponent")}if((z[X]==="+"||z[X]==="-")&&(x=z[X++]==="-"),!J(z[X])&&z[X]!=="."){if(z[X]==="i"||z[X]==="I")return new M(C.Buffer.from(x?_:g));if(z[X]==="N")return new M(C.Buffer.from(c))}for(;J(z[X])||z[X]===".";){if(z[X]==="."){s&&H(z,"contains multiple periods"),s=!0,X=X+1;continue}N<34&&(z[X]!=="0"||O)&&(O||(j=i),O=!0,L[$++]=parseInt(z[X],10),N=N+1),O&&(E=E+1),s&&(I=I+1),i=i+1,X=X+1}if(s&&!i)throw new TypeError(""+z+" not a valid Decimal128 string");if(z[X]==="e"||z[X]==="E"){let nt=z.substr(++X).match(n);if(!nt||!nt[2])return new M(C.Buffer.from(c));D=parseInt(nt[0],10),X=X+nt[0].length}if(z[X])return new M(C.Buffer.from(c));if(v=0,!N)v=0,T=0,L[0]=0,E=1,N=1,A=0;else if(T=N-1,A=E,A!==1)for(;z[j+A-1]==="0";)A=A-1;for(D<=I&&I-D>1<<14?D=u:D=D-I;D>f;){if(T=T+1,T-v>o){if(L.join("").match(/^0+$/)){D=f;break}H(z,"overflow")}D=D-1}for(;D<u||N<E;){if(T===0&&A<N){D=u,A=0;break}if(N<E?E=E-1:T=T-1,D<f)D=D+1;else{if(L.join("").match(/^0+$/)){D=f;break}H(z,"overflow")}}if(T-v+1<A){let nt=i;s&&(j=j+1,nt=nt+1),x&&(j=j+1,nt=nt+1);let a=parseInt(z[j+T+1],10),e=0;if(a>=5&&(e=1,a===5)){for(e=L[T]%2===1?1:0,Z=j+T+2;Z<nt;Z++)if(parseInt(z[Z],10)){e=1;break}}if(e){let r=T;for(;r>=0;r--)if(++L[r]>9&&(L[r]=0,r===0))if(D<f)D=D+1,L[r]=1;else return new M(C.Buffer.from(x?_:g))}}if(k=K.Long.fromNumber(0),et=K.Long.fromNumber(0),A===0)k=K.Long.fromNumber(0),et=K.Long.fromNumber(0);else if(T-v<17){let nt=v;for(et=K.Long.fromNumber(L[nt++]),k=new K.Long(0,0);nt<=T;nt++)et=et.multiply(K.Long.fromNumber(10)),et=et.add(K.Long.fromNumber(L[nt]))}else{let nt=v;for(k=K.Long.fromNumber(L[nt++]);nt<=T-17;nt++)k=k.multiply(K.Long.fromNumber(10)),k=k.add(K.Long.fromNumber(L[nt]));for(et=K.Long.fromNumber(L[nt++]);nt<=T;nt++)et=et.multiply(K.Long.fromNumber(10)),et=et.add(K.Long.fromNumber(L[nt]))}let ht=W(k,K.Long.fromString("100000000000000000"));ht.low=ht.low.add(et),Q(ht.low,et)&&(ht.high=ht.high.add(K.Long.fromNumber(1))),Bt=D+m;let q={low:K.Long.fromNumber(0),high:K.Long.fromNumber(0)};ht.high.shiftRightUnsigned(49).and(K.Long.fromNumber(1)).equals(K.Long.fromNumber(1))?(q.high=q.high.or(K.Long.fromNumber(3).shiftLeft(61)),q.high=q.high.or(K.Long.fromNumber(Bt).and(K.Long.fromNumber(16383).shiftLeft(47))),q.high=q.high.or(ht.high.and(K.Long.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(K.Long.fromNumber(Bt&16383).shiftLeft(49)),q.high=q.high.or(ht.high.and(K.Long.fromNumber(562949953421311)))),q.low=ht.low,x&&(q.high=q.high.or(K.Long.fromString("9223372036854775808")));let ut=C.Buffer.alloc(16);return X=0,ut[X++]=q.low.low&255,ut[X++]=q.low.low>>8&255,ut[X++]=q.low.low>>16&255,ut[X++]=q.low.low>>24&255,ut[X++]=q.low.high&255,ut[X++]=q.low.high>>8&255,ut[X++]=q.low.high>>16&255,ut[X++]=q.low.high>>24&255,ut[X++]=q.high.low&255,ut[X++]=q.high.low>>8&255,ut[X++]=q.high.low>>16&255,ut[X++]=q.high.low>>24&255,ut[X++]=q.high.high&255,ut[X++]=q.high.high>>8&255,ut[X++]=q.high.high>>16&255,ut[X++]=q.high.high>>24&255,new M(ut)}toString(){let z,x=0,s=new Array(36);for(let X=0;X<s.length;X++)s[X]=0;let O=0,A=!1,i,E={parts:[0,0,0,0]},I,j,L=[];O=0;let N=this.bytes,$=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24,v=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24,T=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24,D=N[O++]|N[O++]<<8|N[O++]<<16|N[O++]<<24;O=0,{low:new K.Long($,v),high:new K.Long(T,D)}.high.lessThan(K.Long.ZERO)&&L.push("-");let k=D>>26&w;if(k>>3===3){if(k===p)return L.join("")+"Infinity";if(k===F)return"NaN";z=D>>15&U,i=8+(D>>14&1)}else i=D>>14&7,z=D>>17&U;let et=z-m;if(E.parts[0]=(D&16383)+((i&15)<<14),E.parts[1]=T,E.parts[2]=v,E.parts[3]=$,E.parts[0]===0&&E.parts[1]===0&&E.parts[2]===0&&E.parts[3]===0)A=!0;else for(j=3;j>=0;j--){let X=0,lt=R(E);if(E=lt.quotient,X=lt.rem.low,!!X)for(I=8;I>=0;I--)s[j*9+I]=X%10,X=Math.floor(X/10)}if(A)x=1,s[O]=0;else for(x=36;!s[O];)x=x-1,O=O+1;let Bt=x-1+et;if(Bt>=34||Bt<=-7||et>0){if(x>34)return L.push(`${0}`),et>0?L.push("E+"+et):et<0&&L.push("E"+et),L.join("");L.push(`${s[O++]}`),x=x-1,x&&L.push(".");for(let X=0;X<x;X++)L.push(`${s[O++]}`);L.push("E"),Bt>0?L.push("+"+Bt):L.push(`${Bt}`)}else if(et>=0)for(let X=0;X<x;X++)L.push(`${s[O++]}`);else{let X=x+et;if(X>0)for(let lt=0;lt<X;lt++)L.push(`${s[O++]}`);else L.push("0");for(L.push(".");X++<0;)L.push("0");for(let lt=0;lt<x-Math.max(X-1,0);lt++)L.push(`${s[O++]}`)}return L.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(z){return M.fromString(z.$numberDecimal)}}t.Decimal128=M,Object.defineProperty(M.prototype,"_bsontype",{value:"Decimal128"})});st(Dt);var Gr=Dt.Decimal128,bt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Double=void 0;class h{constructor(l){l instanceof Number&&(l=l.valueOf()),this.value=+l}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(l){if(l&&(l.legacy||l.relaxed&&isFinite(this.value)))return this.value;if(Object.is(Math.sign(this.value),-0))return{$numberDouble:`-${this.value.toFixed(1)}`};let f;return Number.isInteger(this.value)?(f=this.value.toFixed(1),f.length>=13&&(f=this.value.toExponential(13).toUpperCase())):f=this.value.toString(),{$numberDouble:f}}static fromExtendedJSON(l,f){let u=parseFloat(l.$numberDouble);return f&&f.relaxed?u:new h(u)}}t.Double=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Double"})});st(bt);var xr=bt.Double,dt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Int32=void 0;class h{constructor(l){l instanceof Number&&(l=l.valueOf()),this.value=+l}valueOf(){return this.value}toJSON(){return this.value}toExtendedJSON(l){return l&&(l.relaxed||l.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(l,f){return f&&f.relaxed?parseInt(l.$numberInt,10):new h(l.$numberInt)}}t.Int32=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Int32"})});st(dt);var Zr=dt.Int32,$t=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Map=void 0;let h;t.Map=h;let d=function(u){return u&&u.Math==Math&&u};function l(){return d(typeof globalThis=="object"&&globalThis)||d(typeof window=="object"&&window)||d(typeof self=="object"&&self)||d(typeof Vt=="object"&&Vt)||Function("return this")()}let f=l();Object.prototype.hasOwnProperty.call(f,"Map")?t.Map=h=f.Map:t.Map=h=class{constructor(m=[]){this._keys=[],this._values={};for(let o=0;o<m.length;o++){if(m[o]==null)continue;let c=m[o],_=c[0],g=c[1];this._keys.push(_),this._values[_]={v:g,i:this._keys.length-1}}}clear(){this._keys=[],this._values={}}delete(m){let o=this._values[m];return o==null?!1:(delete this._values[m],this._keys.splice(o.i,1),!0)}entries(){let m=0;return{next:()=>{let o=this._keys[m++];return{value:o!==void 0?[o,this._values[o].v]:void 0,done:o===void 0}}}}forEach(m,o){o=o||this;for(let c=0;c<this._keys.length;c++){let _=this._keys[c];m.call(o,this._values[_].v,_,o)}}get(m){return this._values[m]?this._values[m].v:void 0}has(m){return this._values[m]!=null}keys(){let m=0;return{next:()=>{let o=this._keys[m++];return{value:o!==void 0?o:void 0,done:o===void 0}}}}set(m,o){return this._values[m]?(this._values[m].v=o,this):(this._keys.push(m),this._values[m]={v:o,i:this._keys.length-1},this)}values(){let m=0;return{next:()=>{let o=this._keys[m++];return{value:o!==void 0?this._values[o].v:void 0,done:o===void 0}}}}get size(){return this._keys.length}}});st($t);var Qr=$t.Map,Rt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MaxKey=void 0;class h{toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new h}}t.MaxKey=h,Object.defineProperty(h.prototype,"_bsontype",{value:"MaxKey"})});st(Rt);var $r=Rt.MaxKey,Ut=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MinKey=void 0;class h{toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new h}}t.MinKey=h,Object.defineProperty(h.prototype,"_bsontype",{value:"MinKey"})});st(Ut);var tn=Ut.MinKey,St=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectId=void 0;let h=rt.randomBytes(5),d=new RegExp("^[0-9a-fA-F]{24}$"),l=[];for(let _=0;_<256;_++)l[_]=(_<=15?"0":"")+_.toString(16);let f=[],u=0;for(;u<10;)f[48+u]=u++;for(;u<16;)f[65-10+u]=f[97-10+u]=u++;let m=Symbol("id");class o{constructor(g){if(g instanceof o&&(this[m]=g.id,this.__id=g.__id),typeof g=="object"&&g&&"id"in g&&("toHexString"in g&&typeof g.toHexString=="function"?this[m]=C.Buffer.from(g.toHexString(),"hex"):this[m]=typeof g.id=="string"?C.Buffer.from(g.id):g.id),(g==null||typeof g=="number")&&(this[m]=o.generate(typeof g=="number"?g:void 0),o.cacheHexString&&(this.__id=this.id.toString("hex"))),ArrayBuffer.isView(g)&&g.byteLength===12&&(this[m]=Et.ensureBuffer(g)),typeof g=="string")if(g.length===12){let n=C.Buffer.from(g);n.byteLength===12&&(this[m]=n)}else if(g.length===24&&d.test(g))this[m]=C.Buffer.from(g,"hex");else throw new TypeError("Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters");o.cacheHexString&&(this.__id=this.id.toString("hex"))}get id(){return this[m]}set id(g){this[m]=g,o.cacheHexString&&(this.__id=g.toString("hex"))}get generationTime(){return this.id.readInt32BE(0)}set generationTime(g){this.id.writeUInt32BE(g,0)}toHexString(){if(o.cacheHexString&&this.__id)return this.__id;let g=this.id.toString("hex");return o.cacheHexString&&!this.__id&&(this.__id=g),g}static getInc(){return o.index=(o.index+1)%16777215}static generate(g){typeof g!="number"&&(g=~~(Date.now()/1e3));let n=o.getInc(),w=C.Buffer.alloc(12);return w.writeUInt32BE(g,0),w[4]=h[0],w[5]=h[1],w[6]=h[2],w[7]=h[3],w[8]=h[4],w[11]=n&255,w[10]=n>>8&255,w[9]=n>>16&255,w}toString(g){return g?this.id.toString(g):this.toHexString()}toJSON(){return this.toHexString()}equals(g){return g==null?!1:g instanceof o?this.toString()===g.toString():typeof g=="string"&&o.isValid(g)&&g.length===12&&this.id instanceof C.Buffer?g===this.id.toString("binary"):typeof g=="string"&&o.isValid(g)&&g.length===24?g.toLowerCase()===this.toHexString():typeof g=="string"&&o.isValid(g)&&g.length===12?C.Buffer.from(g).equals(this.id):typeof g=="object"&&"toHexString"in g&&typeof g.toHexString=="function"?g.toHexString()===this.toHexString():!1}getTimestamp(){let g=new Date,n=this.id.readUInt32BE(0);return g.setTime(Math.floor(n)*1e3),g}static createPk(){return new o}static createFromTime(g){let n=C.Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(g,0),new o(n)}static createFromHexString(g){if(typeof g>"u"||g!=null&&g.length!==24)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new o(C.Buffer.from(g,"hex"))}static isValid(g){return g==null?!1:typeof g=="number"?!0:typeof g=="string"?g.length===12||g.length===24&&d.test(g):g instanceof o||g instanceof C.Buffer&&g.length===12?!0:typeof g=="object"&&"toHexString"in g&&typeof g.toHexString=="function"?typeof g.id=="string"?g.id.length===12:g.toHexString().length===24&&d.test(g.id.toString("hex")):!1}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(g){return new o(g.$oid)}}t.ObjectId=o,o.index=~~(Math.random()*16777215),Object.defineProperty(o.prototype,"generate",{value:rt.deprecate(_=>o.generate(_),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(o.prototype,"getInc",{value:rt.deprecate(()=>o.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(o.prototype,"get_inc",{value:rt.deprecate(()=>o.getInc(),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(o,"get_inc",{value:rt.deprecate(()=>o.getInc(),"Please use the static `ObjectId.getInc()` instead")});let c=Symbol.for("nodejs.util.inspect.custom");Object.defineProperty(o.prototype,c,o.prototype.toString),Object.defineProperty(o.prototype,"inspect",o.prototype.toString),Object.defineProperty(o.prototype,"_bsontype",{value:"ObjectID"})});st(St);var en=St.ObjectId,b=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_DATA_MAX_KEY=t.BSON_DATA_MIN_KEY=t.BSON_DATA_DECIMAL128=t.BSON_DATA_LONG=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_INT=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_SYMBOL=t.BSON_DATA_CODE=t.BSON_DATA_DBPOINTER=t.BSON_DATA_REGEXP=t.BSON_DATA_NULL=t.BSON_DATA_DATE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_OID=t.BSON_DATA_UNDEFINED=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_DATA_OBJECT=t.BSON_DATA_STRING=t.BSON_DATA_NUMBER=t.JS_INT_MIN=t.JS_INT_MAX=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=void 0,t.BSON_INT32_MAX=2147483647,t.BSON_INT32_MIN=-2147483648,t.BSON_INT64_MAX=Math.pow(2,63)-1,t.BSON_INT64_MIN=-Math.pow(2,63),t.JS_INT_MAX=Math.pow(2,53),t.JS_INT_MIN=-Math.pow(2,53),t.BSON_DATA_NUMBER=1,t.BSON_DATA_STRING=2,t.BSON_DATA_OBJECT=3,t.BSON_DATA_ARRAY=4,t.BSON_DATA_BINARY=5,t.BSON_DATA_UNDEFINED=6,t.BSON_DATA_OID=7,t.BSON_DATA_BOOLEAN=8,t.BSON_DATA_DATE=9,t.BSON_DATA_NULL=10,t.BSON_DATA_REGEXP=11,t.BSON_DATA_DBPOINTER=12,t.BSON_DATA_CODE=13,t.BSON_DATA_SYMBOL=14,t.BSON_DATA_CODE_W_SCOPE=15,t.BSON_DATA_INT=16,t.BSON_DATA_TIMESTAMP=17,t.BSON_DATA_LONG=18,t.BSON_DATA_DECIMAL128=19,t.BSON_DATA_MIN_KEY=255,t.BSON_DATA_MAX_KEY=127,t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BSON_BINARY_SUBTYPE_FUNCTION=1,t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,t.BSON_BINARY_SUBTYPE_UUID=3,t.BSON_BINARY_SUBTYPE_UUID_NEW=4,t.BSON_BINARY_SUBTYPE_MD5=5,t.BSON_BINARY_SUBTYPE_USER_DEFINED=128});st(b);var rn=b.BSON_BINARY_SUBTYPE_USER_DEFINED,nn=b.BSON_BINARY_SUBTYPE_MD5,on=b.BSON_BINARY_SUBTYPE_UUID_NEW,sn=b.BSON_BINARY_SUBTYPE_UUID,fn=b.BSON_BINARY_SUBTYPE_BYTE_ARRAY,an=b.BSON_BINARY_SUBTYPE_FUNCTION,un=b.BSON_BINARY_SUBTYPE_DEFAULT,ln=b.BSON_DATA_MAX_KEY,cn=b.BSON_DATA_MIN_KEY,hn=b.BSON_DATA_DECIMAL128,_n=b.BSON_DATA_LONG,yn=b.BSON_DATA_TIMESTAMP,Bn=b.BSON_DATA_INT,pn=b.BSON_DATA_CODE_W_SCOPE,Nn=b.BSON_DATA_SYMBOL,gn=b.BSON_DATA_CODE,An=b.BSON_DATA_DBPOINTER,Sn=b.BSON_DATA_REGEXP,On=b.BSON_DATA_NULL,mn=b.BSON_DATA_DATE,En=b.BSON_DATA_BOOLEAN,wn=b.BSON_DATA_OID,Tn=b.BSON_DATA_UNDEFINED,bn=b.BSON_DATA_BINARY,dn=b.BSON_DATA_ARRAY,In=b.BSON_DATA_OBJECT,Dn=b.BSON_DATA_STRING,Rn=b.BSON_DATA_NUMBER,Un=b.JS_INT_MIN,Mn=b.JS_INT_MAX,Pn=b.BSON_INT64_MIN,jn=b.BSON_INT64_MAX,Fn=b.BSON_INT32_MIN,Yn=b.BSON_INT32_MAX,Be=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.calculateObjectSize=void 0;function h(l,f,u){let m=5;if(Array.isArray(l))for(let o=0;o<l.length;o++)m+=d(o.toString(),l[o],f,!0,u);else{l.toBSON&&(l=l.toBSON());for(let o in l)m+=d(o,l[o],f,!1,u)}return m}t.calculateObjectSize=h;function d(l,f,u=!1,m=!1,o=!1){switch(f&&f.toBSON&&(f=f.toBSON()),typeof f){case"string":return 1+C.Buffer.byteLength(l,"utf8")+1+4+C.Buffer.byteLength(f,"utf8")+1;case"number":return Math.floor(f)===f&&f>=b.JS_INT_MIN&&f<=b.JS_INT_MAX&&f>=b.BSON_INT32_MIN&&f<=b.BSON_INT32_MAX?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(4+1):(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(8+1);case"undefined":return m||!o?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1:0;case"boolean":return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(1+1);case"object":if(f==null||f._bsontype==="MinKey"||f._bsontype==="MaxKey")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1;if(f._bsontype==="ObjectId"||f._bsontype==="ObjectID")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(12+1);if(f instanceof Date||rt.isDate(f))return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(8+1);if(ArrayBuffer.isView(f)||f instanceof ArrayBuffer)return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(1+4+1)+f.byteLength;if(f._bsontype==="Long"||f._bsontype==="Double"||f._bsontype==="Timestamp")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(8+1);if(f._bsontype==="Decimal128")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(16+1);if(f._bsontype==="Code")return f.scope!=null&&Object.keys(f.scope).length>0?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+4+C.Buffer.byteLength(f.code.toString(),"utf8")+1+h(f.scope,u,o):(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+C.Buffer.byteLength(f.code.toString(),"utf8")+1;if(f._bsontype==="Binary")return f.sub_type===_t.Binary.SUBTYPE_BYTE_ARRAY?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(f.position+1+4+1+4):(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+(f.position+1+4+1);if(f._bsontype==="Symbol")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+C.Buffer.byteLength(f.value,"utf8")+4+1+1;if(f._bsontype==="DBRef"){let c=Object.assign({$ref:f.collection,$id:f.oid},f.fields);return f.db!=null&&(c.$db=f.db),(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+h(c,u,o)}else return f instanceof RegExp||Object.prototype.toString.call(f)==="[object RegExp]"?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+C.Buffer.byteLength(f.source,"utf8")+1+(f.global?1:0)+(f.ignoreCase?1:0)+(f.multiline?1:0)+1:f._bsontype==="BSONRegExp"?(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+C.Buffer.byteLength(f.pattern,"utf8")+1+C.Buffer.byteLength(f.options,"utf8")+1:(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+h(f,u,o)+1;case"function":if(f instanceof RegExp||Object.prototype.toString.call(f)==="[object RegExp]"||String.call(f)==="[object RegExp]")return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+C.Buffer.byteLength(f.source,"utf8")+1+(f.global?1:0)+(f.ignoreCase?1:0)+(f.multiline?1:0)+1;if(u&&f.scope!=null&&Object.keys(f.scope).length>0)return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+4+C.Buffer.byteLength(rt.normalizedFunctionString(f),"utf8")+1+h(f.scope,u,o);if(u)return(l!=null?C.Buffer.byteLength(l,"utf8")+1:0)+1+4+C.Buffer.byteLength(rt.normalizedFunctionString(f),"utf8")+1}return 0}});st(Be);var Ln=Be.calculateObjectSize,Ot=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONRegExp=void 0;function h(l){return l.split("").sort().join("")}class d{constructor(f,u){this.pattern=f,this.options=u??"",h(this.options);for(let m=0;m<this.options.length;m++)if(!(this.options[m]==="i"||this.options[m]==="m"||this.options[m]==="x"||this.options[m]==="l"||this.options[m]==="s"||this.options[m]==="u"))throw new Error(`The regular expression option [${this.options[m]}] is not supported`)}static parseOptions(f){return f?f.split("").sort().join(""):""}toExtendedJSON(f){return f=f||{},f.legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(f){if("$regex"in f)if(typeof f.$regex!="string"){if(f.$regex._bsontype==="BSONRegExp")return f}else return new d(f.$regex,d.parseOptions(f.$options));if("$regularExpression"in f)return new d(f.$regularExpression.pattern,d.parseOptions(f.$regularExpression.options));throw new TypeError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(f)}`)}}t.BSONRegExp=d,Object.defineProperty(d.prototype,"_bsontype",{value:"BSONRegExp"})});st(Ot);var vn=Ot.BSONRegExp,Mt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BSONSymbol=void 0;class h{constructor(l){this.value=l}valueOf(){return this.value}toString(){return this.value}inspect(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(l){return new h(l.$symbol)}}t.BSONSymbol=h,Object.defineProperty(h.prototype,"_bsontype",{value:"Symbol"})});st(Mt);var Cn=Mt.BSONSymbol,wt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Timestamp=t.LongWithoutOverridesClass=void 0,t.LongWithoutOverridesClass=K.Long;class h extends t.LongWithoutOverridesClass{constructor(l,f){K.Long.isLong(l)?super(l.low,l.high,!0):super(l,f,!0),Object.defineProperty(this,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1})}toJSON(){return{$timestamp:this.toString()}}static fromInt(l){return new h(K.Long.fromInt(l,!0))}static fromNumber(l){return new h(K.Long.fromNumber(l,!0))}static fromBits(l,f){return new h(l,f)}static fromString(l,f){return new h(K.Long.fromString(l,!0,f))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(l){return new h(l.$timestamp.i,l.$timestamp.t)}}t.Timestamp=h,h.MAX_VALUE=K.Long.MAX_UNSIGNED_VALUE});st(wt);var zn=wt.Timestamp,Jn=wt.LongWithoutOverridesClass,Gt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateUtf8=void 0;let h=128,d=192,l=224,f=240,u=248,m=192,o=224,c=240,_=128;function g(n,w,U){let p=0;for(let F=w;F<U;F+=1){let J=n[F];if(p){if((J&d)!==_)return!1;p-=1}else if(J&h)if((J&l)===m)p=1;else if((J&f)===o)p=2;else if((J&u)===c)p=3;else return!1}return!p}t.validateUtf8=g});st(Gt);var Wn=Gt.validateUtf8,xt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserialize=void 0;let h=K.Long.fromNumber(b.JS_INT_MAX),d=K.Long.fromNumber(b.JS_INT_MIN),l={};function f(o,c,_){c=c??{};let g=c&&c.index?c.index:0,n=o[g]|o[g+1]<<8|o[g+2]<<16|o[g+3]<<24;if(n<5)throw new Error(`bson size must be >= 5, is ${n}`);if(c.allowObjectSmallerThanBufferSize&&o.length<n)throw new Error(`buffer length ${o.length} must be >= bson size ${n}`);if(!c.allowObjectSmallerThanBufferSize&&o.length!==n)throw new Error(`buffer length ${o.length} must === bson size ${n}`);if(n+g>o.byteLength)throw new Error(`(bson size ${n} + options.index ${g} must be <= buffer length ${o.byteLength})`);if(o[g+n-1]!==0)throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return u(o,g,c,_)}t.deserialize=f;function u(o,c,_,g=!1){let n=_.evalFunctions==null?!1:_.evalFunctions,w=_.cacheFunctions==null?!1:_.cacheFunctions,U=_.fieldsAsRaw==null?null:_.fieldsAsRaw,p=_.raw==null?!1:_.raw,F=typeof _.bsonRegExp=="boolean"?_.bsonRegExp:!1,J=_.promoteBuffers==null?!1:_.promoteBuffers,R=_.promoteLongs==null?!0:_.promoteLongs,W=_.promoteValues==null?!0:_.promoteValues,Q=c;if(o.length<5)throw new Error("corrupt bson message < 5 bytes long");let H=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(H<5||H>o.length)throw new Error("corrupt bson message");let M=g?[]:{},G=0,z=!1;for(;!z;){let O=o[c++];if(O===0)break;let A=c;for(;o[A]!==0&&A<o.length;)A++;if(A>=o.byteLength)throw new Error("Bad BSON Document: illegal CString");let i=g?G++:o.toString("utf8",c,A);if(c=A+1,O===b.BSON_DATA_STRING){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");if(!Gt.validateUtf8(o,c,c+E-1))throw new Error("Invalid UTF-8 string in BSON document");let I=o.toString("utf8",c,c+E-1);M[i]=I,c=c+E}else if(O===b.BSON_DATA_OID){let E=C.Buffer.alloc(12);o.copy(E,0,c,c+12),M[i]=new St.ObjectId(E),c=c+12}else if(O===b.BSON_DATA_INT&&W===!1)M[i]=new dt.Int32(o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24);else if(O===b.BSON_DATA_INT)M[i]=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;else if(O===b.BSON_DATA_NUMBER&&W===!1)M[i]=new bt.Double(o.readDoubleLE(c)),c=c+8;else if(O===b.BSON_DATA_NUMBER)M[i]=o.readDoubleLE(c),c=c+8;else if(O===b.BSON_DATA_DATE){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;M[i]=new Date(new K.Long(E,I).toNumber())}else if(O===b.BSON_DATA_BOOLEAN){if(o[c]!==0&&o[c]!==1)throw new Error("illegal boolean type value");M[i]=o[c++]===1}else if(O===b.BSON_DATA_OBJECT){let E=c,I=o[c]|o[c+1]<<8|o[c+2]<<16|o[c+3]<<24;if(I<=0||I>o.length-c)throw new Error("bad embedded document length in bson");p?M[i]=o.slice(c,c+I):M[i]=u(o,E,_,!1),c=c+I}else if(O===b.BSON_DATA_ARRAY){let E=c,I=o[c]|o[c+1]<<8|o[c+2]<<16|o[c+3]<<24,j=_,L=c+I;if(U&&U[i]){j={};for(let N in _)j[N]=_[N];j.raw=!0}if(M[i]=u(o,E,j,!0),c=c+I,o[c-1]!==0)throw new Error("invalid array terminator byte");if(c!==L)throw new Error("corrupted array bson")}else if(O===b.BSON_DATA_UNDEFINED)M[i]=void 0;else if(O===b.BSON_DATA_NULL)M[i]=null;else if(O===b.BSON_DATA_LONG){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,j=new K.Long(E,I);R&&W===!0?M[i]=j.lessThanOrEqual(h)&&j.greaterThanOrEqual(d)?j.toNumber():j:M[i]=j}else if(O===b.BSON_DATA_DECIMAL128){let E=C.Buffer.alloc(16);o.copy(E,0,c,c+16),c=c+16;let I=new Dt.Decimal128(E);"toObject"in I&&typeof I.toObject=="function"?M[i]=I.toObject():M[i]=I}else if(O===b.BSON_DATA_BINARY){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=E,j=o[c++];if(E<0)throw new Error("Negative binary type element size found");if(E>o.byteLength)throw new Error("Binary type size larger than document size");if(o.slice!=null){if(j===_t.Binary.SUBTYPE_BYTE_ARRAY){if(E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,E<0)throw new Error("Negative binary type element size found for subtype 0x02");if(E>I-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(E<I-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}J&&W?M[i]=o.slice(c,c+E):M[i]=new _t.Binary(o.slice(c,c+E),j)}else{let L=C.Buffer.alloc(E);if(j===_t.Binary.SUBTYPE_BYTE_ARRAY){if(E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,E<0)throw new Error("Negative binary type element size found for subtype 0x02");if(E>I-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(E<I-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(A=0;A<E;A++)L[A]=o[c+A];J&&W?M[i]=L:M[i]=new _t.Binary(L,j)}c=c+E}else if(O===b.BSON_DATA_REGEXP&&F===!1){for(A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let E=o.toString("utf8",c,A);for(c=A+1,A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let I=o.toString("utf8",c,A);c=A+1;let j=new Array(I.length);for(A=0;A<I.length;A++)switch(I[A]){case"m":j[A]="m";break;case"s":j[A]="g";break;case"i":j[A]="i";break}M[i]=new RegExp(E,j.join(""))}else if(O===b.BSON_DATA_REGEXP&&F===!0){for(A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let E=o.toString("utf8",c,A);for(c=A+1,A=c;o[A]!==0&&A<o.length;)A++;if(A>=o.length)throw new Error("Bad BSON Document: illegal CString");let I=o.toString("utf8",c,A);c=A+1,M[i]=new Ot.BSONRegExp(E,I)}else if(O===b.BSON_DATA_SYMBOL){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");let I=o.toString("utf8",c,c+E-1);M[i]=W?I:new Mt.BSONSymbol(I),c=c+E}else if(O===b.BSON_DATA_TIMESTAMP){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24,I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;M[i]=new wt.Timestamp(E,I)}else if(O===b.BSON_DATA_MIN_KEY)M[i]=new Ut.MinKey;else if(O===b.BSON_DATA_MAX_KEY)M[i]=new Rt.MaxKey;else if(O===b.BSON_DATA_CODE){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");let I=o.toString("utf8",c,c+E-1);n?w?M[i]=m(I,l,M):M[i]=m(I):M[i]=new mt.Code(I),c=c+E}else if(O===b.BSON_DATA_CODE_W_SCOPE){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<4+4+4+1)throw new Error("code_w_scope total size shorter minimum expected length");let I=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(I<=0||I>o.length-c||o[c+I-1]!==0)throw new Error("bad string length in bson");let j=o.toString("utf8",c,c+I-1);c=c+I;let L=c,N=o[c]|o[c+1]<<8|o[c+2]<<16|o[c+3]<<24,$=u(o,L,_,!1);if(c=c+N,E<4+4+N+I)throw new Error("code_w_scope total size is too short, truncating scope");if(E>4+4+N+I)throw new Error("code_w_scope total size is too long, clips outer document");n?(w?M[i]=m(j,l,M):M[i]=m(j),M[i].scope=$):M[i]=new mt.Code(j,$)}else if(O===b.BSON_DATA_DBPOINTER){let E=o[c++]|o[c++]<<8|o[c++]<<16|o[c++]<<24;if(E<=0||E>o.length-c||o[c+E-1]!==0)throw new Error("bad string length in bson");if(!Gt.validateUtf8(o,c,c+E-1))throw new Error("Invalid UTF-8 string in BSON document");let I=o.toString("utf8",c,c+E-1);c=c+E;let j=C.Buffer.alloc(12);o.copy(j,0,c,c+12);let L=new St.ObjectId(j);c=c+12,M[i]=new pt.DBRef(I,L)}else throw new Error("Detected unknown BSON type "+O.toString(16)+' for fieldname "'+i+'"')}if(H!==c-Q)throw g?new Error("corrupt array bson"):new Error("corrupt object bson");let x=Object.keys(M).filter(O=>O.startsWith("$")),s=!0;if(x.forEach(O=>{["$ref","$id","$db"].indexOf(O)===-1&&(s=!1)}),!s)return M;if(pt.isDBRefLike(M)){let O=Object.assign({},M);return delete O.$ref,delete O.$id,delete O.$db,new pt.DBRef(M.$ref,M.$id,M.$db,O)}return M}function m(o,c,_){return c?(c[o]==null&&(c[o]=new Function(o)),c[o].bind(_)):new Function(o)}});st(xt);var kn=xt.deserialize,Ft=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.EJSON=t.isBSONType=void 0;function h(p){return rt.isObjectLike(p)&&Reflect.has(p,"_bsontype")&&typeof p._bsontype=="string"}t.isBSONType=h;let d=2147483647,l=-2147483648,f=9223372036854776e3,u=-9223372036854776e3,m={$oid:St.ObjectId,$binary:_t.Binary,$uuid:_t.Binary,$symbol:Mt.BSONSymbol,$numberInt:dt.Int32,$numberDecimal:Dt.Decimal128,$numberDouble:bt.Double,$numberLong:K.Long,$minKey:Ut.MinKey,$maxKey:Rt.MaxKey,$regex:Ot.BSONRegExp,$regularExpression:Ot.BSONRegExp,$timestamp:wt.Timestamp};function o(p,F={}){if(typeof p=="number"){if(F.relaxed||F.legacy)return p;if(Math.floor(p)===p){if(p>=l&&p<=d)return new dt.Int32(p);if(p>=u&&p<=f)return K.Long.fromNumber(p)}return new bt.Double(p)}if(p==null||typeof p!="object")return p;if(p.$undefined)return null;let J=Object.keys(p).filter(R=>R.startsWith("$")&&p[R]!=null);for(let R=0;R<J.length;R++){let W=m[J[R]];if(W)return W.fromExtendedJSON(p,F)}if(p.$date!=null){let R=p.$date,W=new Date;return F.legacy?typeof R=="number"?W.setTime(R):typeof R=="string"&&W.setTime(Date.parse(R)):typeof R=="string"?W.setTime(Date.parse(R)):K.Long.isLong(R)?W.setTime(R.toNumber()):typeof R=="number"&&F.relaxed&&W.setTime(R),W}if(p.$code!=null){let R=Object.assign({},p);return p.$scope&&(R.$scope=o(p.$scope)),mt.Code.fromExtendedJSON(p)}if(p.$ref!=null||p.$dbPointer!=null){let R=p.$ref?p:p.$dbPointer;if(R instanceof pt.DBRef)return R;let W=Object.keys(R).filter(H=>H.startsWith("$")),Q=!0;if(W.forEach(H=>{["$ref","$id","$db"].indexOf(H)===-1&&(Q=!1)}),Q)return pt.DBRef.fromExtendedJSON(R)}return p}function c(p,F){return p.map(J=>g(J,F))}function _(p){let F=p.toISOString();return p.getUTCMilliseconds()!==0?F:F.slice(0,-5)+"Z"}function g(p,F){if(Array.isArray(p))return c(p,F);if(p===void 0)return null;if(p instanceof Date){let J=p.getTime(),R=J>-1&&J<2534023188e5;return F.legacy?F.relaxed&&R?{$date:p.getTime()}:{$date:_(p)}:F.relaxed&&R?{$date:_(p)}:{$date:{$numberLong:p.getTime().toString()}}}if(typeof p=="number"&&!F.relaxed){if(Math.floor(p)===p){let J=p>=l&&p<=d,R=p>=u&&p<=f;if(J)return{$numberInt:p.toString()};if(R)return{$numberLong:p.toString()}}return{$numberDouble:p.toString()}}if(p instanceof RegExp){let J=p.flags;if(J===void 0){let W=p.toString().match(/[gimuy]*$/);W&&(J=W[0])}return new Ot.BSONRegExp(p.source,J).toExtendedJSON(F)}return p!=null&&typeof p=="object"?w(p,F):p}let n={Binary:p=>new _t.Binary(p.value(),p.sub_type),Code:p=>new mt.Code(p.code,p.scope),DBRef:p=>new pt.DBRef(p.collection||p.namespace,p.oid,p.db,p.fields),Decimal128:p=>new Dt.Decimal128(p.bytes),Double:p=>new bt.Double(p.value),Int32:p=>new dt.Int32(p.value),Long:p=>K.Long.fromBits(p.low!=null?p.low:p.low_,p.low!=null?p.high:p.high_,p.low!=null?p.unsigned:p.unsigned_),MaxKey:()=>new Rt.MaxKey,MinKey:()=>new Ut.MinKey,ObjectID:p=>new St.ObjectId(p),ObjectId:p=>new St.ObjectId(p),BSONRegExp:p=>new Ot.BSONRegExp(p.pattern,p.options),Symbol:p=>new Mt.BSONSymbol(p.value),Timestamp:p=>wt.Timestamp.fromBits(p.low,p.high)};function w(p,F){if(p==null||typeof p!="object")throw new Error("not an object instance");let J=p._bsontype;if(typeof J>"u"){let R={};for(let W in p)R[W]=g(p[W],F);return R}else if(h(p)){let R=p;if(typeof R.toExtendedJSON!="function"){let W=n[p._bsontype];if(!W)throw new TypeError("Unrecognized or invalid _bsontype: "+p._bsontype);R=W(R)}return J==="Code"&&R.scope?R=new mt.Code(R.code,g(R.scope,F)):J==="DBRef"&&R.oid&&(R=new pt.DBRef(R.collection,g(R.oid,F),R.db,R.fields)),R.toExtendedJSON(F)}else throw new Error("_bsontype must be a string, but was: "+typeof J)}var U;(function(p){function F(Q,H){let M=Object.assign({},{relaxed:!0,legacy:!1},H);return typeof M.relaxed=="boolean"&&(M.strict=!M.relaxed),typeof M.strict=="boolean"&&(M.relaxed=!M.strict),JSON.parse(Q,(G,z)=>o(z,M))}p.parse=F;function J(Q,H,M,G){M!=null&&typeof M=="object"&&(G=M,M=0),H!=null&&typeof H=="object"&&!Array.isArray(H)&&(G=H,H=void 0,M=0),G=Object.assign({},{relaxed:!0,legacy:!1},G);let z=g(Q,G);return JSON.stringify(z,H,M)}p.stringify=J;function R(Q,H){return H=H||{},JSON.parse(J(Q,H))}p.serialize=R;function W(Q,H){return H=H||{},F(JSON.stringify(Q),H)}p.deserialize=W})(U=t.EJSON||(t.EJSON={}))});st(Ft);var Xn=Ft.EJSON,Kn=Ft.isBSONType,jt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.writeIEEE754=t.readIEEE754=void 0;function h(l,f,u,m,o){let c,_,g=u==="big",n=o*8-m-1,w=(1<<n)-1,U=w>>1,p=-7,F=g?0:o-1,J=g?1:-1,R=l[f+F];for(F+=J,c=R&(1<<-p)-1,R>>=-p,p+=n;p>0;c=c*256+l[f+F],F+=J,p-=8);for(_=c&(1<<-p)-1,c>>=-p,p+=m;p>0;_=_*256+l[f+F],F+=J,p-=8);if(c===0)c=1-U;else{if(c===w)return _?NaN:(R?-1:1)*(1/0);_=_+Math.pow(2,m),c=c-U}return(R?-1:1)*_*Math.pow(2,c-m)}t.readIEEE754=h;function d(l,f,u,m,o,c){let _,g,n,w=m==="big",U=c*8-o-1,p=(1<<U)-1,F=p>>1,J=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=w?c-1:0,W=w?-1:1,Q=f<0||f===0&&1/f<0?1:0;for(f=Math.abs(f),isNaN(f)||f===1/0?(g=isNaN(f)?1:0,_=p):(_=Math.floor(Math.log(f)/Math.LN2),f*(n=Math.pow(2,-_))<1&&(_--,n*=2),_+F>=1?f+=J/n:f+=J*Math.pow(2,1-F),f*n>=2&&(_++,n/=2),_+F>=p?(g=0,_=p):_+F>=1?(g=(f*n-1)*Math.pow(2,o),_=_+F):(g=f*Math.pow(2,F-1)*Math.pow(2,o),_=0)),isNaN(f)&&(g=0);o>=8;)l[u+R]=g&255,R+=W,g/=256,o-=8;for(_=_<<o|g,isNaN(f)&&(_+=8),U+=o;U>0;)l[u+R]=_&255,R+=W,_/=256,U-=8;l[u+R-W]|=Q*128}t.writeIEEE754=d});st(jt);var Vn=jt.writeIEEE754,Hn=jt.readIEEE754,Zt=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeInto=void 0;let h=/\x00/,d=new Set(["$db","$ref","$id","$clusterTime"]);function l(s){return Object.prototype.toString.call(s)==="[object RegExp]"}function f(s,O,A,i,E){s[i++]=b.BSON_DATA_STRING;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I+1,s[i-1]=0;let j=s.write(A,i+4,void 0,"utf8");return s[i+3]=j+1>>24&255,s[i+2]=j+1>>16&255,s[i+1]=j+1>>8&255,s[i]=j+1&255,i=i+4+j,s[i++]=0,i}function u(s,O,A,i,E){if(Number.isInteger(A)&&A>=b.BSON_INT32_MIN&&A<=b.BSON_INT32_MAX){s[i++]=b.BSON_DATA_INT;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0,s[i++]=A&255,s[i++]=A>>8&255,s[i++]=A>>16&255,s[i++]=A>>24&255}else{s[i++]=b.BSON_DATA_NUMBER;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0,jt.writeIEEE754(s,A,i,"little",52,8),i=i+8}return i}function m(s,O,A,i,E){s[i++]=b.BSON_DATA_NULL;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,i}function o(s,O,A,i,E){s[i++]=b.BSON_DATA_BOOLEAN;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,s[i++]=A?1:0,i}function c(s,O,A,i,E){s[i++]=b.BSON_DATA_DATE;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=K.Long.fromNumber(A.getTime()),L=j.getLowBits(),N=j.getHighBits();return s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255,s[i++]=N&255,s[i++]=N>>8&255,s[i++]=N>>16&255,s[i++]=N>>24&255,i}function _(s,O,A,i,E){s[i++]=b.BSON_DATA_REGEXP;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");if(i=i+I,s[i++]=0,A.source&&A.source.match(h)!=null)throw Error("value "+A.source+" must not contain null bytes");return i=i+s.write(A.source,i,void 0,"utf8"),s[i++]=0,A.ignoreCase&&(s[i++]=105),A.global&&(s[i++]=115),A.multiline&&(s[i++]=109),s[i++]=0,i}function g(s,O,A,i,E){s[i++]=b.BSON_DATA_REGEXP;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");if(i=i+I,s[i++]=0,A.pattern.match(h)!=null)throw Error("pattern "+A.pattern+" must not contain null bytes");return i=i+s.write(A.pattern,i,void 0,"utf8"),s[i++]=0,i=i+s.write(A.options.split("").sort().join(""),i,void 0,"utf8"),s[i++]=0,i}function n(s,O,A,i,E){A===null?s[i++]=b.BSON_DATA_NULL:A._bsontype==="MinKey"?s[i++]=b.BSON_DATA_MIN_KEY:s[i++]=b.BSON_DATA_MAX_KEY;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,i}function w(s,O,A,i,E){s[i++]=b.BSON_DATA_OID;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");if(i=i+I,s[i++]=0,typeof A.id=="string")s.write(A.id,i,void 0,"binary");else if(A.id&&A.id.copy)A.id.copy(s,i,0,12);else throw new TypeError("object ["+JSON.stringify(A)+"] is not a valid ObjectId");return i+12}function U(s,O,A,i,E){s[i++]=b.BSON_DATA_BINARY;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=A.length;return s[i++]=j&255,s[i++]=j>>8&255,s[i++]=j>>16&255,s[i++]=j>>24&255,s[i++]=b.BSON_BINARY_SUBTYPE_DEFAULT,s.set(Et.ensureBuffer(A),i),i=i+j,i}function p(s,O,A,i,E=!1,I=0,j=!1,L=!0,N=!1,$=[]){for(let D=0;D<$.length;D++)if($[D]===A)throw new Error("cyclic dependency detected");$.push(A),s[i++]=Array.isArray(A)?b.BSON_DATA_ARRAY:b.BSON_DATA_OBJECT;let v=N?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+v,s[i++]=0;let T=x(s,A,E,i,I+1,j,L,$);return $.pop(),T}function F(s,O,A,i,E){s[i++]=b.BSON_DATA_DECIMAL128;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,A.bytes.copy(s,i,0,16),i+16}function J(s,O,A,i,E){s[i++]=A._bsontype==="Long"?b.BSON_DATA_LONG:b.BSON_DATA_TIMESTAMP;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=A.getLowBits(),L=A.getHighBits();return s[i++]=j&255,s[i++]=j>>8&255,s[i++]=j>>16&255,s[i++]=j>>24&255,s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255,i}function R(s,O,A,i,E){A=A.valueOf(),s[i++]=b.BSON_DATA_INT;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,s[i++]=A&255,s[i++]=A>>8&255,s[i++]=A>>16&255,s[i++]=A>>24&255,i}function W(s,O,A,i,E){s[i++]=b.BSON_DATA_NUMBER;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");return i=i+I,s[i++]=0,jt.writeIEEE754(s,A.value,i,"little",52,8),i=i+8,i}function Q(s,O,A,i,E=!1,I=0,j){s[i++]=b.BSON_DATA_CODE;let L=j?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+L,s[i++]=0;let N=rt.normalizedFunctionString(A),$=s.write(N,i+4,void 0,"utf8")+1;return s[i]=$&255,s[i+1]=$>>8&255,s[i+2]=$>>16&255,s[i+3]=$>>24&255,i=i+4+$-1,s[i++]=0,i}function H(s,O,A,i,E=!1,I=0,j=!1,L=!0,N=!1){if(A.scope&&typeof A.scope=="object"){s[i++]=b.BSON_DATA_CODE_W_SCOPE;let $=N?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+$,s[i++]=0;let v=i,T=typeof A.code=="string"?A.code:A.code.toString();i=i+4;let D=s.write(T,i+4,void 0,"utf8")+1;s[i]=D&255,s[i+1]=D>>8&255,s[i+2]=D>>16&255,s[i+3]=D>>24&255,s[i+4+D-1]=0,i=i+D+4;let Z=x(s,A.scope,E,i,I+1,j,L);i=Z-1;let k=Z-v;s[v++]=k&255,s[v++]=k>>8&255,s[v++]=k>>16&255,s[v++]=k>>24&255,s[i++]=0}else{s[i++]=b.BSON_DATA_CODE;let $=N?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+$,s[i++]=0;let v=A.code.toString(),T=s.write(v,i+4,void 0,"utf8")+1;s[i]=T&255,s[i+1]=T>>8&255,s[i+2]=T>>16&255,s[i+3]=T>>24&255,i=i+4+T-1,s[i++]=0}return i}function M(s,O,A,i,E){s[i++]=b.BSON_DATA_BINARY;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=A.value(!0),L=A.position;return A.sub_type===_t.Binary.SUBTYPE_BYTE_ARRAY&&(L=L+4),s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255,s[i++]=A.sub_type,A.sub_type===_t.Binary.SUBTYPE_BYTE_ARRAY&&(L=L-4,s[i++]=L&255,s[i++]=L>>8&255,s[i++]=L>>16&255,s[i++]=L>>24&255),s.set(j,i),i=i+A.position,i}function G(s,O,A,i,E){s[i++]=b.BSON_DATA_SYMBOL;let I=E?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+I,s[i++]=0;let j=s.write(A.value,i+4,void 0,"utf8")+1;return s[i]=j&255,s[i+1]=j>>8&255,s[i+2]=j>>16&255,s[i+3]=j>>24&255,i=i+4+j-1,s[i++]=0,i}function z(s,O,A,i,E,I,j){s[i++]=b.BSON_DATA_OBJECT;let L=j?s.write(O,i,void 0,"ascii"):s.write(O,i,void 0,"utf8");i=i+L,s[i++]=0;let N=i,$={$ref:A.collection||A.namespace,$id:A.oid};A.db!=null&&($.$db=A.db),$=Object.assign($,A.fields);let v=x(s,$,!1,i,E+1,I),T=v-N;return s[N++]=T&255,s[N++]=T>>8&255,s[N++]=T>>16&255,s[N++]=T>>24&255,v}function x(s,O,A=!1,i=0,E=0,I=!1,j=!0,L=[]){i=i||0,L=L||[],L.push(O);let N=i+4;if(Array.isArray(O))for(let v=0;v<O.length;v++){let T=""+v,D=O[v];if(D&&D.toBSON){if(typeof D.toBSON!="function")throw new TypeError("toBSON is not a function");D=D.toBSON()}if(typeof D=="string")N=f(s,T,D,N,!0);else if(typeof D=="number")N=u(s,T,D,N,!0);else{if(typeof D=="bigint")throw new TypeError("Unsupported type BigInt, please use Decimal128");if(typeof D=="boolean")N=o(s,T,D,N,!0);else if(D instanceof Date||rt.isDate(D))N=c(s,T,D,N,!0);else if(D===void 0)N=m(s,T,D,N,!0);else if(D===null)N=m(s,T,D,N,!0);else if(D._bsontype==="ObjectId"||D._bsontype==="ObjectID")N=w(s,T,D,N,!0);else if(C.Buffer.isBuffer(D)||rt.isUint8Array(D))N=U(s,T,D,N,!0);else if(D instanceof RegExp||l(D))N=_(s,T,D,N,!0);else if(typeof D=="object"&&D._bsontype==null)N=p(s,T,D,N,A,E,I,j,!0,L);else if(typeof D=="object"&&Ft.isBSONType(D)&&D._bsontype==="Decimal128")N=F(s,T,D,N,!0);else if(D._bsontype==="Long"||D._bsontype==="Timestamp")N=J(s,T,D,N,!0);else if(D._bsontype==="Double")N=W(s,T,D,N,!0);else if(typeof D=="function"&&I)N=Q(s,T,D,N,A,E,!0);else if(D._bsontype==="Code")N=H(s,T,D,N,A,E,I,j,!0);else if(D._bsontype==="Binary")N=M(s,T,D,N,!0);else if(D._bsontype==="Symbol")N=G(s,T,D,N,!0);else if(D._bsontype==="DBRef")N=z(s,T,D,N,E,I,!0);else if(D._bsontype==="BSONRegExp")N=g(s,T,D,N,!0);else if(D._bsontype==="Int32")N=R(s,T,D,N,!0);else if(D._bsontype==="MinKey"||D._bsontype==="MaxKey")N=n(s,T,D,N,!0);else if(typeof D._bsontype<"u")throw new TypeError("Unrecognized or invalid _bsontype: "+D._bsontype)}}else if(O instanceof $t.Map){let v=O.entries(),T=!1;for(;!T;){let D=v.next();if(T=!!D.done,T)continue;let Z=D.value[0],k=D.value[1],et=typeof k;if(typeof Z=="string"&&!d.has(Z)){if(Z.match(h)!=null)throw Error("key "+Z+" must not contain null bytes");if(A){if(Z[0]==="$")throw Error("key "+Z+" must not start with '$'");if(~Z.indexOf("."))throw Error("key "+Z+" must not contain '.'")}}if(et==="string")N=f(s,Z,k,N);else if(et==="number")N=u(s,Z,k,N);else{if(et==="bigint"||rt.isBigInt64Array(k)||rt.isBigUInt64Array(k))throw new TypeError("Unsupported type BigInt, please use Decimal128");if(et==="boolean")N=o(s,Z,k,N);else if(k instanceof Date||rt.isDate(k))N=c(s,Z,k,N);else if(k===null||k===void 0&&j===!1)N=m(s,Z,k,N);else if(k._bsontype==="ObjectId"||k._bsontype==="ObjectID")N=w(s,Z,k,N);else if(C.Buffer.isBuffer(k)||rt.isUint8Array(k))N=U(s,Z,k,N);else if(k instanceof RegExp||l(k))N=_(s,Z,k,N);else if(et==="object"&&k._bsontype==null)N=p(s,Z,k,N,A,E,I,j,!1,L);else if(et==="object"&&k._bsontype==="Decimal128")N=F(s,Z,k,N);else if(k._bsontype==="Long"||k._bsontype==="Timestamp")N=J(s,Z,k,N);else if(k._bsontype==="Double")N=W(s,Z,k,N);else if(k._bsontype==="Code")N=H(s,Z,k,N,A,E,I,j);else if(typeof k=="function"&&I)N=Q(s,Z,k,N,A,E,I);else if(k._bsontype==="Binary")N=M(s,Z,k,N);else if(k._bsontype==="Symbol")N=G(s,Z,k,N);else if(k._bsontype==="DBRef")N=z(s,Z,k,N,E,I);else if(k._bsontype==="BSONRegExp")N=g(s,Z,k,N);else if(k._bsontype==="Int32")N=R(s,Z,k,N);else if(k._bsontype==="MinKey"||k._bsontype==="MaxKey")N=n(s,Z,k,N);else if(typeof k._bsontype<"u")throw new TypeError("Unrecognized or invalid _bsontype: "+k._bsontype)}}}else{if(O.toBSON){if(typeof O.toBSON!="function")throw new TypeError("toBSON is not a function");if(O=O.toBSON(),O!=null&&typeof O!="object")throw new TypeError("toBSON function did not return an object")}for(let v in O){let T=O[v];if(T&&T.toBSON){if(typeof T.toBSON!="function")throw new TypeError("toBSON is not a function");T=T.toBSON()}let D=typeof T;if(typeof v=="string"&&!d.has(v)){if(v.match(h)!=null)throw Error("key "+v+" must not contain null bytes");if(A){if(v[0]==="$")throw Error("key "+v+" must not start with '$'");if(~v.indexOf("."))throw Error("key "+v+" must not contain '.'")}}if(D==="string")N=f(s,v,T,N);else if(D==="number")N=u(s,v,T,N);else{if(D==="bigint")throw new TypeError("Unsupported type BigInt, please use Decimal128");if(D==="boolean")N=o(s,v,T,N);else if(T instanceof Date||rt.isDate(T))N=c(s,v,T,N);else if(T===void 0)j===!1&&(N=m(s,v,T,N));else if(T===null)N=m(s,v,T,N);else if(T._bsontype==="ObjectId"||T._bsontype==="ObjectID")N=w(s,v,T,N);else if(C.Buffer.isBuffer(T)||rt.isUint8Array(T))N=U(s,v,T,N);else if(T instanceof RegExp||l(T))N=_(s,v,T,N);else if(D==="object"&&T._bsontype==null)N=p(s,v,T,N,A,E,I,j,!1,L);else if(D==="object"&&T._bsontype==="Decimal128")N=F(s,v,T,N);else if(T._bsontype==="Long"||T._bsontype==="Timestamp")N=J(s,v,T,N);else if(T._bsontype==="Double")N=W(s,v,T,N);else if(T._bsontype==="Code")N=H(s,v,T,N,A,E,I,j);else if(typeof T=="function"&&I)N=Q(s,v,T,N,A,E,I);else if(T._bsontype==="Binary")N=M(s,v,T,N);else if(T._bsontype==="Symbol")N=G(s,v,T,N);else if(T._bsontype==="DBRef")N=z(s,v,T,N,E,I);else if(T._bsontype==="BSONRegExp")N=g(s,v,T,N);else if(T._bsontype==="Int32")N=R(s,v,T,N);else if(T._bsontype==="MinKey"||T._bsontype==="MaxKey")N=n(s,v,T,N);else if(typeof T._bsontype<"u")throw new TypeError("Unrecognized or invalid _bsontype: "+T._bsontype)}}}L.pop(),s[N++]=0;let $=N-i;return s[i++]=$&255,s[i++]=$>>8&255,s[i++]=$>>16&255,s[i++]=$>>24&255,N}t.serializeInto=x});st(Zt);var Gn=Zt.serializeInto,V=ot(function(B,t){Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeStream=t.calculateObjectSize=t.deserialize=t.serializeWithBufferAndIndex=t.serialize=t.setInternalBufferSize=t.ObjectID=t.Decimal128=t.BSONRegExp=t.MaxKey=t.MinKey=t.Int32=t.Double=t.Timestamp=t.Long=t.ObjectId=t.Binary=t.DBRef=t.BSONSymbol=t.Map=t.Code=t.LongWithoutOverridesClass=t.EJSON=t.JS_INT_MIN=t.JS_INT_MAX=t.BSON_INT64_MIN=t.BSON_INT64_MAX=t.BSON_INT32_MIN=t.BSON_INT32_MAX=t.BSON_DATA_UNDEFINED=t.BSON_DATA_TIMESTAMP=t.BSON_DATA_SYMBOL=t.BSON_DATA_STRING=t.BSON_DATA_REGEXP=t.BSON_DATA_OID=t.BSON_DATA_OBJECT=t.BSON_DATA_NUMBER=t.BSON_DATA_NULL=t.BSON_DATA_MIN_KEY=t.BSON_DATA_MAX_KEY=t.BSON_DATA_LONG=t.BSON_DATA_INT=t.BSON_DATA_DECIMAL128=t.BSON_DATA_DBPOINTER=t.BSON_DATA_DATE=t.BSON_DATA_CODE_W_SCOPE=t.BSON_DATA_CODE=t.BSON_DATA_BOOLEAN=t.BSON_DATA_BINARY=t.BSON_DATA_ARRAY=t.BSON_BINARY_SUBTYPE_UUID_NEW=t.BSON_BINARY_SUBTYPE_UUID=t.BSON_BINARY_SUBTYPE_USER_DEFINED=t.BSON_BINARY_SUBTYPE_MD5=t.BSON_BINARY_SUBTYPE_FUNCTION=t.BSON_BINARY_SUBTYPE_DEFAULT=t.BSON_BINARY_SUBTYPE_BYTE_ARRAY=void 0,Object.defineProperty(t,"Binary",{enumerable:!0,get:function(){return _t.Binary}}),Object.defineProperty(t,"Code",{enumerable:!0,get:function(){return mt.Code}}),Object.defineProperty(t,"DBRef",{enumerable:!0,get:function(){return pt.DBRef}}),Object.defineProperty(t,"Decimal128",{enumerable:!0,get:function(){return Dt.Decimal128}}),Object.defineProperty(t,"Double",{enumerable:!0,get:function(){return bt.Double}}),Object.defineProperty(t,"Int32",{enumerable:!0,get:function(){return dt.Int32}}),Object.defineProperty(t,"Long",{enumerable:!0,get:function(){return K.Long}}),Object.defineProperty(t,"Map",{enumerable:!0,get:function(){return $t.Map}}),Object.defineProperty(t,"MaxKey",{enumerable:!0,get:function(){return Rt.MaxKey}}),Object.defineProperty(t,"MinKey",{enumerable:!0,get:function(){return Ut.MinKey}}),Object.defineProperty(t,"ObjectId",{enumerable:!0,get:function(){return St.ObjectId}}),Object.defineProperty(t,"ObjectID",{enumerable:!0,get:function(){return St.ObjectId}}),Object.defineProperty(t,"BSONRegExp",{enumerable:!0,get:function(){return Ot.BSONRegExp}}),Object.defineProperty(t,"BSONSymbol",{enumerable:!0,get:function(){return Mt.BSONSymbol}}),Object.defineProperty(t,"Timestamp",{enumerable:!0,get:function(){return wt.Timestamp}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_BYTE_ARRAY}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_DEFAULT",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_DEFAULT}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_FUNCTION",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_FUNCTION}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_MD5",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_MD5}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_USER_DEFINED",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_USER_DEFINED}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_UUID}}),Object.defineProperty(t,"BSON_BINARY_SUBTYPE_UUID_NEW",{enumerable:!0,get:function(){return b.BSON_BINARY_SUBTYPE_UUID_NEW}}),Object.defineProperty(t,"BSON_DATA_ARRAY",{enumerable:!0,get:function(){return b.BSON_DATA_ARRAY}}),Object.defineProperty(t,"BSON_DATA_BINARY",{enumerable:!0,get:function(){return b.BSON_DATA_BINARY}}),Object.defineProperty(t,"BSON_DATA_BOOLEAN",{enumerable:!0,get:function(){return b.BSON_DATA_BOOLEAN}}),Object.defineProperty(t,"BSON_DATA_CODE",{enumerable:!0,get:function(){return b.BSON_DATA_CODE}}),Object.defineProperty(t,"BSON_DATA_CODE_W_SCOPE",{enumerable:!0,get:function(){return b.BSON_DATA_CODE_W_SCOPE}}),Object.defineProperty(t,"BSON_DATA_DATE",{enumerable:!0,get:function(){return b.BSON_DATA_DATE}}),Object.defineProperty(t,"BSON_DATA_DBPOINTER",{enumerable:!0,get:function(){return b.BSON_DATA_DBPOINTER}}),Object.defineProperty(t,"BSON_DATA_DECIMAL128",{enumerable:!0,get:function(){return b.BSON_DATA_DECIMAL128}}),Object.defineProperty(t,"BSON_DATA_INT",{enumerable:!0,get:function(){return b.BSON_DATA_INT}}),Object.defineProperty(t,"BSON_DATA_LONG",{enumerable:!0,get:function(){return b.BSON_DATA_LONG}}),Object.defineProperty(t,"BSON_DATA_MAX_KEY",{enumerable:!0,get:function(){return b.BSON_DATA_MAX_KEY}}),Object.defineProperty(t,"BSON_DATA_MIN_KEY",{enumerable:!0,get:function(){return b.BSON_DATA_MIN_KEY}}),Object.defineProperty(t,"BSON_DATA_NULL",{enumerable:!0,get:function(){return b.BSON_DATA_NULL}}),Object.defineProperty(t,"BSON_DATA_NUMBER",{enumerable:!0,get:function(){return b.BSON_DATA_NUMBER}}),Object.defineProperty(t,"BSON_DATA_OBJECT",{enumerable:!0,get:function(){return b.BSON_DATA_OBJECT}}),Object.defineProperty(t,"BSON_DATA_OID",{enumerable:!0,get:function(){return b.BSON_DATA_OID}}),Object.defineProperty(t,"BSON_DATA_REGEXP",{enumerable:!0,get:function(){return b.BSON_DATA_REGEXP}}),Object.defineProperty(t,"BSON_DATA_STRING",{enumerable:!0,get:function(){return b.BSON_DATA_STRING}}),Object.defineProperty(t,"BSON_DATA_SYMBOL",{enumerable:!0,get:function(){return b.BSON_DATA_SYMBOL}}),Object.defineProperty(t,"BSON_DATA_TIMESTAMP",{enumerable:!0,get:function(){return b.BSON_DATA_TIMESTAMP}}),Object.defineProperty(t,"BSON_DATA_UNDEFINED",{enumerable:!0,get:function(){return b.BSON_DATA_UNDEFINED}}),Object.defineProperty(t,"BSON_INT32_MAX",{enumerable:!0,get:function(){return b.BSON_INT32_MAX}}),Object.defineProperty(t,"BSON_INT32_MIN",{enumerable:!0,get:function(){return b.BSON_INT32_MIN}}),Object.defineProperty(t,"BSON_INT64_MAX",{enumerable:!0,get:function(){return b.BSON_INT64_MAX}}),Object.defineProperty(t,"BSON_INT64_MIN",{enumerable:!0,get:function(){return b.BSON_INT64_MIN}}),Object.defineProperty(t,"JS_INT_MAX",{enumerable:!0,get:function(){return b.JS_INT_MAX}}),Object.defineProperty(t,"JS_INT_MIN",{enumerable:!0,get:function(){return b.JS_INT_MIN}}),Object.defineProperty(t,"EJSON",{enumerable:!0,get:function(){return Ft.EJSON}});var h=wt;Object.defineProperty(t,"LongWithoutOverridesClass",{enumerable:!0,get:function(){return h.LongWithoutOverridesClass}});let d=1024*1024*17,l=C.Buffer.alloc(d);function f(g){l.length<g&&(l=C.Buffer.alloc(g))}t.setInternalBufferSize=f;function u(g,n={}){let w=typeof n.checkKeys=="boolean"?n.checkKeys:!1,U=typeof n.serializeFunctions=="boolean"?n.serializeFunctions:!1,p=typeof n.ignoreUndefined=="boolean"?n.ignoreUndefined:!0,F=typeof n.minInternalBufferSize=="number"?n.minInternalBufferSize:d;l.length<F&&(l=C.Buffer.alloc(F));let J=Zt.serializeInto(l,g,w,0,0,U,p,[]),R=C.Buffer.alloc(J);return l.copy(R,0,0,R.length),R}t.serialize=u;function m(g,n,w={}){let U=typeof w.checkKeys=="boolean"?w.checkKeys:!1,p=typeof w.serializeFunctions=="boolean"?w.serializeFunctions:!1,F=typeof w.ignoreUndefined=="boolean"?w.ignoreUndefined:!0,J=typeof w.index=="number"?w.index:0,R=Zt.serializeInto(l,g,U,0,0,p,F);return l.copy(n,J,0,R),J+R-1}t.serializeWithBufferAndIndex=m;function o(g,n={}){return xt.deserialize(Et.ensureBuffer(g),n)}t.deserialize=o;function c(g,n={}){n=n||{};let w=typeof n.serializeFunctions=="boolean"?n.serializeFunctions:!1,U=typeof n.ignoreUndefined=="boolean"?n.ignoreUndefined:!0;return Be.calculateObjectSize(g,w,U)}t.calculateObjectSize=c;function _(g,n,w,U,p,F){let J=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},F),R=Et.ensureBuffer(g),W=n;for(let Q=0;Q<w;Q++){let H=R[W]|R[W+1]<<8|R[W+2]<<16|R[W+3]<<24;J.index=W,U[p+Q]=xt.deserialize(R,J),W=W+H}return W}t.deserializeStream=_}),xn=st(V),Zn=V.deserializeStream,qn=V.calculateObjectSize,Ue=V.deserialize,Qn=V.serializeWithBufferAndIndex,Me=V.serialize,$n=V.setInternalBufferSize,ti=V.ObjectID,ei=V.Decimal128,ri=V.BSONRegExp,ni=V.MaxKey,ii=V.MinKey,oi=V.Int32,si=V.Double,fi=V.Timestamp,ai=V.Long,ui=V.ObjectId,li=V.Binary,ci=V.DBRef,hi=V.BSONSymbol,_i=V.Map,yi=V.Code,Bi=V.LongWithoutOverridesClass,pi=V.EJSON,Ni=V.JS_INT_MIN,gi=V.JS_INT_MAX,Ai=V.BSON_INT64_MIN,Si=V.BSON_INT64_MAX,Oi=V.BSON_INT32_MIN,mi=V.BSON_INT32_MAX,Ei=V.BSON_DATA_UNDEFINED,wi=V.BSON_DATA_TIMESTAMP,Ti=V.BSON_DATA_SYMBOL,bi=V.BSON_DATA_STRING,di=V.BSON_DATA_REGEXP,Ii=V.BSON_DATA_OID,Di=V.BSON_DATA_OBJECT,Ri=V.BSON_DATA_NUMBER,Ui=V.BSON_DATA_NULL,Mi=V.BSON_DATA_MIN_KEY,Pi=V.BSON_DATA_MAX_KEY,ji=V.BSON_DATA_LONG,Fi=V.BSON_DATA_INT,Yi=V.BSON_DATA_DECIMAL128,Li=V.BSON_DATA_DBPOINTER,vi=V.BSON_DATA_DATE,Ci=V.BSON_DATA_CODE_W_SCOPE,zi=V.BSON_DATA_CODE,Ji=V.BSON_DATA_BOOLEAN,Wi=V.BSON_DATA_BINARY,ki=V.BSON_DATA_ARRAY,Xi=V.BSON_BINARY_SUBTYPE_UUID_NEW,Ki=V.BSON_BINARY_SUBTYPE_UUID,Vi=V.BSON_BINARY_SUBTYPE_USER_DEFINED,Hi=V.BSON_BINARY_SUBTYPE_MD5,Gi=V.BSON_BINARY_SUBTYPE_FUNCTION,xi=V.BSON_BINARY_SUBTYPE_DEFAULT,Zi=V.BSON_BINARY_SUBTYPE_BYTE_ARRAY;function pe(B,t){return Ue(new Uint8Array(B),t)}var te={name:"BSON",id:"bson",module:"bson",extensions:["bson"],mimeTypes:["application/bson"],category:"json",binary:!0};var Or="4.4.0-alpha.17",ee={...te,dataType:null,batchType:null,name:"BSON",id:"bson",module:"bson",version:Or,extensions:["bson"],mimeTypes:["application/bson"],category:"json",binary:!0,parse:mr,parseSync:Er,options:{bson:{}}};async function mr(B,t){let h={...ee.options.bson,...t?.bson};return pe(B,h)}function Er(B,t){let h={...ee.options.bson,...t?.bson};return pe(B,h)}var je=B=>typeof SharedArrayBuffer<"u"&&B instanceof SharedArrayBuffer;function ge(B){if(B instanceof ArrayBuffer)return B;if(je(B))return Ne(B);let{buffer:t,byteOffset:h,byteLength:d}=B;return t instanceof ArrayBuffer&&h===0&&d===t.byteLength?t:Ne(t,h,d)}function Ne(B,t=0,h=B.byteLength-t){let d=new Uint8Array(B,t,h),l=new Uint8Array(d.length);return l.set(d),l.buffer}function Ae(B,t){let h=Me(B);return ge(h)}var wr="4.4.0-alpha.17",Fe={...te,name:"BSON",id:"bson",module:"bson",version:wr,extensions:["bson"],options:{bson:{}},async encode(B,t){return Ae(B,{})},encodeSync(B,t){return Ae(B,{})}};return Xe(Yt);})();
17
17
  return __exports__;
18
18
  });
package/dist/index.cjs CHANGED
@@ -54,7 +54,7 @@ var BSONFormat = {
54
54
  };
55
55
 
56
56
  // dist/bson-loader.js
57
- var VERSION = true ? "4.4.0-alpha.16" : "latest";
57
+ var VERSION = true ? "4.4.0-alpha.17" : "latest";
58
58
  var BSONLoader = {
59
59
  ...BSONFormat,
60
60
  dataType: null,
@@ -91,7 +91,7 @@ function encodeBSONSync(value, options) {
91
91
  }
92
92
 
93
93
  // dist/bson-writer.js
94
- var VERSION2 = true ? "4.4.0-alpha.16" : "latest";
94
+ var VERSION2 = true ? "4.4.0-alpha.17" : "latest";
95
95
  var BSONWriter = {
96
96
  ...BSONFormat,
97
97
  name: "BSON",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/bson",
3
- "version": "4.4.0-alpha.16",
3
+ "version": "4.4.0-alpha.17",
4
4
  "description": "Framework-independent loader for JSON and streaming JSON formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,14 +40,14 @@
40
40
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
41
41
  },
42
42
  "dependencies": {
43
- "@loaders.gl/gis": "4.4.0-alpha.16",
44
- "@loaders.gl/loader-utils": "4.4.0-alpha.16",
45
- "@loaders.gl/schema": "4.4.0-alpha.16",
43
+ "@loaders.gl/gis": "4.4.0-alpha.17",
44
+ "@loaders.gl/loader-utils": "4.4.0-alpha.17",
45
+ "@loaders.gl/schema": "4.4.0-alpha.17",
46
46
  "@types/bson": "4.2.0",
47
47
  "bson": "4.2.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@loaders.gl/core": "4.4.0-alpha.1"
51
51
  },
52
- "gitHead": "d0f42c97a91c1e63727089ec43ed9e229acfe0d6"
52
+ "gitHead": "1379fa4a0c29df20dbc834a4ed1c9800e4aaec2f"
53
53
  }