From 5e1dbd974bd34761ec91728245503a2344719f71 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 23 Jul 2024 19:02:39 +0100 Subject: [PATCH 1/2] Adding a polyfill bundle for Buffer which can be used in the isolated-vm. --- packages/server/package.json | 4 +- .../src/jsRunner/bundles/bson.ivm.bundle.js | 14 +++--- .../src/jsRunner/bundles/buffer.ivm.bundle.js | 14 ++++++ .../server/src/jsRunner/bundles/buffer.ts | 3 ++ packages/server/src/jsRunner/bundles/index.ts | 2 + packages/server/src/jsRunner/index.ts | 1 + .../src/jsRunner/tests/jsRunner.spec.ts | 11 +++++ .../server/src/jsRunner/vm/isolated-vm.ts | 14 ++++++ yarn.lock | 43 +++++++++++++++---- 9 files changed, 90 insertions(+), 16 deletions(-) create mode 100644 packages/server/src/jsRunner/bundles/buffer.ivm.bundle.js create mode 100644 packages/server/src/jsRunner/bundles/buffer.ts diff --git a/packages/server/package.json b/packages/server/package.json index 9054e1a89f..48ab0685d9 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -16,7 +16,8 @@ "build:isolated-vm-lib:snippets": "esbuild --minify --bundle src/jsRunner/bundles/snippets.ts --outfile=src/jsRunner/bundles/snippets.ivm.bundle.js --platform=node --format=iife --global-name=snippets", "build:isolated-vm-lib:string-templates": "esbuild --minify --bundle src/jsRunner/bundles/index-helpers.ts --outfile=src/jsRunner/bundles/index-helpers.ivm.bundle.js --platform=node --format=iife --external:handlebars --global-name=helpers", "build:isolated-vm-lib:bson": "esbuild --minify --bundle src/jsRunner/bundles/bsonPackage.ts --outfile=src/jsRunner/bundles/bson.ivm.bundle.js --platform=node --format=iife --global-name=bson", - "build:isolated-vm-libs": "yarn build:isolated-vm-lib:string-templates && yarn build:isolated-vm-lib:bson && yarn build:isolated-vm-lib:snippets", + "build:isolated-vm-lib:buffer": "esbuild --minify --bundle src/jsRunner/bundles/buffer.ts --outfile=src/jsRunner/bundles/buffer.ivm.bundle.js --platform=node --format=iife --global-name=buffer", + "build:isolated-vm-libs": "yarn build:isolated-vm-lib:string-templates && yarn build:isolated-vm-lib:bson && yarn build:isolated-vm-lib:snippets && yarn build:isolated-vm-lib:buffer", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js", "jest": "NODE_OPTIONS=\"--no-node-snapshot $NODE_OPTIONS\" jest", @@ -68,6 +69,7 @@ "aws-sdk": "2.1030.0", "bcrypt": "5.1.0", "bcryptjs": "2.4.3", + "buffer": "6.0.3", "bull": "4.10.1", "chokidar": "3.5.3", "content-disposition": "^0.5.4", diff --git a/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js b/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js index 5c49ce78e6..246c2d8f2d 100644 --- a/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js +++ b/packages/server/src/jsRunner/bundles/bson.ivm.bundle.js @@ -1,7 +1,7 @@ -"use strict";var bson=(()=>{var Ut=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames;var en=Object.prototype.hasOwnProperty;var nn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,s)=>(typeof require<"u"?require:t)[s]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var sn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),rn=(e,t)=>{for(var s in t)Ut(e,s,{get:t[s],enumerable:!0})},on=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of tn(t))!en.call(e,r)&&r!==s&&Ut(e,r,{get:()=>t[r],enumerable:!(n=ve(t,r))||n.enumerable});return e};var fn=e=>on(Ut({},"__esModule",{value:!0}),e);var oe=sn(U=>{"use strict";function vt(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function tt(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}function lt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function te(e){return Object.prototype.toString.call(e)==="[object Map]"}function ct(e){return Object.prototype.toString.call(e)==="[object Date]"}function F(e,t){return JSON.stringify(e,(s,n)=>typeof n=="bigint"?{$numberLong:`${n}`}:te(n)?Object.fromEntries(n):n)}function ln(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}var et=6,At=2147483647,$t=-2147483648,Oe=Math.pow(2,63)-1,be=-Math.pow(2,63),Ee=Math.pow(2,53),Te=-Math.pow(2,53),bt=1,Ie=2,ee=3,de=4,ne=5,cn=6,Ae=7,$e=8,_e=9,se=10,Et=11,hn=12,re=13,Ue=14,Le=15,at=16,Re=17,ie=18,De=19,je=255,ze=127,an=0,Tt=4,Fe=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127}),a=class extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,s){super(t,s)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}},P=class extends a{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${et}.x.x`)}},yt=class extends a{get name(){return"BSONRuntimeError"}constructor(t){super(t)}},gn=128,un=192,yn=224,mn=240,wn=248,pn=192,Sn=224,Nn=240,Bn=128;function Me(e,t,s){let n=0;for(let r=t;r20)return null;if(n===1&&e[t]<128)return String.fromCharCode(e[t]);if(n===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(n===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);let r=[];for(let o=t;o127)return null;r.push(c)}return String.fromCharCode(...r)}function On(e){return Z.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}var bn=(()=>{try{return nn("crypto").randomBytes}catch{return On}})(),Z={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new a(`Cannot create Buffer from ${String(e)}`)},allocate(e){return Buffer.alloc(e)},equals(e,t){return Z.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return Z.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return Z.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return Z.toLocalBufferType(e).toString("hex")},fromUTF8(e){return Buffer.from(e,"utf8")},toUTF8(e,t,s,n){let r=s-t<=20?xe(e,t,s):null;if(r!=null)return r;let o=Z.toLocalBufferType(e).toString("utf8",t,s);if(n){for(let c=0;cMath.floor(Math.random()*256)))}var In=(()=>{let{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(gt.allocate(t));if(En()){let{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return Tn})(),fe=/(\d|[a-f])/i,gt={toLocalBufferType(e){let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new a(`Cannot make a Uint8Array from ${String(e)}`)},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let s=0;st.charCodeAt(0))},toBase64(e){return btoa(gt.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){let t=e.length%2===0?e:e.slice(0,e.length-1),s=[];for(let n=0;nt.toString(16).padStart(2,"0")).join("")},fromUTF8(e){return new TextEncoder().encode(e)},toUTF8(e,t,s,n){let r=s-t<=20?xe(e,t,s):null;if(r!=null)return r;if(n)try{return new TextDecoder("utf8",{fatal:n}).decode(e.slice(t,s))}catch(o){throw new a("Invalid UTF-8 string in BSON document",{cause:o})}return new TextDecoder("utf8",{fatal:n}).decode(e.slice(t,s))},utf8ByteLength(e){return gt.fromUTF8(e).byteLength},encodeUTF8Into(e,t,s){let n=gt.fromUTF8(t);return e.set(n,s),n.byteLength},randomBytes:In},dn=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0,l=dn?Z:gt,ut=class extends DataView{static fromUint8Array(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}},j=class{get[Symbol.for("@@mdb.bson.version")](){return et}[Symbol.for("nodejs.util.inspect.custom")](t,s,n){return this.inspect(t,s,n)}},_=class e extends j{get _bsontype(){return"Binary"}constructor(t,s){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!vt(t)&&!Array.isArray(t))throw new a("Binary can only be constructed from Uint8Array or number[]");this.sub_type=s??e.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=l.allocate(e.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?l.fromNumberArray(t):l.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new a("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new a("only accepts single character Uint8Array or Array");let s;if(typeof t=="string"?s=t.charCodeAt(0):typeof t=="number"?s=t:s=t[0],s<0||s>255)throw new a("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=s;else{let n=l.allocate(e.BUFFER_SIZE+this.buffer.length);n.set(this.buffer,0),this.buffer=n,this.buffer[this.position++]=s}}write(t,s){if(s=typeof s=="number"?s:this.position,this.buffer.byteLengththis.position?s+t.length:this.position;else if(typeof t=="string")throw new a("input cannot be string")}read(t,s){return s=s&&s>0?s:this.position,this.buffer.slice(t,t+s)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return l.toBase64(this.buffer)}toString(t){return t==="hex"?l.toHex(this.buffer):t==="base64"?l.toBase64(this.buffer):t==="utf8"||t==="utf-8"?l.toUTF8(this.buffer,0,this.buffer.byteLength,!1):l.toUTF8(this.buffer,0,this.buffer.byteLength,!1)}toExtendedJSON(t){t=t||{};let s=l.toBase64(this.buffer),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:s,$type:n.length===1?"0"+n:n}:{$binary:{base64:s,subType:n.length===1?"0"+n:n}}}toUUID(){if(this.sub_type===e.SUBTYPE_UUID)return new W(this.buffer.slice(0,this.position));throw new a(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${e.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,s){return new e(l.fromHex(t),s)}static createFromBase64(t,s){return new e(l.fromBase64(t),s)}static fromExtendedJSON(t,s){s=s||{};let n,r;if("$binary"in t?s.legacy&&typeof t.$binary=="string"&&"$type"in t?(r=t.$type?parseInt(t.$type,16):0,n=l.fromBase64(t.$binary)):typeof t.$binary!="string"&&(r=t.$binary.subType?parseInt(t.$binary.subType,16):0,n=l.fromBase64(t.$binary.base64)):"$uuid"in t&&(r=4,n=W.bytesFromString(t.$uuid)),!n)throw new a(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return r===Tt?new W(n):new e(n,r)}inspect(t,s,n){n??=F;let r=l.toBase64(this.buffer.subarray(0,this.position)),o=n(r,s),c=n(this.sub_type,s);return`Binary.createFromBase64(${o}, ${c})`}};_.BSON_BINARY_SUBTYPE_DEFAULT=0;_.BUFFER_SIZE=256;_.SUBTYPE_DEFAULT=0;_.SUBTYPE_FUNCTION=1;_.SUBTYPE_BYTE_ARRAY=2;_.SUBTYPE_UUID_OLD=3;_.SUBTYPE_UUID=4;_.SUBTYPE_MD5=5;_.SUBTYPE_ENCRYPTED=6;_.SUBTYPE_COLUMN=7;_.SUBTYPE_USER_DEFINED=128;var Lt=16,An=/^[0-9A-F]{32}$/i,$n=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,W=class e extends _{constructor(t){let s;if(t==null)s=e.generate();else if(t instanceof e)s=l.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===Lt)s=l.toLocalBufferType(t);else if(typeof t=="string")s=e.bytesFromString(t);else throw new a("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(s,Tt)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[l.toHex(this.buffer.subarray(0,4)),l.toHex(this.buffer.subarray(4,6)),l.toHex(this.buffer.subarray(6,8)),l.toHex(this.buffer.subarray(8,10)),l.toHex(this.buffer.subarray(10,16))].join("-"):l.toHex(this.buffer)}toString(t){return t==="hex"?l.toHex(this.id):t==="base64"?l.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof e)return l.equals(t.id,this.id);try{return l.equals(new e(t).id,this.id)}catch{return!1}}toBinary(){return new _(this.id,_.SUBTYPE_UUID)}static generate(){let t=l.randomBytes(Lt);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?e.isValidUUIDString(t):tt(t)?t.byteLength===Lt:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){let s=e.bytesFromString(t);return new e(s)}static createFromBase64(t){return new e(l.fromBase64(t))}static bytesFromString(t){if(!e.isValidUUIDString(t))throw new a("UUID string representation must be 32 hex digits or canonical hyphenated representation");return l.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return An.test(t)||$n.test(t)}inspect(t,s,n){return n??=F,`new UUID(${n(this.toHexString(),s)})`}},Y=class e extends j{get _bsontype(){return"Code"}constructor(t,s){super(),this.code=t.toString(),this.scope=s??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new e(t.$code,t.$scope)}inspect(t,s,n){n??=F;let r=n(this.code,s),o=r.includes(` -`);this.scope!=null&&(r+=`,${o?` -`:" "}${n(this.scope,s)}`);let c=o&&this.scope===null;return`new Code(${o?` -`:""}${r}${c?` -`:""})`}};function Je(e){return e!=null&&typeof e=="object"&&"$id"in e&&e.$id!=null&&"$ref"in e&&typeof e.$ref=="string"&&(!("$db"in e)||"$db"in e&&typeof e.$db=="string")}var C=class e extends j{get _bsontype(){return"DBRef"}constructor(t,s,n,r){super();let o=t.split(".");o.length===2&&(n=o.shift(),t=o.shift()),this.collection=t,this.oid=s,this.db=n,this.fields=r||{}}get namespace(){return this.collection}set namespace(t){this.collection=t}toJSON(){let t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(t.$db=this.db),t}toExtendedJSON(t){t=t||{};let s={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(s.$db=this.db),s=Object.assign(s,this.fields)),s}static fromExtendedJSON(t){let s=Object.assign({},t);return delete s.$ref,delete s.$id,delete s.$db,new e(t.$ref,t.$id,t.$db,s)}inspect(t,s,n){n??=F;let r=[n(this.namespace,s),n(this.oid,s),...this.db?[n(this.db,s)]:[],...Object.keys(this.fields).length>0?[n(this.fields,s)]:[]];return r[1]=n===F?`new ObjectId(${r[1]})`:r[1],`new DBRef(${r.join(", ")})`}},M;try{M=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{}var le=65536,_n=1<<24,ht=le*le,Ce=ht*ht,ce=Ce/2,he={},ae={},Un=20,Ln=/^(\+?0|(\+|-)?[1-9][0-9]*)$/,y=class e extends j{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(t=0,s,n){super(),typeof t=="bigint"?Object.assign(this,e.fromBigInt(t,!!s)):typeof t=="string"?Object.assign(this,e.fromString(t,!!s)):(this.low=t|0,this.high=s|0,this.unsigned=!!n)}static fromBits(t,s,n){return new e(t,s,n)}static fromInt(t,s){let n,r,o;return s?(t>>>=0,(o=0<=t&&t<256)&&(r=ae[t],r)?r:(n=e.fromBits(t,(t|0)<0?-1:0,!0),o&&(ae[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(r=he[t],r)?r:(n=e.fromBits(t,t<0?-1:0,!1),o&&(he[t]=n),n))}static fromNumber(t,s){if(isNaN(t))return s?e.UZERO:e.ZERO;if(s){if(t<0)return e.UZERO;if(t>=Ce)return e.MAX_UNSIGNED_VALUE}else{if(t<=-ce)return e.MIN_VALUE;if(t+1>=ce)return e.MAX_VALUE}return t<0?e.fromNumber(-t,s).neg():e.fromBits(t%ht|0,t/ht|0,s)}static fromBigInt(t,s){return e.fromString(t.toString(),s)}static fromString(t,s,n){if(t.length===0)throw new a("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e.ZERO;if(typeof s=="number"?(n=s,s=!1):s=!!s,n=n||10,n<2||360)throw new a("interior hyphen");if(r===0)return e.fromString(t.substring(1),s,n).neg();let o=e.fromNumber(Math.pow(n,8)),c=e.ZERO;for(let g=0;g>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,c=t.high>>>16,g=t.high&65535,i=t.low>>>16,S=t.low&65535,u=0,f=0,h=0,N=0;return N+=o+S,h+=N>>>16,N&=65535,h+=r+i,f+=h>>>16,h&=65535,f+=n+g,u+=f>>>16,f&=65535,u+=s+c,u&=65535,e.fromBits(h<<16|N,u<<16|f,this.unsigned)}and(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;let s=this.isNegative(),n=t.isNegative();return s&&!n?-1:!s&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1}comp(t){return this.compare(t)}divide(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new a("division by zero");if(M){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;let o=(this.unsigned?M.div_u:M.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(o,M.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;let s,n,r;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;r=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(s=this.shr(1).div(t).shl(1),s.eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(n=this.sub(t.mul(s)),r=s.add(n.div(t)),r));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();r=e.ZERO}for(n=this;n.gte(t);){s=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));let o=Math.ceil(Math.log(s)/Math.LN2),c=o<=48?1:Math.pow(2,o-48),g=e.fromNumber(s),i=g.mul(t);for(;i.isNegative()||i.gt(n);)s-=c,g=e.fromNumber(s,this.unsigned),i=g.mul(t);g.isZero()&&(g=e.ONE),r=r.add(g),n=n.sub(i)}return r}div(t){return this.divide(t)}equals(t){return e.isLong(t)||(t=e.fromValue(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low}eq(t){return this.equals(t)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();let t=this.high!==0?this.high:this.low,s;for(s=31;s>0&&!(t&1<0}gt(t){return this.greaterThan(t)}greaterThanOrEqual(t){return this.comp(t)>=0}gte(t){return this.greaterThanOrEqual(t)}ge(t){return this.greaterThanOrEqual(t)}isEven(){return(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(t){return this.comp(t)<0}lt(t){return this.lessThan(t)}lessThanOrEqual(t){return this.comp(t)<=0}lte(t){return this.lessThanOrEqual(t)}modulo(t){if(e.isLong(t)||(t=e.fromValue(t)),M){let s=(this.unsigned?M.rem_u:M.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(s,M.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))}mod(t){return this.modulo(t)}rem(t){return this.modulo(t)}multiply(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),M){let p=M.mul(this.low,this.high,t.low,t.high);return e.fromBits(p,M.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);let s=this.high>>>16,n=this.high&65535,r=this.low>>>16,o=this.low&65535,c=t.high>>>16,g=t.high&65535,i=t.low>>>16,S=t.low&65535,u=0,f=0,h=0,N=0;return N+=o*S,h+=N>>>16,N&=65535,h+=r*S,f+=h>>>16,h&=65535,h+=o*i,f+=h>>>16,h&=65535,f+=n*S,u+=f>>>16,f&=65535,f+=r*i,u+=f>>>16,f&=65535,f+=o*g,u+=f>>>16,f&=65535,u+=s*S+n*i+r*g+o*c,u&=65535,e.fromBits(h<<16|N,u<<16|f,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)}neg(){return this.negate()}not(){return e.fromBits(~this.low,~this.high,this.unsigned)}notEquals(t){return!this.equals(t)}neq(t){return this.notEquals(t)}ne(t){return this.notEquals(t)}or(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low<>>32-t,this.unsigned):e.fromBits(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(e.isLong(t)&&(t=t.toInt()),t&=63,t===0)return this;{let s=this.high;if(t<32){let n=this.low;return e.fromBits(n>>>t|s<<32-t,s>>>t,this.unsigned)}else return t===32?e.fromBits(s,0,this.unsigned):e.fromBits(s>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())}sub(t){return this.subtract(t)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*ht+(this.low>>>0):this.high*ht+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){let t=this.high,s=this.low;return[s&255,s>>>8&255,s>>>16&255,s>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]}toBytesBE(){let t=this.high,s=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,s>>>24,s>>>16&255,s>>>8&255,s&255]}toSigned(){return this.unsigned?e.fromBits(this.low,this.high,!1):this}toString(t){if(t=t||10,t<2||36>>0).toString(t);if(n=o,n.isZero())return g+r;for(;g.length<6;)g="0"+g;r=""+g+r}}toUnsigned(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)}xor(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)}eqz(){return this.isZero()}le(t){return this.lessThanOrEqual(t)}toExtendedJSON(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(t,s){let{useBigInt64:n=!1,relaxed:r=!0}={...s};if(t.$numberLong.length>Un)throw new a("$numberLong string is too long");if(!Ln.test(t.$numberLong))throw new a(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(n){let c=BigInt(t.$numberLong);return BigInt.asIntN(64,c)}let o=e.fromString(t.$numberLong);return r?o.toNumber():o}inspect(t,s,n){n??=F;let r=n(this.toString(),s),o=this.unsigned?`, ${n(this.unsigned,s)}`:"";return`new Long(${r}${o})`}};y.TWO_PWR_24=y.fromInt(_n);y.MAX_UNSIGNED_VALUE=y.fromBits(-1,-1,!0);y.ZERO=y.fromInt(0);y.UZERO=y.fromInt(0,!0);y.ONE=y.fromInt(1);y.UONE=y.fromInt(1,!0);y.NEG_ONE=y.fromInt(-1);y.MAX_VALUE=y.fromBits(-1,2147483647,!1);y.MIN_VALUE=y.fromBits(0,-2147483648,!1);var Rn=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Dn=/^(\+|-)?(Infinity|inf)$/i,jn=/^(\+|-)?NaN$/i,ft=6111,wt=-6176,ge=6176,ue=34,Rt=l.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ye=l.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),me=l.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),zn=/^([-+])?(\d+)?$/,Fn=31,we=16383,Mn=30,xn=31;function pe(e){return!isNaN(parseInt(e,10))}function Jn(e){let t=y.fromNumber(1e9),s=y.fromNumber(0);if(!e.parts[0]&&!e.parts[1]&&!e.parts[2]&&!e.parts[3])return{quotient:e,rem:s};for(let n=0;n<=3;n++)s=s.shiftLeft(32),s=s.add(new y(e.parts[n],0)),e.parts[n]=s.div(t).low,s=s.modulo(t);return{quotient:e,rem:s}}function Cn(e,t){if(!e&&!t)return{high:y.fromNumber(0),low:y.fromNumber(0)};let s=e.shiftRightUnsigned(32),n=new y(e.getLowBits(),0),r=t.shiftRightUnsigned(32),o=new y(t.getLowBits(),0),c=s.multiply(r),g=s.multiply(o),i=n.multiply(r),S=n.multiply(o);return c=c.add(g.shiftRightUnsigned(32)),g=new y(g.getLowBits(),0).add(i).add(S.shiftRightUnsigned(32)),c=c.add(g.shiftRightUnsigned(32)),S=g.shiftLeft(32).add(new y(S.getLowBits(),0)),{high:c,low:S}}function Hn(e,t){let s=e.high>>>0,n=t.high>>>0;if(s>>0,o=t.low>>>0;if(r=7e3)throw new a(""+t+" not a valid Decimal128 string");let R=t.match(Rn),Nt=t.match(Dn),T=t.match(jn);if(!R&&!Nt&&!T||t.length===0)throw new a(""+t+" not a valid Decimal128 string");if(R){let w=R[2],m=R[4],b=R[5],I=R[6];m&&I===void 0&&J(t,"missing exponent power"),m&&w===void 0&&J(t,"missing exponent base"),m===void 0&&(b||I)&&J(t,"missing e before exponent")}if((t[B]==="+"||t[B]==="-")&&(r=!0,n=t[B++]==="-"),!pe(t[B])&&t[B]!=="."){if(t[B]==="i"||t[B]==="I")return new e(n?ye:me);if(t[B]==="N")return new e(Rt)}for(;pe(t[B])||t[B]===".";){if(t[B]==="."){o&&J(t,"contains multiple periods"),o=!0,B=B+1;continue}N$+16384?$=wt:$=$-u;$>ft;){if(E=E+1,E>=ue){if(g===0){$=ft;break}J(t,"overflow")}$=$-1}if(s.allowRounding){for(;$=5&&(b=1,m===5)){b=h[E]%2===1?1:0;for(let I=f+E+2;I=0&&++h[I]>9;I--)if(h[I]=0,I===0)if($>8&255,L[B++]=d.low.low>>16&255,L[B++]=d.low.low>>24&255,L[B++]=d.low.high&255,L[B++]=d.low.high>>8&255,L[B++]=d.low.high>>16&255,L[B++]=d.low.high>>24&255,L[B++]=d.high.low&255,L[B++]=d.high.low>>8&255,L[B++]=d.high.low>>16&255,L[B++]=d.high.low>>24&255,L[B++]=d.high.high&255,L[B++]=d.high.high>>8&255,L[B++]=d.high.high>>16&255,L[B++]=d.high.high>>24&255,new e(L)}toString(){let t,s=0,n=new Array(36);for(let B=0;B>26&Fn;if(D>>3===3){if(D===Mn)return u.join("")+"Infinity";if(D===xn)return"NaN";t=E>>15&we,c=8+(E>>14&1)}else c=E>>14&7,t=E>>17&we;let A=t-ge;if(g.parts[0]=(E&16383)+((c&15)<<14),g.parts[1]=p,g.parts[2]=N,g.parts[3]=h,g.parts[0]===0&&g.parts[1]===0&&g.parts[2]===0&&g.parts[3]===0)o=!0;else for(S=3;S>=0;S--){let B=0,R=Jn(g);if(g=R.quotient,B=R.rem.low,!!B)for(i=8;i>=0;i--)n[S*9+i]=B%10,B=Math.floor(B/10)}if(o)s=1,n[r]=0;else for(s=36;!n[r];)s=s-1,r=r+1;let x=s-1+A;if(x>=34||x<=-7||A>0){if(s>34)return u.push("0"),A>0?u.push(`E+${A}`):A<0&&u.push(`E${A}`),u.join("");u.push(`${n[r++]}`),s=s-1,s&&u.push(".");for(let B=0;B0?u.push(`+${x}`):u.push(`${x}`)}else if(A>=0)for(let B=0;B0)for(let R=0;R>8&255,n[9]=s>>16&255,n}toString(t){return t==="base64"?l.toBase64(this.id):t==="hex"?this.toHexString():this.toHexString()}toJSON(){return this.toHexString()}static is(t){return t!=null&&typeof t=="object"&&"_bsontype"in t&&t._bsontype==="ObjectId"}equals(t){if(t==null)return!1;if(e.is(t))return this[H][11]===t[H][11]&&l.equals(this[H],t[H]);if(typeof t=="string")return t.toLowerCase()===this.toHexString();if(typeof t=="object"&&typeof t.toHexString=="function"){let s=t.toHexString(),n=this.toHexString();return typeof s=="string"&&s.toLowerCase()===n}return!1}getTimestamp(){let t=new Date,s=ut.fromUint8Array(this.id).getUint32(0,!1);return t.setTime(Math.floor(s)*1e3),t}static createPk(){return new e}static createFromTime(t){let s=l.fromNumberArray([0,0,0,0,0,0,0,0,0,0,0,0]);return ut.fromUint8Array(s).setUint32(0,t,!1),new e(s)}static createFromHexString(t){if(t?.length!==24)throw new a("hex string must be 24 characters");return new e(l.fromHex(t))}static createFromBase64(t){if(t?.length!==16)throw new a("base64 string must be 16 characters");return new e(l.fromBase64(t))}static isValid(t){if(t==null)return!1;try{return new e(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new e(t.$oid)}inspect(t,s,n){return n??=F,`new ObjectId(${n(this.toHexString(),s)})`}};k.index=Math.floor(Math.random()*16777215);function Bt(e,t,s){let n=5;if(Array.isArray(e))for(let r=0;r=Te&&t<=Ee&&t>=$t&&t<=At?(e!=null?l.utf8ByteLength(e)+1:0)+(4+1):(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);case"undefined":return n||!r?(e!=null?l.utf8ByteLength(e)+1:0)+1:0;case"boolean":return(e!=null?l.utf8ByteLength(e)+1:0)+(1+1);case"object":if(t!=null&&typeof t._bsontype=="string"&&t[Symbol.for("@@mdb.bson.version")]!==et)throw new P;if(t==null||t._bsontype==="MinKey"||t._bsontype==="MaxKey")return(e!=null?l.utf8ByteLength(e)+1:0)+1;if(t._bsontype==="ObjectId")return(e!=null?l.utf8ByteLength(e)+1:0)+(12+1);if(t instanceof Date||ct(t))return(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||vt(t))return(e!=null?l.utf8ByteLength(e)+1:0)+(1+4+1)+t.byteLength;if(t._bsontype==="Long"||t._bsontype==="Double"||t._bsontype==="Timestamp")return(e!=null?l.utf8ByteLength(e)+1:0)+(8+1);if(t._bsontype==="Decimal128")return(e!=null?l.utf8ByteLength(e)+1:0)+(16+1);if(t._bsontype==="Code")return t.scope!=null&&Object.keys(t.scope).length>0?(e!=null?l.utf8ByteLength(e)+1:0)+1+4+4+l.utf8ByteLength(t.code.toString())+1+Bt(t.scope,s,r):(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.code.toString())+1;if(t._bsontype==="Binary"){let o=t;return o.sub_type===_.SUBTYPE_BYTE_ARRAY?(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1+4):(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1)}else{if(t._bsontype==="Symbol")return(e!=null?l.utf8ByteLength(e)+1:0)+l.utf8ByteLength(t.value)+4+1+1;if(t._bsontype==="DBRef"){let o=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return t.db!=null&&(o.$db=t.db),(e!=null?l.utf8ByteLength(e)+1:0)+1+Bt(o,s,r)}else return t instanceof RegExp||lt(t)?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.source)+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:t._bsontype==="BSONRegExp"?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.pattern)+1+l.utf8ByteLength(t.options)+1:(e!=null?l.utf8ByteLength(e)+1:0)+Bt(t,s,r)+1}case"function":if(s)return(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.toString())+1}return 0}function Pn(e){return e.split("").sort().join("")}var q=class e extends j{get _bsontype(){return"BSONRegExp"}constructor(t,s){if(super(),this.pattern=t,this.options=Pn(s??""),this.pattern.indexOf("\0")!==-1)throw new a(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(this.options.indexOf("\0")!==-1)throw new a(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let n=0;ng);n??=F;let o=r(n(this.pattern),"regexp"),c=r(n(this.options),"regexp");return`new BSONRegExp(${o}, ${c})`}},it=class e extends j{get _bsontype(){return"BSONSymbol"}constructor(t){super(),this.value=t}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(t){return new e(t.$symbol)}inspect(t,s,n){return n??=F,`new BSONSymbol(${n(this.value,s)})`}},Wn=y,Q=class e extends Wn{get _bsontype(){return"Timestamp"}constructor(t){if(t==null)super(0,0,!0);else if(typeof t=="bigint")super(t,!0);else if(y.isLong(t))super(t.low,t.high,!0);else if(typeof t=="object"&&"t"in t&&"i"in t){if(typeof t.t!="number"&&(typeof t.t!="object"||t.t._bsontype!=="Int32"))throw new a("Timestamp constructed from { t, i } must provide t as a number");if(typeof t.i!="number"&&(typeof t.i!="object"||t.i._bsontype!=="Int32"))throw new a("Timestamp constructed from { t, i } must provide i as a number");let s=Number(t.t),n=Number(t.i);if(s<0||Number.isNaN(s))throw new a("Timestamp constructed from { t, i } must provide a positive t");if(n<0||Number.isNaN(n))throw new a("Timestamp constructed from { t, i } must provide a positive i");if(s>4294967295)throw new a("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n>4294967295)throw new a("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(n,s,!0)}else throw new a("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }")}toJSON(){return{$timestamp:this.toString()}}static fromInt(t){return new e(y.fromInt(t,!0))}static fromNumber(t){return new e(y.fromNumber(t,!0))}static fromBits(t,s){return new e({i:t,t:s})}static fromString(t,s){return new e(y.fromString(t,!0,s))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(t){let s=y.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,n=y.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new e({t:n,i:s})}inspect(t,s,n){n??=F;let r=n(this.high>>>0,s),o=n(this.low>>>0,s);return`new Timestamp({ t: ${r}, i: ${o} })`}};Q.MAX_VALUE=y.MAX_UNSIGNED_VALUE;var Yn=y.fromNumber(Ee),kn=y.fromNumber(Te);function He(e,t,s){t=t??{};let n=t&&t.index?t.index:0,r=e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24;if(r<5)throw new a(`bson size must be >= 5, is ${r}`);if(t.allowObjectSmallerThanBufferSize&&e.length= bson size ${r}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==r)throw new a(`buffer length ${e.length} must === bson size ${r}`);if(r+n>e.byteLength)throw new a(`(bson size ${r} + options.index ${n} must be <= buffer length ${e.byteLength})`);if(e[n+r-1]!==0)throw new a("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return Ot(e,n,t,s)}var qn=/^\$ref$|^\$id$|^\$db$/;function Ot(e,t,s,n=!1){let r=s.fieldsAsRaw==null?null:s.fieldsAsRaw,o=s.raw==null?!1:s.raw,c=typeof s.bsonRegExp=="boolean"?s.bsonRegExp:!1,g=s.promoteBuffers??!1,i=s.promoteLongs??!0,S=s.promoteValues??!0,u=s.useBigInt64??!1;if(u&&!S)throw new a("Must either request bigint or Long for int64 deserialization");if(u&&!i)throw new a("Must either request bigint or Long for int64 deserialization");let f=s.validation==null?{utf8:!0}:s.validation,h=!0,N,p=new Set,E=f.utf8;if(typeof E=="boolean")N=E;else{h=!1;let T=Object.keys(E).map(function(O){return E[O]});if(T.length===0)throw new a("UTF-8 validation setting cannot be empty");if(typeof T[0]!="boolean")throw new a("Invalid UTF-8 validation option, must specify boolean values");if(N=T[0],!T.every(O=>O===N))throw new a("Invalid UTF-8 validation option - keys must be all true or all false")}if(!h)for(let T of Object.keys(E))p.add(T);let $=t;if(e.length<5)throw new a("corrupt bson message < 5 bytes long");let D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(D<5||D>e.length)throw new a("corrupt bson message");let A=n?[]:{},x=0,B=!1,R=n?!1:null,Nt=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;!B;){let T=e[t++];if(T===0)break;let O=t;for(;e[O]!==0&&O=e.byteLength)throw new a("Bad BSON Document: illegal CString");let d=n?x++:l.toUTF8(e,t,O,!1),L=!0;h||p.has(d)?L=N:L=!N,R!==!1&&d[0]==="$"&&(R=qn.test(d));let w;if(t=O+1,T===Ie){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");w=l.toUTF8(e,t,t+m-1,L),t=t+m}else if(T===Ae){let m=l.allocate(12);m.set(e.subarray(t,t+12)),w=new k(m),t=t+12}else if(T===at&&S===!1)w=new X(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(T===at)w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(T===bt&&S===!1)w=new G(Nt.getFloat64(t,!0)),t=t+8;else if(T===bt)w=Nt.getFloat64(t,!0),t=t+8;else if(T===_e){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;w=new Date(new y(m,b).toNumber())}else if(T===$e){if(e[t]!==0&&e[t]!==1)throw new a("illegal boolean type value");w=e[t++]===1}else if(T===ee){let m=t,b=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(b<=0||b>e.length-t)throw new a("bad embedded document length in bson");if(o)w=e.slice(t,t+b);else{let I=s;h||(I={...s,validation:{utf8:L}}),w=Ot(e,m,I,!1)}t=t+b}else if(T===de){let m=t,b=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,I=s,z=t+b;if(r&&r[d]&&(I={...s,raw:!0}),h||(I={...I,validation:{utf8:L}}),w=Ot(e,m,I,!0),t=t+b,e[t-1]!==0)throw new a("invalid array terminator byte");if(t!==z)throw new a("corrupted array bson")}else if(T===cn)w=void 0;else if(T===se)w=null;else if(T===ie){let m=ut.fromUint8Array(e.subarray(t,t+8)),b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,I=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,z=new y(b,I);u?w=m.getBigInt64(0,!0):i&&S===!0?w=z.lessThanOrEqual(Yn)&&z.greaterThanOrEqual(kn)?z.toNumber():z:w=z}else if(T===De){let m=l.allocate(16);m.set(e.subarray(t,t+16),0),t=t+16,w=new nt(m)}else if(T===ne){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,b=m,I=e[t++];if(m<0)throw new a("Negative binary type element size found");if(m>e.byteLength)throw new a("Binary type size larger than document size");if(e.slice!=null){if(I===_.SUBTYPE_BYTE_ARRAY){if(m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,m<0)throw new a("Negative binary type element size found for subtype 0x02");if(m>b-4)throw new a("Binary type with subtype 0x02 contains too long binary size");if(mb-4)throw new a("Binary type with subtype 0x02 contains too long binary size");if(m=e.length)throw new a("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,O,!1);for(t=O+1,O=t;e[O]!==0&&O=e.length)throw new a("Bad BSON Document: illegal CString");let b=l.toUTF8(e,t,O,!1);t=O+1;let I=new Array(b.length);for(O=0;O=e.length)throw new a("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,O,!1);for(t=O+1,O=t;e[O]!==0&&O=e.length)throw new a("Bad BSON Document: illegal CString");let b=l.toUTF8(e,t,O,!1);t=O+1,w=new q(m,b)}else if(T===Ue){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");let b=l.toUTF8(e,t,t+m-1,L);w=S?b:new it(b),t=t+m}else if(T===Re){let m=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*16777216,b=e[t++]+e[t++]*256+e[t++]*65536+e[t++]*(1<<24);w=new Q({i:m,t:b})}else if(T===je)w=new rt;else if(T===ze)w=new st;else if(T===re){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");let b=l.toUTF8(e,t,t+m-1,L);w=new Y(b),t=t+m}else if(T===Le){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<4+4+4+1)throw new a("code_w_scope total size shorter minimum expected length");let b=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(b<=0||b>e.length-t||e[t+b-1]!==0)throw new a("bad string length in bson");let I=l.toUTF8(e,t,t+b-1,L);t=t+b;let z=t,_t=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,Qe=Ot(e,z,s,!1);if(t=t+_t,m<4+4+_t+b)throw new a("code_w_scope total size is too short, truncating scope");if(m>4+4+_t+b)throw new a("code_w_scope total size is too long, clips outer document");w=new Y(I,Qe)}else if(T===hn){let m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<=0||m>e.length-t||e[t+m-1]!==0)throw new a("bad string length in bson");if(f!=null&&f.utf8&&!Me(e,t,t+m-1))throw new a("Invalid UTF-8 string in BSON document");let b=l.toUTF8(e,t,t+m-1,!1);t=t+m;let I=l.allocate(12);I.set(e.subarray(t,t+12),0);let z=new k(I);t=t+12,w=new C(b,z)}else throw new a(`Detected unknown BSON type ${T.toString(16)} for fieldname "${d}"`);d==="__proto__"?Object.defineProperty(A,d,{value:w,writable:!0,enumerable:!0,configurable:!0}):A[d]=w}if(D!==t-$)throw n?new a("corrupt array bson"):new a("corrupt object bson");if(!R)return A;if(Je(A)){let T=Object.assign({},A);return delete T.$ref,delete T.$id,delete T.$db,new C(A.$ref,A.$id,A.$db,T)}return A}var It=/\x00/,Ne=new Set(["$db","$ref","$id","$clusterTime"]);function Dt(e,t,s,n){e[n++]=Ie;let r=l.encodeUTF8Into(e,t,n);n=n+r+1,e[n-1]=0;let o=l.encodeUTF8Into(e,s,n+4);return e[n+3]=o+1>>24&255,e[n+2]=o+1>>16&255,e[n+1]=o+1>>8&255,e[n]=o+1&255,n=n+4+o,e[n++]=0,n}var mt=new DataView(new ArrayBuffer(8),0,8),Zn=new Uint8Array(mt.buffer,0,4),dt=new Uint8Array(mt.buffer,0,8);function jt(e,t,s,n){let o=!Object.is(s,-0)&&Number.isSafeInteger(s)&&s<=At&&s>=$t?at:bt;o===at?mt.setInt32(0,s,!0):mt.setFloat64(0,s,!0);let c=o===at?Zn:dt;e[n++]=o;let g=l.encodeUTF8Into(e,t,n);return n=n+g,e[n++]=0,e.set(c,n),n+=c.byteLength,n}function zt(e,t,s,n){e[n++]=ie;let r=l.encodeUTF8Into(e,t,n);return n+=r,e[n++]=0,mt.setBigInt64(0,s,!0),e.set(dt,n),n+=dt.byteLength,n}function pt(e,t,s,n){e[n++]=se;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,n}function Ft(e,t,s,n){e[n++]=$e;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e[n++]=s?1:0,n}function Mt(e,t,s,n){e[n++]=_e;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=y.fromNumber(s.getTime()),c=o.getLowBits(),g=o.getHighBits();return e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,e[n++]=g&255,e[n++]=g>>8&255,e[n++]=g>>16&255,e[n++]=g>>24&255,n}function xt(e,t,s,n){e[n++]=Et;let r=l.encodeUTF8Into(e,t,n);if(n=n+r,e[n++]=0,s.source&&s.source.match(It)!=null)throw new a("value "+s.source+" must not contain null bytes");return n=n+l.encodeUTF8Into(e,s.source,n),e[n++]=0,s.ignoreCase&&(e[n++]=105),s.global&&(e[n++]=115),s.multiline&&(e[n++]=109),e[n++]=0,n}function Jt(e,t,s,n){e[n++]=Et;let r=l.encodeUTF8Into(e,t,n);if(n=n+r,e[n++]=0,s.pattern.match(It)!=null)throw new a("pattern "+s.pattern+" must not contain null bytes");n=n+l.encodeUTF8Into(e,s.pattern,n),e[n++]=0;let o=s.options.split("").sort().join("");return n=n+l.encodeUTF8Into(e,o,n),e[n++]=0,n}function Ct(e,t,s,n){s===null?e[n++]=se:s._bsontype==="MinKey"?e[n++]=je:e[n++]=ze;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,n}function Ht(e,t,s,n){e[n++]=Ae;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.id;if(tt(o))for(let c=0;c<12;c++)e[n++]=o[c];else throw new a("object ["+JSON.stringify(s)+"] is not a valid ObjectId");return n}function Vt(e,t,s,n){e[n++]=ne;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.length;return e[n++]=o&255,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=an,e.set(s,n),n=n+o,n}function Pt(e,t,s,n,r,o,c,g,i){if(i.has(s))throw new a("Cannot convert circular structure to BSON");i.add(s),e[n++]=Array.isArray(s)?de:ee;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=St(e,s,r,n,o+1,c,g,i);return i.delete(s),u}function Wt(e,t,s,n){e[n++]=De;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e.set(s.bytes.subarray(0,16),n),n+16}function Yt(e,t,s,n){e[n++]=s._bsontype==="Long"?ie:Re;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.getLowBits(),c=s.getHighBits();return e[n++]=o&255,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,n}function kt(e,t,s,n){s=s.valueOf(),e[n++]=at;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,e[n++]=s&255,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,n}function qt(e,t,s,n){e[n++]=bt;let r=l.encodeUTF8Into(e,t,n);return n=n+r,e[n++]=0,mt.setFloat64(0,s.value,!0),e.set(dt,n),n=n+8,n}function Zt(e,t,s,n){e[n++]=re;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.toString(),c=l.encodeUTF8Into(e,o,n+4)+1;return e[n]=c&255,e[n+1]=c>>8&255,e[n+2]=c>>16&255,e[n+3]=c>>24&255,n=n+4+c-1,e[n++]=0,n}function Kt(e,t,s,n,r=!1,o=0,c=!1,g=!0,i){if(s.scope&&typeof s.scope=="object"){e[n++]=Le;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=n,f=s.code;n=n+4;let h=l.encodeUTF8Into(e,f,n+4)+1;e[n]=h&255,e[n+1]=h>>8&255,e[n+2]=h>>16&255,e[n+3]=h>>24&255,e[n+4+h-1]=0,n=n+h+4;let N=St(e,s.scope,r,n,o+1,c,g,i);n=N-1;let p=N-u;e[u++]=p&255,e[u++]=p>>8&255,e[u++]=p>>16&255,e[u++]=p>>24&255,e[n++]=0}else{e[n++]=re;let S=l.encodeUTF8Into(e,t,n);n=n+S,e[n++]=0;let u=s.code.toString(),f=l.encodeUTF8Into(e,u,n+4)+1;e[n]=f&255,e[n+1]=f>>8&255,e[n+2]=f>>16&255,e[n+3]=f>>24&255,n=n+4+f-1,e[n++]=0}return n}function Gt(e,t,s,n){e[n++]=ne;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=s.buffer,c=s.position;return s.sub_type===_.SUBTYPE_BYTE_ARRAY&&(c=c+4),e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255,e[n++]=s.sub_type,s.sub_type===_.SUBTYPE_BYTE_ARRAY&&(c=c-4,e[n++]=c&255,e[n++]=c>>8&255,e[n++]=c>>16&255,e[n++]=c>>24&255),e.set(o,n),n=n+s.position,n}function Xt(e,t,s,n){e[n++]=Ue;let r=l.encodeUTF8Into(e,t,n);n=n+r,e[n++]=0;let o=l.encodeUTF8Into(e,s.value,n+4)+1;return e[n]=o&255,e[n+1]=o>>8&255,e[n+2]=o>>16&255,e[n+3]=o>>24&255,n=n+4+o-1,e[n++]=0,n}function Qt(e,t,s,n,r,o,c){e[n++]=ee;let g=l.encodeUTF8Into(e,t,n);n=n+g,e[n++]=0;let i=n,S={$ref:s.collection||s.namespace,$id:s.oid};s.db!=null&&(S.$db=s.db),S=Object.assign(S,s.fields);let u=St(e,S,!1,n,r+1,o,!0,c),f=u-i;return e[i++]=f&255,e[i++]=f>>8&255,e[i++]=f>>16&255,e[i++]=f>>24&255,u}function St(e,t,s,n,r,o,c,g){if(g==null){if(t==null)return e[0]=5,e[1]=0,e[2]=0,e[3]=0,e[4]=0,5;if(Array.isArray(t))throw new a("serialize does not support an array as the root input");if(typeof t!="object")throw new a("serialize does not support non-object as the root input");if("_bsontype"in t&&typeof t._bsontype=="string")throw new a("BSON types cannot be serialized as a document");if(ct(t)||lt(t)||tt(t)||vt(t))throw new a("date, regexp, typedarray, and arraybuffer cannot be BSON documents");g=new Set}g.add(t);let i=n+4;if(Array.isArray(t))for(let u=0;u>8&255,e[n++]=S>>16&255,e[n++]=S>>24&255,i}function Kn(e){return e!=null&&typeof e=="object"&&"_bsontype"in e&&typeof e._bsontype=="string"}var Gn={$oid:k,$binary:_,$uuid:_,$symbol:it,$numberInt:X,$numberDecimal:nt,$numberDouble:G,$numberLong:y,$minKey:rt,$maxKey:st,$regex:q,$regularExpression:q,$timestamp:Q};function Ve(e,t={}){if(typeof e=="number"){let n=e<=At&&e>=$t,r=e<=Oe&&e>=be;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(n)return new X(e);if(r)return t.useBigInt64?BigInt(e):y.fromNumber(e)}return new G(e)}if(e==null||typeof e!="object")return e;if(e.$undefined)return null;let s=Object.keys(e).filter(n=>n.startsWith("$")&&e[n]!=null);for(let n=0;nc.startsWith("$")),o=!0;if(r.forEach(c=>{["$ref","$id","$db"].indexOf(c)===-1&&(o=!1)}),o)return C.fromExtendedJSON(n)}return e}function Xn(e,t){return e.map((s,n)=>{t.seenObjects.push({propertyName:`index ${n}`,obj:null});try{return V(s,t)}finally{t.seenObjects.pop()}})}function Be(e){let t=e.toISOString();return e.getUTCMilliseconds()!==0?t:t.slice(0,-5)+"Z"}function V(e,t){if(e instanceof Map||te(e)){let s=Object.create(null);for(let[n,r]of e){if(typeof n!="string")throw new a("Can only serialize maps with string keys");s[n]=r}return V(s,t)}if((typeof e=="object"||typeof e=="function")&&e!==null){let s=t.seenObjects.findIndex(n=>n.obj===e);if(s!==-1){let n=t.seenObjects.map(u=>u.propertyName),r=n.slice(0,s).map(u=>`${u} -> `).join(""),o=n[s],c=" -> "+n.slice(s+1,n.length-1).map(u=>`${u} -> `).join(""),g=n[n.length-1],i=" ".repeat(r.length+o.length/2),S="-".repeat(c.length+(o.length+g.length)/2-1);throw new a(`Converting circular structure to EJSON: - ${r}${o}${c}${g} - ${i}\\${S}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return Xn(e,t);if(e===void 0)return null;if(e instanceof Date||ct(e)){let s=e.getTime(),n=s>-1&&s<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:Be(e)}:t.relaxed&&n?{$date:Be(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(typeof e=="number"&&(!t.relaxed||!isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=$t&&e<=At)return{$numberInt:e.toString()};if(e>=be&&e<=Oe)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if(typeof e=="bigint")return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||lt(e)){let s=e.flags;if(s===void 0){let r=e.toString().match(/[gimuy]*$/);r&&(s=r[0])}return new q(e.source,s).toExtendedJSON(t)}return e!=null&&typeof e=="object"?vn(e,t):e}var Qn={Binary:e=>new _(e.value(),e.sub_type),Code:e=>new Y(e.code,e.scope),DBRef:e=>new C(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new nt(e.bytes),Double:e=>new G(e.value),Int32:e=>new X(e.value),Long:e=>y.fromBits(e.low!=null?e.low:e.low_,e.low!=null?e.high:e.high_,e.low!=null?e.unsigned:e.unsigned_),MaxKey:()=>new st,MinKey:()=>new rt,ObjectId:e=>new k(e),BSONRegExp:e=>new q(e.pattern,e.options),BSONSymbol:e=>new it(e.value),Timestamp:e=>Q.fromBits(e.low,e.high)};function vn(e,t){if(e==null||typeof e!="object")throw new a("not an object instance");let s=e._bsontype;if(typeof s>"u"){let n={};for(let r of Object.keys(e)){t.seenObjects.push({propertyName:r,obj:null});try{let o=V(e[r],t);r==="__proto__"?Object.defineProperty(n,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):n[r]=o}finally{t.seenObjects.pop()}}return n}else{if(e!=null&&typeof e=="object"&&typeof e._bsontype=="string"&&e[Symbol.for("@@mdb.bson.version")]!==et)throw new P;if(Kn(e)){let n=e;if(typeof n.toExtendedJSON!="function"){let r=Qn[e._bsontype];if(!r)throw new a("Unrecognized or invalid _bsontype: "+e._bsontype);n=r(n)}return s==="Code"&&n.scope?n=new Y(n.code,V(n.scope,t)):s==="DBRef"&&n.oid&&(n=new C(V(n.collection,t),V(n.oid,t),V(n.db,t),V(n.fields,t))),n.toExtendedJSON(t)}else throw new a("_bsontype must be a string, but was: "+typeof s)}}function Pe(e,t){let s={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,(n,r)=>{if(n.indexOf("\0")!==-1)throw new a(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(n)}`);return Ve(r,s)})}function We(e,t,s,n){s!=null&&typeof s=="object"&&(n=s,s=0),t!=null&&typeof t=="object"&&!Array.isArray(t)&&(n=t,t=void 0,s=0);let r=Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}),o=V(e,r);return JSON.stringify(o,t,s)}function ts(e,t){return t=t||{},JSON.parse(We(e,t))}function es(e,t){return t=t||{},Pe(JSON.stringify(e),t)}var ot=Object.create(null);ot.parse=Pe;ot.stringify=We;ot.serialize=ts;ot.deserialize=es;Object.freeze(ot);var Ye=1024*1024*17,K=l.allocate(Ye);function ke(e){K.lengthss,toJson:()=>rs});var ss=oe().deserialize,rs=oe().EJSON.deserialize;return fn(is);})(); +"use strict";var bson=(()=>{var At=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var fn=Object.getOwnPropertyNames;var ln=Object.prototype.hasOwnProperty;var cn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var hn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gn=(e,t)=>{for(var r in t)At(e,r,{get:t[r],enumerable:!0})},un=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of fn(t))!ln.call(e,i)&&i!==r&&At(e,i,{get:()=>t[i],enumerable:!(n=on(t,i))||n.enumerable});return e};var an=e=>un(At({},"__esModule",{value:!0}),e);var le=hn(U=>{"use strict";function te(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function ht(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}function gt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function ee(e){return Object.prototype.toString.call(e)==="[object Map]"}function ut(e){return Object.prototype.toString.call(e)==="[object Date]"}function F(e,t){return JSON.stringify(e,(r,n)=>typeof n=="bigint"?{$numberLong:`${n}`}:ee(n)?Object.fromEntries(n):n)}function mn(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}var rt=6,Bt=2147483647,Et=-2147483648,Te=Math.pow(2,63)-1,Le=-Math.pow(2,63),$e=Math.pow(2,53),Ae=-Math.pow(2,53),ne=1,Ue=2,re=3,_e=4,ie=5,yn=6,De=7,Re=8,ze=9,se=10,Tt=11,wn=12,oe=13,je=14,Me=15,St=16,xe=17,fe=18,Fe=19,Je=255,Ce=127,pn=0,Lt=4,Pe=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127}),c=class extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,r){super(t,r)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}},k=class extends c{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${rt}.x.x`)}},yt=class extends c{get name(){return"BSONRuntimeError"}constructor(t){super(t)}},C=class extends c{get name(){return"BSONOffsetError"}constructor(t,r,n){super(`${t}. offset: ${r}`,n),this.offset=r}},ce,he;function He(e,t,r,n){if(n){ce??=new TextDecoder("utf8",{fatal:!0});try{return ce.decode(e.subarray(t,r))}catch(i){throw new c("Invalid UTF-8 string in BSON document",{cause:i})}}return he??=new TextDecoder("utf8",{fatal:!1}),he.decode(e.subarray(t,r))}function Ve(e,t,r){if(e.length===0)return"";let n=r-t;if(n===0)return"";if(n>20)return null;if(n===1&&e[t]<128)return String.fromCharCode(e[t]);if(n===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(n===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);let i=[];for(let o=t;o127)return null;i.push(h)}return String.fromCharCode(...i)}function bn(e,t,r){if(t.length===0)return 0;if(t.length>25||e.length-r127)return null;e[i]=o}return t.length}function Sn(e){return X.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}var Nn=(()=>{try{return cn("crypto").randomBytes}catch{return Sn}})(),X={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new c(`Cannot create Buffer from ${String(e)}`)},allocate(e){return Buffer.alloc(e)},allocateUnsafe(e){return Buffer.allocUnsafe(e)},equals(e,t){return X.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return X.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return X.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return X.toLocalBufferType(e).toString("hex")},toUTF8(e,t,r,n){let i=r-t<=20?Ve(e,t,r):null;if(i!=null)return i;let o=X.toLocalBufferType(e).toString("utf8",t,r);if(n){for(let h=0;hMath.floor(Math.random()*256)))}var On=(()=>{let{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(Nt.allocate(t));if(Bn()){let{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return En})(),ge=/(\d|[a-f])/i,Nt={toLocalBufferType(e){let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new c(`Cannot make a Uint8Array from ${String(e)}`)},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe(e){return Nt.allocate(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let r=0;rt.charCodeAt(0))},toBase64(e){return btoa(Nt.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){let t=e.length%2===0?e:e.slice(0,e.length-1),r=[];for(let n=0;nt.toString(16).padStart(2,"0")).join("")},toUTF8(e,t,r,n){let i=r-t<=20?Ve(e,t,r):null;return i??He(e,t,r,n)},utf8ByteLength(e){return new TextEncoder().encode(e).byteLength},encodeUTF8Into(e,t,r){let n=new TextEncoder().encode(t);return e.set(n,r),n.byteLength},randomBytes:On},In=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0,l=In?X:Nt,x=class{get[Symbol.for("@@mdb.bson.version")](){return rt}[Symbol.for("nodejs.util.inspect.custom")](t,r,n){return this.inspect(t,r,n)}},_=class e extends x{get _bsontype(){return"Binary"}constructor(t,r){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!te(t)&&!Array.isArray(t))throw new c("Binary can only be constructed from Uint8Array or number[]");this.sub_type=r??e.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=l.allocate(e.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?l.fromNumberArray(t):l.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new c("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new c("only accepts single character Uint8Array or Array");let r;if(typeof t=="string"?r=t.charCodeAt(0):typeof t=="number"?r=t:r=t[0],r<0||r>255)throw new c("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=r;else{let n=l.allocate(e.BUFFER_SIZE+this.buffer.length);n.set(this.buffer,0),this.buffer=n,this.buffer[this.position++]=r}}write(t,r){if(r=typeof r=="number"?r:this.position,this.buffer.byteLengththis.position?r+t.length:this.position;else if(typeof t=="string")throw new c("input cannot be string")}read(t,r){return r=r&&r>0?r:this.position,this.buffer.slice(t,t+r)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return l.toBase64(this.buffer.subarray(0,this.position))}toString(t){return t==="hex"?l.toHex(this.buffer.subarray(0,this.position)):t==="base64"?l.toBase64(this.buffer.subarray(0,this.position)):t==="utf8"||t==="utf-8"?l.toUTF8(this.buffer,0,this.position,!1):l.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(t){t=t||{};let r=l.toBase64(this.buffer),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:r,$type:n.length===1?"0"+n:n}:{$binary:{base64:r,subType:n.length===1?"0"+n:n}}}toUUID(){if(this.sub_type===e.SUBTYPE_UUID)return new Y(this.buffer.slice(0,this.position));throw new c(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${e.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,r){return new e(l.fromHex(t),r)}static createFromBase64(t,r){return new e(l.fromBase64(t),r)}static fromExtendedJSON(t,r){r=r||{};let n,i;if("$binary"in t?r.legacy&&typeof t.$binary=="string"&&"$type"in t?(i=t.$type?parseInt(t.$type,16):0,n=l.fromBase64(t.$binary)):typeof t.$binary!="string"&&(i=t.$binary.subType?parseInt(t.$binary.subType,16):0,n=l.fromBase64(t.$binary.base64)):"$uuid"in t&&(i=4,n=Y.bytesFromString(t.$uuid)),!n)throw new c(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return i===Lt?new Y(n):new e(n,i)}inspect(t,r,n){n??=F;let i=l.toBase64(this.buffer.subarray(0,this.position)),o=n(i,r),h=n(this.sub_type,r);return`Binary.createFromBase64(${o}, ${h})`}};_.BSON_BINARY_SUBTYPE_DEFAULT=0;_.BUFFER_SIZE=256;_.SUBTYPE_DEFAULT=0;_.SUBTYPE_FUNCTION=1;_.SUBTYPE_BYTE_ARRAY=2;_.SUBTYPE_UUID_OLD=3;_.SUBTYPE_UUID=4;_.SUBTYPE_MD5=5;_.SUBTYPE_ENCRYPTED=6;_.SUBTYPE_COLUMN=7;_.SUBTYPE_SENSITIVE=8;_.SUBTYPE_USER_DEFINED=128;var Ut=16,dn=/^[0-9A-F]{32}$/i,Tn=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,Y=class e extends _{constructor(t){let r;if(t==null)r=e.generate();else if(t instanceof e)r=l.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===Ut)r=l.toLocalBufferType(t);else if(typeof t=="string")r=e.bytesFromString(t);else throw new c("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(r,Lt)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[l.toHex(this.buffer.subarray(0,4)),l.toHex(this.buffer.subarray(4,6)),l.toHex(this.buffer.subarray(6,8)),l.toHex(this.buffer.subarray(8,10)),l.toHex(this.buffer.subarray(10,16))].join("-"):l.toHex(this.buffer)}toString(t){return t==="hex"?l.toHex(this.id):t==="base64"?l.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof e)return l.equals(t.id,this.id);try{return l.equals(new e(t).id,this.id)}catch{return!1}}toBinary(){return new _(this.id,_.SUBTYPE_UUID)}static generate(){let t=l.randomBytes(Ut);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?e.isValidUUIDString(t):ht(t)?t.byteLength===Ut:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){let r=e.bytesFromString(t);return new e(r)}static createFromBase64(t){return new e(l.fromBase64(t))}static bytesFromString(t){if(!e.isValidUUIDString(t))throw new c("UUID string representation must be 32 hex digits or canonical hyphenated representation");return l.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return dn.test(t)||Tn.test(t)}inspect(t,r,n){return n??=F,`new UUID(${n(this.toHexString(),r)})`}},q=class e extends x{get _bsontype(){return"Code"}constructor(t,r){super(),this.code=t.toString(),this.scope=r??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new e(t.$code,t.$scope)}inspect(t,r,n){n??=F;let i=n(this.code,r),o=i.includes(` +`);this.scope!=null&&(i+=`,${o?` +`:" "}${n(this.scope,r)}`);let h=o&&this.scope===null;return`new Code(${o?` +`:""}${i}${h?` +`:""})`}};function We(e){return e!=null&&typeof e=="object"&&"$id"in e&&e.$id!=null&&"$ref"in e&&typeof e.$ref=="string"&&(!("$db"in e)||"$db"in e&&typeof e.$db=="string")}var V=class e extends x{get _bsontype(){return"DBRef"}constructor(t,r,n,i){super();let o=t.split(".");o.length===2&&(n=o.shift(),t=o.shift()),this.collection=t,this.oid=r,this.db=n,this.fields=i||{}}get namespace(){return this.collection}set namespace(t){this.collection=t}toJSON(){let t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(t.$db=this.db),t}toExtendedJSON(t){t=t||{};let r={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(r.$db=this.db),r=Object.assign(r,this.fields)),r}static fromExtendedJSON(t){let r=Object.assign({},t);return delete r.$ref,delete r.$id,delete r.$db,new e(t.$ref,t.$id,t.$db,r)}inspect(t,r,n){n??=F;let i=[n(this.namespace,r),n(this.oid,r),...this.db?[n(this.db,r)]:[],...Object.keys(this.fields).length>0?[n(this.fields,r)]:[]];return i[1]=n===F?`new ObjectId(${i[1]})`:i[1],`new DBRef(${i.join(", ")})`}};function ke(e){if(e==="")return e;let t=0,r=e[t]==="-",n=e[t]==="+";(n||r)&&(t+=1);let i=!1;for(;t>>=0,(o=0<=t&&t<256)&&(i=ye[t],i)?i:(n=e.fromBits(t,(t|0)<0?-1:0,!0),o&&(ye[t]=n),n)):(t|=0,(o=-128<=t&&t<128)&&(i=me[t],i)?i:(n=e.fromBits(t,t<0?-1:0,!1),o&&(me[t]=n),n))}static fromNumber(t,r){if(isNaN(t))return r?e.UZERO:e.ZERO;if(r){if(t<0)return e.UZERO;if(t>=Ye)return e.MAX_UNSIGNED_VALUE}else{if(t<=-ae)return e.MIN_VALUE;if(t+1>=ae)return e.MAX_VALUE}return t<0?e.fromNumber(-t,r).neg():e.fromBits(t%at|0,t/at|0,r)}static fromBigInt(t,r){let n=BigInt(4294967295),i=BigInt(32);return new e(Number(t&n),Number(t>>i&n),r)}static _fromString(t,r,n){if(t.length===0)throw new c("empty string");if(n<2||360)throw new c("interior hyphen");if(i===0)return e._fromString(t.substring(1),r,n).neg();let o=e.fromNumber(Math.pow(n,8)),h=e.ZERO;for(let u=0;u>>16,n=this.high&65535,i=this.low>>>16,o=this.low&65535,h=t.high>>>16,u=t.high&65535,s=t.low>>>16,S=t.low&65535,a=0,f=0,g=0,p=0;return p+=o+S,g+=p>>>16,p&=65535,g+=i+s,f+=g>>>16,g&=65535,f+=n+u,a+=f>>>16,f&=65535,a+=r+h,a&=65535,e.fromBits(g<<16|p,a<<16|f,this.unsigned)}and(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;let r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1}comp(t){return this.compare(t)}divide(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new c("division by zero");if(J){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;let o=(this.unsigned?J.div_u:J.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(o,J.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;let r,n,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;i=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(r=this.shr(1).div(t).shl(1),r.eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(n=this.sub(t.mul(r)),i=r.add(n.div(t)),i));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=e.ZERO}for(n=this;n.gte(t);){r=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));let o=Math.ceil(Math.log(r)/Math.LN2),h=o<=48?1:Math.pow(2,o-48),u=e.fromNumber(r),s=u.mul(t);for(;s.isNegative()||s.gt(n);)r-=h,u=e.fromNumber(r,this.unsigned),s=u.mul(t);u.isZero()&&(u=e.ONE),i=i.add(u),n=n.sub(s)}return i}div(t){return this.divide(t)}equals(t){return e.isLong(t)||(t=e.fromValue(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low}eq(t){return this.equals(t)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();let t=this.high!==0?this.high:this.low,r;for(r=31;r>0&&!(t&1<0}gt(t){return this.greaterThan(t)}greaterThanOrEqual(t){return this.comp(t)>=0}gte(t){return this.greaterThanOrEqual(t)}ge(t){return this.greaterThanOrEqual(t)}isEven(){return(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(t){return this.comp(t)<0}lt(t){return this.lessThan(t)}lessThanOrEqual(t){return this.comp(t)<=0}lte(t){return this.lessThanOrEqual(t)}modulo(t){if(e.isLong(t)||(t=e.fromValue(t)),J){let r=(this.unsigned?J.rem_u:J.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(r,J.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))}mod(t){return this.modulo(t)}rem(t){return this.modulo(t)}multiply(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),J){let w=J.mul(this.low,this.high,t.low,t.high);return e.fromBits(w,J.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);let r=this.high>>>16,n=this.high&65535,i=this.low>>>16,o=this.low&65535,h=t.high>>>16,u=t.high&65535,s=t.low>>>16,S=t.low&65535,a=0,f=0,g=0,p=0;return p+=o*S,g+=p>>>16,p&=65535,g+=i*S,f+=g>>>16,g&=65535,g+=o*s,f+=g>>>16,g&=65535,f+=n*S,a+=f>>>16,f&=65535,f+=i*s,a+=f>>>16,f&=65535,f+=o*u,a+=f>>>16,f&=65535,a+=r*S+n*s+i*u+o*h,a&=65535,e.fromBits(g<<16|p,a<<16|f,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)}neg(){return this.negate()}not(){return e.fromBits(~this.low,~this.high,this.unsigned)}notEquals(t){return!this.equals(t)}neq(t){return this.notEquals(t)}ne(t){return this.notEquals(t)}or(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low<>>32-t,this.unsigned):e.fromBits(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(e.isLong(t)&&(t=t.toInt()),t&=63,t===0)return this;{let r=this.high;if(t<32){let n=this.low;return e.fromBits(n>>>t|r<<32-t,r>>>t,this.unsigned)}else return t===32?e.fromBits(r,0,this.unsigned):e.fromBits(r>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())}sub(t){return this.subtract(t)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*at+(this.low>>>0):this.high*at+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){let t=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]}toBytesBE(){let t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255]}toSigned(){return this.unsigned?e.fromBits(this.low,this.high,!1):this}toString(t){if(t=t||10,t<2||36>>0).toString(t);if(n=o,n.isZero())return u+i;for(;u.length<6;)u="0"+u;i=""+u+i}}toUnsigned(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)}xor(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)}eqz(){return this.isZero()}le(t){return this.lessThanOrEqual(t)}toExtendedJSON(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(t,r){let{useBigInt64:n=!1,relaxed:i=!0}={...r};if(t.$numberLong.length>An)throw new c("$numberLong string is too long");if(!Un.test(t.$numberLong))throw new c(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(n){let h=BigInt(t.$numberLong);return BigInt.asIntN(64,h)}let o=e.fromString(t.$numberLong);return i?o.toNumber():o}inspect(t,r,n){n??=F;let i=n(this.toString(),r),o=this.unsigned?`, ${n(this.unsigned,r)}`:"";return`new Long(${i}${o})`}};y.TWO_PWR_24=y.fromInt($n);y.MAX_UNSIGNED_VALUE=y.fromBits(-1,-1,!0);y.ZERO=y.fromInt(0);y.UZERO=y.fromInt(0,!0);y.ONE=y.fromInt(1);y.UONE=y.fromInt(1,!0);y.NEG_ONE=y.fromInt(-1);y.MAX_VALUE=y.fromBits(-1,2147483647,!1);y.MIN_VALUE=y.fromBits(0,-2147483648,!1);var _n=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Dn=/^(\+|-)?(Infinity|inf)$/i,Rn=/^(\+|-)?NaN$/i,ct=6111,pt=-6176,we=6176,pe=34,_t=l.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),be=l.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Se=l.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),zn=/^([-+])?(\d+)?$/,jn=31,Ne=16383,Mn=30,xn=31;function Be(e){return!isNaN(parseInt(e,10))}function Fn(e){let t=y.fromNumber(1e9),r=y.fromNumber(0);if(!e.parts[0]&&!e.parts[1]&&!e.parts[2]&&!e.parts[3])return{quotient:e,rem:r};for(let n=0;n<=3;n++)r=r.shiftLeft(32),r=r.add(new y(e.parts[n],0)),e.parts[n]=r.div(t).low,r=r.modulo(t);return{quotient:e,rem:r}}function Jn(e,t){if(!e&&!t)return{high:y.fromNumber(0),low:y.fromNumber(0)};let r=e.shiftRightUnsigned(32),n=new y(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new y(t.getLowBits(),0),h=r.multiply(i),u=r.multiply(o),s=n.multiply(i),S=n.multiply(o);return h=h.add(u.shiftRightUnsigned(32)),u=new y(u.getLowBits(),0).add(s).add(S.shiftRightUnsigned(32)),h=h.add(u.shiftRightUnsigned(32)),S=u.shiftLeft(32).add(new y(S.getLowBits(),0)),{high:h,low:S}}function Cn(e,t){let r=e.high>>>0,n=t.high>>>0;if(r>>0,o=t.low>>>0;if(i=7e3)throw new c(""+t+" not a valid Decimal128 string");let R=t.match(_n),d=t.match(Dn),E=t.match(Rn);if(!R&&!d&&!E||t.length===0)throw new c(""+t+" not a valid Decimal128 string");if(R){let m=R[2],B=R[4],L=R[5],z=R[6];B&&z===void 0&&H(t,"missing exponent power"),B&&m===void 0&&H(t,"missing exponent base"),B===void 0&&(L||z)&&H(t,"missing e before exponent")}if((t[b]==="+"||t[b]==="-")&&(i=!0,n=t[b++]==="-"),!Be(t[b])&&t[b]!=="."){if(t[b]==="i"||t[b]==="I")return new e(n?be:Se);if(t[b]==="N")return new e(_t)}for(;Be(t[b])||t[b]===".";){if(t[b]==="."){o&&H(t,"contains multiple periods"),o=!0,b=b+1;continue}pD+16384?D=pt:D=D-a;D>ct;){if(I=I+1,I>=pe){if(u===0){D=ct;break}H(t,"overflow")}D=D-1}if(r.allowRounding){for(;D=5&&(L=1,B===5)){L=g[I]%2===1?1:0;for(let z=f+I+2;z=0&&++g[z]>9;z--)if(g[z]=0,z===0)if(D>8&255,N[b++]=T.low.low>>16&255,N[b++]=T.low.low>>24&255,N[b++]=T.low.high&255,N[b++]=T.low.high>>8&255,N[b++]=T.low.high>>16&255,N[b++]=T.low.high>>24&255,N[b++]=T.high.low&255,N[b++]=T.high.low>>8&255,N[b++]=T.high.low>>16&255,N[b++]=T.high.low>>24&255,N[b++]=T.high.high&255,N[b++]=T.high.high>>8&255,N[b++]=T.high.high>>16&255,N[b++]=T.high.high>>24&255,new e(N)}toString(){let t,r=0,n=new Array(36);for(let b=0;b>26&jn;if(M>>3===3){if(M===Mn)return a.join("")+"Infinity";if(M===xn)return"NaN";t=I>>15&Ne,h=8+(I>>14&1)}else h=I>>14&7,t=I>>17&Ne;let $=t-we;if(u.parts[0]=(I&16383)+((h&15)<<14),u.parts[1]=w,u.parts[2]=p,u.parts[3]=g,u.parts[0]===0&&u.parts[1]===0&&u.parts[2]===0&&u.parts[3]===0)o=!0;else for(S=3;S>=0;S--){let b=0,R=Fn(u);if(u=R.quotient,b=R.rem.low,!!b)for(s=8;s>=0;s--)n[S*9+s]=b%10,b=Math.floor(b/10)}if(o)r=1,n[i]=0;else for(r=36;!n[i];)r=r-1,i=i+1;let P=r-1+$;if(P>=34||P<=-7||$>0){if(r>34)return a.push("0"),$>0?a.push(`E+${$}`):$<0&&a.push(`E${$}`),a.join("");a.push(`${n[i++]}`),r=r-1,r&&a.push(".");for(let b=0;b0?a.push(`+${P}`):a.push(`${P}`)}else if($>=0)for(let b=0;b0)for(let R=0;Rn)throw new c(`Input: '${t}' is smaller than the minimum value for Int32`);if(Number.isSafeInteger(n)){if(n.toString()!==r)throw new c(`Input: '${t}' is not a valid Int32 string`)}else throw new c(`Input: '${t}' is not a safe integer`);return new e(n)}valueOf(){return this.value}toString(t){return this.value.toString(t)}toJSON(){return this.value}toExtendedJSON(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(t,r){return r&&r.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)}inspect(t,r,n){return n??=F,`new Int32(${n(this.value,r)})`}},st=class e extends x{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new e}inspect(){return"new MaxKey()"}},ot=class e extends x{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new e}inspect(){return"new MinKey()"}},mt=new Float64Array(1),A=new Uint8Array(mt.buffer,0,8);mt[0]=-1;var Ee=A[7]===0,O={getNonnegativeInt32LE(e,t){if(e[t+3]>127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getInt32LE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getUint32LE(e,t){return e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216},getUint32BE(e,t){return e[t+3]+e[t+2]*256+e[t+1]*65536+e[t]*16777216},getBigInt64LE(e,t){let r=O.getUint32LE(e,t),n=O.getUint32LE(e,t+4);return(BigInt(n)<(A[7]=e[t],A[6]=e[t+1],A[5]=e[t+2],A[4]=e[t+3],A[3]=e[t+4],A[2]=e[t+5],A[1]=e[t+6],A[0]=e[t+7],mt[0]):(e,t)=>(A[0]=e[t],A[1]=e[t+1],A[2]=e[t+2],A[3]=e[t+3],A[4]=e[t+4],A[5]=e[t+5],A[6]=e[t+6],A[7]=e[t+7],mt[0]),setInt32BE(e,t,r){return e[t+3]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t]=r,4},setInt32LE(e,t,r){return e[t]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+3]=r,4},setBigInt64LE(e,t,r){let n=BigInt(4294967295),i=Number(r&n);e[t]=i,i>>=8,e[t+1]=i,i>>=8,e[t+2]=i,i>>=8,e[t+3]=i;let o=Number(r>>BigInt(32)&n);return e[t+4]=o,o>>=8,e[t+5]=o,o>>=8,e[t+6]=o,o>>=8,e[t+7]=o,8},setFloat64LE:Ee?(e,t,r)=>(mt[0]=r,e[t]=A[7],e[t+1]=A[6],e[t+2]=A[5],e[t+3]=A[4],e[t+4]=A[3],e[t+5]=A[2],e[t+6]=A[1],e[t+7]=A[0],8):(e,t,r)=>(mt[0]=r,e[t]=A[0],e[t+1]=A[1],e[t+2]=A[2],e[t+3]=A[3],e[t+4]=A[4],e[t+5]=A[5],e[t+6]=A[6],e[t+7]=A[7],8)},Pn=new RegExp("^[0-9a-fA-F]{24}$"),nt=null,Z=class e extends x{get _bsontype(){return"ObjectId"}constructor(t){super();let r;if(typeof t=="object"&&t&&"id"in t){if(typeof t.id!="string"&&!ArrayBuffer.isView(t.id))throw new c("Argument passed in must have an id that is of type string or Buffer");"toHexString"in t&&typeof t.toHexString=="function"?r=l.fromHex(t.toHexString()):r=t.id}else r=t;if(r==null||typeof r=="number")this.buffer=e.generate(typeof r=="number"?r:void 0);else if(ArrayBuffer.isView(r)&&r.byteLength===12)this.buffer=l.toLocalBufferType(r);else if(typeof r=="string")if(r.length===24&&Pn.test(r))this.buffer=l.fromHex(r);else throw new c("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");else throw new c("Argument passed in does not match the accepted types");e.cacheHexString&&(this.__id=l.toHex(this.id))}get id(){return this.buffer}set id(t){this.buffer=t,e.cacheHexString&&(this.__id=l.toHex(t))}toHexString(){if(e.cacheHexString&&this.__id)return this.__id;let t=l.toHex(this.id);return e.cacheHexString&&!this.__id&&(this.__id=t),t}static getInc(){return e.index=(e.index+1)%16777215}static generate(t){typeof t!="number"&&(t=Math.floor(Date.now()/1e3));let r=e.getInc(),n=l.allocateUnsafe(12);return O.setInt32BE(n,0,t),nt===null&&(nt=l.randomBytes(5)),n[4]=nt[0],n[5]=nt[1],n[6]=nt[2],n[7]=nt[3],n[8]=nt[4],n[11]=r&255,n[10]=r>>8&255,n[9]=r>>16&255,n}toString(t){return t==="base64"?l.toBase64(this.id):t==="hex"?this.toHexString():this.toHexString()}toJSON(){return this.toHexString()}static is(t){return t!=null&&typeof t=="object"&&"_bsontype"in t&&t._bsontype==="ObjectId"}equals(t){if(t==null)return!1;if(e.is(t))return this.buffer[11]===t.buffer[11]&&l.equals(this.buffer,t.buffer);if(typeof t=="string")return t.toLowerCase()===this.toHexString();if(typeof t=="object"&&typeof t.toHexString=="function"){let r=t.toHexString(),n=this.toHexString();return typeof r=="string"&&r.toLowerCase()===n}return!1}getTimestamp(){let t=new Date,r=O.getUint32BE(this.buffer,0);return t.setTime(Math.floor(r)*1e3),t}static createPk(){return new e}serializeInto(t,r){return t[r]=this.buffer[0],t[r+1]=this.buffer[1],t[r+2]=this.buffer[2],t[r+3]=this.buffer[3],t[r+4]=this.buffer[4],t[r+5]=this.buffer[5],t[r+6]=this.buffer[6],t[r+7]=this.buffer[7],t[r+8]=this.buffer[8],t[r+9]=this.buffer[9],t[r+10]=this.buffer[10],t[r+11]=this.buffer[11],12}static createFromTime(t){let r=l.allocate(12);for(let n=11;n>=4;n--)r[n]=0;return O.setInt32BE(r,0,t),new e(r)}static createFromHexString(t){if(t?.length!==24)throw new c("hex string must be 24 characters");return new e(l.fromHex(t))}static createFromBase64(t){if(t?.length!==16)throw new c("base64 string must be 16 characters");return new e(l.fromBase64(t))}static isValid(t){if(t==null)return!1;try{return new e(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new e(t.$oid)}inspect(t,r,n){return n??=F,`new ObjectId(${n(this.toHexString(),r)})`}};Z.index=Math.floor(Math.random()*16777215);function It(e,t,r){let n=5;if(Array.isArray(e))for(let i=0;i=Ae&&t<=$e&&t>=Et&&t<=Bt?(e!=null?l.utf8ByteLength(e)+1:0)+5:(e!=null?l.utf8ByteLength(e)+1:0)+9;case"undefined":return n||!i?(e!=null?l.utf8ByteLength(e)+1:0)+1:0;case"boolean":return(e!=null?l.utf8ByteLength(e)+1:0)+2;case"object":if(t!=null&&typeof t._bsontype=="string"&&t[Symbol.for("@@mdb.bson.version")]!==rt)throw new k;if(t==null||t._bsontype==="MinKey"||t._bsontype==="MaxKey")return(e!=null?l.utf8ByteLength(e)+1:0)+1;if(t._bsontype==="ObjectId")return(e!=null?l.utf8ByteLength(e)+1:0)+13;if(t instanceof Date||ut(t))return(e!=null?l.utf8ByteLength(e)+1:0)+9;if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||te(t))return(e!=null?l.utf8ByteLength(e)+1:0)+6+t.byteLength;if(t._bsontype==="Long"||t._bsontype==="Double"||t._bsontype==="Timestamp")return(e!=null?l.utf8ByteLength(e)+1:0)+9;if(t._bsontype==="Decimal128")return(e!=null?l.utf8ByteLength(e)+1:0)+17;if(t._bsontype==="Code")return t.scope!=null&&Object.keys(t.scope).length>0?(e!=null?l.utf8ByteLength(e)+1:0)+1+4+4+l.utf8ByteLength(t.code.toString())+1+It(t.scope,r,i):(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.code.toString())+1;if(t._bsontype==="Binary"){let o=t;return o.sub_type===_.SUBTYPE_BYTE_ARRAY?(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1+4):(e!=null?l.utf8ByteLength(e)+1:0)+(o.position+1+4+1)}else{if(t._bsontype==="Symbol")return(e!=null?l.utf8ByteLength(e)+1:0)+l.utf8ByteLength(t.value)+4+1+1;if(t._bsontype==="DBRef"){let o=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return t.db!=null&&(o.$db=t.db),(e!=null?l.utf8ByteLength(e)+1:0)+1+It(o,r,i)}else return t instanceof RegExp||gt(t)?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.source)+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:t._bsontype==="BSONRegExp"?(e!=null?l.utf8ByteLength(e)+1:0)+1+l.utf8ByteLength(t.pattern)+1+l.utf8ByteLength(t.options)+1:(e!=null?l.utf8ByteLength(e)+1:0)+It(t,r,i)+1}case"function":if(r)return(e!=null?l.utf8ByteLength(e)+1:0)+1+4+l.utf8ByteLength(t.toString())+1}return 0}function Hn(e){return e.split("").sort().join("")}var K=class e extends x{get _bsontype(){return"BSONRegExp"}constructor(t,r){if(super(),this.pattern=t,this.options=Hn(r??""),this.pattern.indexOf("\0")!==-1)throw new c(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(this.options.indexOf("\0")!==-1)throw new c(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let n=0;nu);n??=F;let o=i(n(this.pattern),"regexp"),h=i(n(this.options),"regexp");return`new BSONRegExp(${o}, ${h})`}},ft=class e extends x{get _bsontype(){return"BSONSymbol"}constructor(t){super(),this.value=t}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(t){return new e(t.$symbol)}inspect(t,r,n){return n??=F,`new BSONSymbol(${n(this.value,r)})`}},Vn=y,et=class e extends Vn{get _bsontype(){return"Timestamp"}constructor(t){if(t==null)super(0,0,!0);else if(typeof t=="bigint")super(t,!0);else if(y.isLong(t))super(t.low,t.high,!0);else if(typeof t=="object"&&"t"in t&&"i"in t){if(typeof t.t!="number"&&(typeof t.t!="object"||t.t._bsontype!=="Int32"))throw new c("Timestamp constructed from { t, i } must provide t as a number");if(typeof t.i!="number"&&(typeof t.i!="object"||t.i._bsontype!=="Int32"))throw new c("Timestamp constructed from { t, i } must provide i as a number");let r=Number(t.t),n=Number(t.i);if(r<0||Number.isNaN(r))throw new c("Timestamp constructed from { t, i } must provide a positive t");if(n<0||Number.isNaN(n))throw new c("Timestamp constructed from { t, i } must provide a positive i");if(r>4294967295)throw new c("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n>4294967295)throw new c("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(n,r,!0)}else throw new c("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }")}toJSON(){return{$timestamp:this.toString()}}static fromInt(t){return new e(y.fromInt(t,!0))}static fromNumber(t){return new e(y.fromNumber(t,!0))}static fromBits(t,r){return new e({i:t,t:r})}static fromString(t,r){return new e(y.fromString(t,!0,r))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(t){let r=y.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,n=y.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new e({t:n,i:r})}inspect(t,r,n){n??=F;let i=n(this.high>>>0,r),o=n(this.low>>>0,r);return`new Timestamp({ t: ${i}, i: ${o} })`}};et.MAX_VALUE=y.MAX_UNSIGNED_VALUE;var Wn=y.fromNumber($e),kn=y.fromNumber(Ae);function qe(e,t,r){t=t??{};let n=t&&t.index?t.index:0,i=O.getInt32LE(e,n);if(i<5)throw new c(`bson size must be >= 5, is ${i}`);if(t.allowObjectSmallerThanBufferSize&&e.length= bson size ${i}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==i)throw new c(`buffer length ${e.length} must === bson size ${i}`);if(i+n>e.byteLength)throw new c(`(bson size ${i} + options.index ${n} must be <= buffer length ${e.byteLength})`);if(e[n+i-1]!==0)throw new c("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return dt(e,n,t,r)}var Yn=/^\$ref$|^\$id$|^\$db$/;function dt(e,t,r,n=!1){let i=r.fieldsAsRaw==null?null:r.fieldsAsRaw,o=r.raw==null?!1:r.raw,h=typeof r.bsonRegExp=="boolean"?r.bsonRegExp:!1,u=r.promoteBuffers??!1,s=r.promoteLongs??!0,S=r.promoteValues??!0,a=r.useBigInt64??!1;if(a&&!S)throw new c("Must either request bigint or Long for int64 deserialization");if(a&&!s)throw new c("Must either request bigint or Long for int64 deserialization");let f=r.validation==null?{utf8:!0}:r.validation,g=!0,p,w,I=f.utf8;if(typeof I=="boolean")p=I;else{g=!1;let d=Object.keys(I).map(function(E){return I[E]});if(d.length===0)throw new c("UTF-8 validation setting cannot be empty");if(typeof d[0]!="boolean")throw new c("Invalid UTF-8 validation option, must specify boolean values");if(p=d[0],!d.every(E=>E===p))throw new c("Invalid UTF-8 validation option - keys must be all true or all false")}if(!g){w=new Set;for(let d of Object.keys(I))w.add(d)}let D=t;if(e.length<5)throw new c("corrupt bson message < 5 bytes long");let M=O.getInt32LE(e,t);if(t+=4,M<5||M>e.length)throw new c("corrupt bson message");let $=n?[]:{},P=0,b=!1,R=n?!1:null;for(;!b;){let d=e[t++];if(d===0)break;let E=t;for(;e[E]!==0&&E=e.byteLength)throw new c("Bad BSON Document: illegal CString");let j=n?P++:l.toUTF8(e,t,E,!1),T=!0;g||w?.has(j)?T=p:T=!p,R!==!1&&j[0]==="$"&&(R=Yn.test(j));let N;if(t=E+1,d===Ue){let m=O.getInt32LE(e,t);if(t+=4,m<=0||m>e.length-t||e[t+m-1]!==0)throw new c("bad string length in bson");N=l.toUTF8(e,t,t+m-1,T),t=t+m}else if(d===De){let m=l.allocateUnsafe(12);for(let B=0;B<12;B++)m[B]=e[t+B];N=new Z(m),t=t+12}else if(d===St&&S===!1)N=new tt(O.getInt32LE(e,t)),t+=4;else if(d===St)N=O.getInt32LE(e,t),t+=4;else if(d===ne)N=O.getFloat64LE(e,t),t+=8,S===!1&&(N=new v(N));else if(d===ze){let m=O.getInt32LE(e,t),B=O.getInt32LE(e,t+4);t+=8,N=new Date(new y(m,B).toNumber())}else if(d===Re){if(e[t]!==0&&e[t]!==1)throw new c("illegal boolean type value");N=e[t++]===1}else if(d===re){let m=t,B=O.getInt32LE(e,t);if(B<=0||B>e.length-t)throw new c("bad embedded document length in bson");if(o)N=e.slice(t,t+B);else{let L=r;g||(L={...r,validation:{utf8:T}}),N=dt(e,m,L,!1)}t=t+B}else if(d===_e){let m=t,B=O.getInt32LE(e,t),L=r,z=t+B;if(i&&i[j]&&(L={...r,raw:!0}),g||(L={...L,validation:{utf8:T}}),N=dt(e,m,L,!0),t=t+B,e[t-1]!==0)throw new c("invalid array terminator byte");if(t!==z)throw new c("corrupted array bson")}else if(d===yn)N=void 0;else if(d===se)N=null;else if(d===fe)if(a)N=O.getBigInt64LE(e,t),t+=8;else{let m=O.getInt32LE(e,t),B=O.getInt32LE(e,t+4);t+=8;let L=new y(m,B);s&&S===!0?N=L.lessThanOrEqual(Wn)&&L.greaterThanOrEqual(kn)?L.toNumber():L:N=L}else if(d===Fe){let m=l.allocateUnsafe(16);for(let B=0;B<16;B++)m[B]=e[t+B];t=t+16,N=new it(m)}else if(d===ie){let m=O.getInt32LE(e,t);t+=4;let B=m,L=e[t++];if(m<0)throw new c("Negative binary type element size found");if(m>e.byteLength)throw new c("Binary type size larger than document size");if(e.slice!=null){if(L===_.SUBTYPE_BYTE_ARRAY){if(m=O.getInt32LE(e,t),t+=4,m<0)throw new c("Negative binary type element size found for subtype 0x02");if(m>B-4)throw new c("Binary type with subtype 0x02 contains too long binary size");if(mB-4)throw new c("Binary type with subtype 0x02 contains too long binary size");if(m=e.length)throw new c("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,E,!1);for(t=E+1,E=t;e[E]!==0&&E=e.length)throw new c("Bad BSON Document: illegal CString");let B=l.toUTF8(e,t,E,!1);t=E+1;let L=new Array(B.length);for(E=0;E=e.length)throw new c("Bad BSON Document: illegal CString");let m=l.toUTF8(e,t,E,!1);for(t=E+1,E=t;e[E]!==0&&E=e.length)throw new c("Bad BSON Document: illegal CString");let B=l.toUTF8(e,t,E,!1);t=E+1,N=new K(m,B)}else if(d===je){let m=O.getInt32LE(e,t);if(t+=4,m<=0||m>e.length-t||e[t+m-1]!==0)throw new c("bad string length in bson");let B=l.toUTF8(e,t,t+m-1,T);N=S?B:new ft(B),t=t+m}else if(d===xe)N=new et({i:O.getUint32LE(e,t),t:O.getUint32LE(e,t+4)}),t+=8;else if(d===Je)N=new ot;else if(d===Ce)N=new st;else if(d===oe){let m=O.getInt32LE(e,t);if(t+=4,m<=0||m>e.length-t||e[t+m-1]!==0)throw new c("bad string length in bson");let B=l.toUTF8(e,t,t+m-1,T);N=new q(B),t=t+m}else if(d===Me){let m=O.getInt32LE(e,t);if(t+=4,m<13)throw new c("code_w_scope total size shorter minimum expected length");let B=O.getInt32LE(e,t);if(t+=4,B<=0||B>e.length-t||e[t+B-1]!==0)throw new c("bad string length in bson");let L=l.toUTF8(e,t,t+B-1,T);t=t+B;let z=t,G=O.getInt32LE(e,t),sn=dt(e,z,r,!1);if(t=t+G,m<8+G+B)throw new c("code_w_scope total size is too short, truncating scope");if(m>8+G+B)throw new c("code_w_scope total size is too long, clips outer document");N=new q(L,sn)}else if(d===wn){let m=O.getInt32LE(e,t);if(t+=4,m<=0||m>e.length-t||e[t+m-1]!==0)throw new c("bad string length in bson");let B=l.toUTF8(e,t,t+m-1,T);t=t+m;let L=l.allocateUnsafe(12);for(let G=0;G<12;G++)L[G]=e[t+G];let z=new Z(L);t=t+12,N=new V(B,z)}else throw new c(`Detected unknown BSON type ${d.toString(16)} for fieldname "${j}"`);j==="__proto__"?Object.defineProperty($,j,{value:N,writable:!0,enumerable:!0,configurable:!0}):$[j]=N}if(M!==t-D)throw n?new c("corrupt array bson"):new c("corrupt object bson");if(!R)return $;if(We($)){let d=Object.assign({},$);return delete d.$ref,delete d.$id,delete d.$db,new V($.$ref,$.$id,$.$db,d)}return $}var $t=/\x00/,Ie=new Set(["$db","$ref","$id","$clusterTime"]);function Dt(e,t,r,n){e[n++]=Ue;let i=l.encodeUTF8Into(e,t,n);n=n+i+1,e[n-1]=0;let o=l.encodeUTF8Into(e,r,n+4);return O.setInt32LE(e,n,o+1),n=n+4+o,e[n++]=0,n}function Rt(e,t,r,n){let o=!Object.is(r,-0)&&Number.isSafeInteger(r)&&r<=Bt&&r>=Et?St:ne;e[n++]=o;let h=l.encodeUTF8Into(e,t,n);return n=n+h,e[n++]=0,o===St?n+=O.setInt32LE(e,n,r):n+=O.setFloat64LE(e,n,r),n}function zt(e,t,r,n){e[n++]=fe;let i=l.encodeUTF8Into(e,t,n);return n+=i,e[n++]=0,n+=O.setBigInt64LE(e,n,r),n}function bt(e,t,r,n){e[n++]=se;let i=l.encodeUTF8Into(e,t,n);return n=n+i,e[n++]=0,n}function jt(e,t,r,n){e[n++]=Re;let i=l.encodeUTF8Into(e,t,n);return n=n+i,e[n++]=0,e[n++]=r?1:0,n}function Mt(e,t,r,n){e[n++]=ze;let i=l.encodeUTF8Into(e,t,n);n=n+i,e[n++]=0;let o=y.fromNumber(r.getTime()),h=o.getLowBits(),u=o.getHighBits();return n+=O.setInt32LE(e,n,h),n+=O.setInt32LE(e,n,u),n}function xt(e,t,r,n){e[n++]=Tt;let i=l.encodeUTF8Into(e,t,n);if(n=n+i,e[n++]=0,r.source&&r.source.match($t)!=null)throw new c("value "+r.source+" must not contain null bytes");return n=n+l.encodeUTF8Into(e,r.source,n),e[n++]=0,r.ignoreCase&&(e[n++]=105),r.global&&(e[n++]=115),r.multiline&&(e[n++]=109),e[n++]=0,n}function Ft(e,t,r,n){e[n++]=Tt;let i=l.encodeUTF8Into(e,t,n);if(n=n+i,e[n++]=0,r.pattern.match($t)!=null)throw new c("pattern "+r.pattern+" must not contain null bytes");n=n+l.encodeUTF8Into(e,r.pattern,n),e[n++]=0;let o=r.options.split("").sort().join("");return n=n+l.encodeUTF8Into(e,o,n),e[n++]=0,n}function Jt(e,t,r,n){r===null?e[n++]=se:r._bsontype==="MinKey"?e[n++]=Je:e[n++]=Ce;let i=l.encodeUTF8Into(e,t,n);return n=n+i,e[n++]=0,n}function Ct(e,t,r,n){e[n++]=De;let i=l.encodeUTF8Into(e,t,n);return n=n+i,e[n++]=0,n+=r.serializeInto(e,n),n}function Pt(e,t,r,n){e[n++]=ie;let i=l.encodeUTF8Into(e,t,n);n=n+i,e[n++]=0;let o=r.length;if(n+=O.setInt32LE(e,n,o),e[n++]=pn,o<=16)for(let h=0;h=Et,i=e<=Te&&e>=Le;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(n)return new tt(e);if(i)return t.useBigInt64?BigInt(e):y.fromNumber(e)}return new v(e)}if(e==null||typeof e!="object")return e;if(e.$undefined)return null;let r=Object.keys(e).filter(n=>n.startsWith("$")&&e[n]!=null);for(let n=0;nh.startsWith("$")),o=!0;if(i.forEach(h=>{["$ref","$id","$db"].indexOf(h)===-1&&(o=!1)}),o)return V.fromExtendedJSON(n)}return e}function Kn(e,t){return e.map((r,n)=>{t.seenObjects.push({propertyName:`index ${n}`,obj:null});try{return W(r,t)}finally{t.seenObjects.pop()}})}function de(e){let t=e.toISOString();return e.getUTCMilliseconds()!==0?t:t.slice(0,-5)+"Z"}function W(e,t){if(e instanceof Map||ee(e)){let r=Object.create(null);for(let[n,i]of e){if(typeof n!="string")throw new c("Can only serialize maps with string keys");r[n]=i}return W(r,t)}if((typeof e=="object"||typeof e=="function")&&e!==null){let r=t.seenObjects.findIndex(n=>n.obj===e);if(r!==-1){let n=t.seenObjects.map(a=>a.propertyName),i=n.slice(0,r).map(a=>`${a} -> `).join(""),o=n[r],h=" -> "+n.slice(r+1,n.length-1).map(a=>`${a} -> `).join(""),u=n[n.length-1],s=" ".repeat(i.length+o.length/2),S="-".repeat(h.length+(o.length+u.length)/2-1);throw new c(`Converting circular structure to EJSON: + ${i}${o}${h}${u} + ${s}\\${S}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return Kn(e,t);if(e===void 0)return null;if(e instanceof Date||ut(e)){let r=e.getTime(),n=r>-1&&r<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:de(e)}:t.relaxed&&n?{$date:de(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(typeof e=="number"&&(!t.relaxed||!isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=Et&&e<=Bt)return{$numberInt:e.toString()};if(e>=Le&&e<=Te)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if(typeof e=="bigint")return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||gt(e)){let r=e.flags;if(r===void 0){let i=e.toString().match(/[gimuy]*$/);i&&(r=i[0])}return new K(e.source,r).toExtendedJSON(t)}return e!=null&&typeof e=="object"?Xn(e,t):e}var Gn={Binary:e=>new _(e.value(),e.sub_type),Code:e=>new q(e.code,e.scope),DBRef:e=>new V(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new it(e.bytes),Double:e=>new v(e.value),Int32:e=>new tt(e.value),Long:e=>y.fromBits(e.low!=null?e.low:e.low_,e.low!=null?e.high:e.high_,e.low!=null?e.unsigned:e.unsigned_),MaxKey:()=>new st,MinKey:()=>new ot,ObjectId:e=>new Z(e),BSONRegExp:e=>new K(e.pattern,e.options),BSONSymbol:e=>new ft(e.value),Timestamp:e=>et.fromBits(e.low,e.high)};function Xn(e,t){if(e==null||typeof e!="object")throw new c("not an object instance");let r=e._bsontype;if(typeof r>"u"){let n={};for(let i of Object.keys(e)){t.seenObjects.push({propertyName:i,obj:null});try{let o=W(e[i],t);i==="__proto__"?Object.defineProperty(n,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):n[i]=o}finally{t.seenObjects.pop()}}return n}else{if(e!=null&&typeof e=="object"&&typeof e._bsontype=="string"&&e[Symbol.for("@@mdb.bson.version")]!==rt)throw new k;if(qn(e)){let n=e;if(typeof n.toExtendedJSON!="function"){let i=Gn[e._bsontype];if(!i)throw new c("Unrecognized or invalid _bsontype: "+e._bsontype);n=i(n)}return r==="Code"&&n.scope?n=new q(n.code,W(n.scope,t)):r==="DBRef"&&n.oid&&(n=new V(W(n.collection,t),W(n.oid,t),W(n.db,t),W(n.fields,t))),n.toExtendedJSON(t)}else throw new c("_bsontype must be a string, but was: "+typeof r)}}function Ke(e,t){let r={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,(n,i)=>{if(n.indexOf("\0")!==-1)throw new c(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(n)}`);return Ze(i,r)})}function Ge(e,t,r,n){r!=null&&typeof r=="object"&&(n=r,r=0),t!=null&&typeof t=="object"&&!Array.isArray(t)&&(n=t,t=void 0,r=0);let i=Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}),o=W(e,i);return JSON.stringify(o,t,r)}function Qn(e,t){return t=t||{},JSON.parse(Ge(e,t))}function vn(e,t){return t=t||{},Ke(JSON.stringify(e),t)}var lt=Object.create(null);lt.parse=Ke;lt.stringify=Ge;lt.serialize=Qn;lt.deserialize=vn;Object.freeze(lt);function Qt(e,t){try{return O.getNonnegativeInt32LE(e,t)}catch(r){throw new C("BSON size cannot be negative",t,{cause:r})}}function vt(e,t){let r=t;for(;e[r]!==0;r++);if(r===e.length-1)throw new C("Null terminator not found",t);return r}function tr(e,t=0){if(t??=0,e.length<5)throw new C(`Input must be at least 5 bytes, got ${e.length} bytes`,t);let r=Qt(e,t);if(r>e.length-t)throw new C(`Parsed documentSize (${r} bytes) does not match input length (${e.length} bytes)`,t);if(e[t+r-1]!==0)throw new C("BSON documents must end in 0x00",t+r);let n=[],i=t+4;for(;i<=r+t;){let o=e[i];if(i+=1,o===0){if(i-t!==r)throw new C("Invalid 0x00 type byte",i);break}let h=i,u=vt(e,i)-h;i+=u+1;let s;if(o===1||o===18||o===9||o===17)s=8;else if(o===16)s=4;else if(o===7)s=12;else if(o===19)s=16;else if(o===8)s=1;else if(o===10||o===6||o===127||o===255)s=0;else if(o===11)s=vt(e,vt(e,i)+1)+1-i;else if(o===3||o===4||o===15)s=Qt(e,i);else if(o===2||o===5||o===12||o===13||o===14)s=Qt(e,i)+4,o===5&&(s+=1),o===12&&(s+=12);else throw new C(`Invalid 0x${o.toString(16).padStart(2,"0")} type byte`,i);if(s>r)throw new C("value reports length larger than document",i);n.push([o,h,u,i,s]),i+=s}return n}var wt=Object.create(null);wt.parseToElements=tr;wt.ByteUtils=l;wt.NumberUtils=O;Object.freeze(wt);var Xe=1024*1024*17,Q=l.allocate(Xe);function Qe(e){Q.lengthnr,toJson:()=>rr});var nr=le().deserialize,rr=le().EJSON.deserialize;return an(ir);})(); diff --git a/packages/server/src/jsRunner/bundles/buffer.ivm.bundle.js b/packages/server/src/jsRunner/bundles/buffer.ivm.bundle.js new file mode 100644 index 0000000000..e5d385bc66 --- /dev/null +++ b/packages/server/src/jsRunner/bundles/buffer.ivm.bundle.js @@ -0,0 +1,14 @@ +"use strict";var buffer=(()=>{var M=Object.defineProperty;var ar=Object.getOwnPropertyDescriptor;var yr=Object.getOwnPropertyNames;var wr=Object.prototype.hasOwnProperty;var k=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),xr=(i,r)=>{for(var t in r)M(i,t,{get:r[t],enumerable:!0})},Br=(i,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of yr(r))!wr.call(i,e)&&e!==t&&M(i,e,{get:()=>r[e],enumerable:!(n=ar(r,e))||n.enumerable});return i};var Er=i=>Br(M({},"__esModule",{value:!0}),i);var X=k(S=>{"use strict";S.byteLength=gr;S.toByteArray=Ir;S.fromByteArray=Ur;var B=[],w=[],dr=typeof Uint8Array<"u"?Uint8Array:Array,D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(m=0,H=D.length;m0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=r);var n=t===r?0:4-t%4;return[t,n]}function gr(i){var r=V(i),t=r[0],n=r[1];return(t+n)*3/4-n}function mr(i,r,t){return(r+t)*3/4-t}function Ir(i){var r,t=V(i),n=t[0],e=t[1],o=new dr(mr(i,n,e)),u=0,f=e>0?n-4:n,c;for(c=0;c>16&255,o[u++]=r>>8&255,o[u++]=r&255;return e===2&&(r=w[i.charCodeAt(c)]<<2|w[i.charCodeAt(c+1)]>>4,o[u++]=r&255),e===1&&(r=w[i.charCodeAt(c)]<<10|w[i.charCodeAt(c+1)]<<4|w[i.charCodeAt(c+2)]>>2,o[u++]=r>>8&255,o[u++]=r&255),o}function Fr(i){return B[i>>18&63]+B[i>>12&63]+B[i>>6&63]+B[i&63]}function Ar(i,r,t){for(var n,e=[],o=r;of?f:u+o));return n===1?(r=i[t-1],e.push(B[r>>2]+B[r<<4&63]+"==")):n===2&&(r=(i[t-2]<<8)+i[t-1],e.push(B[r>>10]+B[r>>4&63]+B[r<<2&63]+"=")),e.join("")}});var z=k($=>{$.read=function(i,r,t,n,e){var o,u,f=e*8-n-1,c=(1<>1,s=-7,p=t?e-1:0,F=t?-1:1,x=i[r+p];for(p+=F,o=x&(1<<-s)-1,x>>=-s,s+=f;s>0;o=o*256+i[r+p],p+=F,s-=8);for(u=o&(1<<-s)-1,o>>=-s,s+=n;s>0;u=u*256+i[r+p],p+=F,s-=8);if(o===0)o=1-l;else{if(o===c)return u?NaN:(x?-1:1)*(1/0);u=u+Math.pow(2,n),o=o-l}return(x?-1:1)*u*Math.pow(2,o-n)};$.write=function(i,r,t,n,e,o){var u,f,c,l=o*8-e-1,s=(1<>1,F=e===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=n?0:o-1,N=n?1:-1,lr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(f=isNaN(r)?1:0,u=s):(u=Math.floor(Math.log(r)/Math.LN2),r*(c=Math.pow(2,-u))<1&&(u--,c*=2),u+p>=1?r+=F/c:r+=F*Math.pow(2,1-p),r*c>=2&&(u++,c/=2),u+p>=s?(f=0,u=s):u+p>=1?(f=(r*c-1)*Math.pow(2,e),u=u+p):(f=r*Math.pow(2,p-1)*Math.pow(2,e),u=0));e>=8;i[t+x]=f&255,x+=N,f/=256,e-=8);for(u=u<0;i[t+x]=u&255,x+=N,u/=256,l-=8);i[t+x-N]|=lr*128}});var sr=k(T=>{"use strict";var b=X(),U=z(),J=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;T.Buffer=h;T.SlowBuffer=Lr;T.INSPECT_MAX_BYTES=50;var _=2147483647;T.kMaxLength=_;h.TYPED_ARRAY_SUPPORT=Rr();!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Rr(){try{let i=new Uint8Array(1),r={foo:function(){return 42}};return Object.setPrototypeOf(r,Uint8Array.prototype),Object.setPrototypeOf(i,r),i.foo()===42}catch{return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.buffer}});Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(h.isBuffer(this))return this.byteOffset}});function d(i){if(i>_)throw new RangeError('The value "'+i+'" is invalid for option "size"');let r=new Uint8Array(i);return Object.setPrototypeOf(r,h.prototype),r}function h(i,r,t){if(typeof i=="number"){if(typeof r=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return q(i)}return v(i,r,t)}h.poolSize=8192;function v(i,r,t){if(typeof i=="string")return Cr(i,r);if(ArrayBuffer.isView(i))return Sr(i);if(i==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i);if(E(i,ArrayBuffer)||i&&E(i.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(E(i,SharedArrayBuffer)||i&&E(i.buffer,SharedArrayBuffer)))return O(i,r,t);if(typeof i=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=i.valueOf&&i.valueOf();if(n!=null&&n!==i)return h.from(n,r,t);let e=_r(i);if(e)return e;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof i[Symbol.toPrimitive]=="function")return h.from(i[Symbol.toPrimitive]("string"),r,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof i)}h.from=function(i,r,t){return v(i,r,t)};Object.setPrototypeOf(h.prototype,Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function rr(i){if(typeof i!="number")throw new TypeError('"size" argument must be of type number');if(i<0)throw new RangeError('The value "'+i+'" is invalid for option "size"')}function Tr(i,r,t){return rr(i),i<=0?d(i):r!==void 0?typeof t=="string"?d(i).fill(r,t):d(i).fill(r):d(i)}h.alloc=function(i,r,t){return Tr(i,r,t)};function q(i){return rr(i),d(i<0?0:Y(i)|0)}h.allocUnsafe=function(i){return q(i)};h.allocUnsafeSlow=function(i){return q(i)};function Cr(i,r){if((typeof r!="string"||r==="")&&(r="utf8"),!h.isEncoding(r))throw new TypeError("Unknown encoding: "+r);let t=tr(i,r)|0,n=d(t),e=n.write(i,r);return e!==t&&(n=n.slice(0,e)),n}function P(i){let r=i.length<0?0:Y(i.length)|0,t=d(r);for(let n=0;n=_)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_.toString(16)+" bytes");return i|0}function Lr(i){return+i!=i&&(i=0),h.alloc(+i)}h.isBuffer=function(r){return r!=null&&r._isBuffer===!0&&r!==h.prototype};h.compare=function(r,t){if(E(r,Uint8Array)&&(r=h.from(r,r.offset,r.byteLength)),E(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.isBuffer(r)||!h.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(r===t)return 0;let n=r.length,e=t.length;for(let o=0,u=Math.min(n,e);oe.length?(h.isBuffer(u)||(u=h.from(u)),u.copy(e,o)):Uint8Array.prototype.set.call(e,u,o);else if(h.isBuffer(u))u.copy(e,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=u.length}return e};function tr(i,r){if(h.isBuffer(i))return i.length;if(ArrayBuffer.isView(i)||E(i,ArrayBuffer))return i.byteLength;if(typeof i!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof i);let t=i.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let e=!1;for(;;)switch(r){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return G(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return pr(i).length;default:if(e)return n?-1:G(i).length;r=(""+r).toLowerCase(),e=!0}}h.byteLength=tr;function Nr(i,r,t){let n=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,r>>>=0,t<=r))return"";for(i||(i="utf8");;)switch(i){case"hex":return Yr(this,r,t);case"utf8":case"utf-8":return nr(this,r,t);case"ascii":return Gr(this,r,t);case"latin1":case"binary":return qr(this,r,t);case"base64":return Pr(this,r,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wr(this,r,t);default:if(n)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),n=!0}}h.prototype._isBuffer=!0;function I(i,r,t){let n=i[r];i[r]=i[t],i[t]=n}h.prototype.swap16=function(){let r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tt&&(r+=" ... "),""};J&&(h.prototype[J]=h.prototype.inspect);h.prototype.compare=function(r,t,n,e,o){if(E(r,Uint8Array)&&(r=h.from(r,r.offset,r.byteLength)),!h.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof r);if(t===void 0&&(t=0),n===void 0&&(n=r?r.length:0),e===void 0&&(e=0),o===void 0&&(o=this.length),t<0||n>r.length||e<0||o>this.length)throw new RangeError("out of range index");if(e>=o&&t>=n)return 0;if(e>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,e>>>=0,o>>>=0,this===r)return 0;let u=o-e,f=n-t,c=Math.min(u,f),l=this.slice(e,o),s=r.slice(t,n);for(let p=0;p2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,j(t)&&(t=e?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(e)return-1;t=i.length-1}else if(t<0)if(e)t=0;else return-1;if(typeof r=="string"&&(r=h.from(r,n)),h.isBuffer(r))return r.length===0?-1:K(i,r,t,n,e);if(typeof r=="number")return r=r&255,typeof Uint8Array.prototype.indexOf=="function"?e?Uint8Array.prototype.indexOf.call(i,r,t):Uint8Array.prototype.lastIndexOf.call(i,r,t):K(i,[r],t,n,e);throw new TypeError("val must be string, number or Buffer")}function K(i,r,t,n,e){let o=1,u=i.length,f=r.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(i.length<2||r.length<2)return-1;o=2,u/=2,f/=2,t/=2}function c(s,p){return o===1?s[p]:s.readUInt16BE(p*o)}let l;if(e){let s=-1;for(l=t;lu&&(t=u-f),l=t;l>=0;l--){let s=!0;for(let p=0;pe&&(n=e)):n=e;let o=r.length;n>o/2&&(n=o/2);let u;for(u=0;u>>0,isFinite(n)?(n=n>>>0,e===void 0&&(e="utf8")):(e=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),r.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");let u=!1;for(;;)switch(e){case"hex":return Mr(this,r,t,n);case"utf8":case"utf-8":return kr(this,r,t,n);case"ascii":case"latin1":case"binary":return Dr(this,r,t,n);case"base64":return $r(this,r,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return br(this,r,t,n);default:if(u)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),u=!0}};h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Pr(i,r,t){return r===0&&t===i.length?b.fromByteArray(i):b.fromByteArray(i.slice(r,t))}function nr(i,r,t){t=Math.min(i.length,t);let n=[],e=r;for(;e239?4:o>223?3:o>191?2:1;if(e+f<=t){let c,l,s,p;switch(f){case 1:o<128&&(u=o);break;case 2:c=i[e+1],(c&192)===128&&(p=(o&31)<<6|c&63,p>127&&(u=p));break;case 3:c=i[e+1],l=i[e+2],(c&192)===128&&(l&192)===128&&(p=(o&15)<<12|(c&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(u=p));break;case 4:c=i[e+1],l=i[e+2],s=i[e+3],(c&192)===128&&(l&192)===128&&(s&192)===128&&(p=(o&15)<<18|(c&63)<<12|(l&63)<<6|s&63,p>65535&&p<1114112&&(u=p))}}u===null?(u=65533,f=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|u&1023),n.push(u),e+=f}return Or(n)}var Z=4096;function Or(i){let r=i.length;if(r<=Z)return String.fromCharCode.apply(String,i);let t="",n=0;for(;nn)&&(t=n);let e="";for(let o=r;on&&(r=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),tt)throw new RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(r,t,n){r=r>>>0,t=t>>>0,n||a(r,t,this.length);let e=this[r],o=1,u=0;for(;++u>>0,t=t>>>0,n||a(r,t,this.length);let e=this[r+--t],o=1;for(;t>0&&(o*=256);)e+=this[r+--t]*o;return e};h.prototype.readUint8=h.prototype.readUInt8=function(r,t){return r=r>>>0,t||a(r,1,this.length),this[r]};h.prototype.readUint16LE=h.prototype.readUInt16LE=function(r,t){return r=r>>>0,t||a(r,2,this.length),this[r]|this[r+1]<<8};h.prototype.readUint16BE=h.prototype.readUInt16BE=function(r,t){return r=r>>>0,t||a(r,2,this.length),this[r]<<8|this[r+1]};h.prototype.readUint32LE=h.prototype.readUInt32LE=function(r,t){return r=r>>>0,t||a(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};h.prototype.readUint32BE=h.prototype.readUInt32BE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};h.prototype.readBigUInt64LE=g(function(r){r=r>>>0,R(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=t+this[++r]*2**8+this[++r]*2**16+this[++r]*2**24,o=this[++r]+this[++r]*2**8+this[++r]*2**16+n*2**24;return BigInt(e)+(BigInt(o)<>>0,R(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=t*2**24+this[++r]*2**16+this[++r]*2**8+this[++r],o=this[++r]*2**24+this[++r]*2**16+this[++r]*2**8+n;return(BigInt(e)<>>0,t=t>>>0,n||a(r,t,this.length);let e=this[r],o=1,u=0;for(;++u=o&&(e-=Math.pow(2,8*t)),e};h.prototype.readIntBE=function(r,t,n){r=r>>>0,t=t>>>0,n||a(r,t,this.length);let e=t,o=1,u=this[r+--e];for(;e>0&&(o*=256);)u+=this[r+--e]*o;return o*=128,u>=o&&(u-=Math.pow(2,8*t)),u};h.prototype.readInt8=function(r,t){return r=r>>>0,t||a(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};h.prototype.readInt16LE=function(r,t){r=r>>>0,t||a(r,2,this.length);let n=this[r]|this[r+1]<<8;return n&32768?n|4294901760:n};h.prototype.readInt16BE=function(r,t){r=r>>>0,t||a(r,2,this.length);let n=this[r+1]|this[r]<<8;return n&32768?n|4294901760:n};h.prototype.readInt32LE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};h.prototype.readInt32BE=function(r,t){return r=r>>>0,t||a(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};h.prototype.readBigInt64LE=g(function(r){r=r>>>0,R(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=this[r+4]+this[r+5]*2**8+this[r+6]*2**16+(n<<24);return(BigInt(e)<>>0,R(r,"offset");let t=this[r],n=this[r+7];(t===void 0||n===void 0)&&C(r,this.length-8);let e=(t<<24)+this[++r]*2**16+this[++r]*2**8+this[++r];return(BigInt(e)<>>0,t||a(r,4,this.length),U.read(this,r,!0,23,4)};h.prototype.readFloatBE=function(r,t){return r=r>>>0,t||a(r,4,this.length),U.read(this,r,!1,23,4)};h.prototype.readDoubleLE=function(r,t){return r=r>>>0,t||a(r,8,this.length),U.read(this,r,!0,52,8)};h.prototype.readDoubleBE=function(r,t){return r=r>>>0,t||a(r,8,this.length),U.read(this,r,!1,52,8)};function y(i,r,t,n,e,o){if(!h.isBuffer(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>e||ri.length)throw new RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,n=n>>>0,!e){let f=Math.pow(2,8*n)-1;y(this,r,t,n,f,0)}let o=1,u=0;for(this[t]=r&255;++u>>0,n=n>>>0,!e){let f=Math.pow(2,8*n)-1;y(this,r,t,n,f,0)}let o=n-1,u=1;for(this[t+o]=r&255;--o>=0&&(u*=256);)this[t+o]=r/u&255;return t+n};h.prototype.writeUint8=h.prototype.writeUInt8=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,1,255,0),this[t]=r&255,t+1};h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,65535,0),this[t]=r&255,this[t+1]=r>>>8,t+2};h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=r&255,t+2};h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=r&255,t+4};h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};function er(i,r,t,n,e){cr(r,n,e,i,t,7);let o=Number(r&BigInt(4294967295));i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o,o=o>>8,i[t++]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,u=u>>8,i[t++]=u,t}function or(i,r,t,n,e){cr(r,n,e,i,t,7);let o=Number(r&BigInt(4294967295));i[t+7]=o,o=o>>8,i[t+6]=o,o=o>>8,i[t+5]=o,o=o>>8,i[t+4]=o;let u=Number(r>>BigInt(32)&BigInt(4294967295));return i[t+3]=u,u=u>>8,i[t+2]=u,u=u>>8,i[t+1]=u,u=u>>8,i[t]=u,t+8}h.prototype.writeBigUInt64LE=g(function(r,t=0){return er(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeBigUInt64BE=g(function(r,t=0){return or(this,r,t,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeIntLE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){let c=Math.pow(2,8*n-1);y(this,r,t,n,c-1,-c)}let o=0,u=1,f=0;for(this[t]=r&255;++o>0)-f&255;return t+n};h.prototype.writeIntBE=function(r,t,n,e){if(r=+r,t=t>>>0,!e){let c=Math.pow(2,8*n-1);y(this,r,t,n,c-1,-c)}let o=n-1,u=1,f=0;for(this[t+o]=r&255;--o>=0&&(u*=256);)r<0&&f===0&&this[t+o+1]!==0&&(f=1),this[t+o]=(r/u>>0)-f&255;return t+n};h.prototype.writeInt8=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=r&255,t+1};h.prototype.writeInt16LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,32767,-32768),this[t]=r&255,this[t+1]=r>>>8,t+2};h.prototype.writeInt16BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=r&255,t+2};h.prototype.writeInt32LE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,2147483647,-2147483648),this[t]=r&255,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4};h.prototype.writeInt32BE=function(r,t,n){return r=+r,t=t>>>0,n||y(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=r&255,t+4};h.prototype.writeBigInt64LE=g(function(r,t=0){return er(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});h.prototype.writeBigInt64BE=g(function(r,t=0){return or(this,r,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ur(i,r,t,n,e,o){if(t+n>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function hr(i,r,t,n,e){return r=+r,t=t>>>0,e||ur(i,r,t,4,34028234663852886e22,-34028234663852886e22),U.write(i,r,t,n,23,4),t+4}h.prototype.writeFloatLE=function(r,t,n){return hr(this,r,t,!0,n)};h.prototype.writeFloatBE=function(r,t,n){return hr(this,r,t,!1,n)};function fr(i,r,t,n,e){return r=+r,t=t>>>0,e||ur(i,r,t,8,17976931348623157e292,-17976931348623157e292),U.write(i,r,t,n,52,8),t+8}h.prototype.writeDoubleLE=function(r,t,n){return fr(this,r,t,!0,n)};h.prototype.writeDoubleBE=function(r,t,n){return fr(this,r,t,!1,n)};h.prototype.copy=function(r,t,n,e){if(!h.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),!e&&e!==0&&(e=this.length),t>=r.length&&(t=r.length),t||(t=0),e>0&&e=this.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("sourceEnd out of bounds");e>this.length&&(e=this.length),r.length-t>>0,n=n===void 0?this.length:n>>>0,r||(r=0);let o;if(typeof r=="number")for(o=t;o2**32?e=Q(String(t)):typeof t=="bigint"&&(e=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(e=Q(e)),e+="n"),n+=` It must be ${r}. Received ${e}`,n},RangeError);function Q(i){let r="",t=i.length,n=i[0]==="-"?1:0;for(;t>=n+4;t-=3)r=`_${i.slice(t-3,t)}${r}`;return`${i.slice(0,t)}${r}`}function jr(i,r,t){R(r,"offset"),(i[r]===void 0||i[r+t]===void 0)&&C(r,i.length-(t+1))}function cr(i,r,t,n,e,o){if(i>t||i3?r===0||r===BigInt(0)?f=`>= 0${u} and < 2${u} ** ${(o+1)*8}${u}`:f=`>= -(2${u} ** ${(o+1)*8-1}${u}) and < 2 ** ${(o+1)*8-1}${u}`:f=`>= ${r}${u} and <= ${t}${u}`,new A.ERR_OUT_OF_RANGE("value",f,i)}jr(n,e,o)}function R(i,r){if(typeof i!="number")throw new A.ERR_INVALID_ARG_TYPE(r,"number",i)}function C(i,r,t){throw Math.floor(i)!==i?(R(i,t),new A.ERR_OUT_OF_RANGE(t||"offset","an integer",i)):r<0?new A.ERR_BUFFER_OUT_OF_BOUNDS:new A.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${r}`,i)}var Hr=/[^+/0-9A-Za-z-_]/g;function Vr(i){if(i=i.split("=")[0],i=i.trim().replace(Hr,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function G(i,r){r=r||1/0;let t,n=i.length,e=null,o=[];for(let u=0;u55295&&t<57344){if(!e){if(t>56319){(r-=3)>-1&&o.push(239,191,189);continue}else if(u+1===n){(r-=3)>-1&&o.push(239,191,189);continue}e=t;continue}if(t<56320){(r-=3)>-1&&o.push(239,191,189),e=t;continue}t=(e-55296<<10|t-56320)+65536}else e&&(r-=3)>-1&&o.push(239,191,189);if(e=null,t<128){if((r-=1)<0)break;o.push(t)}else if(t<2048){if((r-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((r-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((r-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function Xr(i){let r=[];for(let t=0;t>8,e=t%256,o.push(e),o.push(n);return o}function pr(i){return b.toByteArray(Vr(i))}function L(i,r,t,n){let e;for(e=0;e=r.length||e>=i.length);++e)r[e+t]=i[e];return e}function E(i,r){return i instanceof r||i!=null&&i.constructor!=null&&i.constructor.name!=null&&i.constructor.name===r.name}function j(i){return i!==i}var Jr=function(){let i="0123456789abcdef",r=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let e=0;e<16;++e)r[n+e]=i[t]+i[e]}return r}();function g(i){return typeof BigInt>"u"?Kr:i}function Kr(){throw new Error("BigInt not supported")}});var vr={};xr(vr,{default:()=>Qr});var Zr=sr().Buffer,Qr=Zr;return Er(vr);})(); +/*! Bundled license information: + +ieee754/index.js: + (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) + +buffer/index.js: + (*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + *) +*/ diff --git a/packages/server/src/jsRunner/bundles/buffer.ts b/packages/server/src/jsRunner/bundles/buffer.ts new file mode 100644 index 0000000000..eeef5c24bc --- /dev/null +++ b/packages/server/src/jsRunner/bundles/buffer.ts @@ -0,0 +1,3 @@ +const Buffer = require("buffer/").Buffer + +export default Buffer diff --git a/packages/server/src/jsRunner/bundles/index.ts b/packages/server/src/jsRunner/bundles/index.ts index 94a40fea29..b62adac1cc 100644 --- a/packages/server/src/jsRunner/bundles/index.ts +++ b/packages/server/src/jsRunner/bundles/index.ts @@ -4,12 +4,14 @@ export const enum BundleType { HELPERS = "helpers", BSON = "bson", SNIPPETS = "snippets", + BUFFER = "buffer", } const bundleSourceFile: Record = { [BundleType.HELPERS]: "./index-helpers.ivm.bundle.js", [BundleType.BSON]: "./bson.ivm.bundle.js", [BundleType.SNIPPETS]: "./snippets.ivm.bundle.js", + [BundleType.BUFFER]: "./buffer.ivm.bundle.js", } const bundleSourceCode: Partial> = {} diff --git a/packages/server/src/jsRunner/index.ts b/packages/server/src/jsRunner/index.ts index b2cae1cfbc..ccfca7cb4c 100644 --- a/packages/server/src/jsRunner/index.ts +++ b/packages/server/src/jsRunner/index.ts @@ -23,6 +23,7 @@ export function init() { isolateAccumulatedTimeout: env.JS_PER_REQUEST_TIMEOUT_MS, }) .withHelpers() + .withBuffer() .withSnippets(bbCtx?.snippets) // Persist isolate in context so we can reuse it diff --git a/packages/server/src/jsRunner/tests/jsRunner.spec.ts b/packages/server/src/jsRunner/tests/jsRunner.spec.ts index 9d2bd7104d..525f6d865e 100644 --- a/packages/server/src/jsRunner/tests/jsRunner.spec.ts +++ b/packages/server/src/jsRunner/tests/jsRunner.spec.ts @@ -71,6 +71,17 @@ describe("jsRunner (using isolated-vm)", () => { expect(result).toBeLessThanOrEqual(max) }) }) + + describe("buffer", () => { + it("handle a buffer", async () => { + const base64 = Buffer.from("hello").toString("base64") + const result = await processJS( + `return Buffer.from("${base64}", "base64").toString("utf8")` + ) + expect(result).toBeDefined() + expect(result).toEqual("hello") + }) + }) }) // the test cases here were extracted from templates/real world examples of JS in Budibase diff --git a/packages/server/src/jsRunner/vm/isolated-vm.ts b/packages/server/src/jsRunner/vm/isolated-vm.ts index 833faa3ebd..87d5b966c2 100644 --- a/packages/server/src/jsRunner/vm/isolated-vm.ts +++ b/packages/server/src/jsRunner/vm/isolated-vm.ts @@ -86,6 +86,7 @@ export class IsolatedVM implements VM { } }` const helpersSource = loadBundle(BundleType.HELPERS) + const script = this.isolate.compileScriptSync( `${injectedRequire};${helpersSource};helpers=helpers.default` ) @@ -118,6 +119,19 @@ export class IsolatedVM implements VM { return this } + withBuffer() { + const bufferSource = loadBundle(BundleType.BUFFER) + const script = this.isolate.compileScriptSync(` + ${bufferSource}; + const Buffer = buffer.default; + `) + script.runSync(this.vm, { timeout: this.invocationTimeout, release: false }) + new Promise(() => { + script.release() + }) + return this + } + withContext(context: Record, executeWithContext: () => T) { this.addToContext(context) diff --git a/yarn.lock b/yarn.lock index db8336b7a1..b4309916f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2038,7 +2038,11 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +<<<<<<< Updated upstream "@budibase/backend-core@2.29.22": +======= +"@budibase/backend-core@2.29.24": +>>>>>>> Stashed changes version "0.0.0" dependencies: "@budibase/nano" "10.1.5" @@ -2119,6 +2123,7 @@ through2 "^2.0.0" "@budibase/pro@npm:@budibase/pro@latest": +<<<<<<< Updated upstream version "2.29.22" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.29.22.tgz#2608b2a76be0426879068e5a61100d6b8dde6f3a" integrity sha512-flMVIpWQb9w3f4aiBSM73aLcYmfoPIf+kP8JXgRWO0k3nGrUGaMQNBKzXwC7soTkTrJCZjBh8uaY75AxTP2RdA== @@ -2127,6 +2132,16 @@ "@budibase/shared-core" "2.29.22" "@budibase/string-templates" "2.29.22" "@budibase/types" "2.29.22" +======= + version "2.29.24" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.29.24.tgz#2dbd4c6c0f757aab7e17c413c6d6e4520086f9ac" + integrity sha512-m1v24UD6O21Vbrfsuo5kC5oeg7FzjWO2w8TQMw1VvPKmdIqqclaKDPTPytxwllTMkapMDRNzM5cQzqnQ3yHf6A== + dependencies: + "@budibase/backend-core" "2.29.24" + "@budibase/shared-core" "2.29.24" + "@budibase/string-templates" "2.29.24" + "@budibase/types" "2.29.24" +>>>>>>> Stashed changes "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" @@ -2137,13 +2152,21 @@ scim-patch "^0.8.1" scim2-parse-filter "^0.2.8" +<<<<<<< Updated upstream "@budibase/shared-core@2.29.22": +======= +"@budibase/shared-core@2.29.24": +>>>>>>> Stashed changes version "0.0.0" dependencies: "@budibase/types" "0.0.0" cron-validate "1.4.5" +<<<<<<< Updated upstream "@budibase/string-templates@2.29.22": +======= +"@budibase/string-templates@2.29.24": +>>>>>>> Stashed changes version "0.0.0" dependencies: "@budibase/handlebars-helpers" "^0.13.2" @@ -2151,7 +2174,11 @@ handlebars "^4.7.8" lodash.clonedeep "^4.5.0" +<<<<<<< Updated upstream "@budibase/types@2.29.22": +======= +"@budibase/types@2.29.24": +>>>>>>> Stashed changes version "0.0.0" dependencies: scim-patch "^0.8.1" @@ -7770,6 +7797,14 @@ buffer@4.9.2: ieee754 "^1.1.4" isarray "^1.0.0" +buffer@6.0.3, buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + buffer@^5.1.0, buffer@^5.2.0, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" @@ -7778,14 +7813,6 @@ buffer@^5.1.0, buffer@^5.2.0, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0: base64-js "^1.3.1" ieee754 "^1.1.13" -buffer@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - bufferutil@^4.0.1: version "4.0.7" resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.7.tgz#60c0d19ba2c992dd8273d3f73772ffc894c153ad" From 7823b800883eddb62167a098f0ea00e449d2d100 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 24 Jul 2024 09:41:47 +0100 Subject: [PATCH 2/2] Updating yarn.lock --- yarn.lock | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/yarn.lock b/yarn.lock index b4309916f4..d43d77f6f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2038,11 +2038,7 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -<<<<<<< Updated upstream -"@budibase/backend-core@2.29.22": -======= "@budibase/backend-core@2.29.24": ->>>>>>> Stashed changes version "0.0.0" dependencies: "@budibase/nano" "10.1.5" @@ -2123,16 +2119,6 @@ through2 "^2.0.0" "@budibase/pro@npm:@budibase/pro@latest": -<<<<<<< Updated upstream - version "2.29.22" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.29.22.tgz#2608b2a76be0426879068e5a61100d6b8dde6f3a" - integrity sha512-flMVIpWQb9w3f4aiBSM73aLcYmfoPIf+kP8JXgRWO0k3nGrUGaMQNBKzXwC7soTkTrJCZjBh8uaY75AxTP2RdA== - dependencies: - "@budibase/backend-core" "2.29.22" - "@budibase/shared-core" "2.29.22" - "@budibase/string-templates" "2.29.22" - "@budibase/types" "2.29.22" -======= version "2.29.24" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.29.24.tgz#2dbd4c6c0f757aab7e17c413c6d6e4520086f9ac" integrity sha512-m1v24UD6O21Vbrfsuo5kC5oeg7FzjWO2w8TQMw1VvPKmdIqqclaKDPTPytxwllTMkapMDRNzM5cQzqnQ3yHf6A== @@ -2141,7 +2127,6 @@ "@budibase/shared-core" "2.29.24" "@budibase/string-templates" "2.29.24" "@budibase/types" "2.29.24" ->>>>>>> Stashed changes "@koa/router" "8.0.8" bull "4.10.1" joi "17.6.0" @@ -2152,21 +2137,13 @@ scim-patch "^0.8.1" scim2-parse-filter "^0.2.8" -<<<<<<< Updated upstream -"@budibase/shared-core@2.29.22": -======= "@budibase/shared-core@2.29.24": ->>>>>>> Stashed changes version "0.0.0" dependencies: "@budibase/types" "0.0.0" cron-validate "1.4.5" -<<<<<<< Updated upstream -"@budibase/string-templates@2.29.22": -======= "@budibase/string-templates@2.29.24": ->>>>>>> Stashed changes version "0.0.0" dependencies: "@budibase/handlebars-helpers" "^0.13.2" @@ -2174,11 +2151,7 @@ handlebars "^4.7.8" lodash.clonedeep "^4.5.0" -<<<<<<< Updated upstream -"@budibase/types@2.29.22": -======= "@budibase/types@2.29.24": ->>>>>>> Stashed changes version "0.0.0" dependencies: scim-patch "^0.8.1"