@letscooee/web-sdk
Version:
Engage uniquely and boost conversions with AI-powered customer journeys driven by real-time intent
1 lines • 127 kB
JavaScript
import{$ as te,Aa as Ai,Ab as ki,B as q,Bb as Fi,C as W,Cb as ie,Db as ot,E as Kt,Eb as it,Ga as Ti,Gb as re,H as Jt,Ha as Ni,Hb as xt,I as ut,Ia as Ci,Ib as Ui,J as Ei,Jb as Bt,K as bi,Kb as ji,Lb as Vi,Mb as ne,R as qt,T as Et,U as Qt,V as Ce,W as Ie,X as lt,Z as Rt,a as fi,ba as Oi,c as Y,ca as bt,d as pi,da as Q,ea as ft,fa as Si,g as di,ha as ee,hb as Ii,i as gi,ib as Di,kb as Ri,l as _i,m as mi,n as yi,nb as xi,o as vi,q as wi,qb as Bi,rb as Li,s as j,u as G,v as S,w as Zt,yb as Mi,zb as Pi}from"./chunk-K77Q3IPF.js";import{a as F,b as Gt,e as hi,f as ui}from"./chunk-V7UGKYBN.js";var Yi=hi(($i,ce)=>{"use strict";(function(e){"use strict";var t={};t.VERSION="1.6.1";var i,r={},s=function(p,g){return function(){return g.apply(p,arguments)}},l=function(){var p=arguments,g=p[0],m,v;for(v=1;v<p.length;v++)for(m in p[v])!(m in g)&&p[v].hasOwnProperty(m)&&(g[m]=p[v][m]);return g},a=function(p,g){return{value:p,name:g}};t.TRACE=a(1,"TRACE"),t.DEBUG=a(2,"DEBUG"),t.INFO=a(3,"INFO"),t.TIME=a(4,"TIME"),t.WARN=a(5,"WARN"),t.ERROR=a(8,"ERROR"),t.OFF=a(99,"OFF");var f=function(p){this.context=p,this.setLevel(p.filterLevel),this.log=this.info};f.prototype={setLevel:function(p){p&&"value"in p&&(this.context.filterLevel=p)},getLevel:function(){return this.context.filterLevel},enabledFor:function(p){var g=this.context.filterLevel;return p.value>=g.value},trace:function(){this.invoke(t.TRACE,arguments)},debug:function(){this.invoke(t.DEBUG,arguments)},info:function(){this.invoke(t.INFO,arguments)},warn:function(){this.invoke(t.WARN,arguments)},error:function(){this.invoke(t.ERROR,arguments)},time:function(p){typeof p=="string"&&p.length>0&&this.invoke(t.TIME,[p,"start"])},timeEnd:function(p){typeof p=="string"&&p.length>0&&this.invoke(t.TIME,[p,"end"])},invoke:function(p,g){i&&this.enabledFor(p)&&i(g,l({level:p},this.context))}};var d=new f({filterLevel:t.OFF});(function(){var p=t;p.enabledFor=s(d,d.enabledFor),p.trace=s(d,d.trace),p.debug=s(d,d.debug),p.time=s(d,d.time),p.timeEnd=s(d,d.timeEnd),p.info=s(d,d.info),p.warn=s(d,d.warn),p.error=s(d,d.error),p.log=p.info})(),t.setHandler=function(p){i=p},t.setLevel=function(p){d.setLevel(p);for(var g in r)r.hasOwnProperty(g)&&r[g].setLevel(p)},t.getLevel=function(){return d.getLevel()},t.get=function(p){return r[p]||(r[p]=new f(l({name:p},d.context)))},t.createDefaultHandler=function(p){p=p||{},p.formatter=p.formatter||function(b,w){w.name&&b.unshift("["+w.name+"]")};var g={},m=function(v,b){Function.prototype.apply.call(v,console,b)};return typeof console>"u"?function(){}:function(v,b){v=Array.prototype.slice.call(v);var w=console.log,A;b.level===t.TIME?(A=(b.name?"["+b.name+"] ":"")+v[0],v[1]==="start"?console.time?console.time(A):g[A]=new Date().getTime():console.timeEnd?console.timeEnd(A):m(w,[A+": "+(new Date().getTime()-g[A])+"ms"])):(b.level===t.WARN&&console.warn?w=console.warn:b.level===t.ERROR&&console.error?w=console.error:b.level===t.INFO&&console.info?w=console.info:b.level===t.DEBUG&&console.debug?w=console.debug:b.level===t.TRACE&&console.trace&&(w=console.trace),p.formatter(v,b),m(w,v))}},t.useDefaults=function(p){t.setLevel(p&&p.defaultLevel||t.DEBUG),t.setHandler(t.createDefaultHandler(p))},t.setDefaults=t.useDefaults,typeof define=="function"&&define.amd?define(t):typeof ce<"u"&&ce.exports?ce.exports=t:(t._prevLogger=e.Logger,t.noConflict=function(){return e.Logger=t._prevLogger,t},e.Logger=t)})($i)});var Ur=hi(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.URLBuilder=void 0;var _o=(function(){function e(t){try{this.base=new URL(t),this.params=new URLSearchParams(this.base.search.slice(1))}catch(i){console.error("Un-parsable URL",i)}}return e.prototype.appendQueryParam=function(t,i){this.params.append(t,i?i.toString():"")},e.prototype.clearQueryParams=function(){return this.params=new URLSearchParams,this},e.prototype.deleteQueryParam=function(t){this.params.delete(t)},e.prototype.getBase=function(){return this.base},e.prototype.getPath=function(){return this.base.pathname},e.prototype.getHostname=function(){return this.base.hostname},e.prototype.getParams=function(){return this.params},e.prototype.getQueryParam=function(t){if(!this.params)return"";var i=this.params.get(t);return!i||i==="undefined"||i==="null"?void 0:i},e.prototype.getQueryString=function(){return this.params.toString()},e.prototype.setPath=function(t){return this.base.pathname=t,this},e.prototype.setQueryParam=function(t,i){return this.params.set(t,i?i.toString():""),this},e.prototype.setQueryString=function(t){if(t)return t[0]==="?"&&(t=t.slice(1)),this.params=new URLSearchParams(t),this},e.prototype.toString=function(){var t=this.params.toString();return t===""?this.base.search="":this.base.search="?"+t,this.base.toString()},e})();Oe.URLBuilder=_o});var De="13.0.14";var Gr=De.split("-")[0].split(".").slice(0,3).map(e=>e.padStart(2,"0")).join("");var Hi="CooeeSDK",oe=De,Eo=parseInt(Gr,10);var se=`https://cdn.jsdelivr.net/npm/@letscooee/web-sdk@${oe}/dist`,ae={apiURL:"https://api.sdk.letscooee.com",debug:!1,mode:"production",baseURL:se,styleURL:`${se}/widget.min.css`,widgetURL:`${se}/widget.min.js`,swiperStyleURL:`${se}/swiper-bundle.min.css`};var X=ui(Yi());var Lt=class{static debuggerEl;static infoLogs=[];static log(...t){X.default.info(...t)}static verbose(...t){X.default.debug(...t)}static error(...t){X.default.error(...t)}static warn(...t){X.default.warn(...t)}static info(...t){X.default.info(...t),this.infoLogs.push({time:new Date,message:t.join(" ")}),this.addToDebugger()}static trace(...t){X.default.trace(...t)}static addToDebugger(){sessionStorage.cooeeDebug&&(this.debuggerEl=this.debuggerEl??document.querySelector("cooee-debugger"),this.debuggerEl&&this.debuggerEl&&(this.debuggerEl.logs=[...this.infoLogs]))}};function No(e=Hi){X.default.useDefaults({formatter:function(t){t.unshift(`${e} (v${oe}):`)}}),Zr()&&(localStorage.cooeeLogLevel="TRACE"),localStorage.cooeeLogLevel?X.default.setLevel(X.default[localStorage.cooeeLogLevel]):X.default.setLevel(ae.debug?X.default.TRACE:X.default.OFF)}function Zr(){let e=Kr();return e==="1"||e==="on"}function Kr(){return new URL(location.href).searchParams?.get("cooee-debug")}var Ro=new G("EngagementContext"),xo=new G("EventData");function Jr(e,t){return t={exports:{}},e(t,t.exports),t.exports}var qr=rn,Qr=on,tn=cn,nt=[],K=[],en=typeof Uint8Array<"u"?Uint8Array:Array,Re="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(pt=0,Wi=Re.length;pt<Wi;++pt)nt[pt]=Re[pt],K[Re.charCodeAt(pt)]=pt;var pt,Wi;K[45]=62;K[95]=63;function ar(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=e.indexOf("=");i===-1&&(i=t);var r=i===t?0:4-i%4;return[i,r]}function rn(e){var t=ar(e),i=t[0],r=t[1];return(i+r)*3/4-r}function nn(e,t,i){return(t+i)*3/4-i}function on(e){var t,i=ar(e),r=i[0],s=i[1],l=new en(nn(e,r,s)),a=0,f=s>0?r-4:r,d;for(d=0;d<f;d+=4)t=K[e.charCodeAt(d)]<<18|K[e.charCodeAt(d+1)]<<12|K[e.charCodeAt(d+2)]<<6|K[e.charCodeAt(d+3)],l[a++]=t>>16&255,l[a++]=t>>8&255,l[a++]=t&255;return s===2&&(t=K[e.charCodeAt(d)]<<2|K[e.charCodeAt(d+1)]>>4,l[a++]=t&255),s===1&&(t=K[e.charCodeAt(d)]<<10|K[e.charCodeAt(d+1)]<<4|K[e.charCodeAt(d+2)]>>2,l[a++]=t>>8&255,l[a++]=t&255),l}function sn(e){return nt[e>>18&63]+nt[e>>12&63]+nt[e>>6&63]+nt[e&63]}function an(e,t,i){for(var r,s=[],l=t;l<i;l+=3)r=(e[l]<<16&16711680)+(e[l+1]<<8&65280)+(e[l+2]&255),s.push(sn(r));return s.join("")}function cn(e){for(var t,i=e.length,r=i%3,s=[],l=16383,a=0,f=i-r;a<f;a+=l)s.push(an(e,a,a+l>f?f:a+l));return r===1?(t=e[i-1],s.push(nt[t>>2]+nt[t<<4&63]+"==")):r===2&&(t=(e[i-2]<<8)+e[i-1],s.push(nt[t>>10]+nt[t>>4&63]+nt[t<<2&63]+"=")),s.join("")}var xe={byteLength:qr,toByteArray:Qr,fromByteArray:tn};var ln=function(t,i,r,s,l){var a,f,d=l*8-s-1,p=(1<<d)-1,g=p>>1,m=-7,v=r?l-1:0,b=r?-1:1,w=t[i+v];for(v+=b,a=w&(1<<-m)-1,w>>=-m,m+=d;m>0;a=a*256+t[i+v],v+=b,m-=8);for(f=a&(1<<-m)-1,a>>=-m,m+=s;m>0;f=f*256+t[i+v],v+=b,m-=8);if(a===0)a=1-g;else{if(a===p)return f?NaN:(w?-1:1)*(1/0);f=f+Math.pow(2,s),a=a-g}return(w?-1:1)*f*Math.pow(2,a-s)},hn=function(t,i,r,s,l,a){var f,d,p,g=a*8-l-1,m=(1<<g)-1,v=m>>1,b=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=s?0:a-1,A=s?1:-1,k=i<0||i===0&&1/i<0?1:0;for(i=Math.abs(i),isNaN(i)||i===1/0?(d=isNaN(i)?1:0,f=m):(f=Math.floor(Math.log(i)/Math.LN2),i*(p=Math.pow(2,-f))<1&&(f--,p*=2),f+v>=1?i+=b/p:i+=b*Math.pow(2,1-v),i*p>=2&&(f++,p/=2),f+v>=m?(d=0,f=m):f+v>=1?(d=(i*p-1)*Math.pow(2,l),f=f+v):(d=i*Math.pow(2,v-1)*Math.pow(2,l),f=0));l>=8;t[r+w]=d&255,w+=A,d/=256,l-=8);for(f=f<<l|d,g+=l;g>0;t[r+w]=f&255,w+=A,f/=256,g-=8);t[r+w-A]|=k*128},Ot={read:ln,write:hn},ue=Jr(function(e,t){var i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=M,t.INSPECT_MAX_BYTES=50;var r=2147483647;t.kMaxLength=r,a.TYPED_ARRAY_SUPPORT=s(),!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 s(){try{var c=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(c,n),c.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 l(c){if(c>r)throw new RangeError('The value "'+c+'" is invalid for option "size"');var n=new Uint8Array(c);return Object.setPrototypeOf(n,a.prototype),n}function a(c,n,o){if(typeof c=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(c)}return f(c,n,o)}a.poolSize=8192;function f(c,n,o){if(typeof c=="string")return m(c,n);if(ArrayBuffer.isView(c))return b(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(c));if(et(c,ArrayBuffer)||c&&et(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(et(c,SharedArrayBuffer)||c&&et(c.buffer,SharedArrayBuffer)))return w(c,n,o);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return a.from(h,n,o);var u=A(c);if(u)return u;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return a.from(c[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(c))}a.from=function(c,n,o){return f(c,n,o)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function d(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function p(c,n,o){return d(c),c<=0?l(c):n!==void 0?typeof o=="string"?l(c).fill(n,o):l(c).fill(n):l(c)}a.alloc=function(c,n,o){return p(c,n,o)};function g(c){return d(c),l(c<0?0:k(c)|0)}a.allocUnsafe=function(c){return g(c)},a.allocUnsafeSlow=function(c){return g(c)};function m(c,n){if((typeof n!="string"||n==="")&&(n="utf8"),!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var o=P(c,n)|0,h=l(o),u=h.write(c,n);return u!==o&&(h=h.slice(0,u)),h}function v(c){for(var n=c.length<0?0:k(c.length)|0,o=l(n),h=0;h<n;h+=1)o[h]=c[h]&255;return o}function b(c){if(et(c,Uint8Array)){var n=new Uint8Array(c);return w(n.buffer,n.byteOffset,n.byteLength)}return v(c)}function w(c,n,o){if(n<0||c.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');var h;return n===void 0&&o===void 0?h=new Uint8Array(c):o===void 0?h=new Uint8Array(c,n):h=new Uint8Array(c,n,o),Object.setPrototypeOf(h,a.prototype),h}function A(c){if(a.isBuffer(c)){var n=k(c.length)|0,o=l(n);return o.length===0||c.copy(o,0,0,n),o}if(c.length!==void 0)return typeof c.length!="number"||Ne(c.length)?l(0):v(c);if(c.type==="Buffer"&&Array.isArray(c.data))return v(c.data)}function k(c){if(c>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return c|0}function M(c){return+c!=c&&(c=0),a.alloc(+c)}a.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==a.prototype},a.compare=function(n,o){if(et(n,Uint8Array)&&(n=a.from(n,n.offset,n.byteLength)),et(o,Uint8Array)&&(o=a.from(o,o.offset,o.byteLength)),!a.isBuffer(n)||!a.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===o)return 0;for(var h=n.length,u=o.length,_=0,y=Math.min(h,u);_<y;++_)if(n[_]!==o[_]){h=n[_],u=o[_];break}return h<u?-1:u<h?1:0},a.isEncoding=function(n){switch(String(n).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(n,o){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return a.alloc(0);var h;if(o===void 0)for(o=0,h=0;h<n.length;++h)o+=n[h].length;var u=a.allocUnsafe(o),_=0;for(h=0;h<n.length;++h){var y=n[h];if(et(y,Uint8Array))_+y.length>u.length?a.from(y).copy(u,_):Uint8Array.prototype.set.call(u,y,_);else if(a.isBuffer(y))y.copy(u,_);else throw new TypeError('"list" argument must be an Array of Buffers');_+=y.length}return u};function P(c,n){if(a.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||et(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(c));var o=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&o===0)return 0;for(var u=!1;;)switch(n){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return Te(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return ai(c).length;default:if(u)return h?-1:Te(c).length;n=(""+n).toLowerCase(),u=!0}}a.byteLength=P;function H(c,n,o){var h=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,n>>>=0,o<=n))return"";for(c||(c="utf8");;)switch(c){case"hex":return J(this,n,o);case"utf8":case"utf-8":return vt(this,n,o);case"ascii":return wt(this,n,o);case"latin1":case"binary":return x(this,n,o);case"base64":return yt(this,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,n,o);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}a.prototype._isBuffer=!0;function O(c,n,o){var h=c[n];c[n]=c[o],c[o]=h}a.prototype.swap16=function(){var n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var o=0;o<n;o+=2)O(this,o,o+1);return this},a.prototype.swap32=function(){var n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var o=0;o<n;o+=4)O(this,o,o+3),O(this,o+1,o+2);return this},a.prototype.swap64=function(){var n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var o=0;o<n;o+=8)O(this,o,o+7),O(this,o+1,o+6),O(this,o+2,o+5),O(this,o+3,o+4);return this},a.prototype.toString=function(){var n=this.length;return n===0?"":arguments.length===0?vt(this,0,n):H.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(n){if(!a.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:a.compare(this,n)===0},a.prototype.inspect=function(){var n="",o=t.INSPECT_MAX_BYTES;return n=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(n+=" ... "),"<Buffer "+n+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(n,o,h,u,_){if(et(n,Uint8Array)&&(n=a.from(n,n.offset,n.byteLength)),!a.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(n));if(o===void 0&&(o=0),h===void 0&&(h=n?n.length:0),u===void 0&&(u=0),_===void 0&&(_=this.length),o<0||h>n.length||u<0||_>this.length)throw new RangeError("out of range index");if(u>=_&&o>=h)return 0;if(u>=_)return-1;if(o>=h)return 1;if(o>>>=0,h>>>=0,u>>>=0,_>>>=0,this===n)return 0;for(var y=_-u,N=h-o,D=Math.min(y,N),R=this.slice(u,_),U=n.slice(o,h),B=0;B<D;++B)if(R[B]!==U[B]){y=R[B],N=U[B];break}return y<N?-1:N<y?1:0};function z(c,n,o,h,u){if(c.length===0)return-1;if(typeof o=="string"?(h=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,Ne(o)&&(o=u?0:c.length-1),o<0&&(o=c.length+o),o>=c.length){if(u)return-1;o=c.length-1}else if(o<0)if(u)o=0;else return-1;if(typeof n=="string"&&(n=a.from(n,h)),a.isBuffer(n))return n.length===0?-1:tt(c,n,o,h,u);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?u?Uint8Array.prototype.indexOf.call(c,n,o):Uint8Array.prototype.lastIndexOf.call(c,n,o):tt(c,[n],o,h,u);throw new TypeError("val must be string, number or Buffer")}function tt(c,n,o,h,u){var _=1,y=c.length,N=n.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||n.length<2)return-1;_=2,y/=2,N/=2,o/=2}function D(ci,li){return _===1?ci[li]:ci.readUInt16BE(li*_)}var R;if(u){var U=-1;for(R=o;R<y;R++)if(D(c,R)===D(n,U===-1?0:R-U)){if(U===-1&&(U=R),R-U+1===N)return U*_}else U!==-1&&(R-=R-U),U=-1}else for(o+N>y&&(o=y-N),R=o;R>=0;R--){for(var B=!0,zt=0;zt<N;zt++)if(D(c,R+zt)!==D(n,zt)){B=!1;break}if(B)return R}return-1}a.prototype.includes=function(n,o,h){return this.indexOf(n,o,h)!==-1},a.prototype.indexOf=function(n,o,h){return z(this,n,o,h,!0)},a.prototype.lastIndexOf=function(n,o,h){return z(this,n,o,h,!1)};function at(c,n,o,h){o=Number(o)||0;var u=c.length-o;h?(h=Number(h),h>u&&(h=u)):h=u;var _=n.length;h>_/2&&(h=_/2);for(var y=0;y<h;++y){var N=parseInt(n.substr(y*2,2),16);if(Ne(N))return y;c[o+y]=N}return y}function Se(c,n,o,h){return Xt(Te(n,c.length-o),c,o,h)}function Dt(c,n,o,h){return Xt(Yr(n),c,o,h)}function Ae(c,n,o,h){return Xt(ai(n),c,o,h)}function Yt(c,n,o,h){return Xt(Wr(n,c.length-o),c,o,h)}a.prototype.write=function(n,o,h,u){if(o===void 0)u="utf8",h=this.length,o=0;else if(h===void 0&&typeof o=="string")u=o,h=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(h)?(h=h>>>0,u===void 0&&(u="utf8")):(u=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var _=this.length-o;if((h===void 0||h>_)&&(h=_),n.length>0&&(h<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");u||(u="utf8");for(var y=!1;;)switch(u){case"hex":return at(this,n,o,h);case"utf8":case"utf-8":return Se(this,n,o,h);case"ascii":case"latin1":case"binary":return Dt(this,n,o,h);case"base64":return Ae(this,n,o,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yt(this,n,o,h);default:if(y)throw new TypeError("Unknown encoding: "+u);u=(""+u).toLowerCase(),y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function yt(c,n,o){return n===0&&o===c.length?xe.fromByteArray(c):xe.fromByteArray(c.slice(n,o))}function vt(c,n,o){o=Math.min(c.length,o);for(var h=[],u=n;u<o;){var _=c[u],y=null,N=_>239?4:_>223?3:_>191?2:1;if(u+N<=o){var D,R,U,B;switch(N){case 1:_<128&&(y=_);break;case 2:D=c[u+1],(D&192)===128&&(B=(_&31)<<6|D&63,B>127&&(y=B));break;case 3:D=c[u+1],R=c[u+2],(D&192)===128&&(R&192)===128&&(B=(_&15)<<12|(D&63)<<6|R&63,B>2047&&(B<55296||B>57343)&&(y=B));break;case 4:D=c[u+1],R=c[u+2],U=c[u+3],(D&192)===128&&(R&192)===128&&(U&192)===128&&(B=(_&15)<<18|(D&63)<<12|(R&63)<<6|U&63,B>65535&&B<1114112&&(y=B))}}y===null?(y=65533,N=1):y>65535&&(y-=65536,h.push(y>>>10&1023|55296),y=56320|y&1023),h.push(y),u+=N}return Wt(h)}var ct=4096;function Wt(c){var n=c.length;if(n<=ct)return String.fromCharCode.apply(String,c);for(var o="",h=0;h<n;)o+=String.fromCharCode.apply(String,c.slice(h,h+=ct));return o}function wt(c,n,o){var h="";o=Math.min(c.length,o);for(var u=n;u<o;++u)h+=String.fromCharCode(c[u]&127);return h}function x(c,n,o){var h="";o=Math.min(c.length,o);for(var u=n;u<o;++u)h+=String.fromCharCode(c[u]);return h}function J(c,n,o){var h=c.length;(!n||n<0)&&(n=0),(!o||o<0||o>h)&&(o=h);for(var u="",_=n;_<o;++_)u+=Xr[c[_]];return u}function C(c,n,o){for(var h=c.slice(n,o),u="",_=0;_<h.length-1;_+=2)u+=String.fromCharCode(h[_]+h[_+1]*256);return u}a.prototype.slice=function(n,o){var h=this.length;n=~~n,o=o===void 0?h:~~o,n<0?(n+=h,n<0&&(n=0)):n>h&&(n=h),o<0?(o+=h,o<0&&(o=0)):o>h&&(o=h),o<n&&(o=n);var u=this.subarray(n,o);return Object.setPrototypeOf(u,a.prototype),u};function T(c,n,o){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+n>o)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(n,o,h){n=n>>>0,o=o>>>0,h||T(n,o,this.length);for(var u=this[n],_=1,y=0;++y<o&&(_*=256);)u+=this[n+y]*_;return u},a.prototype.readUintBE=a.prototype.readUIntBE=function(n,o,h){n=n>>>0,o=o>>>0,h||T(n,o,this.length);for(var u=this[n+--o],_=1;o>0&&(_*=256);)u+=this[n+--o]*_;return u},a.prototype.readUint8=a.prototype.readUInt8=function(n,o){return n=n>>>0,o||T(n,1,this.length),this[n]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(n,o){return n=n>>>0,o||T(n,2,this.length),this[n]|this[n+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(n,o){return n=n>>>0,o||T(n,2,this.length),this[n]<<8|this[n+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(n,o){return n=n>>>0,o||T(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(n,o){return n=n>>>0,o||T(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},a.prototype.readIntLE=function(n,o,h){n=n>>>0,o=o>>>0,h||T(n,o,this.length);for(var u=this[n],_=1,y=0;++y<o&&(_*=256);)u+=this[n+y]*_;return _*=128,u>=_&&(u-=Math.pow(2,8*o)),u},a.prototype.readIntBE=function(n,o,h){n=n>>>0,o=o>>>0,h||T(n,o,this.length);for(var u=o,_=1,y=this[n+--u];u>0&&(_*=256);)y+=this[n+--u]*_;return _*=128,y>=_&&(y-=Math.pow(2,8*o)),y},a.prototype.readInt8=function(n,o){return n=n>>>0,o||T(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},a.prototype.readInt16LE=function(n,o){n=n>>>0,o||T(n,2,this.length);var h=this[n]|this[n+1]<<8;return h&32768?h|4294901760:h},a.prototype.readInt16BE=function(n,o){n=n>>>0,o||T(n,2,this.length);var h=this[n+1]|this[n]<<8;return h&32768?h|4294901760:h},a.prototype.readInt32LE=function(n,o){return n=n>>>0,o||T(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},a.prototype.readInt32BE=function(n,o){return n=n>>>0,o||T(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},a.prototype.readFloatLE=function(n,o){return n=n>>>0,o||T(n,4,this.length),Ot.read(this,n,!0,23,4)},a.prototype.readFloatBE=function(n,o){return n=n>>>0,o||T(n,4,this.length),Ot.read(this,n,!1,23,4)},a.prototype.readDoubleLE=function(n,o){return n=n>>>0,o||T(n,8,this.length),Ot.read(this,n,!0,52,8)},a.prototype.readDoubleBE=function(n,o){return n=n>>>0,o||T(n,8,this.length),Ot.read(this,n,!1,52,8)};function $(c,n,o,h,u,_){if(!a.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>u||n<_)throw new RangeError('"value" argument is out of bounds');if(o+h>c.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(n,o,h,u){if(n=+n,o=o>>>0,h=h>>>0,!u){var _=Math.pow(2,8*h)-1;$(this,n,o,h,_,0)}var y=1,N=0;for(this[o]=n&255;++N<h&&(y*=256);)this[o+N]=n/y&255;return o+h},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(n,o,h,u){if(n=+n,o=o>>>0,h=h>>>0,!u){var _=Math.pow(2,8*h)-1;$(this,n,o,h,_,0)}var y=h-1,N=1;for(this[o+y]=n&255;--y>=0&&(N*=256);)this[o+y]=n/N&255;return o+h},a.prototype.writeUint8=a.prototype.writeUInt8=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,1,255,0),this[o]=n&255,o+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,2,65535,0),this[o]=n&255,this[o+1]=n>>>8,o+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,2,65535,0),this[o]=n>>>8,this[o+1]=n&255,o+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,4,4294967295,0),this[o+3]=n>>>24,this[o+2]=n>>>16,this[o+1]=n>>>8,this[o]=n&255,o+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,4,4294967295,0),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4},a.prototype.writeIntLE=function(n,o,h,u){if(n=+n,o=o>>>0,!u){var _=Math.pow(2,8*h-1);$(this,n,o,h,_-1,-_)}var y=0,N=1,D=0;for(this[o]=n&255;++y<h&&(N*=256);)n<0&&D===0&&this[o+y-1]!==0&&(D=1),this[o+y]=(n/N>>0)-D&255;return o+h},a.prototype.writeIntBE=function(n,o,h,u){if(n=+n,o=o>>>0,!u){var _=Math.pow(2,8*h-1);$(this,n,o,h,_-1,-_)}var y=h-1,N=1,D=0;for(this[o+y]=n&255;--y>=0&&(N*=256);)n<0&&D===0&&this[o+y+1]!==0&&(D=1),this[o+y]=(n/N>>0)-D&255;return o+h},a.prototype.writeInt8=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,1,127,-128),n<0&&(n=255+n+1),this[o]=n&255,o+1},a.prototype.writeInt16LE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,2,32767,-32768),this[o]=n&255,this[o+1]=n>>>8,o+2},a.prototype.writeInt16BE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,2,32767,-32768),this[o]=n>>>8,this[o+1]=n&255,o+2},a.prototype.writeInt32LE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,4,2147483647,-2147483648),this[o]=n&255,this[o+1]=n>>>8,this[o+2]=n>>>16,this[o+3]=n>>>24,o+4},a.prototype.writeInt32BE=function(n,o,h){return n=+n,o=o>>>0,h||$(this,n,o,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4};function ni(c,n,o,h,u,_){if(o+h>c.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function oi(c,n,o,h,u){return n=+n,o=o>>>0,u||ni(c,n,o,4),Ot.write(c,n,o,h,23,4),o+4}a.prototype.writeFloatLE=function(n,o,h){return oi(this,n,o,!0,h)},a.prototype.writeFloatBE=function(n,o,h){return oi(this,n,o,!1,h)};function si(c,n,o,h,u){return n=+n,o=o>>>0,u||ni(c,n,o,8),Ot.write(c,n,o,h,52,8),o+8}a.prototype.writeDoubleLE=function(n,o,h){return si(this,n,o,!0,h)},a.prototype.writeDoubleBE=function(n,o,h){return si(this,n,o,!1,h)},a.prototype.copy=function(n,o,h,u){if(!a.isBuffer(n))throw new TypeError("argument should be a Buffer");if(h||(h=0),!u&&u!==0&&(u=this.length),o>=n.length&&(o=n.length),o||(o=0),u>0&&u<h&&(u=h),u===h||n.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(u<0)throw new RangeError("sourceEnd out of bounds");u>this.length&&(u=this.length),n.length-o<u-h&&(u=n.length-o+h);var _=u-h;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(o,h,u):Uint8Array.prototype.set.call(n,this.subarray(h,u),o),_},a.prototype.fill=function(n,o,h,u){if(typeof n=="string"){if(typeof o=="string"?(u=o,o=0,h=this.length):typeof h=="string"&&(u=h,h=this.length),u!==void 0&&typeof u!="string")throw new TypeError("encoding must be a string");if(typeof u=="string"&&!a.isEncoding(u))throw new TypeError("Unknown encoding: "+u);if(n.length===1){var _=n.charCodeAt(0);(u==="utf8"&&_<128||u==="latin1")&&(n=_)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(o<0||this.length<o||this.length<h)throw new RangeError("Out of range index");if(h<=o)return this;o=o>>>0,h=h===void 0?this.length:h>>>0,n||(n=0);var y;if(typeof n=="number")for(y=o;y<h;++y)this[y]=n;else{var N=a.isBuffer(n)?n:a.from(n,u),D=N.length;if(D===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(y=0;y<h-o;++y)this[y+o]=N[y%D]}return this};var Hr=/[^+/0-9A-Za-z-_]/g;function $r(c){if(c=c.split("=")[0],c=c.trim().replace(Hr,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function Te(c,n){n=n||1/0;for(var o,h=c.length,u=null,_=[],y=0;y<h;++y){if(o=c.charCodeAt(y),o>55295&&o<57344){if(!u){if(o>56319){(n-=3)>-1&&_.push(239,191,189);continue}else if(y+1===h){(n-=3)>-1&&_.push(239,191,189);continue}u=o;continue}if(o<56320){(n-=3)>-1&&_.push(239,191,189),u=o;continue}o=(u-55296<<10|o-56320)+65536}else u&&(n-=3)>-1&&_.push(239,191,189);if(u=null,o<128){if((n-=1)<0)break;_.push(o)}else if(o<2048){if((n-=2)<0)break;_.push(o>>6|192,o&63|128)}else if(o<65536){if((n-=3)<0)break;_.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((n-=4)<0)break;_.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return _}function Yr(c){for(var n=[],o=0;o<c.length;++o)n.push(c.charCodeAt(o)&255);return n}function Wr(c,n){for(var o,h,u,_=[],y=0;y<c.length&&!((n-=2)<0);++y)o=c.charCodeAt(y),h=o>>8,u=o%256,_.push(u),_.push(h);return _}function ai(c){return xe.toByteArray($r(c))}function Xt(c,n,o,h){for(var u=0;u<h&&!(u+o>=n.length||u>=c.length);++u)n[u+o]=c[u];return u}function et(c,n){return c instanceof n||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===n.name}function Ne(c){return c!==c}var Xr=(function(){for(var c="0123456789abcdef",n=new Array(256),o=0;o<16;++o)for(var h=o*16,u=0;u<16;++u)n[h+u]=c[o]+c[u];return n})()}),I=ue.Buffer;ue.SlowBuffer;ue.INSPECT_MAX_BYTES;ue.kMaxLength;var ke=function(t,i){return ke=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var l in s)s.hasOwnProperty(l)&&(r[l]=s[l])},ke(t,i)};function fe(e,t){ke(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}var gt=(function(e){fe(t,e);function t(i){var r=e.call(this,i)||this;return Object.setPrototypeOf(r,t.prototype),r}return Object.defineProperty(t.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),t})(Error),L=(function(e){fe(t,e);function t(i){var r=e.call(this,i)||this;return Object.setPrototypeOf(r,t.prototype),r}return Object.defineProperty(t.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),t})(TypeError);function le(e){return e&&e.Math==Math&&e}function cr(){return le(typeof globalThis=="object"&&globalThis)||le(typeof window=="object"&&window)||le(typeof self=="object"&&self)||le(typeof global=="object"&&global)||Function("return this")()}function un(){var e=cr();return typeof e.navigator=="object"&&e.navigator.product==="ReactNative"}var fn=function(t){var i=un()?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(i);for(var r=I.alloc(t),s=0;s<t;++s)r[s]=Math.floor(Math.random()*256);return r},pn=function(){{if(typeof window<"u"){var e=window.crypto||window.msCrypto;if(e&&e.getRandomValues)return function(t){return e.getRandomValues(I.alloc(t))}}return typeof global<"u"&&global.crypto&&global.crypto.getRandomValues?function(t){return global.crypto.getRandomValues(I.alloc(t))}:fn}},lr=pn();function dn(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function Ue(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}function gn(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function _n(e){return Ft(e)&&Object.prototype.toString.call(e)==="[object Date]"}function Ft(e){return typeof e=="object"&&e!==null}function pe(e,t){var i=!1;function r(){for(var s=[],l=0;l<arguments.length;l++)s[l]=arguments[l];return i||(console.warn(t),i=!0),e.apply(this,s)}return r}function he(e){if(ArrayBuffer.isView(e))return I.from(e.buffer,e.byteOffset,e.byteLength);if(dn(e))return I.from(e);throw new L("Must use either Buffer or TypedArray")}var mn=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,hr=function(e){return typeof e=="string"&&mn.test(e)},Fe=function(e){if(!hr(e))throw new L('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var t=e.replace(/-/g,"");return I.from(t,"hex")},Xi=function(e,t){return t===void 0&&(t=!0),t?e.toString("hex",0,4)+"-"+e.toString("hex",4,6)+"-"+e.toString("hex",6,8)+"-"+e.toString("hex",8,10)+"-"+e.toString("hex",10,16):e.toString("hex")};var Lo=Math.pow(2,63)-1,Mo=-Math.pow(2,63),yn=Math.pow(2,53),vn=-Math.pow(2,53);var ur=4;var _t=(function(){function e(t,i){if(!(this instanceof e))return new e(t,i);if(t!=null&&typeof t!="string"&&!ArrayBuffer.isView(t)&&!(t instanceof ArrayBuffer)&&!Array.isArray(t))throw new L("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=i??e.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=I.alloc(e.BUFFER_SIZE),this.position=0):(typeof t=="string"?this.buffer=I.from(t,"binary"):Array.isArray(t)?this.buffer=I.from(t):this.buffer=he(t),this.position=this.buffer.byteLength)}return e.prototype.put=function(t){if(typeof t=="string"&&t.length!==1)throw new L("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new L("only accepts single character Uint8Array or Array");var i;if(typeof t=="string"?i=t.charCodeAt(0):typeof t=="number"?i=t:i=t[0],i<0||i>255)throw new L("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=i;else{var r=I.alloc(e.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=i}},e.prototype.write=function(t,i){if(i=typeof i=="number"?i:this.position,this.buffer.length<i+t.length){var r=I.alloc(this.buffer.length+t.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r}ArrayBuffer.isView(t)?(this.buffer.set(he(t),i),this.position=i+t.byteLength>this.position?i+t.length:this.position):typeof t=="string"&&(this.buffer.write(t,i,t.length,"binary"),this.position=i+t.length>this.position?i+t.length:this.position)},e.prototype.read=function(t,i){return i=i&&i>0?i:this.position,this.buffer.slice(t,t+i)},e.prototype.value=function(t){return t=!!t,t&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},e.prototype.length=function(){return this.position},e.prototype.toJSON=function(){return this.buffer.toString("base64")},e.prototype.toString=function(t){return this.buffer.toString(t)},e.prototype.toExtendedJSON=function(t){t=t||{};var i=this.buffer.toString("base64"),r=Number(this.sub_type).toString(16);return t.legacy?{$binary:i,$type:r.length===1?"0"+r:r}:{$binary:{base64:i,subType:r.length===1?"0"+r:r}}},e.prototype.toUUID=function(){if(this.sub_type===e.SUBTYPE_UUID)return new zi(this.buffer.slice(0,this.position));throw new gt('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(e.SUBTYPE_UUID,'" is currently supported.'))},e.fromExtendedJSON=function(t,i){i=i||{};var r,s;if("$binary"in t?i.legacy&&typeof t.$binary=="string"&&"$type"in t?(s=t.$type?parseInt(t.$type,16):0,r=I.from(t.$binary,"base64")):typeof t.$binary!="string"&&(s=t.$binary.subType?parseInt(t.$binary.subType,16):0,r=I.from(t.$binary.base64,"base64")):"$uuid"in t&&(s=4,r=Fe(t.$uuid)),!r)throw new L("Unexpected Binary Extended JSON format ".concat(JSON.stringify(t)));return s===ur?new zi(r):new e(r,s)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},e.BSON_BINARY_SUBTYPE_DEFAULT=0,e.BUFFER_SIZE=256,e.SUBTYPE_DEFAULT=0,e.SUBTYPE_FUNCTION=1,e.SUBTYPE_BYTE_ARRAY=2,e.SUBTYPE_UUID_OLD=3,e.SUBTYPE_UUID=4,e.SUBTYPE_MD5=5,e.SUBTYPE_ENCRYPTED=6,e.SUBTYPE_COLUMN=7,e.SUBTYPE_USER_DEFINED=128,e})();Object.defineProperty(_t.prototype,"_bsontype",{value:"Binary"});var Be=16,zi=(function(e){fe(t,e);function t(i){var r=this,s,l;if(i==null)s=t.generate();else if(i instanceof t)s=I.from(i.buffer),l=i.__id;else if(ArrayBuffer.isView(i)&&i.byteLength===Be)s=he(i);else if(typeof i=="string")s=Fe(i);else throw new L("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).");return r=e.call(this,s,ur)||this,r.__id=l,r}return Object.defineProperty(t.prototype,"id",{get:function(){return this.buffer},set:function(i){this.buffer=i,t.cacheHexString&&(this.__id=Xi(i))},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(i){if(i===void 0&&(i=!0),t.cacheHexString&&this.__id)return this.__id;var r=Xi(this.id,i);return t.cacheHexString&&(this.__id=r),r},t.prototype.toString=function(i){return i?this.id.toString(i):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(i){if(!i)return!1;if(i instanceof t)return i.id.equals(this.id);try{return new t(i).id.equals(this.id)}catch{return!1}},t.prototype.toBinary=function(){return new _t(this.id,_t.SUBTYPE_UUID)},t.generate=function(){var i=lr(Be);return i[6]=i[6]&15|64,i[8]=i[8]&63|128,I.from(i)},t.isValid=function(i){return i?i instanceof t?!0:typeof i=="string"?hr(i):Ue(i)?i.length!==Be?!1:(i[6]&240)===64&&(i[8]&128)===128:!1:!1},t.createFromHexString=function(i){var r=Fe(i);return new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},t})(_t),de=(function(){function e(t,i){if(!(this instanceof e))return new e(t,i);this.code=t,this.scope=i}return e.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},e.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},e.fromExtendedJSON=function(t){return new e(t.$code,t.$scope)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},e})();Object.defineProperty(de.prototype,"_bsontype",{value:"Code"});function wn(e){return Ft(e)&&e.$id!=null&&typeof e.$ref=="string"&&(e.$db==null||typeof e.$db=="string")}var Pt=(function(){function e(t,i,r,s){if(!(this instanceof e))return new e(t,i,r,s);var l=t.split(".");l.length===2&&(r=l.shift(),t=l.shift()),this.collection=t,this.oid=i,this.db=r,this.fields=s||{}}return Object.defineProperty(e.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(t.$db=this.db),t},e.prototype.toExtendedJSON=function(t){t=t||{};var i={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(i.$db=this.db),i=Object.assign(i,this.fields)),i},e.fromExtendedJSON=function(t){var i=Object.assign({},t);return delete i.$ref,delete i.$id,delete i.$db,new e(t.$ref,t.$id,t.$db,i)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var t=this.oid===void 0||this.oid.toString===void 0?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},e})();Object.defineProperty(Pt.prototype,"_bsontype",{value:"DBRef"});var Z=void 0;try{Z=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 Gi=65536,En=1<<24,At=Gi*Gi,fr=At*At,Zi=fr/2,Ki={},Ji={},E=(function(){function e(t,i,r){if(t===void 0&&(t=0),!(this instanceof e))return new e(t,i,r);typeof t=="bigint"?Object.assign(this,e.fromBigInt(t,!!i)):typeof t=="string"?Object.assign(this,e.fromString(t,!!i)):(this.low=t|0,this.high=i|0,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return e.fromBits=function(t,i,r){return new e(t,i,r)},e.fromInt=function(t,i){var r,s,l;return i?(t>>>=0,(l=0<=t&&t<256)&&(s=Ji[t],s)?s:(r=e.fromBits(t,(t|0)<0?-1:0,!0),l&&(Ji[t]=r),r)):(t|=0,(l=-128<=t&&t<128)&&(s=Ki[t],s)?s:(r=e.fromBits(t,t<0?-1:0,!1),l&&(Ki[t]=r),r))},e.fromNumber=function(t,i){if(isNaN(t))return i?e.UZERO:e.ZERO;if(i){if(t<0)return e.UZERO;if(t>=fr)return e.MAX_UNSIGNED_VALUE}else{if(t<=-Zi)return e.MIN_VALUE;if(t+1>=Zi)return e.MAX_VALUE}return t<0?e.fromNumber(-t,i).neg():e.fromBits(t%At|0,t/At|0,i)},e.fromBigInt=function(t,i){return e.fromString(t.toString(),i)},e.fromString=function(t,i,r){if(t.length===0)throw Error("empty string");if(t==="NaN"||t==="Infinity"||t==="+Infinity"||t==="-Infinity")return e.ZERO;if(typeof i=="number"?(r=i,i=!1):i=!!i,r=r||10,r<2||36<r)throw RangeError("radix");var s;if((s=t.indexOf("-"))>0)throw Error("interior hyphen");if(s===0)return e.fromString(t.substring(1),i,r).neg();for(var l=e.fromNumber(Math.pow(r,8)),a=e.ZERO,f=0;f<t.length;f+=8){var d=Math.min(8,t.length-f),p=parseInt(t.substring(f,f+d),r);if(d<8){var g=e.fromNumber(Math.pow(r,d));a=a.mul(g).add(e.fromNumber(p))}else a=a.mul(l),a=a.add(e.fromNumber(p))}return a.unsigned=i,a},e.fromBytes=function(t,i,r){return r?e.fromBytesLE(t,i):e.fromBytesBE(t,i)},e.fromBytesLE=function(t,i){return new e(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,i)},e.fromBytesBE=function(t,i){return new e(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],i)},e.isLong=function(t){return Ft(t)&&t.__isLong__===!0},e.fromValue=function(t,i){return typeof t=="number"?e.fromNumber(t,i):typeof t=="string"?e.fromString(t,i):e.fromBits(t.low,t.high,typeof i=="boolean"?i:t.unsigned)},e.prototype.add=function(t){e.isLong(t)||(t=e.fromValue(t));var i=this.high>>>16,r=this.high&65535,s=this.low>>>16,l=this.low&65535,a=t.high>>>16,f=t.high&65535,d=t.low>>>16,p=t.low&65535,g=0,m=0,v=0,b=0;return b+=l+p,v+=b>>>16,b&=65535,v+=s+d,m+=v>>>16,v&=65535,m+=r+f,g+=m>>>16,m&=65535,g+=i+a,g&=65535,e.fromBits(v<<16|b,g<<16|m,this.unsigned)},e.prototype.and=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)},e.prototype.compare=function(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;var i=this.isNegative(),r=t.isNegative();return i&&!r?-1:!i&&r?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},e.prototype.comp=function(t){return this.compare(t)},e.prototype.divide=function(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw Error("division by zero");if(Z){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var i=(this.unsigned?Z.div_u:Z.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(i,Z.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var r,s,l;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;l=e.UZERO}else{if(this.eq(e.MIN_VALUE)){if(t.eq(e.ONE)||t.eq(e.NEG_ONE))return e.MIN_VALUE;if(t.eq(e.MIN_VALUE))return e.ONE;var a=this.shr(1);return r=a.div(t).shl(1),r.eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(s=this.sub(t.mul(r)),l=r.add(s.div(t)),l)}else 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();l=e.ZERO}for(s=this;s.gte(t);){r=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var f=Math.ceil(Math.log(r)/Math.LN2),d=f<=48?1:Math.pow(2,f-48),p=e.fromNumber(r),g=p.mul(t);g.isNegative()||g.gt(s);)r-=d,p=e.fromNumber(r,this.unsigned),g=p.mul(t);p.isZero()&&(p=e.ONE),l=l.add(p),s=s.sub(g)}return l},e.prototype.div=function(t){return this.divide(t)},e.prototype.equals=function(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},e.prototype.eq=function(t){return this.equals(t)},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();var t=this.high!==0?this.high:this.low,i;for(i=31;i>0&&(t&1<<i)===0;i--);return this.high!==0?i+33:i+1},e.prototype.greaterThan=function(t){return this.comp(t)>0},e.prototype.gt=function(t){return this.greaterThan(t)},e.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},e.prototype.gte=function(t){return this.greaterThanOrEqual(t)},e.prototype.ge=function(t){return this.greaterThanOrEqual(t)},e.prototype.isEven=function(){return(this.low&1)===0},e.prototype.isNegative=function(){return!this.unsigned&&this.high<0},e.prototype.isOdd=function(){return(this.low&1)===1},e.prototype.isPositive=function(){return this.unsigned||this.high>=0},e.prototype.isZero=function(){return this.high===0&&this.low===0},e.prototype.lessThan=function(t){return this.comp(t)<0},e.prototype.lt=function(t){return this.lessThan(t)},e.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},e.prototype.lte=function(t){return this.lessThanOrEqual(t)},e.prototype.modulo=function(t){if(e.isLong(t)||(t=e.fromValue(t)),Z){var i=(this.unsigned?Z.rem_u:Z.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(i,Z.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},e.prototype.mod=function(t){return this.modulo(t)},e.prototype.rem=function(t){return this.modulo(t)},e.prototype.multiply=function(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),Z){var i=Z.mul(this.low,this.high,t.low,t.high);return e.fromBits(i,Z.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);var r=this.high>>>16,s=this.high&65535,l=this.low>>>16,a=this.low&65535,f=t.high>>>16,d=t.high&65535,p=t.low>>>16,g=t.low&65535,m=0,v=0,b=0,w=0;return w+=a*g,b+=w>>>16,w&=65535,b+=l*g,v+=b>>>16,b&=65535,b+=a*p,v+=b>>>16,b&=65535,v+=s*g,m+=v>>>16,v&=65535,v+=l*p,m+=v>>>16,v&=65535,v+=a*d,m+=v>>>16,v&=65535,m+=r*g+s*p+l*d+a*f,m&=65535,e.fromBits(b<<16|w,m<<16|v,this.unsigned)},e.prototype.mul=function(t){return this.multiply(t)},e.prototype.negate=function(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=function(){return this.negate()},e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.notEquals=function(t){return!this.equals(t)},e.prototype.neq=function(t){return this.notEquals(t)},e.prototype.ne=function(t){return this.notEquals(t)},e.prototype.or=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)},e.prototype.shiftLeft=function(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):e.fromBits(0,this.low<<t-32,this.unsigned)},e.prototype.shl=function(t){return this.shiftLeft(t)},e.prototype.shiftRight=function(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(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)},e.prototype.shr=function(t){return this.shiftRight(t)},e.prototype.shiftRightUnsigned=function(t){if(e.isLong(t)&&(t=t.toInt()),t&=63,t===0)return this;var i=this.high;if(t<32){var r=this.low;return e.fromBits(r>>>t|i<<32-t,i>>>t,this.unsigned)}else return t===32?e.fromBits(i,0,this.unsigned):e.fromBits(i>>>t-32,0,this.unsigned)},e.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},e.prototype.shru=function(t){return this.shiftRightUnsigned(t)},e.prototype.subtract=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())},e.prototype.sub=function(t){return this.subtract(t)},e.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},e.prototype.toNumber=function(){return this.