1import{F as pn,g as L,i as yr,p as mn,u as _n,d as te,c as gn,a as yn,_ as Er,b as En,L as An,e as In,f as Re,h as Tn,j as wn,C as Vn,r as Ke,S as vn}from"./index.esm-oCZZ2okZ.js";var We=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var Ar;(function(){var r;function t(c,o){function u(){}u.prototype=o.prototype,c.F=o.prototype,c.prototype=new u,c.prototype.constructor=c,c.D=function(f,h,d){for(var a=Array(arguments.length-2),ot=2;ot<arguments.length;ot++)a[ot-2]=arguments[ot];return o.prototype[h].apply(f,a)}}function e(){this.blockSize=-1}function n(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}t(n,e),n.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(c,o,u){u||(u=0);const f=Array(16);if(typeof o=="string")for(var h=0;h<16;++h)f[h]=o.charCodeAt(u++)|o.charCodeAt(u++)<<8|o.charCodeAt(u++)<<16|o.charCodeAt(u++)<<24;else for(h=0;h<16;++h)f[h]=o[u++]|o[u++]<<8|o[u++]<<16|o[u++]<<24;o=c.g[0],u=c.g[1],h=c.g[2];let d=c.g[3],a;a=o+(d^u&(h^d))+f[0]+3614090360&4294967295,o=u+(a<<7&4294967295|a>>>25),a=d+(h^o&(u^h))+f[1]+3905402710&4294967295,d=o+(a<<12&4294967295|a>>>20),a=h+(u^d&(o^u))+f[2]+606105819&4294967295,h=d+(a<<17&4294967295|a>>>15),a=u+(o^h&(d^o))+f[3]+3250441966&4294967295,u=h+(a<<22&4294967295|a>>>10),a=o+(d^u&(h^d))+f[4]+4118548399&4294967295,o=u+(a<<7&4294967295|a>>>25),a=d+(h^o&(u^h))+f[5]+1200080426&4294967295,d=o+(a<<12&4294967295|a>>>20),a=h+(u^d&(o^u))+f[6]+2821735955&4294967295,h=d+(a<<17&4294967295|a>>>15),a=u+(o^h&(d^o))+f[7]+4249261313&4294967295,u=h+(a<<22&4294967295|a>>>10),a=o+(d^u&(h^d))+f[8]+1770035416&4294967295,o=u+(a<<7&4294967295|a>>>25),a=d+(h^o&(u^h))+f[9]+2336552879&4294967295,d=o+(a<<12&4294967295|a>>>20),a=h+(u^d&(o^u))+f[10]+4294925233&4294967295,h=d+(a<<17&4294967295|a>>>15),a=u+(o^h&(d^o))+f[11]+2304563134&4294967295,u=h+(a<<22&4294967295|a>>>10),a=o+(d^u&(h^d))+f[12]+1804603682&4294967295,o=u+(a<<7&4294967295|a>>>25),a=d+(h^o&(u^h))+f[13]+4254626195&4294967295,d=o+(a<<12&4294967295|a>>>20),a=h+(u^d&(o^u))+f[14]+2792965006&4294967295,h=d+(a<<17&4294967295|a>>>15),a=u+(o^h&(d^o))+f[15]+1236535329&4294967295,u=h+(a<<22&4294967295|a>>>10),a=o+(h^d&(u^h))+f[1]+4129170786&4294967295,o=u+(a<<5&4294967295|a>>>27),a=d+(u^h&(o^u))+f[6]+3225465664&4294967295,d=o+(a<<9&4294967295|a>>>23),a=h+(o^u&(d^o))+f[11]+643717713&4294967295,h=d+(a<<14&4294967295|a>>>18),a=u+(d^o&(h^d))+f[0]+3921069994&4294967295,u=h+(a<<20&4294967295|a>>>12),a=o+(h^d&(u^h))+f[5]+3593408605&4294967295,o=u+(a<<5&4294967295|a>>>27),a=d+(u^h&(o^u))+f[10]+38016083&4294967295,d=o+(a<<9&4294967295|a>>>23),a=h+(o^u&(d^o))+f[15]+3634488961&4294967295,h=d+(a<<14&4294967295|a>>>18),a=u+(d^o&(h^d))+f[4]+3889429448&4294967295,u=h+(a<<20&4294967295|a>>>12),a=o+(h^d&(u^h))+f[9]+568446438&4294967295,o=u+(a<<5&4294967295|a>>>27),a=d+(u^h&(o^u))+f[14]+3275163606&4294967295,d=o+(a<<9&4294967295|a>>>23),a=h+(o^u&(d^o))+f[3]+4107603335&4294967295,h=d+(a<<14&4294967295|a>>>18),a=u+(d^o&(h^d))+f[8]+1163531501&4294967295,u=h+(a<<20&4294967295|a>>>12),a=o+(h^d&(u^h))+f[13]+2850285829&4294967295,o=u+(a<<5&4294967295|a>>>27),a=d+(u^h&(o^u))+f[2]+4243563512&4294967295,d=o+(a<<9&4294967295|a>>>23),a=h+(o^u&(d^o))+f[7]+1735328473&4294967295,h=d+(a<<14&4294967295|a>>>18),a=u+(d^o&(h^d))+f[12]+2368359562&4294967295,u=h+(a<<20&4294967295|a>>>12),a=o+(u^h^d)+f[5]+4294588738&4294967295,o=u+(a<<4&4294967295|a>>>28),a=d+(o^u^h)+f[8]+2272392833&4294967295,d=o+(a<<11&4294967295|a>>>21),a=h+(d^o^u)+f[11]+1839030562&4294967295,h=d+(a<<16&4294967295|a>>>16),a=u+(h^d^o)+f[14]+4259657740&4294967295,u=h+(a<<23&4294967295|a>>>9),a=o+(u^h^d)+f[1]+2763975236&4294967295,o=u+(a<<4&4294967295|a>>>28),a=d+(o^u^h)+f[4]+1272893353&4294967295,d=o+(a<<11&4294967295|a>>>21),a=h+(d^o^u)+f[7]+4139469664&4294967295,h=d+(a<<16&4294967295|a>>>16),a=u+(h^d^o)+f[10]+3200236656&4294967295,u=h+(a<<23&4294967295|a>>>9),a=o+(u^h^d)+f[13]+681279174&4294967295,o=u+(a<<4&4294967295|a>>>28),a=d+(o^u^h)+f[0]+3936430074&4294967295,d=o+(a<<11&4294967295|a>>>21),a=h+(d^o^u)+f[3]+3572445317&4294967295,h=d+(a<<16&4294967295|a>>>16),a=u+(h^d^o)+f[6]+76029189&4294967295,u=h+(a<<23&4294967295|a>>>9),a=o+(u^h^d)+f[9]+3654602809&4294967295,o=u+(a<<4&4294967295|a>>>28),a=d+(o^u^h)+f[12]+3873151461&4294967295,d=o+(a<<11&4294967295|a>>>21),a=h+(d^o^u)+f[15]+530742520&4294967295,h=d+(a<<16&4294967295|a>>>16),a=u+(h^d^o)+f[2]+3299628645&4294967295,u=h+(a<<23&4294967295|a>>>9),a=o+(h^(u|~d))+f[0]+4096336452&4294967295,o=u+(a<<6&4294967295|a>>>26),a=d+(u^(o|~h))+f[7]+1126891415&4294967295,d=o+(a<<10&4294967295|a>>>22),a=h+(o^(d|~u))+f[14]+2878612391&4294967295,h=d+(a<<15&4294967295|a>>>17),a=u+(d^(h|~o))+f[5]+4237533241&4294967295,u=h+(a<<21&4294967295|a>>>11),a=o+(h^(u|~d))+f[12]+1700485571&4294967295,o=u+(a<<6&4294967295|a>>>26),a=d+(u^(o|~h))+f[3]+2399980690&4294967295,d=o+(a<<10&4294967295|a>>>22),a=h+(o^(d|~u))+f[10]+4293915773&4294967295,h=d+(a<<15&4294967295|a>>>17),a=u+(d^(h|~o))+f[1]+2240044497&4294967295,u=h+(a<<21&4294967295|a>>>11),a=o+(h^(u|~d))+f[8]+1873313359&4294967295,o=u+(a<<6&4294967295|a>>>26),a=d+(u^(o|~h))+f[15]+4264355552&4294967295,d=o+(a<<10&4294967295|a>>>22),a=h+(o^(d|~u))+f[6]+2734768916&4294967295,h=d+(a<<15&4294967295|a>>>17),a=u+(d^(h|~o))+f[13]+1309151649&4294967295,u=h+(a<<21&4294967295|a>>>11),a=o+(h^(u|~d))+f[4]+4149444226&4294967295,o=u+(a<<6&4294967295|a>>>26),a=d+(u^(o|~h))+f[11]+3174756917&4294967295,d=o+(a<<10&4294967295|a>>>22),a=h+(o^(d|~u))+f[2]+718787259&4294967295,h=d+(a<<15&4294967295|a>>>17),a=u+(d^(h|~o))+f[9]+3951481745&4294967295,c.g[0]=c.g[0]+o&4294967295,c.g[1]=c.g[1]+(h+(a<<21&4294967295|a>>>11))&4294967295,c.g[2]=c.g[2]+h&4294967295,c.g[3]=c.g[3]+d&4294967295}n.prototype.v=function(c,o){o===void 0&&(o=c.length);const u=o-this.blockSize,f=this.C;let h=this.h,d=0;for(;d<o;){if(h==0)for(;d<=u;)i(this,c,d),d+=this.blockSize;if(typeof c=="string"){for(;d<o;)if(f[h++]=c.charCodeAt(d++),h==this.blockSize){i(this,f),h=0;break}}else for(;d<o;)if(f[h++]=c[d++],h==this.blockSize){i(this,f),h=0;break}}this.h=h,this.o+=o},n.prototype.A=function(){var c=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);c[0]=128;for(var o=1;o<c.length-8;++o)c[o]=0;o=this.o*8;for(var u=c.length-8;u<c.length;++u)c[u]=o&255,o/=256;for(this.v(c),c=Array(16),o=0,u=0;u<4;++u)for(let f=0;f<32;f+=8)c[o++]=this.g[u]>>>f&255;return c};function s(c,o){var u=p;return Object.prototype.hasOwnProperty.call(u,c)?u[c]:u[c]=o(c)}function l(c,o){this.h=o;const u=[];let f=!0;for(let h=c.length-1;h>=0;h--){const d=c[h]|0;f&&d==o||(u[h]=d,f=!1)}this.g=u}var p={};function m(c){return-128<=c&&c<128?s(c,function(o){return new l([o|0],o<0?-1:0)}):new l([c|0],c<0?-1:0)}function g(c){if(isNaN(c)||!isFinite(c))return A;if(c<0)return w(g(-c));const o=[];let u=1;for(let f=0;c>=u;f++)o[f]=c/u|0,u*=4294967296;return new l(o,0)}function y(c,o){if(c.length==0)throw Error("number format error: empty string");if(o=o||10,o<2||36<o)throw Error("radix out of range: "+o);if(c.charAt(0)=="-")return w(y(c.substring(1),o));if(c.indexOf("-")>=0)throw Error('number format error: interior "-" character');const u=g(Math.pow(o,8));let f=A;for(let d=0;d<c.length;d+=8){var h=Math.min(8,c.length-d);const a=parseInt(c.substring(d,d+h),o);h<8?(h=g(Math.pow(o,h)),f=f.j(h).add(g(a))):(f=f.j(u),f=f.add(g(a)))}return f}var A=m(0),I=m(1),b=m(16777216);r=l.prototype,r.m=function(){if(R(this))return-w(this).m();let c=0,o=1;for(let u=0;u<this.g.length;u++){const f=this.i(u);c+=(f>=0?f:4294967296+f)*o,o*=4294967296}return c},r.toString=function(c){if(c=c||10,c<2||36<c)throw Error("radix out of range: "+c);if(v(this))return"0";if(R(this))return"-"+w(this).toString(c);const o=g(Math.pow(c,6));var u=this;let f="";for(;;){const h=tt(u,o).g;u=H(u,h.j(o));let d=((u.g.length>0?u.g[0]:u.h)>>>0).toString(c);if(u=h,v(u))return d+f;for(;d.length<6;)d="0"+d;f=d+f}},r.i=function(c){return c<0?0:c<this.g.length?this.g[c]:this.h};function v(c){if(c.h!=0)return!1;for(let o=0;o<c.g.length;o++)if(c.g[o]!=0)return!1;return!0}function R(c){return c.h==-1}r.l=function(c){return c=H(this,c),R(c)?-1:v(c)?0:1};function w(c){const o=c.g.length,u=[];for(let f=0;f<o;f++)u[f]=~c.g[f];return new l(u,~c.h).add(I)}r.abs=function(){return R(this)?w(this):this},r.add=function(c){const o=Math.max(this.g.length,c.g.length),u=[];let f=0;for(let h=0;h<=o;h++){let d=f+(this.i(h)&65535)+(c.i(h)&65535),a=(d>>>16)+(this.i(h)>>>16)+(c.i(h)>>>16);f=a>>>16,d&=65535,a&=65535,u[h]=a<<16|d}return new l(u,u[u.length-1]&-2147483648?-1:0)};function H(c,o){return c.add(w(o))}r.j=function(c){if(v(this)||v(c))return A;if(R(this))return R(c)?w(this).j(w(c)):w(w(this).j(c));if(R(c))return w(this.j(w(c)));if(this.l(b)<0&&c.l(b)<0)return g(this.m()*c.m());const o=this.g.length+c.g.length,u=[];for(var f=0;f<2*o;f++)u[f]=0;for(f=0;f<this.g.length;f++)for(let h=0;h<c.g.length;h++){const d=this.i(f)>>>16,a=this.i(f)&65535,ot=c.i(h)>>>16,Qe=c.i(h)&65535;u[2*f+2*h]+=a*Qe,At(u,2*f+2*h),u[2*f+2*h+1]+=d*Qe,At(u,2*f+2*h+1),u[2*f+2*h+1]+=a*ot,At(u,2*f+2*h+1),u[2*f+2*h+2]+=d*ot,At(u,2*f+2*h+2)}for(c=0;c<o;c++)u[c]=u[2*c+1]<<16|u[2*c];for(c=o;c<2*o;c++)u[c]=0;return new l(u,0)};function At(c,o){for(;(c[o]&65535)!=c[o];)c[o+1]+=c[o]>>>16,c[o]&=65535,o++}function B(c,o){this.g=c,this.h=o}function tt(c,o){if(v(o))throw Error("division by zero");if(v(c))return new B(A,A);if(R(c))return o=tt(w(c),o),new B(w(o.g),w(o.h));
1if(R(o))return o=tt(c,w(o)),new B(w(o.g),o.h);if(c.g.length>30){if(R(c)||R(o))throw Error("slowDivide_ only works with positive integers.");for(var u=I,f=o;f.l(c)<=0;)u=ze(u),f=ze(f);var h=It(u,1),d=It(f,1);for(f=It(f,2),u=It(u,2);!v(f);){var a=d.add(f);a.l(c)<=0&&(h=h.add(u),d=a),f=It(f,1),u=It(u,1)}return o=H(c,h.j(o)),new B(h,o)}for(h=A;c.l(o)>=0;){for(u=Math.max(1,Math.floor(c.m()/o.m())),f=Math.ceil(Math.log(u)/Math.LN2),f=f<=48?1:Math.pow(2,f-48),d=g(u),a=d.j(o);R(a)||a.l(c)>0;)u-=f,d=g(u),a=d.j(o);v(d)&&(d=I),h=h.add(d),c=H(c,a)}return new B(h,c)}r.B=function(c){return tt(this,c).h},r.and=function(c){const o=Math.max(this.g.length,c.g.length),u=[];for(let f=0;f<o;f++)u[f]=this.i(f)&c.i(f);return new l(u,this.h&c.h)},r.or=function(c){const o=Math.max(this.g.length,c.g.length),u=[];for(let f=0;f<o;f++)u[f]=this.i(f)|c.i(f);return new l(u,this.h|c.h)},r.xor=function(c){const o=Math.max(this.g.length,c.g.length),u=[];for(let f=0;f<o;f++)u[f]=this.i(f)^c.i(f);return new l(u,this.h^c.h)};function ze(c){const o=c.g.length+1,u=[];for(let f=0;f<o;f++)u[f]=c.i(f)<<1|c.i(f-1)>>>31;return new l(u,c.h)}function It(c,o){const u=o>>5;o%=32;const f=c.g.length-u,h=[];for(let d=0;d<f;d++)h[d]=o>0?c.i(d+u)>>>o|c.i(d+u+1)<<32-o:c.i(d+u);return new l(h,c.h)}n.prototype.digest=n.prototype.A,n.prototype.reset=n.prototype.u,n.prototype.update=n.prototype.v,l.prototype.add=l.prototype.add,l.prototype.multiply=l.prototype.j,l.prototype.modulo=l.prototype.B,l.prototype.compare=l.prototype.l,l.prototype.toNumber=l.prototype.m,l.prototype.toString=l.prototype.toString,l.prototype.getBits=l.prototype.i,l.fromNumber=g,l.fromString=y,Ar=l}).apply(typeof We<"u"?We:typeof self<"u"?self:typeof window<"u"?window:{});class x{constructor(t){this.uid=t}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}x.UNAUTHENTICATED=new x(null),x.GOOGLE_CREDENTIALS=new x("google-credentials-uid"),x.FIRST_PARTY=new x("first-party-uid"),x.MOCK_USER=new x("mock-user");let wt="12.10.0";function Rn(r){wt=r}const ut=new An("@firebase/firestore");function Gi(r){ut.setLogLevel(r)}function lt(r,...t){if(ut.logLevel<=Re.DEBUG){const e=t.map(Pe);ut.debug(`Firestore (${wt}): ${r}`,...e)}}function ee(r,...t){if(ut.logLevel<=Re.ERROR){const e=t.map(Pe);ut.error(`Firestore (${wt}): ${r}`,...e)}}function Ir(r,...t){if(ut.logLevel<=Re.WARN){const e=t.map(Pe);ut.warn(`Firestore (${wt}): ${r}`,...e)}}function Pe(r){if(typeof r=="string")return r;try{return(function(e){return JSON.stringify(e)})(r)}catch{return r}}function V(r,t,e){let n="Unexpected state";typeof t=="string"?n=t:e=t,Tr(r,n,e)}function Tr(r,t,e){let n=`FIRESTORE (${wt}) INTERNAL ASSERTION FAILED: ${t} (ID: ${r.toString(16)})`;if(e!==void 0)try{n+=" CONTEXT: "+JSON.stringify(e)}catch{n+=" CONTEXT: "+e}throw ee(n),new Error(n)}function G(r,t,e,n){let i="Unexpected state";typeof e=="string"?i=e:n=e,r||Tr(t,i,n)}function ct(r,t){return r}const _={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class E extends pn{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class wr{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class Pn{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable((()=>e(x.UNAUTHENTICATED)))}shutdown(){}}class Nn{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable((()=>e(this.token.user)))}shutdown(){this.changeListener=null}}class Sn{constructor(t){this.auth=null,t.onInit((e=>{this.auth=e}))}getToken(){return this.auth?this.auth.getToken().then((t=>t?(G(typeof t.accessToken=="string",42297,{t}),new wr(t.accessToken,new x(this.auth.getUid()))):null)):Promise.resolve(null)}invalidateToken(){}start(t,e){}shutdown(){}}class bn{constructor(t,e,n){this.i=t,this.o=e,this.u=n,this.type="FirstParty",this.user=x.FIRST_PARTY,this.l=new Map}h(){return this.u?this.u():null}get headers(){this.l.set("X-Goog-AuthUser",this.i);const t=this.h();return t&&this.l.set("Authorization",t),this.o&&this.l.set("X-Goog-Iam-Authorization-Token",this.o),this.l}}class Dn{constructor(t,e,n){this.i=t,this.o=e,this.u=n}getToken(){return Promise.resolve(new bn(this.i,this.o,this.u))}start(t,e){t.enqueueRetryable((()=>e(x.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class He{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class kn{constructor(t,e){this.m=e,this.appCheck=null,this.P=null,Tn(t)&&t.settings.appCheckToken&&(this.P=t.settings.appCheckToken),e.onInit((n=>{this.appCheck=n}))}getToken(){return this.P?Promise.resolve(new He(this.P)):this.appCheck?this.appCheck.getToken().then((t=>
1t?(G(typeof t.token=="string",3470,{tokenResult:t}),new He(t.token)):null)):Promise.resolve(null)}invalidateToken(){}start(t,e){}shutdown(){}}class Fn{constructor(t,e,n,i,s,l,p,m,g,y,A){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=i,this.ssl=s,this.forceLongPolling=l,this.autoDetectLongPolling=p,this.longPollingOptions=m,this.useFetchStreams=g,this.isUsingEmulator=y,this.apiKey=A}}const Bt="(default)";class bt{constructor(t,e){this.projectId=t,this.database=e||Bt}static empty(){return new bt("","")}get isDefaultDatabase(){return this.database===Bt}isEqual(t){return t instanceof bt&&t.projectId===this.projectId&&t.database===this.database}}function On(r,t){if(!Object.prototype.hasOwnProperty.apply(r.options,["projectId"]))throw new E(_.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new bt(r.options.projectId,t)}function Ln(r){const t=typeof self<"u"&&(self.crypto||self.msCrypto),e=new Uint8Array(r);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(e);else for(let n=0;n<r;n++)e[n]=Math.floor(256*Math.random());return e}class Cn{static newId(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=62*Math.floor(4.129032258064516);let n="";for(;n.length<20;){const i=Ln(40);for(let s=0;s<i.length;++s)n.length<20&&i[s]<e&&(n+=t.charAt(i[s]%62))}return n}}function k(r,t){return r<t?-1:r>t?1:0}function ye(r,t){const e=Math.min(r.length,t.length);for(let n=0;n<e;n++){const i=r.charAt(n),s=t.charAt(n);if(i!==s)return pe(i)===pe(s)?k(i,s):pe(i)?1:-1}return k(r.length,t.length)}const Un=55296,xn=57343;function pe(r){const t=r.charCodeAt(0);return t>=Un&&t<=xn}function Ne(r,t,e){return r.length===t.length&&r.every(((n,i)=>e(n,t[i])))}const Ee="__name__";class Y{constructor(t,e,n){e===void 0?e=0:e>t.length&&V(637,{offset:e,range:t.length}),n===void 0?n=t.length-e:n>t.length-e&&V(1746,{length:n,range:t.length-e}),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return Y.comparator(this,t)===0}child(t){const e=this.segments.slice(this.offset,this.limit());return t instanceof Y?t.forEach((n=>{e.push(n)})):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=t===void 0?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return this.length===0}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){const n=Math.min(t.length,e.length);for(let i=0;i<n;i++){const s=Y.compareSegments(t.get(i),e.get(i));if(s!==0)return s}return k(t.length,e.length)}static compareSegments(t,e){const n=Y.isNumericId(t),i=Y.isNumericId(e);return n&&!i?-1:!n&&i?1:n&&i?Y.extractNumericId(t).compare(Y.extractNumericId(e)):ye(t,e)}static isNumericId(t){return t.startsWith("__id")&&t.endsWith("__")}static extractNumericId(t){return Ar.fromString(t.substring(4,t.length-2))}}class N extends Y{construct(t,e,n){return new N(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...t){const e=[];for(const n of t){if(n.indexOf("//")>=0)throw new E(_.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter((i=>i.length>0)))}return new N(e)}static emptyPath(){return new N([])}}const Mn=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class M extends Y{construct(t,e,n){return new M(t,e,n)}static isValidIdentifier(t){return Mn.test(t)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),M.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Ee}static keyField(){return new M([Ee])}static fromServerFormat(t){const e=[];let n="",i=0;const s=()=>
1{if(n.length===0)throw new E(_.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""};let l=!1;for(;i<t.length;){const p=t[i];if(p==="\\"){if(i+1===t.length)throw new E(_.INVALID_ARGUMENT,"Path has trailing escape character: "+t);const m=t[i+1];if(m!=="\\"&&m!=="."&&m!=="`")throw new E(_.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=m,i+=2}else p==="`"?(l=!l,i++):p!=="."||l?(n+=p,i++):(s(),i++)}if(s(),l)throw new E(_.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new M(e)}static emptyPath(){return new M([])}}class S{constructor(t){this.path=t}static fromPath(t){return new S(N.fromString(t))}static fromName(t){return new S(N.fromString(t).popFirst(5))}static empty(){return new S(N.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return t!==null&&N.comparator(this.path,t.path)===0}toString(){return this.path.toString()}static comparator(t,e){return N.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new S(new N(t.slice()))}}function Se(r,t,e){if(!e)throw new E(_.INVALID_ARGUMENT,`Function ${r}() cannot be called with an empty ${t}.`)}function Je(r){if(!S.isDocumentKey(r))throw new E(_.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${r} has ${r.length}.`)}function Ye(r){if(S.isDocumentKey(r))throw new E(_.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${r} has ${r.length}.`)}function Vr(r){return typeof r=="object"&&r!==null&&(Object.getPrototypeOf(r)===Object.prototype||Object.getPrototypeOf(r)===null)}function re(r){if(r===void 0)return"undefined";if(r===null)return"null";if(typeof r=="string")return r.length>20&&(r=`${r.substring(0,20)}...`),JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean")return""+r;if(typeof r=="object"){if(r instanceof Array)return"an array";{const t=(function(n){return n.constructor?n.constructor.name:null})(r);return t?`a custom ${t} object`:"an object"}}return typeof r=="function"?"a function":V(12329,{type:typeof r})}function W(r,t){if("_delegate"in r&&(r=r._delegate),!(r instanceof t)){if(t.name===r.constructor.name)throw new E(_.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const e=re(r);throw new E(_.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${e}`)}}return r}function vr(r,t){if(t<=0)throw new E(_.INVALID_ARGUMENT,`Function ${r}() requires a positive number, but it was: ${t}.`)}function Rr(r){const t={};return r.timeoutSeconds!==void 0&&(t.timeoutSeconds=r.timeoutSeconds),t}let Gt=null;function qn(){return Gt===null?Gt=(function(){return 268435456+Math.round(2147483648*Math.random())})():Gt++,"0x"+Gt.toString(16)}function Pr(r){return r==null}function zt(r){return r===0&&1/r==-1/0}const me="RestConnection",Gn={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class $n{get T(){return!1}constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.R=e+"://"+t.host,this.V=`projects/${n}/databases/${i}`,this.A=this.databaseId.database===Bt?`project_id=${n}`:`project_id=${n}&database_id=${i}`}I(t,e,n,i,s){const l=qn(),p=this.p(t,e.toUriEncodedString());lt(me,`Sending RPC '${t}' ${l}:`,p,n);const m={"google-cloud-resource-prefix":this.V,"x-goog-request-params":this.A};this.F(m,i,s);const{host:g}=new URL(p),y=yr(g);return this.v(t,p,m,n,y).then((A=>(lt(me,`Received RPC '${t}' ${l}: `,A),A)),(A=>{throw Ir(me,`RPC '${t}' ${l} failed with error: `,A,"url: ",p,"request:",n),A}))}D(t,e,n,i,s,l){return this.I(t,e,n,i,s)}F(t,e,n){t["X-Goog-Api-Client"]=(function(){return"gl-js/ fire/"+wt})(),t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEac
1h(((i,s)=>t[s]=i)),n&&n.headers.forEach(((i,s)=>t[s]=i))}p(t,e){const n=Gn[t];let i=`${this.R}/v1/${e}:${n}`;return this.databaseInfo.apiKey&&(i=`${i}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),i}terminate(){}}var Xe,T;function jn(r){switch(r){case _.OK:return V(64938);case _.CANCELLED:case _.UNKNOWN:case _.DEADLINE_EXCEEDED:case _.RESOURCE_EXHAUSTED:case _.INTERNAL:case _.UNAVAILABLE:case _.UNAUTHENTICATED:return!1;case _.INVALID_ARGUMENT:case _.NOT_FOUND:case _.ALREADY_EXISTS:case _.PERMISSION_DENIED:case _.FAILED_PRECONDITION:case _.ABORTED:case _.OUT_OF_RANGE:case _.UNIMPLEMENTED:case _.DATA_LOSS:return!0;default:return V(15467,{code:r})}}function Ze(r){if(r===void 0)return ee("RPC_ERROR","HTTP error has no status"),_.UNKNOWN;switch(r){case 200:return _.OK;case 400:return _.FAILED_PRECONDITION;case 401:return _.UNAUTHENTICATED;case 403:return _.PERMISSION_DENIED;case 404:return _.NOT_FOUND;case 409:return _.ABORTED;case 416:return _.OUT_OF_RANGE;case 429:return _.RESOURCE_EXHAUSTED;case 499:return _.CANCELLED;case 500:return _.UNKNOWN;case 501:return _.UNIMPLEMENTED;case 503:return _.UNAVAILABLE;case 504:return _.DEADLINE_EXCEEDED;default:return r>=200&&r<300?_.OK:r>=400&&r<500?_.FAILED_PRECONDITION:r>=500&&r<600?_.INTERNAL:_.UNKNOWN}}(T=Xe||(Xe={}))[T.OK=0]="OK",T[T.CANCELLED=1]="CANCELLED",T[T.UNKNOWN=2]="UNKNOWN",T[T.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",T[T.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",T[T.NOT_FOUND=5]="NOT_FOUND",T[T.ALREADY_EXISTS=6]="ALREADY_EXISTS",T[T.PERMISSION_DENIED=7]="PERMISSION_DENIED",T[T.UNAUTHENTICATED=16]="UNAUTHENTICATED",T[T.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",T[T.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",T[T.ABORTED=10]="ABORTED",T[T.OUT_OF_RANGE=11]="OUT_OF_RANGE",T[T.UNIMPLEMENTED=12]="UNIMPLEMENTED",T[T.INTERNAL=13]="INTERNAL",T[T.UNAVAILABLE=14]="UNAVAILABLE",T[T.DATA_LOSS=15]="DATA_LOSS";class Bn extends $n{S(t,e){throw new Error("Not supported by FetchConnection")}async v(t,e,n,i,s){const l=JSON.stringify(i);let p;try{const m={method:"POST",headers:n,body:l};
1s&&(m.credentials="include"),p=await fetch(e,m)}catch(m){const g=m;throw new E(Ze(g.status),"Request failed with error: "+g.statusText)}if(!p.ok){let m=await p.json();Array.isArray(m)&&(m=m[0]);const g=m?.error?.message;throw new E(Ze(p.status),`Request failed with error: ${g??p.statusText}`)}return p.json()}}function tr(r){let t=0;for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t++;return t}function Ct(r,t){for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&t(e,r[e])}function zn(r,t){const e=[];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.push(t(r[n],n,r));return e}class Qn extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class et{constructor(t){this.binaryString=t}static fromBase64String(t){const e=(function(i){try{return atob(i)}catch(s){throw typeof DOMException<"u"&&s instanceof DOMException?new Qn("Invalid base64 string: "+s):s}})(t);return new et(e)}static fromUint8Array(t){const e=(function(i){let s="";for(let l=0;l<i.length;++l)s+=String.fromCharCode(i[l]);return s})(t);return new et(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return(function(e){return btoa(e)})(this.binaryString)}toUint8Array(){return(function(e){const n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return n})(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return k(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}et.EMPTY_BYTE_STRING=new et("");const Kn=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ht(r){if(G(!!r,39018),typeof r=="string"){let t=0;const e=Kn.exec(r);if(G(!!e,46558,{timestamp:r}),e[1]){let i=e[1];i=(i+"000000000").substr(0,9),t=Number(i)}const n=new Date(r);return{seconds:Math.floor(n.getTime()/1e3),nanos:t}}return{seconds:F(r.seconds),nanos:F(r.nanos)}}function F(r){return typeof r=="number"?r:typeof r=="string"?Number(r):0}function Dt(r){return typeof r=="string"?et.fromBase64String(r):et.fromUint8Array(r)}function Q(r,t){const e={typeString:r};return t&&(e.value=t),e}function Ut(r,t){if(!Vr(r))throw new E(_.INVALID_ARGUMENT,"JSON must be an object");let e;for(const n in t)if(t[n]){const i=t[n].typeString,s="value"in t[n]?{value:t[n].value}:void 0;if(!(n in r)){e=`JSON missing required field: '${n}'`;break}const l=r[n];if(i&&typeof l!==i){e=`JSON field '${n}' must be a ${i}.`;break}if(s!==void 0&&l!==s.value){e=`Expected '${n}' field to equal '${s.value}'`;break}}if(e)throw new E(_.INVALID_ARGUMENT,e);return!0}const er=-62135596800,rr=1e6;class O{static now(){return O.fromMillis(Date.now())}static fromDate(t){return O.fromMillis(t.getTime())}static fromMillis(t){const e=Math.floor(t/1e3),n=Math.floor((t-1e3*e)*rr);return new O(e,n)}constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new E(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new E(_.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<er)throw new E(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new E(_.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/rr}_compareTo(t){return this.seconds===t.seconds?k(this.nanoseconds,t.nanoseconds):k(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:O._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(Ut(t,O._jsonSchema))return new O(t.seconds,t.nanoseconds)}valueOf(){const t=this.seconds-er;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}O._jsonSchemaVersion="firestore/timestamp/1.0",O._jsonSchema={type:Q("string",O._jsonSchemaVersion),seconds:Q("number"),nanoseconds:Q("number")};function be(r){return(r?.mapValue?.fields||{}).__type__?.stringValue==="server_timestamp"}function Nr(r){const t=r.mapValue.fields.__previous_value__;return be(t)?Nr(t):t}function kt(r){const t=ht(r.mapValue.fields.__local_write_time__.timestampValue);
1return new O(t.seconds,t.nanos)}const Sr="__type__",Wn="__max__",$t={},br="__vector__",Qt="value";function ft(r){return"nullValue"in r?0:"booleanValue"in r?1:"integerValue"in r||"doubleValue"in r?2:"timestampValue"in r?3:"stringValue"in r?5:"bytesValue"in r?6:"referenceValue"in r?7:"geoPointValue"in r?8:"arrayValue"in r?9:"mapValue"in r?be(r)?4:(function(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===Wn})(r)?9007199254740991:(function(e){return(e?.mapValue?.fields||{})[Sr]?.stringValue===br})(r)?10:11:V(28295,{value:r})}function Tt(r,t){if(r===t)return!0;const e=ft(r);if(e!==ft(t))return!1;switch(e){case 0:case 9007199254740991:return!0;case 1:return r.booleanValue===t.booleanValue;case 4:return kt(r).isEqual(kt(t));case 3:return(function(i,s){if(typeof i.timestampValue=="string"&&typeof s.timestampValue=="string"&&i.timestampValue.length===s.timestampValue.length)return i.timestampValue===s.timestampValue;const l=ht(i.timestampValue),p=ht(s.timestampValue);return l.seconds===p.seconds&&l.nanos===p.nanos})(r,t);case 5:return r.stringValue===t.stringValue;case 6:return(function(i,s){return Dt(i.bytesValue).isEqual(Dt(s.bytesValue))})(r,t);case 7:return r.referenceValue===t.referenceValue;case 8:return(function(i,s){return F(i.geoPointValue.latitude)===F(s.geoPointValue.latitude)&&F(i.geoPointValue.longitude)===F(s.geoPointValue.longitude)})(r,t);case 2:return(function(i,s){if("integerValue"in i&&"integerValue"in s)return F(i.integerValue)===F(s.integerValue);if("doubleValue"in i&&"doubleValue"in s){const l=F(i.doubleValue),p=F(s.doubleValue);return l===p?zt(l)===zt(p):isNaN(l)&&isNaN(p)}return!1})(r,t);case 9:return Ne(r.arrayValue.values||[],t.arrayValue.values||[],Tt);case 10:case 11:return(function(i,s){const l=i.mapValue.fields||{},p=s.mapValue.fields||{};if(tr(l)!==tr(p))return!1;for(const m in l)if(l.hasOwnProperty(m)&&(p[m]===void 0||!Tt(l[m],p[m])))return!1;return!0})(r,t);default:return V(52216,{left:r})}}function Ft(r,t){return(r.values||[]).find((e=>Tt(e,t)))!==void 0}function Kt(r,t){if(r===t)return 0;const e=ft(r),n=ft(t);if(e!==n)return k(e,n);switch(e){case 0:case 9007199254740991:return 0;case 1:return k(r.booleanValue,t.booleanValue);case 2:return(function(s,l){const p=F(s.integerValue||s.doubleValue),m=F(l.integerValue||l.doubleValue);return p<m?-1:p>m?1:p===m?0:isNaN(p)?isNaN(m)?0:-1:1})(r,t);case 3:return nr(r.timestampValue,t.timestampValue);case 4:return nr(kt(r),kt(t));case 5:return ye(r.stringValue,t.stringValue);case 6:return(function(s,l){const p=Dt(s),m=Dt(l);return p.compareTo(m)})(r.bytesValue,t.bytesValue);case 7:return(function(s,l){const p=s.split("/"),m=l.split("/");for(let g=0;g<p.length&&g<m.length;g++){const y=k(p[g],m[g]);if(y!==0)return y}return k(p.length,m.length)})(r.referenceValue,t.referenceValue);case 8:return(function(s,l){const p=k(F(s.latitude),F(l.latitude));return p!==0?p:k(F(s.longitude),F(l.longitude))})(r.geoPointValue,t.geoPointValue);case 9:return ir(r.arrayValue,t.arrayValue);case 10:return(function(s,l){const p=s.fields||{},m=l.fields||{},g=p[Qt]?.arrayValue,y=m[Qt]?.arrayValue,A=k(g?.values?.length||0,y?.values?.length||0);return A!==0?A:ir(g,y)})(r.mapValue,t.mapValue);case 11:return(function(s,l){if(s===$t&&l===$t)return 0;if(s===$t)return 1;if(l===$t)return-1;const p=s.fields||{},m=Object.keys(p),g=l.fields||{},y=Object.keys(g);m.sort(),y.sort();for(let A=0;A<m.length&&A<y.length;++A){const I=ye(m[A],y[A]);if(I!==0)return I;const b=Kt(p[m[A]],g[y[A]]);if(b!==0)return b}return k(m.length,y.length)})(r.mapValue,t.mapValue);default:throw V(23264,{C:e})}}function nr(r,t){if(typeof r=="string"&&typeof t=="string"&&r.length===t.length)return k(r,t);const e=ht(r),n=ht(t),i=k(e.seconds,n.seconds);return i!==0?i:k(e.nanos,n.nanos)}function ir(r,t){const e=r.values||[],n=t.values||[];for(let i=0;i<e.length&&i<n.length;++i){const s=Kt(e[i],n[i]);if(s)return s}return k(e.length,n.length)}function Wt(r,t){return{referenceValue:`projects/${r.projectId}/databases/${r.database}/documents/${t.path.canonicalString()}`}}function Dr(r){return!!r&&"arrayValue"in r}function sr(r){return!!r&&"nullValue"in r}function or(r){return!!r&&"doubleValue"in r&&isNaN(Number(r.doubleValue))}function _e(r){return!!r&&"mapValue"in r}function Pt(r){if(r.geoPointValue)return{geoPointValue:{...r.geoPointValue}};if(r.timestampValue&&typeof r.timestampValue=="object")return{timestampValue:{...r.timestampValue}};if(r.mapValue){const t={mapValue:{fields:{}}};return Ct(r.mapValue.fields,((e,n)=>t.mapValue.fields[e]=Pt(n))),t}if(r.arrayValue){const t={arrayValue:{values:[]}};for(let e=0;e<(r.arrayValue.values||[]).length;++e)t.arrayValue.values[e]=Pt(r.arrayValue.values[e]);return t}return{...r}}class Ht{constructor(t,e){this.position=t,this.inclusive=e}}function ar(r,t){if(r===null)return t===null;if(t===null||r.inclusive!==t.inclusive||r.position.length!==t.position.length)return!1;for(let e=0;e<r.position.length;e++)if(!Tt(r.position[e],t.position[e]))return!1;return!0}class kr{}class $ extends kr{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?e==="in"||e==="not-in"?this.createKeyFieldInFilter(t,e,n):new Hn(t,e,n):e==="array-contains"?new Xn(t,n):e==="in"?new Zn(t,n):e==="not-in"?new ti(t,n):e==="array-contains-any"?new ei(t,n):new $(t,e,n)}static createKeyFieldInFilter(t,e,n){return e==="in"?new Jn(t,n):new Yn(t,n)}matches(t){const e=t.data.field(this.field);return this.op==="!="?e!==null&&e.nullValue===void 0&&this.matchesComparison(Kt(e,this.value)):e!==null&&ft(this.value)===ft(e)&&this.matchesComparison(Kt(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return t===0;case"!=":return t!==0;case">":return t>0;case">=":return t>=0;default:return V(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class dt extends kr{constructor(t,e){super(),this.filters=t,this.op=e,this.N=null}static create(t,e){return new dt(t,e)}matches(t){return(function(n){return n.op==="and"})(this)?this.filters.find((e=>!e.matches(t)))===void 0:this.filters.find((e=>e.matches(t)))!==void 0}getFlattenedFilters(){return this.N!==null||(this.N=this.filters.reduce(((t,e)=>t.concat(e.getFlattenedFilters())),[])),this.N}getFilters(){return Object.assign([],this.filters)}}function Fr(r,t){return r instanceof $?(function(n,i){return i instanceof $&&n.op===i.op&&n.field.isEqual(i.field)&&Tt(n.value,i.value)})(r,t):r instanceof dt?(function(n,i){return i instanceof dt&&n.op===i.op&&n.filters.length===i.filters.length?n.filters.reduce(((s,l,p)=>
vendor: 12,144 bytes, line 1
1s&&Fr(l,i.filters[p])),!0):!1})(r,t):void V(19439)}class Hn extends ${constructor(t,e,n){super(t,e,n),this.key=S.fromName(n.referenceValue)}matches(t){const e=S.comparator(t.key,this.key);return this.matchesComparison(e)}}class Jn extends ${constructor(t,e){super(t,"in",e),this.keys=Or("in",e)}matches(t){return this.keys.some((e=>e.isEqual(t.key)))}}class Yn extends ${constructor(t,e){super(t,"not-in",e),this.keys=Or("not-in",e)}matches(t){return!this.keys.some((e=>e.isEqual(t.key)))}}function Or(r,t){return(t.arrayValue?.values||[]).map((e=>S.fromName(e.referenceValue)))}class Xn extends ${constructor(t,e){super(t,"array-contains",e)}matches(t){const e=t.data.field(this.field);return Dr(e)&&Ft(e.arrayValue,this.value)}}class Zn extends ${constructor(t,e){super(t,"in",e)}matches(t){const e=t.data.field(this.field);return e!==null&&Ft(this.value.arrayValue,e)}}class ti extends ${constructor(t,e){super(t,"not-in",e)}matches(t){if(Ft(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const e=t.data.field(this.field);return e!==null&&e.nullValue===void 0&&!Ft(this.value.arrayValue,e)}}class ei extends ${constructor(t,e){super(t,"array-contains-any",e)}matches(t){const e=t.data.field(this.field);return!(!Dr(e)||!e.arrayValue.values)&&e.arrayValue.values.some((n=>Ft(this.value.arrayValue,n)))}}class Jt{constructor(t,e="asc"){this.field=t,this.dir=e}}function ri(r,t){return r.dir===t.dir&&r.field.isEqual(t.field)}class D{static fromTimestamp(t){return new D(t)}static min(){return new D(new O(0,0))}static max(){return new D(new O(253402300799,999999999))}constructor(t){this.timestamp=t}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class Yt{constructor(t,e){this.comparator=t,this.root=e||C.EMPTY}insert(t,e){return new Yt(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,C.BLACK,null,null))}remove(t){return new Yt(this.comparator,this.root.remove(t,this.comparator).copy(null,null,C.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){const n=this.comparator(t,e.key);if(n===0)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){const i=this.comparator(t,n.key);if(i===0)return e+n.left.size;i<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal(((e,n)=>(t(e,n),!1)))}toString(){const t=[];return this.inorderTraversal(((e,n)=>(t.push(`${e}:${n}`),!1))),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new jt(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new jt(this.root,t,this.comparator,!1)}getReverseIterator(){return new jt(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new jt(this.root,t,this.comparator,!0)}}class jt{constructor(t,e,n,i){this.isReverse=i,this.nodeStack=[];let s=1;for(;!t.isEmpty();)if(s=e?n(t.key,e):1,e&&i&&(s*=-1),s<0)t=this.isReverse?t.left:t.right;else{if(s===0){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop();const e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class C{constructor(t,e,n,i,s){this.key=t,this.value=e,this.color=n??C.RED,this.left=i??C.EMPTY,this.right=s??C.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,i,s){return new C(t??this.key,e??this.value,n??this.color,i??this.left,s??this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let i=this;const s=n(t,i.key);return i=s<0?i.copy(null,null,null,i.left.insert(t,e,n),null):s===0?i.copy(null,e,null,null,null):i.copy(null,null,null,null,i.right.insert(t,e,n)),i.fixUp()}removeMin(){if(this.left.isEmpty())return C.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,e){let n,i=this;if(e(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,e),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),e(t,i.key)===0){if(i.right.isEmpty())return C.EMPTY;n=i.right.min(),i=i.copy(n.key,n.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,e))}return i.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=t.copy(null,null,null,null,t.right.rotateRight()),t=t.rotateLeft(),t=t.colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=t.rotateRight(),t=t.colorFlip()),t}rotateLeft(){const t=this.copy(null,null,C.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){const t=this.copy(null,null,C.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){const t=this.check();return Math.pow(2,t)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw V(43730,{key:this.key,value:this.value});if(this.right.isRed())throw V(14113,{key:this.key,value:this.value});const t=this.left.check();if(t!==this.right.check())throw V(27949);return t+(this.isRed()?0:1)}}C.EMPTY=null,C.RED=!0,C.BLACK=!1;C.EMPTY=new class{constructor(){this.size=0}get key(){throw V(57766)}get value(){throw V(16141)}get color(){throw V(16727)}get left(){throw V(29726)}get right(){throw V(36894)}copy(t,e,n,i,s){return this}insert(t,e,n){return new C(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class Ot{constructor(t){this.comparator=t,this.data=new Yt(this.comparator)}has(t){return this.data.get(t)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal(((e,n)=>(t(e),!1)))}forEachInRange(t,e){const n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,t[1])>=0)return;e(i.key)}}forEachWhile(t,e){let n;for(n=e!==void 0?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){const e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new ur(this.data.getIterator())}getIteratorFrom(t){return new ur(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach((n=>{e=e.add(n)})),e}isEqual(t){if(!(t instanceof Ot)||this.size!==t.size)return!1;const e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){const i=e.getNext().key,s=n.getNext().key;if(this.comparator(i,s)!==0)return!1}return!0}toArray(){const t=[];return this.forEach((e=>{t.push(e)})),t}toString(){const t=[];return this.forEach((e=>t.push(e))),"SortedSet("+t.toString()+")"}copy(t){const e=new Ot(this.comparator);return e.data=t,e}}class ur{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class pt{constructor(t){this.fields=t,t.sort(M.comparator)}static empty(){return new pt([])}unionWith(t){let e=new Ot(M.comparator);for(const n of this.fields)e=e.add(n);for(const n of t)e=e.add(n);return new pt(e.toArray())}covers(t){for(const e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return Ne(this.fields,t.fields,((e,n)=>e.isEqual(n)))}}class q{constructor(t){this.value=t}static empty(){return new q({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(e=(e.mapValue.fields||{})[t.get(n)],!_e(e))return null;return e=(e.mapValue.fields||{})[t.lastSegment()],e||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=Pt(e)}setAll(t){let e=M.emptyPath(),n={},i=[];t.forEach(((l,p)=>{if(!e.isImmediateParentOf(p)){const m=this.getFieldsMap(e);this.applyChanges(m,n,i),n={},i=[],e=p.popLast()}l?n[p.lastSegment()]=Pt(l):i.push(p.lastSegment())}));const s=this.getFieldsMap(e);this.applyChanges(s,n,i)}delete(t){const e=this.field(t.popLast());_e(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return Tt(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let i=e.mapValue.fields[t.get(n)];_e(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=i),e=i}return e.mapValue.fields}applyChanges(t,e,n){Ct(e,((i,s)=>t[i]=s));for(const i of n)delete t[i]}clone(){return new q(Pt(this.value))}}class X{constructor(t,e,n,i,s,l,p){this.key=t,this.documentType=e,this.version=n,this.readTime=i,this.createTime=s,this.data=l,this.documentState=p}static newInvalidDocument(t){return new X(t,0,D.min(),D.min(),D.min(),q.empty(),0)}static newFoundDocument(t,e,n,i){return new X(t,1,e,D.min(),n,i,0)}static newNoDocument(t,e){return new X(t,2,e,D.min(),D.min(),q.empty(),0)}static newUnknownDocument(t,e){return new X(t,3,e,D.min(),D.min(),q.empty(),2)}convertToFoundDocument(t,e){return!this.createTime.isEqual(D.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=t),this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=q.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=q.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=D.min(),this}setReadTime(t){return this.readTime=t,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof X&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new X(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}
1class ni{constructor(t,e=null,n=[],i=[],s=null,l=null,p=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=i,this.limit=s,this.startAt=l,this.endAt=p,this.O=null}}function lr(r,t=null,e=[],n=[],i=null,s=null,l=null){return new ni(r,t,e,n,i,s,l)}class _t{constructor(t,e=null,n=[],i=[],s=null,l="F",p=null,m=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=i,this.limit=s,this.limitType=l,this.startAt=p,this.endAt=m,this.q=null,this.L=null,this.B=null,this.startAt,this.endAt}}function Lr(r){return r.collectionGroup!==null}function Cr(r){const t=ct(r);if(t.q===null){t.q=[];const e=new Set;for(const s of t.explicitOrderBy)t.q.push(s),e.add(s.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";(function(l){let p=new Ot(M.comparator);return l.filters.forEach((m=>{m.getFlattenedFilters().forEach((g=>{g.isInequality()&&(p=p.add(g.field))}))})),p})(t).forEach((s=>{e.has(s.canonicalString())||s.isKeyField()||t.q.push(new Jt(s,n))})),e.has(M.keyField().canonicalString())||t.q.push(new Jt(M.keyField(),n))}return t.q}function Ae(r){const t=ct(r);return t.L||(t.L=Ur(t,Cr(r))),t.L}function Ur(r,t){if(r.limitType==="F")return lr(r.path,r.collectionGroup,t,r.filters,r.limit,r.startAt,r.endAt);{t=t.map((i=>{const s=i.dir==="desc"?"asc":"desc";return new Jt(i.field,s)}));const e=r.endAt?new Ht(r.endAt.position,r.endAt.inclusive):null,n=r.startAt?new Ht(r.startAt.position,r.startAt.inclusive):null;return lr(r.path,r.collectionGroup,t,r.filters,r.limit,e,n)}}function Ie(r,t){const e=r.filters.concat([t]);return new _t(r.path,r.collectionGroup,r.explicitOrderBy.slice(),e,r.limit,r.limitType,r.startAt,r.endAt)}function ii(r,t){return(function(n,i){if(n.limit!==i.limit||n.orderBy.length!==i.orderBy.length)return!1;for(let s=0;s<n.orderBy.length;s++)if(!ri(n.orderBy[s],i.orderBy[s]))return!1;if(n.filters.length!==i.filters.length)return!1;for(let s=0;s<n.filters.length;s++)if(!Fr(n.filters[s],i.filters[s]))return!1;return n.collectionGroup===i.collectionGroup&&!!n.path.isEqual(i.path)&&!!ar(n.startAt,i.startAt)&&ar(n.endAt,i.endAt)})(Ae(r),Ae(t))&&r.limitType===t.limitType}function xr(r,t){if(r.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:zt(t)?"-0":t}}function Mr(r,t){return(function(n){return typeof n=="number"&&Number.isInteger(n)&&!zt(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER})(t)?(function(n){return{integerValue:""+n}})(t):xr(r,t)}class ne{constructor(){this._=void 0}}class qr extends ne{}class Gr extends ne{constructor(t){super(),this.elements=t}}class $r extends ne{constructor(t){super(),this.elements=t}}class jr extends ne{constructor(t,e){super(),this.serializer=t,this.$=e}}class ie{constructor(t,e){this.field=t,this.transform=e}}class U{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new U}static exists(t){return new U(void 0,t)}static updateTime(t){return new U(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}class se{}class Br extends se{constructor(t,e,n,i=[]){super(),this.key=t,this.value=e,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class De extends se{constructor(t,e,n,i,s=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=i,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}class oe extends se{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class zr extends se{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}const si={asc:"ASCENDING",desc:"DESCENDING"},oi={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},ai={and:"AND",or:"OR"};class ui{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function Te(r,t){return r.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function li(r,t){return r.useProto3Json?t.toBase64():t.toUint8Array()}function ci(r,t){return Te(r,t.toTimestamp())}function Nt(r){return G(!!r,49232),D.fromTimestamp((function(e){const n=ht(e);return new O(n.seconds,n.nanos)})(r))}function ke(r,t){return we(r,t).canonicalString()}function we(r,t){const e=(function(i){return new N(["projects",i.projectId,"databases",i.database])})(r).child("documents");return t===void 0?e:e.child(t)}function Xt(r,t){return ke(r.databaseId,t.path)}function Ve(r,t){const e=(function(i){const s=N.fromString(i);return G(Wr(s),10190,{key:s.toString()}),s})(t);
1if(e.get(1)!==r.databaseId.projectId)throw new E(_.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+e.get(1)+" vs "+r.databaseId.projectId);if(e.get(3)!==r.databaseId.database)throw new E(_.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+e.get(3)+" vs "+r.databaseId.database);return new S((function(i){return G(i.length>4&&i.get(4)==="documents",29091,{key:i.toString()}),i.popFirst(5)})(e))}function cr(r,t,e){return{name:Xt(r,t),fields:e.value.mapValue.fields}}function hi(r,t){return"found"in t?(function(n,i){G(!!i.found,43571),i.found.name,i.found.updateTime;const s=Ve(n,i.found.name),l=Nt(i.found.updateTime),p=i.found.createTime?Nt(i.found.createTime):D.min(),m=new q({mapValue:{fields:i.found.fields}});return X.newFoundDocument(s,l,p,m)})(r,t):"missing"in t?(function(n,i){G(!!i.missing,3894),G(!!i.readTime,22933);const s=Ve(n,i.missing),l=Nt(i.readTime);return X.newNoDocument(s,l)})(r,t):V(7234,{result:t})}function fi(r,t){let e;if(t instanceof Br)e={update:cr(r,t.key,t.value)};else if(t instanceof oe)e={delete:Xt(r,t.key)};
1else if(t instanceof De)e={update:cr(r,t.key,t.data),updateMask:_i(t.fieldMask)};else{if(!(t instanceof zr))return V(16599,{U:t.type});e={verify:Xt(r,t.key)}}return t.fieldTransforms.length>0&&(e.updateTransforms=t.fieldTransforms.map((n=>(function(s,l){const p=l.transform;if(p instanceof qr)return{fieldPath:l.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(p instanceof Gr)return{fieldPath:l.field.canonicalString(),appendMissingElements:{values:p.elements}};if(p instanceof $r)return{fieldPath:l.field.canonicalString(),removeAllFromArray:{values:p.elements}};if(p instanceof jr)return{fieldPath:l.field.canonicalString(),increment:p.$};throw V(20930,{transform:l.transform})})(0,n)))),t.precondition.isNone||(e.currentDocument=(function(i,s){return s.updateTime!==void 0?{updateTime:ci(i,s.updateTime)}:s.exists!==void 0?{exists:s.exists}:V(27497)})(r,t.precondition)),e}function Qr(r,t){const e={structuredQuery:{}},n=t.path;let i;t.collectionGroup!==null?(i=n,e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=n.popLast(),e.structuredQuery.from=[{collectionId:n.lastSegment()}]),e.parent=(function(g,y){return ke(g.databaseId,y)})(r,i);const s=(function(g){if(g.length!==0)return Kr(dt.create(g,"and"))})(t.filters);s&&(e.structuredQuery.where=s);const l=(function(g){if(g.length!==0)return g.map((y=>(function(I){return{field:it(I.field),direction:di(I.dir)}})(y)))})(t.orderBy);l&&(e.structuredQuery.orderBy=l);const p=(function(g,y){return g.useProto3Json||Pr(y)?y:{value:y}})(r,t.limit);return p!==null&&(e.structuredQuery.limit=p),t.startAt&&(e.structuredQuery.startAt=(function(g){return{before:g.inclusive,values:g.position}})(t.startAt)),t.endAt&&(e.structuredQuery.endAt=(function(g){return{before:!g.inclusive,values:g.position}})(t.endAt)),{M:e,parent:i}}function di(r){return si[r]}function pi(r){return oi[r]}function mi(r){return ai[r]}function it(r){return{fieldPath:r.canonicalString()}}function Kr(r){return r instanceof $?(function(e){if(e.op==="=="){if(or(e.value))return{unaryFilter:{field:it(e.field),op:"IS_NAN"}};if(sr(e.value))return{unaryFilter:{field:it(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(or(e.value))return{unaryFilter:{field:it(e.field),op:"IS_NOT_NAN"}};if(sr(e.value))return{unaryFilter:{field:it(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:it(e.field),op:pi(e.op),value:e.value}}})(r):r instanceof dt?(function(e){const n=e.getFilters().map((i=>Kr(i)));return n.length===1?n[0]:{compositeFilter:{op:mi(e.op),filters:n}}})(r):V(54877,{filter:r})}function _i(r){const t=[];return r.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function Wr(r){return r.length>=4&&r.get(0)==="projects"&&r.get(2)==="databases"}function Hr(r){return!!r&&typeof r._toProto=="function"&&r._protoValueType==="ProtoValue"}function Fe(r){return new ui(r,!0)}class gi{}class yi extends gi{constructor(t,e,n,i){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=n,this.serializer=i,this.k=!1}j(){if(this.k)throw new E(_.FAILED_PRECONDITION,"The client has already been terminated.")}I(t,e,n,i){return this.j(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([s,l])=>this.connection.I(t,we(e,n),i,s,l))).catch((s=>{throw s.name==="FirebaseError"?(s.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),s):new E(_.UNKNOWN,s.toString())}))}D(t,e,n,i,s){return this.j(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([l,p])=>this.connection.D(t,we(e,n),i,l,p,s))).catch((l=>{throw l.name==="FirebaseError"?(l.code===_.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),l):new E(_.UNKNOWN,l.toString())}))}terminate(){this.k=!0,this.connection.terminate()}}async function Vt(r,t){const e=ct(r),n={writes:t.map((i=>fi(e.serializer,i)))};await e.I("Commit",e.serializer.databaseId,N.emptyPath(),n)}async function Jr(r,t){const e=ct(r),n={documents:t.map((p=>Xt(e.serializer,p)))},i=await e.D("BatchGetDocuments",e.serializer.databaseId,N.emptyPath(),n,t.length),s=new Map;
1i.forEach((p=>{const m=hi(e.serializer,p);s.set(m.key.toString(),m)}));const l=[];return t.forEach((p=>{const m=s.get(p.toString());G(!!m,55234,{key:p}),l.push(m)})),l}async function Ei(r,t){const e=ct(r),{M:n,parent:i}=Qr(e.serializer,Ae(t));return(await e.D("RunQuery",e.serializer.databaseId,i,{structuredQuery:n.structuredQuery})).filter((s=>!!s.document)).map((s=>(function(p,m,g){const y=Ve(p,m.name),A=Nt(m.updateTime),I=m.createTime?Nt(m.createTime):D.min(),b=new q({mapValue:{fields:m.fields}}),v=X.newFoundDocument(y,A,I,b);return g?v.setHasCommittedMutations():v})(e.serializer,s.document,void 0)))}async function Ai(r,t,e){const n=ct(r),{request:i,K:s,parent:l}=(function(y,A,I,b){const{M:v,parent:R}=Qr(y,A),w={},H=[];let At=0;return I.forEach((B=>{const tt="aggregate_"+At++;w[tt]=B.alias,B.aggregateType==="count"?H.push({alias:tt,count:{}}):B.aggregateType==="avg"?H.push({alias:tt,avg:{field:it(B.fieldPath)}}):B.aggregateType==="sum"&&H.push({alias:tt,sum:{field:it(B.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:H,structuredQuery:v.structuredQuery},parent:v.parent},K:w,parent:R}})(n.serializer,(function(y){const A=ct(y);return A.B||(A.B=Ur(A,y.explicitOrderBy)),A.B})(t),e);n.connection.T||delete i.parent;const p=(await n.D("RunAggregationQuery",n.serializer.databaseId,l,i,1)).filter((g=>!!g.result));G(p.length===1,64727);const m=p[0].result?.aggregateFields;return Object.keys(m).reduce(((g,y)=>(g[s[y]]=m[y],g)),{})}const Yr="ComponentProvider",St=new Map;function rt(r){if(r._terminated)throw new E(_.FAILED_PRECONDITION,"The client has already been terminated.");if(!St.has(r)){lt(Yr,"Initializing Datastore");const t=(function(s){return new Bn(s)})((function(s,l,p,m,g){return new Fn(s,l,p,g.host,g.ssl,g.experimentalForceLongPolling,g.experimentalAutoDetectLongPolling,Rr(g.experimentalLongPollingOptions),g.useFetchStreams,g.isUsingEmulator,m)})(r._databaseId,r.app.options.appId||"",r._persistenceKey,r.app.options.apiKey,r._freezeSettings())),e=Fe(r._databaseId),n=(function(s,l,p,m){return new yi(s,l,p,m)})(r._authCredentials,r._appCheckCredentials,t,e);St.set(r,n)}return St.get(r)}const Ii=1048576,Xr="firestore.googleapis.com",hr=!0;class fr{constructor(t){if(t.host===void 0){if(t.ssl!==void 0)throw new E(_.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Xr,this.ssl=hr}else this.host=t.host,this.ssl=t.ssl??hr;if(this.isUsingEmulator=t.emulatorOptions!==void 0,this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.localCache=t.localCache,t.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(t.cacheSizeBytes!==-1&&t.cacheSizeBytes<Ii)throw new E(_.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}(function(n,i,s,l){if(i===!0&&l===!0)throw new E(_.INVALID_ARGUMENT,`${n} and ${s} cannot be used together.`)})("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:t.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Rr(t.experimentalLongPollingOptions??{}),(function(n){if(n.timeoutSeconds!==void 0){if(isNaN(n.timeoutSeconds))throw new E(_.INVALID_ARGUMENT,`invalid long polling timeout: ${n.timeoutSeconds} (must not be NaN)`);if(n.timeoutSeconds<5)throw new E(_.INVALID_ARGUMENT,`invalid long polling timeout: ${n.timeoutSeconds} (minimum allowed value is 5)`);if(n.timeoutSeconds>30)throw new E(_.INVALID_ARGUMENT,`invalid long polling timeout: ${n.timeoutSeconds} (maximum allowed value is 30)`)}})(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&(function(n,i){return n.timeoutSeconds===i.timeoutSeconds})(this.experimentalLongPollingOptions,t.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class nt{constructor(t,e,n,i){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new fr({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new E(_.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(t){if(this._settingsFrozen)throw new E(_.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new fr(t),this._emulatorOptions=t.emulatorOptions||{},t.credentials!==void 0&&(this._authCredentials=(function(n){if(!n)return new Pn;switch(n.type){case"firstParty":return new Dn(n.sessionIndex||"0",n.iamToken||null,n.authTokenFactory||null);case"provider":return n.client;
1default:throw new E(_.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}})(t.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return(function(e){const n=St.get(e);n&&(lt(Yr,"Removing Datastore"),St.delete(e),n.terminate())})(this),Promise.resolve()}}function ji(r,t,e){e||(e=Bt);const n=Er(r,"firestore/lite");if(n.isInitialized(e))throw new E(_.FAILED_PRECONDITION,"Firestore can only be initialized once per app.");return n.initialize({options:t,instanceIdentifier:e})}function Bi(r,t){const e=typeof r=="object"?r:yn(),n=typeof r=="string"?r:t||"(default)",i=Er(e,"firestore/lite").getImmediate({identifier:n});if(!i._initialized){const s=En("firestore");s&&Ti(i,...s)}return i}function Ti(r,t,e,n={}){r=W(r,nt);const i=yr(t),s=r._getSettings(),l={...s,emulatorOptions:r._getEmulatorOptions()},p=`${t}:${e}`;i&&(mn(`https://${p}`),_n("Firestore",!0)),s.host!==Xr&&s.host!==p&&Ir("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const m={...s,host:p,ssl:i,emulatorOptions:n};if(!te(m,l)&&(r._setSettings(m),n.mockUserToken)){let g,y;if(typeof n.mockUserToken=="string")g=n.mockUserToken,y=x.MOCK_USER;else{g=gn(n.mockUserToken,r._app?.options.projectId);const A=n.mockUserToken.sub||n.mockUserToken.user_id;if(!A)throw new E(_.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");y=new x(A)}r._authCredentials=new Nn(new wr(g,y))}}function zi(r){return r=W(r,nt),In(r.app,"firestore/lite"),r._delete()}class j{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new j(this.firestore,t,this._query)}}class P{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new J(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new P(this.firestore,t,this._key)}toJSON(){return{type:P._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,e,n){if(Ut(e,P._jsonSchema))return new P(t,n||null,new S(N.fromString(e.referencePath)))}}P._jsonSchemaVersion="firestore/documentReference/1.0",P._jsonSchema={type:Q("string",P._jsonSchemaVersion),referencePath:Q("string")};class J extends j{constructor(t,e,n){super(t,e,(function(s){return new _t(s)})(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const t=this._path.popLast();return t.isEmpty()?null:new P(this.firestore,null,new S(t))}withConverter(t){return new J(this.firestore,t,this._path)}}function Qi(r,t,...e){if(r=L(r),Se("collection","path",t),r instanceof nt){const n=N.fromString(t,...e);return Ye(n),new J(r,null,n)}{if(!(r instanceof P||r instanceof J))throw new E(_.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(N.fromString(t,...e));return Ye(n),new J(r.firestore,null,n)}}function Ki(r,t){if(r=W(r,nt),Se("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new E(_.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new j(r,null,(function(n){return new _t(N.emptyPath(),n)})(t))}function wi(r,t,...e){if(r=L(r),arguments.length===1&&(t=Cn.newId()),Se("doc","path",t),r instanceof nt){const n=N.fromString(t,...e);return Je(n),new P(r,null,new S(n))}
1{if(!(r instanceof P||r instanceof J))throw new E(_.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const n=r._path.child(N.fromString(t,...e));return Je(n),new P(r.firestore,r instanceof J?r.converter:null,new S(n))}}function Wi(r,t){return r=L(r),t=L(t),(r instanceof P||r instanceof J)&&(t instanceof P||t instanceof J)&&r.firestore===t.firestore&&r.path===t.path&&r.converter===t.converter}function Zr(r,t){return r=L(r),t=L(t),r instanceof j&&t instanceof j&&r.firestore===t.firestore&&ii(r._query,t._query)&&r.converter===t.converter}class z{constructor(t){this._byteString=t}static fromBase64String(t){try{return new z(et.fromBase64String(t))}catch(e){throw new E(_.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(t){return new z(et.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}toJSON(){return{type:z._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(Ut(t,z._jsonSchema))return z.fromBase64String(t.bytes)}}z._jsonSchemaVersion="firestore/bytes/1.0",z._jsonSchema={type:Q("string",z._jsonSchemaVersion),bytes:Q("string")};class vt{constructor(...t){for(let e=0;e<t.length;++e)if(t[e].length===0)throw new E(_.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new M(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function Hi(){return new vt(Ee)}class gt{constructor(t){this._methodName=t}}class Z{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new E(_.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new E(_.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}_compareTo(t){return k(this._lat,t._lat)||k(this._long,t._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:Z._jsonSchemaVersion}}static fromJSON(t){if(Ut(t,Z._jsonSchema))return new Z(t.latitude,t.longitude)}}Z._jsonSchemaVersion="firestore/geoPoint/1.0",Z._jsonSchema={type:Q("string",Z._jsonSchemaVersion),latitude:Q("number"),longitude:Q("number")};class K{constructor(t){this._values=(t||[]).map((e=>e))}toArray(){return this._values.map((t=>t))}isEqual(t){return(function(n,i){if(n.length!==i.length)return!1;for(let s=0;s<n.length;++s)if(n[s]!==i[s])return!1;return!0})(this._values,t._values)}toJSON(){return{type:K._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(Ut(t,K._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e=="number")))return new K(t.vectorValues);throw new E(_.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}K._jsonSchemaVersion="firestore/vectorValue/1.0",K._jsonSchema={type:Q("string",K._jsonSchemaVersion),vectorValues:Q("object")};const Vi=/^__.*__$/;class vi{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return this.fieldMask!==null?new De(t,this.data,this.fieldMask,e,this.fieldTransforms):new Br(t,this.data,e,this.fieldTransforms)}}class tn{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return new De(t,this.data,this.fieldMask,e,this.fieldTransforms)}}function en(r){switch(r){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw V(40011,{dataSource:r})}}class ae{constructor(t,e,n,i,s,l){this.settings=t,this.databaseId=e,this.serializer=n,this.ignoreUndefinedProperties=i,s===void 0&&this.validatePath(),this.fieldTransforms=s||[],this.fieldMask=l||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(t){return new ae({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(t){const e=this.path?.child(t),n=this.contextWith({path:e,arrayElement:!1});return n.validatePathSegment(t),n}childContextForFieldPath(t){const e=this.path?.child(t),n=this.contextWith({path:e,arrayElement:!1});return n.validatePath(),n}childContextForArray(t){return this.contextWith({path:void 0,arrayElement:!0})}createError(t){return Zt(t,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(t){return this.fieldMask.find((e=>t.isPrefixOf(e)))!==void 0||this.fieldTransforms.find((e=>t.isPrefixOf(e.field)))!==void 0}validatePath(){if(this.path)for(let t=0;t<this.path.length;t++)this.validatePathSegment(this.path.get(t))}validatePathSegment(t){if(t.length===0)throw this.createError("Document fields must not be empty");if(en(this.dataSource)&&Vi.test(t))throw this.createError('Document fields cannot begin and end with "__"')}}class Ri{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer
1=n||Fe(t)}createContext(t,e,n,i=!1){return new ae({dataSource:t,methodName:e,targetDoc:n,path:M.emptyPath(),arrayElement:!1,hasConverter:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function yt(r){const t=r._freezeSettings(),e=Fe(r._databaseId);return new Ri(r._databaseId,!!t.ignoreUndefinedProperties,e)}function ue(r,t,e,n,i,s={}){const l=r.createContext(s.merge||s.mergeFields?2:0,t,e,i);qe("Data must be an object, but it was:",l,n);const p=sn(n,l);let m,g;if(s.merge)m=new pt(l.fieldMask),g=l.fieldTransforms;else if(s.mergeFields){const y=[];for(const A of s.mergeFields){const I=st(t,A,e);if(!l.contains(I))throw new E(_.INVALID_ARGUMENT,`Field '${I}' is specified in your field mask but missing from your input data.`);un(y,I)||y.push(I)}m=new pt(y),g=l.fieldTransforms.filter((A=>m.covers(A.field)))}else m=null,g=l.fieldTransforms;return new vi(new q(p),m,g)}class xt extends gt{_toFieldTransform(t){if(t.dataSource!==2)throw t.dataSource===1?t.createError(`${this._methodName}() can only appear at the top level of your update data`):t.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return t.fieldMask.push(t.path),null}isEqual(t){return t instanceof xt}}function rn(r,t,e){return new ae({dataSource:3,targetDoc:t.settings.targetDoc,methodName:r._methodName,arrayElement:e},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class Oe extends gt{_toFieldTransform(t){return new ie(t.path,new qr)}isEqual(t){return t instanceof Oe}}class Le extends gt{constructor(t,e){super(t),this.G=e}_toFieldTransform(t){const e=rn(this,t,!0),n=this.G.map((s=>Et(s,e))),i=new Gr(n);return new ie(t.path,i)}isEqual(t){return t instanceof Le&&te(this.G,t.G)}}class Ce extends gt{constructor(t,e){super(t),this.G=e}_toFieldTransform(t){const e=rn(this,t,!0),n=this.G.map((s=>Et(s,e))),i=new $r(n);return new ie(t.path,i)}isEqual(t){return t instanceof Ce&&te(this.G,t.G)}}class Ue extends gt{constructor(t,e){super(t),this.W=e}_toFieldTransform(t){const e=new jr(t.serializer,Mr(t.serializer,this.W));return new ie(t.path,e)}isEqual(t){return t instanceof Ue&&this.W===t.W}}function xe(r,t,e,n){const i=r.createContext(1,t,e);qe("Data must be an object, but it was:",i,n);const s=[],l=q.empty();Ct(n,((m,g)=>{const y=an(t,m,e);g=L(g);const A=i.childContextForFieldPath(y);if(g instanceof xt)s.push(y);else{const I=Et(g,A);I!=null&&(s.push(y),l.set(y,I))}}));const p=new pt(s);return new tn(l,p,i.fieldTransforms)}function Me(r,t,e,n,i,s){const l=r.createContext(1,t,e),p=[st(t,n,e)],m=[i];if(s.length%2!=0)throw new E(_.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let I=0;I<s.length;I+=2)p.push(st(t,s[I])),m.push(s[I+1]);const g=[],y=q.empty();for(let I=p.length-1;I>=0;--I)if(!un(g,p[I])){const b=p[I];let v=m[I];v=L(v);const R=l.childContextForFieldPath(b);if(v instanceof xt)g.push(b);else{const w=Et(v,R);w!=null&&(g.push(b),y.set(b,w))}}const A=new pt(g);return new tn(y,A,l.fieldTransforms)}function nn(r,t,e,n=!1){return Et(e,r.createContext(n?4:3,t))}function Et(r,t){if(on(r=L(r)))return qe("Unsupported field value:",t,r),sn(r,t);if(r instanceof gt)return(function(n,i){if(!en(i.dataSource))throw i.createError(`${n._methodName}() can only be used with update() and set()`);if(!i.path)throw i.createError(`${n._methodName}() is not currently supported inside arrays`);const s=n._toFieldTransform(i);s&&i.fieldTransforms.push(s)})(r,t),null;if(r===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),r instanceof Array){if(t.settings.arrayElement&&t.dataSource!==4)throw t.createError("Nested arrays are not supported");return(function(n,i){const s=[];let l=0;for(const p of n){let m=Et(p,i.childContextForArray(l));m==null&&(m={nullValue:"NULL_VALUE"}),s.push(m),l++}return{arrayValue:{values:s}}})(r,t)}return(function(n,i){if((n=L(n))===null)return{nullValue:"NULL_VALUE"};if(typeof n=="number")return Mr(i.serializer,n);if(typeof n=="boolean")return{booleanValue:n};if(typeof n=="string")return{stringValue:n};if(n instanceof Date){const s=O.fromDate(n);
1return{timestampValue:Te(i.serializer,s)}}if(n instanceof O){const s=new O(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:Te(i.serializer,s)}}if(n instanceof Z)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof z)return{bytesValue:li(i.serializer,n._byteString)};if(n instanceof P){const s=i.databaseId,l=n.firestore._databaseId;if(!l.isEqual(s))throw i.createError(`Document reference is for database ${l.projectId}/${l.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:ke(n.firestore._databaseId||i.databaseId,n._key.path)}}if(n instanceof K)return(function(l,p){const m=l instanceof K?l.toArray():l;return{mapValue:{fields:{[Sr]:{stringValue:br},[Qt]:{arrayValue:{values:m.map((y=>{if(typeof y!="number")throw p.createError("VectorValues must only contain numeric values.");return xr(p.serializer,y)}))}}}}}})(n,i);if(Hr(n))return n._toProto(i.serializer);throw i.createError(`Unsupported field value: ${re(n)}`)})(r,t)}function sn(r,t){const e={};return(function(i){for(const s in i)if(Object.prototype.hasOwnProperty.call(i,s))return!1;return!0})(r)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Ct(r,((n,i)=>{const s=Et(i,t.childContextForField(n));s!=null&&(e[n]=s)})),{mapValue:{fields:e}}}function on(r){return!(typeof r!="object"||r===null||r instanceof Array||r instanceof Date||r instanceof O||r instanceof Z||r instanceof z||r instanceof P||r instanceof gt||r instanceof K||Hr(r))}function qe(r,t,e){if(!on(e)||!Vr(e)){const n=re(e);throw n==="an object"?t.createError(r+" a custom object"):t.createError(r+" "+n)}}function st(r,t,e){if((t=L(t))instanceof vt)return t._internalPath;if(typeof t=="string")return an(r,t);throw Zt("Field path arguments must be of type string or ",r,!1,void 0,e)}const Pi=new RegExp("[~\\*/\\[\\]]");function an(r,t,e){if(t.search(Pi)>=0)throw Zt(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,r,!1,void 0,e);try{return new vt(...t.split("."))._internalPath}catch{throw Zt(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,r,!1,void 0,e)}}function Zt(r,t,e,n,i){const s=n&&!n.isEmpty(),l=i!==void 0;let p=`Function ${t}() called with invalid data`;e&&(p+=" (via `toFirestore()`)"),p+=". ";let m="";return(s||l)&&(m+=" (found",s&&(m+=` in field ${n}`),l&&(m+=` in document ${i}`),m+=")"),new E(_.INVALID_ARGUMENT,p+r+m)}function un(r,t){return r.some((e=>e.isEqual(t)))}class mt{constructor(t,e,n,i,s){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=i,this._converter=s}get id(){return this._key.path.lastSegment()}get ref(){return new P(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const t=new ln(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(t){if(this._document){const e=this._document.data.field(st("DocumentSnapshot.get",t));if(e!==null)return this._userDataWriter.convertValue(e)}}}class ln extends mt{data(){return super.data()}}class ve{constructor(t,e){this._docs=e,this.query=t}get docs(){return[...this._docs]}get size(){return this.docs.length}get empty(){return this.docs.length===0}forEach(t,e){this._docs.forEach(t,e)}}function Ni(r,t){return r=L(r),t=L(t),r instanceof mt&&t instanceof mt?r._firestore===t._firestore&&r._key.isEqual(t._key)&&(r._document===null?t._document===null:r._document.isEqual(t._document))&&r._converter===t._converter:r instanceof ve&&t instanceof ve&&Zr(r.query,t.query)&&Ne(r.docs,t.docs,Ni)}class Ge{}class Mt extends Ge{}function Ji(r,t,...e){let n=[];t instanceof Ge&&n.push(t),n=n.concat(e),(function(s){const l=s.filter((m=>m instanceof Rt)).length,p=s.filter((m=>m instanceof qt)).length;if(l>1||l>0&&p>0)throw new E(_.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")})(n);for(const i of n)r=i._apply(r);return r}class qt extends Mt{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new qt(t,e,n)}_apply(t){const e=this._parse(t);return hn(t._query,e),new j(t.firestore,t.converter,Ie(t._query,e))}_parse(t){const e=yt(t.firestore);return(function(s,l,p,m,g,y,A){let I;
1if(g.isKeyField()){if(y==="array-contains"||y==="array-contains-any")throw new E(_.INVALID_ARGUMENT,`Invalid Query. You can't perform '${y}' queries on documentId().`);if(y==="in"||y==="not-in"){pr(A,y);const v=[];for(const R of A)v.push(dr(m,s,R));I={arrayValue:{values:v}}}else I=dr(m,s,A)}else y!=="in"&&y!=="not-in"&&y!=="array-contains-any"||pr(A,y),I=nn(p,l,A,y==="in"||y==="not-in");return $.create(g,y,I)})(t._query,"where",e,t.firestore._databaseId,this._field,this._op,this._value)}}function Yi(r,t,e){const n=t,i=st("where",r);return qt._create(i,n,e)}class Rt extends Ge{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new Rt(t,e)}_parse(t){const e=this._queryConstraints.map((n=>n._parse(t))).filter((n=>n.getFilters().length>0));return e.length===1?e[0]:dt.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return e.getFilters().length===0?t:((function(i,s){let l=i;const p=s.getFlattenedFilters();for(const m of p)hn(l,m),l=Ie(l,m)})(t._query,e),new j(t.firestore,t.converter,Ie(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}function Xi(...r){return r.forEach((t=>fn("or",t))),Rt._create("or",r)}function Zi(...r){return r.forEach((t=>fn("and",t))),Rt._create("and",r)}class $e extends Mt{constructor(t,e){super(),this._field=t,this._direction=e,this.type="orderBy"}static _create(t,e){return new $e(t,e)}_apply(t){const e=(function(i,s,l){if(i.startAt!==null)throw new E(_.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(i.endAt!==null)throw new E(_.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new Jt(s,l)})(t._query,this._field,this._direction);return new j(t.firestore,t.converter,(function(i,s){const l=i.explicitOrderBy.concat([s]);return new _t(i.path,i.collectionGroup,l,i.filters.slice(),i.limit,i.limitType,i.startAt,i.endAt)})(t._query,e))}}function ts(r,t="asc"){const e=t,n=st("orderBy",r);return $e._create(n,e)}class le extends Mt{constructor(t,e,n){super(),this.type=t,this._limit=e,this._limitType=n}static _create(t,e,n){return new le(t,e,n)}_apply(t){return new j(t.firestore,t.converter,(function(n,i,s){return new _t(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),i,s,n.startAt,n.endAt)})(t._query,this._limit,this._limitType))}}function es(r){return vr("limit",r),le._create("limit",r,"F")}function rs(r){return vr("limitToLast",r),le._create("limitToLast",r,"L")}class ce extends Mt{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new ce(t,e,n)}_apply(t){const e=cn(t,this.type,this._docOrFields,this._inclusive);return new j(t.firestore,t.converter,(function(i,s){return new _t(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,s,i.endAt)})(t._query,e))}}function ns(...r){return ce._create("startAt",r,!0)}function is(...r){return ce._create("startAfter",r,!1)}class he extends Mt{constructor(t,e,n){super(),this.type=t,this._docOrFields=e,this._inclusive=n}static _create(t,e,n){return new he(t,e,n)}_apply(t){const e=cn(t,this.type,this._docOrFields,this._inclusive);return new j(t.firestore,t.converter,(function(i,s){return new _t(i.path,i.collectionGroup,i.explicitOrderBy.slice(),i.filters.slice(),i.limit,i.limitType,i.startAt,s)})(t._query,e))}}function ss(...r){return he._create("endBefore",r,!1)}function os(...r){return he._create("endAt",r,!0)}function cn(r,t,e,n){if(e[0]=L(e[0]),e[0]instanceof mt)return(function(s,l,p,m,g){if(!m)throw new E(_.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${p}().`);const y=[];for(const A of Cr(s))if(A.field.isKeyField())y.push(Wt(l,m.key));else{const I=m.data.field(A.field);if(be(I))throw new E(_.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+A.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(I===null){const b=A.field.canonicalString();
1throw new E(_.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${b}' (used as the orderBy) does not exist.`)}y.push(I)}return new Ht(y,g)})(r._query,r.firestore._databaseId,t,e[0]._document,n);{const i=yt(r.firestore);return(function(l,p,m,g,y,A){const I=l.explicitOrderBy;if(y.length>I.length)throw new E(_.INVALID_ARGUMENT,`Too many arguments provided to ${g}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const b=[];for(let v=0;v<y.length;v++){const R=y[v];if(I[v].field.isKeyField()){if(typeof R!="string")throw new E(_.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${g}(), but got a ${typeof R}`);if(!Lr(l)&&R.indexOf("/")!==-1)throw new E(_.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${g}() must be a plain document ID, but '${R}' contains a slash.`);const w=l.path.child(N.fromString(R));if(!S.isDocumentKey(w))throw new E(_.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${g}() must result in a valid document path, but '${w}' is not because it contains an odd number of segments.`);const H=new S(w);b.push(Wt(p,H))}else{const w=nn(m,g,R);b.push(w)}}return new Ht(b,A)})(r._query,r.firestore._databaseId,i,t,e,n)}}function dr(r,t,e){if(typeof(e=L(e))=="string"){if(e==="")throw new E(_.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Lr(t)&&e.indexOf("/")!==-1)throw new E(_.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${e}' contains a '/' character.`);const n=t.path.child(N.fromString(e));if(!S.isDocumentKey(n))throw new E(_.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);return Wt(r,new S(n))}if(e instanceof P)return Wt(r,e._key);throw new E(_.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${re(e)}.`)}function pr(r,t){if(!Array.isArray(r)||r.length===0)throw new E(_.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function hn(r,t){const e=(function(i,s){for(const l of i)for(const p of l.getFlattenedFilters())if(s.indexOf(p.op)>=0)return p.op;return null})(r.filters,(function(i){switch(i){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}})(t.op));if(e!==null)throw e===t.op?new E(_.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new E(_.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${e.toString()}' filters.`)}function fn(r,t){if(!(t instanceof qt||t instanceof Rt))throw new E(_.INVALID_ARGUMENT,`Function ${r}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class Si{convertValue(t,e="none"){switch(ft(t)){case 0:return null;case 1:return t.booleanValue;case 2:return F(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(Dt(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 11:return this.convertObject(t.mapValue,e);case 10:return this.convertVectorValue(t.mapValue);default:throw V(62114,{value:t})}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){const n={};return Ct(t,((i,s)=>{n[i]=this.convertValue(s,e)})),n}convertVectorValue(t){const e=t.fields?.[Qt].arrayValue?.values?.map((n=>F(n.doubleValue)));return new K(e)}convertGeoPoint(t){return new Z(F(t.latitude),F(t.longitude))}convertArray(t,e){return(t.values||[]).map((n=>this.convertValue(n,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=Nr(t);return n==null?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(kt(t));default:return null}}convertTimestamp(t){const e=ht(t);return new O(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=N.fromString(t);G(Wr(n),9688,{name:t});const i=new bt(n.get(1),n.get(3)),s=new S(n.popFirst(5));return i.isEqual(e)||ee(`Document ${s} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),s}}function fe(r,t,e){let n;return n=r?e&&(e.merge||e.mergeFields)?r.toFirestore(t,e):r.toFirestore(t):t,n}class de extends Si{constructor(t){super(),this.firestore=t}convertBytes(t){return new z(t)}convertReference(t){const e=this.convertDocumentKey(t,this.firestore._databaseId);
1return new P(this.firestore,null,e)}}function as(r){const t=rt((r=W(r,P)).firestore),e=new de(r.firestore);return Jr(t,[r._key]).then((n=>{G(n.length===1,15618);const i=n[0];return new mt(r.firestore,e,r._key,i.isFoundDocument()?i:null,r.converter)}))}function us(r){(function(i){if(i.limitType==="L"&&i.explicitOrderBy.length===0)throw new E(_.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")})((r=W(r,j))._query);const t=rt(r.firestore),e=new de(r.firestore);return Ei(t,r._query).then((n=>{const i=n.map((s=>new ln(r.firestore,e,s.key,s,r.converter)));return r._query.limitType==="L"&&i.reverse(),new ve(r,i)}))}function ls(r,t,e){const n=fe((r=W(r,P)).converter,t,e),i=ue(yt(r.firestore),"setDoc",r._key,n,r.converter!==null,e);return Vt(rt(r.firestore),[i.toMutation(r._key,U.none())])}function cs(r,t,e,...n){const i=yt((r=W(r,P)).firestore);let s;return s=typeof(t=L(t))=="string"||t instanceof vt?Me(i,"updateDoc",r._key,t,e,n):xe(i,"updateDoc",r._key,t),Vt(rt(r.firestore),[s.toMutation(r._key,U.exists(!0))])}function hs(r){return Vt(rt((r=W(r,P)).firestore),[new oe(r._key,U.none())])}function fs(r,t){const e=wi(r=W(r,J)),n=fe(r.converter,t),i=ue(yt(r.firestore),"addDoc",e._key,n,e.converter!==null,{});return Vt(rt(r.firestore),[i.toMutation(e._key,U.exists(!1))]).then((()=>e))}function ds(){return new xt("deleteField")}function ps(){return new Oe("serverTimestamp")}function ms(...r){return new Le("arrayUnion",r)}function _s(...r){return new Ce("arrayRemove",r)}function gs(r){return new Ue("increment",r)}function ys(r){return new K(r)}const mr="4.12.0";class je{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}class bi{constructor(t,e,n){this.alias=t,this.aggregateType=e,this.fieldPath=n}}class dn{constructor(t,e,n=1e3,i=1.5,s=6e4){this.t=t,this.timerId=e,this.i=n,this.o=i,this.h=s,this.u=0,this.l=null,this._=Date.now(),this.reset()}reset(){this.u=0}m(){this.u=this.h}A(t){this.cancel();const e=Math.floor(this.u+this.p()),n=Math.max(0,Date.now()-this._),i=Math.max(0,e-n);i>0&<("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.u} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.l=this.t.enqueueAfterDelay(this.timerId,i,(()=>(this._=Date.now(),t()))),this.u*=this.o,this.u<this.i&&(this.u=this.i),this.u>this.h&&(this.u=this.h)}T(){this.l!==null&&(this.l.skipDelay(),this.l=null)}cancel(){this.l!==null&&(this.l.cancel(),this.l=null)}p(){return(Math.random()-.5)*this.u}}class Lt{constructor(t="count",e){this._internalFieldPath=e,this.type="AggregateField",this.aggregateType=t}}class Di{constructor(t,e,n){this._userDataWriter=e,this._data=n,this.type="AggregateQuerySnapshot",this.query=t}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new q({mapValue:{fields:this._data}}).clone().value.mapValue.fields}}function Es(r){return ki(r,{count:Fi()})}function ki(r,t){const e=W(r.firestore,nt),n=rt(e),i=zn(t,((s,l)=>new bi(l,s.aggregateType,s._internalFieldPath)));return Ai(n,r._query,i).then((s=>(function(p,m,g){const y=new de(p);return new Di(m,y,g)})(e,r,s)))}function As(r){return new Lt("sum",st("sum",r))}function Is(r){return new Lt("avg",st("average",r))}function Fi(){return new Lt("count")}function Ts(r,t){return r instanceof Lt&&t instanceof Lt&&r.aggregateType===t.aggregateType&&r._internalFieldPath?.canonicalString()===t._internalFieldPath?.canonicalString()}function ws(r,t){return Zr(r.query,t.query)&&te(r.data(),t.data())}class Oi{constructor(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=yt(t)}set(t,e,n){this._verifyNotCommitted();const i=at(t,this._firestore),s=fe(i.converter,e,n),l=ue(this._dataReader,"WriteBatch.set",i._key,s,i.converter!==null,n);return this._mutations.push(l.toMutation(i._key,U.none())),this}update(t,e,n,...i){this._verifyNotCommitted();const s=at(t,this._firestore);let l;return l=typeof(e=L(e))=="string"||e instanceof vt?Me(this._dataReader,"WriteBatch.update",s._key,e,n,i):xe(this._dataReader,"WriteBatch.update",s._key,e),this._mutations.push(l.toMutation(s._key,U.exists(!0))),this}delete(t){this._verifyNotCommitted();const e=at(t,this._firestore);return this._mutations=this._mutations.concat(new oe(e._key,U.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new E(_.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}
1function at(r,t){if((r=L(r)).firestore!==t)throw new E(_.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return r}function Vs(r){r=W(r,nt);const t=rt(r);return new Oi(r,(e=>Vt(t,e)))}class Li{constructor(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(t){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new E(_.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const e=await Jr(this.datastore,t);return e.forEach((n=>this.recordVersion(n))),e}set(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())}update(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(n){this.lastTransactionError=n}this.writtenDocs.add(t.toString())}delete(t){this.write(new oe(t,this.precondition(t))),this.writtenDocs.add(t.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const t=this.readVersions;this.mutations.forEach((e=>{t.delete(e.key.toString())})),t.forEach(((e,n)=>{const i=S.fromPath(n);this.mutations.push(new zr(i,this.precondition(i)))})),await Vt(this.datastore,this.mutations),this.committed=!0}recordVersion(t){let e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw V(50498,{R:t.constructor.name});e=D.min()}const n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new E(_.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)}precondition(t){const e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?e.isEqual(D.min())?U.exists(!1):U.updateTime(e):U.none()}preconditionForUpdate(t){const e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(D.min()))throw new E(_.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return U.updateTime(e)}return U.exists(!0)}write(t){this.ensureCommitNotCalled(),this.mutations.push(t)}ensureCommitNotCalled(){}}const Ci={maxAttempts:5};class Ui{constructor(t,e,n,i,s){this.asyncQueue=t,this.datastore=e,this.options=n,this.updateFunction=i,this.deferred=s,this.I=n.maxAttempts,this.P=new dn(this.asyncQueue,"transaction_retry")}V(){this.I-=1,this.D()}D(){this.P.A((async()=>{const t=new Li(this.datastore),e=this.F(t);e&&e.then((n=>{this.asyncQueue.enqueueAndForget((()=>t.commit().then((()=>{this.deferred.resolve(n)})).catch((i=>{this.v(i)}))))})).catch((n=>{this.v(n)}))}))}F(t){try{const e=this.updateFunction(t);return!Pr(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}v(t){this.I>0&&this.B(t)?(this.I-=1,this.asyncQueue.enqueueAndForget((()=>(this.D(),Promise.resolve())))):this.deferred.reject(t)}B(t){if(t?.name==="FirebaseError"){const e=t.code;return e==="aborted"||e==="failed-precondition"||e==="already-exists"||!jn(e)}return!1}}function ge(){return typeof document<"u"?document:null}class Be{constructor(t,e,n,i,s){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=i,this.removalCallback=s,this.deferred=new je,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((l=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(t,e,n,i,s){const l=Date.now()+n,p=new Be(t,e,l,i,s);return p.start(n),p}start(t){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new E(_.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
1)}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then((t=>this.deferred.resolve(t)))):Promise.resolve()))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}const _r="AsyncQueue";class xi{constructor(t=Promise.resolve()){this.k=[],this.q=!1,this.O=[],this.S=null,this.C=!1,this.M=!1,this.N=[],this.P=new dn(this,"async_queue_retry"),this.L=()=>{const n=ge();n&<(_r,"Visibility state changed to "+n.visibilityState),this.P.T()},this.W=t;const e=ge();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.L)}get isShuttingDown(){return this.q}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.U(),this.$(t)}enterRestrictedMode(t){if(!this.q){this.q=!0,this.M=t||!1;const e=ge();e&&typeof e.removeEventListener=="function"&&e.removeEventListener("visibilitychange",this.L)}}enqueue(t){if(this.U(),this.q)return new Promise((()=>{}));const e=new je;return this.$((()=>this.q&&this.M?Promise.resolve():(t().then(e.resolve,e.reject),e.promise))).then((()=>e.promise))}enqueueRetryable(t){this.enqueueAndForget((()=>(this.k.push(t),this.j())))}async j(){if(this.k.length!==0){try{await this.k[0](),this.k.shift(),this.P.reset()}catch(t){if(!(function(n){return n.name==="IndexedDbTransactionError"})(t))throw t;lt(_r,"Operation failed with retryable error: "+t)}this.k.length>0&&this.P.A((()=>this.j()))}}$(t){const e=this.W.then((()=>(this.C=!0,t().catch((n=>{this.S=n,this.C=!1;const i=gr(n);throw ee("INTERNAL UNHANDLED ERROR: ",i),n})).then((n=>(this.C=!1,n))))));return this.W=e,e}enqueueAfterDelay(t,e,n){this.U(),this.N.indexOf(t)>-1&&(e=0);const i=Be.createAndSchedule(this,t,e,n,(s=>this.G(s)));return this.O.push(i),i}U(){this.S&&V(47125,{H:gr(this.S)})}verifyOperationInProgress(){}async J(){let t;do t=this.W,await t;while(t!==this.W)}K(t){for(const e of this.O)if(e.timerId===t)return!0;return!1}X(t){return this.J().then((()=>{this.O.sort(((e,n)=>e.targetTimeMs-n.targetTimeMs));for(const e of this.O)if(e.skipDelay(),t!=="all"&&e.timerId===t)break;return this.J()}))}Y(t){this.N.push(t)}G(t){const e=this.O.indexOf(t);this.O.splice(e,1)}}function gr(r){let t=r.message||"";return r.stack&&(t=r.stack.includes(r.message)?r.stack:r.message+` 2`+r.stack),t}class Mi{constructor(t,e){this._firestore=t,this._transaction=e,this._dataReader=yt(t)}get(t){const e=at(t,this._firestore),n=new de(this._firestore);return this._transaction.lookup([e._key]).then((i=>{if(!i||i.length!==1)return V(24041);const s=i[0];if(s.isFoundDocument())return new mt(this._firestore,n,s.key,s,e.converter);if(s.isNoDocument())return new mt(this._firestore,n,e._key,null,e.converter);throw V(18433,{doc:s})}))}set(t,e,n){const i=at(t,this._firestore),s=fe(i.converter,e,n),l=ue(this._dataReader,"Transaction.set",i._key,s,i.converter!==null,n);return this._transaction.set(i._key,l),this}update(t,e,n,...i){const s=at(t,this._firestore);let l;return l=typeof(e=L(e))=="string"||e instanceof vt?Me(this._dataReader,"Transaction.update",s._key,e,n,i):xe(this._dataReader,"Transaction.update",s._key,e),this._transaction.update(s._key,l),this}delete(t){const e=at(t,this._firestore);return this._transaction.delete(e._key),this}}function vs(r,t,e){r=W(r,nt);const n=rt(r),i={...Ci,...e};(function(p){if(p.maxAttempts<1)throw new E(_.INVALID_ARGUMENT,"Max attempts must be at least 1")})(i);const s=new je;return new Ui((function(){return new xi})(),n,i,(l=>t(new Mi(r,l))),s).V(),s.promise}(function(){Rn(`${vn}_lite`),wn(new Vn("firestore/lite",((t,{instanceIdentifier:e,options:n})=>{const i=t.getProvider("app").getImmediate(),s=new nt(new Sn(t.getProvider("auth-internal")),new kn(i,t.getProvider("app-check-internal")),On(i,e),i);return n&&s._setSettings(n),s}),"PUBLIC").setMultipleInstances(!0)),Ke("firestore-lite",mr,""),Ke("firestore-lite",mr,"esm2020")})();export{Lt as AggregateField,Di as AggregateQuerySnapshot,z as Bytes,J as CollectionReference,P as DocumentReference,mt as DocumentSnapshot,vt as FieldPath,gt as FieldValue,nt as Firestore,E as FirestoreError,Z as GeoPoint,j as Query,Rt as QueryCompositeFilterConstraint,Mt as QueryConstraint,ln as QueryDocumentSnapshot,he as QueryEndAtConstraint,qt as QueryFieldFilterConstraint,le as QueryLimitConstraint,$e as QueryOrderByConstraint,ve as QuerySnapsh
2ot,ce as QueryStartAtConstraint,O as Timestamp,Mi as Transaction,K as VectorValue,Oi as WriteBatch,fs as addDoc,Ts as aggregateFieldEqual,ws as aggregateQuerySnapshotEqual,Zi as and,_s as arrayRemove,ms as arrayUnion,Is as average,Qi as collection,Ki as collectionGroup,Ti as connectFirestoreEmulator,Fi as count,hs as deleteDoc,ds as deleteField,wi as doc,Hi as documentId,os as endAt,ss as endBefore,ki as getAggregate,Es as getCount,as as getDoc,us as getDocs,Bi as getFirestore,gs as increment,ji as initializeFirestore,es as limit,rs as limitToLast,Xi as or,ts as orderBy,Ji as query,Zr as queryEqual,Wi as refEqual,vs as runTransaction,ps as serverTimestamp,ls as setDoc,Gi as setLogLevel,Ni as snapshotEqual,is as startAfter,ns as startAt,As as sum,zi as terminate,cs as updateDoc,ys as vector,Yi as where,Vs as writeBatch}; 3//# sourceMappingURL=index.esm-CrQ_nGrO.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.