PageSourceSearch

https://kopern.ai/_next/static/chunks/741dd708061fe346.js?dpl=dpl_5Fg45TmRWFQkKW9jZ15jgdRrEv9E

js kopern.ai collected 2026-10-05 12:23:55 UTC 343,193 bytes, 9 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,436180,98925,e=>{"use strict";var t,n,r,i,s,a,o,l,u,h,c,d,f,m,g=e.i(92953),p=e.i(308070),y=e.i(247167),w=e.i(467034),v=e.i(897427),b="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,I={};(function(){function e(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.C=Array(this.blockSize),this.o=this.h=0,this.u()}var r=function(){this.blockSize=-1};function i(){}function s(e,t,n){n||(n=0);let r=Array(16);if("string"==typeof t)for(var i=0;i<16;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;i<16;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];let s=e.g[3],a;a=t+(s^n&(i^s))+r[0]+0xd76aa478|0,a=s+(i^(t=n+(a<<7|a>>>25))&(n^i))+r[1]+0xe8c7b756|0,a=i+(n^(s=t+(a<<12|a>>>20))&(t^n))+r[2]+0x242070db|0,a=n+(t^(i=s+(a<<17|a>>>15))&(s^t))+r[3]+0xc1bdceee|0,a=t+(s^(n=i+(a<<22|a>>>10))&(i^s))+r[4]+0xf57c0faf|0,a=s+(i^(t=n+(a<<7|a>>>25))&(n^i))+r[5]+0x4787c62a|0,a=i+(n^(s=t+(a<<12|a>>>20))&(t^n))+r[6]+0xa8304613|0,a=n+(t^(i=s+(a<<17|a>>>15))&(s^t))+r[7]+0xfd469501|0,a=t+(s^(n=i+(a<<22|a>>>10))&(i^s))+r[8]+0x698098d8|0,a=s+(i^(t=n+(a<<7|a>>>25))&(n^i))+r[9]+0x8b44f7af|0,a=i+(n^(s=t+(a<<12|a>>>20))&(t^n))+r[10]+0xffff5bb1|0,a=n+(t^(i=s+(a<<17|a>>>15))&(s^t))+r[11]+0x895cd7be|0,a=t+(s^(n=i+(a<<22|a>>>10))&(i^s))+r[12]+0x6b901122|0,a=s+(i^(t=n+(a<<7|a>>>25))&(n^i))+r[13]+0xfd987193|0,a=i+(n^(s=t+(a<<12|a>>>20))&(t^n))+r[14]+0xa679438e|0,a=n+(t^(i=s+(a<<17|a>>>15))&(s^t))+r[15]+0x49b40821|0,n=i+(a<<22|a>>>10),a=t+(i^s&(n^i))+r[1]+0xf61e2562|0,t=n+(a<<5|a>>>27),a=s+(n^i&(t^n))+r[6]+0xc040b340|0,s=t+(a<<9|a>>>23),a=i+(t^n&(s^t))+r[11]+0x265e5a51|0,i=s+(a<<14|a>>>18),a=n+(s^t&(i^s))+r[0]+0xe9b6c7aa|0,n=i+(a<<20|a>>>12),a=t+(i^s&(n^i))+r[5]+0xd62f105d|0,t=n+(a<<5|a>>>27),a=s+(n^i&(t^n))+r[10]+0x2441453|0,s=t+(a<<9|a>>>23),a=i+(t^n&(s^t))+r[15]+0xd8a1e681|0,i=s+(a<<14|a>>>18),a=n+(s^t&(i^s))+r[4]+0xe7d3fbc8|0,n=i+(a<<20|a>>>12),a=t+(i^s&(n^i))+r[9]+0x21e1cde6|0,t=n+(a<<5|a>>>27),a=s+(n^i&(t^n))+r[14]+0xc33707d6|0,s=t+(a<<9|a>>>23),a=i+(t^n&(s^t))+r[3]+0xf4d50d87|0,i=s+(a<<14|a>>>18),a=n+(s^t&(i^s))+r[8]+0x455a14ed|0,n=i+(a<<20|a>>>12),a=t+(i^s&(n^i))+r[13]+0xa9e3e905|0,t=n+(a<<5|a>>>27),a=s+(n^i&(t^n))+r[2]+0xfcefa3f8|0,s=t+(a<<9|a>>>23),a=i+(t^n&(s^t))+r[7]+0x676f02d9|0,i=s+(a<<14|a>>>18),a=n+(s^t&(i^s))+r[12]+0x8d2a4c8a|0,a=t+((n=i+(a<<20|a>>>12))^i^s)+r[5]+0xfffa3942|0,a=s+((t=n+(a<<4|a>>>28))^n^i)+r[8]+0x8771f681|0,a=i+((s=t+(a<<11|a>>>21))^t^n)+r[11]+0x6d9d6122|0,a=n+((i=s+(a<<16|a>>>16))^s^t)+r[14]+0xfde5380c|0,a=t+((n=i+(a<<23|a>>>9))^i^s)+r[1]+0xa4beea44|0,a=s+((t=n+(a<<4|a>>>28))^n^i)+r[4]+0x4bdecfa9|0,a=i+((s=t+(a<<11|a>>>21))^t^n)+r[7]+0xf6bb4b60|0,a=n+((i=s+(a<<16|a>>>16))^s^t)+r[10]+0xbebfbc70|0,a=t+((n=i+(a<<23|a>>>9))^i^s)+r[13]+0x289b7ec6|0,a=s+((t=n+(a<<4|a>>>28))^n^i)+r[0]+0xeaa127fa|0,a=i+((s=t+(a<<11|a>>>21))^t^n)+r[3]+0xd4ef3085|0,a=n+((i=s+(a<<16|a>>>16))^s^t)+r[6]+0x4881d05|0,a=t+((n=i+(a<<23|a>>>9))^i^s)+r[9]+0xd9d4d039|0,a=s+((t=n+(a<<4|a>>>28))^n^i)+r[12]+0xe6db99e5|0,a=i+((s=t+(a<<11|a>>>21))^t^n)+r[15]+0x1fa27cf8|0,a=n+((i=s+(a<<16|a>>>16))^s^t)+r[2]+0xc4ac5665|0,n=i+(a<<23|a>>>9),a=t+(i^(n|~s))+r[0]+0xf4292244|0,t=n+(a<<6|a>>>26),a=s+(n^(t|~i))+r[7]+0x432aff97|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~n))+r[14]+0xab9423a7|0,i=s+(a<<15|a>>>17),a=n+(s^(i|~t))+r[5]+0xfc93a039|0,n=i+(a<<21|a>>>11),a=t+(i^(n|~s))+r[12]+0x655b59c3|0,t=n+(a<<6|a>>>26),a=s+(n^(t|~i))+r[3]+0x8f0ccc92|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~n))+r[10]+0xffeff47d|0,i=s+(a<<15|a>>>17),a=n+(s^(i|~t))+r[1]+0x85845dd1|0,n=i+(a<<21|a>>>11),a=t+(i^(n|~s))+r[8]+0x6fa87e4f|0,t=n+(a<<6|a>>>26),a=s+(n^(t|~i))+r[15]+0xfe2ce6e0|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~n))+r[6]+0xa3014314|0,i=s+(a<<15|a>>>17),a=n+(s^(i|~t))+r[13]+0x4e0811a1|0,n=i+(a<<21|a>>>11),a=t+(i^(n|~s))+r[4]+0xf7537e82|0,t=n+(a<<6|a>>>26),a=s+(n^(t|~i))+r[11]+0xbd3af235|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~n))+r[2]+0x2ad7d2bb|0,i=s+(a<<15|a>>>17),a=n+(s^(i|~t))+r[9]+0xeb86d391|0,e.g[0]=e.g[0]+t|0,e.g[1]=e.g[1]+(i+(a<<21|a>>>11))|0,e.g[2]=e.g[2]+i|0,e.g[3]=e.g[3]+s|0}function a(e,t){this.h=t;let n=[],r=!0;for(let i=e.length-1;i>=0;i--){let s=0|e[i];r&&s==t||(n[i]=s,r=!1)}this.g=n}i.prototype=r.prototype,e.F=r.prototype,e.prototype=new i,e.prototype.constructor=e,e.D=function(e,t,n){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return r.prototype[t].apply(e,i)},e.prototype.u=function(){this.g[0]=0x67452301,this.g[1]=0xefcdab89,this.g[2]=0x98badcfe,this.g[3]=0x10325476,this.o=this.h=0},e.prototype.v=function(e,t){void 0===t&&(t=e.length);let n=t-this.blockSize,r=this.C,i=this.h,a=0;for(;a<t;){if(0==i)for(;a<=n;)s(this,e,a),a+=this.blockSize;if("string"==typeof e){for(;a<t;)if(r[i++]=e.charCodeAt(a++),i==this.blockSize){s(this,r),i=0;break}}else for(;a<t;)if(r[i++]=e[a++],i==this.blockSize){s(this,r),i=0;break}}this.h=i,this.o+=t},e.prototype.A=function(){var e=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;t=8*this.o;for(var n=e.length-8;n<e.length;++n)e[n]=255&t,t/=256;for(this.v(e),e=Array(16),t=0,n=0;n<4;++n)for(let r=0;r<32;r+=8)e[t++]=this.g[n]>>>r&255;return e};var o,l={};function u(e){var t;return -128<=e&&e<128?(t=function(e){return new a([0|e],e<0?-1:0)},Object.prototype.hasOwnProperty.call(l,e)?l[e]:l[e]=t(e)):new a([0|e],e<0?-1:0)}function h(e){if(isNaN(e)||!isFinite(e))return c;if(e<0)return p(h(-e));let t=[],n=1;for(let r=0;e>=n;r++)t[r]=e/n|0,n*=0x100000000;return new a(t,0)}var c=u(0),d=u(1),f=u(0x1000000);function m(e){if(0!=e.h)return!1;for(let t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function g(e){return -1==e.h}function p(e){let t=e.g.length,n=[];for(let r=0;r<t;r++)n[r]=~e.g[r];return new a(n,~e.h).add(d)}function y(e,t){return e.add(p(t))}function w(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function v(e,t){this.g=e,this.h=t}function b(e,t){if(m(t))throw Error("division by zero");if(m(e))return new v(c,c);if(g(e))return t=b(p(e),t),new v(p(t.g),p(t.h));if(g(t))return t=b(e,p(t)),new v(p(t.g),t.h);if(e.g.length>
130){if(g(e)||g(t))throw Error("slowDivide_ only works with positive integers.");for(var n=d,r=t;0>=r.l(e);)n=T(n),r=T(r);var i=_(n,1),s=_(r,1);for(r=_(r,2),n=_(n,2);!m(r);){var a=s.add(r);0>=a.l(e)&&(i=i.add(n),s=a),r=_(r,1),n=_(n,1)}return t=y(e,i.j(t)),new v(i,t)}for(i=c;e.l(t)>=0;){for(r=(r=Math.ceil(Math.log(n=Math.max(1,Math.floor(e.m()/t.m())))/Math.LN2))<=48?1:Math.pow(2,r-48),a=(s=h(n)).j(t);g(a)||a.l(e)>0;)n-=r,a=(s=h(n)).j(t);m(s)&&(s=d),i=i.add(s),e=y(e,a)}return new v(i,e)}function T(e){let t=e.g.length+1,n=[];for(let r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new a(n,e.h)}function _(e,t){let n=t>>5;t%=32;let r=e.g.length-n,i=[];for(let s=0;s<r;s++)i[s]=t>0?e.i(s+n)>>>t|e.i(s+n+1)<<32-t:e.i(s+n);return new a(i,e.h)}(o=a.prototype).m=function(){if(g(this))return-p(this).m();let e=0,t=1;for(let n=0;n<this.g.length;n++){let r=this.i(n);e+=(r>=0?r:0x100000000+r)*t,t*=0x100000000}return e},o.toString=function(e){if((e=e||10)<2||36<e)throw Error("radix out of range: "+e);if(m(this))return"0";if(g(this))return"-"+p(this).toString(e);let t=h(Math.pow(e,6));var n=this;let r="";for(;;){let i=b(n,t).g,s=(((n=y(n,i.j(t))).g.length>0?n.g[0]:n.h)>>>0).toString(e);if(m(n=i))return s+r;for(;s.length<6;)s="0"+s;r=s+r}},o.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h},o.l=function(e){return g(e=y(this,e))?-1:+!m(e)},o.abs=function(){return g(this)?p(this):this},o.add=function(e){let t=Math.max(this.g.length,e.g.length),n=[],r=0;for(let i=0;i<=t;i++){let t=r+(65535&this.i(i))+(65535&e.i(i)),s=(t>>>16)+(this.i(i)>>>16)+(e.i(i)>>>16);r=s>>>16,t&=65535,s&=65535,n[i]=s<<16|t}return new a(n,-0x80000000&n[n.length-1]?-1:0)},o.j=function(e){if(m(this)||m(e))return c;if(g(this))return g(e)?p(this).j(p(e)):p(p(this).j(e));if(g(e))return p(this.j(p(e)));if(0>this.l(f)&&0>e.l(f))return h(this.m()*e.m());let t=this.g.length+e.g.length,n=[];for(var r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(let t=0;t<e.g.length;t++){let i=this.i(r)>>>16,s=65535&this.i(r),a=e.i(t)>>>16,o=65535&e.i(t);n[2*r+2*t]+=s*o,w(n,2*r+2*t),n[2*r+2*t+1]+=i*o,w(n,2*r+2*t+1),n[2*r+2*t+1]+=s*a,w(n,2*r+2*t+1),n[2*r+2*t+2]+=i*a,w(n,2*r+2*t+2)}for(e=0;e<t;e++)n[e]=n[2*e+1]<<16|n[2*e];for(e=t;e<2*t;e++)n[e]=0;return new a(n,0)},o.B=function(e){return b(this,e).h},o.and=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new a(n,this.h&e.h)},o.or=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new a(n,this.h|e.h)},o.xor=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new a(n,this.h^e.h)},e.prototype.digest=e.prototype.A,e.prototype.reset=e.prototype.u,e.prototype.update=e.prototype.v,n=I.Md5=e,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=h,a.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if((n=n||10)<2||36<n)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return p(e(t.substring(1),n));if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character');let r=h(Math.pow(n,8)),i=c;for(let e=0;e<t.length;e+=8){var s=Math.min(8,t.length-e);let a=parseInt(t.substring(e,e+s),n);s<8?(s=h(Math.pow(n,s)),i=i.j(s).add(h(a))):i=(i=i.j(r)).add(h(a))}return i},t=I.Integer=a}).apply(void 0!==b?b:"u">typeof self?self:"u">typeof window?window:{});var T=e.i(683877),_="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,E={};(function(){var e,t,n=Object.defineProperty,c=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof _&&_];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);function d(e,t){if(t)e:{var r=c;e=e.split(".");for(var i=0;i<e.length-1;i++){var s=e[i];if(!(s in r))break e;r=r[s]}(t=t(i=r[e=e[e.length-1]]))!=i&&null!=t&&n(r,e,{configurable:!0,writable:!0,value:t})}}d("Symbol.dispose",function(e){return e||Symbol("Symbol.dispose")}),d("Array.prototype.values",function(e){return e||function(){return this[Symbol.iterator]()}}),d("Object.entries",function(e){return e||function(e){var t,n=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.push([t,e[t]]);return n}});var f=f||{},m=this||self;function g(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function p(e,t,n){return e.call.apply(e.bind,arguments)}function y(e,t,n){return(y=p).apply(null,arguments)}
1function w(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function v(e,t){function n(){}n.prototype=t.prototype,e.Z=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Ob=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}var b="u">typeof AsyncContext&&"function"==typeof AsyncContext.Snapshot?e=>e&&AsyncContext.Snapshot.wrap(e):e=>e;function I(e){let t=e.length;if(t>0){let n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function T(e,t){for(let t=1;t<arguments.length;t++){let r=arguments[t];var n=typeof r;if("array"==(n="object"!=n?n:r?Array.isArray(r)?"array":n:"null")||"object"==n&&"number"==typeof r.length){n=e.length||0;let t=r.length||0;e.length=n+t;for(let i=0;i<t;i++)e[n+i]=r[i]}else e.push(r)}}var S=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return this.h>0?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}(()=>new x,e=>e.reset());class x{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let C,A=!1,D=new class{constructor(){this.h=this.g=null}add(e,t){let n=S.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}},N=()=>{let e=Promise.resolve(void 0);C=()=>{e.then(k)}};function k(){let e;for(var t;e=null,D.g&&(e=D.g,D.g=D.g.next,D.g||(D.h=null),e.next=null),t=e;){try{t.h.call(t.g)}catch(e){!function(e){m.setTimeout(()=>{throw e},0)}(e)}S.j(t),S.h<100&&(S.h++,t.next=S.g,S.g=t)}A=!1}function R(){this.u=this.u,this.C=this.C}function M(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}R.prototype.u=!1,R.prototype.dispose=function(){this.u||(this.u=!0,this.N())},R.prototype[Symbol.dispose]=function(){this.dispose()},R.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},M.prototype.h=function(){this.defaultPrevented=!0};var O=function(){if(!m.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{let e=()=>{};m.addEventListener("test",e,t),m.removeEventListener("test",e,t)}catch(e){}return e}();function P(e){return/^[\s\xa0]*$/.test(e)}function F(e,t){M.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e&&this.init(e,t)}v(F,M),F.prototype.init=function(e,t){let n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.g=t,(t=e.relatedTarget)||("mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement)),this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType=e.pointerType,this.state=e.state,this.i=e,e.defaultPrevented&&F.Z.h.call(this)},F.prototype.h=function(){F.Z.h.call(this);let e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var L="closure_listenable_"+(1e6*Math.random()|0),V=0;function q(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++V,this.da=this.fa=!1}function U(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function B(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function j(e){let t={};for(let n in e)t[n]=e[n];return t}let z="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function G(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t])e[n]=r[n];for(let t=0;t<z.length;
1t++)n=z[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function K(e){this.src=e,this.g={},this.h=0}function $(e,t){let n=t.type;if(n in e.g){var r,i=e.g[n],s=Array.prototype.indexOf.call(i,t,void 0);(r=s>=0)&&Array.prototype.splice.call(i,s,1),r&&(U(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function Q(e,t,n,r){for(let i=0;i<e.length;++i){let s=e[i];if(!s.da&&s.listener==t&&!!n==s.capture&&s.ha==r)return i}return -1}K.prototype.add=function(e,t,n,r,i){let s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);let a=Q(e,t,r,i);return a>-1?(t=e[a],n||(t.fa=!1)):((t=new q(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var H="closure_lm_"+(1e6*Math.random()|0),W={};function J(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");let a=g(i)?!!i.capture:!!i,o=ee(e);if(o||(e[H]=o=new K(e)),(n=o.add(t,n,r,a,s)).proxy)return n;if(r=function e(t){return Z.call(e.src,e.listener,t)},n.proxy=r,r.src=e,r.listener=n,e.addEventListener)O||(i=a),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(X(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error("addEventListener and attachEvent are unavailable.");return n}function Y(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[L])$(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(X(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=ee(t))?($(n,e),0==n.h&&(n.src=null,t[H]=null)):U(e)}}}function X(e){return e in W?W[e]:W[e]="on"+e}function Z(e,t){if(e.da)e=!0;else{t=new F(t,this);let n=e.listener,r=e.ha||e.src;e.fa&&Y(e),e=n.call(r,t)}return e}function ee(e){return(e=e[H])instanceof K?e:null}var et="__closure_events_fn_"+(1e9*Math.random()>>>0);function en(e){return"function"==typeof e?e:(e[et]||(e[et]=function(t){return e.handleEvent(t)}),e[et])}function er(){R.call(this),this.i=new K(this),this.M=this,this.G=null}function ei(e,t){let n,r;var i,s=e.G;if(s)for(i=[];s;s=s.G)i.push(s);if(e=e.M,s=t.type||t,"string"==typeof t)t=new M(t,e);else if(t instanceof M)t.target=t.target||e;else{var a=t;G(t=new M(s,e),a)}if(a=!0,i)for(r=i.length-1;r>=0;r--)a=es(n=t.g=i[r],s,!0,t)&&a;if(a=es(n=t.g=e,s,!0,t)&&a,a=es(n,s,!1,t)&&a,i)for(r=0;r<i.length;r++)a=es(n=t.g=i[r],s,!1,t)&&a}function es(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();let i=!0;for(let s=0;s<t.length;++s){let a=t[s];if(a&&!a.da&&a.capture==n){let t=a.listener,n=a.ha||a.src;a.fa&&$(e.i,a),i=!1!==t.call(n,r)&&i}}return i&&!r.defaultPrevented}v(er,R),er.prototype[L]=!0,er.prototype.removeEventListener=function(e,t,n,r){!function e(t,n,r,i,s){if(Array.isArray(n))for(var a=0;a<n.length;a++)e(t,n[a],r,i,s);else(i=g(i)?!!i.capture:!!i,r=en(r),t&&t[L])?(t=t.i,(a=String(n).toString())in t.g&&(r=Q(n=t.g[a],r,i,s))>-1&&(U(n[r]),Array.prototype.splice.call(n,r,1),0==n.length&&(delete t.g[a],t.h--))):t&&(t=ee(t))&&(n=t.g[n.toString()],t=-1,n&&(t=Q(n,r,i,s)),(r=t>-1?n[t]:null)&&Y(r))}(this,e,t,n,r)},er.prototype.N=function(){if(er.Z.N.call(this),this.i){var e=this.i;for(let t in e.g){let n=e.g[t];for(let e=0;e<n.length;e++)U(n[e]);delete e.g[t],e.h--}}this.G=null},er.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},er.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};class ea extends R{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:function e(t){t.g=function(e,t){if("function"!=typeof e)if(e&&"function"==typeof e.handleEvent)e=y(e.handleEvent,e);else throw Error("Invalid listener argument");return Number(t)>0x7fffffff?-1:m.setTimeout(e,t||0)}(()=>{t.g=null,t.i&&(t.i=!1,e(t))},t.l);let n=t.h;t.h=null,t.m.apply(null,n)}(this)}N(){super.N(),this.g&&(m.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function eo(e){R.call(this),this.h=e,this.g={}}v(eo,R);var el=[];function eu(e){B(e.g,function(e,t){this.g.hasOwnProperty(t)&&Y(e)},e),e.g={}}eo.prototype.N=function(){eo.Z.N.call(this),eu(this)},eo.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var eh=m.JSON.stringify,ec=m.JSON.parse,ed=class{stringify(e){return m.JSON.stringify(e,void 0)}parse(e){return m.JSON.parse(e,void 0)}};function ef(){}function em(){}var eg={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function ep(){M.call(this,"d")}function ey(){M.call(this,"c")}v(ep,M),v(ey,M);var ew={},ev=null;function eb(){return ev=ev||new er}function eI(e){M.call(this,ew.Ia,e)}function eT(e){let t=eb();ei(t,new eI(t))}function e_(e,t){M.call(this,ew.STAT_EVENT,e),this.stat=t}function eE(e){let t=eb();ei(t,new e_(t,e))}function eS(e,t){M.call(this,ew.Ja,e),this.size=t}function ex(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return m.setTimeout(function(){e()},t)}function eC(){this.g=!0}function eA(e,t,n,r){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{let s=JSON.parse(t);if(s){for(e=0;e<s.length;e++)if(Array.isArray(s[e])){var n=s[e];if(!(n.length<2)){var r=n[1];if(Array.isArray(r)&&!(r.length<1)){var i=r[0];if("noop"!=i&&"stop"!=i&&"close"!=i)for(let e=1;e<r.length;e++)r[e]=""}}}}return eh(s)}catch(e){return t}}(e,n)+(r?" "+r:"")})}ew.Ia="serverreachability",v(eI,M),ew.STAT_EVENT="statevent",v(e_,M),ew.Ja="timingevent",v(eS,M),eC.prototype.ua=function(){this.g=!1},eC.prototype.info=function(){};var eD={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},eN={ib:"complete",Fb:"success",ERROR:"error",Ga:"abort",xb:"ready",yb:"readystatechange",TIMEOUT:"timeout",sb:"incrementaldata",wb:"progress",lb:"downloadprogress",Nb:"uploadprogress"};function ek(){}function eR(e){return encodeURIComponent(String(e))}function eM(e,t,n,r){this.j=e,this.i=t,this.l=n,this.S=r||1,this.V=new eo(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new eO}function eO(){this.i=null,this.g="",this.h=!1}v(ek,ef),ek.prototype.g=function(){return new XMLHttpRequest},e=new ek;var eP={},eF={};
1function eL(e,t,n){e.M=1,e.A=e8(e2(t)),e.u=n,e.R=!0,eV(e,null)}function eV(e,t){e.F=Date.now(),eU(e),e.B=e2(e.A);var n,r,i,s,a,o,l=e.B,u=e.S;Array.isArray(u)||(u=[String(u)]),tc(l.i,"t",u),e.C=0,l=e.j.L,e.h=new eO,e.g=tY(e.j,l?t:null,!e.u),e.P>0&&(e.O=new ea(y(e.Y,e,e.g),e.P)),t=e.V,l=e.g,u=e.ba;var h="readystatechange";Array.isArray(h)||(h&&(el[0]=h.toString()),h=el);for(let e=0;e<h.length;e++){let n=function e(t,n,r,i,s){if(i&&i.once)return function e(t,n,r,i,s){if(Array.isArray(n)){for(let a=0;a<n.length;a++)e(t,n[a],r,i,s);return null}return r=en(r),t&&t[L]?t.K(n,r,g(i)?!!i.capture:!!i,s):J(t,n,r,!0,i,s)}(t,n,r,i,s);if(Array.isArray(n)){for(let a=0;a<n.length;a++)e(t,n[a],r,i,s);return null}return r=en(r),t&&t[L]?t.J(n,r,g(i)?!!i.capture:!!i,s):J(t,n,r,!1,i,s)}(l,h[e],u||t.handleEvent,!1,t.h||t);if(!n)break;t.g[n.key]=n}t=e.J?j(e.J):{},e.u?(e.v||(e.v="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.B,e.v,e.u,t)):(e.v="GET",e.g.ea(e.B,e.v,null,t)),eT(),n=e.i,r=e.v,i=e.B,s=e.l,a=e.S,o=e.u,n.info(function(){if(n.g)if(o){var e="",t=o.split("&");for(let n=0;n<t.length;n++){var l=t[n].split("=");if(l.length>1){let t=l[0];l=l[1];let n=t.split("_");e=n.length>=2&&"type"==n[1]?e+(t+"=")+l+"&":e+(t+"=redacted&")}}}else e=null;else e=o;return"XMLHTTP REQ ("+s+") [attempt "+a+"]: "+r+"\n"+i+"\n"+e})}function eq(e){return!!e.g&&"GET"==e.v&&2!=e.M&&e.j.Aa}function eU(e){e.T=Date.now()+e.H,eB(e,e.H)}function eB(e,t){if(null!=e.D)throw Error("WatchDog timer not null");e.D=ex(y(e.aa,e),t)}function ej(e){e.D&&(m.clearTimeout(e.D),e.D=null)}function ez(e){0==e.j.I||e.K||t$(e.j,e)}function eG(e){ej(e);var t=e.O;t&&"function"==typeof t.dispose&&t.dispose(),e.O=null,eu(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}function eK(e,t){try{var n=e.j;if(0!=n.I&&(n.g==e||eJ(n.h,e))){if(!e.L&&eJ(n.h,e)&&3==n.I){try{var r=n.Ba.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){e:if(!n.v){if(n.g)if(n.g.F+3e3<e.F)tK(n),tP(n);else break e;tj(n),eE(18)}}else n.xa=i[1],0<n.xa-n.K&&i[2]<37500&&n.F&&0==n.A&&!n.C&&(n.C=ex(y(n.Va,n),6e3));1>=eW(n.h)&&n.ta&&(n.ta=void 0)}else tH(n,11)}else if((e.L||n.g==e)&&tK(n),!P(t))for(i=n.Ba.g.parse(t),t=0;t<i.length;t++){let o=i[t],l=o[0];if(!(l<=n.K))if(n.K=l,o=o[1],2==n.I)if("c"==o[0]){n.M=o[1],n.ba=o[2];let t=o[3];null!=t&&(n.ka=t,n.j.info("VER="+n.ka));let i=o[4];null!=i&&(n.za=i,n.j.info("SVER="+n.za));let l=o[5];null!=l&&"number"==typeof l&&l>0&&(n.O=r=1.5*l,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;let u=e.g;if(u){let e=u.g?u.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=r.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(eY(s,s.h),s.h=null))}if(r.G){let e=u.g?u.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(r.wa=e,e6(r.J,r.G,e))}}if(n.I=3,n.l&&n.l.ra(),n.aa&&(n.T=Date.now()-e.F,n.j.info("Handshake RTT: "+n.T+"ms")),(r=n).na=tJ(r,r.L?r.ba:null,r.W),e.L){eX(r.h,e);var a=r.O;a&&(e.H=a),e.D&&(ej(e),eU(e)),r.g=e}else tB(r);n.i.length>0&&tL(n)}else"stop"!=o[0]&&"close"!=o[0]||tH(n,7);else 3==n.I&&("stop"==o[0]||"close"==o[0]?"stop"==o[0]?tH(n,7):tO(n):"noop"!=o[0]&&n.l&&n.l.qa(o),n.A=0)}}eT(4)}catch(e){}}eM.prototype.ba=function(e){e=e.target;let t=this.O;t&&3==tN(e)?t.j():this.Y(e)},eM.prototype.Y=function(e){try{if(e==this.g)e:{let d=tN(this.g),f=this.g.ya(),g=this.g.ca();if(!(d<3)&&(3!=d||this.g&&(this.h.h||this.g.la()||tk(this.g)))){this.K||4!=d||7==f||(8==f||g<=0?eT(3):eT(2)),ej(this);var t=this.g.ca();this.X=t;var n=function(e){if(!eq(e))return e.g.la();let t=tk(e.g);if(""===t)return"";let n="",r=t.length,i=4==tN(e.g);if(!e.h.i){if("u"<typeof TextDecoder)return eG(e),ez(e),"";e.h.i=new m.TextDecoder}for(let s=0;s<r;s++)e.h.h=!0,n+=e.h.i.decode(t[s],{stream:!(i&&s==r-1)});return t.length=0,e.h.g+=n,e.C=0,e.h.g}(this);if(this.o=200==t,r=this.i,i=this.v,s=this.B,a=this.l,o=this.S,r.info(function(){return"XMLHTTP RESP ("+a+") [ attempt "+o+"]: "+i+"\n"+s+"\n"+d+" "+t}),this.o){if(this.U&&!this.L){t:{if(this.g){var r,i,s,a,o,l,u=this.g;if((l=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!P(l)){var h=l;break t}}h=null}if(e=h)eA(this.i,this.l,e,"Initial handshake response via X-HTTP-Initial-Response"),this.L=!0,eK(this,e);else{this.o=!1,this.m=3,eE(12),eG(this),ez(this);break e}}if(this.R){let t;for(e=!0;!this.K&&this.C<n.length;)if((t=function(e,t){var n=e.C,r=t.indexOf("\n",n);return -1==r?eF:isNaN(n=Number(t.substring(n,r)))?eP:(r+=1)+n>t.length?eF:(t=t.slice(r,r+n),e.C=r+n,t)}(this,n))==eF){4==d&&(this.m=4,eE(14),e=!1),eA(this.i,this.l,null,"[Incomplete Response]");break}else if(t==eP){this.m=4,eE(15),eA(this.i,this.l,n,"[Invalid Chunk]"),e=!1;break}else eA(this.i,this.l,t,null),eK(this,t);if(eq(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=d||0!=n.length||this.h.h||(this.m=1,eE(16),e=!1),this.o=this.o&&e,e){if(n.length>0&&!this.W){this.W=!0;var c=this.j;c.g==this&&c.aa&&!c.P&&(c.j.info("Great, no buffering proxy detected. Bytes received: "+n.length),tz(c),c.P=!0,eE(11))}}else eA(this.i,this.l,n,"[Invalid Chunked Response]"),eG(this),ez(this)}else eA(this.i,this.l,n,null),eK(this,n);4==d&&eG(this),this.o&&!this.K&&(4==d?t$(this.j,this):(this.o=!1,eU(this)))}else(function(e){let t={};e=(e.g&&tN(e)>=2&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let r=0;r<e.length;r++){if(P(e[r]))continue;var n=function(e){var t=1;e=e.split(":");let n=[];for(;t>0&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}(e[r]);let i=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();let s=t[i]||[];t[i]=s,s.push(n)}
1var r=function(e){return e.join(", ")};for(let e in t)r.call(void 0,t[e],e,t)})(this.g),400==t&&n.indexOf("Unknown SID")>0?(this.m=3,eE(12)):(this.m=0,eE(13)),eG(this),ez(this)}}}catch(e){}finally{}},eM.prototype.cancel=function(){this.K=!0,eG(this)},eM.prototype.aa=function(){var e,t;this.D=null;let n=Date.now();n-this.T>=0?(e=this.i,t=this.B,e.info(function(){return"TIMEOUT: "+t}),2!=this.M&&(eT(),eE(17)),eG(this),this.m=2,ez(this)):eB(this,this.T-n)};var e$=class{constructor(e,t){this.g=e,this.map=t}};function eQ(e){this.l=e||10,e=m.PerformanceNavigationTiming?(e=m.performance.getEntriesByType("navigation")).length>0&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(m.chrome&&m.chrome.loadTimes&&m.chrome.loadTimes()&&m.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function eH(e){return!!e.h||!!e.g&&e.g.size>=e.j}function eW(e){return e.h?1:e.g?e.g.size:0}function eJ(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function eY(e,t){e.g?e.g.add(t):e.h=t}function eX(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function eZ(e){if(null!=e.h)return e.i.concat(e.h.G);if(null!=e.g&&0!==e.g.size){let t=e.i;for(let n of e.g.values())t=t.concat(n.G);return t}return I(e.i)}eQ.prototype.cancel=function(){if(this.i=eZ(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(let e of this.g.values())e.cancel();this.g.clear()}};var e0=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function e1(e){let t;this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1,e instanceof e1?(this.l=e.l,e5(this,e.j),this.o=e.o,this.g=e.g,e3(this,e.u),this.h=e.h,e4(this,td(e.i)),this.m=e.m):e&&(t=String(e).match(e0))?(this.l=!1,e5(this,t[1]||"",!0),this.o=e7(t[2]||""),this.g=e7(t[3]||"",!0),e3(this,t[4]),this.h=e7(t[5]||"",!0),e4(this,t[6]||"",!0),this.m=e7(t[7]||"")):(this.l=!1,this.i=new ta(null,this.l))}function e2(e){return new e1(e)}function e5(e,t,n){e.j=n?e7(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function e3(e,t){if(t){if(isNaN(t=Number(t))||t<0)throw Error("Bad port number "+t);e.u=t}else e.u=null}function e4(e,t,n){var r,i;t instanceof ta?(e.i=t,r=e.i,(i=e.l)&&!r.j&&(to(r),r.i=null,r.g.forEach(function(e,t){let n=t.toLowerCase();t!=n&&(tl(this,t),tc(this,n,e))},r)),r.j=i):(n||(t=e9(t,ti)),e.i=new ta(t,e.l))}function e6(e,t,n){e.i.set(t,n)}function e8(e){return e6(e,"zx",Math.floor(0x80000000*Math.random()).toString(36)+Math.abs(Math.floor(0x80000000*Math.random())^Date.now()).toString(36)),e}function e7(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function e9(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,te),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function te(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}e1.prototype.toString=function(){let e=[];var t=this.j;t&&e.push(e9(t,tt,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(e9(t,tt,!0),"@"),e.push(eR(n).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.u)&&e.push(":",String(n))),(n=this.h)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(e9(n,"/"==n.charAt(0)?tr:tn,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",e9(n,ts)),e.join("")},e1.prototype.resolve=function(e){let t=e2(this),n=!!e.j;n?e5(t,e.j):n=!!e.o,n?t.o=e.o:n=!!e.g,n?t.g=e.g:n=null!=e.u;var r=e.h;if(n)e3(t,e.u);else if(n=!!e.h){if("/"!=r.charAt(0))if(this.g&&!this.h)r="/"+r;else{var i=t.h.lastIndexOf("/");-1!=i&&(r=t.h.slice(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(-1!=i.indexOf("./")||-1!=i.indexOf("/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");let e=[];for(let t=0;t<i.length;){let n=i[t++];"."==n?r&&t==i.length&&e.push(""):".."==n?((e.length>1||1==e.length&&""!=e[0])&&e.pop(),r&&t==i.length&&e.push("")):(e.push(n),r=!0)}r=e.join("/")}else r=i}return n?t.h=r:n=""!==e.i.toString(),n?e4(t,td(e.i)):n=!!e.m,n&&(t.m=e.m),t};var tt=/[#\/\?@]/g,tn=/[#\?:]/g,tr=/[#\?]/g,ti=/[#\?@]/g,ts=/#/g;function ta(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function to(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(let n=0;n<e.length;n++){let r=e[n].indexOf("="),i,s=null;r>=0?(i=e[n].substring(0,r),s=e[n].substring(r+1)):i=e[n],t(i,s?decodeURIComponent(s.replace(/\+/g," ")):"")}}}(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}function tl(e,t){to(e),t=tf(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function tu(e,t){return to(e),t=tf(e,t),e.g.has(t)}function th(e,t){to(e);let n=[];if("string"==typeof t)tu(e,t)&&(n=n.concat(e.g.get(tf(e,t))));else for(e=Array.from(e.g.values()),t=0;t<e.length;t++)n=n.concat(e[t]);return n}
1function tc(e,t,n){tl(e,t),n.length>0&&(e.i=null,e.g.set(tf(e,t),I(n)),e.h+=n.length)}function td(e){let t=new ta;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function tf(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function tm(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch(e){}}function tg(){this.g=new ed}function tp(e){this.i=e.Sb||null,this.h=e.ab||!1}function ty(e,t){er.call(this),this.H=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}function tw(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}function tv(e){e.readyState=4,e.l=null,e.j=null,e.B=null,tb(e)}function tb(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function tI(e){let t="";return B(e,function(e,n){t+=n,t+=":",t+=e,t+="\r\n"}),t}function tT(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=tI(n),"string"==typeof e?null!=n&&eR(n):e6(e,t,n))}function t_(e){er.call(this),this.headers=new Map,this.L=e||null,this.h=!1,this.g=null,this.D="",this.o=0,this.l="",this.j=this.B=this.v=this.A=!1,this.m=null,this.F="",this.H=!1}(t=ta.prototype).add=function(e,t){to(this),this.i=null,e=tf(this,e);let n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},t.forEach=function(e,t){to(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)},t.set=function(e,t){return to(this),this.i=null,tu(this,e=tf(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},t.get=function(e,t){return e&&(e=th(this,e)).length>0?String(e[0]):t},t.toString=function(){if(this.i)return this.i;if(!this.g)return"";let e=[],t=Array.from(this.g.keys());for(let r=0;r<t.length;r++){var n=t[r];let i=eR(n);n=th(this,n);for(let t=0;t<n.length;t++){let r=i;""!==n[t]&&(r+="="+eR(n[t])),e.push(r)}}return this.i=e.join("&")},v(tp,ef),tp.prototype.g=function(){return new ty(this.i,this.h)},v(ty,er),(t=ty.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.F=e,this.D=t,this.readyState=1,tb(this)},t.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;let t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||m).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},t.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&4!=this.readyState&&(this.g=!1,tv(this)),this.readyState=0},t.Pa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,tb(this)),this.g&&(this.readyState=3,tb(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(void 0!==m.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;tw(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))},t.Ma=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?tv(this):tb(this),3==this.readyState&&tw(this)}},t.Oa=function(e){this.g&&(this.response=this.responseText=e,tv(this))},t.Na=function(e){this.g&&(this.response=e,tv(this))},t.ga=function(){this.g&&tv(this)},t.setRequestHeader=function(e,t){this.A.append(e,t)},t.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},t.getAllResponseHeaders=function(){if(!this.h)return"";let e=[],t=this.h.entries();for(var n=t.next();!n.done;)e.push((n=n.value)[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(ty.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),v(t_,er);var tE=/^https?$/i,tS=["POST","PUT"];function tx(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,tC(e),tD(e)}function tC(e){e.A||(e.A=!0,ei(e,"complete"),ei(e,"error"))}function tA(e){if(e.h&&void 0!==f){if(e.v&&4==tN(e))setTimeout(e.Ca.bind(e),0);else if(ei(e,"readystatechange"),4==tN(e)){e.h=!1;try{let s=e.ca();switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t,n,r=!0;break;default:r=!1}if(!(t=r)){if(n=0===s){let t=String(e.D).match(e0)[1]||null;!t&&m.self&&m.self.location&&(t=m.self.location.protocol.slice(0,-1)),n=!tE.test(t?t.toLowerCase():"")}t=n}if(t)ei(e,"complete"),ei(e,"success");else{e.o=6;try{var i=tN(e)>2?e.g.statusText:""}catch(e){i=""}e.l=i+" ["+e.ca()+"]",tC(e)}}finally{tD(e)}}}}function tD(e,t){if(e.g){e.m&&(clearTimeout(e.m),e.m=null);let n=e.g;e.g=null,t||ei(e,"ready");try{n.onreadystatechange=null}catch(e){}}}function tN(e){return e.g?e.g.readyState:0}function tk(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.F){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}
1function tR(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function tM(e){this.za=0,this.i=[],this.j=new eC,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=tR("failFast",!1,e),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=tR("baseRetryDelayMs",5e3,e),this.Za=tR("retryDelaySeedMs",1e4,e),this.Ta=tR("forwardChannelMaxRetries",2,e),this.va=tR("forwardChannelRequestTimeoutMs",2e4,e),this.ma=e&&e.xmlHttpFactory||void 0,this.Ua=e&&e.Rb||void 0,this.Aa=e&&e.useFetchStreams||!1,this.O=void 0,this.L=e&&e.supportsCrossDomainXhr||!1,this.M="",this.h=new eQ(e&&e.concurrentRequestLimit),this.Ba=new tg,this.S=e&&e.fastHandshake||!1,this.R=e&&e.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=e&&e.Pb||!1,e&&e.ua&&this.j.ua(),e&&e.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&e&&e.detectBufferingProxy||!1,this.ia=void 0,e&&e.longPollingTimeout&&e.longPollingTimeout>0&&(this.ia=e.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}function tO(e){if(tF(e),3==e.I){var t=e.V++,n=e2(e.J);if(e6(n,"SID",e.M),e6(n,"RID",t),e6(n,"TYPE","terminate"),tq(e,n),(t=new eM(e,e.j,t)).M=2,t.A=e8(e2(n)),n=!1,m.navigator&&m.navigator.sendBeacon)try{n=m.navigator.sendBeacon(t.A.toString(),"")}catch(e){}!n&&m.Image&&((new Image).src=t.A,n=!0),n||(t.g=tY(t.j,null),t.g.ea(t.A)),t.F=Date.now(),eU(t)}tW(e)}function tP(e){e.g&&(tz(e),e.g.cancel(),e.g=null)}function tF(e){tP(e),e.v&&(m.clearTimeout(e.v),e.v=null),tK(e),e.h.cancel(),e.m&&("number"==typeof e.m&&m.clearTimeout(e.m),e.m=null)}function tL(e){if(!eH(e.h)&&!e.m){e.m=!0;var t=e.Ea;C||N(),A||(C(),A=!0),D.add(t,e),e.D=0}}function tV(e,t){var n;n=t?t.l:e.V++;let r=e2(e.J);e6(r,"SID",e.M),e6(r,"RID",n),e6(r,"AID",e.K),tq(e,r),e.u&&e.o&&tT(r,e.u,e.o),n=new eM(e,e.j,n,e.D+1),null===e.u&&(n.J=e.o),t&&(e.i=t.G.concat(e.i)),t=tU(e,n,1e3),n.H=Math.round(.5*e.va)+Math.round(.5*e.va*Math.random()),eY(e.h,n),eL(n,r,t)}function tq(e,t){e.H&&B(e.H,function(e,n){e6(t,n,e)}),e.l&&B({},function(e,n){e6(t,n,e)})}function tU(e,t,n){n=Math.min(e.i.length,n);let r=e.l?y(e.l.Ka,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){let e=["count="+n];-1==t?n>0?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let o=!0;for(let l=0;l<n;l++){var s=i[l].g;let n=i[l].map;if((s-=t)<0)t=Math.max(0,i[l].g-100),o=!1;else try{s="req"+s+"_";try{var a=n instanceof Map?n:Object.entries(n);for(let[t,n]of a){let r=n;g(n)&&(r=eh(n)),e.push(s+t+"="+encodeURIComponent(r))}}catch(t){throw e.push(s+"type="+encodeURIComponent("_badmap")),t}}catch(e){r&&r(n)}}if(o){a=e.join("&");break e}}a=void 0}return t.G=e=e.i.splice(0,n),a}function tB(e){if(!e.g&&!e.v){e.Y=1;var t=e.Da;C||N(),A||(C(),A=!0),D.add(t,e),e.A=0}}function tj(e){return!e.g&&!e.v&&!(e.A>=3)&&(e.Y++,e.v=ex(y(e.Da,e),tQ(e,e.A)),e.A++,!0)}function tz(e){null!=e.B&&(m.clearTimeout(e.B),e.B=null)}function tG(e){e.g=new eM(e,e.j,"rpc",e.Y),null===e.u&&(e.g.J=e.o),e.g.P=0;var t=e2(e.na);e6(t,"RID","rpc"),e6(t,"SID",e.M),e6(t,"AID",e.K),e6(t,"CI",e.F?"0":"1"),!e.F&&e.ia&&e6(t,"TO",e.ia),e6(t,"TYPE","xmlhttp"),tq(e,t),e.u&&e.o&&tT(t,e.u,e.o),e.O&&(e.g.H=e.O);var n=e.g;e=e.ba,n.M=1,n.A=e8(e2(t)),n.u=null,n.R=!0,eV(n,e)}function tK(e){null!=e.C&&(m.clearTimeout(e.C),e.C=null)}function t$(e,t){var n,r=null;if(e.g==t){tK(e),tz(e),e.g=null;var i=2}else{if(!eJ(e.h,t))return;r=t.G,eX(e.h,t),i=1}if(0!=e.I){if(t.o)if(1==i){r=t.u?t.u.length:0,t=Date.now()-t.F;var s=e.D;ei(i=eb(),new eS(i,r)),tL(e)}else tB(e);else if(3==(s=t.m)||0==s&&t.X>0||!(1==i&&(n=t,!(eW(e.h)>=e.h.j-!!e.m)&&(e.m?(e.i=n.G.concat(e.i),!0):1!=e.I&&2!=e.I&&!(e.D>=(e.Sa?0:e.Ta))&&(e.m=ex(y(e.Ea,e,n),tQ(e,e.D)),e.D++,!0)))||2==i&&tj(e)))switch(r&&r.length>0&&((t=e.h).i=t.i.concat(r)),s){case 1:tH(e,5);break;case 4:tH(e,10);break;case 3:tH(e,6);break;default:tH(e,2)}}}function tQ(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function tH(e,t){if(e.j.info("Error code "+t),2==t){let t,s,a;var n,r=y(e.bb,e),i=e.Ua;let o=!i;i=new e1(i||"//www.google.com/images/cleardot.gif"),m.location&&"http"==m.location.protocol||e5(i,"https"),e8(i),o?function(e,t){let n=new eC;if(m.Image){let r=new Image;r.onload=w(tm,n,"TestLoadImage: loaded",!0,t,r),r.onerror=w(tm,n,"TestLoadImage: error",!1,t,r),r.onabort=w(tm,
1n,"TestLoadImage: abort",!1,t,r),r.ontimeout=w(tm,n,"TestLoadImage: timeout",!1,t,r),m.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}(i.toString(),r):(n=i.toString(),t=new eC,s=new AbortController,a=setTimeout(()=>{s.abort(),tm(t,"TestPingServer: timeout",!1,r)},1e4),fetch(n,{signal:s.signal}).then(e=>{clearTimeout(a),e.ok?tm(t,"TestPingServer: ok",!0,r):tm(t,"TestPingServer: server error",!1,r)}).catch(()=>{clearTimeout(a),tm(t,"TestPingServer: error",!1,r)}))}else eE(2);e.I=0,e.l&&e.l.pa(t),tW(e),tF(e)}function tW(e){if(e.I=0,e.ja=[],e.l){let t=eZ(e.h);(0!=t.length||0!=e.i.length)&&(T(e.ja,t),T(e.ja,e.i),e.h.i.length=0,I(e.i),e.i.length=0),e.l.oa()}}function tJ(e,t,n){var r=n instanceof e1?e2(n):new e1(n);if(""!=r.g)t&&(r.g=t+"."+r.g),e3(r,r.u);else{var i=m.location;r=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;let e=new e1(null);r&&e5(e,r),t&&(e.g=t),i&&e3(e,i),n&&(e.h=n),r=e}return n=e.G,t=e.wa,n&&t&&e6(r,n,t),e6(r,"VER",e.ka),tq(e,r),r}function tY(e,t,n){if(t&&!e.L)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new t_(e.Aa&&!e.ma?new tp({ab:n}):e.ma)).Fa(e.L),t}function tX(){}function tZ(){}function t0(e,t){er.call(this),this.g=new tM(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.sa&&(e?e["X-WebChannel-Client-Profile"]=t.sa:e={"X-WebChannel-Client-Profile":t.sa}),this.g.U=e,(e=t&&t.Qb)&&!P(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!P(t)&&(this.g.G=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new t5(this)}function t1(e){ep.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(let n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function t2(){ey.call(this),this.status=1}function t5(e){this.g=e}(t=t_.prototype).Fa=function(e){this.H=e},t.ea=function(t,n,r,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+t);n=n?n.toUpperCase():"GET",this.D=t,this.l="",this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():e.g(),this.g.onreadystatechange=b(y(this.Ca,this));try{this.B=!0,this.g.open(n,String(t),!0),this.B=!1}catch(e){tx(this,e);return}if(t=r||"",r=new Map(this.headers),i)if(Object.getPrototypeOf(i)===Object.prototype)for(var s in i)r.set(s,i[s]);else if("function"==typeof i.keys&&"function"==typeof i.get)for(let e of i.keys())r.set(e,i.get(e));else throw Error("Unknown input type for opt_headers: "+String(i));for(let[e,a]of(i=Array.from(r.keys()).find(e=>"content-type"==e.toLowerCase()),s=m.FormData&&t instanceof m.FormData,!(Array.prototype.indexOf.call(tS,n,void 0)>=0)||i||s||r.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),r))this.g.setRequestHeader(e,a);this.F&&(this.g.responseType=this.F),"withCredentials"in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&(clearTimeout(this.m),this.m=null),this.v=!0,this.g.send(t),this.v=!1}catch(e){tx(this,e)}},t.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=e||7,ei(this,"complete"),ei(this,"abort"),tD(this))},t.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),tD(this,!0)),t_.Z.N.call(this)},t.Ca=function(){this.u||(this.B||this.v||this.j?tA(this):this.Xa())},t.Xa=function(){tA(this)},t.isActive=function(){return!!this.g},t.ca=function(){try{return tN(this)>2?this.g.status:-1}catch(e){return -1}},t.la=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},t.La=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),ec(t)}},t.ya=function(){return this.o},t.Ha=function(){return"string"==typeof this.l?this.l:String(this.l)},(t=tM.prototype).ka=8,t.I=1,t.connect=function(e,t,n,r){eE(0),this.W=e,this.H=t||{},n&&void 0!==r&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.J=tJ(this,null,this.W),tL(this)},t.Ea=function(e){if(this.m)if(this.m=null,1==this.I){if(!e){this.V=Math.floor(1e5*Math.random()),e=this.V++;let i=new eM(this,this.j,e),s=this.o;if(this.U&&(s?G(s=j(s),this.U):s=this.U),null!==this.u||this.R||(i.J=s,s=null),this.S)e:{for(var t=0,n=0;n<this.i.length;n++){t:{var r=this.i[n];if("__data__"in r.map&&"string"==typeof(r=r.map.__data__)){r=r.length;break t}r=void 0}if(void 0===r)break;
1if((t+=r)>4096){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;t=tU(this,i,t),e6(n=e2(this.J),"RID",e),e6(n,"CVER",22),this.G&&e6(n,"X-HTTP-Session-Id",this.G),tq(this,n),s&&(this.R?t="headers="+eR(tI(s))+"&"+t:this.u&&tT(n,this.u,s)),eY(this.h,i),this.Ra&&e6(n,"TYPE","init"),this.S?(e6(n,"$req",t),e6(n,"SID","null"),i.U=!0,eL(i,n,null)):eL(i,n,t),this.I=2}}else 3==this.I&&(e?tV(this,e):0==this.i.length||eH(this.h)||tV(this))},t.Da=function(){if(this.v=null,tG(this),this.aa&&!(this.P||null==this.g||this.T<=0)){var e=4*this.T;this.j.info("BP detection timer enabled: "+e),this.B=ex(y(this.Wa,this),e)}},t.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,eE(10),tP(this),tG(this))},t.Va=function(){null!=this.C&&(this.C=null,tP(this),tj(this),eE(19))},t.bb=function(e){e?(this.j.info("Successfully pinged google.com"),eE(2)):(this.j.info("Failed to ping google.com"),eE(1))},t.isActive=function(){return!!this.l&&this.l.isActive(this)},(t=tX.prototype).ra=function(){},t.qa=function(){},t.pa=function(){},t.oa=function(){},t.isActive=function(){return!0},t.Ka=function(){},tZ.prototype.g=function(e,t){return new t0(e,t)},v(t0,er),t0.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},t0.prototype.close=function(){tO(this.g)},t0.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.v&&((n={}).__data__=eh(e),e=n);t.i.push(new e$(t.Ya++,e)),3==t.I&&tL(t)},t0.prototype.N=function(){this.g.l=null,delete this.j,tO(this.g),delete this.g,t0.Z.N.call(this)},v(t1,ep),v(t2,ey),v(t5,tX),t5.prototype.ra=function(){ei(this.g,"a")},t5.prototype.qa=function(e){ei(this.g,new t1(e))},t5.prototype.pa=function(e){ei(this.g,new t2)},t5.prototype.oa=function(){ei(this.g,"b")},tZ.prototype.createWebChannel=tZ.prototype.g,t0.prototype.send=t0.prototype.o,t0.prototype.open=t0.prototype.m,t0.prototype.close=t0.prototype.close,h=E.createWebChannelTransport=function(){return new tZ},u=E.getStatEventTarget=function(){return eb()},l=E.Event=ew,o=E.Stat={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},eD.NO_ERROR=0,eD.TIMEOUT=8,eD.HTTP_ERROR=6,a=E.ErrorCode=eD,eN.COMPLETE="complete",s=E.EventType=eN,em.EventType=eg,eg.OPEN="a",eg.CLOSE="b",eg.ERROR="c",eg.MESSAGE="d",er.prototype.listen=er.prototype.J,i=E.WebChannel=em,E.FetchXmlHttpFactory=tp,t_.prototype.listenOnce=t_.prototype.K,t_.prototype.getLastError=t_.prototype.Ha,t_.prototype.getLastErrorCode=t_.prototype.ya,t_.prototype.getStatus=t_.prototype.ca,t_.prototype.getResponseJson=t_.prototype.La,t_.prototype.getResponseText=t_.prototype.la,t_.prototype.send=t_.prototype.ea,t_.prototype.setWithCredentials=t_.prototype.Fa,r=E.XhrIo=t_}).apply(void 0!==_?_:"u">typeof self?self:"u">typeof window?window:{});class S{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}S.UNAUTHENTICATED=new S(null),S.GOOGLE_CREDENTIALS=new S("google-credentials-uid"),S.FIRST_PARTY=new S("first-party-uid"),S.MOCK_USER=new S("mock-user");let x="12.10.0",C=new T.Logger("@firebase/firestore");function A(){return C.logLevel}function D(e){C.setLogLevel(e)}function N(e,...t){if(C.logLevel<=T.LogLevel.DEBUG){let n=t.map(M);C.debug(`Firestore (${x}): ${e}`,...n)}}function k(e,...t){if(C.logLevel<=T.LogLevel.ERROR){let n=t.map(M);C.error(`Firestore (${x}): ${e}`,...n)}}function R(e,...t){if(C.logLevel<=T.LogLevel.WARN){let n=t.map(M);C.warn(`Firestore (${x}): ${e}`,...n)}}function M(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function O(e,t,n){let r="Unexpected state";"string"==typeof t?r=t:n=t,P(e,r,n)}function P(e,t,n){let r=`FIRESTORE (${x}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==n)try{r+=" CONTEXT: "+JSON.stringify(n)}catch(e){r+=" CONTEXT: "+n}throw k(r),Error(r)}function F(e,t,n,r){let i="Unexpected state";"string"==typeof n?i=n:r=n,e||P(t,i,r)}function L(e,t){e||O(57014,t)}let V={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",UNIMPLEMENT
1ED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class q extends v.FirebaseError{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class U{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class B{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class j{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(S.UNAUTHENTICATED))}shutdown(){}}class z{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class G{constructor(e){this.t=e,this.currentUser=S.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){F(void 0===this.o,42304);let n=this.i,r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve(),i=new U;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new U,e.enqueueRetryable(()=>r(this.currentUser))};let s=()=>{let t=i;e.enqueueRetryable(async()=>{await t.promise,await r(this.currentUser)})},a=e=>{N("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>a(e)),setTimeout(()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?a(e):(N("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new U)}},0),s()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(N("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(F("string"==typeof t.accessToken,31837,{l:t}),new B(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return F(null===e||"string"==typeof e,2055,{h:e}),new S(e)}}class K{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type="FirstParty",this.user=S.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);let e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class ${constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new K(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(S.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class Q{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class H{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,(0,g._isFirebaseServerApp)(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){F(void 0===this.o,3512);let n=e=>{null!=e.error&&N("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let n=e.token!==this.m;return this.m=e.token,N("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>n(t))};let r=e=>{N("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>r(e)),setTimeout(()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?r(e):N("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new Q(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(F("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new Q(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class W{getToken(){return Promise.resolve(new Q(""))}invalidateToken(){}start(e,t){}shutdown(){}}class J{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let n=function(e){let t="u">typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(40);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let e=0;e<40;
1e++)n[e]=Math.floor(256*Math.random());return n}(0);for(let r=0;r<n.length;++r)t.length<20&&n[r]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function Y(e,t){return e<t?-1:+(e>t)}function X(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e.charAt(r),i=t.charAt(r);if(n!==i)return Z(n)===Z(i)?Y(n,i):Z(n)?1:-1}return Y(e.length,t.length)}function Z(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}function ee(e,t,n){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}let et="__name__";class en{constructor(e,t,n){void 0===t?t=0:t>e.length&&O(637,{offset:t,range:e.length}),void 0===n?n=e.length-t:n>e.length-t&&O(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===en.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof en?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}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(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=en.compareSegments(e.get(r),t.get(r));if(0!==n)return n}return Y(e.length,t.length)}static compareSegments(e,t){let n=en.isNumericId(e),r=en.isNumericId(t);return n&&!r?-1:!n&&r?1:n&&r?en.extractNumericId(e).compare(en.extractNumericId(t)):X(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return t.fromString(e.substring(4,e.length-2))}}class er extends en{construct(e,t,n){return new er(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let n of e){if(n.indexOf("//")>=0)throw new q(V.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>e.length>0))}return new er(t)}static emptyPath(){return new er([])}}let ei=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class es extends en{construct(e,t,n){return new es(e,t,n)}static isValidIdentifier(e){return ei.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),es.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===et}static keyField(){return new es([et])}static fromServerFormat(e){let t=[],n="",r=0,i=()=>{if(0===n.length)throw new q(V.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""},s=!1;for(;r<e.length;){let t=e[r];if("\\"===t){if(r+1===e.length)throw new q(V.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new q(V.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?s=!s:"."!==t||s?n+=t:i(),r++}if(i(),s)throw new q(V.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new es(t)}static emptyPath(){return new es([])}}class ea{constructor(e){this.path=e}static fromPath(e){return new ea(er.fromString(e))}static fromName(e){return new ea(er.fromString(e).popFirst(5))}static empty(){return new ea(er.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===er.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return er.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new ea(new er(e.slice()))}}function eo(e,t,n){if(!n)throw new q(V.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function el(e,t,n,r){if(!0===t&&!0===r)throw new q(V.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function eu(e){if(!ea.isDocumentKey(e))throw new q(V.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function eh(e){if(ea.isDocumentKey(e))throw new q(V.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function ec(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function ed(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{var t;let n=(t=e).constructor?t.constructor.name:null;return n?`a custom ${n} object`:"an object"}}return"function"==typeof e?"a function":O(12329,{type:typeof e})}function ef(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new q(V.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let n=ed(e);throw new q(V.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function em(e,t){if(t<=0)throw new q(V.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function eg(e,t){let n={typeString:e};return t&&(n.value=t),n}function ep(e,t){let n;if(!ec(e))throw new q(V.INVALID_ARGUMENT,"JSON must be an object");for(let r in t)if(t[r]){let i=t[r].typeString,s="value"in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}let a=e[r];if(i&&typeof a!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(void 0!==s&&a!==s.value){n=`Expected '${r}' field to equal '${s.value}'`;break}}if(n)throw new q(V.INVALID_ARGUMENT,n);return!0}class ey{static now(){return ey.fromMillis(Date.now())}static fromDate(e){return ey.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*1e6);return new ey(t,n)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new q(V.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-0xe7791f700||e>=0x3afff44180)throw new q(V.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?Y(this.nanoseconds,e.nanoseconds):Y(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:ey._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(ep(e,ey._jsonSchema))return new ey(e.seconds,e.nanoseconds)}valueOf(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
1}ey._jsonSchemaVersion="firestore/timestamp/1.0",ey._jsonSchema={type:eg("string",ey._jsonSchemaVersion),seconds:eg("number"),nanoseconds:eg("number")};class ew{static fromTimestamp(e){return new ew(e)}static min(){return new ew(new ey(0,0))}static max(){return new ew(new ey(0x3afff4417f,0x3b9ac9ff))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class ev{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}function eb(e){return e.fields.find(e=>2===e.kind)}function eI(e){return e.fields.filter(e=>2!==e.kind)}function eT(e,t){let n=Y(e.collectionGroup,t.collectionGroup);if(0!==n)return n;for(let r=0;r<Math.min(e.fields.length,t.fields.length);++r)if(0!==(n=function(e,t){let n=es.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:Y(e.kind,t.kind)}(e.fields[r],t.fields[r])))return n;return Y(e.fields.length,t.fields.length)}ev.UNKNOWN_ID=-1;class e_{constructor(e,t){this.fieldPath=e,this.kind=t}}class eE{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new eE(0,eC.min())}}function eS(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new eC(ew.fromTimestamp(1e9===r?new ey(n+1,0):new ey(n,r)),ea.empty(),t)}function ex(e){return new eC(e.readTime,e.key,-1)}class eC{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new eC(ew.min(),ea.empty(),-1)}static max(){return new eC(ew.max(),ea.empty(),-1)}}function eA(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n||0!==(n=ea.comparator(e.documentKey,t.documentKey))?n:Y(e.largestBatchId,t.largestBatchId)}let eD="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class eN{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function ek(e){if(e.code!==V.FAILED_PRECONDITION||e.message!==eD)throw e;N("LocalStore","Unexpectedly lost primary lease")}class eR{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&O(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new eR((n,r)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(n,r)},this.catchCallback=e=>{this.wrapFailure(t,e).next(n,r)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof eR?t:eR.resolve(t)}catch(e){return eR.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):eR.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):eR.reject(t)}static resolve(e){return new eR((t,n)=>{t(e)})}static reject(e){return new eR((t,n)=>{n(e)})}static waitFor(e){return new eR((t,n)=>{let r=0,i=0,s=!1;e.forEach(e=>{++r,e.next(()=>{++i,s&&i===r&&t()},e=>n(e))}),s=!0,i===r&&t()})}static or(e){let t=eR.resolve(!1);for(let n of e)t=t.next(e=>e?eR.resolve(e):n());return t}static forEach(e,t){let n=[];return e.forEach((e,r)=>{n.push(t.call(this,e,r))}),this.waitFor(n)}static mapArray(e,t){return new eR((n,r)=>{let i=e.length,s=Array(i),a=0;for(let o=0;o<i;o++){let l=o;t(e[l]).next(e=>{s[l]=e,++a===i&&n(s)},e=>r(e))}})}static doWhile(e,t){return new eR((n,r)=>{let i=()=>{!0===e()?t().next(()=>{i()},r):n()};i()})}}let eM="SimpleDb";class eO{static open(e,t,n,r){try{return new eO(t,e.transaction(r,n))}catch(e){throw new eV(t,e)}}constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.S=new U,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{t.error?this.S.reject(new eV(e,t.error)):this.S.resolve()},this.transaction.onerror=t=>{let n=ez(t.target.error);this.S.reject(new eV(e,n))}}get D(){return this.S.promise}abort(e){e&&this.S.reject(e),this.aborted||(N(eM,"Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}C(){let e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){return new eU(this.transaction.objectStore(e))}}class eP{static delete(e){return N(eM,"Removing database:",e),eB((0,v.getGlobal)().indexedDB.deleteDatabase(e)).toPromise()}static v(){if(!(0,v.isIndexedDBAvailable)())return!1;if(eP.F())return!0;let e=(0,v.getUA)(),t=eP.M(e),n=eF(e);return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||0<t&&t<10||0<n&&n<4.5)}static F(){return void 0!==y.default&&"YES"===y.default.__PRIVATE_env?.__PRIVATE_USE_MOCK_PERSISTENCE}static O(e,t){return e.store(t)}static M(e){let t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i);return Number(t?t[1].split("_").slice(0,2).join("."):"-1")}constructor(e,t,n){this.name=e,this.version=t,this.N=n,this.B=null,12.2===eP.M((0,v.getUA)())&&k("Firestore persistence suffers from a bug in 
1iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}async L(e){return this.db||(N(eM,"Opening database:",this.name),this.db=await new Promise((t,n)=>{let r=indexedDB.open(this.name,this.version);r.onsuccess=e=>{t(e.target.result)},r.onblocked=()=>{n(new eV(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=t=>{let r=t.target.error;"VersionError"===r.name?n(new q(V.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):"InvalidStateError"===r.name?n(new q(V.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+r)):n(new eV(e,r))},r.onupgradeneeded=e=>{N(eM,'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);let t=e.target.result;this.N.k(t,r.transaction,e.oldVersion,this.version).next(()=>{N(eM,"Database upgrade to version "+this.version+" complete")})}})),this.K&&(this.db.onversionchange=e=>this.K(e)),this.db}q(e){this.K=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,r){let i="readonly"===t,s=0;for(;;){++s;try{this.db=await this.L(e);let t=eO.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).next(e=>(t.C(),e)).catch(e=>(t.abort(e),eR.reject(e))).toPromise();return s.catch(()=>{}),await t.D,s}catch(t){let e="FirebaseError"!==t.name&&s<3;if(N(eM,"Transaction failed with error:",t.message,"Retrying:",e),this.close(),!e)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}function eF(e){let t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}class eL{constructor(e){this.U=e,this.$=!1,this.W=null}get isDone(){return this.$}get G(){return this.W}set cursor(e){this.U=e}done(){this.$=!0}j(e){this.W=e}delete(){return eB(this.U.delete())}}class eV extends q{constructor(e,t){super(V.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function eq(e){return"IndexedDbTransactionError"===e.name}class eU{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(N(eM,"PUT",this.store.name,e,t),n=this.store.put(t,e)):(N(eM,"PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),eB(n)}add(e){return N(eM,"ADD",this.store.name,e,e),eB(this.store.add(e))}get(e){return eB(this.store.get(e)).next(t=>(void 0===t&&(t=null),N(eM,"GET",this.store.name,e,t),t))}delete(e){return N(eM,"DELETE",this.store.name,e),eB(this.store.delete(e))}count(){return N(eM,"COUNT",this.store.name),eB(this.store.count())}H(e,t){let n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if("function"==typeof r.getAll){let e=r.getAll(n.range);return new eR((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}})}{let e=this.cursor(n),t=[];return this.J(e,(e,n)=>{t.push(n)}).next(()=>t)}}Z(e,t){let n=this.store.getAll(e,null===t?void 0:t);return new eR((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}})}X(e,t){N(eM,"DELETE ALL",this.store.name);let n=this.options(e,t);n.Y=!1;let r=this.cursor(n);return this.J(r,(e,t,n)=>n.delete())}ee(e,t){let n;t?n=e:(n={},t=e);let r=this.cursor(n);return this.J(r,t)}te(e){let t=this.cursor({});return new eR((n,r)=>{t.onerror=e=>{r(ez(e.target.error))},t.onsuccess=t=>{let r=t.target.result;r?e(r.primaryKey,r.value).next(e=>{e?r.continue():n()}):n()}})}J(e,t){let n=[];return new eR((r,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{let i=e.target.result;if(!i)return void r();let s=new eL(i),a=t(i.primaryKey,i.value,s);if(a instanceof eR){let e=a.catch(e=>(s.done(),eR.reject(e)));n.push(e)}s.isDone?r():null===s.G?i.continue():i.continue(s.G)}}).next(()=>eR.waitFor(n))}options(e,t){let n;return void 0!==e&&("string"==typeof e?n=e:t=e),{index:n,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){let n=this.store.index(e.index);return e.Y?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function eB(e){return new eR((t,n)=>{e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{n(ez(e.target.error))}})}let ej=!1;function ez(e){let t=eP.M((0,v.getUA)());if(t>=12.2&&t<13){let t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)>=0){let e=new q("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return ej||(ej=!0,setTimeout(()=>{throw e},0)),e}}return e}let eG="IndexBackfiller";class eK{constructor(e,t){this.asyncQueue=e,this.ne=t,this.task=null}start(){this.re(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}re(e){N(eG,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{let e=await this.ne.ie();
1N(eG,`Documents written: ${e}`)}catch(e){eq(e)?N(eG,"Ignoring IndexedDB error during index backfill: ",e):await ek(e)}await this.re(6e4)})}}class e${constructor(e,t){this.localStore=e,this.persistence=t}async ie(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",t=>this.se(t,e))}se(e,t){let n=new Set,r=t,i=!0;return eR.doWhile(()=>!0===i&&r>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(t=>{if(null!==t&&!n.has(t))return N(eG,`Processing collection: ${t}`),this.oe(e,t,r).next(e=>{r-=e,n.add(t)});i=!1})).next(()=>t-r)}oe(e,t,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(r=>this.localStore.localDocuments.getNextDocuments(e,t,r,n).next(n=>{let i=n.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next(()=>this._e(r,n)).next(n=>(N(eG,`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(e,t,n))).next(()=>i.size)}))}_e(e,t){let n=e;return t.changes.forEach((e,t)=>{let r=ex(t);eA(r,n)>0&&(n=r)}),new eC(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class eQ{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}}function eH(e){return null==e}function eW(e){return 0===e&&1/e==-1/0}function eJ(e){return"number"==typeof e&&Number.isInteger(e)&&!eW(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function eY(e){let t="";for(let n=0;n<e.length;n++)t.length>0&&(t+="\x01\x01"),t=function(e,t){let n=t,r=e.length;for(let t=0;t<r;t++){let r=e.charAt(t);switch(r){case"\0":n+="\x01\x10";break;case"\x01":n+="\x01\x11";break;default:n+=r}}return n}(e.get(n),t);return t+"\x01\x01"}eQ.ce=-1;function eX(e){let t=e.length;if(F(t>=2,64408,{path:e}),2===t)return F("\x01"===e.charAt(0)&&"\x01"===e.charAt(1),56145,{path:e}),er.emptyPath();let n=t-2,r=[],i="";for(let s=0;s<t;){let t=e.indexOf("\x01",s);switch((t<0||t>n)&&O(50515,{path:e}),e.charAt(t+1)){case"\x01":let a,o=e.substring(s,t);0===i.length?a=o:(i+=o,a=i,i=""),r.push(a);break;case"\x10":i+=e.substring(s,t),i+="\0";break;case"\x11":i+=e.substring(s,t+1);break;default:O(61167,{path:e})}s=t+2}return new er(r)}let eZ="remoteDocuments",e0="owner",e1="owner",e2="mutationQueues",e5="mutations",e3="batchId",e4="userMutationsIndex",e6=["userId","batchId"],e8={},e7="documentMutations",e9="remoteDocumentsV14",te=["prefixPath","collectionGroup","readTime","documentId"],tt="documentKeyIndex",tn=["prefixPath","collectionGroup","documentId"],tr="collectionGroupIndex",ti=["collectionGroup","readTime","prefixPath","documentId"],ts="remoteDocumentGlobal",ta="remoteDocumentGlobalKey",to="targets",tl="queryTargetsIndex",tu=["canonicalId","targetId"],th="targetDocuments",tc=["targetId","path"],td="documentTargetsIndex",tf=["path","targetId"],tm="targetGlobalKey",tg="targetGlobal",tp="collectionParents",ty=["collectionId","parent"],tw="clientMetadata",tv="bundles",tb="namedQueries",tI="indexConfiguration",tT="collectionGroupIndex",t_="indexState",tE=["indexId","uid"],tS="sequenceNumberIndex",tx=["uid","sequenceNumber"],tC="indexEntries",tA=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],tD="documentKeyIndex",tN=["indexId","uid","orderedDocumentKey"],tk="documentOverlays",tR=["userId","collectionPath","documentId"],tM="collectionPathOverlayIndex",tO=["userId","collectionPath","largestBatchId"],tP="collectionGroupOverlayIndex",tF=["userId","collectionGroup","largestBatchId"],tL="globals",tV=[e2,e5,e7,eZ,to,e0,tg,th,tw,ts,tp,tv,tb],tq=[...tV,tk],tU=[e2,e5,e7,e9,to,e0,tg,th,tw,ts,tp,tv,tb,tk],tB=[...tU,tI,t_,tC],tj=[...tB,tL];class tz extends eN{constructor(e,t){super(),this.le=e,this.currentSequenceNumber=t}}function tG(e,t){return eP.O(e.le,t)}function tK(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function t$(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function tQ(e,t){let n=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function tH(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class tW{constructor(e,t){this.comparator=e,this.root=t||tY.EMPTY}insert(e,t){return new tW(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,tY.BLACK,null,
1null))}remove(e){return new tW(this.comparator,this.root.remove(e,this.comparator).copy(null,null,tY.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r<0?n=n.left:(t+=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(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,n)=>(e(t,n),!1))}toString(){let e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new tJ(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new tJ(this.root,e,this.comparator,!1)}getReverseIterator(){return new tJ(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new tJ(this.root,e,this.comparator,!0)}}class tJ{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class tY{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:tY.RED,this.left=null!=r?r:tY.EMPTY,this.right=null!=i?i:tY.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new tY(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}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(e,t,n){let r=this,i=n(e,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n))).fixUp()}removeMin(){if(this.left.isEmpty())return tY.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()}remove(e,t){let n,r=this;if(0>t(e,r.key))r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===t(e,r.key)){if(r.right.isEmpty())return tY.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}rotateLeft(){let e=this.copy(null,null,tY.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,tY.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw O(43730,{key:this.key,value:this.value});if(this.right.isRed())throw O(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw O(27949);return e+ +!this.isRed()}}
1tY.EMPTY=null,tY.RED=!0,tY.BLACK=!1,tY.EMPTY=new class{constructor(){this.size=0}get key(){throw O(57766)}get value(){throw O(16141)}get color(){throw O(16727)}get left(){throw O(29726)}get right(){throw O(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new tY(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class tX{constructor(e){this.comparator=e,this.data=new tW(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new tZ(this.data.getIterator())}getIteratorFrom(e){return new tZ(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(e=>{t=t.add(e)}),t}isEqual(e){if(!(e instanceof tX)||this.size!==e.size)return!1;let t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){let e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new tX(this.comparator);return t.data=e,t}}class tZ{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function t0(e){return e.hasNext()?e.getNext():void 0}class t1{constructor(e){this.fields=e,e.sort(es.comparator)}static empty(){return new t1([])}unionWith(e){let t=new tX(es.comparator);for(let e of this.fields)t=t.add(e);for(let n of e)t=t.add(n);return new t1(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return ee(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class t2 extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}function t5(){return"u">typeof atob}class t3{constructor(e){this.binaryString=e}static fromBase64String(e){return new t3(function(e){try{return atob(e)}catch(e){throw"u">typeof DOMException&&e instanceof DOMException?new t2("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new t3(function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e))}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return btoa(this.binaryString)}toUint8Array(){var e=this.binaryString;let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return Y(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}t3.EMPTY_BYTE_STRING=new t3("");let t4=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function t6(e){if(F(!!e,39018),"string"==typeof e){let t=0,n=t4.exec(e);if(F(!!n,46558,{timestamp:e}),n[1]){let e=n[1];t=Number(e=(e+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:t8(e.seconds),nanos:t8(e.nanos)}}function t8(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function t7(e){return"string"==typeof e?t3.fromBase64String(e):t3.fromUint8Array(e)}let t9="server_timestamp",ne="__type__",nt="__previous_value__",nn="__local_write_time__";function nr(e){return(e?.mapValue?.fields||{})[ne]?.stringValue===t9}function ni(e){let t=e.mapValue.fields[nt];return nr(t)?ni(t):t}function ns(e){let t=t6(e.mapValue.fields[nn].timestampValue);return new ey(t.seconds,t.nanos)}class na{constructor(e,t,n,r,i,s,a,o,l,u,h){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u,this.apiKey=h}}let no="(default)";class nl{constructor(e,t){this.projectId=e,this.database=t||no}static empty(){return new nl("","")}get isDefaultDatabase(){return this.database===no}isEqual(e){return e instanceof nl&&e.projectId===this.projectId&&e.database===this.database}}let nu="__type__",nh="__max__",nc={mapValue:{fields:{__type__:{stringValue:nh}}}},nd="__vector__",nf="value",nm={nullValue:"NULL_VALUE"};function ng(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?nr(e)?4:nN(e)?0x1fffffffffffff:nA(e)?10:11:O(28295,{value:e})}function np(e,t){if(e===t)return!0;let n=ng(e);if(n!==ng(t))return!1;switch(n){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return ns(e).isEqual(ns(t));case 3:if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let r=t6(e.timestampValue),i=t6(t.timestampValue);return r.seconds===i.seconds&&r.nanos===i.nanos;case 5:return e.stringValue===t.stringValue;case 6:return t7(e.bytesValue).isEqual(t7(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return t8(e.geoPointValue.latitude)===t8(t.geoPointValue.latitude)&&t8(e.geoPointValue.longitude)===t8(t.geoPointValue.longitude);case 2:if("integerValue"in e&&"integerValue"in t)return t8(e.integerValue)===t8(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let n=t8(e.doubleValue),r=t8(t.doubleValue);return n===r?eW(n)===eW(r):isNaN(n)&&isNaN(r)}return!1;case 9:return ee(e.arrayValue.values||[],t.arrayValue.values||[],np);case 10:case 11:let s=e.mapValue.fields||{},a=t.mapValue.fields||{};if(tK(s)!==tK(a))return!1;for(let e in s)if(s.hasOwnProperty(e)&&(void 0===a[e]||!np(s[e],a[e])))return!1;return!0;default:return O(52216,{left:e})}}function ny(e,t){return void 0!==(e.values||[]).find(e=>np(e,t))}function nw(e,t){var n,r,i,s,a,o;if(e===t)return 0;let l=ng(e),u=ng(t);if(l!==u)return Y(l,u);switch(l){case 0:case 0x1fffffffffffff:return 0;case 1:return Y(e.booleanValue,t.booleanValue);case 2:let h,c;return h=t8(e.integerValue||e.doubleValue),h<(c=t8(t.integerValue||t.doubleValue))?-1:h>c?1:h===c?0:isNaN(h)?isNaN(c)?0:-1:1;case 3:return nv(e.timestampValue,t.timestampValue);case 4:return nv(ns(e),ns(t));case 5:return X(e.stringValue,t.stringValue);case 6:let d,f;return n=e.bytesValue,r=t.bytesValue,d=t7(n),f=t7(r),d.compareTo(f);case 7:return function(e,t){let n=e.split("/"),r=t.split("/");for(let e=0;e<n.length&&e<r.length;e++){let t=Y(n[e],r[e]);if(0!==t)return t}return Y(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:let m;return i=e.geoPointValue,s=t.geoPointValue,0!==(m=Y(t8(i.latitude),t8(s.latitude)))?m:Y(t8(i.longitude),t8(s.longitude));case 9:return nb(e.arrayValue,t.arrayValue);case 10:let g,p,y,w,v;return a=e.mapValue,o=t.mapValue,g=a.fields||{},p=o.fields||{},y=g[nf]?.arrayValue,w=p[nf]?.arrayValue,0!==(v=Y(y?.values?.length||0,w?.values?.length||0))?v:nb(y,w);case 11:return function(e,t){if(e===nc.mapValue&&t===nc.mapValue)return 0;if(e===nc.mapValue)return 1;if(t===nc.mapValue)return -1;let n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let e=0;e<r.length&&e<s.length;++e){let t=X(r[e],s[e]);if(0!==t)return t;let a=nw(n[r[e]],i[s[e]]);if(0!==a)return a}return Y(r.length,s.length)}(e.mapValue,t.mapValue);default:throw O(23264,{he:l})}}function nv(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return Y(e,t);let n=t6(e),r=t6(t),i=Y(n.seconds,r.seconds);return 0!==i?i:Y(n.nanos,r.nanos)}function nb(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=nw(n[e],r[e]);if(t)return t}return Y(n.length,r.length)}function nI(e){var t,n;let r;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?(r=t6(e.timestampValue),`time(${r.seconds},${r.nanos}
1)`):"stringValue"in e?e.stringValue:"bytesValue"in e?t7(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,ea.fromName(t).toString()):"geoPointValue"in e?(n=e.geoPointValue,`geo(${n.latitude},${n.longitude})`):"arrayValue"in e?function(e){let t="[",n=!0;for(let r of e.values||[])n?n=!1:t+=",",t+=nI(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),n="{",r=!0;for(let i of t)r?r=!1:n+=",",n+=`${i}:${nI(e.fields[i])}`;return n+"}"}(e.mapValue):O(61005,{value:e})}function nT(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function n_(e){return!!e&&"integerValue"in e}function nE(e){return!!e&&"arrayValue"in e}function nS(e){return!!e&&"nullValue"in e}function nx(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function nC(e){return!!e&&"mapValue"in e}function nA(e){return(e?.mapValue?.fields||{})[nu]?.stringValue===nd}function nD(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return t$(e.mapValue.fields,(e,n)=>t.mapValue.fields[e]=nD(n)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=nD(e.arrayValue.values[n]);return t}return{...e}}function nN(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===nh}let nk={mapValue:{fields:{[nu]:{stringValue:nd},[nf]:{arrayValue:{}}}}};function nR(e,t){let n=nw(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function nM(e,t){let n=nw(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class nO{constructor(e){this.value=e}static empty(){return new nO({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(!nC(t=(t.mapValue.fields||{})[e.get(n)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=nD(t)}setAll(e){let t=es.emptyPath(),n={},r=[];e.forEach((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=nD(e):r.push(i.lastSegment())});let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());nC(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return np(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let r=t.mapValue.fields[e.get(n)];nC(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){for(let r of(t$(t,(t,n)=>e[t]=n),n))delete e[r]}clone(){return new nO(nD(this.value))}}class nP{constructor(e,t,n,r,i,s,a){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=s,this.documentState=a}static newInvalidDocument(e){return new nP(e,0,ew.min(),ew.min(),ew.min(),nO.empty(),0)}static newFoundDocument(e,t,n,r){return new nP(e,1,t,ew.min(),n,r,0)}static newNoDocument(e,t){return new nP(e,2,t,ew.min(),ew.min(),nO.empty(),0)}static newUnknownDocument(e,t){return new nP(e,3,t,ew.min(),ew.min(),nO.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(ew.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=nO.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=nO.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=ew.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof nP&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new nP(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 nF{constructor(e,t){this.position=e,this.inclusive=t}}function nL(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){let s=t[i],a=e.position[i];if(r=s.field.isKeyField()?ea.comparator(ea.fromName(a.referenceValue),n.key):nw(a,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return r}function nV(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!np(e.position[n],t.position[n]))return!1;return!0}class nq{constructor(e,t="asc"){this.field=e,this.dir=t}}class nU{}class nB extends nU{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new nH(e,t,n):"array-contains"===t?new nX(e,n):"in"===t?new nZ(e,n):"not-in"===t?new n0(e,n):"array-contains-any"===t?new n1(e,n):new nB(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new nW(e,n):new nJ(e,n)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(nw(t,this.value)):null!==t&&ng(this.value)===ng(t)&&this.matchesComparison(nw(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return O(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class nj extends nU{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new nj(e,t)}matches(e){return nz(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.Pe||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function nz(e){return"and"===e.op}function nG(e){return"or"===e.op}function nK(e){return n$(e)&&nz(e)}function n$(e){for(let t of e.filters)if(t instanceof nj)return!1;return!0}function nQ(e,t){let n=e.filters.concat(t);return nj.create(n,e.op)}class nH extends nB{constructor(e,t,n){super(e,t,n),this.key=ea.fromName(n.referenceValue)}matches(e){let t=ea.comparator(e.key,this.key);return this.matchesComparison(t)}}class nW extends nB{constructor(e,t){super(e,"in",t),this.keys=nY("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class nJ extends nB{constructor(e,t){super(e,"not-in",t),this.keys=nY("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function nY(e,t){return(t.arrayValue?.values||[]).map(e=>ea.fromName(e.referenceValue))}class nX extends nB{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return nE(t)&&ny(t.arrayValue,this.value)}}class nZ extends nB{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&ny(this.value.arrayValue,t)}}class n0 extends nB{constructor(e,t){super(e,"not-in",t)}matches(e){if(ny(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!ny(this.value.arrayValue,t)}}class n1 extends nB{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!nE(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>ny(this.value.arrayValue,e))}}class n2{constructor(e,t=null,n=[],r=[],i=null,s=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=a,this.Te=null}}function n5(e,t=null,n=[],r=[],i=null,s=null,a=null){return new n2(e,t,n,r,i,s,a)}function n3(e){if(null===e.Te){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(e=>(function e(t){if(t instanceof nB)return t.field.canonicalString()+t.op.toString()+nI(t.value);if(nK(t))return t.filters.map(t=>e(t)).join(",");{let n=t.filters.map(t=>e(t)).join(",");return`${t.op}(${n})`}})(e)).join(","),t+="|ob:",t+=e.orderBy.map(e=>e.field.canonicalString()+e.dir).join(","),eH(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(e=>nI(e)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>nI(e)).join(",")),e.Te=t}return e.Te}function n4(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let i=0;i<e.orderBy.length;i++){var n,r;if(n=e.orderBy[i],r=t.orderBy[i],!(n.dir===r.dir&&n.field.isEqual(r.field)))return!1}if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!function e(t,n){return t instanceof nB?n instanceof nB&&t.op===n.op&&t.field.isEqual(n.field)&&np(t.value,n.value):t instanceof nj?n instanceof nj&&t.op===n.op&&t.filters.length===n.filters.length&&t.filters.reduce((t,r,i)=>t&&e(r,n.filters[i]),!0):void O(19439)}(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!nV(e.startAt,t.startAt)&&nV(e.endAt,t.endAt)}function n6(e){return ea.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function n8(e,t){return e.filters.filter(e=>e instanceof nB&&e.field.isEqual(t))}
1function n7(e,t,n){let r=nm,i=!0;for(let n of n8(e,t)){let e=nm,t=!0;switch(n.op){case"<":case"<=":var s;e="nullValue"in(s=n.value)?nm:"booleanValue"in s?{booleanValue:!1}:"integerValue"in s||"doubleValue"in s?{doubleValue:NaN}:"timestampValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in s?{stringValue:""}:"bytesValue"in s?{bytesValue:""}:"referenceValue"in s?nT(nl.empty(),ea.empty()):"geoPointValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in s?{arrayValue:{}}:"mapValue"in s?nA(s)?nk:{mapValue:{}}:O(35942,{value:s});break;case"==":case"in":case">=":e=n.value;break;case">":e=n.value,t=!1;break;case"!=":case"not-in":e=nm}0>nR({value:r,inclusive:i},{value:e,inclusive:t})&&(r=e,i=t)}if(null!==n){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=n.position[s];0>nR({value:r,inclusive:i},{value:e,inclusive:n.inclusive})&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}function n9(e,t,n){let r=nc,i=!0;for(let n of n8(e,t)){let e=nc,t=!0;switch(n.op){case">=":case">":var s;e="nullValue"in(s=n.value)?{booleanValue:!1}:"booleanValue"in s?{doubleValue:NaN}:"integerValue"in s||"doubleValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in s?{stringValue:""}:"stringValue"in s?{bytesValue:""}:"bytesValue"in s?nT(nl.empty(),ea.empty()):"referenceValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in s?{arrayValue:{}}:"arrayValue"in s?nk:"mapValue"in s?nA(s)?{mapValue:{}}:nc:O(61959,{value:s}),t=!1;break;case"==":case"in":case"<=":e=n.value;break;case"<":e=n.value,t=!1;break;case"!=":case"not-in":e=nc}nM({value:r,inclusive:i},{value:e,inclusive:t})>0&&(r=e,i=t)}if(null!==n){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=n.position[s];nM({value:r,inclusive:i},{value:e,inclusive:n.inclusive})>0&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}class re{constructor(e,t=null,n=[],r=[],i=null,s="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=a,this.endAt=o,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function rt(e){return new re(e)}function rn(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function rr(e){return null!==e.collectionGroup}function ri(e){if(null===e.Ie){let t;e.Ie=[];let n=new Set;for(let t of e.explicitOrderBy)e.Ie.push(t),n.add(t.field.canonicalString());let r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(t=new tX(es.comparator),e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t).forEach(t=>{n.has(t.canonicalString())||t.isKeyField()||e.Ie.push(new nq(t,r))}),n.has(es.keyField().canonicalString())||e.Ie.push(new nq(es.keyField(),r))}return e.Ie}function rs(e){return e.Ee||(e.Ee=ro(e,ri(e))),e.Ee}function ra(e){return e.Re||(e.Re=ro(e,e.explicitOrderBy)),e.Re}function ro(e,t){if("F"===e.limitType)return n5(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{let t="desc"===e.dir?"asc":"desc";return new nq(e.field,t)});let n=e.endAt?new nF(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new nF(e.startAt.position,e.startAt.inclusive):null;return n5(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function rl(e,t){let n=e.filters.concat([t]);return new re(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function ru(e,t,n){return new re(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function rh(e,t){return n4(rs(e),rs(t))&&e.limitType===t.limitType}function rc(e){return`${n3(rs(e))}|lt:${e.limitType}`}function rd(e){var t;let n;return`Query(target=${n=(t=rs(e)).path.canonicalString(),null!==t.collectionGroup&&(n+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(n+=`, filters: [${t.filters.map(e=>(function e(t){return t instanceof nB?`${t.field.canonicalString()} ${t.op} ${nI(t.value)}`:t instanceof nj?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),eH(t.limit)||(n+=", limit: "+t.limit),t.orderBy.length>0&&(n+=`, orderBy: [${t.orderBy.map(e=>`${e.field.canonicalString()} (${e.dir})`).join(", ")}]`),t.startAt&&(n+=", startAt: ",n+=t.startAt.inclusive?"b:":"a:",n+=t.startAt.position.map(e=>nI(e)).join(",")),t.endAt&&(n+=", endAt: ",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(e=>nI(e)).join(",")),`Target(${n})`}; limitType=${e.limitType})`}function rf(e,t){var n,r,i,s;let a,o,l;
1return t.isFoundDocument()&&(a=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(a):ea.isDocumentKey(e.path)?e.path.isEqual(a):e.path.isImmediateParentOf(a))&&function(e,t){for(let n of ri(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(let n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&(n=e,r=t,(!n.startAt||(i=n.startAt,o=nL(i,ri(n),r),i.inclusive?!!(o<=0):!!(o<0)))&&(!n.endAt||(s=n.endAt,l=nL(s,ri(n),r),s.inclusive?!!(l>=0):!!(l>0))))}function rm(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function rg(e){return(t,n)=>{let r=!1;for(let i of ri(e)){let e=function(e,t,n){var r;let i,s,a=e.field.isKeyField()?ea.comparator(t.key,n.key):(r=e.field,i=t.data.field(r),s=n.data.field(r),null!==i&&null!==s?nw(i,s):O(42886));switch(e.dir){case"asc":return a;case"desc":return -1*a;default:return O(19790,{direction:e.dir})}}(i,t,n);if(0!==e)return e;r=r||i.field.isKeyField()}return 0}}class rp{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n){for(let[t,r]of n)if(this.equalsFn(t,e))return r}}has(e){return void 0!==this.get(e)}set(e,t){let n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){t$(this.inner,(t,n)=>{for(let[t,r]of n)e(t,r)})}isEmpty(){return tH(this.inner)}size(){return this.innerSize}}let ry=new tW(ea.comparator),rw=new tW(ea.comparator);function rv(...e){let t=rw;for(let n of e)t=t.insert(n.key,n);return t}function rb(e){let t=rw;return e.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function rI(){return new rp(e=>e.toString(),(e,t)=>e.isEqual(t))}let rT=new tW(ea.comparator),r_=new tX(ea.comparator);function rE(...e){let t=r_;for(let n of e)t=t.add(n);return t}let rS=new tX(Y);function rx(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:eW(t)?"-0":t}}function rC(e){return{integerValue:""+e}}function rA(e,t){return eJ(t)?rC(t):rx(e,t)}class rD{constructor(){this._=void 0}}function rN(e,t){return e instanceof rF?n_(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}class rk extends rD{}class rR extends rD{constructor(e){super(),this.elements=e}}function rM(e,t){let n=rV(t);for(let t of e.elements)n.some(e=>np(e,t))||n.push(t);return{arrayValue:{values:n}}}class rO extends rD{constructor(e){super(),this.elements=e}}function rP(e,t){let n=rV(t);for(let t of e.elements)n=n.filter(e=>!np(e,t));return{arrayValue:{values:n}}}class rF extends rD{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function rL(e){return t8(e.integerValue||e.doubleValue)}function rV(e){return nE(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class rq{constructor(e,t){this.field=e,this.transform=t}}class rU{constructor(e,t){this.version=e,this.transformResults=t}}class rB{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new rB}static exists(e){return new rB(void 0,e)}static updateTime(e){return new rB(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function rj(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class rz{}function rG(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new rX(e.key,rB.none()):new rQ(e.key,e.data,rB.none());{let n=e.data,r=nO.empty(),i=new tX(es.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);null===t&&e.length>1&&(e=e.popLast(),t=n.field(e)),null===t?r.delete(e):r.set(e,t),i=i.add(e)}return new rH(e.key,r,new t1(i.toArray()),rB.none())}}function rK(e,t,n,r){return e instanceof rQ?function(e,t,n,r){if(!rj(e.precondition,t))return n;let i=e.value.clone(),s=rY(e.fieldTransforms,r,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof rH?function(e,t,n,r){if(!rj(e.precondition,t))return n;let i=rY(e.fieldTransforms,r,t),s=t.data;return(s.setAll(rW(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===n)?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,n,r):rj(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}function r$(e,t){var n,r;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(n=e.fieldTransforms,r=t.fieldTransforms,!!(void 0===n&&void 0===r||!(!n||!r)&&ee(n,r,(e,t)=>{var n,r;return e.field.isEqual(t.field)&&(n=e.transform,r=t.transform,n instanceof rR&&r instanceof rR||n instanceof rO&&r instanceof rO?ee(n.elements,r.elements,np):n instanceof rF&&r instanceof rF?np(n.Ae,r.Ae):n instanceof rk&&r instanceof rk)}
1)))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class rQ extends rz{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class rH extends rz{constructor(e,t,n,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function rW(e){let t=new Map;return e.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){let r=e.data.field(n);t.set(n,r)}}),t}function rJ(e,t,n){let r=new Map;F(e.length===n.length,32656,{Ve:n.length,de:e.length});for(let s=0;s<n.length;s++){var i;let a=e[s],o=a.transform,l=t.data.field(a.field);r.set(a.field,(i=n[s],o instanceof rR?rM(o,l):o instanceof rO?rP(o,l):i))}return r}function rY(e,t,n){let r=new Map;for(let i of e){let e=i.transform,s=n.data.field(i.field);r.set(i.field,function(e,t,n){var r;let i,s,a;return e instanceof rk?(r=t,i={fields:{[ne]:{stringValue:t9},[nn]:{timestampValue:{seconds:n.seconds,nanos:n.nanoseconds}}}},r&&nr(r)&&(r=ni(r)),r&&(i.fields[nt]=r),{mapValue:i}):e instanceof rR?rM(e,t):e instanceof rO?rP(e,t):(a=rL(s=rN(e,t))+rL(e.Ae),n_(s)&&n_(e.Ae)?rC(a):rx(e.serializer,a))}(e,s,t))}return r}class rX extends rz{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rZ extends rz{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class r0{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let r=this.mutations[t];r.key.isEqual(e.key)&&function(e,t,n){let r,i;e instanceof rQ?(r=e.value.clone(),i=rJ(e.fieldTransforms,t,n.transformResults),r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()):e instanceof rH?function(e,t,n){if(!rj(e.precondition,t))return t.convertToUnknownDocument(n.version);let r=rJ(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(rW(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):t.convertToNoDocument(n.version).setHasCommittedMutations()}(r,e,n[t])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=rK(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=rK(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=rI();return this.mutations.forEach(r=>{let i=e.get(r.key),s=i.overlayedDocument,a=this.applyToLocalView(s,i.mutatedFields),o=rG(s,a=t.has(r.key)?null:a);null!==o&&n.set(r.key,o),s.isValidDocument()||s.convertToNoDocument(ew.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),rE())}isEqual(e){return this.batchId===e.batchId&&ee(this.mutations,e.mutations,(e,t)=>r$(e,t))&&ee(this.baseMutations,e.baseMutations,(e,t)=>r$(e,t))}}class r1{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){F(e.mutations.length===n.length,58842,{me:e.mutations.length,fe:n.length});let r=rT,i=e.mutations;for(let e=0;e<i.length;e++)r=r.insert(i[e].key,n[e].version);return new r1(e,t,n,r)}}class r2{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{
2      largestBatchId: ${this.largestBatchId},
3      mutation: ${this.mutation.toString()}
4    }`}}class r5{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}}class r3{constructor(e,t){this.count=e,this.unchangedNames=t}}function r4(e){switch(e){case V.OK:return O(64938);case V.CANCELLED:case V.UNKNOWN:case V.DEADLINE_EXCEEDED:case V.RESOURCE_EXHAUSTED:case V.INTERNAL:case V.UNAVAILABLE:case V.UNAUTHENTICATED:return!1;case V.INVALID_ARGUMENT:case V.NOT_FOUND:case V.ALREADY_EXISTS:case V.PERMISSION_DENIED:case V.FAILED_PRECONDITION:case V.ABORTED:case V.OUT_OF_RANGE:case V.UNIMPLEMENT
4ED:case V.DATA_LOSS:return!0;default:return O(15467,{code:e})}}function r6(e){if(void 0===e)return k("GRPC error has no .code"),V.UNKNOWN;switch(e){case c.OK:return V.OK;case c.CANCELLED:return V.CANCELLED;case c.UNKNOWN:return V.UNKNOWN;case c.DEADLINE_EXCEEDED:return V.DEADLINE_EXCEEDED;case c.RESOURCE_EXHAUSTED:return V.RESOURCE_EXHAUSTED;case c.INTERNAL:return V.INTERNAL;case c.UNAVAILABLE:return V.UNAVAILABLE;case c.UNAUTHENTICATED:return V.UNAUTHENTICATED;case c.INVALID_ARGUMENT:return V.INVALID_ARGUMENT;case c.NOT_FOUND:return V.NOT_FOUND;case c.ALREADY_EXISTS:return V.ALREADY_EXISTS;case c.PERMISSION_DENIED:return V.PERMISSION_DENIED;case c.FAILED_PRECONDITION:return V.FAILED_PRECONDITION;case c.ABORTED:return V.ABORTED;case c.OUT_OF_RANGE:return V.OUT_OF_RANGE;case c.UNIMPLEMENTED:return V.UNIMPLEMENTED;case c.DATA_LOSS:return V.DATA_LOSS;default:return O(39323,{code:e})}}(d=c||(c={}))[d.OK=0]="OK",d[d.CANCELLED=1]="CANCELLED",d[d.UNKNOWN=2]="UNKNOWN",d[d.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",d[d.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",d[d.NOT_FOUND=5]="NOT_FOUND",d[d.ALREADY_EXISTS=6]="ALREADY_EXISTS",d[d.PERMISSION_DENIED=7]="PERMISSION_DENIED",d[d.UNAUTHENTICATED=16]="UNAUTHENTICATED",d[d.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",d[d.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",d[d.ABORTED=10]="ABORTED",d[d.OUT_OF_RANGE=11]="OUT_OF_RANGE",d[d.UNIMPLEMENTED=12]="UNIMPLEMENTED",d[d.INTERNAL=13]="INTERNAL",d[d.UNAVAILABLE=14]="UNAVAILABLE",d[d.DATA_LOSS=15]="DATA_LOSS";let r8=null;function r7(){return new TextEncoder}let r9=new t([0xffffffff,0xffffffff],0);function ie(e){let t=r7().encode(e),r=new n;return r.update(t),new Uint8Array(r.digest())}function it(e){let n=new DataView(e.buffer),r=n.getUint32(0,!0),i=n.getUint32(4,!0),s=n.getUint32(8,!0),a=n.getUint32(12,!0);return[new t([r,i],0),new t([s,a],0)]}class ir{constructor(e,n,r){if(this.bitmap=e,this.padding=n,this.hashCount=r,n<0||n>=8)throw new ii(`Invalid padding: ${n}`);if(r<0||e.length>0&&0===this.hashCount)throw new ii(`Invalid hash count: ${r}`);if(0===e.length&&0!==n)throw new ii(`Invalid padding when bitmap length is 0: ${n}`);this.ge=8*e.length-n,this.pe=t.fromNumber(this.ge)}ye(e,n,r){let i=e.add(n.multiply(t.fromNumber(r)));return 1===i.compare(r9)&&(i=new t([i.getBits(0),i.getBits(1)],0)),i.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.ge)return!1;let[t,n]=it(ie(e));for(let e=0;e<this.hashCount;e++){let r=this.ye(t,n,e);if(!this.we(r))return!1}return!0}static create(e,t,n){let r=new ir(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);return n.forEach(e=>r.insert(e)),r}insert(e){if(0===this.ge)return;let[t,n]=it(ie(e));for(let e=0;e<this.hashCount;e++){let r=this.ye(t,n,e);this.be(r)}}be(e){let t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}
4class ii extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class is{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,n){let r=new Map;return r.set(e,ia.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new is(ew.min(),r,new tW(Y),ry,rE())}}class ia{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new ia(n,t,rE(),rE(),rE())}}class io{constructor(e,t,n,r){this.Se=e,this.removedTargetIds=t,this.key=n,this.De=r}}class il{constructor(e,t){this.targetId=e,this.Ce=t}}class iu{constructor(e,t,n=t3.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class ih{constructor(){this.ve=0,this.Fe=im(),this.Me=t3.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return 0!==this.ve}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=rE(),t=rE(),n=rE();return this.Fe.forEach((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:O(38017,{changeType:i})}}),new ia(this.Me,this.xe,e,t,n)}Ke(){this.Oe=!1,this.Fe=im()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,F(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class ic{constructor(e){this.Ge=e,this.ze=new Map,this.je=ry,this.He=id(),this.Je=id(),this.Ze=new tW(Y)}Xe(e){for(let t of e.Se)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(let t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{let n=this.nt(t);switch(e.state){case 0:this.rt(t)&&n.Le(e.resumeToken);break;case 1:n.We(),n.Ne||n.Ke(),n.Le(e.resumeToken);break;case 2:n.We(),n.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(n.Qe(),n.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),n.Le(e.resumeToken));break;default:O(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((e,n)=>{this.rt(n)&&t(n)})}st(e){let t=e.targetId,n=e.Ce.count,r=this.ot(t);if(r){let a=r.target;if(n6(a))if(0===n){let e=new ea(a.path);this.et(t,e,nP.newNoDocument(e,ew.min()))}else F(1===n,20013,{expectedCount:n});else{let r=this._t(t);if(r!==n){var i,s;let n,a,o=this.ut(e),l=o?this.ct(o,e,r):1;0!==l&&(this.it(t),this.Ze=this.Ze.insert(t,2===l?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch")),r8?.lt((i=e.Ce,s=this.Ge.ht(),n={localCacheCount:r,existenceFilterCount:i.count,databaseId:s.database,projectId:s.projectId},(a=i.unchangedNames)&&(n.bloomFilter={applied:0===l,hashCount:a?.hashCount??0,bitmapLength:a?.bits?.bitmap?.length??0,padding:a?.bits?.padding??0,mightContain:e=>o?.mightContain(e)??!1}),n))}}}}ut(e){let t,n,r=e.Ce.unchangedNames;if(!r||!r.bits)return null;let{bits:{bitmap:i="",padding:s=0},hashCount:a=0}=r;try{t=t7(i).toUint8Array()}catch(e){if(e instanceof t2)return R("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{n=new ir(t,s,a)}catch(e){return R(e instanceof ii?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===n.ge?null:n}ct(e,t,n){return 2*(t.Ce.count!==n-this.Pt(e,t.targetId))}Pt(e,t){let n=this.Ge.getRemoteKeysForTarget(t),r=0;return n.forEach(n=>{let i=this.Ge.ht(),s=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(s)||(this.et(t,n,null),r++)}),r}Tt(e){let t=new Map;this.ze.forEach((n,r)=>{let i=this.ot(r);if(i){if(n.current&&n6(i.target)){let t=new ea(i.target.path);this.It(t).has(r)||this.Et(r,t)||this.et(r,t,nP.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.Ke())}});let n=rE();this.Je.forEach((e,t)=>{let r=!0;t.forEachWhile(e=>{let t=this.ot(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)}),r&&(n=n.add(e))}),this.je.forEach((t,n)=>n.setReadTime(e));let r=new is(e,t,this.Ze,this.je,n);return this.je=ry,this.He=id(),this.Je=id(),this.Ze=new tW(Y),r}Ye(e,t){if(!this.rt(e))return;
4let n=2*!!this.Et(e,t.key);this.nt(e).qe(t.key,n),this.je=this.je.insert(t.key,t),this.He=this.He.insert(t.key,this.It(t.key).add(e)),this.Je=this.Je.insert(t.key,this.Rt(t.key).add(e))}et(e,t,n){if(!this.rt(e))return;let r=this.nt(e);this.Et(e,t)?r.qe(t,1):r.Ue(t),this.Je=this.Je.insert(t,this.Rt(t).delete(e)),this.Je=this.Je.insert(t,this.Rt(t).add(e)),n&&(this.je=this.je.insert(t,n))}removeTarget(e){this.ze.delete(e)}_t(e){let t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new ih,this.ze.set(e,t)),t}Rt(e){let t=this.Je.get(e);return t||(t=new tX(Y),this.Je=this.Je.insert(e,t)),t}It(e){let t=this.He.get(e);return t||(t=new tX(Y),this.He=this.He.insert(e,t)),t}rt(e){let t=null!==this.ot(e);return t||N("WatchChangeAggregator","Detected inactive target",e),t}ot(e){let t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new ih),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function id(){return new tW(ea.comparator)}function im(){return new tW(ea.comparator)}let ig={asc:"ASCENDING",desc:"DESCENDING"},ip={"<":"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"},iy={and:"AND",or:"OR"};class iw{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function iv(e,t){return e.useProto3Json||eH(t)?t:{value:t}}function ib(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function iI(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function iT(e){let t;return F(!!e,49232),ew.fromTimestamp(new ey((t=t6(e)).seconds,t.nanos))}function i_(e,t){return iE(e,t).canonicalString()}function iE(e,t){let n=new er(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?n:n.child(t)}function iS(e){let t=er.fromString(e);return F(ij(t),10190,{key:t.toString()}),t}function ix(e,t){return i_(e.databaseId,t.path)}function iC(e,t){let n=iS(t);if(n.get(1)!==e.databaseId.projectId)throw new q(V.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new q(V.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new ea(ik(n))}function iA(e,t){return i_(e.databaseId,t)}function iD(e){let t=iS(e);return 4===t.length?er.emptyPath():ik(t)}function iN(e){return new er(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function ik(e){return F(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function iR(e,t,n){return{name:ix(e,t),fields:n.value.mapValue.fields}}function iM(e,t,n){let r=iC(e,t.name),i=iT(t.updateTime),s=t.createTime?iT(t.createTime):ew.min(),a=new nO({mapValue:{fields:t.fields}}),o=nP.newFoundDocument(r,i,s,a);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function iO(e,t){var n,r;let i;if(t instanceof rQ)i={update:iR(e,t.key,t.value)};else if(t instanceof rX)i={delete:ix(e,t.key)};else if(t instanceof rH){let n;i={update:iR(e,t.key,t.data),updateMask:(r=t.fieldMask,n=[],r.fields.forEach(e=>n.push(e.canonicalString())),{fieldPaths:n})}}else{if(!(t instanceof rZ))return O(16599,{dt:t.type});i={verify:ix(e,t.key)}}return t.fieldTransforms.length>0&&(i.updateTransforms=t.fieldTransforms.map(e=>(function(e,t){let n=t.transform;if(n instanceof rk)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof rR)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof rO)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof rF)return{fieldPath:t.field.canonicalString(),increment:n.Ae};throw O(20930,{transform:t.transform})})(0,e))),t.precondition.isNone||(i.currentDocument=void 0!==(n=t.precondition).updateTime?{updateTime:ib(e,n.updateTime.toTimestamp())}:void 0!==n.exists?{exists:n.exists}:O(27497)),i}function iP(e,t){var n;let r=t.currentDocument?void 0!==(n=t.currentDocument).updateTime?rB.updateTime(iT(n.updateTime)):void 0!==n.exists?rB.exists(n.exists):rB.none():rB.none(),i=t.updateTransforms?t.updateTransforms.map(t=>{let n;
4return n=null,"setToServerValue"in t?(F("REQUEST_TIME"===t.setToServerValue,16630,{proto:t}),n=new rk):"appendMissingElements"in t?n=new rR(t.appendMissingElements.values||[]):"removeAllFromArray"in t?n=new rO(t.removeAllFromArray.values||[]):"increment"in t?n=new rF(e,t.increment):O(16584,{proto:t}),new rq(es.fromServerFormat(t.fieldPath),n)}):[];if(t.update){t.update.name;let n=iC(e,t.update.name),s=new nO({mapValue:{fields:t.update.fields}});return t.updateMask?new rH(n,s,new t1((t.updateMask.fieldPaths||[]).map(e=>es.fromServerFormat(e))),r,i):new rQ(n,s,r,i)}return t.delete?new rX(iC(e,t.delete),r):t.verify?new rZ(iC(e,t.verify),r):O(1463,{proto:t})}function iF(e,t){return{documents:[iA(e,t.path)]}}function iL(e,t){var n,r;let i,s={structuredQuery:{}},a=t.path;null!==t.collectionGroup?(i=a,s.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=a.popLast(),s.structuredQuery.from=[{collectionId:a.lastSegment()}]),s.parent=iA(e,i);let o=function(e){if(0!==e.length)return function e(t){var n;let r;return t instanceof nB?function(e){if("=="===e.op){if(nx(e.value))return{unaryFilter:{field:iU(e.field),op:"IS_NAN"}};if(nS(e.value))return{unaryFilter:{field:iU(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(nx(e.value))return{unaryFilter:{field:iU(e.field),op:"IS_NOT_NAN"}};if(nS(e.value))return{unaryFilter:{field:iU(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:iU(e.field),op:ip[e.op],value:e.value}}}(t):t instanceof nj?1===(r=(n=t).getFilters().map(t=>e(t))).length?r[0]:{compositeFilter:{op:iy[n.op],filters:r}}:O(54877,{filter:t})}(nj.create(e,"and"))}(t.filters);o&&(s.structuredQuery.where=o);let l=function(e){if(0!==e.length)return e.map(e=>({field:iU(e.field),direction:ig[e.dir]}))}(t.orderBy);l&&(s.structuredQuery.orderBy=l);let u=iv(e,t.limit);return null!==u&&(s.structuredQuery.limit=u),t.startAt&&(s.structuredQuery.startAt={before:(n=t.startAt).inclusive,values:n.position}),t.endAt&&(s.structuredQuery.endAt={before:!(r=t.endAt).inclusive,values:r.position}),{ft:s,parent:i}}function iV(e,t,n,r){let{ft:i,parent:s}=iL(e,t),a={},o=[],l=0;return n.forEach(e=>{let t=r?e.alias:"aggregate_"+l++;a[t]=e.alias,"count"===e.aggregateType?o.push({alias:t,count:{}}):"avg"===e.aggregateType?o.push({alias:t,avg:{field:iU(e.fieldPath)}}):"sum"===e.aggregateType&&o.push({alias:t,sum:{field:iU(e.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:o,structuredQuery:i.structuredQuery},parent:i.parent},gt:a,parent:s}}function iq(e){var t,n,r;let i,s,a,o,l=iD(e.parent),u=e.structuredQuery,h=u.from?u.from.length:0,c=null;if(h>0){F(1===h,65062);let e=u.from[0];e.allDescendants?c=e.collectionId:l=l.child(e.collectionId)}let d=[];u.where&&(d=(i=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=iB(e.unaryFilter.field);return nB.create(t,"==",{doubleValue:NaN});case"IS_NULL":let n=iB(e.unaryFilter.field);return nB.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let r=iB(e.unaryFilter.field);return nB.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let i=iB(e.unaryFilter.field);return nB.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return O(61313);default:return O(60726)}}(t):void 0!==t.fieldFilter?nB.create(iB(t.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return O(58110);default:return O(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?nj.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return O(1026)}}(t.compositeFilter.op)):O(30097,{filter:t})}(u.where))instanceof nj&&nK(i)?i.getFilters():[i]);let f=[];u.orderBy&&(f=u.orderBy.map(e=>new nq(iB(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let m=null;u.limit&&(m=eH(s="object"==typeof(t=u.limit)?t.value:t)?null:s);let g=null;u.startAt&&(a=!!(n=u.startAt).before,g=new nF(n.values||[],a));let p=null;return u.endAt&&(o=!(r=u.endAt).before,p=new nF(r.values||[],o)),new re(l,c,f,d,m,"F",g,p)}function iU(e){return{fieldPath:e.canonicalString()}}function iB(e){return es.fromServerFormat(e.fieldPath)}function ij(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function iz(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}class iG{constructor(e,t,n,r,i=ew.min(),s=ew.min(),a=t3.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new iG(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new iG(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new iG(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new iG(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class iK{constructor(e){this.yt=e}}function i$(e,t){let n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:iQ(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument()){var i;r.document={name:ix(i=e.yt,t.key),fields:t.data.value.mapValue.fields,updateTime:ib(i,t.version.toTimestamp()),createTime:ib(i,t.createTime.toTimestamp())}}else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:iH(t.version)};else{if(!t.isUnknownDocument())return O(57904,{document:t});r.unknownDocument={path:n.path.toArray(),version:iH(t.version)}}return r}function iQ(e){let t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function iH(e){let t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function iW(e){let t=new ey(e.seconds,e.nanoseconds);return ew.fromTimestamp(t)}function iJ(e,t){let n=(t.baseMutations||[]).map(t=>iP(e.yt,t));for(let e=0;e<t.mutations.length-1;++e){let n=t.mutations[e];e+1<t.mutations.length&&void 0!==t.mutations[e+1].transform&&(n.updateTransforms=t.mutations[e+1].transform.fieldTransforms,t.mutations.splice(e+1,1),++e)}let r=t.mutations.map(t=>iP(e.yt,t)),i=ey.fromMillis(t.localWriteTimeMs);return new r0(t.batchId,i,n,r)}function iY(e){var t;let n,r=iW(e.readTime),i=void 0!==e.lastLimboFreeSnapshotVersion?iW(e.lastLimboFreeSnapshotVersion):ew.min();return new iG(void 0!==e.query.documents?(F(1===(n=(t=e.query).documents.length),1966,{count:n}),rs(rt(iD(t.documents[0])))):rs(iq(e.query)),e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,r,i,t3.fromBase64String(e.resumeToken))}function iX(e,t){let n,r=iH(t.snapshotVersion),i=iH(t.lastLimboFreeSnapshotVersion);n=n6(t.target)?iF(e.yt,t.target):iL(e.yt,t.target).ft;let s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:n3(t.target),readTime:r,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:i,query:n}}function iZ(e){let t=iq({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?ru(t,t.limit,"L"):t}function i0(e,t){return new r2(t.largestBatchId,iP(e.yt,t.overlayMutation))}function i1(e,t){let n=t.path.lastSegment();return[e,eY(t.path.popLast()),n]}function i2(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:iH(r.readTime),documentKey:eY(r.documentKey.path),largestBatchId:r.largestBatchId}}class i5{getBundleMetadata(e,t){return tG(e,tv).get(t).next(e=>{if(e)return{id:e.bundleId,createTime:iW(e.createTime),version:e.version}})}saveBundleMetadata(e,t){return tG(e,tv).put({bundleId:t.id,createTime:iH(iT(t.createTime)),version:t.version})}getNamedQuery(e,t){return tG(e,tb).get(t).next(e=>{if(e)return{name:e.name,query:iZ(e.bundledQuery),readTime:iW(e.readTime)}})}saveNamedQuery(e,t){return tG(e,tb).put({name:t.name,readTime:iH(iT(t.readTime)),bundledQuery:t.bundledQuery})}}
4class i3{constructor(e,t){this.serializer=e,this.userId=t}static wt(e,t){return new i3(e,t.uid||"")}getOverlay(e,t){return tG(e,tk).get(i1(this.userId,t)).next(e=>e?i0(this.serializer,e):null)}getOverlays(e,t){let n=rI();return eR.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&n.set(t,e)})).next(()=>n)}saveOverlays(e,t,n){let r=[];return n.forEach((n,i)=>{let s=new r2(t,i);r.push(this.bt(e,s))}),eR.waitFor(r)}removeOverlaysForBatchId(e,t,n){let r=new Set;t.forEach(e=>r.add(eY(e.getCollectionPath())));let i=[];return r.forEach(t=>{let r=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,n+1],!1,!0);i.push(tG(e,tk).X(tM,r))}),eR.waitFor(i)}getOverlaysForCollection(e,t,n){let r=rI(),i=eY(t),s=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,1/0],!0);return tG(e,tk).H(tM,s).next(e=>{for(let t of e){let e=i0(this.serializer,t);r.set(e.getKey(),e)}return r})}getOverlaysForCollectionGroup(e,t,n,r){let i,s=rI(),a=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,1/0],!0);return tG(e,tk).ee({index:tP,range:a},(e,t,n)=>{let a=i0(this.serializer,t);s.size()<r||a.largestBatchId===i?(s.set(a.getKey(),a),i=a.largestBatchId):n.done()}).next(()=>s)}bt(e,t){return tG(e,tk).put(function(e,t,n){let[r,i,s]=i1(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:iO(e.yt,n.mutation)}}(this.serializer,this.userId,t))}}class i4{St(e){return tG(e,tL)}getSessionToken(e){return this.St(e).get("sessionToken").next(e=>{let t=e?.value;return t?t3.fromUint8Array(t):t3.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.St(e).put({name:"sessionToken",value:t.toUint8Array()})}}class i6{Dt(e,t){this.Ct(e,t),t.vt()}Ct(e,t){if("nullValue"in e)this.Ft(t,5);else if("booleanValue"in e)this.Ft(t,10),t.Mt(+!!e.booleanValue);else if("integerValue"in e)this.Ft(t,15),t.Mt(t8(e.integerValue));else if("doubleValue"in e){let n=t8(e.doubleValue);isNaN(n)?this.Ft(t,13):(this.Ft(t,15),eW(n)?t.Mt(0):t.Mt(n))}else if("timestampValue"in e){let n=e.timestampValue;this.Ft(t,20),"string"==typeof n&&(n=t6(n)),t.xt(`${n.seconds||""}`),t.Mt(n.nanos||0)}else if("stringValue"in e)this.Ot(e.stringValue,t),this.Nt(t);else if("bytesValue"in e)this.Ft(t,30),t.Bt(t7(e.bytesValue)),this.Nt(t);else if("referenceValue"in e)this.Lt(e.referenceValue,t);else if("geoPointValue"in e){let n=e.geoPointValue;this.Ft(t,45),t.Mt(n.latitude||0),t.Mt(n.longitude||0)}else"mapValue"in e?nN(e)?this.Ft(t,Number.MAX_SAFE_INTEGER):nA(e)?this.kt(e.mapValue,t):(this.Kt(e.mapValue,t),this.Nt(t)):"arrayValue"in e?(this.qt(e.arrayValue,t),this.Nt(t)):O(19022,{Ut:e})}Ot(e,t){this.Ft(t,25),this.$t(e,t)}$t(e,t){t.xt(e)}Kt(e,t){let n=e.fields||{};for(let e of(this.Ft(t,55),Object.keys(n)))this.Ot(e,t),this.Ct(n[e],t)}kt(e,t){let n=e.fields||{};this.Ft(t,53);let r=n[nf].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(t8(r)),this.Ot(nf,t),this.Ct(n[nf],t)}qt(e,t){let n=e.values||[];for(let e of(this.Ft(t,50),n))this.Ct(e,t)}Lt(e,t){this.Ft(t,37),ea.fromName(e).path.forEach(e=>{this.Ft(t,60),this.$t(e,t)})}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}}function i8(e){return Math.ceil((64-function(e){let t=0;for(let n=0;n<8;++n){let r=function(e){if(0===e)return 8;let t=0;return e>>4||(t+=4,e<<=4),e>>6||(t+=2,e<<=2),e>>7||(t+=1),t}(255&e[n]);if(t+=r,8!==r)break}return t}(e))/8)}i6.Wt=new i6;class i7{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Qt(e){let t=e[Symbol.iterator](),n=t.next();for(;!n.done;)this.Gt(n.value),n=t.next();this.zt()}jt(e){let t=e[Symbol.iterator](),n=t.next();for(;!n.done;)this.Ht(n.value),n=t.next();this.Jt()}Zt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Gt(e);else if(e<2048)this.Gt(960|e>>>6),this.Gt(128|63&e);else if(t<"\uD800"||"\uDBFF"<t)this.Gt(480|e>>>12),this.Gt(128|63&e>>>6),this.Gt(128|63&e);else{let e=t.codePointAt(0);this.Gt(240|e>>>18),this.Gt(128|63&e>>>12),this.Gt(128|63&e>>>6),this.Gt(128|63&e)}}this.zt()}Xt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Ht(e);else if(e<2048)this.Ht(960|e>>>6),this.Ht(128|63&e);else if(t<"\uD800"||"\uDBFF"<t)this.Ht(480|e>>>12),this.Ht(128|63&e>>>6),this.Ht(128|63&e);else{let e=t.codePointAt(0);this.Ht(240|e>>>18),this.Ht(128|63&e>>>12),this.Ht(128|63&e>>>6),this.Ht(128|63&e)}}this.Jt()}Yt(e){let t=this.en(e),n=i8(t);this.tn(1+n),this.buffer[this.position++]=255&n;for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=255&t[e]}nn(e){let t=this.en(e),n=i8(t);this.tn(1+n),this.buffer[this.position++]=~(255&n);for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=~(255&t[e])}rn(){this.sn(255),this.sn(255)}_n(){this.an(255),this.an(255)}reset(){this.position=0}seed(e){this.tn(e.length),this.buffer.set(e,this.position),this.position+=e.length}un(){return this.buffer.slice(0,this.position)}en(e){let t,n=((t=new DataView(new ArrayBuffer(8))).setFloat64(0,e,!1),new Uint8Array(t.buffer)),r=!!(128&n[0]);n[0]^=r?255:128;for(let e=1;e<n.length;++e)n[e]^=255*!!r;return n}Gt(e){let t=255&e;0===t?(this.sn(0),this.sn(255)):255===t?(this.sn(255),this.sn(0)):this.sn(t)}Ht(e){let t=255&e;0===t?(this.an(0),this.an(255)):255===t?(this.an(255),this.an(0)):this.an(e)}zt(){this.sn(0),this.sn(1)}Jt(){this.an(0),this.an(1)}sn(e){this.tn(1),this.buffer[this.position++]=e}an(e){this.tn(1),this.buffer[this.position++]=~e}tn(e){let t=e+this.position;if(t<=this.buffer.length)return;let n=2*this.buffer.length;n<t&&(n=t);let r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}class i9{constructor(e){this.cn=e}Bt(e){this.cn.Qt(e)}xt(e){this.cn.Zt(e)}Mt(e){this.cn.Yt(e)}vt(){this.cn.rn()}}class se{constructor(e){this.cn=e}Bt(e){this.cn.jt(e)}xt(e){this.cn.Xt(e)}Mt(e){this.cn.nn(e)}vt(){this.cn._n()}}class st{constructor(){this.cn=new i7,this.ascending=new i9(this.cn),this.descending=new se(this.cn)}seed(e){this.cn.seed(e)}ln(e){return 0===e?this.ascending:this.descending}un(){return this.cn.un()}reset(){this.cn.reset()}}class sn{constructor(e,t,n,r){this.hn=e,this.Pn=t,this.Tn=n,this.In=r}En(){let e=this.In.length,t=0===e||255===this.In[e-1]?e+1:e,n=new Uint8Array(t);return n.set(this.In,0),t!==e?n.set([0],this.In.length):++n[n.length-1],new sn(this.hn,this.Pn,this.Tn,n)}Rn(e,t,n){return{indexId:this.hn,uid:e,arrayValue:ss(this.Tn),directionalValue:ss(this.In),orderedDocumentKey:ss(t),documentKey:n.path.toArray()}}An(e,t,n){let r=this.Rn(e,t,n);return[r.indexId,r.uid,r.arrayValue,r.directionalValue,r.orderedDocumentKey,r.documentKey]}}function sr(e,t){let n=e.hn-t.hn;
4return 0!==n||0!==(n=si(e.Tn,t.Tn))||0!==(n=si(e.In,t.In))?n:ea.comparator(e.Pn,t.Pn)}function si(e,t){for(let n=0;n<e.length&&n<t.length;++n){let r=e[n]-t[n];if(0!==r)return r}return e.length-t.length}function ss(e){return(0,v.isSafariOrWebkit)()?function(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}(e):e}function sa(e){return"string"!=typeof e?e:function(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e)}class so{constructor(e){for(const t of(this.Vn=new tX((e,t)=>es.comparator(e.field,t.field)),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.dn=e.orderBy,this.mn=[],e.filters))t.isInequality()?this.Vn=this.Vn.add(t):this.mn.push(t)}get fn(){return this.Vn.size>1}gn(e){if(F(e.collectionGroup===this.collectionId,49279),this.fn)return!1;let t=eb(e);if(void 0!==t&&!this.pn(t))return!1;let n=eI(e),r=new Set,i=0,s=0;for(;i<n.length&&this.pn(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;if(this.Vn.size>0){let e=this.Vn.getIterator().getNext();if(!r.has(e.field.canonicalString())){let t=n[i];if(!this.yn(e,t)||!this.wn(this.dn[s++],t))return!1}++i}for(;i<n.length;++i){let e=n[i];if(s>=this.dn.length||!this.wn(this.dn[s++],e))return!1}return!0}bn(){if(this.fn)return null;let e=new tX(es.comparator),t=[];for(let n of this.mn)if(!n.field.isKeyField())if("array-contains"===n.op||"array-contains-any"===n.op)t.push(new e_(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new e_(n.field,0))}for(let n of this.dn)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new e_(n.field,+("asc"!==n.dir))));return new ev(ev.UNKNOWN_ID,this.collectionId,t,eE.empty())}pn(e){for(let t of this.mn)if(this.yn(t,e))return!0;return!1}yn(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;let n="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===n}wn(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function sl(e){return e instanceof nB}function su(e){return e instanceof nj&&nK(e)}function sh(e){return sl(e)||su(e)||function(e){if(e instanceof nj&&nG(e)){for(let t of e.getFilters())if(!sl(t)&&!su(t))return!1;return!0}return!1}(e)}function sc(e,t){return F(e instanceof nB||e instanceof nj,38388),F(t instanceof nB||t instanceof nj,25473),sf(e instanceof nB?t instanceof nB?nj.create([e,t],"and"):sd(e,t):t instanceof nB?sd(t,e):function(e,t){if(F(e.filters.length>0&&t.filters.length>0,48005),nz(e)&&nz(t))return nQ(e,t.getFilters());let n=nG(e)?e:t,r=nG(e)?t:e,i=n.filters.map(e=>sc(e,r));return nj.create(i,"or")}(e,t))}function sd(e,t){if(nz(t))return nQ(t,e.getFilters());{let n=t.filters.map(t=>sc(e,t));return nj.create(n,"or")}}function sf(e){if(F(e instanceof nB||e instanceof nj,11850),e instanceof nB)return e;let t=e.getFilters();if(1===t.length)return sf(t[0]);if(n$(e))return e;let n=t.map(e=>sf(e)),r=[];return n.forEach(t=>{t instanceof nB?r.push(t):t instanceof nj&&(t.op===e.op?r.push(...t.filters):r.push(t))}),1===r.length?r[0]:nj.create(r,e.op)}class sm{constructor(){this.Sn=new sg}addToCollectionParentIndex(e,t){return this.Sn.add(t),eR.resolve()}getCollectionParents(e,t){return eR.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return eR.resolve()}deleteFieldIndex(e,t){return eR.resolve()}deleteAllFieldIndexes(e){return eR.resolve()}createTargetIndexes(e,t){return eR.resolve()}getDocumentsMatchingTarget(e,t){return eR.resolve(null)}getIndexType(e,t){return eR.resolve(0)}getFieldIndexes(e,t){return eR.resolve([])}getNextCollectionGroupToUpdate(e){return eR.resolve(null)}getMinOffset(e,t){return eR.resolve(eC.min())}getMinOffsetFromCollectionGroup(e,t){return eR.resolve(eC.min())}updateCollectionGroup(e,t,n){return eR.resolve()}updateIndexEntries(e,t){return eR.resolve()}}class sg{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new tX(er.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new tX(er.comparator)).toArray()}}let sp="IndexedDbIndexManager",sy=new Uint8Array(0);class sw{constructor(e,t){this.databaseId=t,this.Dn=new sg,this.Cn=new rp(e=>
4n3(e),(e,t)=>n4(e,t)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.Dn.has(t)){let n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Dn.add(t)});let i={collectionId:n,parent:eY(r)};return tG(e,tp).put(i)}return eR.resolve()}getCollectionParents(e,t){let n=[],r=IDBKeyRange.bound([t,""],[t+"\0",""],!1,!0);return tG(e,tp).H(r).next(e=>{for(let r of e){if(r.collectionId!==t)break;n.push(eX(r.parent))}return n})}addFieldIndex(e,t){let n=tG(e,tI),r={indexId:t.indexId,collectionGroup:t.collectionGroup,fields:t.fields.map(e=>[e.fieldPath.canonicalString(),e.kind])};delete r.indexId;let i=n.add(r);if(t.indexState){let n=tG(e,t_);return i.next(e=>{n.put(i2(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){let n=tG(e,tI),r=tG(e,t_),i=tG(e,tC);return n.delete(t.indexId).next(()=>r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))).next(()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))}deleteAllFieldIndexes(e){let t=tG(e,tI),n=tG(e,tC),r=tG(e,t_);return t.X().next(()=>n.X()).next(()=>r.X())}createTargetIndexes(e,t){return eR.forEach(this.vn(t),t=>this.getIndexType(e,t).next(n=>{if(0===n||1===n){let n=new so(t).bn();if(null!=n)return this.addFieldIndex(e,n)}}))}getDocumentsMatchingTarget(e,t){let n=tG(e,tC),r=!0,i=new Map;return eR.forEach(this.vn(t),t=>this.Fn(e,t).next(e=>{r&&(r=!!e),i.set(t,e)})).next(()=>{if(r){let e=rE(),r=[];return eR.forEach(i,(i,s)=>{N(sp,`Using index id=${i.indexId}|cg=${i.collectionGroup}|f=${i.fields.map(e=>`${e.fieldPath}:${e.kind}`).join(",")} to execute ${n3(t)}`);let a=function(e,t){let n=eb(t);if(void 0===n)return null;for(let t of n8(e,n.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(s,i),o=function(e,t){let n=new Map;for(let r of eI(t))for(let t of n8(e,r.fieldPath))switch(t.op){case"==":case"in":n.set(r.fieldPath.canonicalString(),t.value);break;case"not-in":case"!=":return n.set(r.fieldPath.canonicalString(),t.value),Array.from(n.values())}return null}(s,i),l=function(e,t){let n=[],r=!0;for(let i of eI(t)){let t=0===i.kind?n7(e,i.fieldPath,e.startAt):n9(e,i.fieldPath,e.startAt);n.push(t.value),r&&(r=t.inclusive)}return new nF(n,r)}(s,i),u=function(e,t){let n=[],r=!0;for(let i of eI(t)){let t=0===i.kind?n9(e,i.fieldPath,e.endAt):n7(e,i.fieldPath,e.endAt);n.push(t.value),r&&(r=t.inclusive)}return new nF(n,r)}(s,i),h=this.Mn(i,s,l),c=this.Mn(i,s,u),d=this.xn(i,s,o),f=this.On(i.indexId,a,h,l.inclusive,c,u.inclusive,d);return eR.forEach(f,i=>n.Z(i,t.limit).next(t=>{t.forEach(t=>{let n=ea.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))})}))}).next(()=>r)}return eR.resolve(null)})}vn(e){let t=this.Cn.get(e);return t||(t=0===e.filters.length?[e]:(function(e){if(0===e.getFilters().length)return[];let t=function e(t){if(F(t instanceof nB||t instanceof nj,34018),t instanceof nB)return t;if(1===t.filters.length)return e(t.filters[0]);let n=t.filters.map(t=>e(t)),r=nj.create(n,t.op);return sh(r=sf(r))?r:(F(r instanceof nj,64498),F(nz(r),40251),F(r.filters.length>1,57927),r.filters.reduce((e,t)=>sc(e,t)))}(function e(t){if(F(t instanceof nB||t instanceof nj,20012),t instanceof nB){if(t instanceof nZ){let e=t.value.arrayValue?.values?.map(e=>nB.create(t.field,"==",e))||[];return nj.create(e,"or")}return t}let n=t.filters.map(t=>e(t));return nj.create(n,t.op)}(e));return F(sh(t),7391),sl(t)||su(t)?[t]:t.getFilters()})(nj.create(e.filters,"and")).map(t=>n5(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)),this.Cn.set(e,t)),t}On(e,t,n,r,i,s,a){let o=(null!=t?t.length:1)*Math.max(n.length,i.length),l=o/(null!=t?t.length:1),u=[];for(let h=0;h<o;++h){let o=t?this.Nn(t[h/l]):sy,c=this.Bn(e,o,n[h%l],r),d=this.Ln(e,o,i[h%l],s),f=a.map(t=>this.Bn(e,o,t,!0));u.push(...this.createRange(c,d,f))}return u}Bn(e,t,n,r){let i=new sn(e,ea.empty(),t,n);return r?i:i.En()}Ln(e,t,n,r){let i=new sn(e,ea.empty(),t,n);return r?i.En():i}Fn(e,t){let n=new so(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next(e=>{let t=null;for(let r of e)n.gn(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t})}getIndexType(e,t){let n=2,r=this.vn(t);return eR.forEach(r,t=>this.Fn(e,t).next(e=>{e?0!==n&&e.fields.length<function(e){let t=new tX(es.comparator),n=!1;for(let r of e.filters)for(let e of r.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?n=!0:t=t.add(e.field));for(let n of e.orderBy)n.field.isKeyField()||(t=t.add(n.field));return t.size+ +!!n}(t)&&(n=1):n=0})).next(()=>null!==t.limit&&r.length>1&&2===n?1:n)}kn(e,t){let n=new st;for(let r of eI(e)){let e=t.data.field(r.fieldPath);if(null==e)return null;let i=n.ln(r.kind);i6.Wt.Dt(e,i)}return n.un()}Nn(e){let t=new st;return i6.Wt.Dt(e,t.ln(0)),t.un()}Kn(e,t){let n,r=new st;return i6.Wt.Dt(nT(this.databaseId,t),r.ln(0===(n=eI(e)).length?0:n[n.length-1].kind)),r.un()}xn(e,t,n){if(null===n)return[];let r=[];r.push(new st);let i=0;for(let s of eI(e)){let e=n[i++];for(let n of r)if(this.qn(t,s.fieldPath)&&nE(e))r=this.Un(r,s,e);else{let t=n.ln(s.kind);i6.Wt.Dt(e,t)}}return this.$n(r)}Mn(e,t,n){return this.xn(e,t,n.position)}$n(e){let t=[];for(let n=0;n<e.length;++n)t[n]=e[n].un();return t}Un(e,t,n){let r=[...e],i=[];for(let e of n.arrayValue.values||[])for(let n of r){let r=new st;r.seed(n.un()),i6.Wt.Dt(e,r.ln(t.kind)),i.push(r)}return i}qn(e,t){return!!e.filters.find(e=>e instanceof nB&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op))}getFieldIndexes(e,t){let n=tG(e,tI),r=tG(e,t_);return(t?n.H(tT,IDBKeyRange.bound(t,t)):n.H()).next(e=>{let t=[];return eR.forEach(e,e=>r.get([e.indexId,this.uid]).next(n=>{let r,i;t.push((r=n?new eE(n.sequenceNumber,new eC(iW(n.readTime),new ea(eX(n.documentKey)),n.largestBatchId)):eE.empty(),i=e.fields.map(([e,t])=>new e_(es.fromServerFormat(e),t)),new ev(e.indexId,e.collectionGroup,i,r)))})).next(()=>t)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(e=>0===e.length?null:(e.sort((e,t)=>
4{let n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:Y(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(e,t,n){let r=tG(e,tI),i=tG(e,t_);return this.Wn(e).next(e=>r.H(tT,IDBKeyRange.bound(t,t)).next(t=>eR.forEach(t,t=>i.put(i2(t.indexId,this.uid,e,n)))))}updateIndexEntries(e,t){let n=new Map;return eR.forEach(t,(t,r)=>{let i=n.get(t.collectionGroup);return(i?eR.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next(i=>(n.set(t.collectionGroup,i),eR.forEach(i,n=>this.Qn(e,t,n).next(t=>{let i=this.Gn(r,n);return t.isEqual(i)?eR.resolve():this.zn(e,r,n,t,i)}))))})}jn(e,t,n,r){return tG(e,tC).put(r.Rn(this.uid,this.Kn(n,t.key),t.key))}Hn(e,t,n,r){return tG(e,tC).delete(r.An(this.uid,this.Kn(n,t.key),t.key))}Qn(e,t,n){let r=tG(e,tC),i=new tX(sr);return r.ee({index:tD,range:IDBKeyRange.only([n.indexId,this.uid,ss(this.Kn(n,t))])},(e,r)=>{i=i.add(new sn(n.indexId,t,sa(r.arrayValue),sa(r.directionalValue)))}).next(()=>i)}Gn(e,t){let n=new tX(sr),r=this.kn(t,e);if(null==r)return n;let i=eb(t);if(null!=i){let s=e.data.field(i.fieldPath);if(nE(s))for(let i of s.arrayValue.values||[])n=n.add(new sn(t.indexId,e.key,this.Nn(i),r))}else n=n.add(new sn(t.indexId,e.key,sy,r));return n}zn(e,t,n,r,i){N(sp,"Updating index entries for document '%s'",t.key);let s=[];return function(e,t,n,r,i){let s=e.getIterator(),a=t.getIterator(),o=t0(s),l=t0(a);for(;o||l;){let e=!1,t=!1;if(o&&l){let r=n(o,l);r<0?t=!0:r>0&&(e=!0)}else null!=o?t=!0:e=!0;e?(r(l),l=t0(a)):t?(i(o),o=t0(s)):(o=t0(s),l=t0(a))}}(r,i,sr,r=>{s.push(this.jn(e,t,n,r))},r=>{s.push(this.Hn(e,t,n,r))}),eR.waitFor(s)}Wn(e){let t=1;return tG(e,t_).ee({index:tS,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(e,n,r)=>{r.done(),t=n.sequenceNumber+1}).next(()=>t)}createRange(e,t,n){n=n.sort((e,t)=>sr(e,t)).filter((e,t,n)=>!t||0!==sr(e,n[t-1]));let r=[];for(let i of(r.push(e),n)){let n=sr(i,e),s=sr(i,t);if(0===n)r[0]=e.En();else if(n>0&&s<0)r.push(i),r.push(i.En());else if(s>0)break}r.push(t);let i=[];for(let e=0;e<r.length;e+=2){if(this.Jn(r[e],r[e+1]))return[];let t=r[e].An(this.uid,sy,ea.empty()),n=r[e+1].An(this.uid,sy,ea.empty());i.push(IDBKeyRange.bound(t,n))}return i}Jn(e,t){return sr(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(sv)}getMinOffset(e,t){return eR.mapArray(this.vn(t),t=>this.Fn(e,t).next(e=>e||O(44426))).next(sv)}}function sv(e){F(0!==e.length,28825);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r<e.length;r++){let i=e[r].indexState.offset;0>eA(i,t)&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new eC(t.readTime,t.documentKey,n)}let sb={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class sI{static withCacheSize(e){return new sI(e,sI.DEFAULT_COLLECTION_PERCENTILE,sI.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}}function sT(e,t,n){let r=e.store(e5),i=e.store(e7),s=[],a=IDBKeyRange.only(n.batchId),o=0,l=r.ee({range:a},(e,t,n)=>(o++,n.delete()));s.push(l.next(()=>{F(1===o,47070,{batchId:n.batchId})}));let u=[];for(let e of n.mutations){var h,c;let r=(h=e.key.path,c=n.batchId,[t,eY(h),c]);s.push(i.delete(r)),u.push(e.key)}return eR.waitFor(s).next(()=>u)}function s_(e){let t;if(!e)return 0;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw O(14731);t=e.noDocument}return JSON.stringify(t).length}sI.DEFAULT_COLLECTION_PERCENTILE=10,sI.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,sI.DEFAULT=new sI(0x2800000,sI.DEFAULT_COLLECTION_PERCENTILE,sI.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),sI.DISABLED=new sI(-1,0,0);class sE{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.Zn={}}static wt(e,t,n,r){return F(""!==e.uid,64387),new sE(e.isAuthenticated()?e.uid:"",t,n,r)}checkEmpty(e){let t=!0,n=IDBKeyRange.bound([this.userId,-1/0],[this.userId,1/0]);return sx(e).ee({index:e4,range:n},(e,n,r)=>{t=!1,r.done()}).next(()=>t)}addMutationBatch(e,t,n,r){let i=tG(e,e7),s=sx(e);return s.add({}).next(a=>{var o,l,u,h;let c,d;F("number"==typeof a,49019);let f=new r0(a,t,n,r),m=(o=this.serializer,l=this.userId,c=f.baseMutations.map(e=>iO(o.yt,e)),d=f.mutations.map(e=>iO(o.yt,e)),{userId:l,batchId:f.batchId,localWriteTimeMs:f.localWriteTime.toMillis(),baseMutations:c,mutations:d}),g=[],p=new tX((e,t)=>Y(e.canonicalString(),t.canonicalString()));
4for(let e of r){let t=(u=this.userId,h=e.key.path,[u,eY(h),a]);p=p.add(e.key.path.popLast()),g.push(s.put(m)),g.push(i.put(t,e8))}return p.forEach(t=>{g.push(this.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(()=>{this.Zn[a]=f.keys()}),eR.waitFor(g).next(()=>f)})}lookupMutationBatch(e,t){return sx(e).get(t).next(e=>e?(F(e.userId===this.userId,48,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),iJ(this.serializer,e)):null)}Xn(e,t){return this.Zn[t]?eR.resolve(this.Zn[t]):this.lookupMutationBatch(e,t).next(e=>{if(e){let n=e.keys();return this.Zn[t]=n,n}return null})}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]),i=null;return sx(e).ee({index:e4,range:r},(e,t,r)=>{t.userId===this.userId&&(F(t.batchId>=n,47524,{Yn:n}),i=iJ(this.serializer,t)),r.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){let t=IDBKeyRange.upperBound([this.userId,1/0]),n=-1;return sx(e).ee({index:e4,range:t,reverse:!0},(e,t,r)=>{n=t.batchId,r.done()}).next(()=>n)}getAllMutationBatches(e){let t=IDBKeyRange.bound([this.userId,-1],[this.userId,1/0]);return sx(e).H(e4,t).next(e=>e.map(e=>iJ(this.serializer,e)))}getAllMutationBatchesAffectingDocumentKey(e,t){let n=[this.userId,eY(t.path)],r=IDBKeyRange.lowerBound(n),i=[];return tG(e,e7).ee({range:r},(n,r,s)=>{let[a,o,l]=n,u=eX(o);if(a===this.userId&&t.path.isEqual(u))return sx(e).get(l).next(e=>{if(!e)throw O(61480,{er:n,batchId:l});F(e.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:e.userId,batchId:l}),i.push(iJ(this.serializer,e))});s.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tX(Y),r=[];return t.forEach(t=>{let i=[this.userId,eY(t.path)],s=IDBKeyRange.lowerBound(i),a=tG(e,e7).ee({range:s},(e,r,i)=>{let[s,a,o]=e,l=eX(a);s===this.userId&&t.path.isEqual(l)?n=n.add(o):i.done()});r.push(a)}),eR.waitFor(r).next(()=>this.tr(e,n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=[this.userId,eY(n)],s=IDBKeyRange.lowerBound(i),a=new tX(Y);return tG(e,e7).ee({range:s},(e,t,i)=>{let[s,o,l]=e,u=eX(o);s===this.userId&&n.isPrefixOf(u)?u.length===r&&(a=a.add(l)):i.done()}).next(()=>this.tr(e,a))}tr(e,t){let n=[],r=[];return t.forEach(t=>{r.push(sx(e).get(t).next(e=>{if(null===e)throw O(35274,{batchId:t});F(e.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),n.push(iJ(this.serializer,e))}))}),eR.waitFor(r).next(()=>n)}removeMutationBatch(e,t){return sT(e.le,this.userId,t).next(n=>(e.addOnCommittedListener(()=>{this.nr(t.batchId)}),eR.forEach(n,t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))}nr(e){delete this.Zn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>{if(!t)return eR.resolve();let n=IDBKeyRange.lowerBound([this.userId]),r=[];return tG(e,e7).ee({range:n},(e,t,n)=>{if(e[0]===this.userId){let t=eX(e[1]);r.push(t)}else n.done()}).next(()=>{F(0===r.length,56720,{rr:r.map(e=>e.canonicalString())})})})}containsKey(e,t){return sS(e,this.userId,t)}ir(e){return tG(e,e2).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function sS(e,t,n){let r=[t,eY(n.path)],i=r[1],s=IDBKeyRange.lowerBound(r),a=!1;return tG(e,e7).ee({range:s,Y:!0},(e,n,r)=>{let[s,o,l]=e;s===t&&o===i&&(a=!0),r.done()}).next(()=>a)}function sx(e){return tG(e,e5)}class sC{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new sC(0)}static ar(){return new sC(-1)}}class sA{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.ur(e).next(t=>{let n=new sC(t.highestTargetId);return t.highestTargetId=n.next(),this.cr(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.ur(e).next(e=>ew.fromTimestamp(new ey(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.ur(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(e,t,n){return this.ur(e).next(r=>(r.highestListenSequenceNumber=t,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.cr(e,r)))}addTargetData(e,t){return this.lr(e,t).next(()=>this.ur(e).next(n=>(n.targetCount+=1,this.hr(t,n),this.cr(e,n))))}updateTargetData(e,t){return this.lr(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>tG(e,to).delete(t.targetId)).next(()=>this.ur(e)).next(t=>(F(t.targetCount>0,8065),t.targetCount-=1,this.cr(e,t)))}removeTargets(e,t,n){let r=0,i=[];return tG(e,to).ee((s,a)=>{let o=iY(a);o.sequenceNumber<=t&&null===n.get(o.targetId)&&(r++,i.push(this.removeTargetData(e,o)))}).next(()=>eR.waitFor(i)).next(()=>r)}forEachTarget(e,t){return tG(e,to).ee((e,n)=>{t(iY(n))})}ur(e){return tG(e,tg).get(tm).next(e=>(F(null!==e,2888),e))}cr(e,t){return tG(e,tg).put(tm,t)}lr(e,t){return tG(e,to).put(iX(this.serializer,t))}hr(e,t){let n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}getTargetCount(e){return this.ur(e).next(e=>e.targetCount)}getTargetData(e,t){let n=n3(t),r=IDBKeyRange.bound([n,-1/0],[n,1/0]),i=null;return tG(e,to).ee({range:r,index:tl},(e,n,r)=>{let s=iY(n);n4(t,s.target)&&(i=s,r.done())}).next(()=>i)}addMatchingKeys(e,t,n){let r=[],i=sD(e);return t.forEach(t=>{let s=eY(t.path);r.push(i.put({targetId:n,path:s})),r.push(this.referenceDelegate.addReference(e,n,t))}),eR.waitFor(r)}removeMatchingKeys(e,t,n){let r=sD(e);return eR.forEach(t,t=>{let i=eY(t.path);return eR.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])})}removeMatchingKeysForTargetId(e,t){let n=sD(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){let n=IDBKeyRange.bound([t],[t+1],!1,!0),r=sD(e),i=rE();return r.ee({range:n,Y:!0},(e,t,n)=>{let r=new ea(eX(e[1]));i=i.add(r)}).next(()=>i)}containsKey(e,t){let n=eY(t.path),r=IDBKeyRange.bound([n],[n+"\0"],!1,!0),i=0;return sD(e).ee({index:td,Y:!0,range:r},([e,t],n,r)=>{0!==e&&(i++,r.done())}).next(()=>i>0)}At(e,t){return tG(e,to).get(t).next(e=>e?iY(e):null)}}function sD(e){return tG(e,th)}let sN="LruGarbageCollector";function sk([e,t],[n,r]){let i=Y(e,n);return 0===i?Y(t,r):i}class sR{constructor(e){this.Pr=e,this.buffer=new tX(sk),this.Tr=0}Ir(){return++this.Tr}Er(e){let t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>sk(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class sM{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Rr=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return null!==this.Rr}Ar(e){N(sN,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){eq(e)?N(sN,"Ignoring IndexedDB error during garbage collection: ",e):await ek(e)}await this.Ar(3e5)})}}class sO{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return eR.resolve(eQ.ce);let n=new sR(t);return this.Vr.forEachTarget(e,e=>n.Er(e.sequenceNumber)).next(()=>this.Vr.mr(e,e=>n.Er(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.Vr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(N("LruGarbageCollector","Garbage collection skipped; disabled"),eR.resolve(sb)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(N("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),sb):this.gr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let n,r,i,s,a,o,l,u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(N("LruGarbageCollector",`C
4apping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,s=Date.now(),this.nthSequenceNumber(e,r))).next(r=>(n=r,a=Date.now(),this.removeTargets(e,n,t))).next(t=>(i=t,o=Date.now(),this.removeOrphanedDocuments(e,n))).next(e=>(l=Date.now(),A()<=T.LogLevel.DEBUG&&N("LruGarbageCollector",`LRU Garbage Collection
5	Counted targets in ${s-u}ms
6	Determined least recently used ${r} in `+(a-s)+"ms\n"+`	Removed ${i} targets in `+(o-a)+"ms\n"+`	Removed ${e} documents in `+(l-o)+"ms\n"+`Total Duration: ${l-u}ms`),eR.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e})))}}class sP{constructor(e,t){this.db=e,this.garbageCollector=function(e,t){return new sO(e,t)}(this,t)}dr(e){let t=this.pr(e);return this.db.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}pr(e){let t=0;return this.mr(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}mr(e,t){return this.yr(e,(e,n)=>t(n))}addReference(e,t,n){return sF(e,n)}removeReference(e,t,n){return sF(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return sF(e,t)}wr(e,t){let n;return n=!1,tG(e,e2).te(r=>sS(e,r,t).next(e=>(e&&(n=!0),eR.resolve(!e)))).next(()=>n)}removeOrphanedDocuments(e,t){let n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[],i=0;return this.yr(e,(s,a)=>{if(a<=t){let t=this.wr(e,s).next(t=>{if(!t)return i++,n.getEntry(e,s).next(()=>(n.removeEntry(s,ew.min()),sD(e).delete([0,eY(s.path)])))});r.push(t)}}).next(()=>eR.waitFor(r)).next(()=>n.apply(e)).next(()=>i)}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return sF(e,t)}yr(e,t){let n=sD(e),r,i=eQ.ce;return n.ee({index:td},([e,n],{path:s,sequenceNumber:a})=>{0===e?(i!==eQ.ce&&t(new ea(eX(r)),i),i=a,r=s):i=eQ.ce}).next(()=>{i!==eQ.ce&&t(new ea(eX(r)),i)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function sF(e,t){var n;return sD(e).put((n=e.currentSequenceNumber,{targetId:0,path:eY(t.path),sequenceNumber:n}))}class sL{constructor(){this.changes=new rp(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,nP.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return void 0!==n?eR.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class sV{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return tG(e,e9).put(n)}removeEntry(e,t,n){let r;return tG(e,e9).delete([(r=t.path.toArray()).slice(0,r.length-2),r[r.length-2],iQ(n),r[r.length-1]])}updateMetadata(e,t){return this.getMetadata(e).next(n=>(n.byteSize+=t,this.br(e,n)))}getEntry(e,t){let n=nP.newInvalidDocument(t);return tG(e,e9).ee({index:tt,range:IDBKeyRange.only(sU(t))},(e,r)=>{n=this.Sr(t,r)}).next(()=>n)}Dr(e,t){let n={size:0,document:nP.newInvalidDocument(t)};return tG(e,e9).ee({index:tt,range:IDBKeyRange.only(sU(t))},(e,r)=>{n={document:this.Sr(t,r),size:s_(r)}}).next(()=>n)}getEntries(e,t){let n=ry;return this.Cr(e,t,(e,t)=>{let r=this.Sr(e,t);n=n.insert(e,r)}).next(()=>n)}vr(e,t){let n=ry,r=new tW(ea.comparator);return this.Cr(e,t,(e,t)=>{let i=this.Sr(e,t);n=n.insert(e,i),r=r.insert(e,s_(t))}).next(()=>({documents:n,Fr:r}))}Cr(e,t,n){if(t.isEmpty())return eR.resolve();let r=new tX(sj);t.forEach(e=>r=r.add(e));let i=IDBKeyRange.bound(sU(r.first()),sU(r.last())),s=r.getIterator(),a=s.getNext();return tG(e,e9).ee({index:tt,range:i},(e,t,r)=>{let i=ea.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;a&&0>sj(a,i);)n(a,null),a=s.getNext();a&&a.isEqual(i)&&(n(a,t),a=s.hasNext()?s.getNext():null),a?r.j(sU(a)):r.done()}).next(()=>{for(;a;)n(a,null),a=s.hasNext()?s.getNext():null})}getDocumentsMatchingQuery(e,t,n,r,i){let s=t.path,a=[s.popLast().toArray(),s.lastSegment(),iQ(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],o=[s.popLast().toArray(),s.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return tG(e,e9).H(IDBKeyRange.bound(a,o,!0)).next(e=>{i?.incrementDocumentReadCount(e.length);let n=ry;for(let i of e){let e=this.Sr(ea.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);
6e.isFoundDocument()&&(rf(t,e)||r.has(e.key))&&(n=n.insert(e.key,e))}return n})}getAllFromCollectionGroup(e,t,n,r){let i=ry,s=sB(t,n),a=sB(t,eC.max());return tG(e,e9).ee({index:tr,range:IDBKeyRange.bound(s,a,!0)},(e,t,n)=>{let s=this.Sr(ea.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);(i=i.insert(s.key,s)).size===r&&n.done()}).next(()=>i)}newChangeBuffer(e){return new sq(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return tG(e,ts).get(ta).next(e=>(F(!!e,20021),e))}br(e,t){return tG(e,ts).put(ta,t)}Sr(e,t){if(t){let e=function(e,t){var n;let r,i;if(t.document)r=iM(e.yt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){let e=ea.fromSegments(t.noDocument.path),n=iW(t.noDocument.readTime);r=nP.newNoDocument(e,n),t.hasCommittedMutations&&r.setHasCommittedMutations()}else{if(!t.unknownDocument)return O(56709);{let e=ea.fromSegments(t.unknownDocument.path),n=iW(t.unknownDocument.version);r=nP.newUnknownDocument(e,n)}}return t.readTime&&r.setReadTime((i=new ey((n=t.readTime)[0],n[1]),ew.fromTimestamp(i))),r}(this.serializer,t);if(!(e.isNoDocument()&&e.version.isEqual(ew.min())))return e}return nP.newInvalidDocument(e)}}class sq extends sL{constructor(e,t){super(),this.Mr=e,this.trackRemovals=t,this.Or=new rp(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(e){let t=[],n=0,r=new tX((e,t)=>Y(e.canonicalString(),t.canonicalString()));
6return this.changes.forEach((i,s)=>{let a=this.Or.get(i);if(t.push(this.Mr.removeEntry(e,i,a.readTime)),s.isValidDocument()){let o=i$(this.Mr.serializer,s);r=r.add(i.path.popLast());let l=s_(o);n+=l-a.size,t.push(this.Mr.addEntry(e,i,o))}else if(n-=a.size,this.trackRemovals){let n=i$(this.Mr.serializer,s.convertToNoDocument(ew.min()));t.push(this.Mr.addEntry(e,i,n))}}),r.forEach(n=>{t.push(this.Mr.indexManager.addToCollectionParentIndex(e,n))}),t.push(this.Mr.updateMetadata(e,n)),eR.waitFor(t)}getFromCache(e,t){return this.Mr.Dr(e,t).next(e=>(this.Or.set(t,{size:e.size,readTime:e.document.readTime}),e.document))}getAllFromCache(e,t){return this.Mr.vr(e,t).next(({documents:e,Fr:t})=>(t.forEach((t,n)=>{this.Or.set(t,{size:n,readTime:e.get(t).readTime})}),e))}}function sU(e){let t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function sB(e,t){let n=t.documentKey.path.toArray();return[e,iQ(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function sj(e,t){let n=e.path.toArray(),r=t.path.toArray(),i=0;for(let e=0;e<n.length-2&&e<r.length-2;++e)if(i=Y(n[e],r[e]))return i;return(i=Y(n.length,r.length))||(i=Y(n[n.length-2],r[r.length-2]))||Y(n[n.length-1],r[r.length-1])}class sz{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class sG{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next(r=>(n=r,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==n&&rK(n.mutation,e,t1.empty(),ey.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,rE()).next(()=>t))}getLocalViewOfDocuments(e,t,n=rE()){let r=rI();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,n).next(e=>{let t=rv();return e.forEach((e,n)=>{t=t.insert(e,n.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let n=rI();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,rE()))}populateOverlays(e,t,n){let r=[];return n.forEach(e=>{t.has(e)||r.push(e)}),this.documentOverlayCache.getOverlays(e,r).next(e=>{e.forEach((e,n)=>{t.set(e,n)})})}computeViews(e,t,n,r){let i=ry,s=rI(),a=rI();return t.forEach((e,t)=>{let a=n.get(t.key);r.has(t.key)&&(void 0===a||a.mutation instanceof rH)?i=i.insert(t.key,t):void 0!==a?(s.set(t.key,a.mutation.getFieldMask()),rK(a.mutation,t,a.mutation.getFieldMask(),ey.now())):s.set(t.key,t1.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>a.set(e,new sz(t,s.get(e)??null))),a))}recalculateAndSaveOverlays(e,t){let n=rI(),r=new tW((e,t)=>e-t),i=rE();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let i of e)i.keys().forEach(e=>{let s=t.get(e);if(null===s)return;let a=n.get(e)||t1.empty();a=i.applyToLocalView(s,a),n.set(e,a);let o=(r.get(i.batchId)||rE()).add(e);r=r.insert(i.batchId,o)})}).next(()=>{let s=[],a=r.getReverseIterator();for(;a.hasNext();){let r=a.getNext(),o=r.key,l=r.value,u=rI();l.forEach(e=>{if(!i.has(e)){let r=rG(t.get(e),n.get(e));null!==r&&u.set(e,r),i=i.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,o,u))}return eR.waitFor(s)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,n,r){return ea.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):rr(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next(i=>{let s=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):eR.resolve(rI()),a=-1,o=i;return s.next(t=>eR.forEach(t,(t,n)=>(a<n.largestBatchId&&(a=n.largestBatchId),i.get(t)?eR.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{o=o.insert(t,e)}))).next(()=>this.populateOverlays(e,t,i)).next(()=>this.computeViews(e,o,t,rE())).next(e=>({batchId:a,changes:rb(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new ea(t)).next(e=>{let t=rv();
vendor: 4,143 bytes, line 6
6return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,s=rv();return this.indexManager.getCollectionParents(e,i).next(a=>eR.forEach(a,a=>{let o=new re(a.child(i),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(e,o,n,r).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r))).next(e=>{i.forEach((t,n)=>{let r=n.getKey();null===e.get(r)&&(e=e.insert(r,nP.newInvalidDocument(r)))});let n=rv();return e.forEach((e,r)=>{let s=i.get(e);void 0!==s&&rK(s.mutation,r,t1.empty(),ey.now()),rf(t,r)&&(n=n.insert(e,r))}),n})}}class sK{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return eR.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,{id:t.id,version:t.version,createTime:iT(t.createTime)}),eR.resolve()}getNamedQuery(e,t){return eR.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,{name:t.name,query:iZ(t.bundledQuery),readTime:iT(t.readTime)}),eR.resolve()}}class s${constructor(){this.overlays=new tW(ea.comparator),this.Lr=new Map}getOverlay(e,t){return eR.resolve(this.overlays.get(t))}getOverlays(e,t){let n=rI();return eR.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&n.set(t,e)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((n,r)=>{this.bt(e,t,r)}),eR.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.Lr.get(n);return void 0!==r&&(r.forEach(e=>this.overlays=this.overlays.remove(e)),this.Lr.delete(n)),eR.resolve()}getOverlaysForCollection(e,t,n){let r=rI(),i=t.length+1,s=new ea(t.child("")),a=this.overlays.getIteratorFrom(s);for(;a.hasNext();){let e=a.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return eR.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new tW((e,t)=>e-t),s=this.overlays.getIterator();for(;s.hasNext();){let e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);null===t&&(t=rI(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=rI(),o=i.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=r)););return eR.resolve(a)}bt(e,t,n){let r=this.overlays.get(n.key);if(null!==r){let e=this.Lr.get(r.largestBatchId).delete(n.key);this.Lr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new r2(t,n));let i=this.Lr.get(t);void 0===i&&(i=rE(),this.Lr.set(t,i)),this.Lr.set(t,i.add(n.key))}}class sQ{constructor(){this.sessionToken=t3.EMPTY_BYTE_STRING}getSessionToken(e){return eR.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,eR.resolve()}}class sH{constructor(){this.kr=new tX(sW.Kr),this.qr=new tX(sW.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){let n=new sW(e,t);this.kr=this.kr.add(n),this.qr=this.qr.add(n)}$r(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Wr(new sW(e,t))}Qr(e,t){e.forEach(e=>this.removeReference(e,t))}Gr(e){let t=new ea(new er([])),n=new sW(t,e),r=new sW(t,e+1),i=[];return this.qr.forEachInRange([n,r],e=>{this.Wr(e),i.push(e.key)}),i}zr(){this.kr.forEach(e=>this.Wr(e))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){let t=new ea(new er([])),n=new sW(t,e),r=new sW(t,e+1),i=rE();return this.qr.forEachInRange([n,r],e=>{i=i.add(e.key)}),i}containsKey(e){let t=new sW(e,0),n=this.kr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class sW{constructor(e,t){this.key=e,this.Hr=t}static Kr(e,t){return ea.comparator(e.key,t.key)||Y(e.Hr,t.Hr)}static Ur(e,t){return Y(e.Hr,t.Hr)||ea.comparator(e.key,t.key)}}class sJ{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Jr=new tX(sW.Kr)}checkEmpty(e){return eR.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){let i=this.Yn;
6this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new r0(i,t,n,r);for(let t of(this.mutationQueue.push(s),r))this.Jr=this.Jr.add(new sW(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return eR.resolve(s)}lookupMutationBatch(e,t){return eR.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){let n=this.Xr(t+1),r=n<0?0:n;return eR.resolve(this.mutationQueue.length>r?this.mutationQueue[r]:null)}getHighestUnacknowledgedBatchId(){return eR.resolve(0===this.mutationQueue.length?-1:this.Yn-1)}getAllMutationBatches(e){return eR.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new sW(t,0),r=new sW(t,1/0),i=[];return this.Jr.forEachInRange([n,r],e=>{let t=this.Zr(e.Hr);i.push(t)}),eR.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tX(Y);return t.forEach(e=>{let t=new sW(e,0),r=new sW(e,1/0);this.Jr.forEachInRange([t,r],e=>{n=n.add(e.Hr)})}),eR.resolve(this.Yr(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;ea.isDocumentKey(i)||(i=i.child(""));let s=new sW(new ea(i),0),a=new tX(Y);return this.Jr.forEachWhile(e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(a=a.add(e.Hr)),!0)},s),eR.resolve(this.Yr(a))}Yr(e){let t=[];return e.forEach(e=>{let n=this.Zr(e);null!==n&&t.push(n)}),t}removeMutationBatch(e,t){F(0===this.ei(t.batchId,"removed"),55003),this.mutationQueue.shift();let n=this.Jr;return eR.forEach(t.mutations,r=>{let i=new sW(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)}).next(()=>{this.Jr=n})}nr(e){}containsKey(e,t){let n=new sW(t,0),r=this.Jr.firstAfterOrEqual(n);return eR.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,eR.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Zr(e){let t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class sY{constructor(e){this.ti=e,this.docs=new tW(ea.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,r=this.docs.get(n),i=r?r.size:0,s=this.ti(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let n=this.docs.get(t);return eR.resolve(n?n.document.mutableCopy():nP.newInvalidDocument(t))}getEntries(e,t){let n=ry;return t.forEach(e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():nP.newInvalidDocument(e))}),eR.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=ry,s=t.path,a=new ea(s.child("__id-9223372036854775808__")),o=this.docs.getIteratorFrom(a);for(;o.hasNext();){let{key:e,value:{document:a}}=o.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||0>=eA(ex(a),n)||(r.has(a.key)||rf(t,a))&&(i=i.insert(a.key,a.mutableCopy()))}return eR.resolve(i)}getAllFromCollectionGroup(e,t,n,r){O(9500)}ni(e,t){return eR.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new sX(this)}getSize(e){return eR.resolve(this.size)}}class sX extends sL{constructor(e){super(),this.Mr=e}applyChanges(e){let t=[];
vendor: 4,785 bytes, line 6
6return this.changes.forEach((n,r)=>{r.isValidDocument()?t.push(this.Mr.addEntry(e,r)):this.Mr.removeEntry(n)}),eR.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class sZ{constructor(e){this.persistence=e,this.ri=new rp(e=>n3(e),n4),this.lastRemoteSnapshotVersion=ew.min(),this.highestTargetId=0,this.ii=0,this.si=new sH,this.targetCount=0,this.oi=sC._r()}forEachTarget(e,t){return this.ri.forEach((e,n)=>t(n)),eR.resolve()}getLastRemoteSnapshotVersion(e){return eR.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return eR.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),eR.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.ii&&(this.ii=t),eR.resolve()}lr(e){this.ri.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.oi=new sC(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,eR.resolve()}updateTargetData(e,t){return this.lr(t),eR.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,eR.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.ri.forEach((s,a)=>{a.sequenceNumber<=t&&null===n.get(a.targetId)&&(this.ri.delete(s),i.push(this.removeMatchingKeysForTargetId(e,a.targetId)),r++)}),eR.waitFor(i).next(()=>r)}getTargetCount(e){return eR.resolve(this.targetCount)}getTargetData(e,t){let n=this.ri.get(t)||null;return eR.resolve(n)}addMatchingKeys(e,t,n){return this.si.$r(t,n),eR.resolve()}removeMatchingKeys(e,t,n){this.si.Qr(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(t=>{i.push(r.markPotentiallyOrphaned(e,t))}),eR.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),eR.resolve()}getMatchingKeysForTargetId(e,t){let n=this.si.jr(t);return eR.resolve(n)}containsKey(e,t){return eR.resolve(this.si.containsKey(t))}}class s0{constructor(e,t){this._i={},this.overlays={},this.ai=new eQ(0),this.ui=!1,this.ui=!0,this.ci=new sQ,this.referenceDelegate=e(this),this.li=new sZ(this),this.indexManager=new sm,this.remoteDocumentCache=function(e){return new sY(e)}(e=>this.referenceDelegate.hi(e)),this.serializer=new iK(t),this.Pi=new sK(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new s$,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this._i[e.toKey()];return n||(n=new sJ(t,this.referenceDelegate),this._i[e.toKey()]=n),n}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,n){N("MemoryPersistence","Starting transaction:",e);let r=new s1(this.ai.next());return this.referenceDelegate.Ti(),n(r).next(e=>this.referenceDelegate.Ii(r).next(()=>e)).toPromise().then(e=>(r.raiseOnCommittedEvent(),e))}Ei(e,t){return eR.or(Object.values(this._i).map(n=>()=>n.containsKey(e,t)))}}class s1 extends eN{constructor(e){super(),this.currentSequenceNumber=e}}class s2{constructor(e){this.persistence=e,this.Ri=new sH,this.Ai=null}static Vi(e){return new s2(e)}get di(){if(this.Ai)return this.Ai;throw O(60996)}addReference(e,t,n){return this.Ri.addReference(n,t),this.di.delete(n.toString()),eR.resolve()}removeReference(e,t,n){return this.Ri.removeReference(n,t),this.di.add(n.toString()),eR.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),eR.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach(e=>this.di.add(e.toString()));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.di.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}Ti(){this.Ai=new Set}Ii(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return eR.forEach(this.di,n=>{let r=ea.fromPath(n);return this.mi(e,r).next(e=>{e||t.removeEntry(r,ew.min())})}).next(()=>(this.Ai=null,t.apply(e)))}updateLimboDocument(e,t){return this.mi(e,t).next(e=>{e?this.di.delete(t.toString()):this.di.add(t.toString())})}hi(e){return 0}mi(e,t){return eR.or([()=>eR.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class s5{constructor(e,t){this.persistence=e,this.fi=new rp(e=>eY(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=function(e,t){return new sO(e,t)}(this,t)}static Vi(e,t){return new s5(e,t)}Ti(){}Ii(e){return eR.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEac
6hTarget(e,t)}dr(e){let t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}pr(e){let t=0;return this.mr(e,e=>{t++}).next(()=>t)}mr(e,t){return eR.forEach(this.fi,(n,r)=>this.wr(e,n,r).next(e=>e?eR.resolve():t(r)))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.ni(e,r=>this.wr(e,r,t).next(e=>{e||(n++,i.removeEntry(r,ew.min()))})).next(()=>i.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),eR.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.fi.set(n,e.currentSequenceNumber),eR.resolve()}removeReference(e,t,n){return this.fi.set(n,e.currentSequenceNumber),eR.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),eR.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(ng(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let n=ni(t);return n?16+e(n):16;case 5:return 2*t.stringValue.length;case 6:return t7(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce((t,n)=>t+e(n),0);case 10:case 11:var r;let i;return r=t.mapValue,i=0,t$(r.fields,(t,n)=>{i+=t.length+e(n)}),i;default:throw O(13486,{value:t})}}(e.data.value)),t}wr(e,t,n){return eR.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.fi.get(t);return eR.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class s3{constructor(e){this.serializer=e}k(e,t,n,r){let i=new eO("createOrUpgrade",t);n<1&&r>=1&&(e.createObjectStore(e0),e.createObjectStore(e2,{keyPath:"userId"}),e.createObjectStore(e5,{keyPath:e3,autoIncrement:!0}).createIndex(e4,e6,{unique:!0}),e.createObjectStore(e7),s4(e),e.createObjectStore(eZ));let s=eR.resolve();return n<3&&r>=3&&(0!==n&&(e.deleteObjectStore(th),e.deleteObjectStore(to),e.deleteObjectStore(tg),s4(e)),s=s.next(()=>{let e,t;return e=i.store(tg),t={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:ew.min().toTimestamp(),targetCount:0},e.put(tm,t)})),n<4&&r>=4&&(0!==n&&(s=s.next(()=>i.store(e5).H().next(t=>{e.deleteObjectStore(e5),e.createObjectStore(e5,{keyPath:e3,autoIncrement:!0}).createIndex(e4,e6,{unique:!0});let n=i.store(e5),r=t.map(e=>n.put(e));return eR.waitFor(r)}))),s=s.next(()=>{e.createObjectStore(tw,{keyPath:"clientId"})})),n<5&&r>=5&&(s=s.next(()=>this.gi(i))),n<6&&r>=6&&(s=s.next(()=>(e.createObjectStore(ts),this.pi(i)))),n<7&&r>=7&&(s=s.next(()=>this.yi(i))),n<8&&r>=8&&(s=s.next(()=>this.wi(e,i))),n<9&&r>=9&&(s=s.next(()=>{e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")})),n<10&&r>=10&&(s=s.next(()=>this.bi(i))),n<11&&r>=11&&(s=s.next(()=>{e.createObjectStore(tv,{keyPath:"bundleId"}),e.createObjectStore(tb,{keyPath:"name"})})),n<12&&r>=12&&(s=s.next(()=>{let t;(t=e.createObjectStore(tk,{keyPath:tR})).createIndex(tM,tO,{unique:!1}),t.createIndex(tP,tF,{unique:!1})})),n<13&&r>=13&&(s=s.next(()=>{let t;(t=e.createObjectStore(e9,{keyPath:te})).createIndex(tt,tn),t.createIndex(tr,ti)}).next(()=>this.Si(e,i)).next(()=>e.deleteObjectStore(eZ))),n<14&&r>=14&&(s=s.next(()=>this.Di(e,i))),n<15&&r>=15&&(s=s.next(()=>{e.createObjectStore(tI,{keyPath:"indexId",autoIncrement:!0}).createIndex(tT,"collectionGroup",{unique:!1}),e.createObjectStore(t_,{keyPath:tE}).createIndex(tS,tx,{unique:!1}),e.createObjectStore(tC,{keyPath:tA}).createIndex(tD,tN,{unique:!1})})),n<16&&r>=16&&(s=s.next(()=>{t.objectStore(t_).clear()}).next(()=>{t.objectStore(tC).clear()})),n<17&&r>=17&&(s=s.next(()=>{e.createObjectStore(tL,{keyPath:"name"})})),n<18&&r>=18&&(0,v.isSafariOrWebkit)()&&(s=s.next(()=>{t.objectStore(t_).clear()}).next(()=>{t.objectStore(tC).clear()})),s}pi(e){let t=0;return e.store(eZ).ee((e,n)=>{t+=s_(n)}).next(()=>{let n={byteSize:t};return e.store(ts).put(ta,n)})}gi(e){let t=e.store(e2),n=e.store(e5);return t.H().next(t=>eR.forEach(t,t=>{let r=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return n.H(e4,r).next(n=>eR.forEach(n,n=>{F(n.userId===t.userId,18650,"Cannot process batch from unexpected user",{batchId:n.batchId});let r=iJ(this.serializer,n);return sT(e,t.userId,r).next(()=>{})}))}))}yi(e){let t=e.store(th),n=e.store(eZ);return e.store(tg).get(tm).next(e=>{let r=[];return n.ee((n,i)=>{let s=new er(n),a=[0,eY(s)];r.push(t.get(a).next(n=>n?eR.resolve():t.put({targetId:0,path:eY(s),sequenceNumber:e.highestListenSequenceNumber})))}).next(()=>eR.waitFor(r))})}wi(e,t){e.createObjectStore(tp,{keyPath:ty});let n=t.store(tp),r=new sg,i=e=>{if(r.add(e)){let t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:eY(r)})}};return t.store(eZ).ee({Y:!0},(e,t)=>i(new er(e).popLast())).next(()=>t.store(e7).ee({Y:!0},([e,t,n],r)=>
6i(eX(t).popLast())))}bi(e){let t=e.store(to);return t.ee((e,n)=>{let r=iY(n),i=iX(this.serializer,r);return t.put(i)})}Si(e,t){let n=t.store(eZ),r=[];return n.ee((e,n)=>{let i=t.store(e9),s=(n.document?new ea(er.fromString(n.document.name).popFirst(5)):n.noDocument?ea.fromSegments(n.noDocument.path):n.unknownDocument?ea.fromSegments(n.unknownDocument.path):O(36783)).path.toArray(),a={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(a))}).next(()=>eR.waitFor(r))}Di(e,t){let n=t.store(e5),r=new sV(this.serializer),i=new s0(s2.Vi,this.serializer.yt);return n.H().next(e=>{let n=new Map;return e.forEach(e=>{let t=n.get(e.userId)??rE();iJ(this.serializer,e).keys().forEach(e=>t=t.add(e)),n.set(e.userId,t)}),eR.forEach(n,(e,n)=>{let s=new S(n),a=i3.wt(this.serializer,s),o=i.getIndexManager(s);return new sG(r,sE.wt(s,this.serializer,o,i.referenceDelegate),a,o).recalculateAndSaveOverlaysForDocumentKeys(new tz(t,eQ.ce),e).next()})})}}function s4(e){e.createObjectStore(th,{keyPath:tc}).createIndex(td,tf,{unique:!0}),e.createObjectStore(to,{keyPath:"targetId"}).createIndex(tl,tu,{unique:!0}),e.createObjectStore(tg)}let s6="IndexedDbPersistence",s8="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",s7="main";class s9{constructor(e,t,n,r,i,s,a,o,l,u,h=18){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.Ci=i,this.window=s,this.document=a,this.Fi=l,this.Mi=u,this.xi=h,this.ai=null,this.ui=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Oi=null,this.inForeground=!1,this.Ni=null,this.Bi=null,this.Li=-1/0,this.ki=e=>Promise.resolve(),!s9.v())throw new q(V.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new sP(this,r),this.Ki=t+s7,this.serializer=new iK(o),this.qi=new eP(this.Ki,this.xi,new s3(this.serializer)),this.ci=new i4,this.li=new sA(this.referenceDelegate,this.serializer),this.remoteDocumentCache=function(e){return new sV(e)}(this.serializer),this.Pi=new i5,this.window&&this.window.localStorage?this.Ui=this.window.localStorage:(this.Ui=null,!1===u&&k(s6,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.$i().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new q(V.FAILED_PRECONDITION,s8);return this.Wi(),this.Qi(),this.Gi(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.li.getHighestSequenceNumber(e))}).then(e=>{this.ai=new eQ(e,this.Fi)}).then(()=>{this.ui=!0}).catch(e=>(this.qi&&this.qi.close(),Promise.reject(e)))}zi(e){return this.ki=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.qi.q(async t=>{null===t.newVersion&&await e()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Ci.enqueueAndForget(async()=>{this.started&&await this.$i()}))}$i(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>tG(e,tw).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.ji(e).next(e=>{e||(this.isPrimary=!1,this.Ci.enqueueRetryable(()=>this.ki(!1)))})}).next(()=>this.Hi(e)).next(t=>this.isPrimary&&!t?this.Ji(e).next(()=>!1):!!t&&this.Zi(e).next(()=>!0))).catch(e=>{if(eq(e))return N(s6,"Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return N(s6,"Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Ci.enqueueRetryable(()=>this.ki(e)),this.isPrimary=e})}ji(e){return tG(e,e0).get(e1).next(e=>eR.resolve(this.Xi(e)))}Yi(e){return tG(e,tw).delete(this.clientId)}async es(){if(this.isPrimary&&!this.ts(this.Li,18e5)){this.Li=Date.now();let e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{let t=tG(e,tw);return t.H().next(e=>{let n=this.ns(e,18e5),r=e.filter(e=>-1===n.indexOf(e));return eR.forEach(r,e=>t.delete(e.clientId)).next(()=>r)})}).catch(()=>[]);if(this.Ui)for(let t of e)this.Ui.removeItem(this.rs(t.clientId))}}Gi(){this.Bi=this.Ci.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.$i().then(()=>this.es()).then(()=>this.Gi()))}Xi(e){return!!e&&e.ownerId===this.clientId}Hi(e){return this.Mi?eR.resolve(!0):tG(e,e0).get(e1).next(t=>
6{if(null!==t&&this.ts(t.leaseTimestampMs,5e3)&&!this.ss(t.ownerId)){if(this.Xi(t)&&this.networkEnabled)return!0;if(!this.Xi(t)){if(!t.allowTabSynchronization)throw new q(V.FAILED_PRECONDITION,s8);return!1}}return!(!this.networkEnabled||!this.inForeground)||tG(e,tw).H().next(e=>void 0===this.ns(e,5e3).find(e=>{if(this.clientId!==e.clientId){let t=!this.networkEnabled&&e.networkEnabled,n=!this.inForeground&&e.inForeground,r=this.networkEnabled===e.networkEnabled;if(t||n&&r)return!0}return!1}))}).next(e=>(this.isPrimary!==e&&N(s6,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.ui=!1,this._s(),this.Bi&&(this.Bi.cancel(),this.Bi=null),this.us(),this.cs(),await this.qi.runTransaction("shutdown","readwrite",[e0,tw],e=>{let t=new tz(e,eQ.ce);return this.Ji(t).next(()=>this.Yi(t))}),this.qi.close(),this.ls()}ns(e,t){return e.filter(e=>this.ts(e.updateTimeMs,t)&&!this.ss(e.clientId))}hs(){return this.runTransaction("getActiveClients","readonly",e=>tG(e,tw).H().next(e=>this.ns(e,18e5).map(e=>e.clientId)))}get started(){return this.ui}getGlobalsCache(){return this.ci}getMutationQueue(e,t){return sE.wt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new sw(e,this.serializer.yt.databaseId)}getDocumentOverlayCache(e){return i3.wt(this.serializer,e)}getBundleCache(){return this.Pi}runTransaction(e,t,n){var r;let i;N(s6,"Starting transaction:",e);let s=18===(r=this.xi)||17===r?tj:16===r||15===r?tB:14===r||13===r?tU:12===r?tq:11===r?tV:void O(60245);return this.qi.runTransaction(e,"readonly"===t?"readonly":"readwrite",s,r=>(i=new tz(r,this.ai?this.ai.next():eQ.ce),"readwrite-primary"===t?this.ji(i).next(e=>!!e||this.Hi(i)).next(t=>{if(!t)throw k(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.Ci.enqueueRetryable(()=>this.ki(!1)),new q(V.FAILED_PRECONDITION,eD);return n(i)}).next(e=>this.Zi(i).next(()=>e)):this.Ps(i).next(()=>n(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}Ps(e){return tG(e,e0).get(e1).next(e=>{if(null!==e&&this.ts(e.leaseTimestampMs,5e3)&&!this.ss(e.ownerId)&&!this.Xi(e)&&!(this.Mi||this.allowTabSynchronization&&e.allowTabSynchronization))throw new q(V.FAILED_PRECONDITION,s8)})}Zi(e){let t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return tG(e,e0).put(e1,t)}static v(){return eP.v()}Ji(e){let t=tG(e,e0);return t.get(e1).next(e=>
6this.Xi(e)?(N(s6,"Releasing primary lease."),t.delete(e1)):eR.resolve())}ts(e,t){let n=Date.now();return!(e<n-t)&&(!(e>n)||(k(`Detected an update time that is in the future: ${e} > ${n}`),!1))}Wi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ni=()=>{this.Ci.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.$i()))},this.document.addEventListener("visibilitychange",this.Ni),this.inForeground="visible"===this.document.visibilityState)}us(){this.Ni&&(this.document.removeEventListener("visibilitychange",this.Ni),this.Ni=null)}Qi(){"function"==typeof this.window?.addEventListener&&(this.Oi=()=>{this._s();let e=/(?:Version|Mobile)\/1[456]/;(0,v.isSafari)()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.Ci.enterRestrictedMode(!0),this.Ci.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Oi))}cs(){this.Oi&&(this.window.removeEventListener("pagehide",this.Oi),this.Oi=null)}ss(e){try{let t=null!==this.Ui?.getItem(this.rs(e));return N(s6,`Client '${e}' ${t?"is":"is not"} zombied in LocalStorage`),t}catch(e){return k(s6,"Failed to get zombied client id.",e),!1}}_s(){if(this.Ui)try{this.Ui.setItem(this.rs(this.clientId),String(Date.now()))}catch(e){k("Failed to set zombie client id.",e)}}ls(){if(this.Ui)try{this.Ui.removeItem(this.rs(this.clientId))}catch(e){}}rs(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function ae(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class at{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Ts=n,this.Is=r}static Es(e,t){let n=rE(),r=rE();for(let e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new at(e,t.fromCache,n,r)}}class an{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class ar{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=(0,v.isSafari)()?8:eF((0,v.getUA)())>0?6:4}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.gs(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.ps(e,t,r,n).next(e=>{i.result=e})}).next(()=>{if(i.result)return;let n=new an;return this.ys(e,t,n).next(r=>{if(i.result=r,this.As)return this.ws(e,t,n,r.size)})}).next(()=>i.result)}ws(e,t,n,r){return n.documentReadCount<this.Vs?(A()<=T.LogLevel.DEBUG&&N("QueryEngine","SDK will not create cache indexes for query:",rd(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),eR.resolve()):(A()<=T.LogLevel.DEBUG&&N("QueryEngine","Query:",rd(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.ds*r?(A()<=T.LogLevel.DEBUG&&N("QueryEngine","The SDK decides to create cache indexes for query:",rd(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,rs(t))):eR.resolve())}gs(e,t){if(rn(t))return eR.resolve(null);let n=rs(t);return this.indexManager.getIndexType(e,n).next(r=>0===r?null:(null!==t.limit&&1===r&&(n=rs(t=ru(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,n).next(r=>{let i=rE(...r);return this.fs.getDocuments(e,i).next(r=>this.indexManager.getMinOffset(e,n).next(n=>{let s=this.bs(t,r);return this.Ss(t,s,i,n.readTime)?this.gs(e,ru(t,null,"F")):this.Ds(e,s,t,n)}))})))}ps(e,t,n,r){return rn(t)||r.isEqual(ew.min())?eR.resolve(null):this.fs.getDocuments(e,n).next(i=>{let s=this.bs(t,i);return this.Ss(t,s,n,r)?eR.resolve(null):(A()<=T.LogLevel.DEBUG&&N("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),rd(t)),this.Ds(e,s,t,eS(r,-1)).next(e=>e))})}bs(e,t){let n=new tX(rg(e));return t.forEach((t,r)=>{rf(e,r)&&(n=n.add(r))}),n}Ss(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;let i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}ys(e,t,n){return A()<=T.LogLevel.DEBUG&&N("QueryEngine","Using full collection scan to execute query:",rd(t)),this.fs.getDocumentsMatchingQuery(e,t,eC.min(),n)}Ds(e,t,n,r){return this.fs.getDocumentsMatchingQuery(e,n,r).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let ai="LocalStore";class as{constructor(e,t,n,r){this.persistence=e,this.Cs=t,this.serializer
6=r,this.vs=new tW(Y),this.Fs=new rp(e=>n3(e),n4),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(n)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new sG(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.vs))}}async function aa(e,t){return await e.persistence.runTransaction("Handle user change","readonly",n=>{let r;return e.mutationQueue.getAllMutationBatches(n).next(i=>(r=i,e.Os(t),e.mutationQueue.getAllMutationBatches(n))).next(t=>{let i=[],s=[],a=rE();for(let e of r)for(let t of(i.push(e.batchId),e.mutations))a=a.add(t.key);for(let e of t)for(let t of(s.push(e.batchId),e.mutations))a=a.add(t.key);return e.localDocuments.getDocuments(n,a).next(e=>({Ns:e,removedBatchIds:i,addedBatchIds:s}))})})}function ao(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.li.getLastRemoteSnapshotVersion(t))}function al(e,t,n){let r=rE(),i=rE();return n.forEach(e=>r=r.add(e)),t.getEntries(e,r).next(e=>{let r=ry;return n.forEach((n,s)=>{let a=e.get(n);s.isFoundDocument()!==a.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(ew.min())?(t.removeEntry(n,s.readTime),r=r.insert(n,s)):!a.isValidDocument()||s.version.compareTo(a.version)>0||0===s.version.compareTo(a.version)&&a.hasPendingWrites?(t.addEntry(s),r=r.insert(n,s)):N(ai,"Ignoring outdated watch update for ",n,". Current version:",a.version," Watch version:",s.version)}),{Bs:r,Ls:i}})}function au(e,t){return e.persistence.runTransaction("Allocate target","readwrite",n=>{let r;return e.li.getTargetData(n,t).next(i=>i?(r=i,eR.resolve(r)):e.li.allocateTargetId(n).next(i=>(r=new iG(t,i,"TargetPurposeListen",n.currentSequenceNumber),e.li.addTargetData(n,r).next(()=>r))))}).then(n=>{let r=e.vs.get(n.targetId);return(null===r||n.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(e.vs=e.vs.insert(n.targetId,n),e.Fs.set(t,n.targetId)),n})}async function ah(e,t,n){let r=e.vs.get(t);try{n||await e.persistence.runTransaction("Release target",n?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,r))}catch(e){if(!eq(e))throw e;N(ai,`Failed to update sequence numbers for target ${t}: ${e}`)}e.vs=e.vs.remove(t),e.Fs.delete(r.target)}function ac(e,t,n){let r=ew.min(),i=rE();return e.persistence.runTransaction("Execute query","readwrite",s=>{var a;let o;return(a=rs(t),void 0!==(o=e.Fs.get(a))?eR.resolve(e.vs.get(o)):e.li.getTargetData(s,a)).next(t=>{if(t)return r=t.lastLimboFreeSnapshotVersion,e.li.getMatchingKeysForTargetId(s,t.targetId).next(e=>{i=e})}).next(()=>e.Cs.getDocumentsMatchingQuery(s,t,n?r:ew.min(),n?i:rE())).next(n=>(am(e,rm(t),n),{documents:n,ks:i}))})}function ad(e,t){let n=e.li,r=e.vs.get(t);return r?Promise.resolve(r.target):e.persistence.runTransaction("Get target data","readonly",e=>n.At(e,t).next(e=>e?e.target:null))}function af(e,t){let n=e.Ms.get(t)||ew.min();return e.persistence.runTransaction("Get new document changes","readonly",r=>e.xs.getAllFromCollectionGroup(r,t,eS(n,-1),Number.MAX_SAFE_INTEGER)).then(n=>(am(e,t,n),n))}function am(e,t,n){let r=e.Ms.get(t)||ew.min();n.forEach((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)}),e.Ms.set(t,r)}async function ag(e,t,n,r){let i=rE(),s=ry;for(let e of n){let n=t.Ks(e.metadata.name);e.document&&(i=i.add(n));let r=t.qs(e);r.setReadTime(t.Us(e.metadata.readTime)),s=s.insert(n,r)}let a=e.xs.newChangeBuffer({trackRemovals:!0}),o=await au(e,rs(rt(er.fromString(`__bundle__/docs/${r}`))));return e.persistence.runTransaction("Apply bundle documents","readwrite",t=>al(t,a,s).next(e=>(a.apply(t),e)).next(n=>e.li.removeMatchingKeysForTargetId(t,o.targetId).next(()=>e.li.addMatchingKeys(t,i,o.targetId)).next(()=>e.localDocuments.getLocalViewOfDocuments(t,n.Bs,n.Ls)).next(()=>
6n.Bs)))}async function ap(e,t,n=rE()){let r=await au(e,rs(iZ(t.bundledQuery)));return e.persistence.runTransaction("Save named query","readwrite",i=>{let s=iT(t.readTime);if(r.snapshotVersion.compareTo(s)>=0)return e.Pi.saveNamedQuery(i,t);let a=r.withResumeToken(t3.EMPTY_BYTE_STRING,s);return e.vs=e.vs.insert(a.targetId,a),e.li.updateTargetData(i,a).next(()=>e.li.removeMatchingKeysForTargetId(i,r.targetId)).next(()=>e.li.addMatchingKeys(i,n,r.targetId)).next(()=>e.Pi.saveNamedQuery(i,t))})}let ay="firestore_clients";function aw(e,t){return`${ay}_${e}_${t}`}let av="firestore_mutations";function ab(e,t,n){let r=`${av}_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}let aI="firestore_targets";function aT(e,t){return`${aI}_${e}_${t}`}let a_="SharedClientState";class aE{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static $s(e,t,n){let r=JSON.parse(n),i,s="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return s&&r.error&&(s="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(i=new q(r.error.code,r.error.message)),s?new aE(e,t,r.state,i):(k(a_,`Failed to parse mutation state for ID '${t}': ${n}`),null)}Ws(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class aS{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static $s(e,t){let n=JSON.parse(t),r,i="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return i&&n.error&&(i="string"==typeof n.error.message&&"string"==typeof n.error.code)&&(r=new q(n.error.code,n.error.message)),i?new aS(e,n.state,r):(k(a_,`Failed to parse target state for ID '${e}': ${t}`),null)}Ws(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class ax{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static $s(e,t){let n=JSON.parse(t),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=rS;for(let e=0;r&&e<n.activeTargetIds.length;++e)r=eJ(n.activeTargetIds[e]),i=i.add(n.activeTargetIds[e]);return r?new ax(e,i):(k(a_,`Failed to parse client data for instance '${e}': ${t}`),null)}}class aC{constructor(e,t){this.clientId=e,this.onlineState=t}static $s(e){let t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new aC(t.clientId,t.onlineState):(k(a_,`Failed to parse online state: ${e}`),null)}}class aA{constructor(){this.activeTargetIds=rS}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class aD{constructor(e,t,n,r,i){this.window=e,this.Ci=t,this.persistenceKey=n,this.zs=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.js=this.Hs.bind(this),this.Js=new tW(Y),this.started=!1,this.Zs=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Xs=aw(this.persistenceKey,this.zs),this.Ys=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Js=this.Js.insert(this.zs,new aA),this.eo=RegExp(`^${ay}_${s}_([^_]*)$`),this.no=RegExp(`^${av}_${s}_(\\d+)(?:_(.*))?$`),this.ro=RegExp(`^${aI}_${s}_(\\d+)$`),this.io=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.so=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this.js)}static v(e){return!(!e||!e.localStorage)}async start(){for(let e of(await this.syncEngine.hs())){if(e===this.zs)continue;let t=this.getItem(aw(this.persistenceKey,e));if(t){let n=ax.$s(e,t);n&&(this.Js=this.Js.insert(n.clientId,n))}}this.oo();let e=this.storage.getItem(this.io);if(e){let t=this._o(e);t&&this.ao(t)}for(let e of this.Zs)this.Hs(e);this.Zs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.Ys,JSON.stringify(e))}getAllActiveQueryTargets(){return this.uo(this.Js)}isActiveQueryTarget(e){let t=!1;
6return this.Js.forEach((n,r)=>{r.activeTargetIds.has(e)&&(t=!0)}),t}addPendingMutation(e){this.co(e,"pending")}updateMutationState(e,t,n){this.co(e,t,n),this.lo(e)}addLocalQueryTarget(e,t=!0){let n="not-current";if(this.isActiveQueryTarget(e)){let t=this.storage.getItem(aT(this.persistenceKey,e));if(t){let r=aS.$s(e,t);r&&(n=r.state)}}return t&&this.ho.Qs(e),this.oo(),n}removeLocalQueryTarget(e){this.ho.Gs(e),this.oo()}isLocalQueryTarget(e){return this.ho.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(aT(this.persistenceKey,e))}updateQueryState(e,t,n){this.Po(e,t,n)}handleUserChange(e,t,n){t.forEach(e=>{this.lo(e)}),this.currentUser=e,n.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.To(e)}notifyBundleLoaded(e){this.Io(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.js),this.removeItem(this.Xs),this.started=!1)}getItem(e){let t=this.storage.getItem(e);return N(a_,"READ",e,t),t}setItem(e,t){N(a_,"SET",e,t),this.storage.setItem(e,t)}removeItem(e){N(a_,"REMOVE",e),this.storage.removeItem(e)}Hs(e){if(e.storageArea===this.storage){if(N(a_,"EVENT",e.key,e.newValue),e.key===this.Xs)return void k("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Ci.enqueueRetryable(async()=>{if(this.started){if(null!==e.key){if(this.eo.test(e.key)){if(null==e.newValue){let t=this.Eo(e.key);return this.Ro(t,null)}{let t=this.Ao(e.key,e.newValue);if(t)return this.Ro(t.clientId,t)}}else if(this.no.test(e.key)){if(null!==e.newValue){let t=this.Vo(e.key,e.newValue);if(t)return this.mo(t)}}else if(this.ro.test(e.key)){if(null!==e.newValue){let t=this.fo(e.key,e.newValue);if(t)return this.po(t)}}else if(e.key===this.io){if(null!==e.newValue){let t=this._o(e.newValue);if(t)return this.ao(t)}}else if(e.key===this.Ys){let t=function(e){let t=eQ.ce;if(null!=e)try{let n=JSON.parse(e);F("number"==typeof n,30636,{yo:e}),t=n}catch(e){k(a_,"Failed to read sequence number from WebStorage",e)}return t}(e.newValue);t!==eQ.ce&&this.sequenceNumberHandler(t)}else if(e.key===this.so){let t=this.wo(e.newValue);await Promise.all(t.map(e=>this.syncEngine.bo(e)))}}}else this.Zs.push(e)})}}get ho(){return this.Js.get(this.zs)}oo(){this.setItem(this.Xs,this.ho.Ws())}co(e,t,n){let r=new aE(this.currentUser,e,t,n),i=ab(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Ws())}lo(e){let t=ab(this.persistenceKey,this.currentUser,e);this.removeItem(t)}To(e){let t={clientId:this.zs,onlineState:e};this.storage.setItem(this.io,JSON.stringify(t))}Po(e,t,n){let r=aT(this.persistenceKey,e),i=new aS(e,t,n);this.setItem(r,i.Ws())}Io(e){let t=JSON.stringify(Array.from(e));this.setItem(this.so,t)}Eo(e){let t=this.eo.exec(e);return t?t[1]:null}Ao(e,t){let n=this.Eo(e);return ax.$s(n,t)}Vo(e,t){let n=this.no.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return aE.$s(new S(i),r,t)}fo(e,t){let n=Number(this.ro.exec(e)[1]);return aS.$s(n,t)}_o(e){return aC.$s(e)}wo(e){return JSON.parse(e)}async mo(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.So(e.batchId,e.state,e.error);N(a_,`Ignoring mutation for non-active user ${e.user.uid}`)}po(e){return this.syncEngine.Do(e.targetId,e.state,e.error)}Ro(e,t){let n=t?this.Js.insert(e,t):this.Js.remove(e),r=this.uo(this.Js),i=this.uo(n),s=[],a=[];return i.forEach(e=>{r.has(e)||s.push(e)}),r.forEach(e=>{i.has(e)||a.push(e)}),this.syncEngine.Co(s,a).then(()=>{this.Js=n})}ao(e){this.Js.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}uo(e){let t=rS;return e.forEach((e,n)=>{t=t.unionWith(n.activeTargetIds)}),t}}class aN{constructor(){this.vo=new aA,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,n){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new aA,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class ak{Mo(e){}shutdown(){}}let aR="ConnectivityMonitor";class aM{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}
6ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){for(let e of(N(aR,"Network connectivity changed: AVAILABLE"),this.Lo))e(0)}Bo(){for(let e of(N(aR,"Network connectivity changed: UNAVAILABLE"),this.Lo))e(1)}static v(){return"u">typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let aO=null;function aP(){return null===aO?aO=0x10000000+Math.round(0x80000000*Math.random()):aO++,"0x"+aO.toString(16)}let aF="RestConnection",aL={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class aV{get Ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.qo=t+"://"+e.host,this.Uo=`projects/${n}/databases/${r}`,this.$o=this.databaseId.database===no?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Wo(e,t,n,r,i){let s=aP(),a=this.Qo(e,t.toUriEncodedString());N(aF,`Sending RPC '${e}' ${s}:`,a,n);let o={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(o,r,i);let{host:l}=new URL(a),u=(0,v.isCloudWorkstation)(l);return this.zo(e,a,o,n,u).then(t=>(N(aF,`Received RPC '${e}' ${s}: `,t),t),t=>{throw R(aF,`RPC '${e}' ${s} failed with error: `,t,"url: ",a,"request:",n),t})}jo(e,t,n,r,i,s){return this.Wo(e,t,n,r,i)}Go(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+x,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,n)=>e[n]=t),n&&n.headers.forEach((t,n)=>e[n]=t)}Qo(e,t){let n=aL[e],r=`${this.qo}/v1/${t}:${n}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}}class aq{constructor(e){this.Ho=e.Ho,this.Jo=e.Jo}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Jo()}send(e){this.Ho(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}let aU="WebChannelConnection",aB=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};class aj extends aV{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){aj.c_||(aB(u(),l.STAT_EVENT,e=>{e.stat===o.PROXY?N(aU,"STAT_EVENT: detected buffering proxy"):e.stat===o.NOPROXY&&N(aU,"STAT_EVENT: detected no buffering proxy")}),aj.c_=!0)}zo(e,t,n,i,o){let l=aP();return new Promise((o,u)=>{let h=new r;h.setWithCredentials(!0),h.listenOnce(s.COMPLETE,()=>{try{switch(h.getLastErrorCode()){case a.NO_ERROR:let t=h.getResponseJson();N(aU,`XHR for RPC '${e}' ${l} received:`,JSON.stringify(t)),o(t);break;case a.TIMEOUT:N(aU,`RPC '${e}' ${l} timed out`),u(new q(V.DEADLINE_EXCEEDED,"Request time out"));break;case a.HTTP_ERROR:let n=h.getStatus();if(N(aU,`RPC '${e}' ${l} failed with status:`,n,"response text:",h.getResponseText()),n>0){let e=h.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;if(t&&t.status&&t.message){let e,n=(e=t.status.toLowerCase().replace(/_/g,"-"),Object.values(V).indexOf(e)>=0?e:V.UNKNOWN);u(new q(n,t.message))}else u(new q(V.UNKNOWN,"Server responded with status "+h.getStatus()))}else u(new q(V.UNAVAILABLE,"Connection failed."));break;default:O(9055,{l_:e,streamId:l,h_:h.getLastErrorCode(),P_:h.getLastError()})}}finally{N(aU,`RPC '${e}' ${l} completed.`)}});let c=JSON.stringify(i);N(aU,`RPC '${e}' ${l} sending request:`,i),h.send(t,"POST",c,n,15)})}T_(e,t,n){let r=aP(),s=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},l=this.longPollingOptions.timeoutSeconds;void 0!==l&&(o.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(o.useFetchStreams=!0),this.Go(o.initMessageHeaders,t,n),o.encodeInitMessageHeaders=!0;let u=s.join("");N(aU,`Creating RPC '${e}' stream ${r}: ${u}`,o);let h=a.createWebChannel(u,o);this.I_(h);let d=!1,f=!1,m=new aq({Ho:t=>{f?N(aU,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(d||(N(aU,`Opening RPC '${e}' stream ${r} transport.`),h.open(),d=!0),N(aU,`RPC '${e}' stream ${r} sending:`,t),h.send(t))},Jo:()=>h.close()});return aB(h,i.EventType.OPEN,()=>{f||(N(aU,`RPC '${e}' stream ${r} transport opened.`),m.i_())}),aB(h,i.EventType.CLOSE,()=>{f||(f=!0,N(aU,`RPC '${e}' stream ${r} transport closed`),m.o_(),this.E_(h))}
6),aB(h,i.EventType.ERROR,t=>{f||(f=!0,R(aU,`RPC '${e}' stream ${r} transport errored. Name:`,t.name,"Message:",t.message),m.o_(new q(V.UNAVAILABLE,"The operation could not be completed")))}),aB(h,i.EventType.MESSAGE,t=>{if(!f){let n=t.data[0];F(!!n,16349);let i=n?.error||n[0]?.error;if(i){N(aU,`RPC '${e}' stream ${r} received error:`,i);let t=i.status,n=function(e){let t=c[e];if(void 0!==t)return r6(t)}(t),s=i.message;"NOT_FOUND"===t&&s.includes("database")&&s.includes("does not exist")&&s.includes(this.databaseId.database)&&R(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),void 0===n&&(n=V.INTERNAL,s="Unknown error status: "+t+" with message "+i.message),f=!0,m.o_(new q(n,s)),h.close()}else N(aU,`RPC '${e}' stream ${r} received:`,n),m.__(n)}}),aj.u_(),setTimeout(()=>{m.s_()},0),m}terminate(){this.a_.forEach(e=>e.close()),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter(t=>t===e)}Go(e,t,n){super.Go(e,t,n),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return h()}}function az(){return"u">typeof window?window:null}function aG(){return"u">typeof document?document:null}function aK(e){return new iw(e,!0)}aj.c_=!1;class a${constructor(e,t,n=1e3,r=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=n,this.A_=r,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();let t=Math.floor(this.d_+this.y_()),n=Math.max(0,Date.now()-this.f_),r=Math.max(0,t-n);r>0&&N("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,r,()=>(this.f_=Date.now(),e())),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){null!==this.m_&&(this.m_.skipDelay(),this.m_=null)}cancel(){null!==this.m_&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}let aQ="PersistentStream";class aH{constructor(e,t,n,r,i,s,a,o){this.Ci=e,this.b_=n,this.S_=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new a$(e,t)}x_(){return 1===this.state||5===this.state||this.O_()}O_(){return 2===this.state||3===this.state}start(){this.F_=0,4!==this.state?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&null===this.C_&&(this.C_=this.Ci.enqueueAfterDelay(this.b_,6e4,()=>this.k_()))}K_(e){this.q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,4!==e?this.M_.reset():t&&t.code===V.RESOURCE_EXHAUSTED?(k(t.toString()),k("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===V.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;let e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,n])=>{this.D_===t&&this.G_(e,n)},t=>{e(()=>{let e=new q(V.UNKNOWN,"Fetching auth token failed: "+t.message);return this.z_(e)})})}G_(e,t){let n=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo(()=>{n(()=>this.listener.Zo())}),this.stream.Yo(()=>{n(()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.S_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.Yo()))}),this.stream.t_(e=>{n(()=>this.z_(e))}),this.stream.onMessage(e=>{n(()=>1==++this.F_?this.H_(e):this.onNext(e))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return N(aQ,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget(()=>this.D_===e?t():(N(aQ,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class aW extends aH{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s
6),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}H_(e){return this.onNext(e)}onNext(e){this.M_.reset();let t=function(e,t){let n;if("targetChange"in t){var r,i;t.targetChange;let s="NO_CHANGE"===(r=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===r?1:"REMOVE"===r?2:"CURRENT"===r?3:"RESET"===r?4:O(39313,{state:r}),a=t.targetChange.targetIds||[],o=(i=t.targetChange.resumeToken,e.useProto3Json?(F(void 0===i||"string"==typeof i,58123),t3.fromBase64String(i||"")):(F(void 0===i||i instanceof w.Buffer||i instanceof Uint8Array,16193),t3.fromUint8Array(i||new Uint8Array))),l=t.targetChange.cause;n=new iu(s,a,o,l&&new q(void 0===l.code?V.UNKNOWN:r6(l.code),l.message||"")||null)}else if("documentChange"in t){t.documentChange;let r=t.documentChange;r.document,r.document.name,r.document.updateTime;let i=iC(e,r.document.name),s=iT(r.document.updateTime),a=r.document.createTime?iT(r.document.createTime):ew.min(),o=new nO({mapValue:{fields:r.document.fields}}),l=nP.newFoundDocument(i,s,a,o);n=new io(r.targetIds||[],r.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let r=t.documentDelete;r.document;let i=iC(e,r.document),s=r.readTime?iT(r.readTime):ew.min(),a=nP.newNoDocument(i,s);n=new io([],r.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let r=t.documentRemove;r.document;let i=iC(e,r.document);n=new io([],r.removedTargetIds||[],i,null)}else{if(!("filter"in t))return O(11601,{Vt:t});{t.filter;let e=t.filter;e.targetId;let{count:r=0,unchangedNames:i}=e,s=new r3(r,i);n=new il(e.targetId,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return ew.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?ew.min():t.readTime?iT(t.readTime):ew.min()}(e);return this.listener.J_(t,n)}Z_(e){let t,n={};n.database=iN(this.serializer),n.addTarget=function(e,t){let n,r=t.target;if((n=n6(r)?{documents:iF(e,r)}:{query:iL(e,r).ft}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=iI(e,t.resumeToken);let r=iv(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(ew.min())>0){n.readTime=ib(e,t.snapshotVersion.toTimestamp());let r=iv(e,t.expectedCount);null!==r&&(n.expectedCount=r)}return n}(this.serializer,e);let r=(this.serializer,null==(t=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return O(28987,{purpose:e})}}(e.purpose))?null:{"goog-listen-tags":t});r&&(n.labels=r),this.K_(n)}X_(e){let t={};t.database=iN(this.serializer),t.removeTarget=e,this.K_(t)}}class aJ extends aH{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}H_(e){return F(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,F(!e.writeResults||0===e.writeResults.length,55816),this.listener.ta()}onNext(e){var t,n;F(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();let r=(t=e.writeResults,n=e.commitTime,t&&t.length>0?(F(void 0!==n,14353),t.map(e=>{let t;return(t=e.updateTime?iT(e.updateTime):iT(n)).isEqual(ew.min())&&(t=iT(n)),new rU(t,e.transformResults||[])})):[]),i=iT(e.commitTime);return this.listener.na(i,r)}ra(){let e={};e.database=iN(this.serializer),this.K_(e)}ea(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>iO(this.serializer,e))};this.K_(t)}}class aY{}class aX extends aY{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.ia=!1}sa(){if(this.ia)throw new q(V.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,n,r){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.Wo(e,iE(t,n),r,i,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===V.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new q(V.UNKNOWN,e.toString())})}jo(e,t,n,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.connection.jo(e,iE(t,n),r,s,a,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===V.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new q(V.UNKNOWN,e.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}class aZ{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){0===this.oa&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(e){"Online"===this.state?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,"Online"===e&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){let t=`Could not reach Cloud Firestore backend. ${e}
7This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(k(t),this.aa=!1):N("OnlineStateTracker",t)}Pa(){null!==this._a&&(this._a.cancel(),this._a=null)}}let a0="RemoteStore";class a1{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo(e=>{n.enqueueAndForget(async()=>
7{oe(this)&&(N(a0,"Restarting streams for network reachability change."),await async function(e){e.Ea.add(4),await a5(e),e.Va.set("Unknown"),e.Ea.delete(4),await a2(e)}(this))})}),this.Va=new aZ(n,r)}}async function a2(e){if(oe(e))for(let t of e.Ra)await t(!0)}async function a5(e){for(let t of e.Ra)await t(!1)}function a3(e,t){e.Ia.has(t.targetId)||(e.Ia.set(t.targetId,t),a9(e)?a7(e):op(e).O_()&&a6(e,t))}function a4(e,t){let n=op(e);e.Ia.delete(t),n.O_()&&a8(e,t),0===e.Ia.size&&(n.O_()?n.L_():oe(e)&&e.Va.set("Unknown"))}function a6(e,t){if(e.da.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(ew.min())>0){let n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}op(e).Z_(t)}function a8(e,t){e.da.$e(t),op(e).X_(t)}function a7(e){e.da=new ic({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ia.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),op(e).start(),e.Va.ua()}function a9(e){return oe(e)&&!op(e).x_()&&e.Ia.size>0}function oe(e){return 0===e.Ea.size}async function ot(e){e.Va.set("Online")}async function on(e){e.Ia.forEach((t,n)=>{a6(e,t)})}async function or(e,t){e.da=void 0,a9(e)?(e.Va.ha(t),a7(e)):e.Va.set("Unknown")}async function oi(e,t,n){if(e.Va.set("Online"),t instanceof iu&&2===t.state&&t.cause)try{await async function(e,t){let n=t.cause;for(let r of t.targetIds)e.Ia.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.Ia.delete(r),e.da.removeTarget(r))}(e,t)}catch(n){N(a0,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await os(e,n)}else if(t instanceof io?e.da.Xe(t):t instanceof il?e.da.st(t):e.da.tt(t),!n.isEqual(ew.min()))try{let t,r=await ao(e.localStore);n.compareTo(r)>
7=0&&await ((t=e.da.Tt(n)).targetChanges.forEach((t,r)=>{if(t.resumeToken.approximateByteSize()>0){let i=e.Ia.get(r);i&&e.Ia.set(r,i.withResumeToken(t.resumeToken,n))}}),t.targetMismatches.forEach((t,n)=>{let r=e.Ia.get(t);if(!r)return;e.Ia.set(t,r.withResumeToken(t3.EMPTY_BYTE_STRING,r.snapshotVersion)),a8(e,t);let i=new iG(r.target,t,n,r.sequenceNumber);a6(e,i)}),e.remoteSyncer.applyRemoteEvent(t))}catch(t){N(a0,"Failed to raise snapshot:",t),await os(e,t)}}async function os(e,t,n){if(!eq(t))throw t;e.Ea.add(1),await a5(e),e.Va.set("Offline"),n||(n=()=>ao(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{N(a0,"Retrying IndexedDB access"),await n(),e.Ea.delete(1),await a2(e)})}function oa(e,t){return t().catch(n=>os(e,n,t))}async function oo(e){var t;let n=oy(e),r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:-1;for(;oe(t=e)&&t.Ta.length<10;)try{let t=await function(e,t){return e.persistence.runTransaction("Get next mutation batch","readonly",n=>(void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(n,t)))}(e.localStore,r);if(null===t){0===e.Ta.length&&n.L_();break}r=t.batchId,function(e,t){e.Ta.push(t);let n=oy(e);n.O_()&&n.Y_&&n.ea(t.mutations)}(e,t)}catch(t){await os(e,t)}ol(e)&&ou(e)}function ol(e){return oe(e)&&!oy(e).x_()&&e.Ta.length>0}function ou(e){oy(e).start()}async function oh(e){oy(e).ra()}async function oc(e){let t=oy(e);for(let n of e.Ta)t.ea(n.mutations)}async function od(e,t,n){let r=e.Ta.shift(),i=r1.from(r,t,n);await oa(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await oo(e)}async function of(e,t){t&&oy(e).Y_&&await async function(e,t){var n;if(r4(n=t.code)&&n!==V.ABORTED){let n=e.Ta.shift();oy(e).B_(),await oa(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await oo(e)}}(e,t),ol(e)&&ou(e)}async function om(e,t){e.asyncQueue.verifyOperationInProgress(),N(a0,"RemoteStore received new credentials");let n=oe(e);e.Ea.add(3),await a5(e),n&&e.Va.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ea.delete(3),await a2(e)}async function og(e,t){t?(e.Ea.delete(2),await a2(e)):t||(e.Ea.add(2),await a5(e),e.Va.set("Unknown"))}function op(e){var t,n,r;return e.ma||(t=e.datastore,n=e.asyncQueue,r={Zo:ot.bind(null,e),Yo:on.bind(null,e),t_:or.bind(null,e),J_:oi.bind(null,e)},t.sa(),e.ma=new aW(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r),e.Ra.push(async t=>{t?(e.ma.B_(),a9(e)?a7(e):e.Va.set("Unknown")):(await e.ma.stop(),e.da=void 0)})),e.ma}function oy(e){var t,n,r;return e.fa||(t=e.datastore,n=e.asyncQueue,r={Zo:()=>Promise.resolve(),Yo:oh.bind(null,e),t_:of.bind(null,e),ta:oc.bind(null,e),na:od.bind(null,e)},t.sa(),e.fa=new aJ(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r),e.Ra.push(async t=>{t?(e.fa.B_(),await oo(e)):(await e.fa.stop(),e.Ta.length>0&&(N(a0,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))})),e.fa}class ow{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new U,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,r,i){let s=new ow(e,t,Date.now()+n,r,i);return s.start(n),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new q(V.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function ov(e,t){if(k("AsyncQueue",`${t}: ${e}`),eq(e))return new q(V.UNAVAILABLE,`${t}: ${e}`);throw e}class ob{static emptySet(e){return new ob(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||ea.comparator(t.key,n.key):(e,t)=>ea.comparator(e.key,t.key),this.keyedMap=rv(),this.sortedSet=new tW(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,n)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof ob)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){let e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"}copy(e,t){let n=new ob;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class oI{constructor(){this.ga=new tW(ea.comparator)}track(e){let t=e.doc.key,n=this.ga.get(t);n?0!==e.type&&3===n.type?this.ga=this.ga.insert(t,e):3===e.type&&1!==n.type?this.ga=this.ga.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.ga=this.ga.remove(t):1===e.type&&2===n.type?this.ga=this.ga.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):O(63341,{Vt:e,pa:n}):this.ga=this.ga.insert(t,e)}ya(){let e=[];return this.ga.inorderTraversal((t,n)=>{e.push(n)}),e}}class oT{constructor(e,t,n,r,i,s,a,o,l){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,n,r,i){let s=[];
7return t.forEach(e=>{s.push({type:0,doc:e})}),new oT(e,t,ob.emptySet(t),s,n,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&rh(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}}class o_{constructor(){this.wa=void 0,this.ba=[]}Sa(){return this.ba.some(e=>e.Da())}}class oE{constructor(){this.queries=oS(),this.onlineState="Unknown",this.Ca=new Set}terminate(){var e;let t;e=new q(V.ABORTED,"Firestore shutting down"),t=this.queries,this.queries=oS(),t.forEach((t,n)=>{for(let t of n.ba)t.onError(e)})}}function oS(){return new rp(e=>rc(e),rh)}async function ox(e,t){let n=3,r=t.query,i=e.queries.get(r);i?!i.Sa()&&t.Da()&&(n=2):(i=new o_,n=+!t.Da());try{switch(n){case 0:i.wa=await e.onListen(r,!0);break;case 1:i.wa=await e.onListen(r,!1);break;case 2:await e.onFirstRemoteStoreListen(r)}}catch(n){let e=ov(n,`Initialization of query '${rd(t.query)}' failed`);return void t.onError(e)}e.queries.set(r,i),i.ba.push(t),t.va(e.onlineState),i.wa&&t.Fa(i.wa)&&oN(e)}async function oC(e,t){let n=t.query,r=3,i=e.queries.get(n);if(i){let e=i.ba.indexOf(t);e>=0&&(i.ba.splice(e,1),0===i.ba.length?r=+!t.Da():!i.Sa()&&t.Da()&&(r=2))}switch(r){case 0:return e.queries.delete(n),e.onUnlisten(n,!0);case 1:return e.queries.delete(n),e.onUnlisten(n,!1);case 2:return e.onLastRemoteStoreUnlisten(n);default:return}}function oA(e,t){let n=!1;for(let r of t){let t=r.query,i=e.queries.get(t);if(i){for(let e of i.ba)e.Fa(r)&&(n=!0);i.wa=r}}n&&oN(e)}function oD(e,t,n){let r=e.queries.get(t);if(r)for(let e of r.ba)e.onError(n);e.queries.delete(t)}function oN(e){e.Ca.forEach(e=>{e.next()})}(m=f||(f={})).Ma="default",m.Cache="cache";class ok{constructor(e,t,n){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=n||{}}Fa(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)3!==n.type&&t.push(n);e=new oT(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){return!(e.fromCache&&this.Da())||(!this.options.Ka||"Offline"===t)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Ba(e){if(e.docChanges.length>0)return!0;let t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ka(e){e=oT.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==f.Cache}}class oR{constructor(e,t){this.qa=e,this.byteLength=t}Ua(){return"metadata"in this.qa}}class oM{constructor(e){this.serializer=e}Ks(e){return iC(this.serializer,e)}qs(e){return e.metadata.exists?iM(this.serializer,e.document,!1):nP.newNoDocument(this.Ks(e.metadata.name),this.Us(e.metadata.readTime))}Us(e){return iT(e)}}class oO{constructor(e,t){this.$a=e,this.serializer=t,this.Wa=[],this.Qa=[],this.collectionGroups=new Set,this.progress=oP(e)}get queries(){return this.Wa}get documents(){return this.Qa}Ga(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.qa.namedQuery)this.Wa.push(e.qa.namedQuery);else if(e.qa.documentMetadata){this.Qa.push({metadata:e.qa.documentMetadata}),e.qa.documentMetadata.exists||++t;let n=er.fromString(e.qa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.qa.document&&(this.Qa[this.Qa.length-1].document=e.qa.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,{...this.progress}):null}za(e){let t=new Map,n=new oM(this.serializer);for(let r of e)if(r.metadata.queries){let e=n.Ks(r.metadata.name);for(let n of r.metadata.queries){let r=(t.get(n)||rE()).add(e);t.set(n,r)}}return t}async ja(e){let t=await ag(e,new oM(this.serializer),this.Qa,this.$a.id),n=this.za(this.documents);for(let t of this.Wa)await ap(e,t,n.get(t.name));return this.progress.taskState="Success",{progress:this.progress,Ha:this.collectionGroups,Ja:t}}}function oP(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class oF{constructor(e){this.key=e}}class oL{constructor(e){this.key=e}}class oV{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=rE(),this.mutatedKeys=rE(),this.eu=rg(e),this.tu=new ob(this.eu)}get nu(){return this.Za}ru(e,t){let n=t?t.iu:new oI,r=t?t.tu:this.tu,i=t?t.mutatedKeys:this.mutatedKeys,s=r,a=!1,o="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,l="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal((e,t)=>
7{let u=r.get(e),h=rf(this.query,t)?t:null,c=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations),f=!1;u&&h?u.data.isEqual(h.data)?c!==d&&(n.track({type:3,doc:h}),f=!0):this.su(u,h)||(n.track({type:2,doc:h}),f=!0,(o&&this.eu(h,o)>0||l&&0>this.eu(h,l))&&(a=!0)):!u&&h?(n.track({type:0,doc:h}),f=!0):u&&!h&&(n.track({type:1,doc:u}),f=!0,(o||l)&&(a=!0)),f&&(h?(s=s.add(h),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;){let e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{tu:s,iu:n,Ss:a,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;let s=e.iu.ya();s.sort((e,t)=>{var n,r;let i;return n=e.type,r=t.type,(i=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return O(20277,{Vt:e})}})(n)-i(r)||this.eu(e.doc,t.doc)}),this.ou(n),r=r??!1;let a=t&&!r?this._u():[],o=0===this.Ya.size&&this.current&&!r?1:0,l=o!==this.Xa;return(this.Xa=o,0!==s.length||l)?{snapshot:new oT(this.query,e.tu,i,s,e.mutatedKeys,0===o,l,!1,!!n&&n.resumeToken.approximateByteSize()>0),au:a}:{au:a}}va(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({tu:this.tu,iu:new oI,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach(e=>this.Za=this.Za.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Za=this.Za.delete(e)),this.current=e.current)}_u(){if(!this.current)return[];let e=this.Ya;this.Ya=rE(),this.tu.forEach(e=>{this.uu(e.key)&&(this.Ya=this.Ya.add(e.key))});let t=[];return e.forEach(e=>{this.Ya.has(e)||t.push(new oL(e))}),this.Ya.forEach(n=>{e.has(n)||t.push(new oF(n))}),t}cu(e){this.Za=e.ks,this.Ya=rE();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return oT.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,0===this.Xa,this.hasCachedResults)}}let oq="SyncEngine";class oU{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class oB{constructor(e){this.key=e,this.hu=!1}}class oj{constructor(e,t,n,r,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.Pu={},this.Tu=new rp(e=>rc(e),rh),this.Iu=new Map,this.Eu=new Set,this.Ru=new tW(ea.comparator),this.Au=new Map,this.Vu=new sH,this.du={},this.mu=new Map,this.fu=sC.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return!0===this.gu}}async function oz(e,t,n=!0){let r,i=lh(e),s=i.Tu.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),r=s.view.lu()):r=await oK(i,t,n,!0),r}async function oG(e,t){let n=lh(e);await oK(n,t,!0,!1)}async function oK(e,t,n,r){let i,s=await au(e.localStore,rs(t)),a=s.targetId,o=e.sharedCl
7ientState.addLocalQueryTarget(a,n);return r&&(i=await o$(e,t,a,"current"===o,s.resumeToken)),e.isPrimaryClient&&n&&a3(e.remoteStore,s),i}async function o$(e,t,n,r,i){e.pu=(t,n,r)=>(async function(e,t,n,r){let i=t.view.ru(n);i.Ss&&(i=await ac(e.localStore,t.query,!1).then(({documents:e})=>t.view.ru(e,i)));let s=r&&r.targetChanges.get(t.targetId),a=r&&null!=r.targetMismatches.get(t.targetId),o=t.view.applyChanges(i,e.isPrimaryClient,s,a);return o6(e,t.targetId,o.au),o.snapshot})(e,t,n,r);let s=await ac(e.localStore,t,!0),a=new oV(t,s.ks),o=a.ru(s.documents),l=ia.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),u=a.applyChanges(o,e.isPrimaryClient,l);o6(e,n,u.au);let h=new oU(t,n,a);return e.Tu.set(t,h),e.Iu.has(n)?e.Iu.get(n).push(t):e.Iu.set(n,[t]),u.snapshot}async function oQ(e,t,n){let r=e.Tu.get(t),i=e.Iu.get(r.targetId);i.length>1?(e.Iu.set(r.targetId,i.filter(e=>!rh(e,t))),e.Tu.delete(t)):e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(r.targetId),e.sharedClientState.isActiveQueryTarget(r.targetId)||await ah(e.localStore,r.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(r.targetId),n&&a4(e.remoteStore,r.targetId),o3(e,r.targetId)}).catch(ek)):(o3(e,r.targetId),await ah(e.localStore,r.targetId,!0))}async function oH(e,t){let n=e.Tu.get(t),r=e.Iu.get(n.targetId);e.isPrimaryClient&&1===r.length&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),a4(e.remoteStore,n.targetId))}async function oW(e,t,n){let r=lc(e);try{var i,s;let e,a,o,l,u,h=await (i=r.localStore,o=ey.now(),l=t.reduce((e,t)=>e.add(t.key),rE()),i.persistence.runTransaction("Locally write mutations","readwrite",n=>{let r=ry,s=rE();return i.xs.getEntries(n,l).next(e=>{(r=e).forEach((e,t)=>{t.isValidDocument()||(s=s.add(e))})}).next(()=>i.localDocuments.getOverlayedDocuments(n,r)).next(r=>{e=r;let s=[];for(let n of t){let t=function(e,t){let n=null;for(let r of e.fieldTransforms){let e=t.data.field(r.field),i=rN(r.transform,e||null);null!=i&&(null===n&&(n=nO.empty()),n.set(r.field,i))}return n||null}(n,e.get(n.key).overlayedDocument);null!=t&&s.push(new rH(n.key,t,function e(t){let n=[];return t$(t.fields,(t,r)=>{let i=new es([t]);if(nC(r)){let t=e(r.mapValue).fields;if(0===t.length)n.push(i);else for(let e of t)n.push(i.child(e))}else n.push(i)}),new t1(n)}(t.value.mapValue),rB.exists(!0)))}
7return i.mutationQueue.addMutationBatch(n,o,s,t)}).next(t=>{a=t;let r=t.applyToLocalDocumentSet(e,s);return i.documentOverlayCache.saveOverlays(n,t.batchId,r)})}).then(()=>({batchId:a.batchId,changes:rb(e)})));r.sharedClientState.addPendingMutation(h.batchId),s=h.batchId,(u=r.du[r.currentUser.toKey()])||(u=new tW(Y)),u=u.insert(s,n),r.du[r.currentUser.toKey()]=u,await o7(r,h.changes),await oo(r.remoteStore)}catch(t){let e=ov(t,"Failed to persist write");n.reject(e)}}async function oJ(e,t){var n;try{let r,i,s=await (n=e.localStore,r=t.snapshotVersion,i=n.vs,n.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{let s=n.xs.newChangeBuffer({trackRemovals:!0});i=n.vs;let a=[];t.targetChanges.forEach((s,o)=>{var l;let u=i.get(o);if(!u)return;a.push(n.li.removeMatchingKeys(e,s.removedDocuments,o).next(()=>n.li.addMatchingKeys(e,s.addedDocuments,o)));let h=u.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(o)?h=h.withResumeToken(t3.EMPTY_BYTE_STRING,ew.min()).withLastLimboFreeSnapshotVersion(ew.min()):s.resumeToken.approximateByteSize()>0&&(h=h.withResumeToken(s.resumeToken,r)),i=i.insert(o,h),l=h,(0===u.resumeToken.approximateByteSize()||l.snapshotVersion.toMicroseconds()-u.snapshotVersion.toMicroseconds()>=3e8||s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size>0)&&a.push(n.li.updateTargetData(e,h))});let o=ry,l=rE();if(t.documentUpdates.forEach(r=>{t.resolvedLimboDocuments.has(r)&&a.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))}),a.push(al(e,s,t.documentUpdates).next(e=>{o=e.Bs,l=e.Ls})),!r.isEqual(ew.min())){let t=n.li.getLastRemoteSnapshotVersion(e).next(t=>n.li.setTargetsMetadata(e,e.currentSequenceNumber,r));a.push(t)}return eR.waitFor(a).next(()=>s.apply(e)).next(()=>n.localDocuments.getLocalViewOfDocuments(e,o,l)).next(()=>o)}).then(e=>(n.vs=i,e)));
7t.targetChanges.forEach((t,n)=>{let r=e.Au.get(n);r&&(F(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?r.hu=!0:t.modifiedDocuments.size>0?F(r.hu,14607):t.removedDocuments.size>0&&(F(r.hu,42227),r.hu=!1))}),await o7(e,s,t)}catch(e){await ek(e)}}function oY(e,t,n){var r;if(e.isPrimaryClient&&0===n||!e.isPrimaryClient&&1===n){let n,i=[];e.Tu.forEach((e,n)=>{let r=n.view.va(t);r.snapshot&&i.push(r.snapshot)}),(r=e.eventManager).onlineState=t,n=!1,r.queries.forEach((e,r)=>{for(let e of r.ba)e.va(t)&&(n=!0)}),n&&oN(r),i.length&&e.Pu.J_(i),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function oX(e,t,n){e.sharedClientState.updateQueryState(t,"rejected",n);let r=e.Au.get(t),i=r&&r.key;if(i){let n=new tW(ea.comparator);n=n.insert(i,nP.newNoDocument(i,ew.min()));let r=rE().add(i),s=new is(ew.min(),new Map,new tW(Y),n,r);await oJ(e,s),e.Ru=e.Ru.remove(i),e.Au.delete(t),o8(e)}else await ah(e.localStore,t,!1).then(()=>o3(e,t,n)).catch(ek)}async function oZ(e,t){var n;let r=t.batch.batchId;try{let i=await (n=e.localStore,n.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let r,i,s,a=t.batch.keys(),o=n.xs.newChangeBuffer({trackRemovals:!0});return(i=(r=t.batch).keys(),s=eR.resolve(),i.forEach(n=>{s=s.next(()=>o.getEntry(e,n)).next(e=>{let i=t.docVersions.get(n);F(null!==i,48541),0>e.version.compareTo(i)&&(r.applyToRemoteDocument(e,t),e.isValidDocument()&&(e.setReadTime(t.commitVersion),o.addEntry(e)))})}),s.next(()=>n.mutationQueue.removeMutationBatch(e,r))).next(()=>o.apply(e)).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,a,t.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=rE();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t))).next(()=>n.localDocuments.getDocuments(e,a))}));o5(e,r,null),o2(e,r),e.sharedClientState.updateMutationState(r,"acknowledged"),await o7(e,i)}catch(e){await ek(e)}}async function o0(e,t,n){var r;try{let i=await (r=e.localStore,r.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let n;return r.mutationQueue.lookupMutationBatch(e,t).next(t=>(F(null!==t,37113),n=t.keys(),r.mutationQueue.removeMutationBatch(e,t))).next(()=>r.mutationQueue.performConsistencyCheck(e)).next(()=>r.documentOverlayCache.removeOverlaysForBatchId(e,n,t)).next(()=>r.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,n)).next(()=>r.localDocuments.getDocuments(e,n))}));o5(e,t,n),o2(e,t),e.sharedClientState.updateMutationState(t,"rejected",n),await o7(e,i)}catch(e){await ek(e)}}async function o1(e,t){var n;oe(e.remoteStore)||N(oq,"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{let r=await (n=e.localStore).persistence.runTransaction("Get highest unacknowledged batch id","readonly",e=>n.mutationQueue.getHighestUnacknowledgedBatchId(e));if(-1===r)return void t.resolve();let i=e.mu.get(r)||[];i.push(t),e.mu.set(r,i)}catch(n){let e=ov(n,"Initialization of waitForPendingWrites() operation failed");t.reject(e)}}function o2(e,t){(e.mu.get(t)||[]).forEach(e=>{e.resolve()}),e.mu.delete(t)}function o5(e,t,n){let r=e.du[e.currentUser.toKey()];if(r){let i=r.get(t);i&&(n?i.reject(n):i.resolve(),r=r.remove(t)),e.du[e.currentUser.toKey()]=r}}function o3(e,t,n=null){for(let r of(e.sharedClientState.removeLocalQueryTarget(t),e.Iu.get(t)))e.Tu.delete(r),n&&e.Pu.yu(r,n);e.Iu.delete(t),e.isPrimaryClient&&e.Vu.Gr(t).forEach(t=>{e.Vu.containsKey(t)||o4(e,t)})}function o4(e,t){e.Eu.delete(t.path.canonicalString());let n=e.Ru.get(t);null!==n&&(a4(e.remoteStore,n),e.Ru=e.Ru.remove(t),e.Au.delete(n),o8(e))}function o6(e,t,n){for(let r of n)r instanceof oF?(e.Vu.addReference(r.key,t),function(e,t){let n=t.key,r=n.path.canonicalString();e.Ru.get(n)||e.Eu.has(r)||(N(oq,"New document in limbo: "+n),e.Eu.add(r),o8(e))}(e,r)):r instanceof oL?(N(oq,"Document no longer in limbo: "+r.key),e.Vu.removeReference(r.key,t),e.Vu.containsKey(r.key)||o4(e,r.key)):O(19791,{wu:r})}function o8(e){for(;e.Eu.size>0&&e.Ru.size<e.maxConcurrentLimboResolutions;){let t=e.Eu.values().next().value;e.Eu.delete(t);let n=new ea(er.fromString(t)),r=e.fu.next();e.Au.set(r,new oB(n)),e.Ru=e.Ru.insert(n,r),a3(e.remoteStore,new iG(rs(rt(n.path)),r,"TargetPurposeLimboResolution",eQ.ce))}}async function o7(e,t,n){let r=[],i=[],s=[];e.Tu.isEmpty()||(e.Tu.forEach((a,o)=>{s.push(e.pu(o,t,n).then(t=>{if((t||n)&&e.isPrimaryClient){let r=t?!t.fromCache:n?.targetChanges.get(o.targetId)?.current;
7e.sharedClientState.updateQueryState(o.targetId,r?"current":"not-current")}if(t){r.push(t);let e=at.Es(o.targetId,t);i.push(e)}}))}),await Promise.all(s),e.Pu.J_(r),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",n=>eR.forEach(t,t=>eR.forEach(t.Ts,r=>e.persistence.referenceDelegate.addReference(n,t.targetId,r)).next(()=>eR.forEach(t.Is,r=>e.persistence.referenceDelegate.removeReference(n,t.targetId,r)))))}catch(e){if(!eq(e))throw e;N(ai,"Failed to update sequence numbers: "+e)}for(let n of t){let t=n.targetId;if(!n.fromCache){let n=e.vs.get(t),r=n.snapshotVersion,i=n.withLastLimboFreeSnapshotVersion(r);e.vs=e.vs.insert(t,i)}}}(e.localStore,i))}async function o9(e,t){if(!e.currentUser.isEqual(t)){N(oq,"User change. New user:",t.toKey());let n=await aa(e.localStore,t);e.currentUser=t,e.mu.forEach(e=>{e.forEach(e=>{e.reject(new q(V.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.mu.clear(),e.sharedClientState.handleUserChange(t,n.removedBatchIds,n.addedBatchIds),await o7(e,n.Ns)}}function le(e,t){let n=e.Au.get(t);if(n&&n.hu)return rE().add(n.key);{let n=rE(),r=e.Iu.get(t);if(!r)return n;for(let t of r){let r=e.Tu.get(t);n=n.unionWith(r.view.nu)}return n}}async function lt(e,t){let n=await ac(e.localStore,t.query,!0),r=t.view.cu(n);return e.isPrimaryClient&&o6(e,t.targetId,r.au),r}async function ln(e,t){return af(e.localStore,t).then(t=>o7(e,t))}async function lr(e,t,n,r){var i,s;let a,o=await (i=e.localStore,a=i.mutationQueue,i.persistence.runTransaction("Lookup mutation documents","readonly",e=>a.Xn(e,t).next(t=>t?i.localDocuments.getDocuments(e,t):eR.resolve(null))));null!==o?("pending"===n?await oo(e.remoteStore):"acknowledged"===n||"rejected"===n?(o5(e,t,r||null),o2(e,t),s=e.localStore,s.mutationQueue.nr(t)):O(6
7720,"Unknown batchState",{bu:n}),await o7(e,o)):N(oq,"Cannot apply mutation batch with id: "+t)}async function li(e,t){if(lh(e),lc(e),!0===t&&!0!==e.gu){let t=e.sharedClientState.getAllActiveQueryTargets(),n=await ls(e,t.toArray());for(let t of(e.gu=!0,await og(e.remoteStore,!0),n))a3(e.remoteStore,t)}else if(!1===t&&!1!==e.gu){let t=[],n=Promise.resolve();e.Iu.forEach((r,i)=>{e.sharedClientState.isLocalQueryTarget(i)?t.push(i):n=n.then(()=>(o3(e,i),ah(e.localStore,i,!0))),a4(e.remoteStore,i)}),await n,await ls(e,t),e.Au.forEach((t,n)=>{a4(e.remoteStore,n)}),e.Vu.zr(),e.Au=new Map,e.Ru=new tW(ea.comparator),e.gu=!1,await og(e.remoteStore,!1)}}async function ls(e,t,n){let r=[],i=[];for(let n of t){let t,s=e.Iu.get(n);if(s&&0!==s.length)for(let n of(t=await au(e.localStore,rs(s[0])),s)){let t=e.Tu.get(n),r=await lt(e,t);r.snapshot&&i.push(r.snapshot)}else{let r=await ad(e.localStore,n);t=await au(e.localStore,r),await o$(e,la(r),n,!1,t.resumeToken)}r.push(t)}return e.Pu.J_(i),r}function la(e){var t,n,r,i,s;return t=e.path,n=e.collectionGroup,r=e.orderBy,i=e.filters,s=e.limit,new re(t,n,r,i,s,"F",e.startAt,e.endAt)}function lo(e){return e.localStore.persistence.hs()}async function ll(e,t,n,r){if(e.gu)return void N(oq,"Ignoring unexpected query state notification.");let i=e.Iu.get(t);if(i&&i.length>0)switch(n){case"current":case"not-current":{let r=await af(e.localStore,rm(i[0])),s=is.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,t3.EMPTY_BYTE_STRING);await o7(e,r,s);break}case"rejected":await ah(e.localStore,t,!0),o3(e,t,r);break;default:O(64155,n)}}async function lu(e,t,n){let r=lh(e);if(r.gu){for(let e of t){if(r.Iu.has(e)&&r.sharedClientState.isActiveQueryTarget(e)){N(oq,"Adding an already active target "+e);continue}let t=await ad(r.localStore,e),n=await au(r.localStore,t);await o$(r,la(t),n.targetId,!1,n.resumeToken),a3(r.remoteStore,n)}for(let e of n)r.Iu.has(e)&&await ah(r.localStore,e,!1).then(()=>{a4(r.remoteStore,e),o3(r,e)}).catch(ek)}}function lh(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=oJ.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=le.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=oX.bind(null,e),e.Pu.J_=oA.bind(null,e.eventManager),e.Pu.yu=oD.bind(null,e.eventManager),e}function lc(e){return e.remoteStore.remoteSyncer.applySuccessfulWrite=oZ.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=o0.bind(null,e),e}class ld{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=aK(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){var t,n;return t=this.persistence,n=new ar,new as(t,n,e.initialUser,this.serializer)}Cu(e){return new s0(s2.Vi,this.serializer)}Du(e){return new aN}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}ld.provider={build:()=>new ld};class lf extends ld{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){return F(this.persistence.referenceDelegate instanceof s5,46915),new sM(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Cu(e){let t=void 0!==this.cacheSizeBytes?sI.withCacheSize(this.cacheSizeBytes):sI.DEFAULT;return new s0(e=>s5.Vi(e,t),this.serializer)}}class lm extends ld{constructor(e,t,n){super(),this.xu=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.kind="persistent",this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.xu.initialize(this,e),await lc(this.xu.syncEngine),await oo(this.xu.remoteStore),await this.persistence.zi(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}vu(e){var t,n;return t=this.persistence,n=new ar,new as(t,n,e.initialUser,this.serializer)}Fu(e,t){return new sM(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Mu(e,t){let n=new e$(t,this.persistence);return new eK(e.asyncQueue,n)}Cu(e){let t=ae(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?sI.withCacheSize(this.cacheSizeBytes):sI.DEFAULT;return new s9(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,az(),aG(),this.serializer,this.sharedCl
7ientState,!!this.forceOwnership)}Du(e){return new aN}}class lg extends lm{constructor(e,t){super(e,t,!1),this.xu=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);let t=this.xu.syncEngine;this.sharedClientState instanceof aD&&(this.sharedClientState.syncEngine={So:lr.bind(null,t),Do:ll.bind(null,t),Co:lu.bind(null,t),hs:lo.bind(null,t),bo:ln.bind(null,t)},await this.sharedClientState.start()),await this.persistence.zi(async e=>{await li(this.xu.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())})}Du(e){let t=az();if(!aD.v(t))throw new q(V.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");let n=ae(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new aD(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class lp{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>oY(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=o9.bind(null,this.syncEngine),await og(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new oE}createDatastore(e){var t;let n=aK(e.databaseInfo.databaseId),r=new aj(e.databaseInfo);return t=e.authCredentials,new aX(t,e.appCheckCredentials,r,n)}createRemoteStore(e){var t,n;return t=this.localStore,n=this.datastore,new a1(t,n,e.asyncQueue,e=>oY(this.syncEngine,e,0),aM.v()?new aM:new ak)}createSyncEngine(e,t){var n,r,i,s,a,o;let l;return n=this.localStore,r=this.remoteStore,i=this.eventManager,s=this.sharedClientState,a=e.initialUser,o=e.maxConcurrentLimboResolutions,l=new oj(n,r,i,s,a,o),t&&(l.gu=!0),l}async terminate(){await async function(e){N(a0,"RemoteStore shutting down."),e.Ea.add(5),await a5(e),e.Aa.shutdown(),e.Va.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}function ly(e,t=10240){let n=0;return{async read(){if(n<e.byteLength){let r={value:e.slice(n,n+t),done:!1};return n+=t,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}lp.provider={build:()=>new lp};class lw{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):k("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class lv{constructor(e,t){this.Bu=e,this.serializer=t,this.metadata=new U,this.buffer=new Uint8Array,this.Lu=new TextDecoder("utf-8"),this.ku().then(e=>{e&&e.Ua()?this.metadata.resolve(e.qa.metadata):this.metadata.reject(Error(`The first element of the bundle is not a metadata, it is
8             ${JSON.stringify(e?.qa)}`))},e=>this.metadata.reject(e))}close(){return this.Bu.cancel()}async getMetadata(){return this.metadata.promise}async Su(){return await this.getMetadata(),this.ku()}async ku(){let e=await this.Ku();if(null===e)return null;let t=this.Lu.decode(e),n=Number(t);return isNaN(n)&&this.qu(`length string (${t}) is not valid number`),new oR(JSON.parse(await this.Uu(n)),e.length+n)}$u(){return this.buffer.findIndex(e=>123===e)}async Ku(){for(;0>this.$u()&&!await this.Wu(););if(0===this.buffer.length)return null;let e=this.$u();e<0&&this.qu("Reached the end of bundle when a length string is expected.");let t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async Uu(e){for(;this.buffer.length<e;)await this.Wu()&&this.qu("Reached the end of bundle when more is expected.");let t=this.Lu.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}qu(e){throw this.Bu.cancel(),Error(`Invalid bundle format: ${e}`)}async Wu(){let e=await this.Bu.read();if(!e.done){let t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}}
8class lb{constructor(e,t){this.bundleData=e,this.serializer=t,this.cursor=0,this.elements=[];let n=this.Su();if(!n||!n.Ua())throw Error(`The first element of the bundle is not a metadata object, it is
9         ${JSON.stringify(n?.qa)}`);this.metadata=n;do null!==(n=this.Su())&&this.elements.push(n);while(null!==n)}getMetadata(){return this.metadata}Qu(){return this.elements}Su(){if(this.cursor===this.bundleData.length)return null;let e=this.Ku();return new oR(JSON.parse(this.Uu(e)),e)}Uu(e){if(this.cursor+e>this.bundleData.length)throw new q(V.INTERNAL,"Reached the end of bundle when more is expected.");return this.bundleData.slice(this.cursor,this.cursor+=e)}Ku(){let e=this.cursor,t=this.cursor;for(;t<this.bundleData.length;){if("{"===this.bundleData[t]){if(t===e)throw Error("First character is a bracket and not a number");return this.cursor=t,Number(this.bundleData.slice(e,t))}t++}throw Error("Reached the end of bundle when more is expected.")}}class lI{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new q(V.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;let t=await async function(e,t){let n={documents:t.map(t=>ix(e.serializer,t))},r=await e.jo("BatchGetDocuments",e.serializer.databaseId,er.emptyPath(),n,t.length),i=new Map;r.forEach(t=>{var n;let r,s,a,o,l,u,h=(n=e.serializer,"found"in t?(F(!!t.found,43571),t.found.name,t.found.updateTime,r=iC(n,t.found.name),s=iT(t.found.updateTime),a=t.found.createTime?iT(t.found.createTime):ew.min(),o=new nO({mapValue:{fields:t.found.fields}}),nP.newFoundDocument(r,s,a,o)):"missing"in t?(F(!!t.missing,3894),F(!!t.readTime,22933),l=iC(n,t.missing),u=iT(t.readTime),nP.newNoDocument(l,u)):O(7234,{result:t}));i.set(h.key.toString(),h)});let s=[];return t.forEach(e=>{let t=i.get(e.toString());F(!!t,55234,{key:e}),s.push(t)}),s}(this.datastore,e);return t.forEach(e=>this.recordVersion(e)),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new rX(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;let e=this.readVersions;this.mutations.forEach(t=>{e.delete(t.key.toString())}),e.forEach((e,t)=>{let n=ea.fromPath(t);this.mutations.push(new rZ(n,this.precondition(n)))}),await async function(e,t){let n={writes:t.map(t=>iO(e.serializer,t))};await e.Wo("Commit",e.serializer.databaseId,er.emptyPath(),n)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw O(50498,{Gu:e.constructor.name});t=ew.min()}let n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new q(V.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){let t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(ew.min())?rB.exists(!1):rB.updateTime(t):rB.none()}preconditionForUpdate(e){let t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(ew.min()))throw new q(V.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return rB.updateTime(t)}return rB.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class lT{constructor(e,t,n,r,i){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=r,this.deferred=i,this.zu=n.maxAttempts,this.M_=new a$(this.asyncQueue,"transaction_retry")}ju(){this.zu-=1,this.Hu()}Hu(){this.M_.p_(async()=>{let e=new lI(this.datastore),t=this.Ju(e);t&&t.then(t=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(t)}).catch(e=>{this.Zu(e)}))}).catch(e=>{this.Zu(e)})})}Ju(e){try{let t=this.updateFunction(e);return!eH(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}Zu(e){this.zu>0&&this.Xu(e)?(this.zu-=1,this.asyncQueue.enqueueAndForget(()=>(this.Hu(),Promise.resolve()))):this.deferred.reject(e)}Xu(e){if("FirebaseError"===e?.name){let t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!r4(t)}return!1}}let l_="FirestoreClient";class lE{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=S.UNAUTHENTICATED,this.clientId=J.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,async e=>{N(l_,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,e=>(N(l_,"Received new app check token=",e),this.appCheckCredentialListener(e,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new U;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}
9catch(n){let t=ov(n,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function lS(e,t){e.asyncQueue.verifyOperationInProgress(),N(l_,"Initializing OfflineComponentProvider");let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await aa(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function lx(e,t){e.asyncQueue.verifyOperationInProgress();let n=await lC(e);N(l_,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener(e=>om(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,n)=>om(t.remoteStore,n)),e._onlineComponents=t}async function lC(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){N(l_,"Using user provided OfflineComponentProvider");try{await lS(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===V.FAILED_PRECONDITION||t.code===V.UNIMPLEMENTED:!("u">typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;R("Error using user provided cache. Falling back to memory cache: "+t),await lS(e,new ld)}}else N(l_,"Using default OfflineComponentProvider"),await lS(e,new lf(void 0));return e._offlineComponents}async function lA(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(N(l_,"Using user provided OnlineComponentProvider"),await lx(e,e._uninitializedComponentsProvider._online)):(N(l_,"Using default OnlineComponentProvider"),await lx(e,new lp))),e._onlineComponents}function lD(e){return lC(e).then(e=>e.persistence)}function lN(e){return lC(e).then(e=>e.localStore)}function lk(e){return lA(e).then(e=>e.remoteStore)}function lR(e){return lA(e).then(e=>e.syncEngine)}function lM(e){return lA(e).then(e=>e.datastore)}async function lO(e){let t=await lA(e),n=t.eventManager;return n.onListen=oz.bind(null,t.syncEngine),n.onUnlisten=oQ.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=oG.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=oH.bind(null,t.syncEngine),n}function lP(e,t,n={}){let r=new U;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await lO(e),s=e.asyncQueue,a=new lw({next:e=>{a.Nu(),s.enqueueAndForget(()=>oC(i,o));let l=e.docs.has(t);!l&&e.fromCache?r.reject(new q(V.UNAVAILABLE,"Failed to get document because the client is offline.")):l&&e.fromCache&&n&&"server"===n.source?r.reject(new q(V.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):r.resolve(e)},error:e=>r.reject(e)}),ox(i,o=new ok(rt(t.path),a,{includeMetadataChanges:!0,Ka:!0}))}),r.promise}function lF(e,t,n={}){let r=new U;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await lO(e),s=e.asyncQueue,o=new ok(t,a=new lw({next:e=>{a.Nu(),s.enqueueAndForget(()=>oC(i,o)),e.fromCache&&"server"===n.source?r.reject(new q(V.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):r.resolve(e)},error:e=>r.reject(e)}),{includeMetadataChanges:!0,Ka:!0}),ox(i,o)}),r.promise}function lL(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}let lV=new Map,lq="firestore.googleapis.com";class lU{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new q(V.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=lq,this.ssl=!0}else this.host=e.host,this.ssl=e.ssl??!0;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new q(V.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}el("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=lL(e.experimentalLongPollingOptions??{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new q(V.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new q(V.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new q(V.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){var t,n;return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(t=this.experimentalLongPollingOptions,n=e.experimentalLongPollingOptions,t.timeoutSeconds===n.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class lB{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new lU({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new q(V.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"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new q(V.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 lU(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new j;switch(e.type){case"firstParty":return new $(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new q(V.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
9d credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){let e;return(e=lV.get(this))&&(N("ComponentProvider","Removing Datastore"),lV.delete(this),e.terminate()),Promise.resolve()}}function lj(e,t,n,r={}){e=ef(e,lB);let i=(0,v.isCloudWorkstation)(t),s=e._getSettings(),a={...s,emulatorOptions:e._getEmulatorOptions()},o=`${t}:${n}`;i&&((0,v.pingServer)(`https://${o}`),(0,v.updateEmulatorBanner)("Firestore",!0)),s.host!==lq&&s.host!==o&&R("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let l={...s,host:o,ssl:i,emulatorOptions:r};if(!(0,v.deepEqual)(l,a)&&(e._setSettings(l),r.mockUserToken)){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=S.MOCK_USER;else{t=(0,v.createMockUserToken)(r.mockUserToken,e._app?.options.projectId);let i=r.mockUserToken.sub||r.mockUserToken.user_id;if(!i)throw new q(V.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new S(i)}e._authCredentials=new z(new B(t,n))}}class lz{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new lz(this.firestore,e,this._query)}}class lG{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new lK(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new lG(this.firestore,e,this._key)}toJSON(){return{type:lG._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,n){if(ep(t,lG._jsonSchema))return new lG(e,n||null,new ea(er.fromString(t.referencePath)))}}lG._jsonSchemaVersion="firestore/documentReference/1.0",lG._jsonSchema={type:eg("string",lG._jsonSchemaVersion),referencePath:eg("string")};class lK extends lz{constructor(e,t,n){super(e,t,rt(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new lG(this.firestore,null,new ea(e))}withConverter(e){return new lK(this.firestore,e,this._path)}}function l$(e,t,...n){if(e=(0,v.getModularInstance)(e),eo("collection","path",t),e instanceof lB){let r=er.fromString(t,...n);return eh(r),new lK(e,null,r)}{if(!(e instanceof lG||e instanceof lK))throw new q(V.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=e._path.child(er.fromString(t,...n));return eh(r),new lK(e.firestore,null,r)}}function lQ(e,t){if(e=ef(e,lB),eo("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new q(V.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new lz(e,null,new re(er.emptyPath(),t))}function lH(e,t,...n){if(e=(0,v.getModularInstance)(e),1==arguments.length&&(t=J.newId()),eo("doc","path",t),e instanceof lB){let r=er.fromString(t,...n);return eu(r),new lG(e,null,new ea(r))}{if(!(e instanceof lG||e instanceof lK))throw new q(V.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=e._path.child(er.fromString(t,...n));return eu(r),new lG(e.firestore,e instanceof lK?e.converter:null,new ea(r))}}function lW(e,t){return e=(0,v.getModularInstance)(e),t=(0,v.getModularInstance)(t),(e instanceof lG||e instanceof lK)&&(t instanceof lG||t instanceof lK)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function lJ(e,t){return e=(0,v.getModularInstance)(e),t=(0,v.getModularInstance)(t),e instanceof lz&&t instanceof lz&&e.firestore===t.firestore&&rh(e._query,t._query)&&e.converter===t.converter}let lY="AsyncQueue";class lX{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new a$(this,"async_queue_retry"),this._c=()=>{let e=aG();e&&N(lY,"Visibility state changed to "+e.visibilityState),this.M_.w_()},this.ac=e;const t=aG();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;let t=aG();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise(()=>{});let t=new U;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Yu.push(e),this.lc()))}async lc(){if(0!==this.Yu.length){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!eq(e))throw e;N(lY,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_(()=>this.lc())}}cc(e){let t=this.ac.then(()=>(this.rc=!0,e().catch(e=>{throw this.nc=e,this.rc=!1,k("INTERNAL UNHANDLED ERROR: ",lZ(e)),e}).then(e=>(this.rc=!1,e))));return this.ac=t,t}enqueueAfterDelay(e,t,n){this.uc(),this.oc.indexOf(e)>-1&&(t=0);let r=ow.createAndSchedule(this,e,t,n,e=>this.hc(e));return this.tc.push(r),r}uc(){this.nc&&O(47125,{Pc:lZ(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(let t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then(()=>{for(let t of(this.tc.sort((e,t)=>
9e.targetTimeMs-t.targetTimeMs),this.tc))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Tc()})}Rc(e){this.oc.push(e)}hc(e){let t=this.tc.indexOf(e);this.tc.splice(t,1)}}function lZ(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class l0{constructor(){this._progressObserver={},this._taskCompletionResolver=new U,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,n){this._progressObserver={next:e,error:t,complete:n}}catch(e){return this._taskCompletionResolver.promise.catch(e)}then(e,t){return this._taskCompletionResolver.promise.then(e,t)}_completeWith(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}_failWith(e){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}_updateProgress(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}}class l1 extends lB{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new lX,this._persistenceKey=r?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new lX(e),this._firestoreClient=void 0,await e}}}function l2(e,t,n){n||(n=no);let r=(0,g._getProvider)(e,"firestore");if(r.isInitialized(n)){let e=r.getImmediate({identifier:n}),i=r.getOptions(n);if((0,v.deepEqual)(i,t))return e;throw new q(V.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&&void 0!==t.localCache)throw new q(V.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(void 0!==t.cacheSizeBytes&&-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new q(V.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return t.host&&(0,v.isCloudWorkstation)(t.host)&&(0,v.pingServer)(t.host),r.initialize({options:t,instanceIdentifier:n})}function l5(e,t){let n="object"==typeof e?e:(0,g.getApp)(),r="string"==typeof e?e:t||no,i=(0,g._getProvider)(n,"firestore").getImmediate({identifier:r});if(!i._initialized){let e=(0,v.getDefaultEmulatorHostnameAndPort)("firestore");e&&lj(i,...e)}return i}function l3(e){if(e._terminated)throw new q(V.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||l4(e),e._firestoreClient}function l4(e){var t,n,r,i,s;let a,o=e._freezeSettings(),l=(t=e._databaseId,n=e._app?.options.appId||"",r=e._persistenceKey,i=e._app?.options.apiKey,new na(t,n,r,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,lL(o.experimentalLongPollingOptions),o.useFetchStreams,o.isUsingEmulator,i));e._componentsProvider||o.localCache?._offlineComponentProvider&&o.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:o.localCache._offlineComponentProvider,_online:o.localCache._onlineComponentProvider}),e._firestoreClient=new lE(e._authCredentials,e._appCheckCredentials,e._queue,l,e._componentsProvider&&(s=e._componentsProvider,a=s?._online.build(),{_offline:s?._offline.build(a),_online:a}))}function l6(e,t){R("enableIndexedDbPersistence() will be deprecated 
9in the future, you can use `FirestoreSettings.cache` instead.");let n=e._freezeSettings();return l7(e,lp.provider,{build:e=>new lm(e,n.cacheSizeBytes,t?.forceOwnership)}),Promise.resolve()}async function l8(e){R("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");let t=e._freezeSettings();l7(e,lp.provider,{build:e=>new lg(e,t.cacheSizeBytes)})}function l7(e,t,n){if((e=ef(e,l1))._firestoreClient||e._terminated)throw new q(V.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.");if(e._componentsProvider||e._getSettings().localCache)throw new q(V.FAILED_PRECONDITION,"SDK cache is already specified.");e._componentsProvider={_online:t,_offline:n},l4(e)}function l9(e){if(e._initialized&&!e._terminated)throw new q(V.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");let t=new U;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!eP.v())return Promise.resolve();await eP.delete(e+s7)}(ae(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise}function ue(e){var t;let n;return t=l3(e=ef(e,l1)),n=new U,t.asyncQueue.enqueueAndForget(async()=>o1(await lR(t),n)),n.promise}function ut(e){var t;return(t=l3(e=ef(e,l1))).asyncQueue.enqueue(async()=>{let e=await lD(t),n=await lk(t);return e.setNetworkEnabled(!0),n.Ea.delete(0),a2(n)})}function un(e){var t;return(t=l3(e=ef(e,l1))).asyncQueue.enqueue(async()=>{let e=await lD(t),n=await lk(t);return e.setNetworkEnabled(!1),async function(e){e.Ea.add(0),await a5(e),e.Va.set("Offline")}(n)})}function ur(e){return(0,g._removeServiceInstance)(e.app,"firestore",e._databaseId.database),e._delete()}function ui(e,t){let n=l3(e=ef(e,l1)),r=new l0;return function(e,t,n,r){var i;let s=(i=aK(t),new lv(function(e,t){if(e instanceof Uint8Array)return ly(e,void 0);if(e instanceof ArrayBuffer)return ly(new Uint8Array(e),void 0);if(e instanceof ReadableStream)return e.getReader();throw Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}("string"==typeof n?r7().encode(n):n),i));e.asyncQueue.enqueueAndForget(async()=>{var t;(async function(e,t,n){try{var r,i;let s,a=await t.getMetadata();if(await (r=e.localStore,s=iT(a.createTime),r.persistence.runTransaction("hasNewerBundle","readonly",e=>r.Pi.getBundleMetadata(e,a.id)).then(e=>!!e&&e.createTime.compareTo(s)>=0)))return await t.close(),n._completeWith({taskState:"Success",documentsLoaded:a.totalDocuments,bytesLoaded:a.totalBytes,totalDocuments:a.totalDocuments,totalBytes:a.totalBytes}),Promise.resolve(new Set);n._updateProgress(oP(a));let o=new oO(a,t.serializer),l=await t.Su();for(;l;){let e=await o.Ga(l);e&&n._updateProgress(e),l=await t.Su()}let u=await o.ja(e.localStore);return await o7(e,u.Ja,void 0),await (i=e.localStore,i.persistence.runTransaction("Save bundle","readwrite",e=>i.Pi.saveBundleMetadata(e,a))),n._completeWith(u.progress),Promise.resolve(u.Ha)}catch(e){return R(oq,`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(t=await lR(e),s,r).then(e=>{t.sharedClientState.notifyBundleLoaded(e)})})}(n,e._databaseId,t,r),r}function us(e,t){var n;return(n=l3(e=ef(e,l1)),n.asyncQueue.enqueue(async()=>{var e;return e=await lN(n),e.persistence.runTransaction("Get named query","readonly",n=>e.Pi.getNamedQuery(n,t))})).then(t=>t?new lz(e,null,t.query):null)}class ua{constructor(e){this._byteString=e}static fromBase64String(e){try{return new ua(t3.fromBase64String(e))}catch(e){throw new q(V.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new ua(t3.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:ua._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(ep(e,ua._jsonSchema))return ua.fromBase64String(e.bytes)}}
9ua._jsonSchemaVersion="firestore/bytes/1.0",ua._jsonSchema={type:eg("string",ua._jsonSchemaVersion),bytes:eg("string")};class uo{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new q(V.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new es(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function ul(){return new uo(et)}class uu{constructor(e){this._methodName=e}}class uh{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new q(V.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new q(V.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return Y(this._lat,e._lat)||Y(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:uh._jsonSchemaVersion}}static fromJSON(e){if(ep(e,uh._jsonSchema))return new uh(e.latitude,e.longitude)}}uh._jsonSchemaVersion="firestore/geoPoint/1.0",uh._jsonSchema={type:eg("string",uh._jsonSchemaVersion),latitude:eg("number"),longitude:eg("number")};class uc{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}toJSON(){return{type:uc._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(ep(e,uc._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new uc(e.vectorValues);throw new q(V.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}uc._jsonSchemaVersion="firestore/vectorValue/1.0",uc._jsonSchema={type:eg("string",uc._jsonSchemaVersion),vectorValues:eg("object")};let ud=/^__.*__$/;class uf{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new rH(e,this.data,this.fieldMask,t,this.fieldTransforms):new rQ(e,this.data,t,this.fieldTransforms)}}class um{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new rH(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function ug(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw O(40011,{dataSource:e})}}class up{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new up({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){let t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePathSegment(e),n}childContextForFieldPath(e){let t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePath(),n}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return uF(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(0===e.length)throw this.createError("Document fields must not be empty");if(ug(this.dataSource)&&ud.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class uy{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||aK(e)}createContext(e,t,n,r=!1){return new up({dataSource:e,methodName:t,targetDoc:n,path:es.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function uw(e){let t=e._freezeSettings(),n=aK(e._databaseId);return new uy(e._databaseId,!!t.ignoreUndefinedProperties,n)}function uv(e,t,n,r,i,s={}){let a,o,l=e.createContext(s.merge||s.mergeFields?2:0,t,n,i);uR("Data must be an object, but it was:",l,r);let u=uN(r,l);if(s.merge)a=new t1(l.fieldMask),o=l.fieldTransforms;else if(s.mergeFields){let e=[];for(let r of s.mergeFields){let i=uM(t,r,n);if(!l.contains(i))throw new q(V.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);uL(e,i)||e.push(i)}a=new t1(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new uf(new nO(u),a,o)}class ub extends uu{_toFieldTransform(e){if(2!==e.dataSource)throw 1===e.dataSource?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof ub}}function uI(e,t,n){return new up({dataSource:3,targetDoc:t.settings.targetDoc,methodName:e._methodName,arrayElement:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class uT extends uu{_toFieldTransform(e){return new rq(e.path,new rk)}isEqual(e){return e instanceof uT}}class u_ extends uu{constructor(e,t){super(e),this.Ac=t}_toFieldTransform(e){let t=uI(this,e,!0),n=new rR(this.Ac.map(e=>uD(e,t)));return new rq(e.path,n)}isEqual(e){return e instanceof u_&&(0,v.deepEqual)(this.Ac,e.Ac)}}class uE extends uu{constructor(e,t){super(e),this.Ac=t}_toFieldTransform(e){let t=uI(this,e,!0),n=new rO(this.Ac.map(e=>uD(e,t)));return new rq(e.path,n)}isEqual(e){return e instanceof uE&&(0,v.deepEqual)(this.Ac,e.Ac)}}class uS extends uu{constructor(e,t){super(e),this.Vc=t}_toFieldTransform(e){let t=new rF(e.serializer,rA(e.serializer,this.Vc));return new rq(e.path,t)}isEqual(e){return e instanceof uS&&this.Vc===e.Vc}}function ux(e,t,n,r){let i=e.createContext(1,t,n);uR("Data must be an object, but it was:",i,r);let s=[],a=nO.empty();return t$(r,(e,r)=>{let o=uP(t,e,n);r=(0,v.getModularInstance)(r);let l=i.childContextForFieldPath(o);if(r instanceof ub)s.push(o);else{let e=uD(r,l);null!=e&&(s.push(o),a.set(o,e))}}),new um(a,new t1(s),i.fieldTransforms)}function uC(e,t,n,r,i,s){let a=e.createContext(1,t,n),o=[uM(t,r,n)],l=[i];if(s.length%2!=0)throw new q(V.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)o.push(uM(t,s[e])),l.push(s[e+1]);let u=[],h=nO.empty();for(let e=o.length-1;e>=0;
9--e)if(!uL(u,o[e])){let t=o[e],n=l[e];n=(0,v.getModularInstance)(n);let r=a.childContextForFieldPath(t);if(n instanceof ub)u.push(t);else{let e=uD(n,r);null!=e&&(u.push(t),h.set(t,e))}}return new um(h,new t1(u),a.fieldTransforms)}function uA(e,t,n,r=!1){return uD(n,e.createContext(r?4:3,t))}function uD(e,t){if(uk(e=(0,v.getModularInstance)(e)))return uR("Unsupported field value:",t,e),uN(e,t);if(e instanceof uu)return function(e,t){if(!ug(t.dataSource))throw t.createError(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.createError(`${e._methodName}() is not currently supported inside arrays`);let n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&4!==t.dataSource)throw t.createError("Nested arrays are not supported");let n=[],r=0;for(let i of e){let e=uD(i,t.childContextForArray(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}return function(e,t){if(null===(e=(0,v.getModularInstance)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return rA(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){let n=ey.fromDate(e);return{timestampValue:ib(t.serializer,n)}}if(e instanceof ey){let n=new ey(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:ib(t.serializer,n)}}if(e instanceof uh)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof ua)return{bytesValue:iI(t.serializer,e._byteString)};if(e instanceof lG){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.createError(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:i_(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof uc){var n;return{mapValue:{fields:{[nu]:{stringValue:nd},[nf]:{arrayValue:{values:((n=e)instanceof uc?n.toArray():n).map(e=>{if("number"!=typeof e)throw t.createError("VectorValues must only contain numeric values.");return rx(t.serializer,e)})}}}}}}if(iz(e))return e._toProto(t.serializer);throw t.createError(`Unsupported field value: ${ed(e)}`)}(e,t)}function uN(e,t){let n={};return tH(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):t$(e,(e,r)=>{let i=uD(r,t.childContextForField(e));null!=i&&(n[e]=i)}),{mapValue:{fields:n}}}function uk(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof ey||e instanceof uh||e instanceof ua||e instanceof lG||e instanceof uu||e instanceof uc||iz(e))}function uR(e,t,n){if(!uk(n)||!ec(n)){let r=ed(n);throw"an object"===r?t.createError(e+" a custom object"):t.createError(e+" "+r)}}function uM(e,t,n){if((t=(0,v.getModularInstance)(t))instanceof uo)return t._internalPath;if("string"==typeof t)return uP(e,t);throw uF("Field path arguments must be of type string or ",e,!1,void 0,n)}let uO=RegExp("[~\\*/\\[\\]]");function uP(e,t,n){if(t.search(uO)>=0)throw uF(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new uo(...t.split("."))._internalPath}catch(r){throw uF(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function uF(e,t,n,r,i){let s=r&&!r.isEmpty(),a=void 0!==i,o=`Function ${t}() called with invalid data`;n&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(s||a)&&(l+=" (found",s&&(l+=` in field ${r}`),a&&(l+=` in document ${i}`),l+=")"),new q(V.INVALID_ARGUMENT,o+e+l)}function uL(e,t){return e.some(e=>e.isEqual(t))}class uV{convertValue(e,t="none"){switch(ng(e)){case 0:return null;case 1:return e.booleanValue;case 2:return t8(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(t7(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw O(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let n={};return t$(e,(e,r)=>{n[e]=this.convertValue(r,t)}),n}convertVectorValue(e){return new uc(e.fields?.[nf].arrayValue?.values?.map(e=>t8(e.doubleValue)))}convertGeoPoint(e){return new uh(t8(e.latitude),t8(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let n=ni(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(ns(e));default:return null}}convertTimestamp(e){let t=t6(e);return new ey(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=er.fromString(e);F(ij(n),9688,{name:e});let r=new nl(n.get(1),n.get(3)),i=new ea(n.popFirst(5));return r.isEqual(t)||k(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}class uq extends uV{constructor(e){super(),this.firestore=e}convertBytes(e){return new ua(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
9return new lG(this.firestore,null,t)}}function uU(){return new ub("deleteField")}function uB(){return new uT("serverTimestamp")}function uj(...e){return new u_("arrayUnion",e)}function uz(...e){return new uE("arrayRemove",e)}function uG(e){return new uS("increment",e)}function uK(e){return new uc(e)}function u$(e){let t=l3(ef(e.firestore,l1)),n=t._onlineComponents?.datastore.serializer;return void 0===n?null:iL(n,rs(e._query)).ft}function uQ(e,t){let n=tQ(t,(e,t)=>new r5(t,e.aggregateType,e._internalFieldPath)),r=l3(ef(e.firestore,l1)),i=r._onlineComponents?.datastore.serializer;return void 0===i?null:iV(i,ra(e._query),n,!0).request}let uH="@firebase/firestore",uW="4.12.0";function uJ(e){if("object"!=typeof e||null===e)return!1;for(let t of["next","error","complete"])if(t in e&&"function"==typeof e[t])return!0;return!1}class uY{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class uX{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new nO({mapValue:{fields:this._data}}).clone().value.mapValue.fields}}class uZ{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new lG(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let e=new u0(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){let t=this._document.data.field(uM("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class u0 extends uZ{data(){return super.data()}}function u1(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new q(V.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class u2{}class u5 extends u2{}function u3(e,t,...n){let r=[];for(let i of(t instanceof u2&&r.push(t),function(e){let t=e.filter(e=>e instanceof u8).length,n=e.filter(e=>e instanceof u4).length;if(t>1||t>0&&n>0)throw new q(V.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(...)))`.")}(r=r.concat(n)),r))e=i._apply(e);return e}class u4 extends u5{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new u4(e,t,n)}_apply(e){let t=this._parse(e);return hm(e._query,t),new lz(e.firestore,e.converter,rl(e._query,t))}_parse(e){let t=uw(e.firestore);return function(e,t,n,r,i,s,a){let o;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new q(V.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){hf(a,s);let t=[];for(let n of a)t.push(hd(r,e,n));o={arrayValue:{values:t}}}else o=hd(r,e,a)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||hf(a,s),o=uA(n,t,a,"in"===s||"not-in"===s);return nB.create(i,s,o)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function u6(e,t,n){let r=uM("where",e);return u4._create(r,t,n)}class u8 extends u2{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new u8(e,t)}_parse(e){let t=this._queryConstraints.map(t=>t._parse(e)).filter(e=>e.getFilters().length>0);return 1===t.length?t[0]:nj.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;for(let e of t.getFlattenedFilters())hm(n,e),n=rl(n,e)}(e._query,t),new lz(e.firestore,e.converter,rl(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}
9function u7(...e){return e.forEach(e=>hg("or",e)),u8._create("or",e)}function u9(...e){return e.forEach(e=>hg("and",e)),u8._create("and",e)}class he extends u5{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new he(e,t)}_apply(e){var t;let n,r=function(e,t,n){if(null!==e.startAt)throw new q(V.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new q(V.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new nq(t,n)}(e._query,this._field,this._direction);return new lz(e.firestore,e.converter,(t=e._query,n=t.explicitOrderBy.concat([r]),new re(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)))}}function ht(e,t="asc"){let n=uM("orderBy",e);return he._create(n,t)}class hn extends u5{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new hn(e,t,n)}_apply(e){return new lz(e.firestore,e.converter,ru(e._query,this._limit,this._limitType))}}function hr(e){return em("limit",e),hn._create("limit",e,"F")}function hi(e){return em("limitToLast",e),hn._create("limitToLast",e,"L")}class hs extends u5{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new hs(e,t,n)}_apply(e){var t;let n=hc(e,this.type,this._docOrFields,this._inclusive);return new lz(e.firestore,e.converter,(t=e._query,new re(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,n,t.endAt)))}}function ha(...e){return hs._create("startAt",e,!0)}function ho(...e){return hs._create("startAfter",e,!1)}class hl extends u5{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new hl(e,t,n)}_apply(e){var t;let n=hc(e,this.type,this._docOrFields,this._inclusive);return new lz(e.firestore,e.converter,(t=e._query,new re(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,n)))}}function hu(...e){return hl._create("endBefore",e,!1)}function hh(...e){return hl._create("endAt",e,!0)}function hc(e,t,n,r){if(n[0]=(0,v.getModularInstance)(n[0]),n[0]instanceof uZ)return function(e,t,n,r,i){if(!r)throw new q(V.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);let s=[];for(let n of ri(e))if(n.field.isKeyField())s.push(nT(t,r.key));else{let e=r.data.field(n.field);if(nr(e))throw new q(V.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===e){let e=n.field.canonicalString();throw new q(V.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}s.push(e)}return new nF(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{let i=uw(e.firestore);return function(e,t,n,r,i,s){let a=e.explicitOrderBy;if(i.length>a.length)throw new q(V.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);let o=[];for(let s=0;s<i.length;s++){let l=i[s];if(a[s].field.isKeyField()){if("string"!=typeof l)throw new q(V.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof l}`);if(!rr(e)&&-1!==l.indexOf("/"))throw new q(V.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${l}' contains a slash.`);let n=e.path.child(er.fromString(l));if(!ea.isDocumentKey(n))throw new q(V.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);let i=new ea(n);
9o.push(nT(t,i))}else{let e=uA(n,r,l);o.push(e)}}return new nF(o,s)}(e._query,e.firestore._databaseId,i,t,n,r)}}function hd(e,t,n){if("string"==typeof(n=(0,v.getModularInstance)(n))){if(""===n)throw new q(V.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!rr(t)&&-1!==n.indexOf("/"))throw new q(V.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let r=t.path.child(er.fromString(n));if(!ea.isDocumentKey(r))throw new q(V.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return nT(e,new ea(r))}if(n instanceof lG)return nT(e,n._key);throw new q(V.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ed(n)}.`)}function hf(e,t){if(!Array.isArray(e)||0===e.length)throw new q(V.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function hm(e,t){let n=function(e,t){for(let n of e)for(let e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){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(null!==n)throw n===t.op?new q(V.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new q(V.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function hg(e,t){if(!(t instanceof u4||t instanceof u8))throw new q(V.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}function hp(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}class hy extends uV{constructor(e){super(),this.firestore=e}convertBytes(e){return new ua(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new lG(this.firestore,null,t)}}function hw(e){return new uY("sum",uM("sum",e))}function hv(e){return new uY("avg",uM("average",e))}function hb(){return new uY("count")}function hI(e,t){return e instanceof uY&&t instanceof uY&&e.aggregateType===t.aggregateType&&e._internalFieldPath?.canonicalString()===t._internalFieldPath?.canonicalString()}function hT(e,t){return lJ(e.query,t.query)&&(0,v.deepEqual)(e.data(),t.data())}function h_(e){return hE(e,{count:hb()})}function hE(e,t){var n;let r,i=ef(e.firestore,l1),s=l3(i),a=tQ(t,(e,t)=>new r5(t,e.aggregateType,e._internalFieldPath));return(n=e._query,r=new U,s.asyncQueue.enqueueAndForget(async()=>{try{let e=await lM(s);r.resolve(async function(e,t,n){let{request:r,gt:i,parent:s}=iV(e.serializer,ra(t),n);e.connection.Ko||delete r.parent;let a=(await e.jo("RunAggregationQuery",e.serializer.databaseId,s,r,1)).filter(e=>!!e.result);F(1===a.length,64727);let o=a[0].result?.aggregateFields;return Object.keys(o).reduce((e,t)=>(e[i[t]]=o[t],e),{})}(e,n,a))}catch(e){r.reject(e)}}),r.promise).then(t=>new uX(e,new uq(i),t))}class hS{constructor(e){this.kind="memory",this._onlineComponentProvider=lp.provider,this._offlineComponentProvider=e?.garbageCollector?e.garbageCollector._offlineComponentProvider:{build:()=>new lf(void 0)}}toJSON(){return{kind:this.kind}}}class hx{constructor(e){let t;this.kind="persistent",e?.tabManager?(e.tabManager._initialize(e),t=e.tabManager):(t=hP(void 0))._initialize(e),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class hC{constructor(){this.kind="memoryEager",this._offlineComponentProvider=ld.provider}toJSON(){return{kind:this.kind}}}class hA{constructor(e){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new lf(e)}}toJSON(){return{kind:this.kind}}}function hD(){return new hC}function hN(e){return new hA(e?.cacheSizeBytes)}function hk(e){return new hS(e)}function hR(e){return new hx(e)}class hM{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=lp.provider,this._offlineComponentProvider={build:t=>new lm(t,e?.cacheSizeBytes,this.forceOwnership)}}}class hO{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=lp.provider,this._offlineComponentProvider={build:t=>new lg(t,e?.cacheSizeBytes)}}}function hP(e){return new hM(e?.forceOwnership)}function hF(){return new hO}let hL="NOT SUPPORTED";class hV{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}
9class hq extends uZ{constructor(e,t,n,r,i,s){super(e,t,n,r,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new hB(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let n=this._document.data.field(uM("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new q(V.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e=this._document,t={};return t.type=hq._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()&&(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),this._firestore,this.ref.path,t.bundle="NOT SUPPORTED"),t}}function hU(e,t,n){if(ep(t,hq._jsonSchema)){var r;if(t.bundle===hL)throw new q(V.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");let i=aK(e._databaseId),s=(r=t.bundle,new lb(r,i)),a=s.t(),o=new oO(s.getMetadata(),i);for(let e of a)o.o(e);let l=o.documents;if(1!==l.length)throw new q(V.INVALID_ARGUMENT,`Expected bundle data to contain 1 document, but it contains ${l.length} documents.`);let u=iM(i,l[0].document),h=new ea(er.fromString(t.bundleName));return new hq(e,new hy(e),h,u,new hV(!1,!1),n||null)}}hq._jsonSchemaVersion="firestore/documentSnapshot/1.0",hq._jsonSchema={type:eg("string",hq._jsonSchemaVersion),bundleSource:eg("string","DocumentSnapshot"),bundleName:eg("string"),bundle:eg("string")};class hB extends hq{data(e={}){return super.data(e)}}class hj{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new hV(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new hB(this._firestore,this._userDataWriter,n.key,n,new hV(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new q(V.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map(n=>{let r=new hB(e._firestore,e._userDataWriter,n.doc.key,n.doc,new hV(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:"added",doc:r,oldIndex:-1,newIndex:t++}})}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(e=>t||3!==e.type).map(t=>{let r=new hB(e._firestore,e._userDataWriter,t.doc.key,t.doc,new hV(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,s=-1;return 0!==t.type&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&&(s=(n=n.add(t.doc)).indexOf(t.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return O(61501,{type:e})}}(t.type),doc:r,oldIndex:i,newIndex:s}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new q(V.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e={};e.type=hj._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=J.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let t=[],n=[],r=[];
9return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),n.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),r.push(e.ref.path))}),this._firestore,this.query._query,e.bundleName,e.bundle="NOT SUPPORTED",e}}function hz(e,t,n){if(ep(t,hj._jsonSchema)){var r;if(t.bundle===hL)throw new q(V.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");let i=aK(e._databaseId),s=(r=t.bundle,new lb(r,i)),a=s.t(),o=new oO(s.getMetadata(),i);for(let e of a)o.o(e);if(1!==o.queries.length)throw new q(V.INVALID_ARGUMENT,`Snapshot data expected 1 query but found ${o.queries.length} queries.`);let l=iZ(o.queries[0].bundledQuery),u=o.documents,h=new ob;u.map(e=>{let t=iM(i,e.document);h=h.add(t)});let c=oT.fromInitialDocuments(l,h,rE(),!1,!1),d=new lz(e,n||null,l);return new hj(e,new hy(e),d,c)}}function hG(e,t){return e instanceof hq&&t instanceof hq?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(null===e._document?null===t._document:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof hj&&t instanceof hj&&e._firestore===t._firestore&&lJ(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}hj._jsonSchemaVersion="firestore/querySnapshot/1.0",hj._jsonSchema={type:eg("string",hj._jsonSchemaVersion),bundleSource:eg("string","QuerySnapshot"),bundleName:eg("string"),bundle:eg("string")};let hK={maxAttempts:5};class h${constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=uw(e)}set(e,t,n){this._verifyNotCommitted();let r=hQ(e,this._firestore),i=hp(r.converter,t,n),s=uv(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,rB.none())),this}update(e,t,n,...r){let i;this._verifyNotCommitted();let s=hQ(e,this._firestore);return i="string"==typeof(t=(0,v.getModularInstance)(t))||t instanceof uo?uC(this._dataReader,"WriteBatch.update",s._key,t,n,r):ux(this._dataReader,"WriteBatch.update",s._key,t),this._mutations.push(i.toMutation(s._key,rB.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=hQ(e,this._firestore);return this._mutations=this._mutations.concat(new rX(t._key,rB.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 q(V.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function hQ(e,t){if((e=(0,v.getModularInstance)(e)).firestore!==t)throw new q(V.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class hH{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=uw(e)}get(e){let t=hQ(e,this._firestore),n=new hy(this._firestore);return this._transaction.lookup([t._key]).then(e=>{if(!e||1!==e.length)return O(24041);let r=e[0];if(r.isFoundDocument())return new uZ(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new uZ(this._firestore,n,t._key,null,t.converter);throw O(18433,{doc:r})})}set(e,t,n){let r=hQ(e,this._firestore),i=hp(r.converter,t,n),s=uv(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(e,t,n,...r){let i,s=hQ(e,this._firestore);return i="string"==typeof(t=(0,v.getModularInstance)(t))||t instanceof uo?uC(this._dataReader,"Transaction.update",s._key,t,n,r):ux(this._dataReader,"Transaction.update",s._key,t),this._transaction.update(s._key,i),this}delete(e){let t=hQ(e,this._firestore);return this._transaction.delete(t._key),this}}class hW extends hH{constructor(e,t){super(e,t),this._firestore=e}get(e){let t=hQ(e,this._firestore),n=new uq(this._firestore);return super.get(e).then(e=>new hq(this._firestore,n,t._key,e._document,new hV(!1,!1),t.converter))}}function hJ(e,t,n){var r,i;let s;e=ef(e,l1);let a={...hK,...n};if(a.maxAttempts<1)throw new q(V.INVALID_ARGUMENT,"Max attempts must be at least 1");return r=l3(e),i=n=>t(new hW(e,n)),s=new U,r.asyncQueue.enqueueAndForget(async()=>{let e=await lM(r);new lT(r.asyncQueue,e,a,i,s).ju()}),s.promise}function hY(e){e=ef(e,lG);let t=ef(e.firestore,l1);return lP(l3(t),e._key).then(n=>ct(t,e,n))}function hX(e){var t;let n;e=ef(e,lG);let r=ef(e.firestore,l1),i=l3(r),s=new uq(r);return(t=e._key,n=new U,i.asyncQueue.enqueueAndForget(async()=>(async function(e,t,n){try{let r=await e.persistence.runTransaction("read document","readonly",n=>e.localDocuments.getDocument(n,t));r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new q(V.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(r){let e=ov(r,`Failed to get document '${t} from cache`);n.reject(e)}})(await lN(i),t,n)),n.promise).then(t=>new hq(r,s,e._key,t,new hV(null!==t&&t.hasLocalMutations,!0),e.converter))}function hZ(e){e=ef(e,lG);let t=ef(e.firestore,l1);return lP(l3(t),e._key,{source:"server"}).then(n=>ct(t,e,n))}function h0(e){e=ef(e,lz);let t=ef(e.firestore,l1),n=l3(t),r=new uq(t);return u1(e._query),lF(n,e._query).then(n=>new hj(t,r,e,n))}function h1(e){var t;let n;e=ef(e,lz);let r=ef(e.firestore,l1),i=l3(r),s=new uq(r);return(t=e._query,n=new U,i.asyncQueue.enqueueAndForget(async()=>(async function(e,t,n){try{let r=await ac(e,t,!0),i=new oV(t,r.ks),s=i.ru(r.documents),a=i.applyChanges(s,
9!1);n.resolve(a.snapshot)}catch(r){let e=ov(r,`Failed to execute query '${t} against cache`);n.reject(e)}})(await lN(i),t,n)),n.promise).then(t=>new hj(r,s,e,t))}function h2(e){e=ef(e,lz);let t=ef(e.firestore,l1),n=l3(t),r=new uq(t);return lF(n,e._query,{source:"server"}).then(n=>new hj(t,r,e,n))}function h5(e,t,n){e=ef(e,lG);let r=ef(e.firestore,l1),i=hp(e.converter,t,n),s=uw(r);return ce(r,[uv(s,"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,rB.none())])}function h3(e,t,n,...r){e=ef(e,lG);let i=ef(e.firestore,l1),s=uw(i);return ce(i,[("string"==typeof(t=(0,v.getModularInstance)(t))||t instanceof uo?uC(s,"updateDoc",e._key,t,n,r):ux(s,"updateDoc",e._key,t)).toMutation(e._key,rB.exists(!0))])}function h4(e){return ce(ef(e.firestore,l1),[new rX(e._key,rB.none())])}function h6(e,t){let n=ef(e.firestore,l1),r=lH(e),i=hp(e.converter,t);return ce(n,[uv(uw(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,rB.exists(!1))]).then(()=>r)}function h8(e,...t){var n;let r,i,s,a,o;e=(0,v.getModularInstance)(e);let l={includeMetadataChanges:!1,source:"default"},u=0;"object"!=typeof t[0]||uJ(t[u])||(l=t[u++]);let h={includeMetadataChanges:l.includeMetadataChanges,source:l.source};if(uJ(t[u])){let e=t[u];t[u]=e.next?.bind(e),t[u+1]=e.error?.bind(e),t[u+2]=e.complete?.bind(e)}if(e instanceof lG)i=ef(e.firestore,l1),s=rt(e._key.path),r={next:n=>{t[u]&&t[u](ct(i,e,n))},error:t[u+1],complete:t[u+2]};else{let n=ef(e,lz);i=ef(n.firestore,l1),s=n._query;let a=new uq(i);r={next:e=>{t[u]&&t[u](new hj(i,a,n,e))},error:t[u+1],complete:t[u+2]},u1(e._query)}return n=l3(i),o=new ok(s,a=new lw(r),h),n.asyncQueue.enqueueAndForget(async()=>ox(await lO(n),o)),()=>{a.Nu(),n.asyncQueue.enqueueAndForget(async()=>oC(await lO(n),o))}}function h7(e,t,...n){var r,i,s,a,o,l;let u=(0,v.getModularInstance)(e),h=function(e){let t={bundle:"",bundleName:"",bundleSource:""};for(let n of["bundle","bundleName","bundleSource"]){if(!(n in e)){t.error=`snapshotJson missing required field: ${n}`;break}let r=e[n];if("string"!=typeof r){t.error=`snapshotJson field '${n}' must be a string.`;break}if(0===r.length){t.error=`snapshotJson field '${n}' cannot be an empty string.`;break}"bundle"===n?t.bundle=r:"bundleName"===n?t.bundleName=r:"bundleSource"===n&&(t.bundleSource=r)}return t}(t);if(h.error)throw new q(V.INVALID_ARGUMENT,h.error);let c,d=0;if("object"!=typeof n[0]||uJ(n[d])||(c=n[d++]),"QuerySnapshot"===h.bundleSource){let e,t,a=null;if("object"==typeof n[d]&&uJ(n[d])){let e=n[d++];a={next:e.next,error:e.error,complete:e.complete}}else a={next:n[d++],error:n[d++],complete:n[d++]};return r=c,i=a,s=n[d],t=!1,ui(u,h.bundle).then(()=>us(u,h.bundleName)).then(n=>{n&&!t&&(s&&n.withConverter(s),e=h8(n,r||{},i))}).catch(e=>(i.error&&i.error(e),()=>{})),()=>{t||(t=!0,e&&e())}}if("DocumentSnapshot"===h.bundleSource){let e,t,r=null;if("object"==typeof n[d]&&uJ(n[d])){let e=n[d++];r={next:e.next,error:e.error,complete:e.complete}}else r={next:n[d++],error:n[d++],complete:n[d++]};return a=c,o=r,l=n[d],t=!1,ui(u,h.bundle).then(()=>{t||(e=h8(new lG(u,l||null,ea.fromPath(h.bundleName)),a||{},o))}).catch(e=>(o.error&&o.error(e),()=>{})),()=>{t||(t=!0,e&&e())}}throw new q(V.INVALID_ARGUMENT,`unsupported bundle source: ${h.bundleSource}`)}function h9(e,t){let n,r=l3(e=ef(e,l1));return n=new lw(uJ(t)?t:{next:t}),r.asyncQueue.enqueueAndForget(async()=>{var e;return e=await lO(r),void(e.Ca.add(n),n.next())}),()=>{n.Nu(),r.asyncQueue.enqueueAndForget(async()=>{var e;return e=await lO(r),void e.Ca.delete(n)})}}function ce(e,t){var n;let r;return n=l3(e),r=new U,n.asyncQueue.enqueueAndForget(async()=>oW(await lR(n),t,r)),r.promise}function ct(e,t,n){let r=n.docs.get(t._key),i=new uq(e);return new hq(e,i,t._key,r,new hV(n.hasPendingWrites,n.fromCache),t.converter)}function cn(e){return l3(e=ef(e,l1)),new h$(e,t=>ce(e,t))}function cr(e,t){let n=l3(e=ef(e,l1));if(!n._uninitializedComponentsProvider||"memory"===n._uninitializedComponentsProvider._offline.kind)return R("Cannot enable indexes when persistence is disabled"),Promise.resolve();let r=function(e){let t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new q(V.INVALID_ARGUMENT,"Failed to parse JSON: "+e?.message)}}(e):e,n=[];if(Array.isArray(t.indexes))for(let e of t.indexes){let t=ci(e,"collectionGroup"),r=[];if(Array.isArray(e.fields))for(let t of e.fields){let e=uP("setIndexConfiguration",ci(t,"fieldPath"));"CONTAINS"===t.arrayConfig?r.push(new e_(e,2)):"ASCENDING"===t.order?r.push(new e_(e,0)):"DESCENDING"===t.order&&r.push(new e_(e,1))}n.push(new ev(ev.UNKNOWN_ID,t,r,eE.empty()))}return n}(t);return n.asyncQueue.enqueue(async()=>(async function(e,t){let n=e.indexManager,r=[];return e.persistence.runTransaction("Configure indexes","readwrite",e=>n.getFieldIndexes(e).next(i=>(function(e,t,n,r,i){t=[...t],(e=[...e]).sort(n),t.sort(n);let s=e.length,a=t.length,o=0,l=0;for(;o<a&&l<s;){let s=n(e[l],t[o]);s<0?i(e[l++]):s>0?r(t[o++]):(o++,l++)}for(;o<a;)r(t[o++]);for(;l<s;)i(e[l++])})(i,t,eT,t=>{r.push(n.addFieldIndex(e,t))},t=>{r.push(n.deleteFieldIndex(e,t))})).next(()=>eR.waitFor(r)))})(await lN(n),r))}function ci(e,t){if("string"!=typeof e[t])throw new q(V.INVALID_ARGUMENT,"Missing str
9ing value for: "+t);return e[t]}class cs{constructor(e){this._firestore=e,this.type="PersistentCacheIndexManager"}}function ca(e){e=ef(e,l1);let t=cc.get(e);if(t)return t;let n=l3(e);if("persistent"!==n._uninitializedComponentsProvider?._offline.kind)return null;let r=new cs(e);return cc.set(e,r),r}function co(e){ch(e,!0)}function cl(e){ch(e,!1)}function cu(e){var t;(t=l3(e._firestore)).asyncQueue.enqueue(async()=>{var e;let n;return n=(e=await lN(t)).indexManager,e.persistence.runTransaction("Delete All Indexes","readwrite",e=>n.deleteAllFieldIndexes(e))}).then(e=>N("deleting all persistent cache indexes succeeded")).catch(e=>R("deleting all persistent cache indexes failed",e))}function ch(e,t){var n;(n=l3(e._firestore),n.asyncQueue.enqueue(async()=>{var e;return e=await lN(n),void(e.Cs.As=t)})).then(e=>N(`setting persistent cache index auto creation isEnabled=${t} succeeded`)).catch(e=>R(`setting persistent cache index auto creation isEnabled=${t} failed`,e))}let cc=new WeakMap;class cd{constructor(){throw Error("instances of this class should not be created")}static onExistenceFilterMismatch(e){return cf.instance.onExistenceFilterMismatch(e)}}class cf{constructor(){this.i=new Map}static get instance(){return cm||function(e){if(r8)throw Error("a TestingHooksSpi instance is already set");r8=e}(cm=new cf),cm}u(e){this.i.forEach(t=>t(e))}onExistenceFilterMismatch(e){let t=Symbol(),n=this.i;return n.set(t,e),()=>n.delete(t)}}let cm=null;!function(e=!0){x=g.SDK_VERSION,(0,g._registerComponent)(new p.Component("firestore",(t,{instanceIdentifier:n,options:r})=>{let i=t.getProvider("app").getImmediate(),s=new l1(new G(t.getProvider("auth-internal")),new H(i,t.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new q(V.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new nl(e.options.projectId,t)}(i,n),i);return r={useFetchStreams:e,...r},s._setSettings(r),s},"PUBLIC").setMultipleInstances(!0)),(0,g.registerVersion)(uH,uW,void 0),(0,g.registerVersion)(uH,uW,"esm2020")}(),e.s(["AggregateField",()=>uY,"AggregateQuerySnapshot",()=>uX,"DocumentSnapshot",()=>hq,"PersistentCacheIndexManager",()=>cs,"QueryCompositeFilterConstraint",()=>u8,"QueryConstraint",()=>u5,"QueryDocumentSnapshot",()=>hB,"QueryEndAtConstraint",()=>hl,"QueryFieldFilterConstraint",()=>u4,"QueryLimitConstraint",()=>hn,"QueryOrderByConstraint",()=>he,"QuerySnapshot",()=>hj,"QueryStartAtConstraint",()=>hs,"SnapshotMetadata",()=>hV,"Transaction",()=>hW,"WriteBatch",()=>h$,"_TestingHooks",()=>cd,"addDoc",()=>h6,"aggregateFieldEqual",()=>hI,"aggregateQuerySnapshotEqual",()=>hT,"and",()=>u9,"average",()=>hv,"count",()=>hb,"deleteAllPersistentCacheIndexes",()=>cu,"deleteDoc",()=>h4,"disablePersistentCacheIndexAutoCreation",()=>cl,"documentSnapshotFromJSON",()=>hU,"enablePersistentCacheIndexAutoCreation",()=>co,"endAt",()=>hh,"endBefore",()=>hu,"executeWrite",()=>ce,"getAggregateFromServer",()=>hE,"getCountFromServer",()=>h_,"getDoc",()=>hY,"getDocFromCache",()=>hX,"getDocFromServer",()=>hZ,"getDocs",()=>h0,"getDocsFromCache",()=>h1,"getDocsFromServer",()=>h2,"getPersistentCacheIndexManager",()=>ca,"limit",()=>hr,"limitToLast",()=>hi,"memoryEagerGarbageCollector",()=>hD,"memoryLocalCache",()=>hk,"memoryLruGarbageCollector",()=>hN,"onSnapshot",()=>h8,"onSnapshotResume",()=>h7,"onSnapshotsInSync",()=>h9,"or",()=>u7,"orderBy",()=>ht,"persistentLocalCache",()=>hR,"persistentMultipleTabManager",()=>hF,"persistentSingleTabManager",()=>hP,"query",()=>u3,"querySnapshotFromJSON",()=>hz,"runTransaction",()=>hJ,"setDoc",()=>h5,"setIndexConfiguration",()=>cr,"snapshotEqual",()=>hG,"startAfter",()=>ho,"startAt",()=>ha,"sum",()=>hw,"updateDoc",()=>h3,"where",()=>u6,"writeBatch",()=>cn],263802),e.s([],436180),e.i(263802),e.s(["AbstractUserDataWriter",()=>uV,"AggregateField",()=>uY,"AggregateQuerySnapshot",()=>uX,"Bytes",()=>ua,"CACHE_SIZE_UNLIMITED",()=>-1,"CollectionReference",()=>lK,"DocumentReference",()=>lG,"DocumentSnapshot",()=>hq,"FieldPath",()=>uo,"FieldValue",()=>uu,"Firestore",()=>l1,"FirestoreError",()=>q,"GeoPoint",()=>uh,"LoadBundleTask",()=>l0,"PersistentCacheIndexManager",()=>cs,"Query",()=>lz,"QueryCompositeFilterConstraint",()=>u8,"QueryConstraint",()=>u5,"QueryDocumentSnapshot",()=>hB,"QueryEndAtConstraint",()=>hl,"QueryFieldFilterConstraint",()=>u4,"QueryLimitConstraint",()=>hn,"QueryOrderByConstraint",()=>
9he,"QuerySnapshot",()=>hj,"QueryStartAtConstraint",()=>hs,"SnapshotMetadata",()=>hV,"Timestamp",()=>ey,"Transaction",()=>hW,"VectorValue",()=>uc,"WriteBatch",()=>h$,"_AutoId",()=>J,"_ByteString",()=>t3,"_DatabaseId",()=>nl,"_DocumentKey",()=>ea,"_EmptyAppCheckTokenProvider",()=>W,"_EmptyAuthCredentialsProvider",()=>j,"_FieldPath",()=>es,"_TestingHooks",()=>cd,"_cast",()=>ef,"_debugAssert",()=>L,"_internalAggregationQueryToProtoRunAggregationQueryRequest",()=>uQ,"_internalQueryToProtoQueryTarget",()=>u$,"_isBase64Available",()=>t5,"_logWarn",()=>R,"_validateIsNotUsedTogether",()=>el,"addDoc",()=>h6,"aggregateFieldEqual",()=>hI,"aggregateQuerySnapshotEqual",()=>hT,"and",()=>u9,"arrayRemove",()=>uz,"arrayUnion",()=>uj,"average",()=>hv,"clearIndexedDbPersistence",()=>l9,"collection",()=>l$,"collectionGroup",()=>lQ,"connectFirestoreEmulator",()=>lj,"count",()=>hb,"deleteAllPersistentCacheIndexes",()=>cu,"deleteDoc",()=>h4,"deleteField",()=>uU,"disableNetwork",()=>un,"disablePersistentCacheIndexAutoCreation",()=>cl,"doc",()=>lH,"documentId",()=>ul,"documentSnapshotFromJSON",()=>hU,"enableIndexedDbPersistence",()=>l6,"enableMultiTabIndexedDbPersistence",()=>l8,"enableNetwork",()=>ut,"enablePersistentCacheIndexAutoCreation",()=>co,"endAt",()=>hh,"endBefore",()=>hu,"ensureFirestoreConfigured",()=>l3,"executeWrite",()=>ce,"getAggregateFromServer",()=>hE,"getCountFromServer",()=>h_,"getDoc",()=>hY,"getDocFromCache",()=>hX,"getDocFromServer",()=>hZ,"getDocs",()=>h0,"getDocsFromCache",()=>h1,"getDocsFromServer",()=>h2,"getFirestore",()=>l5,"getPersistentCacheIndexManager",()=>ca,"increment",()=>uG,"initializeFirestore",()=>l2,"limit",()=>hr,"limitToLast",()=>hi,"loadBundle",()=>ui,"memoryEagerGarbageCollector",()=>hD,"memoryLocalCache",()=>hk,"memoryLruGarbageCollector",()=>hN,"namedQuery",()=>us,"onSnapshot",()=>h8,"onSnapshotResume",()=>h7,"onSnapshotsInSync",()=>h9,"or",()=>u7,"orderBy",()=>ht,"persistentLocalCache",()=>hR,"persistentMultipleTabManager",()=>hF,"persistentSingleTabManager",()=>hP,"query",()=>u3,"queryEqual",()=>lJ,"querySnapshotFromJSON",()=>hz,"refEqual",()=>lW,"runTransaction",()=>hJ,"serverTimestamp",()=>uB,"setDoc",()=>h5,"setIndexConfiguration",()=>cr,"setLogLevel",()=>D,"snapshotEqual",()=>hG,"startAfter",()=>ho,"startAt",()=>ha,"sum",()=>hw,"terminate",()=>ur,"updateDoc",()=>h3,"vector",()=>uK,"waitForPendingWrites",()=>ue,"where",()=>u6,"writeBatch",()=>cn],98925)}]);

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.