UNPKG

@loaders.gl/bson

Version:

Framework-independent loader for JSON and streaming JSON formats

16 lines 105 kB
(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['loaders'] = factory(); else root['loaders'] = factory();})(globalThis, function () { "use strict";var __exports__=(()=>{var Me=Object.create;var zt=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var Fe=(B,e)=>()=>(e||B((e={exports:{}}).exports,e),e.exports),Le=(B,e)=>{for(var y in e)zt(B,y,{get:e[y],enumerable:!0})},Ct=(B,e,y,b)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of je(e))!ve.call(B,l)&&l!==y&&zt(B,l,{get:()=>e[l],enumerable:!(b=Pe(e,l))||b.enumerable});return B},Jt=(B,e,y)=>(Ct(B,e,"default"),y&&Ct(y,e,"default")),Ce=(B,e,y)=>(y=B!=null?Me(Ye(B)):{},Ct(e||!B||!B.__esModule?zt(y,"default",{value:B,enumerable:!0}):y,B)),ze=B=>Ct(zt({},"__esModule",{value:!0}),B);var Se=Fe((Er,Oe)=>{Oe.exports=globalThis.loaders});var vt={};Le(vt,{BSONLoader:()=>te,BSONWriter:()=>Ue});Jt(vt,Ce(Se(),1));var Ht=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function st(B){return B&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")?B.default:B}function ot(B,e){return e={exports:{}},B(e,e.exports),e.exports}var Je=Ke,We=Ge,Xe=qe,gt=[],yt=[],ke=typeof Uint8Array<"u"?Uint8Array:Array,re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Tt=0,Ae=re.length;Tt<Ae;++Tt)gt[Tt]=re[Tt],yt[re.charCodeAt(Tt)]=Tt;var Tt,Ae;yt["-".charCodeAt(0)]=62;yt["_".charCodeAt(0)]=63;function Ee(B){var e=B.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var y=B.indexOf("=");y===-1&&(y=e);var b=y===e?0:4-y%4;return[y,b]}function Ke(B){var e=Ee(B),y=e[0],b=e[1];return(y+b)*3/4-b}function He(B,e,y){return(e+y)*3/4-y}function Ge(B){var e,y=Ee(B),b=y[0],l=y[1],f=new ke(He(B,b,l)),a=0,E=l>0?b-4:b,o;for(o=0;o<E;o+=4)e=yt[B.charCodeAt(o)]<<18|yt[B.charCodeAt(o+1)]<<12|yt[B.charCodeAt(o+2)]<<6|yt[B.charCodeAt(o+3)],f[a++]=e>>16&255,f[a++]=e>>8&255,f[a++]=e&255;return l===2&&(e=yt[B.charCodeAt(o)]<<2|yt[B.charCodeAt(o+1)]>>4,f[a++]=e&255),l===1&&(e=yt[B.charCodeAt(o)]<<10|yt[B.charCodeAt(o+1)]<<4|yt[B.charCodeAt(o+2)]>>2,f[a++]=e>>8&255,f[a++]=e&255),f}function Ve(B){return gt[B>>18&63]+gt[B>>12&63]+gt[B>>6&63]+gt[B&63]}function Ze(B,e,y){for(var b,l=[],f=e;f<y;f+=3)b=(B[f]<<16&16711680)+(B[f+1]<<8&65280)+(B[f+2]&255),l.push(Ve(b));return l.join("")}function qe(B){for(var e,y=B.length,b=y%3,l=[],f=16383,a=0,E=y-b;a<E;a+=f)l.push(Ze(B,a,a+f>E?E:a+f));return b===1?(e=B[y-1],l.push(gt[e>>2]+gt[e<<4&63]+"==")):b===2&&(e=(B[y-2]<<8)+B[y-1],l.push(gt[e>>10]+gt[e>>4&63]+gt[e<<2&63]+"=")),l.join("")}var ne={byteLength:Je,toByteArray:We,fromByteArray:Xe},Qe=function(e,y,b,l,f){var a,E,o=f*8-l-1,c=(1<<o)-1,h=c>>1,p=-7,n=b?f-1:0,w=b?-1:1,U=e[y+n];for(n+=w,a=U&(1<<-p)-1,U>>=-p,p+=o;p>0;a=a*256+e[y+n],n+=w,p-=8);for(E=a&(1<<-p)-1,a>>=-p,p+=l;p>0;E=E*256+e[y+n],n+=w,p-=8);if(a===0)a=1-h;else{if(a===c)return E?NaN:(U?-1:1)*(1/0);E=E+Math.pow(2,l),a=a-h}return(U?-1:1)*E*Math.pow(2,a-l)},xe=function(e,y,b,l,f,a){var E,o,c,h=a*8-f-1,p=(1<<h)-1,n=p>>1,w=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,U=l?0:a-1,N=l?1:-1,Y=y<0||y===0&&1/y<0?1:0;for(y=Math.abs(y),isNaN(y)||y===1/0?(o=isNaN(y)?1:0,E=p):(E=Math.floor(Math.log(y)/Math.LN2),y*(c=Math.pow(2,-E))<1&&(E--,c*=2),E+n>=1?y+=w/c:y+=w*Math.pow(2,1-n),y*c>=2&&(E++,c/=2),E+n>=p?(o=0,E=p):E+n>=1?(o=(y*c-1)*Math.pow(2,f),E=E+n):(o=y*Math.pow(2,n-1)*Math.pow(2,f),E=0));f>=8;e[b+U]=o&255,U+=N,o/=256,f-=8);for(E=E<<f|o,h+=f;h>0;e[b+U]=E&255,U+=N,E/=256,h-=8);e[b+U-N]|=Y*128},bt={read:Qe,write:xe},C=ot(function(B,e){var y=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=a,e.SlowBuffer=Y,e.INSPECT_MAX_BYTES=50;var b=2147483647;e.kMaxLength=b,a.TYPED_ARRAY_SUPPORT=l(),!a.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 l(){try{var u=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(u,t),u.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function f(u){if(u>b)throw new RangeError('The value "'+u+'" is invalid for option "size"');var t=new Uint8Array(u);return Object.setPrototypeOf(t,a.prototype),t}function a(u,t,r){if(typeof u=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(u)}return E(u,t,r)}a.poolSize=8192;function E(u,t,r){if(typeof u=="string")return p(u,t);if(ArrayBuffer.isView(u))return n(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(u));if(Q(u,ArrayBuffer)||u&&Q(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Q(u,SharedArrayBuffer)||u&&Q(u.buffer,SharedArrayBuffer)))return w(u,t,r);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var _=u.valueOf&&u.valueOf();if(_!=null&&_!==u)return a.from(_,t,r);var S=U(u);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return a.from(u[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(u))}a.from=function(u,t,r){return E(u,t,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function o(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function c(u,t,r){return o(u),u<=0?f(u):t!==void 0?typeof r=="string"?f(u).fill(t,r):f(u).fill(t):f(u)}a.alloc=function(u,t,r){return c(u,t,r)};function h(u){return o(u),f(u<0?0:N(u)|0)}a.allocUnsafe=function(u){return h(u)},a.allocUnsafeSlow=function(u){return h(u)};function p(u,t){if((typeof t!="string"||t==="")&&(t="utf8"),!a.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=J(u,t)|0,_=f(r),S=_.write(u,t);return S!==r&&(_=_.slice(0,S)),_}function n(u){for(var t=u.length<0?0:N(u.length)|0,r=f(t),_=0;_<t;_+=1)r[_]=u[_]&255;return r}function w(u,t,r){if(t<0||u.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var _;return t===void 0&&r===void 0?_=new Uint8Array(u):r===void 0?_=new Uint8Array(u,t):_=new Uint8Array(u,t,r),Object.setPrototypeOf(_,a.prototype),_}function U(u){if(a.isBuffer(u)){var t=N(u.length)|0,r=f(t);return r.length===0||u.copy(r,0,0,t),r}if(u.length!==void 0)return typeof u.length!="number"||at(u.length)?f(0):n(u);if(u.type==="Buffer"&&Array.isArray(u.data))return n(u.data)}function N(u){if(u>=b)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+b.toString(16)+" bytes");return u|0}function Y(u){return+u!=u&&(u=0),a.alloc(+u)}a.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==a.prototype},a.compare=function(t,r){if(Q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),Q(r,Uint8Array)&&(r=a.from(r,r.offset,r.byteLength)),!a.isBuffer(t)||!a.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;for(var _=t.length,S=r.length,P=0,v=Math.min(_,S);P<v;++P)if(t[P]!==r[P]){_=t[P],S=r[P];break}return _<S?-1:S<_?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var _;if(r===void 0)for(r=0,_=0;_<t.length;++_)r+=t[_].length;var S=a.allocUnsafe(r),P=0;for(_=0;_<t.length;++_){var v=t[_];if(Q(v,Uint8Array)&&(v=a.from(v)),!a.isBuffer(v))throw new TypeError('"list" argument must be an Array of Buffers');v.copy(S,P),P+=v.length}return S};function J(u,t){if(a.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||Q(u,ArrayBuffer))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(u));var r=u.length,_=arguments.length>2&&arguments[2]===!0;if(!_&&r===0)return 0;for(var S=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return k(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Ft(u).length;default:if(S)return _?-1:k(u).length;t=(""+t).toLowerCase(),S=!0}}a.byteLength=J;function R(u,t,r){var _=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(u||(u="utf8");;)switch(u){case"hex":return g(this,t,r);case"utf8":case"utf-8":return i(this,t,r);case"ascii":return j(this,t,r);case"latin1":case"binary":return F(this,t,r);case"base64":return O(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $(this,t,r);default:if(_)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),_=!0}}a.prototype._isBuffer=!0;function W(u,t,r){var _=u[t];u[t]=u[r],u[r]=_}a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)W(this,r,r+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)W(this,r,r+3),W(this,r+1,r+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)W(this,r,r+7),W(this,r+1,r+6),W(this,r+2,r+5),W(this,r+3,r+4);return this},a.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?i(this,0,t):R.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0},a.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},y&&(a.prototype[y]=a.prototype.inspect),a.prototype.compare=function(t,r,_,S,P){if(Q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(r===void 0&&(r=0),_===void 0&&(_=t?t.length:0),S===void 0&&(S=0),P===void 0&&(P=this.length),r<0||_>t.length||S<0||P>this.length)throw new RangeError("out of range index");if(S>=P&&r>=_)return 0;if(S>=P)return-1;if(r>=_)return 1;if(r>>>=0,_>>>=0,S>>>=0,P>>>=0,this===t)return 0;for(var v=P-S,tt=_-r,it=Math.min(v,tt),ft=this.slice(S,P),ct=t.slice(r,_),ut=0;ut<it;++ut)if(ft[ut]!==ct[ut]){v=ft[ut],tt=ct[ut];break}return v<tt?-1:tt<v?1:0};function x(u,t,r,_,S){if(u.length===0)return-1;if(typeof r=="string"?(_=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,at(r)&&(r=S?0:u.length-1),r<0&&(r=u.length+r),r>=u.length){if(S)return-1;r=u.length-1}else if(r<0)if(S)r=0;else return-1;if(typeof t=="string"&&(t=a.from(t,_)),a.isBuffer(t))return t.length===0?-1:G(u,t,r,_,S);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?S?Uint8Array.prototype.indexOf.call(u,t,r):Uint8Array.prototype.lastIndexOf.call(u,t,r):G(u,[t],r,_,S);throw new TypeError("val must be string, number or Buffer")}function G(u,t,r,_,S){var P=1,v=u.length,tt=t.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(u.length<2||t.length<2)return-1;P=2,v/=2,tt/=2,r/=2}function it(ge,pe){return P===1?ge[pe]:ge.readUInt16BE(pe*P)}var ft;if(S){var ct=-1;for(ft=r;ft<v;ft++)if(it(u,ft)===it(t,ct===-1?0:ft-ct)){if(ct===-1&&(ct=ft),ft-ct+1===tt)return ct*P}else ct!==-1&&(ft-=ft-ct),ct=-1}else for(r+tt>v&&(r=v-tt),ft=r;ft>=0;ft--){for(var ut=!0,Lt=0;Lt<tt;Lt++)if(it(u,ft+Lt)!==it(t,Lt)){ut=!1;break}if(ut)return ft}return-1}a.prototype.includes=function(t,r,_){return this.indexOf(t,r,_)!==-1},a.prototype.indexOf=function(t,r,_){return x(this,t,r,_,!0)},a.prototype.lastIndexOf=function(t,r,_){return x(this,t,r,_,!1)};function M(u,t,r,_){r=Number(r)||0;var S=u.length-r;_?(_=Number(_),_>S&&(_=S)):_=S;var P=t.length;_>P/2&&(_=P/2);for(var v=0;v<_;++v){var tt=parseInt(t.substr(v*2,2),16);if(at(tt))return v;u[r+v]=tt}return v}function V(u,t,r,_){return ht(k(t,u.length-r),u,r,_)}function z(u,t,r,_){return ht(lt(t),u,r,_)}function Z(u,t,r,_){return z(u,t,r,_)}function s(u,t,r,_){return ht(Ft(t),u,r,_)}function A(u,t,r,_){return ht(ee(t,u.length-r),u,r,_)}a.prototype.write=function(t,r,_,S){if(r===void 0)S="utf8",_=this.length,r=0;else if(_===void 0&&typeof r=="string")S=r,_=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(_)?(_=_>>>0,S===void 0&&(S="utf8")):(S=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var P=this.length-r;if((_===void 0||_>P)&&(_=P),t.length>0&&(_<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");S||(S="utf8");for(var v=!1;;)switch(S){case"hex":return M(this,t,r,_);case"utf8":case"utf-8":return V(this,t,r,_);case"ascii":return z(this,t,r,_);case"latin1":case"binary":return Z(this,t,r,_);case"base64":return s(this,t,r,_);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,r,_);default:if(v)throw new TypeError("Unknown encoding: "+S);S=(""+S).toLowerCase(),v=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(u,t,r){return t===0&&r===u.length?ne.fromByteArray(u):ne.fromByteArray(u.slice(t,r))}function i(u,t,r){r=Math.min(u.length,r);for(var _=[],S=t;S<r;){var P=u[S],v=null,tt=P>239?4:P>223?3:P>191?2:1;if(S+tt<=r){var it,ft,ct,ut;switch(tt){case 1:P<128&&(v=P);break;case 2:it=u[S+1],(it&192)===128&&(ut=(P&31)<<6|it&63,ut>127&&(v=ut));break;case 3:it=u[S+1],ft=u[S+2],(it&192)===128&&(ft&192)===128&&(ut=(P&15)<<12|(it&63)<<6|ft&63,ut>2047&&(ut<55296||ut>57343)&&(v=ut));break;case 4:it=u[S+1],ft=u[S+2],ct=u[S+3],(it&192)===128&&(ft&192)===128&&(ct&192)===128&&(ut=(P&15)<<18|(it&63)<<12|(ft&63)<<6|ct&63,ut>65535&&ut<1114112&&(v=ut))}}v===null?(v=65533,tt=1):v>65535&&(v-=65536,_.push(v>>>10&1023|55296),v=56320|v&1023),_.push(v),S+=tt}return D(_)}var m=4096;function D(u){var t=u.length;if(t<=m)return String.fromCharCode.apply(String,u);for(var r="",_=0;_<t;)r+=String.fromCharCode.apply(String,u.slice(_,_+=m));return r}function j(u,t,r){var _="";r=Math.min(u.length,r);for(var S=t;S<r;++S)_+=String.fromCharCode(u[S]&127);return _}function F(u,t,r){var _="";r=Math.min(u.length,r);for(var S=t;S<r;++S)_+=String.fromCharCode(u[S]);return _}function g(u,t,r){var _=u.length;(!t||t<0)&&(t=0),(!r||r<0||r>_)&&(r=_);for(var S="",P=t;P<r;++P)S+=nt[u[P]];return S}function $(u,t,r){for(var _=u.slice(t,r),S="",P=0;P<_.length;P+=2)S+=String.fromCharCode(_[P]+_[P+1]*256);return S}a.prototype.slice=function(t,r){var _=this.length;t=~~t,r=r===void 0?_:~~r,t<0?(t+=_,t<0&&(t=0)):t>_&&(t=_),r<0?(r+=_,r<0&&(r=0)):r>_&&(r=_),r<t&&(r=t);var S=this.subarray(t,r);return Object.setPrototypeOf(S,a.prototype),S};function L(u,t,r){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+t>r)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUIntLE=function(t,r,_){t=t>>>0,r=r>>>0,_||L(t,r,this.length);for(var S=this[t],P=1,v=0;++v<r&&(P*=256);)S+=this[t+v]*P;return S},a.prototype.readUIntBE=function(t,r,_){t=t>>>0,r=r>>>0,_||L(t,r,this.length);for(var S=this[t+--r],P=1;r>0&&(P*=256);)S+=this[t+--r]*P;return S},a.prototype.readUInt8=function(t,r){return t=t>>>0,r||L(t,1,this.length),this[t]},a.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||L(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||L(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},a.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||L(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,r,_){t=t>>>0,r=r>>>0,_||L(t,r,this.length);for(var S=this[t],P=1,v=0;++v<r&&(P*=256);)S+=this[t+v]*P;return P*=128,S>=P&&(S-=Math.pow(2,8*r)),S},a.prototype.readIntBE=function(t,r,_){t=t>>>0,r=r>>>0,_||L(t,r,this.length);for(var S=r,P=1,v=this[t+--S];S>0&&(P*=256);)v+=this[t+--S]*P;return P*=128,v>=P&&(v-=Math.pow(2,8*r)),v},a.prototype.readInt8=function(t,r){return t=t>>>0,r||L(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},a.prototype.readInt16LE=function(t,r){t=t>>>0,r||L(t,2,this.length);var _=this[t]|this[t+1]<<8;return _&32768?_|4294901760:_},a.prototype.readInt16BE=function(t,r){t=t>>>0,r||L(t,2,this.length);var _=this[t+1]|this[t]<<8;return _&32768?_|4294901760:_},a.prototype.readInt32LE=function(t,r){return t=t>>>0,r||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,r){return t=t>>>0,r||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,r){return t=t>>>0,r||L(t,4,this.length),bt.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,r){return t=t>>>0,r||L(t,4,this.length),bt.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||L(t,8,this.length),bt.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||L(t,8,this.length),bt.read(this,t,!1,52,8)};function T(u,t,r,_,S,P){if(!a.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>S||t<P)throw new RangeError('"value" argument is out of bounds');if(r+_>u.length)throw new RangeError("Index out of range")}a.prototype.writeUIntLE=function(t,r,_,S){if(t=+t,r=r>>>0,_=_>>>0,!S){var P=Math.pow(2,8*_)-1;T(this,t,r,_,P,0)}var v=1,tt=0;for(this[r]=t&255;++tt<_&&(v*=256);)this[r+tt]=t/v&255;return r+_},a.prototype.writeUIntBE=function(t,r,_,S){if(t=+t,r=r>>>0,_=_>>>0,!S){var P=Math.pow(2,8*_)-1;T(this,t,r,_,P,0)}var v=_-1,tt=1;for(this[r+v]=t&255;--v>=0&&(tt*=256);)this[r+v]=t/tt&255;return r+_},a.prototype.writeUInt8=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,1,255,0),this[r]=t&255,r+1},a.prototype.writeUInt16LE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2},a.prototype.writeUInt16BE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2},a.prototype.writeUInt32LE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4},a.prototype.writeUInt32BE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4},a.prototype.writeIntLE=function(t,r,_,S){if(t=+t,r=r>>>0,!S){var P=Math.pow(2,8*_-1);T(this,t,r,_,P-1,-P)}var v=0,tt=1,it=0;for(this[r]=t&255;++v<_&&(tt*=256);)t<0&&it===0&&this[r+v-1]!==0&&(it=1),this[r+v]=(t/tt>>0)-it&255;return r+_},a.prototype.writeIntBE=function(t,r,_,S){if(t=+t,r=r>>>0,!S){var P=Math.pow(2,8*_-1);T(this,t,r,_,P-1,-P)}var v=_-1,tt=1,it=0;for(this[r+v]=t&255;--v>=0&&(tt*=256);)t<0&&it===0&&this[r+v+1]!==0&&(it=1),this[r+v]=(t/tt>>0)-it&255;return r+_},a.prototype.writeInt8=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1},a.prototype.writeInt16LE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2},a.prototype.writeInt16BE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2},a.prototype.writeInt32LE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},a.prototype.writeInt32BE=function(t,r,_){return t=+t,r=r>>>0,_||T(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function d(u,t,r,_,S,P){if(r+_>u.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function q(u,t,r,_,S){return t=+t,r=r>>>0,S||d(u,t,r,4),bt.write(u,t,r,_,23,4),r+4}a.prototype.writeFloatLE=function(t,r,_){return q(this,t,r,!0,_)},a.prototype.writeFloatBE=function(t,r,_){return q(this,t,r,!1,_)};function X(u,t,r,_,S){return t=+t,r=r>>>0,S||d(u,t,r,8),bt.write(u,t,r,_,52,8),r+8}a.prototype.writeDoubleLE=function(t,r,_){return X(this,t,r,!0,_)},a.prototype.writeDoubleBE=function(t,r,_){return X(this,t,r,!1,_)},a.prototype.copy=function(t,r,_,S){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(_||(_=0),!S&&S!==0&&(S=this.length),r>=t.length&&(r=t.length),r||(r=0),S>0&&S<_&&(S=_),S===_||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(_<0||_>=this.length)throw new RangeError("Index out of range");if(S<0)throw new RangeError("sourceEnd out of bounds");S>this.length&&(S=this.length),t.length-r<S-_&&(S=t.length-r+_);var P=S-_;if(this===t&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(r,_,S);else if(this===t&&_<r&&r<S)for(var v=P-1;v>=0;--v)t[v+r]=this[v+_];else Uint8Array.prototype.set.call(t,this.subarray(_,S),r);return P},a.prototype.fill=function(t,r,_,S){if(typeof t=="string"){if(typeof r=="string"?(S=r,r=0,_=this.length):typeof _=="string"&&(S=_,_=this.length),S!==void 0&&typeof S!="string")throw new TypeError("encoding must be a string");if(typeof S=="string"&&!a.isEncoding(S))throw new TypeError("Unknown encoding: "+S);if(t.length===1){var P=t.charCodeAt(0);(S==="utf8"&&P<128||S==="latin1")&&(t=P)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<_)throw new RangeError("Out of range index");if(_<=r)return this;r=r>>>0,_=_===void 0?this.length:_>>>0,t||(t=0);var v;if(typeof t=="number")for(v=r;v<_;++v)this[v]=t;else{var tt=a.isBuffer(t)?t:a.from(t,S),it=tt.length;if(it===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(v=0;v<_-r;++v)this[v+r]=tt[v%it]}return this};var et=/[^+/0-9A-Za-z-_]/g;function Bt(u){if(u=u.split("=")[0],u=u.trim().replace(et,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function k(u,t){t=t||1/0;for(var r,_=u.length,S=null,P=[],v=0;v<_;++v){if(r=u.charCodeAt(v),r>55295&&r<57344){if(!S){if(r>56319){(t-=3)>-1&&P.push(239,191,189);continue}else if(v+1===_){(t-=3)>-1&&P.push(239,191,189);continue}S=r;continue}if(r<56320){(t-=3)>-1&&P.push(239,191,189),S=r;continue}r=(S-55296<<10|r-56320)+65536}else S&&(t-=3)>-1&&P.push(239,191,189);if(S=null,r<128){if((t-=1)<0)break;P.push(r)}else if(r<2048){if((t-=2)<0)break;P.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;P.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;P.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return P}function lt(u){for(var t=[],r=0;r<u.length;++r)t.push(u.charCodeAt(r)&255);return t}function ee(u,t){for(var r,_,S,P=[],v=0;v<u.length&&!((t-=2)<0);++v)r=u.charCodeAt(v),_=r>>8,S=r%256,P.push(S),P.push(_);return P}function Ft(u){return ne.toByteArray(Bt(u))}function ht(u,t,r,_){for(var S=0;S<_&&!(S+r>=t.length||S>=u.length);++S)t[S+r]=u[S];return S}function Q(u,t){return u instanceof t||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===t.name}function at(u){return u!==u}var nt=function(){for(var u="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var _=r*16,S=0;S<16;++S)t[_+S]=u[r]+u[S];return t}()}),mr=C.Buffer,wr=C.SlowBuffer,Tr=C.INSPECT_MAX_BYTES,Ir=C.kMaxLength,mt=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ensureBuffer=void 0;function y(b){if(C.Buffer.isBuffer(b))return b;if(ArrayBuffer.isView(b))return C.Buffer.from(b.buffer);if(b instanceof ArrayBuffer)return C.Buffer.from(b);throw new TypeError("Must use either Buffer or TypedArray")}e.ensureBuffer=y});st(mt);var Dr=mt.ensureBuffer,le=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseUUID=void 0;let y=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function b(l){if(typeof l!="string")throw new TypeError("Invalid type for UUID, expected string but got "+typeof l);if(!y.test(l))throw new TypeError("Invalid format for UUID: "+l);let f,a=new Uint8Array(16);return a[0]=(f=parseInt(l.slice(0,8),16))>>>24,a[1]=f>>>16&255,a[2]=f>>>8&255,a[3]=f&255,a[4]=(f=parseInt(l.slice(9,13),16))>>>8,a[5]=f&255,a[6]=(f=parseInt(l.slice(14,18),16))>>>8,a[7]=f&255,a[8]=(f=parseInt(l.slice(19,23),16))>>>8,a[9]=f&255,a[10]=(f=parseInt(l.slice(24,36),16))/1099511627776&255,a[11]=f/4294967296&255,a[12]=f>>>24&255,a[13]=f>>>16&255,a[14]=f>>>8&255,a[15]=f&255,a}e.parseUUID=b});st(le);var br=le.parseUUID,_t=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Binary=void 0;class y{constructor(l,f){if(l!=null&&typeof l!="string"&&!ArrayBuffer.isView(l)&&!(l instanceof ArrayBuffer)&&!Array.isArray(l))throw new TypeError("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=f??y.BSON_BINARY_SUBTYPE_DEFAULT,l==null?(this.buffer=C.Buffer.alloc(y.BUFFER_SIZE),this.position=0):(typeof l=="string"?this.buffer=C.Buffer.from(l,"binary"):Array.isArray(l)?this.buffer=C.Buffer.from(l):this.buffer=mt.ensureBuffer(l),this.position=this.buffer.byteLength)}put(l){if(typeof l=="string"&&l.length!==1)throw new TypeError("only accepts single character String");if(typeof l!="number"&&l.length!==1)throw new TypeError("only accepts single character Uint8Array or Array");let f;if(typeof l=="string"?f=l.charCodeAt(0):typeof l=="number"?f=l:f=l[0],f<0||f>255)throw new TypeError("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=f;else{let a=C.Buffer.alloc(y.BUFFER_SIZE+this.buffer.length);this.buffer.copy(a,0,0,this.buffer.length),this.buffer=a,this.buffer[this.position++]=f}}write(l,f){if(f=typeof f=="number"?f:this.position,this.buffer.length<f+l.length){let a=C.Buffer.alloc(this.buffer.length+l.length);this.buffer.copy(a,0,0,this.buffer.length),this.buffer=a}ArrayBuffer.isView(l)?(this.buffer.set(mt.ensureBuffer(l),f),this.position=f+l.byteLength>this.position?f+l.length:this.position):typeof l=="string"&&(this.buffer.write(l,f,l.length,"binary"),this.position=f+l.length>this.position?f+l.length:this.position)}read(l,f){return f=f&&f>0?f:this.position,this.buffer.slice(l,l+f)}value(l){return l=!!l,l&&this.buffer.length===this.position?this.buffer:l?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)}length(){return this.position}toJSON(){return this.buffer.toString("base64")}toString(l){return this.buffer.toString(l)}toExtendedJSON(l){l=l||{};let f=this.buffer.toString("base64"),a=Number(this.sub_type).toString(16);return l.legacy?{$binary:f,$type:a.length===1?"0"+a:a}:{$binary:{base64:f,subType:a.length===1?"0"+a:a}}}static fromExtendedJSON(l,f){f=f||{};let a,E;if("$binary"in l?f.legacy&&typeof l.$binary=="string"&&"$type"in l?(E=l.$type?parseInt(l.$type,16):0,a=C.Buffer.from(l.$binary,"base64")):typeof l.$binary!="string"&&(E=l.$binary.subType?parseInt(l.$binary.subType,16):0,a=C.Buffer.from(l.$binary.base64,"base64")):"$uuid"in l&&(E=4,a=C.Buffer.from(le.parseUUID(l.$uuid))),!a)throw new TypeError(`Unexpected Binary Extended JSON format ${JSON.stringify(l)}`);return new y(a,E)}}e.Binary=y,y.BSON_BINARY_SUBTYPE_DEFAULT=0,y.BUFFER_SIZE=256,y.SUBTYPE_DEFAULT=0,y.SUBTYPE_FUNCTION=1,y.SUBTYPE_BYTE_ARRAY=2,y.SUBTYPE_UUID_OLD=3,y.SUBTYPE_UUID=4,y.SUBTYPE_MD5=5,y.SUBTYPE_USER_DEFINED=128,Object.defineProperty(y.prototype,"_bsontype",{value:"Binary"})});st(_t);var dr=_t.Binary,Et=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Code=void 0;class y{constructor(l,f){this.code=l,this.scope=f}toJSON(){return{code:this.code,scope:this.scope}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(l){return new y(l.$code,l.$scope)}}e.Code=y,Object.defineProperty(y.prototype,"_bsontype",{value:"Code"})});st(Et);var Rr=Et.Code,$e={},fe;typeof Object.create=="function"?fe=function(e,y){e.super_=y,e.prototype=Object.create(y.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:fe=function(e,y){e.super_=y;var b=function(){};b.prototype=y.prototype,e.prototype=new b,e.prototype.constructor=e};var tr=fe,er=/%[sdj%]/g;function ce(B){if(!xt(B)){for(var e=[],y=0;y<arguments.length;y++)e.push(Ot(arguments[y]));return e.join(" ")}for(var y=1,b=arguments,l=b.length,f=String(B).replace(er,function(E){if(E==="%%")return"%";if(y>=l)return E;switch(E){case"%s":return String(b[y++]);case"%d":return Number(b[y++]);case"%j":try{return JSON.stringify(b[y++])}catch{return"[Circular]"}default:return E}}),a=b[y];y<l;a=b[++y])Qt(a)||!Pt(a)?f+=" "+a:f+=" "+Ot(a);return f}function me(B,e){if(pt(global.process))return function(){return me(B,e).apply(this,arguments)};var y=!1;function b(){return y||(console.error(e),y=!0),B.apply(this,arguments)}return b}var Wt={},ie;function rr(B){if(pt(ie)&&(ie=""),B=B.toUpperCase(),!Wt[B])if(new RegExp("\\b"+B+"\\b","i").test(ie)){var e=0;Wt[B]=function(){var y=ce.apply(null,arguments);console.error("%s %d: %s",B,e,y)}}else Wt[B]=function(){};return Wt[B]}function Ot(B,e){var y={seen:[],stylize:ir};return arguments.length>=3&&(y.depth=arguments[2]),arguments.length>=4&&(y.colors=arguments[3]),he(e)?y.showHidden=e:e&&Ie(y,e),pt(y.showHidden)&&(y.showHidden=!1),pt(y.depth)&&(y.depth=2),pt(y.colors)&&(y.colors=!1),pt(y.customInspect)&&(y.customInspect=!0),y.colors&&(y.stylize=nr),Gt(y,B,y.depth)}Ot.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};Ot.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function nr(B,e){var y=Ot.styles[e];return y?"\x1B["+Ot.colors[y][0]+"m"+B+"\x1B["+Ot.colors[y][1]+"m":B}function ir(B,e){return B}function or(B){var e={};return B.forEach(function(y,b){e[y]=!0}),e}function Gt(B,e,y){if(B.customInspect&&e&&Kt(e.inspect)&&e.inspect!==Ot&&!(e.constructor&&e.constructor.prototype===e)){var b=e.inspect(y,B);return xt(b)||(b=Gt(B,b,y)),b}var l=sr(B,e);if(l)return l;var f=Object.keys(e),a=or(f);if(B.showHidden&&(f=Object.getOwnPropertyNames(e)),kt(e)&&(f.indexOf("message")>=0||f.indexOf("description")>=0))return oe(e);if(f.length===0){if(Kt(e)){var E=e.name?": "+e.name:"";return B.stylize("[Function"+E+"]","special")}if(Xt(e))return B.stylize(RegExp.prototype.toString.call(e),"regexp");if(ae(e))return B.stylize(Date.prototype.toString.call(e),"date");if(kt(e))return oe(e)}var o="",c=!1,h=["{","}"];if(we(e)&&(c=!0,h=["[","]"]),Kt(e)){var p=e.name?": "+e.name:"";o=" [Function"+p+"]"}if(Xt(e)&&(o=" "+RegExp.prototype.toString.call(e)),ae(e)&&(o=" "+Date.prototype.toUTCString.call(e)),kt(e)&&(o=" "+oe(e)),f.length===0&&(!c||e.length==0))return h[0]+o+h[1];if(y<0)return Xt(e)?B.stylize(RegExp.prototype.toString.call(e),"regexp"):B.stylize("[Object]","special");B.seen.push(e);var n;return c?n=fr(B,e,y,a,f):n=f.map(function(w){return ue(B,e,y,a,w,c)}),B.seen.pop(),ur(n,o,h)}function sr(B,e){if(pt(e))return B.stylize("undefined","undefined");if(xt(e)){var y="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return B.stylize(y,"string")}if(Te(e))return B.stylize(""+e,"number");if(he(e))return B.stylize(""+e,"boolean");if(Qt(e))return B.stylize("null","null")}function oe(B){return"["+Error.prototype.toString.call(B)+"]"}function fr(B,e,y,b,l){for(var f=[],a=0,E=e.length;a<E;++a)De(e,String(a))?f.push(ue(B,e,y,b,String(a),!0)):f.push("");return l.forEach(function(o){o.match(/^\d+$/)||f.push(ue(B,e,y,b,o,!0))}),f}function ue(B,e,y,b,l,f){var a,E,o;if(o=Object.getOwnPropertyDescriptor(e,l)||{value:e[l]},o.get?o.set?E=B.stylize("[Getter/Setter]","special"):E=B.stylize("[Getter]","special"):o.set&&(E=B.stylize("[Setter]","special")),De(b,l)||(a="["+l+"]"),E||(B.seen.indexOf(o.value)<0?(Qt(y)?E=Gt(B,o.value,null):E=Gt(B,o.value,y-1),E.indexOf(` `)>-1&&(f?E=E.split(` `).map(function(c){return" "+c}).join(` `).substr(2):E=` `+E.split(` `).map(function(c){return" "+c}).join(` `))):E=B.stylize("[Circular]","special")),pt(a)){if(f&&l.match(/^\d+$/))return E;a=JSON.stringify(""+l),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=B.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=B.stylize(a,"string"))}return a+": "+E}function ur(B,e,y){var b=B.reduce(function(l,f){return f.indexOf(` `)>=0,l+f.replace(/\u001b\[\d\d?m/g,"").length+1},0);return b>60?y[0]+(e===""?"":e+` `)+" "+B.join(`, `)+" "+y[1]:y[0]+e+" "+B.join(", ")+" "+y[1]}function we(B){return Array.isArray(B)}function he(B){return typeof B=="boolean"}function Qt(B){return B===null}function ar(B){return B==null}function Te(B){return typeof B=="number"}function xt(B){return typeof B=="string"}function lr(B){return babelHelpers.typeof(B)==="symbol"}function pt(B){return B===void 0}function Xt(B){return Pt(B)&&_e(B)==="[object RegExp]"}function Pt(B){return babelHelpers.typeof(B)==="object"&&B!==null}function ae(B){return Pt(B)&&_e(B)==="[object Date]"}function kt(B){return Pt(B)&&(_e(B)==="[object Error]"||B instanceof Error)}function Kt(B){return typeof B=="function"}function cr(B){return B===null||typeof B=="boolean"||typeof B=="number"||typeof B=="string"||babelHelpers.typeof(B)==="symbol"||typeof B>"u"}function hr(B){return Buffer.isBuffer(B)}function _e(B){return Object.prototype.toString.call(B)}function se(B){return B<10?"0"+B.toString(10):B.toString(10)}var _r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function yr(){var B=new Date,e=[se(B.getHours()),se(B.getMinutes()),se(B.getSeconds())].join(":");return[B.getDate(),_r[B.getMonth()],e].join(" ")}function Br(){console.log("%s - %s",yr(),ce.apply(null,arguments))}function Ie(B,e){if(!e||!Pt(e))return B;for(var y=Object.keys(e),b=y.length;b--;)B[y[b]]=e[y[b]];return B}function De(B,e){return Object.prototype.hasOwnProperty.call(B,e)}var Nr={inherits:tr,_extend:Ie,log:Br,isBuffer:hr,isPrimitive:cr,isFunction:Kt,isError:kt,isDate:ae,isObject:Pt,isRegExp:Xt,isUndefined:pt,isSymbol:lr,isString:xt,isNumber:Te,isNullOrUndefined:ar,isNull:Qt,isBoolean:he,isArray:we,inspect:Ot,deprecate:me,format:ce,debuglog:rr},rt=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.deprecate=e.isObjectLike=e.isDate=e.isBuffer=e.haveBuffer=e.isBigUInt64Array=e.isBigInt64Array=e.isUint8Array=e.randomBytes=e.normalizedFunctionString=void 0;function y(n){return n.toString().replace("function(","function (")}e.normalizedFunctionString=y;function b(n){let w=C.Buffer.alloc(n);for(let U=0;U<n;++U)w[U]=Math.floor(Math.random()*256);return w}if(e.randomBytes=b,typeof window<"u"&&window.crypto&&window.crypto.getRandomValues)e.randomBytes=n=>window.crypto.getRandomValues(C.Buffer.alloc(n));else{try{e.randomBytes=$e.randomBytes}catch{}e.randomBytes==null&&(e.randomBytes=b)}function l(n){return Object.prototype.toString.call(n)==="[object Uint8Array]"}e.isUint8Array=l;function f(n){return Object.prototype.toString.call(n)==="[object BigInt64Array]"}e.isBigInt64Array=f;function a(n){return Object.prototype.toString.call(n)==="[object BigUint64Array]"}e.isBigUInt64Array=a;function E(){return typeof Ht<"u"&&typeof Ht.Buffer<"u"}e.haveBuffer=E;function o(n){return E()&&C.Buffer.isBuffer(n)}e.isBuffer=o;function c(n){return h(n)&&Object.prototype.toString.call(n)==="[object Date]"}e.isDate=c;function h(n){return typeof n=="object"&&n!==null}e.isObjectLike=h;function p(n,w){if(typeof window>"u"||typeof self>"u")return Nr.deprecate(n,w);let U=!1;function N(...Y){return U||(console.warn(w),U=!0),n.apply(this,...Y)}return N}e.deprecate=p});st(rt);var Ur=rt.deprecate,Mr=rt.isObjectLike,Pr=rt.isDate,jr=rt.isBuffer,Yr=rt.haveBuffer,vr=rt.isBigUInt64Array,Fr=rt.isBigInt64Array,Lr=rt.isUint8Array,Cr=rt.randomBytes,zr=rt.normalizedFunctionString,Nt=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.DBRef=e.isDBRefLike=void 0;function y(l){return rt.isObjectLike(l)&&l.$id!=null&&l.$ref!=null}e.isDBRefLike=y;class b{constructor(f,a,E,o){let c=f.split(".");c.length===2&&(E=c.shift(),f=c.shift()),this.collection=f,this.oid=a,this.db=E,this.fields=o||{}}get namespace(){return this.collection}set namespace(f){this.collection=f}toJSON(){let f=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(f.$db=this.db),f}toExtendedJSON(f){f=f||{};let a={$ref:this.collection,$id:this.oid};return f.legacy||(this.db&&(a.$db=this.db),a=Object.assign(a,this.fields)),a}static fromExtendedJSON(f){let a=Object.assign({},f);return delete a.$ref,delete a.$id,delete a.$db,new b(f.$ref,f.$id,f.$db,a)}}e.DBRef=b,Object.defineProperty(b.prototype,"_bsontype",{value:"DBRef"})});st(Nt);var Jr=Nt.DBRef,Wr=Nt.isDBRefLike,K=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Long=void 0;let y;try{y=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}let b=1<<16,l=1<<24,f=b*b,a=f*f,E=a/2,o={},c={};class h{constructor(n=0,w=0,U){this.comp=h.prototype.compare,this.div=h.prototype.divide,this.eq=h.prototype.equals,this.gt=h.prototype.greaterThan,this.gte=h.prototype.greaterThanOrEqual,this.ge=h.prototype.greaterThanOrEqual,this.lt=h.prototype.lessThan,this.lte=h.prototype.lessThanOrEqual,this.mod=h.prototype.modulo,this.rem=h.prototype.modulo,this.mul=h.prototype.multiply,this.neg=h.prototype.negate,this.neq=h.prototype.notEquals,this.ne=h.prototype.notEquals,this.shl=h.prototype.shiftLeft,this.shr=h.prototype.shiftRight,this.shr_u=h.prototype.shiftRightUnsigned,this.shru=h.prototype.shiftRightUnsigned,this.sub=h.prototype.subtract,this.eqz=h.prototype.isZero,this.le=h.prototype.lessThanOrEqual,this.low=n|0,this.high=w|0,this.unsigned=!!U,Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}static fromBits(n,w,U){return new h(n,w,U)}static fromInt(n,w){let U,N,Y;return w?(n>>>=0,(Y=0<=n&&n<256)&&(N=c[n],N)?N:(U=h.fromBits(n,(n|0)<0?-1:0,!0),Y&&(c[n]=U),U)):(n|=0,(Y=-128<=n&&n<128)&&(N=o[n],N)?N:(U=h.fromBits(n,n<0?-1:0,!1),Y&&(o[n]=U),U))}static fromNumber(n,w){if(isNaN(n))return w?h.UZERO:h.ZERO;if(w){if(n<0)return h.UZERO;if(n>=a)return h.MAX_UNSIGNED_VALUE}else{if(n<=-E)return h.MIN_VALUE;if(n+1>=E)return h.MAX_VALUE}return n<0?h.fromNumber(-n,w).neg():h.fromBits(n%f|0,n/f|0,w)}static fromBigInt(n,w){return h.fromString(n.toString(),w)}static fromString(n,w,U){if(n.length===0)throw Error("empty string");if(n==="NaN"||n==="Infinity"||n==="+Infinity"||n==="-Infinity")return h.ZERO;if(typeof w=="number"?(U=w,w=!1):w=!!w,U=U||10,U<2||36<U)throw RangeError("radix");let N;if((N=n.indexOf("-"))>0)throw Error("interior hyphen");if(N===0)return h.fromString(n.substring(1),w,U).neg();let Y=h.fromNumber(Math.pow(U,8)),J=h.ZERO;for(let R=0;R<n.length;R+=8){let W=Math.min(8,n.length-R),x=parseInt(n.substring(R,R+W),U);if(W<8){let G=h.fromNumber(Math.pow(U,W));J=J.mul(G).add(h.fromNumber(x))}else J=J.mul(Y),J=J.add(h.fromNumber(x))}return J.unsigned=w,J}static fromBytes(n,w,U){return U?h.fromBytesLE(n,w):h.fromBytesBE(n,w)}static fromBytesLE(n,w){return new h(n[0]|n[1]<<8|n[2]<<16|n[3]<<24,n[4]|n[5]<<8|n[6]<<16|n[7]<<24,w)}static fromBytesBE(n,w){return new h(n[4]<<24|n[5]<<16|n[6]<<8|n[7],n[0]<<24|n[1]<<16|n[2]<<8|n[3],w)}static isLong(n){return rt.isObjectLike(n)&&n.__isLong__===!0}static fromValue(n,w){return typeof n=="number"?h.fromNumber(n,w):typeof n=="string"?h.fromString(n,w):h.fromBits(n.low,n.high,typeof w=="boolean"?w:n.unsigned)}add(n){h.isLong(n)||(n=h.fromValue(n));let w=this.high>>>16,U=this.high&65535,N=this.low>>>16,Y=this.low&65535,J=n.high>>>16,R=n.high&65535,W=n.low>>>16,x=n.low&65535,G=0,M=0,V=0,z=0;return z+=Y+x,V+=z>>>16,z&=65535,V+=N+W,M+=V>>>16,V&=65535,M+=U+R,G+=M>>>16,M&=65535,G+=w+J,G&=65535,h.fromBits(V<<16|z,G<<16|M,this.unsigned)}and(n){return h.isLong(n)||(n=h.fromValue(n)),h.fromBits(this.low&n.low,this.high&n.high,this.unsigned)}compare(n){if(h.isLong(n)||(n=h.fromValue(n)),this.eq(n))return 0;let w=this.isNegative(),U=n.isNegative();return w&&!U?-1:!w&&U?1:this.unsigned?n.high>>>0>this.high>>>0||n.high===this.high&&n.low>>>0>this.low>>>0?-1:1:this.sub(n).isNegative()?-1:1}divide(n){if(h.isLong(n)||(n=h.fromValue(n)),n.isZero())throw Error("division by zero");if(y){if(!this.unsigned&&this.high===-2147483648&&n.low===-1&&n.high===-1)return this;let Y=(this.unsigned?y.div_u:y.div_s)(this.low,this.high,n.low,n.high);return h.fromBits(Y,y.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?h.UZERO:h.ZERO;let w,U,N;if(this.unsigned){if(n.unsigned||(n=n.toUnsigned()),n.gt(this))return h.UZERO;if(n.gt(this.shru(1)))return h.UONE;N=h.UZERO}else{if(this.eq(h.MIN_VALUE))return n.eq(h.ONE)||n.eq(h.NEG_ONE)?h.MIN_VALUE:n.eq(h.MIN_VALUE)?h.ONE:(w=this.shr(1).div(n).shl(1),w.eq(h.ZERO)?n.isNegative()?h.ONE:h.NEG_ONE:(U=this.sub(n.mul(w)),N=w.add(U.div(n)),N));if(n.eq(h.MIN_VALUE))return this.unsigned?h.UZERO:h.ZERO;if(this.isNegative())return n.isNegative()?this.neg().div(n.neg()):this.neg().div(n).neg();if(n.isNegative())return this.div(n.neg()).neg();N=h.ZERO}for(U=this;U.gte(n);){w=Math.max(1,Math.floor(U.toNumber()/n.toNumber()));let Y=Math.ceil(Math.log(w)/Math.LN2),J=Y<=48?1:Math.pow(2,Y-48),R=h.fromNumber(w),W=R.mul(n);for(;W.isNegative()||W.gt(U);)w-=J,R=h.fromNumber(w,this.unsigned),W=R.mul(n);R.isZero()&&(R=h.ONE),N=N.add(R),U=U.sub(W)}return N}equals(n){return h.isLong(n)||(n=h.fromValue(n)),this.unsigned!==n.unsigned&&this.high>>>31===1&&n.high>>>31===1?!1:this.high===n.high&&this.low===n.low}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(h.MIN_VALUE)?64:this.neg().getNumBitsAbs();let n=this.high!==0?this.high:this.low,w;for(w=31;w>0&&!(n&1<<w);w--);return this.high!==0?w+33:w+1}greaterThan(n){return this.comp(n)>0}greaterThanOrEqual(n){return this.comp(n)>=0}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(n){return this.comp(n)<0}lessThanOrEqual(n){return this.comp(n)<=0}modulo(n){if(h.isLong(n)||(n=h.fromValue(n)),y){let w=(this.unsigned?y.rem_u:y.rem_s)(this.low,this.high,n.low,n.high);return h.fromBits(w,y.get_high(),this.unsigned)}return this.sub(this.div(n).mul(n))}multiply(n){if(this.isZero())return h.ZERO;if(h.isLong(n)||(n=h.fromValue(n)),y){let Z=y.mul(this.low,this.high,n.low,n.high);return h.fromBits(Z,y.get_high(),this.unsigned)}if(n.isZero())return h.ZERO;if(this.eq(h.MIN_VALUE))return n.isOdd()?h.MIN_VALUE:h.ZERO;if(n.eq(h.MIN_VALUE))return this.isOdd()?h.MIN_VALUE:h.ZERO;if(this.isNegative())return n.isNegative()?this.neg().mul(n.neg()):this.neg().mul(n).neg();if(n.isNegative())return this.mul(n.neg()).neg();if(this.lt(h.TWO_PWR_24)&&n.lt(h.TWO_PWR_24))return h.fromNumber(this.toNumber()*n.toNumber(),this.unsigned);let w=this.high>>>16,U=this.high&65535,N=this.low>>>16,Y=this.low&65535,J=n.high>>>16,R=n.high&65535,W=n.low>>>16,x=n.low&65535,G=0,M=0,V=0,z=0;return z+=Y*x,V+=z>>>16,z&=65535,V+=N*x,M+=V>>>16,V&=65535,V+=Y*W,M+=V>>>16,V&=65535,M+=U*x,G+=M>>>16,M&=65535,M+=N*W,G+=M>>>16,M&=65535,M+=Y*R,G+=M>>>16,M&=65535,G+=w*x+U*W+N*R+Y*J,G&=65535,h.fromBits(V<<16|z,G<<16|M,this.unsigned)}negate(){return!this.unsigned&&this.eq(h.MIN_VALUE)?h.MIN_VALUE:this.not().add(h.ONE)}not(){return h.fromBits(~this.low,~this.high,this.unsigned)}notEquals(n){return!this.equals(n)}or(n){return h.isLong(n)||(n=h.fromValue(n)),h.fromBits(this.low|n.low,this.high|n.high,this.unsigned)}shiftLeft(n){return h.isLong(n)&&(n=n.toInt()),(n&=63)===0?this:n<32?h.fromBits(this.low<<n,this.high<<n|this.low>>>32-n,this.unsigned):h.fromBits(0,this.low<<n-32,this.unsigned)}shiftRight(n){return h.isLong(n)&&(n=n.toInt()),(n&=63)===0?this:n<32?h.fromBits(this.low>>>n|this.high<<32-n,this.high>>n,this.unsigned):h.fromBits(this.high>>n-32,this.high>=0?0:-1,this.unsigned)}shiftRightUnsigned(n){if(h.isLong(n)&&(n=n.toInt()),n&=63,n===0)return this;{let w=this.high;if(n<32){let U=this.low;return h.fromBits(U>>>n|w<<32-n,w>>>n,this.unsigned)}else return n===32?h.fromBits(w,0,this.unsigned):h.fromBits(w>>>n-32,0,this.unsigned)}}subtract(n){return h.isLong(n)||(n=h.fromValue(n)),this.add(n.neg())}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*f+(this.low>>>0):this.high*f+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(n){return n?this.toBytesLE():this.toBytesBE()}toBytesLE(){let n=this.high,w=this.low;return[w&255,w>>>8&255,w>>>16&255,w>>>24,n&255,n>>>8&255,n>>>16&255,n>>>24]}toBytesBE(){let n=this.high,w=this.low;return[n>>>24,n>>>16&255,n>>>8&255,n&255,w>>>24,w>>>16&255,w>>>8&255,w&255]}toSigned(){return this.unsigned?h.fromBits(this.low,this.high,!1):this}toString(n){if(n=n||10,n<2||36<n)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(h.MIN_VALUE)){let Y=h.fromNumber(n),J=this.div(Y),R=J.mul(Y).sub(this);return J.toString(n)+R.toInt().toString(n)}else return"-"+this.neg().toString(n);let w=h.fromNumber(Math.pow(n,6),this.unsigned),U=this,N="";for(;;){let Y=U.div(w),R=(U.sub(Y.mul(w)).toInt()>>>0).toString(n);if(U=Y,U.isZero())return R+N;for(;R.length<6;)R="0"+R;N=""+R+N}}toUnsigned(){return this.unsigned?this:h.fromBits(this.low,this.high,!0)}xor(n){return h.isLong(n)||(n=h.fromValue(n)),h.fromBits(this.low^n.low,this.high^n.high,this.unsigned)}toExtendedJSON(n){return n&&n.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(n,w){let U=h.fromString(n.$numberLong);return w&&w.relaxed?U.toNumber():U}}e.Long=h,h.TWO_PWR_24=h.fromInt(l),h.MAX_UNSIGNED_VALUE=h.fromBits(-1,-1,!0),h.ZERO=h.fromInt(0),h.UZERO=h.fromInt(0,!0),h.ONE=h.fromInt(1),h.UONE=h.fromInt(1,!0),h.NEG_ONE=h.fromInt(-1),h.MAX_VALUE=h.fromBits(-1,2147483647,!1),h.MIN_VALUE=h.fromBits(0,-2147483648,!1),Object.defineProperty(h.prototype,"__isLong__",{value:!0}),Object.defineProperty(h.prototype,"_bsontype",{value:"Long"})});st(K);var Xr=K.Long,dt=ot(function(B,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Decimal128=void 0;let y=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,b=/^(\+|-)?(Infinity|inf)$/i,l=/^(\+|-)?NaN$/i,f=6111,a=-6176,E=6176,o=34,c=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),h=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),p=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),n=/^([-+])?(\d+)?$/,w=31,U=16383,N=30,Y=31;function J(V){return!isNaN(parseInt(V,10))}function R(V){let z=K.Long.fromNumber(1e9),Z=K.Long.fromNumber(0);if(!V.parts[0]&&!V.parts[1]&&!V.parts[2]&&!V.parts[3])return{quotient:V,rem:Z};for(let s=0;s<=3;s++)Z=Z.shiftLeft(32),Z=Z.add(new K.Long(V.parts[s],0)),V.parts[s]=Z.div(z).low,Z=Z.modulo(z);return{quotient:V,rem:Z}}function W(V,z){if(!V&&!z)return{high:K.Long.fromNumber(0),low:K.Long.fromNumber(0)};let Z=V.shiftRightUnsigned(32),s=new K.Long(V.getLowBits(),0),A=z.shiftRightUnsigned(32),O=new K.Long(z.getLowBits(),0),i=Z.multiply(A),m=Z.multiply(O),D=s.multiply(A),j=s.multiply(O);return i=i.add(m.shiftRightUnsigned(32)),m=new K.Long(m.getLowBits(),0).add(D).add(j.shiftRightUnsigned(32)),i=i.add(m.shiftRightUnsigned(32)),j=m.shiftLeft(32).add(new K.Long(j.getLowBits(),0)),{high:i,low:j}}function x(V,z){let Z=V.high>>>0,s=z.high>>>0;if(Z<s)return!0;if(Z===s){let A=V.low>>>0,O=z.low>>>0;if(A<O)return!0}return!1}function G(V,z){throw new TypeError(`"${V}" is not a valid Decimal128 string - ${z}`)}class M{constructor(z){this.bytes=z}static fromString(z){let Z=!1,s=!1,A=!1,O=0,i=0,m=0,D=0,j=0,F=[0],g=0