@verdant-web/store 3.3.1 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/index.js.map +2 -2
- package/dist/cjs/metadata/Metadata.d.ts +1 -0
- package/dist/cjs/metadata/Metadata.js +7 -4
- package/dist/cjs/metadata/Metadata.js.map +1 -1
- package/dist/esm/metadata/Metadata.d.ts +1 -0
- package/dist/esm/metadata/Metadata.js +7 -4
- package/dist/esm/metadata/Metadata.js.map +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/metadata/Metadata.ts +11 -7
package/dist/bundle/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Use "options.replacer" or "options.ignoreUnknown"
|
|
4
4
|
`)},_domwindow:function(){return h("domwindow")},_bigint:function(d){return h("bigint:"+d.toString())},_process:function(){return h("process")},_timer:function(){return h("timer")},_pipe:function(){return h("pipe")},_tcp:function(){return h("tcp")},_udp:function(){return h("udp")},_tty:function(){return h("tty")},_statwatcher:function(){return h("statwatcher")},_securecontext:function(){return h("securecontext")},_connection:function(){return h("connection")},_zlib:function(){return h("zlib")},_context:function(){return h("context")},_nodescript:function(){return h("nodescript")},_httpparser:function(){return h("httpparser")},_dataview:function(){return h("dataview")},_signal:function(){return h("signal")},_fsevent:function(){return h("fsevent")},_tlswrap:function(){return h("tlswrap")}}}function F(){return{buf:"",write:function(b){this.buf+=b},end:function(b){this.buf+=b},read:function(){return this.buf}}}e.writeToStream=function(b,_,u){return u===void 0&&(u=_,_={}),D(_=I(b,_),u).dispatch(b)}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){(function(y){"use strict";var C=typeof Uint8Array<"u"?Uint8Array:Array,w="+".charCodeAt(0),x="/".charCodeAt(0),I="0".charCodeAt(0),S="a".charCodeAt(0),D="A".charCodeAt(0),F="-".charCodeAt(0),b="_".charCodeAt(0);function _(u){return u=u.charCodeAt(0),u===w||u===F?62:u===x||u===b?63:u<I?-1:u<I+10?u-I+26+26:u<D+26?u-D:u<S+26?u-S+26:void 0}y.toByteArray=function(u){var h,d;if(0<u.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var O=u.length,O=u.charAt(O-2)==="="?2:u.charAt(O-1)==="="?1:0,E=new C(3*u.length/4-O),B=0<O?u.length-4:u.length,M=0;function j(k){E[M++]=k}for(h=0;h<B;h+=4,0)j((16711680&(d=_(u.charAt(h))<<18|_(u.charAt(h+1))<<12|_(u.charAt(h+2))<<6|_(u.charAt(h+3))))>>16),j((65280&d)>>8),j(255&d);return O==2?j(255&(d=_(u.charAt(h))<<2|_(u.charAt(h+1))>>4)):O==1&&(j((d=_(u.charAt(h))<<10|_(u.charAt(h+1))<<4|_(u.charAt(h+2))>>2)>>8&255),j(255&d)),E},y.fromByteArray=function(u){var h,d,O,E,B=u.length%3,M="";function j(k){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(k)}for(h=0,O=u.length-B;h<O;h+=3)d=(u[h]<<16)+(u[h+1]<<8)+u[h+2],M+=j((E=d)>>18&63)+j(E>>12&63)+j(E>>6&63)+j(63&E);switch(B){case 1:M=(M+=j((d=u[u.length-1])>>2))+j(d<<4&63)+"==";break;case 2:M=(M=(M+=j((d=(u[u.length-2]<<8)+u[u.length-1])>>10))+j(d>>4&63))+j(d<<2&63)+"="}return M}})(e===void 0?this.base64js={}:e)}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(i,t,e){(function(n,r,w,s,a,p,l,m,v){var y=i("base64-js"),C=i("ieee754");function w(c,f,g){if(!(this instanceof w))return new w(c,f,g);var A,P,T,N,W=typeof c;if(f==="base64"&&W=="string")for(c=(N=c).trim?N.trim():N.replace(/^\s+|\s+$/g,"");c.length%4!=0;)c+="=";if(W=="number")A=te(c);else if(W=="string")A=w.byteLength(c,f);else{if(W!="object")throw new Error("First argument needs to be a number, array or string.");A=te(c.length)}if(w._useTypedArrays?P=w._augment(new Uint8Array(A)):((P=this).length=A,P._isBuffer=!0),w._useTypedArrays&&typeof c.byteLength=="number")P._set(c);else if(H(N=c)||w.isBuffer(N)||N&&typeof N=="object"&&typeof N.length=="number")for(T=0;T<A;T++)w.isBuffer(c)?P[T]=c.readUInt8(T):P[T]=c[T];else if(W=="string")P.write(c,0,f);else if(W=="number"&&!w._useTypedArrays&&!g)for(T=0;T<A;T++)P[T]=0;return P}function x(c,f,g,A){return w._charsWritten=Et(function(P){for(var T=[],N=0;N<P.length;N++)T.push(255&P.charCodeAt(N));return T}(f),c,g,A)}function I(c,f,g,A){return w._charsWritten=Et(function(P){for(var T,N,W=[],Y=0;Y<P.length;Y++)N=P.charCodeAt(Y),T=N>>8,N=N%256,W.push(N),W.push(T);return W}(f),c,g,A)}function S(c,f,g){var A="";g=Math.min(c.length,g);for(var P=f;P<g;P++)A+=String.fromCharCode(c[P]);return A}function D(c,f,g,T){T||(R(typeof g=="boolean","missing or invalid endian"),R(f!=null,"missing offset"),R(f+1<c.length,"Trying to read beyond buffer length"));var P,T=c.length;if(!(T<=f))return g?(P=c[f],f+1<T&&(P|=c[f+1]<<8)):(P=c[f]<<8,f+1<T&&(P|=c[f+1])),P}function F(c,f,g,T){T||(R(typeof g=="boolean","missing or invalid endian"),R(f!=null,"missing offset"),R(f+3<c.length,"Trying to read beyond buffer length"));var P,T=c.length;if(!(T<=f))return g?(f+2<T&&(P=c[f+2]<<16),f+1<T&&(P|=c[f+1]<<8),P|=c[f],f+3<T&&(P+=c[f+3]<<24>>>0)):(f+1<T&&(P=c[f+1]<<16),f+2<T&&(P|=c[f+2]<<8),f+3<T&&(P|=c[f+3]),P+=c[f]<<24>>>0),P}function b(c,f,g,A){if(A||(R(typeof g=="boolean","missing or invalid endian"),R(f!=null,"missing offset"),R(f+1<c.length,"Trying to read beyond buffer length")),!(c.length<=f))return A=D(c,f,g,!0),32768&A?-1*(65535-A+1):A}function _(c,f,g,A){if(A||(R(typeof g=="boolean","missing or invalid endian"),R(f!=null,"missing offset"),R(f+3<c.length,"Trying to read beyond buffer length")),!(c.length<=f))return A=F(c,f,g,!0),2147483648&A?-1*(4294967295-A+1):A}function u(c,f,g,A){return A||(R(typeof g=="boolean","missing or invalid endian"),R(f+3<c.length,"Trying to read beyond buffer length")),C.read(c,f,g,23,4)}function h(c,f,g,A){return A||(R(typeof g=="boolean","missing or invalid endian"),R(f+7<c.length,"Trying to read beyond buffer length")),C.read(c,f,g,52,8)}function d(c,f,g,A,P){if(P||(R(f!=null,"missing value"),R(typeof A=="boolean","missing or invalid endian"),R(g!=null,"missing offset"),R(g+1<c.length,"trying to write beyond buffer length"),zn(f,65535)),P=c.length,!(P<=g))for(var T=0,N=Math.min(P-g,2);T<N;T++)c[g+T]=(f&255<<8*(A?T:1-T))>>>8*(A?T:1-T)}function O(c,f,g,A,P){if(P||(R(f!=null,"missing value"),R(typeof A=="boolean","missing or invalid endian"),R(g!=null,"missing offset"),R(g+3<c.length,"trying to write beyond buffer length"),zn(f,4294967295)),P=c.length,!(P<=g))for(var T=0,N=Math.min(P-g,4);T<N;T++)c[g+T]=f>>>8*(A?T:3-T)&255}function E(c,f,g,A,P){P||(R(f!=null,"missing value"),R(typeof A=="boolean","missing or invalid endian"),R(g!=null,"missing offset"),R(g+1<c.length,"Trying to write beyond buffer length"),qn(f,32767,-32768)),c.length<=g||d(c,0<=f?f:65535+f+1,g,A,P)}function B(c,f,g,A,P){P||(R(f!=null,"missing value"),R(typeof A=="boolean","missing or invalid endian"),R(g!=null,"missing offset"),R(g+3<c.length,"Trying to write beyond buffer length"),qn(f,2147483647,-2147483648)),c.length<=g||O(c,0<=f?f:4294967295+f+1,g,A,P)}function M(c,f,g,A,P){P||(R(f!=null,"missing value"),R(typeof A=="boolean","missing or invalid endian"),R(g!=null,"missing offset"),R(g+3<c.length,"Trying to write beyond buffer length"),Ji(f,34028234663852886e22,-34028234663852886e22)),c.length<=g||C.write(c,f,g,A,23,4)}function j(c,f,g,A,P){P||(R(f!=null,"missing value"),R(typeof A=="boolean","missing or invalid endian"),R(g!=null,"missing offset"),R(g+7<c.length,"Trying to write beyond buffer length"),Ji(f,17976931348623157e292,-17976931348623157e292)),c.length<=g||C.write(c,f,g,A,52,8)}e.Buffer=w,e.SlowBuffer=w,e.INSPECT_MAX_BYTES=50,w.poolSize=8192,w._useTypedArrays=function(){try{var c=new ArrayBuffer(0),f=new Uint8Array(c);return f.foo=function(){return 42},f.foo()===42&&typeof f.subarray=="function"}catch{return!1}}(),w.isEncoding=function(c){switch(String(c).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},w.isBuffer=function(c){return!(c==null||!c._isBuffer)},w.byteLength=function(c,f){var g;switch(c+="",f||"utf8"){case"hex":g=c.length/2;break;case"utf8":case"utf-8":g=_e(c).length;break;case"ascii":case"binary":case"raw":g=c.length;break;case"base64":g=Wi(c).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":g=2*c.length;break;default:throw new Error("Unknown encoding")}return g},w.concat=function(c,f){if(R(H(c),`Usage: Buffer.concat(list, [totalLength])
|
|
5
5
|
list should be an Array.`),c.length===0)return new w(0);if(c.length===1)return c[0];if(typeof f!="number")for(P=f=0;P<c.length;P++)f+=c[P].length;for(var g=new w(f),A=0,P=0;P<c.length;P++){var T=c[P];T.copy(g,A),A+=T.length}return g},w.prototype.write=function(c,f,g,A){isFinite(f)?isFinite(g)||(A=g,g=void 0):(Y=A,A=f,f=g,g=Y),f=Number(f)||0;var P,T,N,W,Y=this.length-f;switch((!g||Y<(g=Number(g)))&&(g=Y),A=String(A||"utf8").toLowerCase()){case"hex":P=function(ye,ie,re,X){re=Number(re)||0;var G=ye.length-re;(!X||G<(X=Number(X)))&&(X=G),R((G=ie.length)%2==0,"Invalid hex string"),G/2<X&&(X=G/2);for(var We=0;We<X;We++){var Gi=parseInt(ie.substr(2*We,2),16);R(!isNaN(Gi),"Invalid hex string"),ye[re+We]=Gi}return w._charsWritten=2*We,We}(this,c,f,g);break;case"utf8":case"utf-8":T=this,N=f,W=g,P=w._charsWritten=Et(_e(c),T,N,W);break;case"ascii":case"binary":P=x(this,c,f,g);break;case"base64":T=this,N=f,W=g,P=w._charsWritten=Et(Wi(c),T,N,W);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":P=I(this,c,f,g);break;default:throw new Error("Unknown encoding")}return P},w.prototype.toString=function(c,f,g){var A,P,T,N,W=this;if(c=String(c||"utf8").toLowerCase(),f=Number(f)||0,(g=g!==void 0?Number(g):W.length)===f)return"";switch(c){case"hex":A=function(Y,ye,ie){var re=Y.length;(!ye||ye<0)&&(ye=0),(!ie||ie<0||re<ie)&&(ie=re);for(var X="",G=ye;G<ie;G++)X+=z(Y[G]);return X}(W,f,g);break;case"utf8":case"utf-8":A=function(Y,ye,ie){var re="",X="";ie=Math.min(Y.length,ie);for(var G=ye;G<ie;G++)Y[G]<=127?(re+=Qi(X)+String.fromCharCode(Y[G]),X=""):X+="%"+Y[G].toString(16);return re+Qi(X)}(W,f,g);break;case"ascii":case"binary":A=S(W,f,g);break;case"base64":P=W,N=g,A=(T=f)===0&&N===P.length?y.fromByteArray(P):y.fromByteArray(P.slice(T,N));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":A=function(Y,ye,ie){for(var re=Y.slice(ye,ie),X="",G=0;G<re.length;G+=2)X+=String.fromCharCode(re[G]+256*re[G+1]);return X}(W,f,g);break;default:throw new Error("Unknown encoding")}return A},w.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},w.prototype.copy=function(c,f,g,A){if(f=f||0,(A=A||A===0?A:this.length)!==(g=g||0)&&c.length!==0&&this.length!==0){R(g<=A,"sourceEnd < sourceStart"),R(0<=f&&f<c.length,"targetStart out of bounds"),R(0<=g&&g<this.length,"sourceStart out of bounds"),R(0<=A&&A<=this.length,"sourceEnd out of bounds"),A>this.length&&(A=this.length);var P=(A=c.length-f<A-g?c.length-f+g:A)-g;if(P<100||!w._useTypedArrays)for(var T=0;T<P;T++)c[T+f]=this[T+g];else c._set(this.subarray(g,g+P),f)}},w.prototype.slice=function(c,f){var g=this.length;if(c=q(c,g,0),f=q(f,g,g),w._useTypedArrays)return w._augment(this.subarray(c,f));for(var A=f-c,P=new w(A,void 0,!0),T=0;T<A;T++)P[T]=this[T+c];return P},w.prototype.get=function(c){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(c)},w.prototype.set=function(c,f){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(c,f)},w.prototype.readUInt8=function(c,f){if(f||(R(c!=null,"missing offset"),R(c<this.length,"Trying to read beyond buffer length")),!(c>=this.length))return this[c]},w.prototype.readUInt16LE=function(c,f){return D(this,c,!0,f)},w.prototype.readUInt16BE=function(c,f){return D(this,c,!1,f)},w.prototype.readUInt32LE=function(c,f){return F(this,c,!0,f)},w.prototype.readUInt32BE=function(c,f){return F(this,c,!1,f)},w.prototype.readInt8=function(c,f){if(f||(R(c!=null,"missing offset"),R(c<this.length,"Trying to read beyond buffer length")),!(c>=this.length))return 128&this[c]?-1*(255-this[c]+1):this[c]},w.prototype.readInt16LE=function(c,f){return b(this,c,!0,f)},w.prototype.readInt16BE=function(c,f){return b(this,c,!1,f)},w.prototype.readInt32LE=function(c,f){return _(this,c,!0,f)},w.prototype.readInt32BE=function(c,f){return _(this,c,!1,f)},w.prototype.readFloatLE=function(c,f){return u(this,c,!0,f)},w.prototype.readFloatBE=function(c,f){return u(this,c,!1,f)},w.prototype.readDoubleLE=function(c,f){return h(this,c,!0,f)},w.prototype.readDoubleBE=function(c,f){return h(this,c,!1,f)},w.prototype.writeUInt8=function(c,f,g){g||(R(c!=null,"missing value"),R(f!=null,"missing offset"),R(f<this.length,"trying to write beyond buffer length"),zn(c,255)),f>=this.length||(this[f]=c)},w.prototype.writeUInt16LE=function(c,f,g){d(this,c,f,!0,g)},w.prototype.writeUInt16BE=function(c,f,g){d(this,c,f,!1,g)},w.prototype.writeUInt32LE=function(c,f,g){O(this,c,f,!0,g)},w.prototype.writeUInt32BE=function(c,f,g){O(this,c,f,!1,g)},w.prototype.writeInt8=function(c,f,g){g||(R(c!=null,"missing value"),R(f!=null,"missing offset"),R(f<this.length,"Trying to write beyond buffer length"),qn(c,127,-128)),f>=this.length||(0<=c?this.writeUInt8(c,f,g):this.writeUInt8(255+c+1,f,g))},w.prototype.writeInt16LE=function(c,f,g){E(this,c,f,!0,g)},w.prototype.writeInt16BE=function(c,f,g){E(this,c,f,!1,g)},w.prototype.writeInt32LE=function(c,f,g){B(this,c,f,!0,g)},w.prototype.writeInt32BE=function(c,f,g){B(this,c,f,!1,g)},w.prototype.writeFloatLE=function(c,f,g){M(this,c,f,!0,g)},w.prototype.writeFloatBE=function(c,f,g){M(this,c,f,!1,g)},w.prototype.writeDoubleLE=function(c,f,g){j(this,c,f,!0,g)},w.prototype.writeDoubleBE=function(c,f,g){j(this,c,f,!1,g)},w.prototype.fill=function(c,f,g){if(f=f||0,g=g||this.length,R(typeof(c=typeof(c=c||0)=="string"?c.charCodeAt(0):c)=="number"&&!isNaN(c),"value is not a number"),R(f<=g,"end < start"),g!==f&&this.length!==0){R(0<=f&&f<this.length,"start out of bounds"),R(0<=g&&g<=this.length,"end out of bounds");for(var A=f;A<g;A++)this[A]=c}},w.prototype.inspect=function(){for(var c=[],f=this.length,g=0;g<f;g++)if(c[g]=z(this[g]),g===e.INSPECT_MAX_BYTES){c[g+1]="...";break}return"<Buffer "+c.join(" ")+">"},w.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(w._useTypedArrays)return new w(this).buffer;for(var c=new Uint8Array(this.length),f=0,g=c.length;f<g;f+=1)c[f]=this[f];return c.buffer};var k=w.prototype;function q(c,f,g){return typeof c!="number"?g:f<=(c=~~c)?f:0<=c||0<=(c+=f)?c:0}function te(c){return(c=~~Math.ceil(+c))<0?0:c}function H(c){return(Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"})(c)}function z(c){return c<16?"0"+c.toString(16):c.toString(16)}function _e(c){for(var f=[],g=0;g<c.length;g++){var A=c.charCodeAt(g);if(A<=127)f.push(c.charCodeAt(g));else for(var P=g,T=(55296<=A&&A<=57343&&g++,encodeURIComponent(c.slice(P,g+1)).substr(1).split("%")),N=0;N<T.length;N++)f.push(parseInt(T[N],16))}return f}function Wi(c){return y.toByteArray(c)}function Et(c,f,g,A){for(var P=0;P<A&&!(P+g>=f.length||P>=c.length);P++)f[P+g]=c[P];return P}function Qi(c){try{return decodeURIComponent(c)}catch{return String.fromCharCode(65533)}}function zn(c,f){R(typeof c=="number","cannot write a non-number as a number"),R(0<=c,"specified a negative value for writing an unsigned value"),R(c<=f,"value is larger than maximum value for type"),R(Math.floor(c)===c,"value has a fractional component")}function qn(c,f,g){R(typeof c=="number","cannot write a non-number as a number"),R(c<=f,"value larger than maximum allowed value"),R(g<=c,"value smaller than minimum allowed value"),R(Math.floor(c)===c,"value has a fractional component")}function Ji(c,f,g){R(typeof c=="number","cannot write a non-number as a number"),R(c<=f,"value larger than maximum allowed value"),R(g<=c,"value smaller than minimum allowed value")}function R(c,f){if(!c)throw new Error(f||"Failed assertion")}w._augment=function(c){return c._isBuffer=!0,c._get=c.get,c._set=c.set,c.get=k.get,c.set=k.set,c.write=k.write,c.toString=k.toString,c.toLocaleString=k.toString,c.toJSON=k.toJSON,c.copy=k.copy,c.slice=k.slice,c.readUInt8=k.readUInt8,c.readUInt16LE=k.readUInt16LE,c.readUInt16BE=k.readUInt16BE,c.readUInt32LE=k.readUInt32LE,c.readUInt32BE=k.readUInt32BE,c.readInt8=k.readInt8,c.readInt16LE=k.readInt16LE,c.readInt16BE=k.readInt16BE,c.readInt32LE=k.readInt32LE,c.readInt32BE=k.readInt32BE,c.readFloatLE=k.readFloatLE,c.readFloatBE=k.readFloatBE,c.readDoubleLE=k.readDoubleLE,c.readDoubleBE=k.readDoubleBE,c.writeUInt8=k.writeUInt8,c.writeUInt16LE=k.writeUInt16LE,c.writeUInt16BE=k.writeUInt16BE,c.writeUInt32LE=k.writeUInt32LE,c.writeUInt32BE=k.writeUInt32BE,c.writeInt8=k.writeInt8,c.writeInt16LE=k.writeInt16LE,c.writeInt16BE=k.writeInt16BE,c.writeInt32LE=k.writeInt32LE,c.writeInt32BE=k.writeInt32BE,c.writeFloatLE=k.writeFloatLE,c.writeFloatBE=k.writeFloatBE,c.writeDoubleLE=k.writeDoubleLE,c.writeDoubleBE=k.writeDoubleBE,c.fill=k.fill,c.inspect=k.inspect,c.toArrayBuffer=k.toArrayBuffer,c}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(i,t,e){(function(n,r,y,s,a,p,l,m,v){var y=i("buffer").Buffer,C=4,w=new y(C);w.fill(0),t.exports={hash:function(x,I,S,D){for(var F=I(function(d,O){d.length%C!=0&&(E=d.length+(C-d.length%C),d=y.concat([d,w],E));for(var E,B=[],M=O?d.readInt32BE:d.readInt32LE,j=0;j<d.length;j+=C)B.push(M.call(d,j));return B}(x=y.isBuffer(x)?x:new y(x),D),8*x.length),I=D,b=new y(S),_=I?b.writeInt32BE:b.writeInt32LE,u=0;u<F.length;u++)_.call(b,F[u],4*u,!0);return b}}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(i,t,e){(function(n,r,y,s,a,p,l,m,v){var y=i("buffer").Buffer,C=i("./sha"),w=i("./sha256"),x=i("./rng"),I={sha1:C,sha256:w,md5:i("./md5")},S=64,D=new y(S);function F(d,O){var E=I[d=d||"sha1"],B=[];return E||b("algorithm:",d,"is not yet supported"),{update:function(M){return y.isBuffer(M)||(M=new y(M)),B.push(M),M.length,this},digest:function(M){var j=y.concat(B),j=O?function(k,q,te){y.isBuffer(q)||(q=new y(q)),y.isBuffer(te)||(te=new y(te)),q.length>S?q=k(q):q.length<S&&(q=y.concat([q,D],S));for(var H=new y(S),z=new y(S),_e=0;_e<S;_e++)H[_e]=54^q[_e],z[_e]=92^q[_e];return te=k(y.concat([H,te])),k(y.concat([z,te]))}(E,O,j):E(j);return B=null,M?j.toString(M):j}}}function b(){var d=[].slice.call(arguments).join(" ");throw new Error([d,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
|
|
6
|
-
`))}D.fill(0),e.createHash=function(d){return F(d)},e.createHmac=F,e.randomBytes=function(d,O){if(!O||!O.call)return new y(x(d));try{O.call(this,void 0,new y(x(d)))}catch(E){O(E)}};var _,u=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],h=function(d){e[d]=function(){b("sorry,",d,"is not implemented yet")}};for(_ in u)h(u[_],_)}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y=i("./helpers");function C(b,_){b[_>>5]|=128<<_%32,b[14+(_+64>>>9<<4)]=_;for(var u=1732584193,h=-271733879,d=-1732584194,O=271733878,E=0;E<b.length;E+=16){var B=u,M=h,j=d,k=O,u=x(u,h,d,O,b[E+0],7,-680876936),O=x(O,u,h,d,b[E+1],12,-389564586),d=x(d,O,u,h,b[E+2],17,606105819),h=x(h,d,O,u,b[E+3],22,-1044525330);u=x(u,h,d,O,b[E+4],7,-176418897),O=x(O,u,h,d,b[E+5],12,1200080426),d=x(d,O,u,h,b[E+6],17,-1473231341),h=x(h,d,O,u,b[E+7],22,-45705983),u=x(u,h,d,O,b[E+8],7,1770035416),O=x(O,u,h,d,b[E+9],12,-1958414417),d=x(d,O,u,h,b[E+10],17,-42063),h=x(h,d,O,u,b[E+11],22,-1990404162),u=x(u,h,d,O,b[E+12],7,1804603682),O=x(O,u,h,d,b[E+13],12,-40341101),d=x(d,O,u,h,b[E+14],17,-1502002290),u=I(u,h=x(h,d,O,u,b[E+15],22,1236535329),d,O,b[E+1],5,-165796510),O=I(O,u,h,d,b[E+6],9,-1069501632),d=I(d,O,u,h,b[E+11],14,643717713),h=I(h,d,O,u,b[E+0],20,-373897302),u=I(u,h,d,O,b[E+5],5,-701558691),O=I(O,u,h,d,b[E+10],9,38016083),d=I(d,O,u,h,b[E+15],14,-660478335),h=I(h,d,O,u,b[E+4],20,-405537848),u=I(u,h,d,O,b[E+9],5,568446438),O=I(O,u,h,d,b[E+14],9,-1019803690),d=I(d,O,u,h,b[E+3],14,-187363961),h=I(h,d,O,u,b[E+8],20,1163531501),u=I(u,h,d,O,b[E+13],5,-1444681467),O=I(O,u,h,d,b[E+2],9,-51403784),d=I(d,O,u,h,b[E+7],14,1735328473),u=S(u,h=I(h,d,O,u,b[E+12],20,-1926607734),d,O,b[E+5],4,-378558),O=S(O,u,h,d,b[E+8],11,-2022574463),d=S(d,O,u,h,b[E+11],16,1839030562),h=S(h,d,O,u,b[E+14],23,-35309556),u=S(u,h,d,O,b[E+1],4,-1530992060),O=S(O,u,h,d,b[E+4],11,1272893353),d=S(d,O,u,h,b[E+7],16,-155497632),h=S(h,d,O,u,b[E+10],23,-1094730640),u=S(u,h,d,O,b[E+13],4,681279174),O=S(O,u,h,d,b[E+0],11,-358537222),d=S(d,O,u,h,b[E+3],16,-722521979),h=S(h,d,O,u,b[E+6],23,76029189),u=S(u,h,d,O,b[E+9],4,-640364487),O=S(O,u,h,d,b[E+12],11,-421815835),d=S(d,O,u,h,b[E+15],16,530742520),u=D(u,h=S(h,d,O,u,b[E+2],23,-995338651),d,O,b[E+0],6,-198630844),O=D(O,u,h,d,b[E+7],10,1126891415),d=D(d,O,u,h,b[E+14],15,-1416354905),h=D(h,d,O,u,b[E+5],21,-57434055),u=D(u,h,d,O,b[E+12],6,1700485571),O=D(O,u,h,d,b[E+3],10,-1894986606),d=D(d,O,u,h,b[E+10],15,-1051523),h=D(h,d,O,u,b[E+1],21,-2054922799),u=D(u,h,d,O,b[E+8],6,1873313359),O=D(O,u,h,d,b[E+15],10,-30611744),d=D(d,O,u,h,b[E+6],15,-1560198380),h=D(h,d,O,u,b[E+13],21,1309151649),u=D(u,h,d,O,b[E+4],6,-145523070),O=D(O,u,h,d,b[E+11],10,-1120210379),d=D(d,O,u,h,b[E+2],15,718787259),h=D(h,d,O,u,b[E+9],21,-343485551),u=F(u,B),h=F(h,M),d=F(d,j),O=F(O,k)}return Array(u,h,d,O)}function w(b,_,u,h,d,O){return F((_=F(F(_,b),F(h,O)))<<d|_>>>32-d,u)}function x(b,_,u,h,d,O,E){return w(_&u|~_&h,b,_,d,O,E)}function I(b,_,u,h,d,O,E){return w(_&h|u&~h,b,_,d,O,E)}function S(b,_,u,h,d,O,E){return w(_^u^h,b,_,d,O,E)}function D(b,_,u,h,d,O,E){return w(u^(_|~h),b,_,d,O,E)}function F(b,_){var u=(65535&b)+(65535&_);return(b>>16)+(_>>16)+(u>>16)<<16|65535&u}t.exports=function(b){return y.hash(b,C,16)}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y;t.exports=y||function(C){for(var w,x=new Array(C),I=0;I<C;I++)!(3&I)&&(w=4294967296*Math.random()),x[I]=w>>>((3&I)<<3)&255;return x}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y=i("./helpers");function C(I,S){I[S>>5]|=128<<24-S%32,I[15+(S+64>>9<<4)]=S;for(var D,F,b,_=Array(80),u=1732584193,h=-271733879,d=-1732584194,O=271733878,E=-1009589776,B=0;B<I.length;B+=16){for(var M=u,j=h,k=d,q=O,te=E,H=0;H<80;H++){_[H]=H<16?I[B+H]:x(_[H-3]^_[H-8]^_[H-14]^_[H-16],1);var z=w(w(x(u,5),(z=h,F=d,b=O,(D=H)<20?z&F|~z&b:!(D<40)&&D<60?z&F|z&b|F&b:z^F^b)),w(w(E,_[H]),(D=H)<20?1518500249:D<40?1859775393:D<60?-1894007588:-899497514)),E=O,O=d,d=x(h,30),h=u,u=z}u=w(u,M),h=w(h,j),d=w(d,k),O=w(O,q),E=w(E,te)}return Array(u,h,d,O,E)}function w(I,S){var D=(65535&I)+(65535&S);return(I>>16)+(S>>16)+(D>>16)<<16|65535&D}function x(I,S){return I<<S|I>>>32-S}t.exports=function(I){return y.hash(I,C,20,!0)}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){function y(S,D){var F=(65535&S)+(65535&D);return(S>>16)+(D>>16)+(F>>16)<<16|65535&F}function C(S,D){var F,b=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),_=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),u=new Array(64);S[D>>5]|=128<<24-D%32,S[15+(D+64>>9<<4)]=D;for(var h,d,O=0;O<S.length;O+=16){for(var E=_[0],B=_[1],M=_[2],j=_[3],k=_[4],q=_[5],te=_[6],H=_[7],z=0;z<64;z++)u[z]=z<16?S[z+O]:y(y(y((d=u[z-2],x(d,17)^x(d,19)^I(d,10)),u[z-7]),(d=u[z-15],x(d,7)^x(d,18)^I(d,3))),u[z-16]),F=y(y(y(y(H,x(d=k,6)^x(d,11)^x(d,25)),k&q^~k&te),b[z]),u[z]),h=y(x(h=E,2)^x(h,13)^x(h,22),E&B^E&M^B&M),H=te,te=q,q=k,k=y(j,F),j=M,M=B,B=E,E=y(F,h);_[0]=y(E,_[0]),_[1]=y(B,_[1]),_[2]=y(M,_[2]),_[3]=y(j,_[3]),_[4]=y(k,_[4]),_[5]=y(q,_[5]),_[6]=y(te,_[6]),_[7]=y(H,_[7])}return _}var w=i("./helpers"),x=function(S,D){return S>>>D|S<<32-D},I=function(S,D){return S>>>D};t.exports=function(S){return w.hash(S,C,32,!0)}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){e.read=function(y,C,w,x,O){var S,D,F=8*O-x-1,b=(1<<F)-1,_=b>>1,u=-7,h=w?O-1:0,d=w?-1:1,O=y[C+h];for(h+=d,S=O&(1<<-u)-1,O>>=-u,u+=F;0<u;S=256*S+y[C+h],h+=d,u-=8);for(D=S&(1<<-u)-1,S>>=-u,u+=x;0<u;D=256*D+y[C+h],h+=d,u-=8);if(S===0)S=1-_;else{if(S===b)return D?NaN:1/0*(O?-1:1);D+=Math.pow(2,x),S-=_}return(O?-1:1)*D*Math.pow(2,S-x)},e.write=function(y,C,w,x,I,E){var D,F,b=8*E-I-1,_=(1<<b)-1,u=_>>1,h=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=x?0:E-1,O=x?1:-1,E=C<0||C===0&&1/C<0?1:0;for(C=Math.abs(C),isNaN(C)||C===1/0?(F=isNaN(C)?1:0,D=_):(D=Math.floor(Math.log(C)/Math.LN2),C*(x=Math.pow(2,-D))<1&&(D--,x*=2),2<=(C+=1<=D+u?h/x:h*Math.pow(2,1-u))*x&&(D++,x/=2),_<=D+u?(F=0,D=_):1<=D+u?(F=(C*x-1)*Math.pow(2,I),D+=u):(F=C*Math.pow(2,u-1)*Math.pow(2,I),D=0));8<=I;y[w+d]=255&F,d+=O,F/=256,I-=8);for(D=D<<I|F,b+=I;0<b;y[w+d]=255&D,d+=O,D/=256,b-=8);y[w+d-O]|=128*E}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y,C,w;function x(){}(n=t.exports={}).nextTick=(C=typeof window<"u"&&window.setImmediate,w=typeof window<"u"&&window.postMessage&&window.addEventListener,C?function(I){return window.setImmediate(I)}:w?(y=[],window.addEventListener("message",function(I){var S=I.source;S!==window&&S!==null||I.data!=="process-tick"||(I.stopPropagation(),0<y.length&&y.shift()())},!0),function(I){y.push(I),window.postMessage("process-tick","*")}):function(I){setTimeout(I,0)}),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.on=x,n.addListener=x,n.once=x,n.off=x,n.removeListener=x,n.removeAllListeners=x,n.emit=x,n.binding=function(I){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(I){throw new Error("process.chdir is not supported")}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})});var ze={};Yi(ze,{__addDisposableResource:()=>So,__assign:()=>bn,__asyncDelegator:()=>po,__asyncGenerator:()=>fo,__asyncValues:()=>ho,__await:()=>nt,__awaiter:()=>oo,__classPrivateFieldGet:()=>bo,__classPrivateFieldIn:()=>vo,__classPrivateFieldSet:()=>wo,__createBinding:()=>vn,__decorate:()=>no,__disposeResources:()=>xo,__esDecorate:()=>ia,__exportStar:()=>ao,__extends:()=>eo,__generator:()=>so,__importDefault:()=>yo,__importStar:()=>go,__makeTemplateObject:()=>mo,__metadata:()=>ro,__param:()=>io,__propKey:()=>oa,__read:()=>Pi,__rest:()=>to,__runInitializers:()=>ra,__setFunctionName:()=>sa,__spread:()=>co,__spreadArray:()=>uo,__spreadArrays:()=>lo,__values:()=>wn,default:()=>la});function eo(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Ci(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function to(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]]);return e}function no(i,t,e,n){var r=arguments.length,o=r<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,n);else for(var a=i.length-1;a>=0;a--)(s=i[a])&&(o=(r<3?s(o):r>3?s(t,e,o):s(t,e))||o);return r>3&&o&&Object.defineProperty(t,e,o),o}function io(i,t){return function(e,n){t(e,n,i)}}function ia(i,t,e,n,r,o){function s(S){if(S!==void 0&&typeof S!="function")throw new TypeError("Function expected");return S}for(var a=n.kind,p=a==="getter"?"get":a==="setter"?"set":"value",l=!t&&i?n.static?i:i.prototype:null,m=t||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),v,y=!1,C=e.length-1;C>=0;C--){var w={};for(var x in n)w[x]=x==="access"?{}:n[x];for(var x in n.access)w.access[x]=n.access[x];w.addInitializer=function(S){if(y)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(S||null))};var I=(0,e[C])(a==="accessor"?{get:m.get,set:m.set}:m[p],w);if(a==="accessor"){if(I===void 0)continue;if(I===null||typeof I!="object")throw new TypeError("Object expected");(v=s(I.get))&&(m.get=v),(v=s(I.set))&&(m.set=v),(v=s(I.init))&&r.unshift(v)}else(v=s(I))&&(a==="field"?r.unshift(v):m[p]=v)}l&&Object.defineProperty(l,n.name,m),y=!0}function ra(i,t,e){for(var n=arguments.length>2,r=0;r<t.length;r++)e=n?t[r].call(i,e):t[r].call(i);return n?e:void 0}function oa(i){return typeof i=="symbol"?i:"".concat(i)}function sa(i,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function ro(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}function oo(i,t,e,n){function r(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(m){try{l(n.next(m))}catch(v){s(v)}}function p(m){try{l(n.throw(m))}catch(v){s(v)}}function l(m){m.done?o(m.value):r(m.value).then(a,p)}l((n=n.apply(i,t||[])).next())})}function so(i,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,r,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(l){return function(m){return p([l,m])}}function p(l){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(e=0)),e;)try{if(n=1,r&&(o=l[0]&2?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){e.label=l[1];break}if(l[0]===6&&e.label<o[1]){e.label=o[1],o=l;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(l);break}o[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(i,e)}catch(m){l=[6,m],r=0}finally{n=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ao(i,t){for(var e in i)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&vn(t,i,e)}function wn(i){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&i[t],n=0;if(e)return e.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pi(i,t){var e=typeof Symbol=="function"&&i[Symbol.iterator];if(!e)return i;var n=e.call(i),r,o=[],s;try{for(;(t===void 0||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(a){s={error:a}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o}function co(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(Pi(arguments[t]));return i}function lo(){for(var i=0,t=0,e=arguments.length;t<e;t++)i+=arguments[t].length;for(var n=Array(i),r=0,t=0;t<e;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}function uo(i,t,e){if(e||arguments.length===2)for(var n=0,r=t.length,o;n<r;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return i.concat(o||Array.prototype.slice.call(t))}function nt(i){return this instanceof nt?(this.v=i,this):new nt(i)}function fo(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(y){n[y]&&(r[y]=function(C){return new Promise(function(w,x){o.push([y,C,w,x])>1||a(y,C)})})}function a(y,C){try{p(n[y](C))}catch(w){v(o[0][3],w)}}function p(y){y.value instanceof nt?Promise.resolve(y.value.v).then(l,m):v(o[0][2],y)}function l(y){a("next",y)}function m(y){a("throw",y)}function v(y,C){y(C),o.shift(),o.length&&a(o[0][0],o[0][1])}}function po(i){var t,e;return t={},n("next"),n("throw",function(r){throw r}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(r,o){t[r]=i[r]?function(s){return(e=!e)?{value:nt(i[r](s)),done:!1}:o?o(s):s}:o}}function ho(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof wn=="function"?wn(i):i[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=i[o]&&function(s){return new Promise(function(a,p){s=i[o](s),r(a,p,s.done,s.value)})}}function r(o,s,a,p){Promise.resolve(p).then(function(l){o({value:l,done:a})},s)}}function mo(i,t){return Object.defineProperty?Object.defineProperty(i,"raw",{value:t}):i.raw=t,i}function go(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var e in i)e!=="default"&&Object.prototype.hasOwnProperty.call(i,e)&&vn(t,i,e);return aa(t,i),t}function yo(i){return i&&i.__esModule?i:{default:i}}function bo(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)}function wo(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e}function vo(i,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?t===i:i.has(t)}function So(i,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var n;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose]}if(typeof n!="function")throw new TypeError("Object not disposable.");i.stack.push({value:t,dispose:n,async:e})}else e&&i.stack.push({async:!0});return t}function xo(i){function t(n){i.error=i.hasError?new ca(n,i.error,"An error was suppressed during disposal."):n,i.hasError=!0}function e(){for(;i.stack.length;){var n=i.stack.pop();try{var r=n.dispose&&n.dispose.call(n.value);if(n.async)return Promise.resolve(r).then(e,function(o){return t(o),e()})}catch(o){t(o)}}if(i.hasError)throw i.error}return e()}var Ci,bn,vn,aa,ca,la,qe=$o(()=>{Ci=function(i,t){return Ci=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},Ci(i,t)};bn=function(){return bn=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},bn.apply(this,arguments)};vn=Object.create?function(i,t,e,n){n===void 0&&(n=e);var r=Object.getOwnPropertyDescriptor(t,e);(!r||("get"in r?!t.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,n,r)}:function(i,t,e,n){n===void 0&&(n=e),i[n]=t[e]};aa=Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t};ca=typeof SuppressedError=="function"?SuppressedError:function(i,t,e){var n=new Error(e);return n.name="SuppressedError",n.error=i,n.suppressed=t,n};la={__extends:eo,__assign:bn,__rest:to,__decorate:no,__param:io,__metadata:ro,__awaiter:oo,__generator:so,__createBinding:vn,__exportStar:ao,__values:wn,__read:Pi,__spread:co,__spreadArrays:lo,__spreadArray:uo,__await:nt,__asyncGenerator:fo,__asyncDelegator:po,__asyncValues:ho,__makeTemplateObject:mo,__importStar:go,__importDefault:yo,__classPrivateFieldGet:bo,__classPrivateFieldSet:wo,__classPrivateFieldIn:vo,__addDisposableResource:So,__disposeResources:xo}});var Io=oe(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0})});var Fi=oe(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.invokeEventHandlersAsync=De.invokeEventHandlers=De.eventHandlerSafeInvokeAsync=De.eventHandlerSafeInvoke=void 0;var Do=(qe(),Je(ze));function _o(i,t,e){try{return i(t,e),{succeeded:!0}}catch(n){return{error:n,succeeded:!1}}}De.eventHandlerSafeInvoke=_o;function Ai(i,t,e){return(0,Do.__awaiter)(this,void 0,void 0,function*(){try{return yield i(t,e),{succeeded:!0}}catch(n){return{error:n,succeeded:!1}}})}De.eventHandlerSafeInvokeAsync=Ai;function da(i,t,e,n){for(let r of i){let{succeeded:o,error:s}=_o(r,t,e);if(!o&&n?.swallowExceptions!==!0)throw s}}De.invokeEventHandlers=da;function ua(i,t,e,n){return(0,Do.__awaiter)(this,void 0,void 0,function*(){if(n?.parallelize===!1)for(let r of i){let{succeeded:o,error:s}=yield Ai(r,t,e);if(!o&&n?.swallowExceptions!==!0)throw s}else{let r=[];for(let o of i)r.push(Ai(o,t,e).then(({succeeded:s,error:a})=>{if(!s&&n?.swallowExceptions!==!0)throw a}));yield Promise.all(r)}})}De.invokeEventHandlersAsync=ua});var Po=oe(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.TypedEvent=void 0;var fa=(qe(),Je(ze)),Eo=Fi(),Co={swallowExceptions:!1,parallelize:!0},Ri=class{constructor(){this._handlers=[]}attach(t){this._handlers.push(t)}detach(t){this.tryRemoveHandler(t)}invoke(t,e,n=Co){(0,Eo.invokeEventHandlers)(this._handlers,t,e,n)}invokeAsync(t,e,n=Co){return(0,fa.__awaiter)(this,void 0,void 0,function*(){yield(0,Eo.invokeEventHandlersAsync)(this._handlers,t,e,n)})}tryRemoveHandler(t){let e=this._handlers.findIndex(n=>n===t);e>=0&&this._handlers.splice(e,1)}};Sn.TypedEvent=Ri});var ki=oe(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});var pa=(qe(),Je(ze));(0,pa.__exportStar)(Po(),Ti)});var Ao=oe(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.FinalizationRegistryMissingError=void 0;var Mi=class extends Error{};xn.FinalizationRegistryMissingError=Mi});var ji=oe(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.WeakHandlerHolder=void 0;var ha=Ao(),Bi=class{constructor(t){this._refs=[];try{this._finalizationRegistry=new FinalizationRegistry(t)}catch(e){throw e.name==="FinalizationRegistry"?new ha.FinalizationRegistryMissingError("FinalizationRegistry is not defined. Weak Events cannot be used. Please consult 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry' for compatibility information"):e}}getWeakHandler(t,e){let n=new WeakRef(e);return this._finalizationRegistry.register(e,{eventSource:t,handlerRef:n},n),this._refs.push(n),n}releaseWeakHandler(t){let n=this._refs.find(r=>r?.deref()===t)||new WeakRef(t);return this._finalizationRegistry.unregister(n),n}unregisterRef(t){this._finalizationRegistry.unregister(t)}};On.WeakHandlerHolder=Bi});var Fo=oe(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.WeakEvent=void 0;var Li=(qe(),Je(ze)),ma=ki(),ga=ji(),Ni=Fi(),ya={swallowExceptions:!1,parallelize:!0},Ui=class{constructor(){this._handlers=[],this._handlerFinalizedEvent=new ma.TypedEvent,this.handlerFinalizedEvent=this._handlerFinalizedEvent,this._refHolder=new ga.WeakHandlerHolder(t=>{this.onHandlerFinalizer(t)})}invoke(t,e,n){for(let r of this._handlers){let o=r?.deref();if(o){let{succeeded:s,error:a}=(0,Ni.eventHandlerSafeInvoke)(o,t,e);if(!s&&n?.swallowExceptions!==!0)throw a}else this.releaseHandler(r)}}invokeAsync(t,e,n=ya){return(0,Li.__awaiter)(this,void 0,void 0,function*(){n?.parallelize===!1?yield this.sequentialInvokeAsync(t,e,n):yield this.parallelInvokeAsync(t,e,n)})}sequentialInvokeAsync(t,e,n){return(0,Li.__awaiter)(this,void 0,void 0,function*(){for(let r of this._handlers){let o=r?.deref();if(o){let{succeeded:s,error:a}=yield(0,Ni.eventHandlerSafeInvokeAsync)(o,t,e);if(!s&&n.swallowExceptions!==!0)throw a}else this.releaseHandler(r)}})}parallelInvokeAsync(t,e,n){return(0,Li.__awaiter)(this,void 0,void 0,function*(){let r=[];for(let o of this._handlers){let s=o?.deref();s?r.push((0,Ni.eventHandlerSafeInvokeAsync)(s,t,e).then(({succeeded:a,error:p})=>{if(!a&&n.swallowExceptions!==!0)throw p})):this.releaseHandler(o)}yield Promise.all(r)})}attach(t){this._handlers.push(this._refHolder.getWeakHandler(this,t))}detach(t){let e=this._refHolder.releaseWeakHandler(t);this.tryRemoveHandlerRef(e)}onHandlerFinalizer(t){this.tryRemoveHandlerRef(t?.handlerRef),this._handlerFinalizedEvent.invokeAsync(this,t,{swallowExceptions:!0})}tryRemoveHandlerRef(t){let e=this._handlers.findIndex(n=>n===t);e>=0&&this._handlers.splice(e,1)}releaseHandler(t){this._refHolder.unregisterRef(t),this.tryRemoveHandlerRef(t)}};In.WeakEvent=Ui});var To=oe(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});var Ro=(qe(),Je(ze));(0,Ro.__exportStar)(ji(),Dn);(0,Ro.__exportStar)(Fo(),Dn)});var ko=oe(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});var Vi=(qe(),Je(ze));(0,Vi.__exportStar)(Io(),It);(0,Vi.__exportStar)(ki(),It);(0,Vi.__exportStar)(To(),It)});var Hi={};Yi(Hi,{Client:()=>He,ClientDescriptor:()=>$n,Entity:()=>ue,EntityFile:()=>de,MigrationPathError:()=>Ze,ServerSync:()=>rt,Storage:()=>He,StorageDescriptor:()=>$n,collection:()=>yi,createDefaultMigration:()=>bi,createMigration:()=>wi,migrate:()=>Wt,schema:()=>gt});var hr=Qe(at(),1),Mt=4,lt=36;function dr(i){return i.toString(lt).padStart(Mt,"0")}function Go(i){return i.toString().padStart(6,"0")}var Ft=class{constructor(){this.latest={time:Date.now(),counter:0,node:Yo()};this.zeroCounter=0;this.now=t=>(this.latest=fr(this.latest),this.get(t,this.latest));this.OLD_now=t=>(this.latest=fr(this.latest),Go(t)+Zo(this.latest));this.timerState=()=>this.latest;this.update=t=>{let e=t.slice(Mt);this.latest=Xo(this.latest,mr(e))};this.get=(t,e)=>dr(t)+ur(e);this.zero=t=>dr(t)+ur({time:0,counter:this.zeroCounter++,node:this.latest.node});this.getWallClockTime=Zn}},Rt=class extends Error{constructor(...e){super();this.type="ClockDriftError",this.message=["maximum clock drift exceeded"].concat(e).join(" ")}},Tt=class extends Error{constructor(){super();this.type="OverflowError",this.message="timestamp counter overflow"}},Gn=4,Yn=7,kt=60*1e3,ct=9;function Yo(){return hr.default.slug().padStart(Yn,"0").slice(0,Yn)}function ur(i){let t=new Date(i.time).getTime().toString(lt).padStart(ct,"0"),e=i.counter.toString(lt).padStart(Gn,"0"),n=i.node.padStart(Yn,"0");return`${t}${e}${n}`}function fr(i){let t=Date.now(),e=Math.max(i.time,t),n=i.time===e?i.counter+1:0;if(e-t>kt)throw new Rt(e,t,kt);if(n>65535)throw new Tt;return{time:e,counter:n,node:i.node}}function Xo(i,t){let e=Date.now(),n=Math.max(e,Math.max(i.time,t.time)),r=Math.max(i.counter,t.counter),o;if(i.time===n&&t.time===n?o=r+1:i.time===n?o=i.counter+1:t.time===n?o=t.counter+1:o=0,n-e>kt)throw new Rt(n,e,kt);if(o>65535)throw new Tt;return{time:n,counter:o,node:i.node}}function mr(i){let t=i.slice(0,ct),e=i.slice(ct,ct+Gn),n=i.slice(ct+Gn),r=parseInt(t,lt),o=parseInt(e,lt);if(isNaN(r)||isNaN(o))throw new Error("invalid clock format");return{time:r,counter:o,node:n}}function Zo(i){let t=new Date(i.time).toISOString(),e=i.counter.toString(16).toUpperCase().padStart(4,"0"),n=i.node.padStart(16,"0");return`${t}-${e}-${n}`}function pr(i){return parseInt(i.slice(0,Mt),36)}function Xn(i,t){return pr(i)-pr(t)}function Zn(i){return mr(i.slice(Mt)).time}function be(i){return i&&i["@@type"]==="file"}function Bt(i){return{"@@type":"file",id:i}}var jt,es=new Uint8Array(16);function ei(){if(!jt&&(jt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!jt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return jt(es)}var gr=/^(?:[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 ts(i){return typeof i=="string"&&gr.test(i)}var yr=ts;var ee=[];for(Lt=0;Lt<256;++Lt)ee.push((Lt+256).toString(16).substr(1));var Lt;function ns(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(ee[i[t+0]]+ee[i[t+1]]+ee[i[t+2]]+ee[i[t+3]]+"-"+ee[i[t+4]]+ee[i[t+5]]+"-"+ee[i[t+6]]+ee[i[t+7]]+"-"+ee[i[t+8]]+ee[i[t+9]]+"-"+ee[i[t+10]]+ee[i[t+11]]+ee[i[t+12]]+ee[i[t+13]]+ee[i[t+14]]+ee[i[t+15]]).toLowerCase();if(!yr(e))throw TypeError("Stringified UUID is invalid");return e}var br=ns;function is(i,t,e){i=i||{};var n=i.random||(i.rng||ei)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var r=0;r<16;++r)t[e+r]=n[r];return t}return br(n)}var dt=is;function Q(i){return Se(i)||be(i)}function Ge(i,t){return i===t?!0:!(!Q(i)||!Q(t)||i["@@type"]!==t["@@type"]||i.id!==t.id)}var xr=Qe(Sr(),1);function rs(i,t){return typeof t!="object"||t===null||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).sort(([e],[n])=>e<n?-1:e>n?1:0))}function ut(i){return JSON.stringify(i,rs)}function ae(i,t=!0){if(V(i)||Array.isArray(i)){let e=pe(i),n;if(Array.isArray(i))n=i.map(r=>ae(r,t));else{n={};for(let[r,o]of Object.entries(i))n[r]=ae(o,t)}return t&&e&&K(n,e),n}return i}function Fe(i){return(0,xr.default)(i)}function V(i){return i&&typeof i=="object"}function Or(i){for(var t=[],e=[i],n=0;e.length;){var r=e.pop();if(typeof r=="boolean")n+=4;else if(typeof r=="string")n+=r.length*2;else if(typeof r=="number")n+=8;else if(typeof r=="object"&&t.indexOf(r)===-1){t.push(r);for(var o in r)e.push(r[o])}}return n}function L(i,t="assertion failed"){if(!i)throw new Error(t)}function Nt(i=16){return dt().replace("-","").slice(0,i)}function Ir(i,t){for(let e=i.length-1;e>=0;e--)if(t(i[e]))return e;return-1}function Dr(i,t){let e;return function(...n){let r=this;clearTimeout(e),e=setTimeout(()=>i.apply(r,n),t)}}var Me="__@@oid_do_not_use",Oe="@@id",os="/",pt=":",ni=new WeakMap;function ne(i){let t=pe(i);return L(!!t,`Object ${JSON.stringify(i)} does not have an OID assigned to it`),t}function pe(i){if(V(i))return ni.get(i)??i[Oe]??i[Me]}function K(i,t){return L(V(i),`Only objects can be assigned OIDs, received ${JSON.stringify(i)}`),ii(i)&&Kt(i),ni.set(i,t),i}function ii(i){return!!pe(i)}function Kt(i){return ni.delete(i),i}function ri(i){return i===Oe||i===Me}function oi(i,t,e){if(ii(i))return ne(i);{let n=xe(t,e);return K(i,n),n}}function _r(i,t,e){if(ii(i)){let n=ne(i);if(Ee(n,t))return ne(i);{let r=xe(t,e);return K(i,r),r}}else{let n=xe(t,e);return K(i,n),n}}var ti={".":"˙","/":"&slash;",":":":"};function Er(i){return i.replace(/[/]/g,ti["/"]).replace(/[:]/g,ti[":"]).replace(/[.]/g,ti["."])}function Cr(i){return i.replace(/&slash;/g,"/").replace(/:/g,":").replace(/˙/g,".")}function Z(i,t,e){let n=Er(i)+os+Er(t);return e&&(n+=pt+e),n}function xe(i,t=ls){let{collection:e,id:n}=me(i);return Z(e,n,t())}function me(i){let[t,e]=i.split(pt),[n,r,...o]=t.split("/");o.length&&(r+="/"+o.join("/"));let s;return r.includes(".")?s=r.slice(0,r.indexOf(".")):s=r,{collection:Cr(n),id:Cr(s),subId:e}}function Ye(i,t){let e=ne(i);if(Array.isArray(i)){let n;for(let r=0;r<i.length;r++)n=i[r],V(n)&&!Q(n)&&(_r(n,e,t),Ye(n,t))}else if(V(i)&&!Q(i))for(let n of Object.keys(i))V(i[n])&&!Q(i[n])&&(_r(i[n],e,t),Ye(i[n],t))}function ss(i){if(V(i))return i[Oe]||i[Me]}function as(i){return V(i)&&(delete i[Me],delete i[Oe]),i}function cs(i){let t=ss(i);t&&K(i,t)}function ft(i){if(cs(i),as(i),Array.isArray(i))for(let t=0;t<i.length;t++)ft(i[t]);else if(V(i))for(let t of Object.keys(i))ft(i[t])}function Ut(i){if(Kt(i),Array.isArray(i))for(let t=0;t<i.length;t++)Ut(i[t]);else if(V(i))for(let t of Object.keys(i))Ut(i[t])}function ls(){return dt().slice(0,8)}function he(i){return{"@@type":"ref",id:i}}function Vt(i,t=new Map){if(Array.isArray(i)){let e=ne(i),n=K([],e);for(let r=0;r<i.length;r++){let o=i[r];if(V(o)){if(Se(o))throw new Error("An attempt was made to normalize an already normalized object! This is an error in verdant itself.");if(be(o)){n[r]=o;continue}else{let s=ne(o);n[r]=he(s),Vt(o,t)}}else n[r]=o}t.set(e,n)}else if(V(i)&&!Q(i)){let e=ne(i),n=K({},e);for(let r of Object.keys(i)){let o=i[r];if(V(o)){if(Se(o))throw new Error("An attempt was made to normalize an already normalized object! This is an error in verdant itself.");if(be(o))n[r]=o;else{let s=ne(o);n[r]=he(s),Vt(o,t)}}else n[r]=o}t.set(e,n)}else Q(i);return t}function $(i){return i.split(".")[0].split(pt)[0]}function si(i){let t=$(i),e=xe(t,()=>"\uFFFF");return[`${t}${pt}`,e]}function ai(i){let t=$(i);return[`${t}.`,`${t}.\uFFFF`]}function Ee(i,t){return $(i)===$(t)}function ds(i){let{collection:t,id:e,subId:n}=me(i);return Z(t,e,n)}var us=/"\w+\/[^"]+?(\.[^"]+)+\:[\S]+?"/g;function fs(i){return i.replaceAll(us,t=>{let e=t.slice(1,t.length-1);return`"${ds(e)}"`})}function ci(i){return JSON.parse(fs(JSON.stringify(i)))}function Pr(i){return!i.includes(pt)}function Se(i){return i&&typeof i=="object"&&i["@@type"]==="ref"}function li(i){return V(i)&&!Q(i)}function ps(i,t){return i===t?!0:Q(i)&&Q(t)?Ge(i,t):!1}function ht(i,t,e,n,r=[],o={}){let s=ne(i);function a(p,l,m){if(!li(l))ps(l,m)||r.push({oid:s,timestamp:e(),data:{op:"set",name:p,value:l}});else{let v=pe(m),y=pe(l);y&&!Ee(s,y)?(l=ae(l,!1),y=xe(s,n),K(l,y)):o.mergeUnknownObjects?!y&&v?(K(l,v),y=v):y=oi(l,s,n):y=oi(l,s,n),L(!!y,"Error: no value OID was resolved during diff. This is a bug in Verdant."),L(Ee(s,y),`Error: value OID ${y} is not related to parent OID ${s}. This is a bug in Verdant.`),m===void 0||y!==v?(Re(l,y,e,n,r),r.push({oid:s,timestamp:e(),data:{op:"set",name:p,value:he(y)}}),v!==void 0&&r.push({oid:v,timestamp:e(),data:{op:"delete"}})):ht(m,l,e,n,r,o)}}if(Array.isArray(i)&&Array.isArray(t)){for(let l=0;l<t.length;l++){let m=t[l],v=i[l];a(l,m,v)}let p=i.length-t.length;if(p>0){for(let l=t.length;l<i.length;l++){let m=i[l],v=pe(m);v&&r.push({oid:v,timestamp:e(),data:{op:"delete"}})}r.push({oid:s,timestamp:e(),data:{op:"list-delete",index:t.length,count:p}})}}else{if(Array.isArray(i)||Array.isArray(t))throw new Error("Cannot diff an array with an object");if(li(i)&&li(t)){let p=new Set(Object.keys(i));for(let[l,m]of Object.entries(t)){if(m===void 0&&o.defaultUndefined||(p.delete(l),ri(l)))continue;let v=i[l];a(l,m,v)}if(!o.defaultUndefined)for(let l of p)ri(l)||r.push({oid:s,timestamp:e(),data:{op:"remove",name:l}})}}return r}function Re(i,t,e,n,r=[]){K(i,t),Ye(i,n);let o=Vt(i);for(let s of o.keys()){let a=o.get(s);r.push({oid:s,timestamp:e(),data:{op:"initialize",value:Kt(a)}})}return r}function mt(i){let t={};for(let e of i)e.oid in t?t[e.oid].push(e):t[e.oid]=[e];return t}function Fr(i){let t={};for(let e of i){let n=$(e.oid);n in t?t[n].push(e):t[n]=[e]}return t}function Rr(i){let t={};for(let e of i){let n=$(e.oid);n in t?t[n].push(e):t[n]=[e]}return t}function Be(i){return Array.isArray(i)?!0:(console.error(`Cannot apply list patch; expected array, received ${JSON.stringify(i)}. This suggests your data is changing from a list to an object over time. (OID: ${pe(i)})`),!1)}function je(i,t,e){if(i==null&&t.op!=="initialize")return i;let n=i,r,o;function s(a){e&&Q(a)&&e.push(a)}switch(t.op){case"set":s(n[t.name]),n[t.name]=t.value;break;case"remove":s(n[t.name]),delete n[t.name];break;case"list-push":Be(i)&&i.push(t.value);break;case"list-delete":Be(i)&&(s(i[t.index]),i.splice(t.index,t.count));break;case"list-move-by-index":Be(i)&&(o=i.splice(t.from,1),i.splice(t.to,0,o[0]));break;case"list-remove":if(Be(i))do{let a=t.value;t.only==="last"?Se(a)?r=Ir(i,p=>p.id===a.id):r=i.lastIndexOf(a):Se(a)?r=i.findIndex(p=>p.id===a.id):r=i.indexOf(a),r!==-1&&(s(i[r]),i.splice(r,1))}while(!t.only&&r!==-1);break;case"list-add":Be(i)&&(i.some(p=>Se(p)&&Se(t.value)?p.id===t.value.id:p===t.value)||i.push(t.value));break;case"list-move-by-ref":Be(i)&&(r=i.findIndex(a=>Ge(a,t.value)),o=i.splice(r,1),i.splice(t.index,0,o[0]));break;case"list-insert":if(Be(i)){if(!t.value&&!t.values)throw new Error(`Cannot apply list insert patch; expected value or values, received ${JSON.stringify(t)}`);t.value?i.splice(t.index,0,t.value):i.splice(t.index,0,...t.values)}break;case"delete":Array.isArray(i)?i.forEach(s):V(i)&&Object.values(i||{}).forEach(s);return;case"initialize":return ae(t.value);case"touch":return i;default:throw new Error(`Unsupported patch operation: ${t.op}`)}return i}function $t(i,t,e=[]){if(Array.isArray(i))for(let n=0;n<i.length;n++){let r=i[n];i[n]=Ar(r,t,e),V(i[n])&&$t(i[n],t,e)}else if(!be(i)){if(V(i)){L(pe(i),`Object ${JSON.stringify(i)} must have an oid`);for(let n of Object.keys(i))i[n]=Ar(i[n],t,e),V(i[n])&&$t(i[n],t,e)}}return e}function Ar(i,t,e){if(Se(i)){e.push(i.id);let n=t.get(i.id);return L(!!n,`No value was found in object map for ${i.id}`),K(n,i.id)}else return i}var hs=i=>({type:"object",...i}),ms=i=>({type:"array",...i}),gs=i=>({type:"string",...i}),ys=i=>({type:"number",...i}),bs=i=>({type:"boolean",...i}),ws=i=>({type:"any",...i}),vs=i=>({type:"map",...i}),Ss=i=>({type:"file",...i}),Tr={object:hs,array:ms,string:gs,number:ys,boolean:bs,any:ws,map:vs,file:Ss};var Br=Qe(at(),1);function di(i){return i.equals!==void 0}function ui(i){return i.gte!==void 0||i.lte!==void 0||i.gt!==void 0||i.lt!==void 0}function xs(i){return!!i.match}function fi(i){return i.startsWith!==void 0}function kr(i){return!ui(i)&&!di(i)&&!xs(i)&&!fi(i)&&i.order}function we(i){return i.type==="any"?!0:i.type==="map"?!1:i.nullable}function Ce(i){return i?i.type==="map"||i.type==="array"?!0:i.type==="file"?!1:i.default!==void 0:!1}function hi(i){if(!(!i||!Ce(i)))return i.type==="file"?we(i)?null:void 0:i.type==="map"?{}:i.type==="array"?we(i)?null:[]:i.type==="object"?we(i)?null:void 0:typeof i.default=="function"?i.default():i.default}function Pe(i,t){for(let[e,n]of Object.entries(i.fields)){let r=mi(n);(r!==void 0&&t[e]===void 0||!we(n)&&t[e]===null)&&(t[e]=r),t[e]&&Le(t[e],n)}return t}function Le(i,t){if(i==null)return i;if(t.type==="object")for(let[e,n]of Object.entries(t.properties)){if(i[e]===void 0){let r=mi(n);r!==void 0&&(i[e]=r)}Le(i[e],n)}else if(t.type==="array")for(let e of i)Le(e,t.items);else if(t.type==="map")for(let[e,n]of Object.entries(i))e===Oe||e===Me||Le(n,t.values)}function mi(i){if(i.type==="string"||i.type==="number"||i.type==="boolean"||i.type==="any"){if(i.default&&typeof i.default=="function")return i.default();if(i.default!==void 0)return JSON.parse(JSON.stringify(i.default))}if(i.type==="array")return[];if(i.type==="map")return{};if(i.type!=="any"&&i.nullable)return null;if(i.type==="object"&&i.default){let t=typeof i.default=="function"?i.default():JSON.parse(JSON.stringify(i.default));for(let[e,n]of Object.entries(i.properties))t[e]===void 0&&(t[e]=mi(n));return t}}function gi(i,t){for(let[e,n]of Object.entries(t))e===Oe||e===Me||(i.fields[e]?pi(n,i.fields[e]):delete t[e]);return t}function pi(i,t){if(V(i)&&t.type==="object")for(let[e,n]of Object.entries(i))t.properties[e]?pi(n,t.properties[e]):delete i[e];else if(Array.isArray(i)&&t.type==="array")for(let e of i)pi(e,t.items)}function Mr(i,t){for(let[e,n]of Object.entries(t))if(e!==Oe){if(!i[e])return{type:"invalid-key",fieldPath:[e],message:`Invalid field "${e}"`};if(n){let r=Te({field:i[e],value:n,fieldPath:[e]});if(r)return r}}}function Te({field:i,value:t,fieldPath:e=[],depth:n,requireDefaults:r}){if(!(n!==void 0&&n<=0)&&!(we(i)&&t===null)){if(t===null&&(r||!Ce(i)))return{type:"no-default",fieldPath:e,message:`Invalid null value for field ${Ae(e)}`};if(i.type==="object"){if(!V(t))return{type:"invalid-type",fieldPath:e,message:`Expected object${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`};for(let[o,s]of Object.entries(i.properties))o!==Oe&&t[o]&&Te({field:s,value:t[o],fieldPath:[...e,o],depth:n!==void 0?n-1:void 0});for(let o of Object.keys(t))if(!i.properties[o])return{type:"invalid-key",fieldPath:[...e,o],message:`Invalid unexpected field "${o}" on value ${Ae(e)}`}}else if(i.type==="array"){if(!Array.isArray(t))return t===null&&i.nullable?void 0:{type:"invalid-value",fieldPath:e,message:`Expected array${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`};for(let o of t)Te({field:i.items,value:o,fieldPath:[...e,"[]"],depth:n!==void 0?n-1:void 0})}else if(i.type==="map"){if(!V(t))return{type:"invalid-type",fieldPath:e,message:`Expected map for field ${Ae(e)}, got ${t}`};for(let[o,s]of Object.entries(t))Te({field:i.values,value:s,fieldPath:[...e,o],depth:n!==void 0?n-1:void 0})}else if(i.type==="string"){if(typeof t!="string")return{type:"invalid-type",fieldPath:e,message:`Expected string ${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`};if(i.options&&!i.options.includes(t))return{type:"invalid-value",fieldPath:e,message:`Expected one of ${i.options.join(", ")} for field ${Ae(e)}, got ${t}`}}else if(i.type==="boolean"){if(typeof t!="boolean")return{type:"invalid-type",fieldPath:e,message:`Expected boolean ${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`}}else if(i.type==="number"){if(typeof t!="number")return{type:"invalid-type",fieldPath:e,message:`Expected number ${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`}}else i.type}}function Ae(i){return i.length===0?"root":i.join(".")}function Ne(i,t){return i.type==="object"?i.properties[t]:i.type==="array"?i.items:i.type==="map"?i.values:i.type==="any"?i:"type"in i?null:i[t]??null}function yi({synthetics:i,indexes:t,...e}){let n={...i,...t};for(let[r,o]of Object.entries(e.fields))"indexed"in o&&(n[r]={field:r});return{...e,indexes:n}}function gt(i){return i}gt.collection=yi;gt.fields=Tr;gt.generated={id:Br.default};var zt="\uFFFFFE",Os="\0",Is="\uFFFFFF";function ce(...i){let t=Ds(i);return t.length===1?t[0]:t}function Ue(...i){return i.join(zt)+`${Is}`}function Ve(...i){return i.join(zt)+`${zt}${Os}`}function Ds(i){let t=[[]];for(let e of i)if(Array.isArray(e)){let n=[];for(let r of t)for(let o of e)n.push(r.concat(o));t=n}else for(let n of t)n.push(`${e}`);return Array.from(new Set(t.map(e=>e.join(zt))))}function _s(i){return!!i.field}function Es(i,t){let e={};for(let[n,r]of Object.entries(i.indexes||{})){let o=r;_s(o)?e[n]=ve(t[o.field]):e[n]=ve(o.compute(t))}return e}function Cs(i,t){return Object.entries(i.compounds||{}).reduce((e,[n,r])=>(e[n]=ce(...r.of.map(o=>t[o])),e),{})}function Ps(i,t){return Object.entries(i.fields).reduce((e,[n,r])=>("indexed"in r&&(e[n]=ve(t[n])),e),{})}function qt(i,t){let e={[i.primaryKey]:t[i.primaryKey],...Ps(i,t),...Es(i,t)};return Object.assign(e,Cs(i,{...t,...e})),e["@@@snapshot"]=t,e}var As="null";function ve(i){if(i===null)return As;if(typeof i=="string"||typeof i=="number")return i;if(typeof i=="boolean"||i===null)return`${i}`;if(i===void 0)return"undefined";if(Array.isArray(i))return i.map(ve);throw new Error(`Unsupported index value: ${i}`)}var jr={version:0,collections:{}};function Wt(i,t,e){let n=typeof t=="function",r=n?jr:i,o=n?i:t,s=n?t:e,a=Object.keys(o.collections).filter(x=>r.collections[x]&&ut(r.collections[x])!==ut(o.collections[x])),p=Object.keys(r.collections).filter(x=>!o.collections[x]),l=Object.keys(o.collections).filter(x=>!r.collections[x]),m=new Set;for(let x of a){let I=r.collections[x].fields,S=o.collections[x].fields;Object.keys(S).some(D=>!I[D]?.default&&S[D]?.default)&&m.add(x),Object.keys(I).some(D=>!S[D])&&m.add(x)}let v={},y={};for(let x of[...a,...l]){let I=Ht(r.collections[x]),S=Ht(o.collections[x]),D=S.filter(b=>!I.find(_=>_.name===b.name)),F=I.filter(b=>!S.find(_=>_.name===b.name));D.length>0&&(v[x]=D,a.includes(x)&&m.add(x)),F.length>0&&(y[x]=F,a.includes(x)&&m.add(x))}let C=(x,I)=>Pe(o.collections[x],I),w=x=>I=>{let S=o.collections[x];return Pe(S,gi(S,I))};return{version:o.version,migrate:async x=>{let I=[];if(await s({migrate:async(S,D)=>{let F=w(S),b=async _=>{let u=await D(_);return K(u,ne(_)),F(u)};await x.migrate(S,b),I.push(S),m.delete(S)},identity:S=>S,withDefaults:C,info:{changedCollections:a,addedCollections:l,removedCollections:p},queries:x.queries,mutations:x.mutations}),o.version>1){x.log("debug","auto-migrating collections with new defaults",m);for(let D of m)await x.migrate(D,w(D)),I.push(D);let S=a.filter(D=>!I.includes(D));S.length>0&&console.error(`Unmigrated changed collections from version ${r.version} to version ${o.version}:`,S)}},removedCollections:p,addedIndexes:v,removedIndexes:y,allCollections:Object.keys(o.collections),changedCollections:a,addedCollections:l,oldCollections:Object.keys(r.collections),oldSchema:r,newSchema:o}}function Ht(i){return i?[...Object.keys(i.indexes||{}).map(t=>({name:t,multiEntry:["array","string[]","number[]","boolean[]"].includes(i.indexes[t].type),synthetic:!0,compound:!1})),...Object.keys(i.compounds||{}).map(t=>({name:t,multiEntry:i.compounds[t].of.some(e=>(i.fields[e]||i.indexes[e]).type==="array"),synthetic:!1,compound:!0}))]:[]}function bi(i,t){return Wt(t?i:{version:0,collections:{}},t||i,async({migrate:n,info:r})=>{if((t||i).version!==1)for(let o of r.changedCollections)await n(o,s=>s)})}function wi(i,t,e){let n=typeof t=="function"||t===void 0,r=n?jr:i,o=n?i:t,s=n?t:e;L(r,"Invalid arguments to createMigration"),L(o,"Invalid arguments to createMigration");let{changedCollections:a,addedCollections:p,removedCollections:l,addedIndexes:m,removedIndexes:v,autoMigratedCollections:y,autoMigration:C}=Fs(r,o);return{version:o.version,migrate:async w=>{let x=[];if(await s?.({migrate:async(S,D)=>{let F=C(S),b=async _=>{let u=await D(_);K(u,ne(_));let h=F(u),d=Mr(o.collections[S].fields,h);return h};await w.migrate(S,b),x.push(S),y.delete(S)},info:{changedCollections:a,addedCollections:p,removedCollections:l},queries:w.queries,mutations:w.mutations}),o.version>1){w.log("debug","auto-migrating collections with new defaults",y);for(let D of y)await w.migrate(D,C(D)),x.push(D);for(let D of l)await w.deleteCollection(D);let S=a.filter(D=>!x.includes(D));S.length>0&&console.error(`Unmigrated changed collections from version ${r.version} to version ${o.version}:`,S)}},removedCollections:l,addedIndexes:m,removedIndexes:v,allCollections:Object.keys(o.collections),changedCollections:a,addedCollections:p,oldCollections:Object.keys(r.collections),oldSchema:r,newSchema:o}}function Fs(i,t){let e=Object.keys(t.collections).filter(m=>i.collections[m]&&ut(i.collections[m])!==ut(t.collections[m])),n=Object.keys(i.collections).filter(m=>!t.collections[m]),r=Object.keys(t.collections).filter(m=>!i.collections[m]),o=new Set;for(let m of e){let v=i.collections[m].fields,y=t.collections[m].fields;Object.keys(y).some(C=>!Ce(v[C])&&Ce(y[C]))&&o.add(m),Object.keys(v).some(C=>!y[C])&&o.add(m)}let s={},a={};for(let m of[...e,...r]){let v=Ht(i.collections[m]),y=Ht(t.collections[m]),C=y.filter(x=>!v.find(I=>I.name===x.name)),w=v.filter(x=>!y.find(I=>I.name===x.name));C.length>0&&(s[m]=C,e.includes(m)&&o.add(m)),w.length>0&&(a[m]=w,e.includes(m)&&o.add(m))}return{changedCollections:e,addedCollections:r,removedCollections:n,addedIndexes:s,removedIndexes:a,autoMigratedCollections:o,withDefaults:(m,v)=>Pe(t.collections[m],v),autoMigration:m=>v=>{let y=t.collections[m];return Pe(y,gi(y,v))}}}var Qt=class{constructor(t,e){this.getNow=t;this.createSubId=e;this.isPrimitive=t=>!V(t)||Q(t);this.createDiff=(t,e,n={})=>ht(t,e,this.getNow,this.createSubId,[],n);this.createInitialize=(t,e)=>Re(t,e,this.getNow,this.createSubId);this.createSet=(t,e,n)=>{if(this.isPrimitive(n))return[{oid:t,timestamp:this.getNow(),data:{op:"set",name:e,value:n}}];{let r=xe(t,this.createSubId);return[...Re(n,r,this.getNow),{oid:t,timestamp:this.getNow(),data:{op:"set",value:he(r),name:e}}]}};this.createRemove=(t,e)=>[{oid:t,timestamp:this.getNow(),data:{op:"remove",name:e}}];this.createListPush=(t,e)=>{if(this.isPrimitive(e))return[{oid:t,timestamp:this.getNow(),data:{op:"list-push",value:e}}];{let n=xe(t,this.createSubId);return[...Re(e,n,this.getNow),{oid:t,timestamp:this.getNow(),data:{op:"list-push",value:he(n)}}]}};this.createListAdd=(t,e)=>this.isPrimitive(e)?[{oid:t,timestamp:this.getNow(),data:{op:"list-add",value:e}}]:[{oid:t,timestamp:this.getNow(),data:{op:"list-add",value:he(e)}}];this.createListInsert=(t,e,n)=>{if(this.isPrimitive(n))return[{oid:t,timestamp:this.getNow(),data:{op:"list-insert",value:n,index:e}}];{let r=xe(t,this.createSubId);return[...Re(n,r,this.getNow),{oid:t,timestamp:this.getNow(),data:{op:"list-insert",value:he(r),index:e}}]}};this.createListRemove=(t,e,n)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-remove",value:e,only:n}}];this.createListDelete=(t,e,n=1)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-delete",index:e,count:n}}];this.createListMoveByRef=(t,e,n)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-move-by-ref",value:e,index:n}}];this.createListMoveByIndex=(t,e,n)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-move-by-index",from:e,to:n}}];this.createDelete=t=>[{oid:t,timestamp:this.getNow(),data:{op:"delete"}}];this.createDeleteAll=t=>t.map(e=>({oid:e,timestamp:this.getNow(),data:{op:"delete"}}))}};var U=class{constructor(t){this._onAllUnsubscribed=t;this.subscribers={};this.counts={};this._disabled=!1;this.disposed=!1;this.subscriberCount=t=>this.counts[t]??0;this.totalSubscriberCount=()=>Object.values(this.counts).reduce((t,e)=>t+e,0);this.subscribe=(t,e)=>{let n=Nt(),r=this.subscribers[t];return r||(r=this.subscribers[t]={}),r[n]=e,this.counts[t]=(this.counts[t]||0)+1,()=>{this.subscribers[t]&&(delete this.subscribers[t][n],this.counts[t]--,this.counts[t]===0&&(delete this.subscribers[t],delete this.counts[t],this._onAllUnsubscribed&&this._onAllUnsubscribed(t)))}};this.emit=(t,...e)=>{this._disabled||this.subscribers[t]&&Object.values(this.subscribers[t]).forEach(n=>n(...e))};this.dispose=()=>{this._disabled=!0,this.disposed=!0;let t=Object.keys(this.subscribers);this.subscribers={},this.counts={},t.forEach(e=>{this._onAllUnsubscribed&&this._onAllUnsubscribed(e)})};this.disable=()=>{this._disabled=!0}}get disabled(){return this._disabled}};function Lr(i,t,e,n){if(t==null)return[{oid:i,timestamp:n(),data:{op:"delete"}}];let r=ae(t),o=[];for(let s of e){let a=Rs(i,r,s,n);o.unshift(...a),je(r,s.data)}return o}function Rs(i,t,e,n){let r=e.data;switch(r.op){case"set":case"remove":return[{oid:i,timestamp:n(),data:{op:"set",name:r.name,value:t[r.name]}}];case"list-insert":return[{oid:i,timestamp:n(),data:{op:"list-delete",index:r.index,count:1}}];case"list-delete":return[{oid:i,timestamp:n(),data:{op:"list-insert",index:r.index,values:t.slice(r.index,r.count)}}];case"list-move-by-ref":return[{oid:i,timestamp:n(),data:{op:"list-move-by-ref",value:r.value,index:t.indexOf(r.value)}}];case"list-move-by-index":return[{oid:i,timestamp:n(),data:{op:"list-move-by-index",from:r.to,to:r.from}}];case"delete":return[{oid:i,timestamp:n(),data:{op:"initialize",value:t}}];case"list-push":return[{oid:i,timestamp:n(),data:{op:"list-remove",value:r.value,only:"last"}}];case"list-remove":if(r.only==="last"){let o=t.lastIndexOf(r.value);return[{oid:i,timestamp:n(),data:{op:"list-insert",index:o,values:[r.value]}}]}else if(r.only==="first"){let o=t.indexOf(r.value);return[{oid:i,timestamp:n(),data:{op:"list-insert",index:o,values:[r.value]}}]}else{let o=[],s=t.indexOf(r.value);for(;s!==-1;)o.push(s),s=t.indexOf(r.value,s+1);return o.map(a=>({oid:i,timestamp:n(),data:{op:"list-insert",index:a,value:r.value}}))}case"list-add":return[{oid:i,timestamp:n(),data:{op:"list-remove",value:r.value,only:"last"}}];case"initialize":return[{oid:i,timestamp:n(),data:{op:"delete"}}];case"touch":return[];default:throw new Error(`Cannot undo operation type: ${r.op}`)}}var Xe=class{constructor(t){this.flusher=t;this.batches=new Map;this.flush=t=>{let e=this.batches.get(t);if(e)return e.flush()};this.discard=t=>{let e=this.batches.get(t);e&&(e.discard(),this.batches.delete(t))};this.flushAll=()=>[...this.batches.values()].map(t=>t.flush());this.getSize=t=>{let e=this.batches.get(t);return e?e.items.length:0}}add({key:t,userData:e,items:n,max:r,timeout:o}){let s=this.batches.get(t);return s||(s=new vi({max:r||null,startedAt:Date.now(),userData:e,timeout:o||null,flusher:this.flusher,key:t}),this.batches.set(t,s)),s.update({items:n,max:r,timeout:o,userData:e}),s}},vi=class{constructor({max:t,startedAt:e,timeout:n,userData:r,flusher:o,key:s}){this.items=[];this.update=({items:t,max:e,timeout:n,userData:r})=>{this.items.push(...t),e!==void 0&&(this.max=e),n!==void 0&&(this.timeout=n),r&&(this.userData=r);let o=this.items.length!==0&&this.timeout!==null&&!this.flushTimeout;this.max!==null&&this.items.length>=this.max?this.flush():o&&this.timeout!==null&&(this.flushTimeout=setTimeout(this.flush,this.timeout))};this.flush=()=>{this.flushTimeout&&clearTimeout(this.flushTimeout),this.flushTimeout=void 0;let t=this.items;return this.items=[],this.flusher(t,this.key,this.userData)};this.discard=()=>{this.flushTimeout&&clearTimeout(this.flushTimeout),this.flushTimeout=void 0,this.items=[]};this.max=t,this.startedAt=e,this.timeout=n,this.userData=r,this.flusher=o,this.key=s}};function Nr(i,t){let e,n;return(...r)=>{let o=t();return e&&e.length===o.length&&e.every((s,a)=>s===o[a])||(e=[...o],n=i(...r)),n}}var Si=(l=>(l[l.InvalidRequest=4e3]="InvalidRequest",l[l.BodyRequired=4001]="BodyRequired",l[l.NoToken=4010]="NoToken",l[l.InvalidToken=4011]="InvalidToken",l[l.TokenExpired=4012]="TokenExpired",l[l.NotFound=4040]="NotFound",l[l.Unexpected=5e3]="Unexpected",l[l.ConfigurationError=5010]="ConfigurationError",l[l.NoFileStorage=5011]="NoFileStorage",l))(Si||{}),Ur=class extends Error{constructor(e,n,r){super(r??`Verdant error: ${e}`,{cause:n});this.code=e;this.toResponse=()=>JSON.stringify({code:this.code})}static{this.Code=Si}get httpStatus(){let e=Math.floor(this.code/10);return e<600?e:500}};function Vr(i){return typeof i=="object"&&"code"in i&&typeof i.code=="number"}function le(i){return i instanceof Error&&i.name==="AbortError"}function J(i){return new Promise((t,e)=>{i.onsuccess=()=>{t(i.result)},i.onerror=()=>{i.error&&le(i.error)?t(i.result):e(i.error)}})}function yt(i,t){return new Promise((e,n)=>{let r=i.transaction([t],"readonly"),s=r.objectStore(t).openCursor(),a=0,p=0;s.onsuccess=function(l){let m=s.result;m&&(a++,p=p+Or(m.value),m.continue())},s.onerror=function(l){s.error&&le(s.error)?e({count:a,size:p}):n(s.error)},r.oncomplete=function(l){e({count:a,size:p})},r.onabort=function(l){n(l)},r.onerror=function(l){n(l)}})}function Jt(i,t){let e=i.transaction(t,"readonly"),n=t.map(r=>{let o=e.objectStore(r);return J(o.getAll())});return Promise.all(n)}async function Ke(i){i.close(),await new Promise((t,e)=>{t()})}async function Gt(i,t=window.indexedDB){let e=t.deleteDatabase([i,"meta"].join("_")),n=t.deleteDatabase([i,"collections"].join("_"));await Promise.all([new Promise((r,o)=>{e.onsuccess=r,e.onerror=o}),new Promise((r,o)=>{n.onsuccess=r,n.onerror=o})]),window.location.reload()}function Kr(i,t=window.indexedDB){return J(t.deleteDatabase(i))}async function $r(i=window.indexedDB){return i.databases()}function Yt(i,t,e,n,r){let o=i.transaction(t,e);if(n){let s=()=>{r?.("debug","aborting transaction");try{o.abort()}catch(a){r?.("debug","aborting transaction failed",a)}};n.addEventListener("abort",s),o.addEventListener("error",()=>{n.removeEventListener("abort",s)}),o.addEventListener("complete",()=>{n.removeEventListener("abort",s)})}return o}var Ie=class{constructor(){this._disposes=[];this.disposed=!1;this.dispose=()=>{this.disposed=!0,this._disposes.forEach(t=>t()),this._disposes=[]};this.addDispose=t=>{this._disposes.push(t)}}};var se=class extends Ie{constructor(e,{log:n}={}){super();this.db=e;this.globalAbortController=new AbortController;this.createTransaction=(e,n)=>{let r=Yt(this.db,e,n?.mode||"readonly",n?.abort,this.log);return this.globalAbortController.signal.addEventListener("abort",r.abort),r.addEventListener("complete",()=>{this.globalAbortController.signal.removeEventListener("abort",r.abort)}),r.addEventListener("error",()=>{this.globalAbortController.signal.removeEventListener("abort",r.abort)}),r};this.run=async(e,n,r)=>{if(this.disposed||r?.transaction?.error)return Promise.resolve(void 0);let s=(r?.transaction||this.createTransaction([e],r)).objectStore(e),a=n(s);return J(a)};this.runAll=async(e,n,r)=>{if(this.disposed||r?.transaction?.error)return Promise.resolve([]);let s=(r?.transaction||this.createTransaction([e],r)).objectStore(e),a=n(s);return Promise.all(a.map(J))};this.iterate=async(e,n,r,o)=>{let a=(o?.transaction||this.createTransaction([e],o)).objectStore(e),p=n(a);return Array.isArray(p)?Promise.all(p.map(l=>new Promise((m,v)=>{l.onsuccess=()=>{let y=l.result;y?(r(y.value,a),y.continue()):m()},l.onerror=()=>{l.error&&le(l.error)?m():v(l.error)}}))).then(()=>{}):new Promise((l,m)=>{p.onsuccess=()=>{let v=p.result;v?(r(v.value,a),v.continue()):l()},p.onerror=()=>{p.error&&le(p.error)?l():m(p.error)}})};this.clear=e=>this.run(e,n=>n.clear(),{mode:"readwrite"});this.log=n,this.addDispose(()=>{this.globalAbortController.abort()})}};var Xt=class extends se{constructor(){super(...arguments);this.getAckInfo=async()=>{let e=await this.run("info",n=>n.get("ack"));return e||{globalAckTimestamp:null,type:"ack"}};this.setGlobalAck=async e=>{await this.run("info",n=>n.put({type:"ack",globalAckTimestamp:e}),{mode:"readwrite"})}}};var Zt=class extends se{constructor(e,n){super(e,n);this.getAllForDocument=async(e,{mode:n="readonly",transaction:r}={})=>{let o=[];return await this.iterateOverAllForDocument(e,s=>{o.push(s)},{mode:n,transaction:r}),o};this.iterateOverAllForDocument=async(e,n,{mode:r="readonly",transaction:o}={})=>this.iterate("baselines",s=>{let a=$(e),[p,l]=si(e),[m,v]=ai(e);return[s.openCursor(IDBKeyRange.only(a)),s.openCursor(IDBKeyRange.bound(p,l,!1,!1)),s.openCursor(IDBKeyRange.bound(m,v,!1,!1))]},n,{mode:r,transaction:o});this.iterateOverAllForCollection=async(e,n,{mode:r="readonly",transaction:o}={})=>this.iterate("baselines",s=>[s.openCursor(IDBKeyRange.bound(e,e+"\uFFFF",!1,!1))],n,{mode:r,transaction:o});this.getAllForMultipleDocuments=async(e,{mode:n="readonly"}={})=>(await this.runAll("baselines",o=>e.flatMap(s=>{let a=$(s),[p,l]=si(s),[m,v]=ai(s);return[o.get(a),o.getAll(IDBKeyRange.bound(p,l,!1,!1)),o.getAll(IDBKeyRange.bound(m,v,!1,!1))]}),{mode:n})).flat();this.getAllSince=async(e,{mode:n="readonly"}={})=>this.run("baselines",r=>{let o=e?IDBKeyRange.lowerBound(e,!0):void 0;return r.index("timestamp").getAll(o)},{mode:n});this.get=async(e,{transaction:n,mode:r="readonly"}={})=>this.run("baselines",o=>o.get(e),{mode:r,transaction:n});this.set=async(e,{transaction:n}={})=>{await this.run("baselines",r=>r.put(e),{mode:"readwrite",transaction:n})};this.setAll=async(e,{transaction:n}={})=>{await this.runAll("baselines",r=>e.map(o=>r.put(o)),{mode:"readwrite",transaction:n})};this.reset=()=>this.clear("baselines");this.delete=async(e,{transaction:n})=>{await this.run("baselines",r=>r.delete(e),{mode:"readwrite",transaction:n})}}};var zr=Qe(at(),1);var en=class extends se{constructor(){super(...arguments);this.get=async({transaction:e}={})=>{if(this.cached)return this.cached;let n=await this.run("info",r=>r.get("localReplicaInfo"),{transaction:e});return n?(this.cached=n,n):(this._creating||(this._creating=(async()=>{let o={type:"localReplicaInfo",id:(0,zr.default)(),ackedLogicalTime:null,lastSyncedLogicalTime:null};await this.run("info",s=>s.put(o),{mode:"readwrite"}),this.cached=o})()),await this._creating,this.get({transaction:e}))};this.update=async(e,{transaction:n}={})=>{let r=await this.get({transaction:n});Object.assign(r,e),await this.run("info",o=>o.put(r),{mode:"readwrite"}),this.cached=r};this.reset=async()=>{let e=await this.get();e.ackedLogicalTime=null,e.lastSyncedLogicalTime=null,await this.run("info",n=>n.put(e),{mode:"readwrite"})}}};var tn=class{constructor(t){this.meta=t;this.createOperation=async t=>{let e=await this.meta.localReplica.get();return{type:"op",timestamp:this.meta.now,replicaId:e.id,operations:t.operations.map(n=>({data:n.data,oid:n.oid,timestamp:n.timestamp}))}};this.createMigrationOperation=async({targetVersion:t,...e})=>{let n=await this.meta.localReplica.get();return{type:"op",operations:e.operations.map(r=>({...r,timestamp:this.meta.time.zero(t)})),timestamp:this.meta.time.zero(t),replicaId:n.id}};this.createSyncStep1=async t=>{let e=await this.meta.localReplica.get(),n=t===null?null:e.lastSyncedLogicalTime,r=[],o=new Set;n?await this.meta.operations.iterateOverAllLocalOperations(a=>{r.push({data:a.data,oid:a.oid,timestamp:a.timestamp}),o.add($(a.oid))},{after:n,mode:"readwrite"}):await this.meta.operations.iterateOverAllOperations(a=>{r.push({data:a.data,oid:a.oid,timestamp:a.timestamp}),o.add($(a.oid))},{mode:"readwrite"});let s=[];return n||(s=await this.meta.baselines.getAllSince("")),{type:"sync",schemaVersion:this.meta.schema.currentVersion,timestamp:this.meta.now,replicaId:e.id,resyncAll:!e.lastSyncedLogicalTime,operations:r,baselines:s,since:n}};this.createPresenceUpdate=async t=>{let e=await this.meta.localReplica.get();return{type:"presence-update",presence:t,replicaId:e.id}};this.createHeartbeat=async()=>{let t=await this.meta.localReplica.get();return{type:"heartbeat",timestamp:this.meta.now,replicaId:t.id}};this.createAck=async t=>{let e=await this.meta.localReplica.get();return{type:"ack",timestamp:this.meta.now,replicaId:e.id,nonce:t}}}};var nn=class extends se{constructor(e,n){super(e,n);this.iterateOverAllOperationsForDocument=async(e,n,{to:r,from:o,after:s,mode:a="readonly",transaction:p}={})=>{let m=(p||this.createTransaction(["operations"],{mode:a})).objectStore("operations"),v=m.index("d_t"),y=o||s,C=y?ce(e,y):Ve(e),w=r?ce(e,r):Ue(e),x=IDBKeyRange.bound(C,w,!!s,!1),I=v.openCursor(x,"next");return new Promise((S,D)=>{let F;I.onsuccess=b=>{let _=I.result;if(_){let u=_.value;L(u.oid.startsWith(e)),L(F===void 0||F<=u.timestamp,`expected ${F} <= ${u.timestamp}`),n(u,m),F=u.timestamp,_.continue()}else S()},I.onerror=b=>{if(le(I.error)){S();return}else D(I.error)}})};this.iterateOverAllOperationsForEntity=async(e,n,{after:r,to:o,mode:s,transaction:a})=>{let l=(a||this.createTransaction(["operations"],{mode:s})).objectStore("operations"),m=r?ce(e,r):Ve(e),v=o?ce(e,o):Ue(e),y=IDBKeyRange.bound(m,v,!!r,!1),C=l.openCursor(y,"next");return new Promise((w,x)=>{let I;C.onsuccess=S=>{let D=C.result;if(D){let F=D.value;L(F.oid.startsWith(e)),L(I===void 0||I<=F.timestamp,`expected ${I} <= ${F.timestamp}`),n(F,l),I=F.timestamp,D.continue()}else w()},C.onerror=S=>{le(C.error)?w():x(C.error)}})};this.iterateOverAllOperationsForCollection=async(e,n,{after:r,to:o,mode:s,transaction:a})=>{let p=a||this.createTransaction(["operations"],{mode:s});return this.iterate("operations",l=>l.openCursor(IDBKeyRange.bound(e,e+"\uFFFF",!1,!1),"next"),n,{mode:s,transaction:p})};this.iterateOverAllLocalOperations=async(e,{before:n,after:r,mode:o="readonly",transaction:s})=>{let p=(s||this.createTransaction(["operations"],{mode:o})).objectStore("operations"),l=p.index("l_t"),m=r?ce(!0,r):Ve(!0),v=n?ce(!0,n):Ue(!0),y=IDBKeyRange.bound(m,v,!!r,!0),C=l.openCursor(y,"next");return new Promise((w,x)=>{let I;C.onsuccess=S=>{let D=C.result;if(D){let F=D.value;L(I===void 0||I<=F.timestamp,`expected ${I} <= ${F.timestamp}`),e(F,p),I=F.timestamp,D.continue()}else w()},C.onerror=S=>{le(C.error)?w():x(C.error)}})};this.iterateOverAllOperations=async(e,{before:n,transaction:r,mode:o,from:s})=>{await this.iterate("operations",a=>{let p=s?Ve(s):void 0,l=n?Ue(n):void 0,m=p&&l?window.IDBKeyRange.bound(p,l,!1,!0):p?window.IDBKeyRange.lowerBound(p,!1):l?window.IDBKeyRange.upperBound(l,!0):void 0;return a.index("timestamp").openCursor(m,"next")},e,{mode:o,transaction:r})};this.addOperations=async(e,{transaction:n}={})=>this.insert(e.map(this.addCompoundIndexes),{transaction:n});this.addCompoundIndexes=e=>({...e,oid_timestamp:ce(e.oid,e.timestamp),l_t:ce(e.isLocal,e.timestamp),d_t:ce($(e.oid),e.timestamp)});this.insert=async(e,{transaction:n})=>{let r=new Set;return await this.runAll("operations",o=>e.map(s=>(r.add($(s.oid)),o.put(s))),{mode:"readwrite",transaction:n}),Array.from(r)};this.reset=()=>this.clear("operations")}};var rn=class{constructor(t,e){this.db=t;this.currentVersion=e;this.cached=null;this.get=async()=>{if(this.cached)return this.cached;let r=this.db.transaction("info","readonly").objectStore("info").get("schema"),o=await J(r);return o?(this.cached=JSON.parse(o.schema),this.cached):null};this.set=async t=>{let o=this.db.transaction("info","readwrite").objectStore("info").put({type:"schema",schema:JSON.stringify(t)});this.cached=t,await J(o)}}};var bt=class extends U{constructor({disableRebasing:e,context:n}){super();this.time=new Ft;this.disableRebasing=!1;this._closing=!1;this.setContext=e=>{this.context=e};this.close=()=>{this._closing=!0};this.createTransaction=(e,n={})=>Yt(this.db,e,"readwrite",n.abort,this.context.log);this.getAllDocumentRelatedOids=async e=>{let n=new Set,r=$(e);L(r===e,"Must be root document OID"),n.add(r);let o=this.createTransaction(["baselines","operations"]);return await Promise.all([this.baselines.iterateOverAllForDocument(r,s=>{n.add(s.oid)},{transaction:o}),this.operations.iterateOverAllOperationsForDocument(r,s=>{n.add(s.oid)},{transaction:o})]),Array.from(n)};this.getAllCollectionRelatedOids=async e=>{let n=new Set,r=this.db.transaction(["baselines","operations"],"readwrite");return await Promise.all([this.baselines.iterateOverAllForCollection(e,o=>{n.add(o.oid)},{transaction:r}),this.operations.iterateOverAllOperationsForCollection(e,o=>{n.add(o.oid)},{transaction:r})]),Array.from(n)};this.getDocumentSnapshot=async(e,n={})=>{let r=$(e);L(r===e,"Must be root document OID");let o=this.db.transaction(["baselines","operations"],"readwrite"),s=await this.baselines.getAllForDocument(r,{transaction:o}),a=new Map;for(let l of s)l.snapshot&&K(l.snapshot,l.oid),a.set(l.oid,l.snapshot);await this.operations.iterateOverAllOperationsForDocument(r,l=>{let m=a.get(l.oid)||void 0,v=je(m,l.data);v&&K(v,l.oid),a.set(l.oid,v)},{transaction:o,to:n.to||this.now});let p=a.get(r);return p&&$t(p,a),p};this.getDocumentData=async(e,n)=>{let r=this.createTransaction(["baselines","operations"],n),o=[],s={};return await Promise.all([this.baselines.iterateOverAllForDocument(e,a=>{o.push(a)},{transaction:r}),this.operations.iterateOverAllOperationsForDocument(e,a=>{s[a.oid]??=[],s[a.oid].push(a)},{transaction:r})]),{baselines:o,operations:s}};this.ack=async e=>{let n=await this.localReplica.get();e>this.now||(this.emit("message",{type:"ack",replicaId:n.id,timestamp:e}),!this._closing&&(!n.ackedLogicalTime||e>n.ackedLogicalTime)&&this.localReplica.update({ackedLogicalTime:e}))};this.insertLocalOperations=async(e,n)=>{if(e.length===0)return;this.log("debug",`Inserting ${e.length} local operations`,e);for(let o of e)o.isLocal=!0;await this.operations.addOperations(e,n);let r=await this.messageCreator.createOperation({operations:e});this.emit("message",r),this.tryAutonomousRebase()};this.insertRemoteOperations=async(e,n)=>{if(e.length===0)return[];this.log("debug",`Inserting ${e.length} remote operations`,e);let r=await this.operations.addOperations(e.map(o=>({...o,isLocal:!1})),n);return this.ack(e[e.length-1].timestamp),r};this.insertRemoteBaselines=async(e,n)=>{if(e.length===0)return[];this.log(`Inserting ${e.length} remote baselines`),await this.baselines.setAll(e,n);let r=new Set;return e.forEach(o=>{r.add($(o.oid))}),Array.from(r)};this.insertData=async(e,n)=>{let r=this.createTransaction(["baselines","operations"],n);e.baselines&&await this.insertRemoteBaselines(e.baselines,{transaction:r}),!n?.abort?.aborted&&e.operations&&(e.isLocal?await this.insertLocalOperations(e.operations,{transaction:r}):await this.insertRemoteOperations(e.operations,{transaction:r}))};this.updateLastSynced=async e=>{if(!this._closing)return this.localReplica.update({lastSyncedLogicalTime:e})};this.lastSyncedTimestamp=async()=>(await this.localReplica.get()).lastSyncedLogicalTime;this.tryAutonomousRebase=async()=>{this.disableRebasing||(await this.localReplica.get()).lastSyncedLogicalTime||await this.runRebase(this.now)};this.runRebase=async e=>{if(this._closing)return;let n,r=new Set,o=this.createTransaction(["baselines","operations"]),s=0;if(await this.operations.iterateOverAllOperations(p=>{r.add(p.oid),n=p.timestamp,s++},{before:e,transaction:o}),!r.size||this._closing)return;let a=[];for(let p of r)a.push(await this.rebase(p,n||e,o));this.emit("rebase",a)};this.rebase=async(e,n,r)=>{let o=(await this.localReplica.get()).id;this.log("[",o,"]","Rebasing",e,"up to",n);let s=r||this.createTransaction(["operations","baselines"]),a=await this.baselines.get(e,{transaction:s}),p=a?.snapshot||void 0,l=0,m=[];await this.operations.iterateOverAllOperationsForEntity(e,(y,C)=>{(!a||y.timestamp>a.timestamp)&&(p=je(p,y.data,m)),l++,C.delete(y.oid_timestamp)},{to:n,transaction:s}),p&&K(p,e);let v={oid:e,snapshot:p,timestamp:n};if(v.snapshot?await this.baselines.set(v,{transaction:s}):await this.baselines.delete(e,{transaction:s}),this.log("debug","successfully rebased",e,"up to",n,":",p,"and deleted",l,"operations"),m.length){let y=m.filter(be);y.length&&this.emit("filesDeleted",y)}return v};this.reset=async()=>{await this.operations.reset(),await this.baselines.reset(),await this.localReplica.reset()};this.updateSchema=async(e,n)=>{let r=await this.schema.get();if(r&&n===r.version&&r.version===e.version&&JSON.stringify(r)!==JSON.stringify(e))throw console.error(`Schema mismatch for version ${e.version}
|
|
6
|
+
`))}D.fill(0),e.createHash=function(d){return F(d)},e.createHmac=F,e.randomBytes=function(d,O){if(!O||!O.call)return new y(x(d));try{O.call(this,void 0,new y(x(d)))}catch(E){O(E)}};var _,u=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],h=function(d){e[d]=function(){b("sorry,",d,"is not implemented yet")}};for(_ in u)h(u[_],_)}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y=i("./helpers");function C(b,_){b[_>>5]|=128<<_%32,b[14+(_+64>>>9<<4)]=_;for(var u=1732584193,h=-271733879,d=-1732584194,O=271733878,E=0;E<b.length;E+=16){var B=u,M=h,j=d,k=O,u=x(u,h,d,O,b[E+0],7,-680876936),O=x(O,u,h,d,b[E+1],12,-389564586),d=x(d,O,u,h,b[E+2],17,606105819),h=x(h,d,O,u,b[E+3],22,-1044525330);u=x(u,h,d,O,b[E+4],7,-176418897),O=x(O,u,h,d,b[E+5],12,1200080426),d=x(d,O,u,h,b[E+6],17,-1473231341),h=x(h,d,O,u,b[E+7],22,-45705983),u=x(u,h,d,O,b[E+8],7,1770035416),O=x(O,u,h,d,b[E+9],12,-1958414417),d=x(d,O,u,h,b[E+10],17,-42063),h=x(h,d,O,u,b[E+11],22,-1990404162),u=x(u,h,d,O,b[E+12],7,1804603682),O=x(O,u,h,d,b[E+13],12,-40341101),d=x(d,O,u,h,b[E+14],17,-1502002290),u=I(u,h=x(h,d,O,u,b[E+15],22,1236535329),d,O,b[E+1],5,-165796510),O=I(O,u,h,d,b[E+6],9,-1069501632),d=I(d,O,u,h,b[E+11],14,643717713),h=I(h,d,O,u,b[E+0],20,-373897302),u=I(u,h,d,O,b[E+5],5,-701558691),O=I(O,u,h,d,b[E+10],9,38016083),d=I(d,O,u,h,b[E+15],14,-660478335),h=I(h,d,O,u,b[E+4],20,-405537848),u=I(u,h,d,O,b[E+9],5,568446438),O=I(O,u,h,d,b[E+14],9,-1019803690),d=I(d,O,u,h,b[E+3],14,-187363961),h=I(h,d,O,u,b[E+8],20,1163531501),u=I(u,h,d,O,b[E+13],5,-1444681467),O=I(O,u,h,d,b[E+2],9,-51403784),d=I(d,O,u,h,b[E+7],14,1735328473),u=S(u,h=I(h,d,O,u,b[E+12],20,-1926607734),d,O,b[E+5],4,-378558),O=S(O,u,h,d,b[E+8],11,-2022574463),d=S(d,O,u,h,b[E+11],16,1839030562),h=S(h,d,O,u,b[E+14],23,-35309556),u=S(u,h,d,O,b[E+1],4,-1530992060),O=S(O,u,h,d,b[E+4],11,1272893353),d=S(d,O,u,h,b[E+7],16,-155497632),h=S(h,d,O,u,b[E+10],23,-1094730640),u=S(u,h,d,O,b[E+13],4,681279174),O=S(O,u,h,d,b[E+0],11,-358537222),d=S(d,O,u,h,b[E+3],16,-722521979),h=S(h,d,O,u,b[E+6],23,76029189),u=S(u,h,d,O,b[E+9],4,-640364487),O=S(O,u,h,d,b[E+12],11,-421815835),d=S(d,O,u,h,b[E+15],16,530742520),u=D(u,h=S(h,d,O,u,b[E+2],23,-995338651),d,O,b[E+0],6,-198630844),O=D(O,u,h,d,b[E+7],10,1126891415),d=D(d,O,u,h,b[E+14],15,-1416354905),h=D(h,d,O,u,b[E+5],21,-57434055),u=D(u,h,d,O,b[E+12],6,1700485571),O=D(O,u,h,d,b[E+3],10,-1894986606),d=D(d,O,u,h,b[E+10],15,-1051523),h=D(h,d,O,u,b[E+1],21,-2054922799),u=D(u,h,d,O,b[E+8],6,1873313359),O=D(O,u,h,d,b[E+15],10,-30611744),d=D(d,O,u,h,b[E+6],15,-1560198380),h=D(h,d,O,u,b[E+13],21,1309151649),u=D(u,h,d,O,b[E+4],6,-145523070),O=D(O,u,h,d,b[E+11],10,-1120210379),d=D(d,O,u,h,b[E+2],15,718787259),h=D(h,d,O,u,b[E+9],21,-343485551),u=F(u,B),h=F(h,M),d=F(d,j),O=F(O,k)}return Array(u,h,d,O)}function w(b,_,u,h,d,O){return F((_=F(F(_,b),F(h,O)))<<d|_>>>32-d,u)}function x(b,_,u,h,d,O,E){return w(_&u|~_&h,b,_,d,O,E)}function I(b,_,u,h,d,O,E){return w(_&h|u&~h,b,_,d,O,E)}function S(b,_,u,h,d,O,E){return w(_^u^h,b,_,d,O,E)}function D(b,_,u,h,d,O,E){return w(u^(_|~h),b,_,d,O,E)}function F(b,_){var u=(65535&b)+(65535&_);return(b>>16)+(_>>16)+(u>>16)<<16|65535&u}t.exports=function(b){return y.hash(b,C,16)}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y;t.exports=y||function(C){for(var w,x=new Array(C),I=0;I<C;I++)!(3&I)&&(w=4294967296*Math.random()),x[I]=w>>>((3&I)<<3)&255;return x}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y=i("./helpers");function C(I,S){I[S>>5]|=128<<24-S%32,I[15+(S+64>>9<<4)]=S;for(var D,F,b,_=Array(80),u=1732584193,h=-271733879,d=-1732584194,O=271733878,E=-1009589776,B=0;B<I.length;B+=16){for(var M=u,j=h,k=d,q=O,te=E,H=0;H<80;H++){_[H]=H<16?I[B+H]:x(_[H-3]^_[H-8]^_[H-14]^_[H-16],1);var z=w(w(x(u,5),(z=h,F=d,b=O,(D=H)<20?z&F|~z&b:!(D<40)&&D<60?z&F|z&b|F&b:z^F^b)),w(w(E,_[H]),(D=H)<20?1518500249:D<40?1859775393:D<60?-1894007588:-899497514)),E=O,O=d,d=x(h,30),h=u,u=z}u=w(u,M),h=w(h,j),d=w(d,k),O=w(O,q),E=w(E,te)}return Array(u,h,d,O,E)}function w(I,S){var D=(65535&I)+(65535&S);return(I>>16)+(S>>16)+(D>>16)<<16|65535&D}function x(I,S){return I<<S|I>>>32-S}t.exports=function(I){return y.hash(I,C,20,!0)}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){function y(S,D){var F=(65535&S)+(65535&D);return(S>>16)+(D>>16)+(F>>16)<<16|65535&F}function C(S,D){var F,b=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),_=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),u=new Array(64);S[D>>5]|=128<<24-D%32,S[15+(D+64>>9<<4)]=D;for(var h,d,O=0;O<S.length;O+=16){for(var E=_[0],B=_[1],M=_[2],j=_[3],k=_[4],q=_[5],te=_[6],H=_[7],z=0;z<64;z++)u[z]=z<16?S[z+O]:y(y(y((d=u[z-2],x(d,17)^x(d,19)^I(d,10)),u[z-7]),(d=u[z-15],x(d,7)^x(d,18)^I(d,3))),u[z-16]),F=y(y(y(y(H,x(d=k,6)^x(d,11)^x(d,25)),k&q^~k&te),b[z]),u[z]),h=y(x(h=E,2)^x(h,13)^x(h,22),E&B^E&M^B&M),H=te,te=q,q=k,k=y(j,F),j=M,M=B,B=E,E=y(F,h);_[0]=y(E,_[0]),_[1]=y(B,_[1]),_[2]=y(M,_[2]),_[3]=y(j,_[3]),_[4]=y(k,_[4]),_[5]=y(q,_[5]),_[6]=y(te,_[6]),_[7]=y(H,_[7])}return _}var w=i("./helpers"),x=function(S,D){return S>>>D|S<<32-D},I=function(S,D){return S>>>D};t.exports=function(S){return w.hash(S,C,32,!0)}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){e.read=function(y,C,w,x,O){var S,D,F=8*O-x-1,b=(1<<F)-1,_=b>>1,u=-7,h=w?O-1:0,d=w?-1:1,O=y[C+h];for(h+=d,S=O&(1<<-u)-1,O>>=-u,u+=F;0<u;S=256*S+y[C+h],h+=d,u-=8);for(D=S&(1<<-u)-1,S>>=-u,u+=x;0<u;D=256*D+y[C+h],h+=d,u-=8);if(S===0)S=1-_;else{if(S===b)return D?NaN:1/0*(O?-1:1);D+=Math.pow(2,x),S-=_}return(O?-1:1)*D*Math.pow(2,S-x)},e.write=function(y,C,w,x,I,E){var D,F,b=8*E-I-1,_=(1<<b)-1,u=_>>1,h=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=x?0:E-1,O=x?1:-1,E=C<0||C===0&&1/C<0?1:0;for(C=Math.abs(C),isNaN(C)||C===1/0?(F=isNaN(C)?1:0,D=_):(D=Math.floor(Math.log(C)/Math.LN2),C*(x=Math.pow(2,-D))<1&&(D--,x*=2),2<=(C+=1<=D+u?h/x:h*Math.pow(2,1-u))*x&&(D++,x/=2),_<=D+u?(F=0,D=_):1<=D+u?(F=(C*x-1)*Math.pow(2,I),D+=u):(F=C*Math.pow(2,u-1)*Math.pow(2,I),D=0));8<=I;y[w+d]=255&F,d+=O,F/=256,I-=8);for(D=D<<I|F,b+=I;0<b;y[w+d]=255&D,d+=O,D/=256,b-=8);y[w+d-O]|=128*E}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(i,t,e){(function(n,r,o,s,a,p,l,m,v){var y,C,w;function x(){}(n=t.exports={}).nextTick=(C=typeof window<"u"&&window.setImmediate,w=typeof window<"u"&&window.postMessage&&window.addEventListener,C?function(I){return window.setImmediate(I)}:w?(y=[],window.addEventListener("message",function(I){var S=I.source;S!==window&&S!==null||I.data!=="process-tick"||(I.stopPropagation(),0<y.length&&y.shift()())},!0),function(I){y.push(I),window.postMessage("process-tick","*")}):function(I){setTimeout(I,0)}),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.on=x,n.addListener=x,n.once=x,n.off=x,n.removeListener=x,n.removeAllListeners=x,n.emit=x,n.binding=function(I){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(I){throw new Error("process.chdir is not supported")}}).call(this,i("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},i("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})});var ze={};Yi(ze,{__addDisposableResource:()=>So,__assign:()=>bn,__asyncDelegator:()=>po,__asyncGenerator:()=>fo,__asyncValues:()=>ho,__await:()=>nt,__awaiter:()=>oo,__classPrivateFieldGet:()=>bo,__classPrivateFieldIn:()=>vo,__classPrivateFieldSet:()=>wo,__createBinding:()=>vn,__decorate:()=>no,__disposeResources:()=>xo,__esDecorate:()=>ia,__exportStar:()=>ao,__extends:()=>eo,__generator:()=>so,__importDefault:()=>yo,__importStar:()=>go,__makeTemplateObject:()=>mo,__metadata:()=>ro,__param:()=>io,__propKey:()=>oa,__read:()=>Pi,__rest:()=>to,__runInitializers:()=>ra,__setFunctionName:()=>sa,__spread:()=>co,__spreadArray:()=>uo,__spreadArrays:()=>lo,__values:()=>wn,default:()=>la});function eo(i,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Ci(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function to(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(e[n[r]]=i[n[r]]);return e}function no(i,t,e,n){var r=arguments.length,o=r<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,t,e,n);else for(var a=i.length-1;a>=0;a--)(s=i[a])&&(o=(r<3?s(o):r>3?s(t,e,o):s(t,e))||o);return r>3&&o&&Object.defineProperty(t,e,o),o}function io(i,t){return function(e,n){t(e,n,i)}}function ia(i,t,e,n,r,o){function s(S){if(S!==void 0&&typeof S!="function")throw new TypeError("Function expected");return S}for(var a=n.kind,p=a==="getter"?"get":a==="setter"?"set":"value",l=!t&&i?n.static?i:i.prototype:null,m=t||(l?Object.getOwnPropertyDescriptor(l,n.name):{}),v,y=!1,C=e.length-1;C>=0;C--){var w={};for(var x in n)w[x]=x==="access"?{}:n[x];for(var x in n.access)w.access[x]=n.access[x];w.addInitializer=function(S){if(y)throw new TypeError("Cannot add initializers after decoration has completed");o.push(s(S||null))};var I=(0,e[C])(a==="accessor"?{get:m.get,set:m.set}:m[p],w);if(a==="accessor"){if(I===void 0)continue;if(I===null||typeof I!="object")throw new TypeError("Object expected");(v=s(I.get))&&(m.get=v),(v=s(I.set))&&(m.set=v),(v=s(I.init))&&r.unshift(v)}else(v=s(I))&&(a==="field"?r.unshift(v):m[p]=v)}l&&Object.defineProperty(l,n.name,m),y=!0}function ra(i,t,e){for(var n=arguments.length>2,r=0;r<t.length;r++)e=n?t[r].call(i,e):t[r].call(i);return n?e:void 0}function oa(i){return typeof i=="symbol"?i:"".concat(i)}function sa(i,t,e){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(i,"name",{configurable:!0,value:e?"".concat(e," ",t):t})}function ro(i,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,t)}function oo(i,t,e,n){function r(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function a(m){try{l(n.next(m))}catch(v){s(v)}}function p(m){try{l(n.throw(m))}catch(v){s(v)}}function l(m){m.done?o(m.value):r(m.value).then(a,p)}l((n=n.apply(i,t||[])).next())})}function so(i,t){var e={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,r,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(l){return function(m){return p([l,m])}}function p(l){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,l[0]&&(e=0)),e;)try{if(n=1,r&&(o=l[0]&2?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(o=e.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){e.label=l[1];break}if(l[0]===6&&e.label<o[1]){e.label=o[1],o=l;break}if(o&&e.label<o[2]){e.label=o[2],e.ops.push(l);break}o[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(i,e)}catch(m){l=[6,m],r=0}finally{n=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ao(i,t){for(var e in i)e!=="default"&&!Object.prototype.hasOwnProperty.call(t,e)&&vn(t,i,e)}function wn(i){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&i[t],n=0;if(e)return e.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&n>=i.length&&(i=void 0),{value:i&&i[n++],done:!i}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pi(i,t){var e=typeof Symbol=="function"&&i[Symbol.iterator];if(!e)return i;var n=e.call(i),r,o=[],s;try{for(;(t===void 0||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(a){s={error:a}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(s)throw s.error}}return o}function co(){for(var i=[],t=0;t<arguments.length;t++)i=i.concat(Pi(arguments[t]));return i}function lo(){for(var i=0,t=0,e=arguments.length;t<e;t++)i+=arguments[t].length;for(var n=Array(i),r=0,t=0;t<e;t++)for(var o=arguments[t],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}function uo(i,t,e){if(e||arguments.length===2)for(var n=0,r=t.length,o;n<r;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return i.concat(o||Array.prototype.slice.call(t))}function nt(i){return this instanceof nt?(this.v=i,this):new nt(i)}function fo(i,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(i,t||[]),r,o=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(y){n[y]&&(r[y]=function(C){return new Promise(function(w,x){o.push([y,C,w,x])>1||a(y,C)})})}function a(y,C){try{p(n[y](C))}catch(w){v(o[0][3],w)}}function p(y){y.value instanceof nt?Promise.resolve(y.value.v).then(l,m):v(o[0][2],y)}function l(y){a("next",y)}function m(y){a("throw",y)}function v(y,C){y(C),o.shift(),o.length&&a(o[0][0],o[0][1])}}function po(i){var t,e;return t={},n("next"),n("throw",function(r){throw r}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(r,o){t[r]=i[r]?function(s){return(e=!e)?{value:nt(i[r](s)),done:!1}:o?o(s):s}:o}}function ho(i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=i[Symbol.asyncIterator],e;return t?t.call(i):(i=typeof wn=="function"?wn(i):i[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(o){e[o]=i[o]&&function(s){return new Promise(function(a,p){s=i[o](s),r(a,p,s.done,s.value)})}}function r(o,s,a,p){Promise.resolve(p).then(function(l){o({value:l,done:a})},s)}}function mo(i,t){return Object.defineProperty?Object.defineProperty(i,"raw",{value:t}):i.raw=t,i}function go(i){if(i&&i.__esModule)return i;var t={};if(i!=null)for(var e in i)e!=="default"&&Object.prototype.hasOwnProperty.call(i,e)&&vn(t,i,e);return aa(t,i),t}function yo(i){return i&&i.__esModule?i:{default:i}}function bo(i,t,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!n:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(i):n?n.value:t.get(i)}function wo(i,t,e,n,r){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?r.call(i,e):r?r.value=e:t.set(i,e),e}function vo(i,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof i=="function"?t===i:i.has(t)}function So(i,t,e){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var n;if(e){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(n===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose]}if(typeof n!="function")throw new TypeError("Object not disposable.");i.stack.push({value:t,dispose:n,async:e})}else e&&i.stack.push({async:!0});return t}function xo(i){function t(n){i.error=i.hasError?new ca(n,i.error,"An error was suppressed during disposal."):n,i.hasError=!0}function e(){for(;i.stack.length;){var n=i.stack.pop();try{var r=n.dispose&&n.dispose.call(n.value);if(n.async)return Promise.resolve(r).then(e,function(o){return t(o),e()})}catch(o){t(o)}}if(i.hasError)throw i.error}return e()}var Ci,bn,vn,aa,ca,la,qe=$o(()=>{Ci=function(i,t){return Ci=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])},Ci(i,t)};bn=function(){return bn=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},bn.apply(this,arguments)};vn=Object.create?function(i,t,e,n){n===void 0&&(n=e);var r=Object.getOwnPropertyDescriptor(t,e);(!r||("get"in r?!t.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return t[e]}}),Object.defineProperty(i,n,r)}:function(i,t,e,n){n===void 0&&(n=e),i[n]=t[e]};aa=Object.create?function(i,t){Object.defineProperty(i,"default",{enumerable:!0,value:t})}:function(i,t){i.default=t};ca=typeof SuppressedError=="function"?SuppressedError:function(i,t,e){var n=new Error(e);return n.name="SuppressedError",n.error=i,n.suppressed=t,n};la={__extends:eo,__assign:bn,__rest:to,__decorate:no,__param:io,__metadata:ro,__awaiter:oo,__generator:so,__createBinding:vn,__exportStar:ao,__values:wn,__read:Pi,__spread:co,__spreadArrays:lo,__spreadArray:uo,__await:nt,__asyncGenerator:fo,__asyncDelegator:po,__asyncValues:ho,__makeTemplateObject:mo,__importStar:go,__importDefault:yo,__classPrivateFieldGet:bo,__classPrivateFieldSet:wo,__classPrivateFieldIn:vo,__addDisposableResource:So,__disposeResources:xo}});var Io=oe(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0})});var Fi=oe(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.invokeEventHandlersAsync=De.invokeEventHandlers=De.eventHandlerSafeInvokeAsync=De.eventHandlerSafeInvoke=void 0;var Do=(qe(),Je(ze));function _o(i,t,e){try{return i(t,e),{succeeded:!0}}catch(n){return{error:n,succeeded:!1}}}De.eventHandlerSafeInvoke=_o;function Ai(i,t,e){return(0,Do.__awaiter)(this,void 0,void 0,function*(){try{return yield i(t,e),{succeeded:!0}}catch(n){return{error:n,succeeded:!1}}})}De.eventHandlerSafeInvokeAsync=Ai;function da(i,t,e,n){for(let r of i){let{succeeded:o,error:s}=_o(r,t,e);if(!o&&n?.swallowExceptions!==!0)throw s}}De.invokeEventHandlers=da;function ua(i,t,e,n){return(0,Do.__awaiter)(this,void 0,void 0,function*(){if(n?.parallelize===!1)for(let r of i){let{succeeded:o,error:s}=yield Ai(r,t,e);if(!o&&n?.swallowExceptions!==!0)throw s}else{let r=[];for(let o of i)r.push(Ai(o,t,e).then(({succeeded:s,error:a})=>{if(!s&&n?.swallowExceptions!==!0)throw a}));yield Promise.all(r)}})}De.invokeEventHandlersAsync=ua});var Po=oe(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.TypedEvent=void 0;var fa=(qe(),Je(ze)),Eo=Fi(),Co={swallowExceptions:!1,parallelize:!0},Ri=class{constructor(){this._handlers=[]}attach(t){this._handlers.push(t)}detach(t){this.tryRemoveHandler(t)}invoke(t,e,n=Co){(0,Eo.invokeEventHandlers)(this._handlers,t,e,n)}invokeAsync(t,e,n=Co){return(0,fa.__awaiter)(this,void 0,void 0,function*(){yield(0,Eo.invokeEventHandlersAsync)(this._handlers,t,e,n)})}tryRemoveHandler(t){let e=this._handlers.findIndex(n=>n===t);e>=0&&this._handlers.splice(e,1)}};Sn.TypedEvent=Ri});var ki=oe(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});var pa=(qe(),Je(ze));(0,pa.__exportStar)(Po(),Ti)});var Ao=oe(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.FinalizationRegistryMissingError=void 0;var Mi=class extends Error{};xn.FinalizationRegistryMissingError=Mi});var ji=oe(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});On.WeakHandlerHolder=void 0;var ha=Ao(),Bi=class{constructor(t){this._refs=[];try{this._finalizationRegistry=new FinalizationRegistry(t)}catch(e){throw e.name==="FinalizationRegistry"?new ha.FinalizationRegistryMissingError("FinalizationRegistry is not defined. Weak Events cannot be used. Please consult 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry' for compatibility information"):e}}getWeakHandler(t,e){let n=new WeakRef(e);return this._finalizationRegistry.register(e,{eventSource:t,handlerRef:n},n),this._refs.push(n),n}releaseWeakHandler(t){let n=this._refs.find(r=>r?.deref()===t)||new WeakRef(t);return this._finalizationRegistry.unregister(n),n}unregisterRef(t){this._finalizationRegistry.unregister(t)}};On.WeakHandlerHolder=Bi});var Fo=oe(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.WeakEvent=void 0;var Li=(qe(),Je(ze)),ma=ki(),ga=ji(),Ni=Fi(),ya={swallowExceptions:!1,parallelize:!0},Ui=class{constructor(){this._handlers=[],this._handlerFinalizedEvent=new ma.TypedEvent,this.handlerFinalizedEvent=this._handlerFinalizedEvent,this._refHolder=new ga.WeakHandlerHolder(t=>{this.onHandlerFinalizer(t)})}invoke(t,e,n){for(let r of this._handlers){let o=r?.deref();if(o){let{succeeded:s,error:a}=(0,Ni.eventHandlerSafeInvoke)(o,t,e);if(!s&&n?.swallowExceptions!==!0)throw a}else this.releaseHandler(r)}}invokeAsync(t,e,n=ya){return(0,Li.__awaiter)(this,void 0,void 0,function*(){n?.parallelize===!1?yield this.sequentialInvokeAsync(t,e,n):yield this.parallelInvokeAsync(t,e,n)})}sequentialInvokeAsync(t,e,n){return(0,Li.__awaiter)(this,void 0,void 0,function*(){for(let r of this._handlers){let o=r?.deref();if(o){let{succeeded:s,error:a}=yield(0,Ni.eventHandlerSafeInvokeAsync)(o,t,e);if(!s&&n.swallowExceptions!==!0)throw a}else this.releaseHandler(r)}})}parallelInvokeAsync(t,e,n){return(0,Li.__awaiter)(this,void 0,void 0,function*(){let r=[];for(let o of this._handlers){let s=o?.deref();s?r.push((0,Ni.eventHandlerSafeInvokeAsync)(s,t,e).then(({succeeded:a,error:p})=>{if(!a&&n.swallowExceptions!==!0)throw p})):this.releaseHandler(o)}yield Promise.all(r)})}attach(t){this._handlers.push(this._refHolder.getWeakHandler(this,t))}detach(t){let e=this._refHolder.releaseWeakHandler(t);this.tryRemoveHandlerRef(e)}onHandlerFinalizer(t){this.tryRemoveHandlerRef(t?.handlerRef),this._handlerFinalizedEvent.invokeAsync(this,t,{swallowExceptions:!0})}tryRemoveHandlerRef(t){let e=this._handlers.findIndex(n=>n===t);e>=0&&this._handlers.splice(e,1)}releaseHandler(t){this._refHolder.unregisterRef(t),this.tryRemoveHandlerRef(t)}};In.WeakEvent=Ui});var To=oe(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});var Ro=(qe(),Je(ze));(0,Ro.__exportStar)(ji(),Dn);(0,Ro.__exportStar)(Fo(),Dn)});var ko=oe(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});var Vi=(qe(),Je(ze));(0,Vi.__exportStar)(Io(),It);(0,Vi.__exportStar)(ki(),It);(0,Vi.__exportStar)(To(),It)});var Hi={};Yi(Hi,{Client:()=>He,ClientDescriptor:()=>$n,Entity:()=>ue,EntityFile:()=>de,MigrationPathError:()=>Ze,ServerSync:()=>rt,Storage:()=>He,StorageDescriptor:()=>$n,collection:()=>yi,createDefaultMigration:()=>bi,createMigration:()=>wi,migrate:()=>Wt,schema:()=>gt});var hr=Qe(at(),1),Mt=4,lt=36;function dr(i){return i.toString(lt).padStart(Mt,"0")}function Go(i){return i.toString().padStart(6,"0")}var Ft=class{constructor(){this.latest={time:Date.now(),counter:0,node:Yo()};this.zeroCounter=0;this.now=t=>(this.latest=fr(this.latest),this.get(t,this.latest));this.OLD_now=t=>(this.latest=fr(this.latest),Go(t)+Zo(this.latest));this.timerState=()=>this.latest;this.update=t=>{let e=t.slice(Mt);this.latest=Xo(this.latest,mr(e))};this.get=(t,e)=>dr(t)+ur(e);this.zero=t=>dr(t)+ur({time:0,counter:this.zeroCounter++,node:this.latest.node});this.getWallClockTime=Zn}},Rt=class extends Error{constructor(...e){super();this.type="ClockDriftError",this.message=["maximum clock drift exceeded"].concat(e).join(" ")}},Tt=class extends Error{constructor(){super();this.type="OverflowError",this.message="timestamp counter overflow"}},Gn=4,Yn=7,kt=60*1e3,ct=9;function Yo(){return hr.default.slug().padStart(Yn,"0").slice(0,Yn)}function ur(i){let t=new Date(i.time).getTime().toString(lt).padStart(ct,"0"),e=i.counter.toString(lt).padStart(Gn,"0"),n=i.node.padStart(Yn,"0");return`${t}${e}${n}`}function fr(i){let t=Date.now(),e=Math.max(i.time,t),n=i.time===e?i.counter+1:0;if(e-t>kt)throw new Rt(e,t,kt);if(n>65535)throw new Tt;return{time:e,counter:n,node:i.node}}function Xo(i,t){let e=Date.now(),n=Math.max(e,Math.max(i.time,t.time)),r=Math.max(i.counter,t.counter),o;if(i.time===n&&t.time===n?o=r+1:i.time===n?o=i.counter+1:t.time===n?o=t.counter+1:o=0,n-e>kt)throw new Rt(n,e,kt);if(o>65535)throw new Tt;return{time:n,counter:o,node:i.node}}function mr(i){let t=i.slice(0,ct),e=i.slice(ct,ct+Gn),n=i.slice(ct+Gn),r=parseInt(t,lt),o=parseInt(e,lt);if(isNaN(r)||isNaN(o))throw new Error("invalid clock format");return{time:r,counter:o,node:n}}function Zo(i){let t=new Date(i.time).toISOString(),e=i.counter.toString(16).toUpperCase().padStart(4,"0"),n=i.node.padStart(16,"0");return`${t}-${e}-${n}`}function pr(i){return parseInt(i.slice(0,Mt),36)}function Xn(i,t){return pr(i)-pr(t)}function Zn(i){return mr(i.slice(Mt)).time}function be(i){return i&&i["@@type"]==="file"}function Bt(i){return{"@@type":"file",id:i}}var jt,es=new Uint8Array(16);function ei(){if(!jt&&(jt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!jt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return jt(es)}var gr=/^(?:[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 ts(i){return typeof i=="string"&&gr.test(i)}var yr=ts;var ee=[];for(Lt=0;Lt<256;++Lt)ee.push((Lt+256).toString(16).substr(1));var Lt;function ns(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(ee[i[t+0]]+ee[i[t+1]]+ee[i[t+2]]+ee[i[t+3]]+"-"+ee[i[t+4]]+ee[i[t+5]]+"-"+ee[i[t+6]]+ee[i[t+7]]+"-"+ee[i[t+8]]+ee[i[t+9]]+"-"+ee[i[t+10]]+ee[i[t+11]]+ee[i[t+12]]+ee[i[t+13]]+ee[i[t+14]]+ee[i[t+15]]).toLowerCase();if(!yr(e))throw TypeError("Stringified UUID is invalid");return e}var br=ns;function is(i,t,e){i=i||{};var n=i.random||(i.rng||ei)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var r=0;r<16;++r)t[e+r]=n[r];return t}return br(n)}var dt=is;function Q(i){return Se(i)||be(i)}function Ge(i,t){return i===t?!0:!(!Q(i)||!Q(t)||i["@@type"]!==t["@@type"]||i.id!==t.id)}var xr=Qe(Sr(),1);function rs(i,t){return typeof t!="object"||t===null||Array.isArray(t)?t:Object.fromEntries(Object.entries(t).sort(([e],[n])=>e<n?-1:e>n?1:0))}function ut(i){return JSON.stringify(i,rs)}function ae(i,t=!0){if(V(i)||Array.isArray(i)){let e=pe(i),n;if(Array.isArray(i))n=i.map(r=>ae(r,t));else{n={};for(let[r,o]of Object.entries(i))n[r]=ae(o,t)}return t&&e&&K(n,e),n}return i}function Fe(i){return(0,xr.default)(i)}function V(i){return i&&typeof i=="object"}function Or(i){for(var t=[],e=[i],n=0;e.length;){var r=e.pop();if(typeof r=="boolean")n+=4;else if(typeof r=="string")n+=r.length*2;else if(typeof r=="number")n+=8;else if(typeof r=="object"&&t.indexOf(r)===-1){t.push(r);for(var o in r)e.push(r[o])}}return n}function L(i,t="assertion failed"){if(!i)throw new Error(t)}function Nt(i=16){return dt().replace("-","").slice(0,i)}function Ir(i,t){for(let e=i.length-1;e>=0;e--)if(t(i[e]))return e;return-1}function Dr(i,t){let e;return function(...n){let r=this;clearTimeout(e),e=setTimeout(()=>i.apply(r,n),t)}}var Me="__@@oid_do_not_use",Oe="@@id",os="/",pt=":",ni=new WeakMap;function ne(i){let t=pe(i);return L(!!t,`Object ${JSON.stringify(i)} does not have an OID assigned to it`),t}function pe(i){if(V(i))return ni.get(i)??i[Oe]??i[Me]}function K(i,t){return L(V(i),`Only objects can be assigned OIDs, received ${JSON.stringify(i)}`),ii(i)&&Kt(i),ni.set(i,t),i}function ii(i){return!!pe(i)}function Kt(i){return ni.delete(i),i}function ri(i){return i===Oe||i===Me}function oi(i,t,e){if(ii(i))return ne(i);{let n=xe(t,e);return K(i,n),n}}function _r(i,t,e){if(ii(i)){let n=ne(i);if(Ee(n,t))return ne(i);{let r=xe(t,e);return K(i,r),r}}else{let n=xe(t,e);return K(i,n),n}}var ti={".":"˙","/":"&slash;",":":":"};function Er(i){return i.replace(/[/]/g,ti["/"]).replace(/[:]/g,ti[":"]).replace(/[.]/g,ti["."])}function Cr(i){return i.replace(/&slash;/g,"/").replace(/:/g,":").replace(/˙/g,".")}function Z(i,t,e){let n=Er(i)+os+Er(t);return e&&(n+=pt+e),n}function xe(i,t=ls){let{collection:e,id:n}=me(i);return Z(e,n,t())}function me(i){let[t,e]=i.split(pt),[n,r,...o]=t.split("/");o.length&&(r+="/"+o.join("/"));let s;return r.includes(".")?s=r.slice(0,r.indexOf(".")):s=r,{collection:Cr(n),id:Cr(s),subId:e}}function Ye(i,t){let e=ne(i);if(Array.isArray(i)){let n;for(let r=0;r<i.length;r++)n=i[r],V(n)&&!Q(n)&&(_r(n,e,t),Ye(n,t))}else if(V(i)&&!Q(i))for(let n of Object.keys(i))V(i[n])&&!Q(i[n])&&(_r(i[n],e,t),Ye(i[n],t))}function ss(i){if(V(i))return i[Oe]||i[Me]}function as(i){return V(i)&&(delete i[Me],delete i[Oe]),i}function cs(i){let t=ss(i);t&&K(i,t)}function ft(i){if(cs(i),as(i),Array.isArray(i))for(let t=0;t<i.length;t++)ft(i[t]);else if(V(i))for(let t of Object.keys(i))ft(i[t])}function Ut(i){if(Kt(i),Array.isArray(i))for(let t=0;t<i.length;t++)Ut(i[t]);else if(V(i))for(let t of Object.keys(i))Ut(i[t])}function ls(){return dt().slice(0,8)}function he(i){return{"@@type":"ref",id:i}}function Vt(i,t=new Map){if(Array.isArray(i)){let e=ne(i),n=K([],e);for(let r=0;r<i.length;r++){let o=i[r];if(V(o)){if(Se(o))throw new Error("An attempt was made to normalize an already normalized object! This is an error in verdant itself.");if(be(o)){n[r]=o;continue}else{let s=ne(o);n[r]=he(s),Vt(o,t)}}else n[r]=o}t.set(e,n)}else if(V(i)&&!Q(i)){let e=ne(i),n=K({},e);for(let r of Object.keys(i)){let o=i[r];if(V(o)){if(Se(o))throw new Error("An attempt was made to normalize an already normalized object! This is an error in verdant itself.");if(be(o))n[r]=o;else{let s=ne(o);n[r]=he(s),Vt(o,t)}}else n[r]=o}t.set(e,n)}else Q(i);return t}function $(i){return i.split(".")[0].split(pt)[0]}function si(i){let t=$(i),e=xe(t,()=>"\uFFFF");return[`${t}${pt}`,e]}function ai(i){let t=$(i);return[`${t}.`,`${t}.\uFFFF`]}function Ee(i,t){return $(i)===$(t)}function ds(i){let{collection:t,id:e,subId:n}=me(i);return Z(t,e,n)}var us=/"\w+\/[^"]+?(\.[^"]+)+\:[\S]+?"/g;function fs(i){return i.replaceAll(us,t=>{let e=t.slice(1,t.length-1);return`"${ds(e)}"`})}function ci(i){return JSON.parse(fs(JSON.stringify(i)))}function Pr(i){return!i.includes(pt)}function Se(i){return i&&typeof i=="object"&&i["@@type"]==="ref"}function li(i){return V(i)&&!Q(i)}function ps(i,t){return i===t?!0:Q(i)&&Q(t)?Ge(i,t):!1}function ht(i,t,e,n,r=[],o={}){let s=ne(i);function a(p,l,m){if(!li(l))ps(l,m)||r.push({oid:s,timestamp:e(),data:{op:"set",name:p,value:l}});else{let v=pe(m),y=pe(l);y&&!Ee(s,y)?(l=ae(l,!1),y=xe(s,n),K(l,y)):o.mergeUnknownObjects?!y&&v?(K(l,v),y=v):y=oi(l,s,n):y=oi(l,s,n),L(!!y,"Error: no value OID was resolved during diff. This is a bug in Verdant."),L(Ee(s,y),`Error: value OID ${y} is not related to parent OID ${s}. This is a bug in Verdant.`),m===void 0||y!==v?(Re(l,y,e,n,r),r.push({oid:s,timestamp:e(),data:{op:"set",name:p,value:he(y)}}),v!==void 0&&r.push({oid:v,timestamp:e(),data:{op:"delete"}})):ht(m,l,e,n,r,o)}}if(Array.isArray(i)&&Array.isArray(t)){for(let l=0;l<t.length;l++){let m=t[l],v=i[l];a(l,m,v)}let p=i.length-t.length;if(p>0){for(let l=t.length;l<i.length;l++){let m=i[l],v=pe(m);v&&r.push({oid:v,timestamp:e(),data:{op:"delete"}})}r.push({oid:s,timestamp:e(),data:{op:"list-delete",index:t.length,count:p}})}}else{if(Array.isArray(i)||Array.isArray(t))throw new Error("Cannot diff an array with an object");if(li(i)&&li(t)){let p=new Set(Object.keys(i));for(let[l,m]of Object.entries(t)){if(m===void 0&&o.defaultUndefined||(p.delete(l),ri(l)))continue;let v=i[l];a(l,m,v)}if(!o.defaultUndefined)for(let l of p)ri(l)||r.push({oid:s,timestamp:e(),data:{op:"remove",name:l}})}}return r}function Re(i,t,e,n,r=[]){K(i,t),Ye(i,n);let o=Vt(i);for(let s of o.keys()){let a=o.get(s);r.push({oid:s,timestamp:e(),data:{op:"initialize",value:Kt(a)}})}return r}function mt(i){let t={};for(let e of i)e.oid in t?t[e.oid].push(e):t[e.oid]=[e];return t}function Fr(i){let t={};for(let e of i){let n=$(e.oid);n in t?t[n].push(e):t[n]=[e]}return t}function Rr(i){let t={};for(let e of i){let n=$(e.oid);n in t?t[n].push(e):t[n]=[e]}return t}function Be(i){return Array.isArray(i)?!0:(console.error(`Cannot apply list patch; expected array, received ${JSON.stringify(i)}. This suggests your data is changing from a list to an object over time. (OID: ${pe(i)})`),!1)}function je(i,t,e){if(i==null&&t.op!=="initialize")return i;let n=i,r,o;function s(a){e&&Q(a)&&e.push(a)}switch(t.op){case"set":s(n[t.name]),n[t.name]=t.value;break;case"remove":s(n[t.name]),delete n[t.name];break;case"list-push":Be(i)&&i.push(t.value);break;case"list-delete":Be(i)&&(s(i[t.index]),i.splice(t.index,t.count));break;case"list-move-by-index":Be(i)&&(o=i.splice(t.from,1),i.splice(t.to,0,o[0]));break;case"list-remove":if(Be(i))do{let a=t.value;t.only==="last"?Se(a)?r=Ir(i,p=>p.id===a.id):r=i.lastIndexOf(a):Se(a)?r=i.findIndex(p=>p.id===a.id):r=i.indexOf(a),r!==-1&&(s(i[r]),i.splice(r,1))}while(!t.only&&r!==-1);break;case"list-add":Be(i)&&(i.some(p=>Se(p)&&Se(t.value)?p.id===t.value.id:p===t.value)||i.push(t.value));break;case"list-move-by-ref":Be(i)&&(r=i.findIndex(a=>Ge(a,t.value)),o=i.splice(r,1),i.splice(t.index,0,o[0]));break;case"list-insert":if(Be(i)){if(!t.value&&!t.values)throw new Error(`Cannot apply list insert patch; expected value or values, received ${JSON.stringify(t)}`);t.value?i.splice(t.index,0,t.value):i.splice(t.index,0,...t.values)}break;case"delete":Array.isArray(i)?i.forEach(s):V(i)&&Object.values(i||{}).forEach(s);return;case"initialize":return ae(t.value);case"touch":return i;default:throw new Error(`Unsupported patch operation: ${t.op}`)}return i}function $t(i,t,e=[]){if(Array.isArray(i))for(let n=0;n<i.length;n++){let r=i[n];i[n]=Ar(r,t,e),V(i[n])&&$t(i[n],t,e)}else if(!be(i)){if(V(i)){L(pe(i),`Object ${JSON.stringify(i)} must have an oid`);for(let n of Object.keys(i))i[n]=Ar(i[n],t,e),V(i[n])&&$t(i[n],t,e)}}return e}function Ar(i,t,e){if(Se(i)){e.push(i.id);let n=t.get(i.id);return L(!!n,`No value was found in object map for ${i.id}`),K(n,i.id)}else return i}var hs=i=>({type:"object",...i}),ms=i=>({type:"array",...i}),gs=i=>({type:"string",...i}),ys=i=>({type:"number",...i}),bs=i=>({type:"boolean",...i}),ws=i=>({type:"any",...i}),vs=i=>({type:"map",...i}),Ss=i=>({type:"file",...i}),Tr={object:hs,array:ms,string:gs,number:ys,boolean:bs,any:ws,map:vs,file:Ss};var Br=Qe(at(),1);function di(i){return i.equals!==void 0}function ui(i){return i.gte!==void 0||i.lte!==void 0||i.gt!==void 0||i.lt!==void 0}function xs(i){return!!i.match}function fi(i){return i.startsWith!==void 0}function kr(i){return!ui(i)&&!di(i)&&!xs(i)&&!fi(i)&&i.order}function we(i){return i.type==="any"?!0:i.type==="map"?!1:i.nullable}function Ce(i){return i?i.type==="map"||i.type==="array"?!0:i.type==="file"?!1:i.default!==void 0:!1}function hi(i){if(!(!i||!Ce(i)))return i.type==="file"?we(i)?null:void 0:i.type==="map"?{}:i.type==="array"?we(i)?null:[]:i.type==="object"?we(i)?null:void 0:typeof i.default=="function"?i.default():i.default}function Pe(i,t){for(let[e,n]of Object.entries(i.fields)){let r=mi(n);(r!==void 0&&t[e]===void 0||!we(n)&&t[e]===null)&&(t[e]=r),t[e]&&Le(t[e],n)}return t}function Le(i,t){if(i==null)return i;if(t.type==="object")for(let[e,n]of Object.entries(t.properties)){if(i[e]===void 0){let r=mi(n);r!==void 0&&(i[e]=r)}Le(i[e],n)}else if(t.type==="array")for(let e of i)Le(e,t.items);else if(t.type==="map")for(let[e,n]of Object.entries(i))e===Oe||e===Me||Le(n,t.values)}function mi(i){if(i.type==="string"||i.type==="number"||i.type==="boolean"||i.type==="any"){if(i.default&&typeof i.default=="function")return i.default();if(i.default!==void 0)return JSON.parse(JSON.stringify(i.default))}if(i.type==="array")return[];if(i.type==="map")return{};if(i.type!=="any"&&i.nullable)return null;if(i.type==="object"&&i.default){let t=typeof i.default=="function"?i.default():JSON.parse(JSON.stringify(i.default));for(let[e,n]of Object.entries(i.properties))t[e]===void 0&&(t[e]=mi(n));return t}}function gi(i,t){for(let[e,n]of Object.entries(t))e===Oe||e===Me||(i.fields[e]?pi(n,i.fields[e]):delete t[e]);return t}function pi(i,t){if(V(i)&&t.type==="object")for(let[e,n]of Object.entries(i))t.properties[e]?pi(n,t.properties[e]):delete i[e];else if(Array.isArray(i)&&t.type==="array")for(let e of i)pi(e,t.items)}function Mr(i,t){for(let[e,n]of Object.entries(t))if(e!==Oe){if(!i[e])return{type:"invalid-key",fieldPath:[e],message:`Invalid field "${e}"`};if(n){let r=Te({field:i[e],value:n,fieldPath:[e]});if(r)return r}}}function Te({field:i,value:t,fieldPath:e=[],depth:n,requireDefaults:r}){if(!(n!==void 0&&n<=0)&&!(we(i)&&t===null)){if(t===null&&(r||!Ce(i)))return{type:"no-default",fieldPath:e,message:`Invalid null value for field ${Ae(e)}`};if(i.type==="object"){if(!V(t))return{type:"invalid-type",fieldPath:e,message:`Expected object${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`};for(let[o,s]of Object.entries(i.properties))o!==Oe&&t[o]&&Te({field:s,value:t[o],fieldPath:[...e,o],depth:n!==void 0?n-1:void 0});for(let o of Object.keys(t))if(!i.properties[o])return{type:"invalid-key",fieldPath:[...e,o],message:`Invalid unexpected field "${o}" on value ${Ae(e)}`}}else if(i.type==="array"){if(!Array.isArray(t))return t===null&&i.nullable?void 0:{type:"invalid-value",fieldPath:e,message:`Expected array${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`};for(let o of t)Te({field:i.items,value:o,fieldPath:[...e,"[]"],depth:n!==void 0?n-1:void 0})}else if(i.type==="map"){if(!V(t))return{type:"invalid-type",fieldPath:e,message:`Expected map for field ${Ae(e)}, got ${t}`};for(let[o,s]of Object.entries(t))Te({field:i.values,value:s,fieldPath:[...e,o],depth:n!==void 0?n-1:void 0})}else if(i.type==="string"){if(typeof t!="string")return{type:"invalid-type",fieldPath:e,message:`Expected string ${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`};if(i.options&&!i.options.includes(t))return{type:"invalid-value",fieldPath:e,message:`Expected one of ${i.options.join(", ")} for field ${Ae(e)}, got ${t}`}}else if(i.type==="boolean"){if(typeof t!="boolean")return{type:"invalid-type",fieldPath:e,message:`Expected boolean ${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`}}else if(i.type==="number"){if(typeof t!="number")return{type:"invalid-type",fieldPath:e,message:`Expected number ${i.nullable?" or null":""} for field ${Ae(e)}, got ${t}`}}else i.type}}function Ae(i){return i.length===0?"root":i.join(".")}function Ne(i,t){return i.type==="object"?i.properties[t]:i.type==="array"?i.items:i.type==="map"?i.values:i.type==="any"?i:"type"in i?null:i[t]??null}function yi({synthetics:i,indexes:t,...e}){let n={...i,...t};for(let[r,o]of Object.entries(e.fields))"indexed"in o&&(n[r]={field:r});return{...e,indexes:n}}function gt(i){return i}gt.collection=yi;gt.fields=Tr;gt.generated={id:Br.default};var zt="\uFFFFFE",Os="\0",Is="\uFFFFFF";function ce(...i){let t=Ds(i);return t.length===1?t[0]:t}function Ue(...i){return i.join(zt)+`${Is}`}function Ve(...i){return i.join(zt)+`${zt}${Os}`}function Ds(i){let t=[[]];for(let e of i)if(Array.isArray(e)){let n=[];for(let r of t)for(let o of e)n.push(r.concat(o));t=n}else for(let n of t)n.push(`${e}`);return Array.from(new Set(t.map(e=>e.join(zt))))}function _s(i){return!!i.field}function Es(i,t){let e={};for(let[n,r]of Object.entries(i.indexes||{})){let o=r;_s(o)?e[n]=ve(t[o.field]):e[n]=ve(o.compute(t))}return e}function Cs(i,t){return Object.entries(i.compounds||{}).reduce((e,[n,r])=>(e[n]=ce(...r.of.map(o=>t[o])),e),{})}function Ps(i,t){return Object.entries(i.fields).reduce((e,[n,r])=>("indexed"in r&&(e[n]=ve(t[n])),e),{})}function qt(i,t){let e={[i.primaryKey]:t[i.primaryKey],...Ps(i,t),...Es(i,t)};return Object.assign(e,Cs(i,{...t,...e})),e["@@@snapshot"]=t,e}var As="null";function ve(i){if(i===null)return As;if(typeof i=="string"||typeof i=="number")return i;if(typeof i=="boolean"||i===null)return`${i}`;if(i===void 0)return"undefined";if(Array.isArray(i))return i.map(ve);throw new Error(`Unsupported index value: ${i}`)}var jr={version:0,collections:{}};function Wt(i,t,e){let n=typeof t=="function",r=n?jr:i,o=n?i:t,s=n?t:e,a=Object.keys(o.collections).filter(x=>r.collections[x]&&ut(r.collections[x])!==ut(o.collections[x])),p=Object.keys(r.collections).filter(x=>!o.collections[x]),l=Object.keys(o.collections).filter(x=>!r.collections[x]),m=new Set;for(let x of a){let I=r.collections[x].fields,S=o.collections[x].fields;Object.keys(S).some(D=>!I[D]?.default&&S[D]?.default)&&m.add(x),Object.keys(I).some(D=>!S[D])&&m.add(x)}let v={},y={};for(let x of[...a,...l]){let I=Ht(r.collections[x]),S=Ht(o.collections[x]),D=S.filter(b=>!I.find(_=>_.name===b.name)),F=I.filter(b=>!S.find(_=>_.name===b.name));D.length>0&&(v[x]=D,a.includes(x)&&m.add(x)),F.length>0&&(y[x]=F,a.includes(x)&&m.add(x))}let C=(x,I)=>Pe(o.collections[x],I),w=x=>I=>{let S=o.collections[x];return Pe(S,gi(S,I))};return{version:o.version,migrate:async x=>{let I=[];if(await s({migrate:async(S,D)=>{let F=w(S),b=async _=>{let u=await D(_);return K(u,ne(_)),F(u)};await x.migrate(S,b),I.push(S),m.delete(S)},identity:S=>S,withDefaults:C,info:{changedCollections:a,addedCollections:l,removedCollections:p},queries:x.queries,mutations:x.mutations}),o.version>1){x.log("debug","auto-migrating collections with new defaults",m);for(let D of m)await x.migrate(D,w(D)),I.push(D);let S=a.filter(D=>!I.includes(D));S.length>0&&console.error(`Unmigrated changed collections from version ${r.version} to version ${o.version}:`,S)}},removedCollections:p,addedIndexes:v,removedIndexes:y,allCollections:Object.keys(o.collections),changedCollections:a,addedCollections:l,oldCollections:Object.keys(r.collections),oldSchema:r,newSchema:o}}function Ht(i){return i?[...Object.keys(i.indexes||{}).map(t=>({name:t,multiEntry:["array","string[]","number[]","boolean[]"].includes(i.indexes[t].type),synthetic:!0,compound:!1})),...Object.keys(i.compounds||{}).map(t=>({name:t,multiEntry:i.compounds[t].of.some(e=>(i.fields[e]||i.indexes[e]).type==="array"),synthetic:!1,compound:!0}))]:[]}function bi(i,t){return Wt(t?i:{version:0,collections:{}},t||i,async({migrate:n,info:r})=>{if((t||i).version!==1)for(let o of r.changedCollections)await n(o,s=>s)})}function wi(i,t,e){let n=typeof t=="function"||t===void 0,r=n?jr:i,o=n?i:t,s=n?t:e;L(r,"Invalid arguments to createMigration"),L(o,"Invalid arguments to createMigration");let{changedCollections:a,addedCollections:p,removedCollections:l,addedIndexes:m,removedIndexes:v,autoMigratedCollections:y,autoMigration:C}=Fs(r,o);return{version:o.version,migrate:async w=>{let x=[];if(await s?.({migrate:async(S,D)=>{let F=C(S),b=async _=>{let u=await D(_);K(u,ne(_));let h=F(u),d=Mr(o.collections[S].fields,h);return h};await w.migrate(S,b),x.push(S),y.delete(S)},info:{changedCollections:a,addedCollections:p,removedCollections:l},queries:w.queries,mutations:w.mutations}),o.version>1){w.log("debug","auto-migrating collections with new defaults",y);for(let D of y)await w.migrate(D,C(D)),x.push(D);for(let D of l)await w.deleteCollection(D);let S=a.filter(D=>!x.includes(D));S.length>0&&console.error(`Unmigrated changed collections from version ${r.version} to version ${o.version}:`,S)}},removedCollections:l,addedIndexes:m,removedIndexes:v,allCollections:Object.keys(o.collections),changedCollections:a,addedCollections:p,oldCollections:Object.keys(r.collections),oldSchema:r,newSchema:o}}function Fs(i,t){let e=Object.keys(t.collections).filter(m=>i.collections[m]&&ut(i.collections[m])!==ut(t.collections[m])),n=Object.keys(i.collections).filter(m=>!t.collections[m]),r=Object.keys(t.collections).filter(m=>!i.collections[m]),o=new Set;for(let m of e){let v=i.collections[m].fields,y=t.collections[m].fields;Object.keys(y).some(C=>!Ce(v[C])&&Ce(y[C]))&&o.add(m),Object.keys(v).some(C=>!y[C])&&o.add(m)}let s={},a={};for(let m of[...e,...r]){let v=Ht(i.collections[m]),y=Ht(t.collections[m]),C=y.filter(x=>!v.find(I=>I.name===x.name)),w=v.filter(x=>!y.find(I=>I.name===x.name));C.length>0&&(s[m]=C,e.includes(m)&&o.add(m)),w.length>0&&(a[m]=w,e.includes(m)&&o.add(m))}return{changedCollections:e,addedCollections:r,removedCollections:n,addedIndexes:s,removedIndexes:a,autoMigratedCollections:o,withDefaults:(m,v)=>Pe(t.collections[m],v),autoMigration:m=>v=>{let y=t.collections[m];return Pe(y,gi(y,v))}}}var Qt=class{constructor(t,e){this.getNow=t;this.createSubId=e;this.isPrimitive=t=>!V(t)||Q(t);this.createDiff=(t,e,n={})=>ht(t,e,this.getNow,this.createSubId,[],n);this.createInitialize=(t,e)=>Re(t,e,this.getNow,this.createSubId);this.createSet=(t,e,n)=>{if(this.isPrimitive(n))return[{oid:t,timestamp:this.getNow(),data:{op:"set",name:e,value:n}}];{let r=xe(t,this.createSubId);return[...Re(n,r,this.getNow),{oid:t,timestamp:this.getNow(),data:{op:"set",value:he(r),name:e}}]}};this.createRemove=(t,e)=>[{oid:t,timestamp:this.getNow(),data:{op:"remove",name:e}}];this.createListPush=(t,e)=>{if(this.isPrimitive(e))return[{oid:t,timestamp:this.getNow(),data:{op:"list-push",value:e}}];{let n=xe(t,this.createSubId);return[...Re(e,n,this.getNow),{oid:t,timestamp:this.getNow(),data:{op:"list-push",value:he(n)}}]}};this.createListAdd=(t,e)=>this.isPrimitive(e)?[{oid:t,timestamp:this.getNow(),data:{op:"list-add",value:e}}]:[{oid:t,timestamp:this.getNow(),data:{op:"list-add",value:he(e)}}];this.createListInsert=(t,e,n)=>{if(this.isPrimitive(n))return[{oid:t,timestamp:this.getNow(),data:{op:"list-insert",value:n,index:e}}];{let r=xe(t,this.createSubId);return[...Re(n,r,this.getNow),{oid:t,timestamp:this.getNow(),data:{op:"list-insert",value:he(r),index:e}}]}};this.createListRemove=(t,e,n)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-remove",value:e,only:n}}];this.createListDelete=(t,e,n=1)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-delete",index:e,count:n}}];this.createListMoveByRef=(t,e,n)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-move-by-ref",value:e,index:n}}];this.createListMoveByIndex=(t,e,n)=>[{oid:t,timestamp:this.getNow(),data:{op:"list-move-by-index",from:e,to:n}}];this.createDelete=t=>[{oid:t,timestamp:this.getNow(),data:{op:"delete"}}];this.createDeleteAll=t=>t.map(e=>({oid:e,timestamp:this.getNow(),data:{op:"delete"}}))}};var U=class{constructor(t){this._onAllUnsubscribed=t;this.subscribers={};this.counts={};this._disabled=!1;this.disposed=!1;this.subscriberCount=t=>this.counts[t]??0;this.totalSubscriberCount=()=>Object.values(this.counts).reduce((t,e)=>t+e,0);this.subscribe=(t,e)=>{let n=Nt(),r=this.subscribers[t];return r||(r=this.subscribers[t]={}),r[n]=e,this.counts[t]=(this.counts[t]||0)+1,()=>{this.subscribers[t]&&(delete this.subscribers[t][n],this.counts[t]--,this.counts[t]===0&&(delete this.subscribers[t],delete this.counts[t],this._onAllUnsubscribed&&this._onAllUnsubscribed(t)))}};this.emit=(t,...e)=>{this._disabled||this.subscribers[t]&&Object.values(this.subscribers[t]).forEach(n=>n(...e))};this.dispose=()=>{this._disabled=!0,this.disposed=!0;let t=Object.keys(this.subscribers);this.subscribers={},this.counts={},t.forEach(e=>{this._onAllUnsubscribed&&this._onAllUnsubscribed(e)})};this.disable=()=>{this._disabled=!0}}get disabled(){return this._disabled}};function Lr(i,t,e,n){if(t==null)return[{oid:i,timestamp:n(),data:{op:"delete"}}];let r=ae(t),o=[];for(let s of e){let a=Rs(i,r,s,n);o.unshift(...a),je(r,s.data)}return o}function Rs(i,t,e,n){let r=e.data;switch(r.op){case"set":case"remove":return[{oid:i,timestamp:n(),data:{op:"set",name:r.name,value:t[r.name]}}];case"list-insert":return[{oid:i,timestamp:n(),data:{op:"list-delete",index:r.index,count:1}}];case"list-delete":return[{oid:i,timestamp:n(),data:{op:"list-insert",index:r.index,values:t.slice(r.index,r.count)}}];case"list-move-by-ref":return[{oid:i,timestamp:n(),data:{op:"list-move-by-ref",value:r.value,index:t.indexOf(r.value)}}];case"list-move-by-index":return[{oid:i,timestamp:n(),data:{op:"list-move-by-index",from:r.to,to:r.from}}];case"delete":return[{oid:i,timestamp:n(),data:{op:"initialize",value:t}}];case"list-push":return[{oid:i,timestamp:n(),data:{op:"list-remove",value:r.value,only:"last"}}];case"list-remove":if(r.only==="last"){let o=t.lastIndexOf(r.value);return[{oid:i,timestamp:n(),data:{op:"list-insert",index:o,values:[r.value]}}]}else if(r.only==="first"){let o=t.indexOf(r.value);return[{oid:i,timestamp:n(),data:{op:"list-insert",index:o,values:[r.value]}}]}else{let o=[],s=t.indexOf(r.value);for(;s!==-1;)o.push(s),s=t.indexOf(r.value,s+1);return o.map(a=>({oid:i,timestamp:n(),data:{op:"list-insert",index:a,value:r.value}}))}case"list-add":return[{oid:i,timestamp:n(),data:{op:"list-remove",value:r.value,only:"last"}}];case"initialize":return[{oid:i,timestamp:n(),data:{op:"delete"}}];case"touch":return[];default:throw new Error(`Cannot undo operation type: ${r.op}`)}}var Xe=class{constructor(t){this.flusher=t;this.batches=new Map;this.flush=t=>{let e=this.batches.get(t);if(e)return e.flush()};this.discard=t=>{let e=this.batches.get(t);e&&(e.discard(),this.batches.delete(t))};this.flushAll=()=>[...this.batches.values()].map(t=>t.flush());this.getSize=t=>{let e=this.batches.get(t);return e?e.items.length:0}}add({key:t,userData:e,items:n,max:r,timeout:o}){let s=this.batches.get(t);return s||(s=new vi({max:r||null,startedAt:Date.now(),userData:e,timeout:o||null,flusher:this.flusher,key:t}),this.batches.set(t,s)),s.update({items:n,max:r,timeout:o,userData:e}),s}},vi=class{constructor({max:t,startedAt:e,timeout:n,userData:r,flusher:o,key:s}){this.items=[];this.update=({items:t,max:e,timeout:n,userData:r})=>{this.items.push(...t),e!==void 0&&(this.max=e),n!==void 0&&(this.timeout=n),r&&(this.userData=r);let o=this.items.length!==0&&this.timeout!==null&&!this.flushTimeout;this.max!==null&&this.items.length>=this.max?this.flush():o&&this.timeout!==null&&(this.flushTimeout=setTimeout(this.flush,this.timeout))};this.flush=()=>{this.flushTimeout&&clearTimeout(this.flushTimeout),this.flushTimeout=void 0;let t=this.items;return this.items=[],this.flusher(t,this.key,this.userData)};this.discard=()=>{this.flushTimeout&&clearTimeout(this.flushTimeout),this.flushTimeout=void 0,this.items=[]};this.max=t,this.startedAt=e,this.timeout=n,this.userData=r,this.flusher=o,this.key=s}};function Nr(i,t){let e,n;return(...r)=>{let o=t();return e&&e.length===o.length&&e.every((s,a)=>s===o[a])||(e=[...o],n=i(...r)),n}}var Si=(l=>(l[l.InvalidRequest=4e3]="InvalidRequest",l[l.BodyRequired=4001]="BodyRequired",l[l.NoToken=4010]="NoToken",l[l.InvalidToken=4011]="InvalidToken",l[l.TokenExpired=4012]="TokenExpired",l[l.NotFound=4040]="NotFound",l[l.Unexpected=5e3]="Unexpected",l[l.ConfigurationError=5010]="ConfigurationError",l[l.NoFileStorage=5011]="NoFileStorage",l))(Si||{}),Ur=class extends Error{constructor(e,n,r){super(r??`Verdant error: ${e}`,{cause:n});this.code=e;this.toResponse=()=>JSON.stringify({code:this.code})}static{this.Code=Si}get httpStatus(){let e=Math.floor(this.code/10);return e<600?e:500}};function Vr(i){return typeof i=="object"&&"code"in i&&typeof i.code=="number"}function le(i){return i instanceof Error&&i.name==="AbortError"}function J(i){return new Promise((t,e)=>{i.onsuccess=()=>{t(i.result)},i.onerror=()=>{i.error&&le(i.error)?t(i.result):e(i.error)}})}function yt(i,t){return new Promise((e,n)=>{let r=i.transaction([t],"readonly"),s=r.objectStore(t).openCursor(),a=0,p=0;s.onsuccess=function(l){let m=s.result;m&&(a++,p=p+Or(m.value),m.continue())},s.onerror=function(l){s.error&&le(s.error)?e({count:a,size:p}):n(s.error)},r.oncomplete=function(l){e({count:a,size:p})},r.onabort=function(l){n(l)},r.onerror=function(l){n(l)}})}function Jt(i,t){let e=i.transaction(t,"readonly"),n=t.map(r=>{let o=e.objectStore(r);return J(o.getAll())});return Promise.all(n)}async function Ke(i){i.close(),await new Promise((t,e)=>{t()})}async function Gt(i,t=window.indexedDB){let e=t.deleteDatabase([i,"meta"].join("_")),n=t.deleteDatabase([i,"collections"].join("_"));await Promise.all([new Promise((r,o)=>{e.onsuccess=r,e.onerror=o}),new Promise((r,o)=>{n.onsuccess=r,n.onerror=o})]),window.location.reload()}function Kr(i,t=window.indexedDB){return J(t.deleteDatabase(i))}async function $r(i=window.indexedDB){return i.databases()}function Yt(i,t,e,n,r){let o=i.transaction(t,e);if(n){let s=()=>{r?.("debug","aborting transaction");try{o.abort()}catch(a){r?.("debug","aborting transaction failed",a)}};n.addEventListener("abort",s),o.addEventListener("error",()=>{n.removeEventListener("abort",s)}),o.addEventListener("complete",()=>{n.removeEventListener("abort",s)})}return o}var Ie=class{constructor(){this._disposes=[];this.disposed=!1;this.dispose=()=>{this.disposed=!0,this._disposes.forEach(t=>t()),this._disposes=[]};this.addDispose=t=>{this._disposes.push(t)}}};var se=class extends Ie{constructor(e,{log:n}={}){super();this.db=e;this.globalAbortController=new AbortController;this.createTransaction=(e,n)=>{let r=Yt(this.db,e,n?.mode||"readonly",n?.abort,this.log);return this.globalAbortController.signal.addEventListener("abort",r.abort),r.addEventListener("complete",()=>{this.globalAbortController.signal.removeEventListener("abort",r.abort)}),r.addEventListener("error",()=>{this.globalAbortController.signal.removeEventListener("abort",r.abort)}),r};this.run=async(e,n,r)=>{if(this.disposed||r?.transaction?.error)return Promise.resolve(void 0);let s=(r?.transaction||this.createTransaction([e],r)).objectStore(e),a=n(s);return J(a)};this.runAll=async(e,n,r)=>{if(this.disposed||r?.transaction?.error)return Promise.resolve([]);let s=(r?.transaction||this.createTransaction([e],r)).objectStore(e),a=n(s);return Promise.all(a.map(J))};this.iterate=async(e,n,r,o)=>{let a=(o?.transaction||this.createTransaction([e],o)).objectStore(e),p=n(a);return Array.isArray(p)?Promise.all(p.map(l=>new Promise((m,v)=>{l.onsuccess=()=>{let y=l.result;y?(r(y.value,a),y.continue()):m()},l.onerror=()=>{l.error&&le(l.error)?m():v(l.error)}}))).then(()=>{}):new Promise((l,m)=>{p.onsuccess=()=>{let v=p.result;v?(r(v.value,a),v.continue()):l()},p.onerror=()=>{p.error&&le(p.error)?l():m(p.error)}})};this.clear=e=>this.run(e,n=>n.clear(),{mode:"readwrite"});this.log=n,this.addDispose(()=>{this.globalAbortController.abort()})}};var Xt=class extends se{constructor(){super(...arguments);this.getAckInfo=async()=>{let e=await this.run("info",n=>n.get("ack"));return e||{globalAckTimestamp:null,type:"ack"}};this.setGlobalAck=async e=>{await this.run("info",n=>n.put({type:"ack",globalAckTimestamp:e}),{mode:"readwrite"})}}};var Zt=class extends se{constructor(e,n){super(e,n);this.getAllForDocument=async(e,{mode:n="readonly",transaction:r}={})=>{let o=[];return await this.iterateOverAllForDocument(e,s=>{o.push(s)},{mode:n,transaction:r}),o};this.iterateOverAllForDocument=async(e,n,{mode:r="readonly",transaction:o}={})=>this.iterate("baselines",s=>{let a=$(e),[p,l]=si(e),[m,v]=ai(e);return[s.openCursor(IDBKeyRange.only(a)),s.openCursor(IDBKeyRange.bound(p,l,!1,!1)),s.openCursor(IDBKeyRange.bound(m,v,!1,!1))]},n,{mode:r,transaction:o});this.iterateOverAllForCollection=async(e,n,{mode:r="readonly",transaction:o}={})=>this.iterate("baselines",s=>[s.openCursor(IDBKeyRange.bound(e,e+"\uFFFF",!1,!1))],n,{mode:r,transaction:o});this.getAllForMultipleDocuments=async(e,{mode:n="readonly"}={})=>(await this.runAll("baselines",o=>e.flatMap(s=>{let a=$(s),[p,l]=si(s),[m,v]=ai(s);return[o.get(a),o.getAll(IDBKeyRange.bound(p,l,!1,!1)),o.getAll(IDBKeyRange.bound(m,v,!1,!1))]}),{mode:n})).flat();this.getAllSince=async(e,{mode:n="readonly"}={})=>this.run("baselines",r=>{let o=e?IDBKeyRange.lowerBound(e,!0):void 0;return r.index("timestamp").getAll(o)},{mode:n});this.get=async(e,{transaction:n,mode:r="readonly"}={})=>this.run("baselines",o=>o.get(e),{mode:r,transaction:n});this.set=async(e,{transaction:n}={})=>{await this.run("baselines",r=>r.put(e),{mode:"readwrite",transaction:n})};this.setAll=async(e,{transaction:n}={})=>{await this.runAll("baselines",r=>e.map(o=>r.put(o)),{mode:"readwrite",transaction:n})};this.reset=()=>this.clear("baselines");this.delete=async(e,{transaction:n})=>{await this.run("baselines",r=>r.delete(e),{mode:"readwrite",transaction:n})}}};var zr=Qe(at(),1);var en=class extends se{constructor(){super(...arguments);this.get=async({transaction:e}={})=>{if(this.cached)return this.cached;let n=await this.run("info",r=>r.get("localReplicaInfo"),{transaction:e});return n?(this.cached=n,n):(this._creating||(this._creating=(async()=>{let o={type:"localReplicaInfo",id:(0,zr.default)(),ackedLogicalTime:null,lastSyncedLogicalTime:null};await this.run("info",s=>s.put(o),{mode:"readwrite"}),this.cached=o})()),await this._creating,this.get({transaction:e}))};this.update=async(e,{transaction:n}={})=>{let r=await this.get({transaction:n});Object.assign(r,e),await this.run("info",o=>o.put(r),{mode:"readwrite"}),this.cached=r};this.reset=async()=>{let e=await this.get();e.ackedLogicalTime=null,e.lastSyncedLogicalTime=null,await this.run("info",n=>n.put(e),{mode:"readwrite"})}}};var tn=class{constructor(t){this.meta=t;this.createOperation=async t=>{let e=await this.meta.localReplica.get();return{type:"op",timestamp:this.meta.now,replicaId:e.id,operations:t.operations.map(n=>({data:n.data,oid:n.oid,timestamp:n.timestamp}))}};this.createMigrationOperation=async({targetVersion:t,...e})=>{let n=await this.meta.localReplica.get();return{type:"op",operations:e.operations.map(r=>({...r,timestamp:this.meta.time.zero(t)})),timestamp:this.meta.time.zero(t),replicaId:n.id}};this.createSyncStep1=async t=>{let e=await this.meta.localReplica.get(),n=t===null?null:e.lastSyncedLogicalTime,r=[],o=new Set;n?await this.meta.operations.iterateOverAllLocalOperations(a=>{r.push({data:a.data,oid:a.oid,timestamp:a.timestamp}),o.add($(a.oid))},{after:n,mode:"readwrite"}):await this.meta.operations.iterateOverAllOperations(a=>{r.push({data:a.data,oid:a.oid,timestamp:a.timestamp}),o.add($(a.oid))},{mode:"readwrite"});let s=[];return n||(s=await this.meta.baselines.getAllSince("")),{type:"sync",schemaVersion:this.meta.schema.currentVersion,timestamp:this.meta.now,replicaId:e.id,resyncAll:!e.lastSyncedLogicalTime,operations:r,baselines:s,since:n}};this.createPresenceUpdate=async t=>{let e=await this.meta.localReplica.get();return{type:"presence-update",presence:t,replicaId:e.id}};this.createHeartbeat=async()=>{let t=await this.meta.localReplica.get();return{type:"heartbeat",timestamp:this.meta.now,replicaId:t.id}};this.createAck=async t=>{let e=await this.meta.localReplica.get();return{type:"ack",timestamp:this.meta.now,replicaId:e.id,nonce:t}}}};var nn=class extends se{constructor(e,n){super(e,n);this.iterateOverAllOperationsForDocument=async(e,n,{to:r,from:o,after:s,mode:a="readonly",transaction:p}={})=>{let m=(p||this.createTransaction(["operations"],{mode:a})).objectStore("operations"),v=m.index("d_t"),y=o||s,C=y?ce(e,y):Ve(e),w=r?ce(e,r):Ue(e),x=IDBKeyRange.bound(C,w,!!s,!1),I=v.openCursor(x,"next");return new Promise((S,D)=>{let F;I.onsuccess=b=>{let _=I.result;if(_){let u=_.value;L(u.oid.startsWith(e)),L(F===void 0||F<=u.timestamp,`expected ${F} <= ${u.timestamp}`),n(u,m),F=u.timestamp,_.continue()}else S()},I.onerror=b=>{if(le(I.error)){S();return}else D(I.error)}})};this.iterateOverAllOperationsForEntity=async(e,n,{after:r,to:o,mode:s,transaction:a})=>{let l=(a||this.createTransaction(["operations"],{mode:s})).objectStore("operations"),m=r?ce(e,r):Ve(e),v=o?ce(e,o):Ue(e),y=IDBKeyRange.bound(m,v,!!r,!1),C=l.openCursor(y,"next");return new Promise((w,x)=>{let I;C.onsuccess=S=>{let D=C.result;if(D){let F=D.value;L(F.oid.startsWith(e)),L(I===void 0||I<=F.timestamp,`expected ${I} <= ${F.timestamp}`),n(F,l),I=F.timestamp,D.continue()}else w()},C.onerror=S=>{le(C.error)?w():x(C.error)}})};this.iterateOverAllOperationsForCollection=async(e,n,{after:r,to:o,mode:s,transaction:a})=>{let p=a||this.createTransaction(["operations"],{mode:s});return this.iterate("operations",l=>l.openCursor(IDBKeyRange.bound(e,e+"\uFFFF",!1,!1),"next"),n,{mode:s,transaction:p})};this.iterateOverAllLocalOperations=async(e,{before:n,after:r,mode:o="readonly",transaction:s})=>{let p=(s||this.createTransaction(["operations"],{mode:o})).objectStore("operations"),l=p.index("l_t"),m=r?ce(!0,r):Ve(!0),v=n?ce(!0,n):Ue(!0),y=IDBKeyRange.bound(m,v,!!r,!0),C=l.openCursor(y,"next");return new Promise((w,x)=>{let I;C.onsuccess=S=>{let D=C.result;if(D){let F=D.value;L(I===void 0||I<=F.timestamp,`expected ${I} <= ${F.timestamp}`),e(F,p),I=F.timestamp,D.continue()}else w()},C.onerror=S=>{le(C.error)?w():x(C.error)}})};this.iterateOverAllOperations=async(e,{before:n,transaction:r,mode:o,from:s})=>{await this.iterate("operations",a=>{let p=s?Ve(s):void 0,l=n?Ue(n):void 0,m=p&&l?window.IDBKeyRange.bound(p,l,!1,!0):p?window.IDBKeyRange.lowerBound(p,!1):l?window.IDBKeyRange.upperBound(l,!0):void 0;return a.index("timestamp").openCursor(m,"next")},e,{mode:o,transaction:r})};this.addOperations=async(e,{transaction:n}={})=>this.insert(e.map(this.addCompoundIndexes),{transaction:n});this.addCompoundIndexes=e=>({...e,oid_timestamp:ce(e.oid,e.timestamp),l_t:ce(e.isLocal,e.timestamp),d_t:ce($(e.oid),e.timestamp)});this.insert=async(e,{transaction:n})=>{let r=new Set;return await this.runAll("operations",o=>e.map(s=>(r.add($(s.oid)),o.put(s))),{mode:"readwrite",transaction:n}),Array.from(r)};this.reset=()=>this.clear("operations")}};var rn=class{constructor(t,e){this.db=t;this.currentVersion=e;this.cached=null;this.get=async()=>{if(this.cached)return this.cached;let r=this.db.transaction("info","readonly").objectStore("info").get("schema"),o=await J(r);return o?(this.cached=JSON.parse(o.schema),this.cached):null};this.set=async t=>{let o=this.db.transaction("info","readwrite").objectStore("info").put({type:"schema",schema:JSON.stringify(t)});this.cached=t,await J(o)}}};var bt=class extends U{constructor({disableRebasing:e,context:n}){super();this.time=new Ft;this.disableRebasing=!1;this._closing=!1;this.setContext=e=>{this.context=e};this.close=()=>{this._closing=!0};this.createTransaction=(e,n={})=>Yt(this.db,e,n.write?"readwrite":"readonly",n.abort,this.context.log);this.getAllDocumentRelatedOids=async e=>{let n=new Set,r=$(e);L(r===e,"Must be root document OID"),n.add(r);let o=this.createTransaction(["baselines","operations"]);return await Promise.all([this.baselines.iterateOverAllForDocument(r,s=>{n.add(s.oid)},{transaction:o}),this.operations.iterateOverAllOperationsForDocument(r,s=>{n.add(s.oid)},{transaction:o})]),Array.from(n)};this.getAllCollectionRelatedOids=async e=>{let n=new Set,r=this.db.transaction(["baselines","operations"],"readwrite");return await Promise.all([this.baselines.iterateOverAllForCollection(e,o=>{n.add(o.oid)},{transaction:r}),this.operations.iterateOverAllOperationsForCollection(e,o=>{n.add(o.oid)},{transaction:r})]),Array.from(n)};this.getDocumentSnapshot=async(e,n={})=>{let r=$(e);L(r===e,"Must be root document OID");let o=this.db.transaction(["baselines","operations"],"readwrite"),s=await this.baselines.getAllForDocument(r,{transaction:o}),a=new Map;for(let l of s)l.snapshot&&K(l.snapshot,l.oid),a.set(l.oid,l.snapshot);await this.operations.iterateOverAllOperationsForDocument(r,l=>{let m=a.get(l.oid)||void 0,v=je(m,l.data);v&&K(v,l.oid),a.set(l.oid,v)},{transaction:o,to:n.to||this.now});let p=a.get(r);return p&&$t(p,a),p};this.getDocumentData=async(e,n)=>{let r=this.createTransaction(["baselines","operations"],n),o=[],s={};return await Promise.all([this.baselines.iterateOverAllForDocument(e,a=>{o.push(a)},{transaction:r}),this.operations.iterateOverAllOperationsForDocument(e,a=>{s[a.oid]??=[],s[a.oid].push(a)},{transaction:r})]),{baselines:o,operations:s}};this.ack=async e=>{let n=await this.localReplica.get();e>this.now||(this.emit("message",{type:"ack",replicaId:n.id,timestamp:e}),!this._closing&&(!n.ackedLogicalTime||e>n.ackedLogicalTime)&&this.localReplica.update({ackedLogicalTime:e}))};this.insertLocalOperations=async(e,n)=>{if(e.length===0)return;this.log("debug",`Inserting ${e.length} local operations`,e);for(let o of e)o.isLocal=!0;await this.operations.addOperations(e,n);let r=await this.messageCreator.createOperation({operations:e});this.emit("message",r),this.tryAutonomousRebase()};this.insertRemoteOperations=async(e,n)=>{if(e.length===0)return[];this.log("debug",`Inserting ${e.length} remote operations`,e);let r=await this.operations.addOperations(e.map(o=>({...o,isLocal:!1})),n);return this.ack(e[e.length-1].timestamp),r};this.insertRemoteBaselines=async(e,n)=>{if(e.length===0)return[];this.log(`Inserting ${e.length} remote baselines`),await this.baselines.setAll(e,n);let r=new Set;return e.forEach(o=>{r.add($(o.oid))}),Array.from(r)};this.insertData=async(e,n)=>{let r=this.createTransaction(["baselines","operations"],{...n,write:!0});e.baselines&&await this.insertRemoteBaselines(e.baselines,{transaction:r}),!n?.abort?.aborted&&e.operations&&(e.isLocal?await this.insertLocalOperations(e.operations,{transaction:r}):await this.insertRemoteOperations(e.operations,{transaction:r}))};this.updateLastSynced=async e=>{if(!this._closing)return this.localReplica.update({lastSyncedLogicalTime:e})};this.lastSyncedTimestamp=async()=>(await this.localReplica.get()).lastSyncedLogicalTime;this.tryAutonomousRebase=async()=>{this.disableRebasing||(await this.localReplica.get()).lastSyncedLogicalTime||await this.runRebase(this.now)};this.runRebase=async e=>{if(this._closing)return;let n,r=new Set,o=this.createTransaction(["baselines","operations"],{write:!0}),s=0;if(await this.operations.iterateOverAllOperations(p=>{r.add(p.oid),n=p.timestamp,s++},{before:e,transaction:o}),!r.size||this._closing)return;let a=[];for(let p of r)a.push(await this.rebase(p,n||e,o));this.emit("rebase",a)};this.rebase=async(e,n,r)=>{let o=(await this.localReplica.get()).id;this.log("[",o,"]","Rebasing",e,"up to",n);let s=r||this.createTransaction(["operations","baselines"],{write:!0}),a=await this.baselines.get(e,{transaction:s}),p=a?.snapshot||void 0,l=0,m=[];await this.operations.iterateOverAllOperationsForEntity(e,(y,C)=>{(!a||y.timestamp>a.timestamp)&&(p=je(p,y.data,m)),l++,C.delete(y.oid_timestamp)},{to:n,transaction:s}),p&&K(p,e);let v={oid:e,snapshot:p,timestamp:n};if(v.snapshot?await this.baselines.set(v,{transaction:s}):await this.baselines.delete(e,{transaction:s}),this.log("debug","successfully rebased",e,"up to",n,":",p,"and deleted",l,"operations"),m.length){let y=m.filter(be);y.length&&this.emit("filesDeleted",y)}return v};this.reset=async()=>{await this.operations.reset(),await this.baselines.reset(),await this.localReplica.reset()};this.updateSchema=async(e,n)=>{let r=await this.schema.get();if(r&&n===r.version&&r.version===e.version&&JSON.stringify(r)!==JSON.stringify(e))throw console.error(`Schema mismatch for version ${e.version}
|
|
7
7
|
${JSON.stringify(r)}
|
|
8
8
|
${JSON.stringify(e)}`),new Error("Schema has changed without a version change! Any changes to your schema must be accompanied by a change in schema version and a migration routine.");await this.schema.set(e)};this.setGlobalAck=async e=>{this._closing||(await this.ackInfo.setGlobalAck(e),this.disableRebasing||await this.runRebase(e))};this.export=async()=>{let e=this.db,[n,r]=await Jt(e,["baselines","operations"]),o=await this.localReplica.get(),s=await this.schema.get();if(!s)throw new Error("Cannot export Client data before initializing");return{operations:r,baselines:n,localReplica:o,schema:s}};this.resetFrom=async e=>{let r=this.db.transaction(["baselines","operations","info"],"readwrite");await J(r.objectStore("baselines").clear()),await J(r.objectStore("operations").clear()),await J(r.objectStore("info").clear()),await this.localReplica.update({ackedLogicalTime:e.localReplica.ackedLogicalTime,lastSyncedLogicalTime:e.localReplica.lastSyncedLogicalTime},{transaction:r})};this.stats=async()=>{let e=this.db,n=await yt(e,"operations"),r=await yt(e,"baselines");return{operationsSize:n,baselinesSize:r}};this.context=n,this.schema=new rn(n.metaDb,n.schema.version),this.operations=new nn(this.db,{log:n.log}),this.baselines=new Zt(this.db,{log:n.log}),this.localReplica=new en(this.db),this.ackInfo=new Xt(this.db),this.messageCreator=new tn(this),this.patchCreator=new Qt(()=>this.now),e&&(this.disableRebasing=e)}get db(){return this.context.metaDb}get log(){return this.context.log}get now(){return this.time.now(this.schema.currentVersion)}};var Ts=[ks,Ms,Bs,js,Ls];function on({indexedDB:i=window.indexedDB,namespace:t,log:e,metadataVersion:n=5}){return new Promise((r,o)=>{let s=i.open(`${t}_meta`,n),a=!1;s.onupgradeneeded=async p=>{let l=s.result,m=s.transaction,v=Ts.slice(p.oldVersion);for(let y of v)await y(l,m);await new Promise((y,C)=>{m.addEventListener("complete",y),m.addEventListener("error",C)}),p.oldVersion||(a=!0)},s.onerror=()=>{console.error("Error opening database",s.error),o(s.error)},s.onsuccess=()=>{r({db:s.result,wasInitialized:a})}})}async function qr({wipNamespace:i,namespace:t,indexedDB:e,log:n,metadataVersion:r}){let o=await on({namespace:i,indexedDB:e,log:n,metadataVersion:r});if(!o.wasInitialized)return o;n?.("debug","Beginning copy of production metadata database to WIP");let{db:s}=await on({namespace:t,indexedDB:e,log:n,metadataVersion:r}),a=s.transaction(["baselines","operations","info"],"readonly"),[p,l,m]=await Promise.all([J(a.objectStore("baselines").getAll()),J(a.objectStore("operations").getAll()),J(a.objectStore("info").getAll())]),v=o.db.transaction(["baselines","operations","info"],"readwrite"),y=v.objectStore("baselines"),C=v.objectStore("operations"),w=v.objectStore("info");for(let x of p)y.put(x);for(let x of l)C.put(x);for(let x of m)w.put(x);return await new Promise((x,I)=>{v.oncomplete=()=>{x()},v.onerror=S=>{I(S)},v.onabort=S=>{I(S)}}),await Ke(s),n?.("debug","Finished copy of production metadata database to WIP. Copied:",p.length,"baselines,",l.length,"operations"),o}async function ks(i,t){let e=i.createObjectStore("baselines",{keyPath:"oid"}),n=i.createObjectStore("operations",{keyPath:"oid_timestamp"}),r=i.createObjectStore("info",{keyPath:"type"});e.createIndex("timestamp","timestamp"),n.createIndex("isLocal_timestamp","isLocal_timestamp"),n.createIndex("documentOid_timestamp","documentOid_timestamp")}async function Ms(i,t){let e=t.objectStore("operations");await new Promise((n,r)=>{let o=e.openCursor();o.onsuccess=()=>{let s=o.result;if(s){let{isLocal_timestamp:a,documentOid_timestamp:p,...l}=s.value;s.update({...l,l_t:a,d_t:p}),s.continue()}else n()},o.onerror=s=>{r(o.error)}}),e.deleteIndex("isLocal_timestamp"),e.deleteIndex("documentOid_timestamp"),e.createIndex("l_t","l_t",{unique:!1}),e.createIndex("o_t","o_t",{unique:!1}),e.createIndex("d_t","d_t",{unique:!1})}async function Bs(i,t){t.objectStore("operations").createIndex("timestamp","timestamp")}async function js(i,t){let e=i.createObjectStore("files",{keyPath:"id"});e.createIndex("remote","remote"),e.createIndex("deletedAt","deletedAt")}async function Ls(i,t){let e=t.objectStore("operations");await new Promise((r,o)=>{let s=e.openCursor();s.onsuccess=()=>{let a=s.result;if(a){let p=ci(a.value);p.oid_timestamp!==a.primaryKey?(a.delete(),e.put(p)):a.update(p),a.continue()}else r()},s.onerror=a=>{o(s.error)}});let n=t.objectStore("baselines");await new Promise((r,o)=>{let s=n.openCursor();s.onsuccess=()=>{let a=s.result;if(a){let p=ci(a.value);p.oid!==a.primaryKey?(a.delete(),n.put(p)):a.update(p),a.continue()}else r()},s.onerror=a=>{o(s.error)}})}var Ns=i=>IDBKeyRange.only(ve(i.equals)),Us=i=>{},Vs=i=>{let t=i.gte||i.gt,e=i.lte||i.lt;return t===e?IDBKeyRange.only(ve(t)):t?e?IDBKeyRange.bound(ve(t),ve(e),!!i.gt,!!i.lt):IDBKeyRange.lowerBound(ve(t),!!i.gt):IDBKeyRange.upperBound(ve(e),!!i.lt)},Ks=(i,t,e)=>{let n=i.collections[t].compounds[e.where];L(n,`Index ${e.where} does not exist on collection ${t}`);let r=Object.keys(e.match).sort((p,l)=>n.of.indexOf(p)-n.of.indexOf(l));for(let p of r)if(n.of.indexOf(p)!==r.indexOf(p))throw new Error(`Compound index ${e.where} does not have ${p} at the start of its order`);let o=r.map(p=>e.match[p]);if(r.length===n.of.length)return IDBKeyRange.only(ce(...o));let s=Ve(...o),a=Ue(...o);return IDBKeyRange.bound(s,a)};function $s(i){let t=i.startsWith,e=i.startsWith+"\uFFFF";return IDBKeyRange.bound(t,e)}function sn(i,t,e){if(e)return ui(e)?Vs(e):di(e)?Ns(e):kr(e)?Us(e):fi(e)?$s(e):Ks(i,t,e)}function xi(i,t,e){return i.transaction(t,e?"readwrite":"readonly").objectStore(t)}async function an({collection:i,index:t,context:e}){let n=xi(e.documentDb,i),r=t?.where?n.index(t.where):n,o=sn(e.schema,i,t),s=t?.order==="desc"?"prev":"next",a=r.openCursor(o,s);return await new Promise((l,m)=>{a.onsuccess=()=>{let v=a.result;l(v?Z(i,v.primaryKey.toString()):null)},a.onerror=()=>{a.error?.name==="InvalidStateError"?(e.log("error","findOne query failed with InvalidStateError",a.error),l(null)):le(a.error)?l(null):m(a.error)}})}async function cn({collection:i,index:t,context:e}){let n=xi(e.documentDb,i),r=t?.where?n.index(t.where):n,o=sn(e.schema,i,t),s=t?.order==="desc"?"prev":"next",a=r.openCursor(o,s);return await new Promise((l,m)=>{let v=new Set;a.onsuccess=()=>{let y=a.result;y?(v.add(Z(i,y.primaryKey.toString())),y.continue()):l(Array.from(v))},a.onerror=()=>{a.error?.name==="InvalidStateError"?(e.log("error","findAll query failed with InvalidStateError",a.error),l([])):le(a.error)?l([]):m(a.error)}})}async function wt({collection:i,index:t,context:e,limit:n,offset:r}){let o=xi(e.documentDb,i),s=t?.where?o.index(t.where):o,a=sn(e.schema,i,t),p=t?.order==="desc"?"prev":"next",l=s.openCursor(a,p),m=!r,v=!1,y=0;return{result:await new Promise((w,x)=>{let I=new Set;l.onsuccess=()=>{y++;let S=l.result;S?r&&!m?(S.advance(r),m=!0):(n&&I.size<n&&I.add(Z(i,S.primaryKey.toString())),n&&y>n?(v=!0,w(Array.from(I))):S.continue()):w(Array.from(I))},l.onerror=()=>{l.error?.name==="InvalidStateError"?(e.log("error","find query failed with InvalidStateError",l.error),w([])):le(l.error)?w([]):x(l.error)}}),hasNextPage:v}}async function Oi(i,t,e,n){function r(a,p){let l,m,v=i.open([t,"collections"].join("_"),e);v.onupgradeneeded=async y=>{l=y.oldVersion;let C=v.transaction;m=v.result,C.abort()},v.onsuccess=y=>{a([v.result.version,v.result])},v.onblocked=y=>{n?.("Database blocked, waiting...")},v.onerror=y=>{a([l,m])}}let[o,s]=await new Promise(r);return await ln(s),o}async function ln(i){i.close(),await new Promise(t=>t())}async function Hr(i,t,e,n,r){function o(s,a){let p=i.open([t,"collections"].join("_"),e),l=!1;p.onupgradeneeded=m=>{let v=p.transaction;n(v,p.result,m),l=!0},p.onsuccess=m=>{p.result.close(),l?s():a(new Error("Database was not upgraded when a version change was expected"))},p.onerror=m=>{a(p.error||new Error("Unknown error"))},p.onblocked=m=>{r?.("Database upgrade blocked, waiting...")}}return new Promise(o)}async function Wr(i,t){typeof navigator<"u"&&navigator.locks?await navigator.locks.request(`verdant_migration_${i}`,t):await t()}async function $e(i,t,e,n){n?.("debug","Opening database",t,"at version",e);let r=await new Promise((o,s)=>{let a=i.open([t,"collections"].join("_"),e);a.onupgradeneeded=async p=>{a.transaction.abort(),n?.("error","Database upgrade needed, but not expected","Expected",e,"Got",a.result.version),s(a.error||new Error(`Migration error: database version changed unexpectedly when reading current data. Expected ${e}, got ${a.result.version}`))},a.onsuccess=p=>{o(a.result)},a.onblocked=p=>{s(new Error("Migration error: database blocked"))},a.onerror=p=>{s(new Error("Migration error: database error"))}});return r.addEventListener("versionchange",o=>{r.close()}),r}var Ze=class extends Error{constructor(e){super(e);this.message=e;this.name="MigrationPathError"}};function dn({currentVersion:i,targetVersion:t,migrations:e}){let n=Qr({currentVersion:i,targetVersion:t,migrations:e});if(!n)throw new Ze(`No migration path found from ${i} to ${t}! This is a bug. If you're seeing this, contact the developer and provide them with the full contents of this message.`);return n}function Qr({currentVersion:i,targetVersion:t,migrations:e}){if(i===t)return[];let n=e.filter(r=>r.oldSchema.version===i).sort((r,o)=>o.newSchema.version-r.newSchema.version);for(;n.length>0;){let r=n.shift();if(r.newSchema.version>t)return null;if(r.newSchema.version===t)return[r];let o=Qr({currentVersion:r.newSchema.version,targetVersion:t,migrations:e});if(o)return[r,...o]}return null}var Di=typeof window<"u"?window.indexedDB:void 0;async function vt({version:i,indexedDB:t=Di,migrations:e,meta:n,context:r}){if(r.schema.wip)throw new Error("Cannot open a production client with a WIP schema!");let o=await Oi(t,r.namespace,i,r.log);r.log("debug","Current database version:",o,"target version:",i);let s=dn({currentVersion:o,targetVersion:i,migrations:e});return s.length>0&&(r.log("debug","Migrations to run:",s.map(a=>a.version)),await Ii({context:r,toRun:s,meta:n,indexedDB:t})),$e(t,r.namespace,i,r.log)}async function Jr({version:i,indexedDB:t=Di,migrations:e,meta:n,context:r,wipNamespace:o}){r.log("debug","Opening WIP database",o);let s=await Oi(t,o,i,r.log);if(s===i)r.log("info","WIP schema is up-to-date; not refreshing database");else{r.log("info","WIP schema is out-of-date; refreshing database");let a=dn({currentVersion:s,targetVersion:i-1,migrations:e});if(a.length>0){await Ii({context:r,toRun:a,meta:n,indexedDB:t,namespace:o});let l=await $e(t,r.namespace,i-1,r.log),m=await $e(t,o,i-1,r.log),v=new Array;for(let S=0;S<l.objectStoreNames.length;S++)v.push(l.objectStoreNames[S]);let y=l.transaction(v,"readonly"),C=v.map(S=>y.objectStore(S)),w=await Promise.all(C.map(S=>J(S.getAll()))),x=m.transaction(v,"readwrite"),I=v.map(S=>x.objectStore(S));for(let S=0;S<I.length;S++)await Promise.all(w[S].map(D=>J(I[S].put(D))))}let p=dn({currentVersion:i-1,targetVersion:i,migrations:e});p.length>0&&await Ii({context:r,toRun:p,meta:n,indexedDB:t,namespace:o})}return $e(t,o,i,r.log)}async function Ii({context:i,toRun:t,meta:e,indexedDB:n=Di,namespace:r=i.namespace}){await Wr(r,async()=>{for(let o of t){let s;if(o.oldSchema.version===0)s=Hs({meta:e,migration:o,context:i}),await o.migrate(s);else{let l=await $e(n,r,o.oldSchema.version,i.log);s=qs({meta:e,migration:o,context:{...i,documentDb:l}});try{await o.migrate(s),await Promise.all(s.awaitables)}catch(m){throw i.log("critical",`Migration failed (${o.oldSchema.version} -> ${o.newSchema.version})`,m),m instanceof Error?m:new Error("Unknown error during migration")}await ln(l)}i.log("debug","Upgrading database",r,"to version",o.newSchema.version),await Hr(n,r,o.newSchema.version,(l,m)=>{for(let v of o.addedCollections)m.createObjectStore(v,{keyPath:o.newSchema.collections[v].primaryKey,autoIncrement:!1});for(let v of o.allCollections){let y=l.objectStore(v);for(let C of o.addedIndexes[v]||[])y.createIndex(C.name,C.name,{multiEntry:C.multiEntry});for(let C of o.removedIndexes[v]||[])y.deleteIndex(C.name)}for(let v of o.removedCollections)l.objectStore(v).clear()},i.log);let a=await Gs({meta:e,currentVersion:o.oldSchema.version,newVersion:o.newSchema.version}),p=await $e(n,r,o.newSchema.version,i.log);for(let l of o.allCollections){let v=p.transaction(l,"readwrite").objectStore(l),C=(await Ws(v)).map(D=>Z(l,`${D}`));C.push(...s.newOids.filter(D=>me(D).collection===l),...a.filter(D=>me(D).collection===l));let x=(await Promise.all(C.map(async D=>{try{let F=await e.getDocumentSnapshot(D);return[D,F]}catch(F){return i.log("error","Could not regenerate snapshot during migration for oid",D,"this document will not be preserved",F),null}}))).filter(D=>!!D).map(([D,F])=>{if(!F)return[D,void 0];let b=qt(o.newSchema.collections[l],F);return[D,b]}),S=p.transaction(l,"readwrite").objectStore(l);await Promise.all(x.map(([D,F])=>{if(F)return Js(S,F);{let{id:b}=me(D);return Qs(S,b)}}))}await ln(p),i.log("debug",`Migration of ${r} complete.`),i.log(`
|
|
9
9
|
\u2B06\uFE0F v${o.newSchema.version} Migration complete. Here's the rundown:
|