1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0adf6-a150-7bc2-869d-0ac013db8350")}catch(e){}}();;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="3a08f979-b312-448e-a2e3-1f91c04c676e")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,98925,e=>{"use strict";var t,n,r,i,s,a,o,l,u,h,c,d,f,m,g=e.i(247167),p=e.i(467034),y=e.i(92953),w=e.i(308070),v=e.i(683877),b=e.i(897427),I="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,T={};(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>>>
226),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>30){if(g(e)||g(t))throw Error("slowDivide_ only works with positive integers.");for(var n=d,r=t;0>=r.l(e);)n=I(n),r=I(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 I(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=T.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);
2if("-"==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=T.Integer=a}).apply(void 0!==I?I:"u">typeof self?self:"u">typeof window?window:{});var _="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)}function 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 M(){this.u=this.u,this.C=this.C}function R(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}M.prototype.u=!1,M.prototype.dispose=function(){this.u||(this.u=!0,this.N())},M.prototype[Symbol.dispose]=function(){this.dispose()},M.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},R.prototype.h=function(){this.defaultPrevented=!0};var P=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 O(e){return/^[\s\xa0]*$/.test(e)}function F(e,t){R.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,R),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:"mou
2seout"==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;t++)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)P||(i=a),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Y(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error("addEventListener and attachEvent are unavailable.");return n}function X(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(Y(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 Y(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&&X(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(){M.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 R(t,e);else if(t instanceof R)t.target=t.target||e;else{var a=t;G(t=new R(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,M),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)&&X(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 M{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){M.call(this),this.h=e,this.g={}}v(eo,M);var el=[];function eu(e){B(e.g,function(e,t){this.g.hasOwnProperty(t)&&X(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(){R.call(this,"d")}function ey(){R.call(this,"c")}v(ep,R),v(ey,R);var ew={},ev=null;function eb(){return ev=ev||new er}function eI(e){R.call(this,ew.Ia,e)}function eT(e){let t=eb();ei(t,new eI(t))}function e_(e,t){R.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){R.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,R),ew.STAT_EVENT="statevent",v(e_,R),ew.Ja="timingevent",v(eS,R),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 eM(e){return encodeURIComponent(String(e))}function eR(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 eP}function eP(){this.i=null,this.g="",this.h=!1}v(ek,ef),ek.prototype.g=function(){return new XMLHttpRequest},e=new ek;var eO={},eF={};
2function 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 eP,e.g=tX(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),tO(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),!O(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&&(eX(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){eY(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):tP(n):"noop"!=o[0]&&n.l&&n.l.qa(o),n.A=0)}}eT(4)}catch(e){}}eR.prototype.ba=function(e){e=e.target;let t=this.O;t&&3==tN(e)?t.j():this.Y(e)},eR.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)&&!O(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)))?eO:(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==eO){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(O(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)}
2var 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{}},eR.prototype.cancel=function(){this.K=!0,eG(this)},eR.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 eX(e,t){e.g?e.g.add(t):e.h=t}function eY(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(eM(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}
2function 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&&eM(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=eM(n);n=th(this,n);for(let t=0;t<n.length;t++){let r=i;""!==n[t]&&(r+="="+eM(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}}
2function tM(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function tR(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=tM("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=tM("baseRetryDelayMs",5e3,e),this.Za=tM("retryDelaySeedMs",1e4,e),this.Ta=tM("forwardChannelMaxRetries",2,e),this.va=tM("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 tP(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 eR(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=tX(t.j,null),t.g.ea(t.A)),t.F=Date.now(),eU(t)}tW(e)}function tO(e){e.g&&(tz(e),e.g.cancel(),e.g=null)}function tF(e){tO(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 eR(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()),eX(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 eR(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,eY(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,
2n,"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 tX(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 tY(){}function tZ(){}function t0(e,t){er.call(this),this.g=new tR(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)&&!O(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!O(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=tR.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 eR(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;
2if((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="+eM(tI(s))+"&"+t:this.u&&tT(n,this.u,s)),eX(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),tO(this),tG(this))},t.Va=function(){null!=this.C&&(this.C=null,tO(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=tY.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(){tP(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,tP(this.g),delete this.g,t0.Z.N.call(this)},v(t1,ep),v(t2,ey),v(t5,tY),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:{});let S="@firebase/firestore",x="4.9.2";class C{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}}C.UNAUTHENTICATED=new C(null),C.GOOGLE_CREDENTIALS=new C("google-credentials-uid"),C.FIRST_PARTY=new C("first-party-uid"),C.MOCK_USER=new C("mock-user");let A="12.3.0",D=new v.Logger("@firebase/firestore");function N(){return D.logLevel}function k(e,...t){if(D.logLevel<=v.LogLevel.DEBUG){let n=t.map(P);D.debug(`Firestore (${A}): ${e}`,...n)}}function M(e,...t){if(D.logLevel<=v.LogLevel.ERROR){let n=t.map(P);D.error(`Firestore (${A}): ${e}`,...n)}}function R(e,...t){if(D.logLevel<=v.LogLevel.WARN){let n=t.map(P);D.warn(`Firestore (${A}): ${e}`,...n)}}function P(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,F(e,r,n)}function F(e,t,n){let r=`FIRESTORE (${A}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==n)try{r+=" CONTEXT: "+JSON.stringify(n)}catch(e){r+=" CONTEXT: "+n}throw M(r),Error(r)}function L(e,t,n,r){let i="Unexpected state";"string"==typeof n?i=n:r=n,e||F(t,i,r)}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
2ED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class q extends b.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(C.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=C.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){L(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=>{k("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):(k("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?(k("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(L("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 L(null===e||"string"==typeof e,2055,{h:e}),new C(e)}}class K{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type="FirstParty",this.user=C.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);let e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}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(C.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,y._isFirebaseServerApp)(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){L(void 0===this.o,3512);let n=e=>{null!=e.error&&k("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,k("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>n(t))};let r=e=>{k("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):k("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?(L("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{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let n=function(){let e="u">typeof self&&(self.crypto||self.msCrypto),t=new Uint8Array(40);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(t);else for(let e=0;e<40;
2e++)t[e]=Math.floor(256*Math.random());return t}();for(let r=0;r<n.length;++r)t.length<20&&n[r]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function J(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 Y(n)===Y(i)?J(n,i):Y(n)?1:-1}return J(e.length,t.length)}function Y(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}function Z(e,t,n){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}let ee="__name__";class et{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===et.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof et?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=et.compareSegments(e.get(r),t.get(r));if(0!==n)return n}return J(e.length,t.length)}static compareSegments(e,t){let n=et.isNumericId(e),r=et.isNumericId(t);return n&&!r?-1:!n&&r?1:n&&r?et.extractNumericId(e).compare(et.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 en extends et{construct(e,t,n){return new en(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 en(t)}static emptyPath(){return new en([])}}let er=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class ei extends et{construct(e,t,n){return new ei(e,t,n)}static isValidIdentifier(e){return er.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),ei.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===ee}static keyField(){return new ei([ee])}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 ei(t)}static emptyPath(){return new ei([])}}class es{constructor(e){this.path=e}static fromPath(e){return new es(en.fromString(e))}static fromName(e){return new es(en.fromString(e).popFirst(5))}static empty(){return new es(en.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===en.comparator(this.path,e.path)}toString(){return this.path.toString()}
2static comparator(e,t){return en.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new es(new en(e.slice()))}}function ea(e,t,n){if(!n)throw new q(V.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function eo(e,t,n,r){if(!0===t&&!0===r)throw new q(V.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function el(e){if(!es.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 eu(e){if(es.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 eh(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function ec(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 ed(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=ec(e);throw new q(V.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function ef(e,t){if(t<=0)throw new q(V.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function em(e,t){let n={typeString:e};return t&&(n.value=t),n}function eg(e,t){let n;if(!eh(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 ep{static now(){return ep.fromMillis(Date.now())}static fromDate(e){return ep.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*1e6);return new ep(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?J(this.nanoseconds,e.nanoseconds):J(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:ep._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(eg(e,ep._jsonSchema))return new ep(e.seconds,e.nanoseconds)}valueOf(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}ep._jsonSchemaVersion="firestore/timestamp/1.0",ep._jsonSchema={type:em("string",ep._jsonSchemaVersion),seconds:em("number"),nanoseconds:em("number")};class ey{static fromTimestamp(e){return new ey(e)}static min(){return new ey(new ep(0,0))}static max(){return new ey(new ep(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 ew{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}function ev(e){return e.fields.find(e=>2===e.kind)}function eb(e){return e.fields.filter(e=>2!==e.kind)}function eI(e,t){let n=J(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=ei.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:J(e.kind,t.kind)}(e.fields[r],t.fields[r])))return n;return J(e.fields.length,t.fields.length)}ew.UNKNOWN_ID=-1;class eT{constructor(e,t){this.fieldPath=e,this.kind=t}}class e_{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new e_(0,ex.min())}}function eE(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new ex(ey.fromTimestamp(1e9===r?new ep(n+1,0):new ep(n,r)),es.empty(),t)}function eS(e){return new ex(e.readTime,e.key,-1)}class ex{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new ex(ey.min(),es.empty(),-1)}static max(){return new ex(ey.max(),es.empty(),-1)}}function eC(e,t){let n=e.readTime.compareTo(t.readTime);
2return 0!==n||0!==(n=es.comparator(e.documentKey,t.documentKey))?n:J(e.largestBatchId,t.largestBatchId)}let eA="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class eD{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function eN(e){if(e.code!==V.FAILED_PRECONDITION||e.message!==eA)throw e;k("LocalStore","Unexpectedly lost primary lease")}class ek{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 ek((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 ek?t:ek.resolve(t)}catch(e){return ek.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):ek.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):ek.reject(t)}static resolve(e){return new ek((t,n)=>{t(e)})}static reject(e){return new ek((t,n)=>{n(e)})}static waitFor(e){return new ek((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=ek.resolve(!1);for(let n of e)t=t.next(e=>e?ek.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 ek((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 ek((n,r)=>{let i=()=>{!0===e()?t().next(()=>{i()},r):n()};i()})}}let eM="SimpleDb";class eR{static open(e,t,n,r){try{return new eR(t,e.transaction(r,n))}catch(e){throw new eL(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 eL(e,t.error)):this.S.resolve()},this.transaction.onerror=t=>{let n=ej(t.target.error);this.S.reject(new eL(e,n))}}get D(){return this.S.promise}abort(e){e&&this.S.reject(e),this.aborted||(k(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 eq(this.transaction.objectStore(e))}}class eP{static delete(e){return k(eM,"Removing database:",e),eU((0,b.getGlobal)().indexedDB.deleteDatabase(e)).toPromise()}static v(){if(!(0,b.isIndexedDBAvailable)())return!1;if(eP.F())return!0;let e=(0,b.getUA)(),t=eP.M(e),n=eO(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!==g.default&&"YES"===g.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,b.getUA)())&&M("Firestore persistence suffers from a bug in iOS 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||(k(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 eL(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 eL(e,r))},r.onupgradeneeded=e=>{k(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(()=>{k(eM,"Database upgrade to version "+this.version+" complete")}
2)}})),this.q&&(this.db.onversionchange=e=>this.q(e)),this.db}$(e){this.q=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=eR.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).next(e=>(t.C(),e)).catch(e=>(t.abort(e),ek.reject(e))).toPromise();return s.catch(()=>{}),await t.D,s}catch(t){let e="FirebaseError"!==t.name&&s<3;if(k(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 eO(e){let t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}class eF{constructor(e){this.U=e,this.K=!1,this.W=null}get isDone(){return this.K}get G(){return this.W}set cursor(e){this.U=e}done(){this.K=!0}j(e){this.W=e}delete(){return eU(this.U.delete())}}class eL extends q{constructor(e,t){super(V.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function eV(e){return"IndexedDbTransactionError"===e.name}class eq{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(k(eM,"PUT",this.store.name,e,t),n=this.store.put(t,e)):(k(eM,"PUT",this.store.name,"<auto-key>",e),n=this.store.put(e)),eU(n)}add(e){return k(eM,"ADD",this.store.name,e,e),eU(this.store.add(e))}get(e){return eU(this.store.get(e)).next(t=>(void 0===t&&(t=null),k(eM,"GET",this.store.name,e,t),t))}delete(e){return k(eM,"DELETE",this.store.name,e),eU(this.store.delete(e))}count(){return k(eM,"COUNT",this.store.name),eU(this.store.count())}J(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 ek((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}})}{let e=this.cursor(n),t=[];return this.H(e,(e,n)=>{t.push(n)}).next(()=>t)}}Y(e,t){let n=this.store.getAll(e,null===t?void 0:t);return new ek((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}})}Z(e,t){k(eM,"DELETE ALL",this.store.name);let n=this.options(e,t);n.X=!1;let r=this.cursor(n);return this.H(r,(e,t,n)=>n.delete())}ee(e,t){let n;t?n=e:(n={},t=e);let r=this.cursor(n);return this.H(r,t)}te(e){let t=this.cursor({});return new ek((n,r)=>{t.onerror=e=>{r(ej(e.target.error))},t.onsuccess=t=>{let r=t.target.result;r?e(r.primaryKey,r.value).next(e=>{e?r.continue():n()}):n()}})}H(e,t){let n=[];return new ek((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 eF(i),a=t(i.primaryKey,i.value,s);if(a instanceof ek){let e=a.catch(e=>(s.done(),ek.reject(e)));n.push(e)}s.isDone?r():null===s.G?i.continue():i.continue(s.G)}}).next(()=>ek.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.X?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function eU(e){return new ek((t,n)=>{e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{n(ej(e.target.error))}})}let eB=!1;function ej(e){let t=eP.M((0,b.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 eB||(eB=!0,setTimeout(()=>{throw e},0)),e}}return e}let ez="IndexBackfiller";class eG{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){k(ez,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{let e=await this.ne.ie();k(ez,`Documents written: ${e}`)}catch(e){eV(e)?k(ez,"Ignoring IndexedDB error during index backfill: ",e):await eN(e)}await this.re(6e4)})}}class eK{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;
2return ek.doWhile(()=>!0===i&&r>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(t=>{if(null!==t&&!n.has(t))return k(ez,`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=>(k(ez,`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=eS(t);eC(r,n)>0&&(n=r)}),new ex(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class e${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 eQ(e){return null==e}function eH(e){return 0===e&&1/e==-1/0}function eW(e){return"number"==typeof e&&Number.isInteger(e)&&!eH(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function eJ(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"}e$.ce=-1;function eX(e){let t=e.length;if(L(t>=2,64408,{path:e}),2===t)return L("\x01"===e.charAt(0)&&"\x01"===e.charAt(1),56145,{path:e}),en.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 en(r)}let eY="remoteDocuments",eZ="owner",e0="owner",e1="mutationQueues",e2="mutations",e5="batchId",e3="userMutationsIndex",e4=["userId","batchId"],e6={},e8="documentMutations",e7="remoteDocumentsV14",e9=["prefixPath","collectionGroup","readTime","documentId"],te="documentKeyIndex",tt=["prefixPath","collectionGroup","documentId"],tn="collectionGroupIndex",tr=["collectionGroup","readTime","prefixPath","documentId"],ti="remoteDocumentGlobal",ts="remoteDocumentGlobalKey",ta="targets",to="queryTargetsIndex",tl=["canonicalId","targetId"],tu="targetDocuments",th=["targetId","path"],tc="documentTargetsIndex",td=["path","targetId"],tf="targetGlobalKey",tm="targetGlobal",tg="collectionParents",tp=["collectionId","parent"],ty="clientMetadata",tw="bundles",tv="namedQueries",tb="indexConfiguration",tI="collectionGroupIndex",tT="indexState",t_=["indexId","uid"],tE="sequenceNumberIndex",tS=["uid","sequenceNumber"],tx="indexEntries",tC=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],tA="documentKeyIndex",tD=["indexId","uid","orderedDocumentKey"],tN="documentOverlays",tk=["userId","collectionPath","documentId"],tM="collectionPathOverlayIndex",tR=["userId","collectionPath","largestBatchId"],tP="collectionGroupOverlayIndex",tO=["userId","collectionGroup","largestBatchId"],tF="globals",tL=[e1,e2,e8,eY,ta,eZ,tm,tu,ty,ti,tg,tw,tv],tV=[...tL,tN],tq=[e1,e2,e8,e7,ta,eZ,tm,tu,ty,ti,tg,tw,tv,tN],tU=[...tq,tb,tT,tx],tB=[...tU,tF];class tj extends eD{constructor(e,t){super(),this.le=e,this.currentSequenceNumber=t}}function tz(e,t){return eP.O(e.le,t)}function tG(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function tK(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function t$(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 tQ(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class tH{constructor(e,t){this.comparator=e,this.root=t||tJ.EMPTY}insert(e,t){return new tH(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,tJ.BLACK,null,
2null))}remove(e){return new tH(this.comparator,this.root.remove(e,this.comparator).copy(null,null,tJ.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 tW(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new tW(this.root,e,this.comparator,!1)}getReverseIterator(){return new tW(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new tW(this.root,e,this.comparator,!0)}}class tW{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 tJ{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:tJ.RED,this.left=null!=r?r:tJ.EMPTY,this.right=null!=i?i:tJ.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new tJ(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 tJ.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 tJ.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,tJ.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,tJ.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()}}
2tJ.EMPTY=null,tJ.RED=!0,tJ.BLACK=!1,tJ.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 tJ(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 tH(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 tY(this.data.getIterator())}getIteratorFrom(e){return new tY(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 tY{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function tZ(e){return e.hasNext()?e.getNext():void 0}class t0{constructor(e){this.fields=e,e.sort(ei.comparator)}static empty(){return new t0([])}unionWith(e){let t=new tX(ei.comparator);for(let e of this.fields)t=t.add(e);for(let n of e)t=t.add(n);return new t0(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Z(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class t1 extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class t2{constructor(e){this.binaryString=e}static fromBase64String(e){return new t2(function(e){try{return atob(e)}catch(e){throw"u">typeof DOMException&&e instanceof DOMException?new t1("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new t2(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 J(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}t2.EMPTY_BYTE_STRING=new t2("");let t5=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function t3(e){if(L(!!e,39018),"string"==typeof e){let t=0,n=t5.exec(e);if(L(!!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:t4(e.seconds),nanos:t4(e.nanos)}}function t4(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function t6(e){return"string"==typeof e?t2.fromBase64String(e):t2.fromUint8Array(e)}let t8="server_timestamp",t7="__type__",t9="__previous_value__",ne="__local_write_time__";function nt(e){return(e?.mapValue?.fields||{})[t7]?.stringValue===t8}function nn(e){let t=e.mapValue.fields[t9];return nt(t)?nn(t):t}function nr(e){let t=t3(e.mapValue.fields[ne].timestampValue);return new ep(t.seconds,t.nanos)}class ni{constructor(e,t,n,r,i,s,a,o,l,u){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}}let ns="(default)";class na{constructor(e,t){this.projectId=e,this.database=t||ns}static empty(){return new na("","")}get isDefaultDatabase(){return this.database===ns}isEqual(e){return e instanceof na&&e.projectId===this.projectId&&e.database===this.database}}let no="__type__",nl="__max__",nu={mapValue:{fields:{__type__:{stringValue:nl}}}},nh="__vector__",nc="value",nd={nullValue:"NULL_VALUE"};function nf(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?nt(e)?4:nA(e)?0x1fffffffffffff:nx(e)?10:11:O(28295,{value:e})}function nm(e,t){if(e===t)return!0;let n=nf(e);if(n!==nf(t))return!1;switch(n){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return nr(e).isEqual(nr(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=t3(e.timestampValue),i=t3(t.timestampValue);return r.seconds===i.seconds&&r.nanos===i.nanos;case 5:return e.stringValue===t.stringValue;case 6:return t6(e.bytesValue).isEqual(t6(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return t4(e.geoPointValue.latitude)===t4(t.geoPointValue.latitude)&&t4(e.geoPointValue.longitude)===t4(t.geoPointValue.longitude);case 2:if("integerValue"in e&&"integerValue"in t)return t4(e.integerValue)===t4(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let n=t4(e.doubleValue),r=t4(t.doubleValue);return n===r?eH(n)===eH(r):isNaN(n)&&isNaN(r)}return!1;case 9:return Z(e.arrayValue.values||[],t.arrayValue.values||[],nm);case 10:case 11:let s=e.mapValue.fields||{},a=t.mapValue.fields||{};if(tG(s)!==tG(a))return!1;for(let e in s)if(s.hasOwnProperty(e)&&(void 0===a[e]||!nm(s[e],a[e])))return!1;return!0;default:return O(52216,{left:e})}}function ng(e,t){return void 0!==(e.values||[]).find(e=>nm(e,t))}function np(e,t){var n,r,i,s,a,o;if(e===t)return 0;let l=nf(e),u=nf(t);if(l!==u)return J(l,u);switch(l){case 0:case 0x1fffffffffffff:return 0;case 1:return J(e.booleanValue,t.booleanValue);case 2:let h,c;return h=t4(e.integerValue||e.doubleValue),h<(c=t4(t.integerValue||t.doubleValue))?-1:h>c?1:h===c?0:isNaN(h)?isNaN(c)?0:-1:1;case 3:return ny(e.timestampValue,t.timestampValue);case 4:return ny(nr(e),nr(t));case 5:return X(e.stringValue,t.stringValue);case 6:let d,f;return n=e.bytesValue,r=t.bytesValue,d=t6(n),f=t6(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=J(n[e],r[e]);if(0!==t)return t}return J(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:let m;return i=e.geoPointValue,s=t.geoPointValue,0!==(m=J(t4(i.latitude),t4(s.latitude)))?m:J(t4(i.longitude),t4(s.longitude));case 9:return nw(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[nc]?.arrayValue,w=p[nc]?.arrayValue,0!==(v=J(y?.values?.length||0,w?.values?.length||0))?v:nw(y,w);case 11:return function(e,t){if(e===nu.mapValue&&t===nu.mapValue)return 0;if(e===nu.mapValue)return 1;if(t===nu.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=np(n[r[e]],i[s[e]]);if(0!==a)return a}return J(r.length,s.length)}(e.mapValue,t.mapValue);default:throw O(23264,{he:l})}}function ny(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return J(e,t);let n=t3(e),r=t3(t),i=J(n.seconds,r.seconds);return 0!==i?i:J(n.nanos,r.nanos)}function nw(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=np(n[e],r[e]);if(t)return t}return J(n.length,r.length)}function nv(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=t3(e.timestampValue),`time(${r.seconds},${r.nanos}
2)`):"stringValue"in e?e.stringValue:"bytesValue"in e?t6(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,es.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+=nv(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}:${nv(e.fields[i])}`;return n+"}"}(e.mapValue):O(61005,{value:e})}function nb(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function nI(e){return!!e&&"integerValue"in e}function nT(e){return!!e&&"arrayValue"in e}function n_(e){return!!e&&"nullValue"in e}function nE(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function nS(e){return!!e&&"mapValue"in e}function nx(e){return(e?.mapValue?.fields||{})[no]?.stringValue===nh}function nC(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 tK(e.mapValue.fields,(e,n)=>t.mapValue.fields[e]=nC(n)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=nC(e.arrayValue.values[n]);return t}return{...e}}function nA(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===nl}let nD={mapValue:{fields:{[no]:{stringValue:nh},[nc]:{arrayValue:{}}}}};function nN(e,t){let n=np(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function nk(e,t){let n=np(e.value,t.value);return 0!==n?n:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class nM{constructor(e){this.value=e}static empty(){return new nM({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(!nS(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()]=nC(t)}setAll(e){let t=ei.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()]=nC(e):r.push(i.lastSegment())});let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());nS(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return nm(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)];nS(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(tK(t,(t,n)=>e[t]=n),n))delete e[r]}clone(){return new nM(nC(this.value))}}class nR{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 nR(e,0,ey.min(),ey.min(),ey.min(),nM.empty(),0)}static newFoundDocument(e,t,n,r){return new nR(e,1,t,ey.min(),n,r,0)}static newNoDocument(e,t){return new nR(e,2,t,ey.min(),ey.min(),nM.empty(),0)}static newUnknownDocument(e,t){return new nR(e,3,t,ey.min(),ey.min(),nM.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(ey.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=nM.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=nM.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=ey.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 nR&&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 nR(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}})`}}
2class nP{constructor(e,t){this.position=e,this.inclusive=t}}function nO(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()?es.comparator(es.fromName(a.referenceValue),n.key):np(a,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return r}function nF(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(!nm(e.position[n],t.position[n]))return!1;return!0}class nL{constructor(e,t="asc"){this.field=e,this.dir=t}}class nV{}class nq extends nV{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 n$(e,t,n):"array-contains"===t?new nJ(e,n):"in"===t?new nX(e,n):"not-in"===t?new nY(e,n):"array-contains-any"===t?new nZ(e,n):new nq(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new nQ(e,n):new nH(e,n)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(np(t,this.value)):null!==t&&nf(this.value)===nf(t)&&this.matchesComparison(np(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 nU extends nV{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new nU(e,t)}matches(e){return nB(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 nB(e){return"and"===e.op}function nj(e){return"or"===e.op}function nz(e){return nG(e)&&nB(e)}function nG(e){for(let t of e.filters)if(t instanceof nU)return!1;return!0}function nK(e,t){let n=e.filters.concat(t);return nU.create(n,e.op)}class n$ extends nq{constructor(e,t,n){super(e,t,n),this.key=es.fromName(n.referenceValue)}matches(e){let t=es.comparator(e.key,this.key);return this.matchesComparison(t)}}class nQ extends nq{constructor(e,t){super(e,"in",t),this.keys=nW("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class nH extends nq{constructor(e,t){super(e,"not-in",t),this.keys=nW("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function nW(e,t){return(t.arrayValue?.values||[]).map(e=>es.fromName(e.referenceValue))}class nJ extends nq{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return nT(t)&&ng(t.arrayValue,this.value)}}class nX extends nq{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&ng(this.value.arrayValue,t)}}class nY extends nq{constructor(e,t){super(e,"not-in",t)}matches(e){if(ng(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!ng(this.value.arrayValue,t)}}class nZ extends nq{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!nT(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>ng(this.value.arrayValue,e))}}class n0{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 n1(e,t=null,n=[],r=[],i=null,s=null,a=null){return new n0(e,t,n,r,i,s,a)}function n2(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 nq)return t.field.canonicalString()+t.op.toString()+nv(t.value);if(nz(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(","),eQ(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(e=>nv(e)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>nv(e)).join(",")),e.Te=t}return e.Te}function n5(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 nq?n instanceof nq&&t.op===n.op&&t.field.isEqual(n.field)&&nm(t.value,n.value):t instanceof nU?n instanceof nU&&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)&&!!nF(e.startAt,t.startAt)&&nF(e.endAt,t.endAt)}function n3(e){return es.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function n4(e,t){return e.filters.filter(e=>e instanceof nq&&e.field.isEqual(t))}function n6(e,t,n){let r=nd,i=!0;for(let n of n4(e,t)){let e=nd,t=!0;switch(n.op){case"<":case"<=":var s;
2e="nullValue"in(s=n.value)?nd:"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?nb(na.empty(),es.empty()):"geoPointValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in s?{arrayValue:{}}:"mapValue"in s?nx(s)?nD:{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=nd}0>nN({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>nN({value:r,inclusive:i},{value:e,inclusive:n.inclusive})&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}function n8(e,t,n){let r=nu,i=!0;for(let n of n4(e,t)){let e=nu,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?nb(na.empty(),es.empty()):"referenceValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in s?{arrayValue:{}}:"arrayValue"in s?nD:"mapValue"in s?nx(s)?{mapValue:{}}:nu: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=nu}nk({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];nk({value:r,inclusive:i},{value:e,inclusive:n.inclusive})>0&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}class n7{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.de=null,this.startAt,this.endAt}}function n9(e){return new n7(e)}function re(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 rt(e){return null!==e.collectionGroup}function rn(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(ei.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 nL(t,r))}),n.has(ei.keyField().canonicalString())||e.Ie.push(new nL(ei.keyField(),r))}return e.Ie}function rr(e){return e.Ee||(e.Ee=rs(e,rn(e))),e.Ee}function ri(e){return e.de||(e.de=rs(e,e.explicitOrderBy)),e.de}function rs(e,t){if("F"===e.limitType)return n1(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 nL(e.field,t)});let n=e.endAt?new nP(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new nP(e.startAt.position,e.startAt.inclusive):null;return n1(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function ra(e,t){let n=e.filters.concat([t]);return new n7(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function ro(e,t,n){return new n7(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function rl(e,t){return n5(rr(e),rr(t))&&e.limitType===t.limitType}function ru(e){return`${n2(rr(e))}|lt:${e.limitType}`}function rh(e){var t;let n;return`Query(target=${n=(t=rr(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 nq?`${t.field.canonicalString()} ${t.op} ${nv(t.value)}`:t instanceof nU?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),eQ(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=>nv(e)).join(",")),t.endAt&&(n+=", endAt: ",n+=t.endAt.inclusive?"a:":"b:",n+=t.endAt.position.map(e=>nv(e)).join(",")),`Target(${n})`}; limitType=${e.limitType})`}function rc(e,t){var n,r,i,s;let a,o,l;
2return t.isFoundDocument()&&(a=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(a):es.isDocumentKey(e.path)?e.path.isEqual(a):e.path.isImmediateParentOf(a))&&function(e,t){for(let n of rn(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=nO(i,rn(n),r),i.inclusive?!!(o<=0):!!(o<0)))&&(!n.endAt||(s=n.endAt,l=nO(s,rn(n),r),s.inclusive?!!(l>=0):!!(l>0))))}function rd(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function rf(e){return(t,n)=>{let r=!1;for(let i of rn(e)){let e=function(e,t,n){var r;let i,s,a=e.field.isKeyField()?es.comparator(t.key,n.key):(r=e.field,i=t.data.field(r),s=n.data.field(r),null!==i&&null!==s?np(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 rm{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){tK(this.inner,(t,n)=>{for(let[t,r]of n)e(t,r)})}isEmpty(){return tQ(this.inner)}size(){return this.innerSize}}let rg=new tH(es.comparator),rp=new tH(es.comparator);function ry(...e){let t=rp;for(let n of e)t=t.insert(n.key,n);return t}function rw(e){let t=rp;return e.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function rv(){return new rm(e=>e.toString(),(e,t)=>e.isEqual(t))}let rb=new tH(es.comparator),rI=new tX(es.comparator);function rT(...e){let t=rI;for(let n of e)t=t.add(n);return t}let r_=new tX(J);function rE(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:eH(t)?"-0":t}}function rS(e){return{integerValue:""+e}}function rx(e,t){return eW(t)?rS(t):rE(e,t)}class rC{constructor(){this._=void 0}}function rA(e,t){return e instanceof rP?nI(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}class rD extends rC{}class rN extends rC{constructor(e){super(),this.elements=e}}function rk(e,t){let n=rF(t);for(let t of e.elements)n.some(e=>nm(e,t))||n.push(t);return{arrayValue:{values:n}}}class rM extends rC{constructor(e){super(),this.elements=e}}function rR(e,t){let n=rF(t);for(let t of e.elements)n=n.filter(e=>!nm(e,t));return{arrayValue:{values:n}}}class rP extends rC{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function rO(e){return t4(e.integerValue||e.doubleValue)}function rF(e){return nT(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class rL{constructor(e,t){this.field=e,this.transform=t}}class rV{constructor(e,t){this.version=e,this.transformResults=t}}class rq{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new rq}static exists(e){return new rq(void 0,e)}static updateTime(e){return new rq(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 rU(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class rB{}function rj(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new rJ(e.key,rq.none()):new rK(e.key,e.data,rq.none());{let n=e.data,r=nM.empty(),i=new tX(ei.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 r$(e.key,r,new t0(i.toArray()),rq.none())}}function rz(e,t,n,r){return e instanceof rK?function(e,t,n,r){if(!rU(e.precondition,t))return n;let i=e.value.clone(),s=rW(e.fieldTransforms,r,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof r$?function(e,t,n,r){if(!rU(e.precondition,t))return n;let i=rW(e.fieldTransforms,r,t),s=t.data;return(s.setAll(rQ(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):rU(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}function rG(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)&&Z(n,r,(e,t)=>{var n,r;return e.field.isEqual(t.field)&&(n=e.transform,r=t.transform,n instanceof rN&&r instanceof rN||n instanceof rM&&r instanceof rM?Z(n.elements,r.elements,nm):n instanceof rP&&r instanceof rP?nm(n.Ae,r.Ae):n instanceof rD&&r instanceof rD)})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class rK extends rB{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.prec
2ondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class r$ extends rB{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 rQ(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 rH(e,t,n){let r=new Map;L(e.length===n.length,32656,{Re:n.length,Ve: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 rN?rk(o,l):o instanceof rM?rR(o,l):i))}return r}function rW(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 rD?(r=t,i={fields:{[t7]:{stringValue:t8},[ne]:{timestampValue:{seconds:n.seconds,nanos:n.nanoseconds}}}},r&&nt(r)&&(r=nn(r)),r&&(i.fields[t9]=r),{mapValue:i}):e instanceof rN?rk(e,t):e instanceof rM?rR(e,t):(a=rO(s=rA(e,t))+rO(e.Ae),nI(s)&&nI(e.Ae)?rS(a):rE(e.serializer,a))}(e,s,t))}return r}class rJ extends rB{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rX extends rB{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class rY{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 rK?(r=e.value.clone(),i=rH(e.fieldTransforms,t,n.transformResults),r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()):e instanceof r$?function(e,t,n){if(!rU(e.precondition,t))return t.convertToUnknownDocument(n.version);let r=rH(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(rQ(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=rz(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=rz(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=rv();return this.mutations.forEach(r=>{let i=e.get(r.key),s=i.overlayedDocument,a=this.applyToLocalView(s,i.mutatedFields),o=rj(s,a=t.has(r.key)?null:a);null!==o&&n.set(r.key,o),s.isValidDocument()||s.convertToNoDocument(ey.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),rT())}isEqual(e){return this.batchId===e.batchId&&Z(this.mutations,e.mutations,(e,t)=>rG(e,t))&&Z(this.baseMutations,e.baseMutations,(e,t)=>rG(e,t))}}class rZ{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){L(e.mutations.length===n.length,58842,{me:e.mutations.length,fe:n.length});let r=rb,i=e.mutations;for(let e=0;e<i.length;e++)r=r.insert(i[e].key,n[e].version);return new rZ(e,t,n,r)}}class r0{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{ 3 largestBatchId: ${this.largestBatchId}, 4 mutation: ${this.mutation.toString()} 5 }`}}class r1{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}}class r2{constructor(e,t){this.count=e,this.unchangedNames=t}}function r5(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.UNIMPLEMENTED:case V.DATA_LOSS:return!0;default:return O(15467,{code:e})}}function r3(e){if(void 0===e)return M("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;
5case 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 r4=null;function r6(){return new TextEncoder}let r8=new t([0xffffffff,0xffffffff],0);function r7(e){let t=r6().encode(e),r=new n;return r.update(t),new Uint8Array(r.digest())}function r9(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 ie{constructor(e,n,r){if(this.bitmap=e,this.padding=n,this.hashCount=r,n<0||n>=8)throw new it(`Invalid padding: ${n}`);if(r<0||e.length>0&&0===this.hashCount)throw new it(`Invalid hash count: ${r}`);if(0===e.length&&0!==n)throw new it(`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(r8)&&(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]=r9(r7(e));for(let e=0;e<this.hashCount;e++){let r=this.ye(t,n,e);if(!this.we(r))return!1}return!0}
5static create(e,t,n){let r=new ie(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]=r9(r7(e));for(let e=0;e<this.hashCount;e++){let r=this.ye(t,n,e);this.Se(r)}}Se(e){let t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}class it extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class ir{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,ii.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new ir(ey.min(),r,new tH(J),rg,rT())}}class ii{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 ii(n,t,rT(),rT(),rT())}}class is{constructor(e,t,n,r){this.be=e,this.removedTargetIds=t,this.key=n,this.De=r}}class ia{constructor(e,t){this.targetId=e,this.Ce=t}}class io{constructor(e,t,n=t2.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class il{constructor(){this.ve=0,this.Fe=ic(),this.Me=t2.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=rT(),t=rT(),n=rT();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 ii(this.Me,this.xe,e,t,n)}qe(){this.Oe=!1,this.Fe=ic()}Qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}$e(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}Ue(){this.ve+=1}Ke(){this.ve-=1,L(this.ve>=0,3241,{ve:this.ve})}We(){this.Oe=!0,this.xe=!0}}class iu{constructor(e){this.Ge=e,this.ze=new Map,this.je=rg,this.Je=ih(),this.He=ih(),this.Ye=new tH(J)}Ze(e){for(let t of e.be)e.De&&e.De.isFoundDocument()?this.Xe(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.Ke(),n.Ne||n.qe(),n.Le(e.resumeToken);break;case 2:n.Ke(),n.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(n.We(),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(n3(a))if(0===n){let e=new es(a.path);this.et(t,e,nR.newNoDocument(e,ey.min()))}else L(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.Ye=this.Ye.insert(t,2===l?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch")),r4?.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=t6(i).toUint8Array()}catch(e){if(e instanceof t1)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 ie(t,s,a)}catch(e){return R(e instanceof it?"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&&n3(i.target)){let t=new es(i.target.path);this.It(t).has(r)||this.Et(r,t)||this.et(r,t,nR.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.qe())}});let n=rT();this.He.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 ir(e,t,this.Ye,this.je,n);return this.je=rg,this.Je=ih(),this.He=ih(),this.Ye=new tH(J),r}Xe(e,t){if(!this.rt(e))return;
5let n=2*!!this.Et(e,t.key);this.nt(e).Qe(t.key,n),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.He=this.He.insert(t.key,this.dt(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.$e(t),this.He=this.He.insert(t,this.dt(t).delete(e)),this.He=this.He.insert(t,this.dt(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}Ue(e){this.nt(e).Ue()}nt(e){let t=this.ze.get(e);return t||(t=new il,this.ze.set(e,t)),t}dt(e){let t=this.He.get(e);return t||(t=new tX(J),this.He=this.He.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new tX(J),this.Je=this.Je.insert(e,t)),t}rt(e){let t=null!==this.ot(e);return t||k("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 il),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function ih(){return new tH(es.comparator)}function ic(){return new tH(es.comparator)}let id={asc:"ASCENDING",desc:"DESCENDING"},im={"<":"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"},ig={and:"AND",or:"OR"};class ip{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function iy(e,t){return e.useProto3Json||eQ(t)?t:{value:t}}function iw(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 iv(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function ib(e){let t;return L(!!e,49232),ey.fromTimestamp(new ep((t=t3(e)).seconds,t.nanos))}function iI(e,t){return iT(e,t).canonicalString()}function iT(e,t){let n=new en(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?n:n.child(t)}function i_(e){let t=en.fromString(e);return L(iU(t),10190,{key:t.toString()}),t}function iE(e,t){return iI(e.databaseId,t.path)}function iS(e,t){let n=i_(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 es(iD(n))}function ix(e,t){return iI(e.databaseId,t)}function iC(e){let t=i_(e);return 4===t.length?en.emptyPath():iD(t)}function iA(e){return new en(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function iD(e){return L(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function iN(e,t,n){return{name:iE(e,t),fields:n.value.mapValue.fields}}function ik(e,t,n){let r=iS(e,t.name),i=ib(t.updateTime),s=t.createTime?ib(t.createTime):ey.min(),a=new nM({mapValue:{fields:t.fields}}),o=nR.newFoundDocument(r,i,s,a);return n&&o.setHasCommittedMutations(),n?o.setHasCommittedMutations():o}function iM(e,t){var n,r;let i;if(t instanceof rK)i={update:iN(e,t.key,t.value)};else if(t instanceof rJ)i={delete:iE(e,t.key)};else if(t instanceof r$){let n;i={update:iN(e,t.key,t.data),updateMask:(r=t.fieldMask,n=[],r.fields.forEach(e=>n.push(e.canonicalString())),{fieldPaths:n})}}else{if(!(t instanceof rX))return O(16599,{Vt:t.type});i={verify:iE(e,t.key)}}return t.fieldTransforms.length>0&&(i.updateTransforms=t.fieldTransforms.map(e=>(function(e){let t=e.transform;if(t instanceof rD)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof rN)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof rM)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof rP)return{fieldPath:e.field.canonicalString(),increment:t.Ae};throw O(20930,{transform:e.transform})})(e))),t.precondition.isNone||(i.currentDocument=void 0!==(n=t.precondition).updateTime?{updateTime:iw(e,n.updateTime.toTimestamp())}:void 0!==n.exists?{exists:n.exists}:O(27497)),i}function iR(e,t){var n;let r=t.currentDocument?void 0!==(n=t.currentDocument).updateTime?rq.updateTime(ib(n.updateTime)):void 0!==n.exists?rq.exists(n.exists):rq.none():rq.none(),i=t.updateTransforms?t.updateTransforms.map(t=>{let n;
5return n=null,"setToServerValue"in t?(L("REQUEST_TIME"===t.setToServerValue,16630,{proto:t}),n=new rD):"appendMissingElements"in t?n=new rN(t.appendMissingElements.values||[]):"removeAllFromArray"in t?n=new rM(t.removeAllFromArray.values||[]):"increment"in t?n=new rP(e,t.increment):O(16584,{proto:t}),new rL(ei.fromServerFormat(t.fieldPath),n)}):[];if(t.update){t.update.name;let n=iS(e,t.update.name),s=new nM({mapValue:{fields:t.update.fields}});return t.updateMask?new r$(n,s,new t0((t.updateMask.fieldPaths||[]).map(e=>ei.fromServerFormat(e))),r,i):new rK(n,s,r,i)}return t.delete?new rJ(iS(e,t.delete),r):t.verify?new rX(iS(e,t.verify),r):O(1463,{proto:t})}function iP(e,t){return{documents:[ix(e,t.path)]}}function iO(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=ix(e,i);let o=function(e){if(0!==e.length)return function e(t){var n;let r;return t instanceof nq?function(e){if("=="===e.op){if(nE(e.value))return{unaryFilter:{field:iV(e.field),op:"IS_NAN"}};if(n_(e.value))return{unaryFilter:{field:iV(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(nE(e.value))return{unaryFilter:{field:iV(e.field),op:"IS_NOT_NAN"}};if(n_(e.value))return{unaryFilter:{field:iV(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:iV(e.field),op:im[e.op],value:e.value}}}(t):t instanceof nU?1===(r=(n=t).getFilters().map(t=>e(t))).length?r[0]:{compositeFilter:{op:ig[n.op],filters:r}}:O(54877,{filter:t})}(nU.create(e,"and"))}(t.filters);o&&(s.structuredQuery.where=o);let l=function(e){if(0!==e.length)return e.map(e=>({field:iV(e.field),direction:id[e.dir]}))}(t.orderBy);l&&(s.structuredQuery.orderBy=l);let u=iy(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 iF(e,t,n,r){let{ft:i,parent:s}=iO(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:iV(e.fieldPath)}}):"sum"===e.aggregateType&&o.push({alias:t,sum:{field:iV(e.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:o,structuredQuery:i.structuredQuery},parent:i.parent},gt:a,parent:s}}function iL(e){var t,n,r;let i,s,a,o,l=iC(e.parent),u=e.structuredQuery,h=u.from?u.from.length:0,c=null;if(h>0){L(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=iq(e.unaryFilter.field);return nq.create(t,"==",{doubleValue:NaN});case"IS_NULL":let n=iq(e.unaryFilter.field);return nq.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let r=iq(e.unaryFilter.field);return nq.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let i=iq(e.unaryFilter.field);return nq.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return O(61313);default:return O(60726)}}(t):void 0!==t.fieldFilter?nq.create(iq(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?nU.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 nU&&nz(i)?i.getFilters():[i]);let f=[];u.orderBy&&(f=u.orderBy.map(e=>new nL(iq(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let m=null;u.limit&&(m=eQ(s="object"==typeof(t=u.limit)?t.value:t)?null:s);let g=null;u.startAt&&(a=!!(n=u.startAt).before,g=new nP(n.values||[],a));let p=null;return u.endAt&&(o=!(r=u.endAt).before,p=new nP(r.values||[],o)),new n7(l,c,f,d,m,"F",g,p)}function iV(e){return{fieldPath:e.canonicalString()}}function iq(e){return ei.fromServerFormat(e.fieldPath)}function iU(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}class iB{constructor(e,t,n,r,i=ey.min(),s=ey.min(),a=t2.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 iB(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new iB(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new iB(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new iB(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class ij{constructor(e){this.yt=e}}function iz(e,t){let n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:iG(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument()){var i;r.document={name:iE(i=e.yt,t.key),fields:t.data.value.mapValue.fields,updateTime:iw(i,t.version.toTimestamp()),createTime:iw(i,t.createTime.toTimestamp())}}else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:iK(t.ver
5sion)};else{if(!t.isUnknownDocument())return O(57904,{document:t});r.unknownDocument={path:n.path.toArray(),version:iK(t.version)}}return r}function iG(e){let t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function iK(e){let t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function i$(e){let t=new ep(e.seconds,e.nanoseconds);return ey.fromTimestamp(t)}function iQ(e,t){let n=(t.baseMutations||[]).map(t=>iR(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=>iR(e.yt,t)),i=ep.fromMillis(t.localWriteTimeMs);return new rY(t.batchId,i,n,r)}function iH(e){var t;let n,r=i$(e.readTime),i=void 0!==e.lastLimboFreeSnapshotVersion?i$(e.lastLimboFreeSnapshotVersion):ey.min();return new iB(void 0!==e.query.documents?(L(1===(n=(t=e.query).documents.length),1966,{count:n}),rr(n9(iC(t.documents[0])))):rr(iL(e.query)),e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,r,i,t2.fromBase64String(e.resumeToken))}function iW(e,t){let n,r=iK(t.snapshotVersion),i=iK(t.lastLimboFreeSnapshotVersion);n=n3(t.target)?iP(e.yt,t.target):iO(e.yt,t.target).ft;let s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:n2(t.target),readTime:r,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:i,query:n}}function iJ(e){let t=iL({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?ro(t,t.limit,"L"):t}function iX(e,t){return new r0(t.largestBatchId,iR(e.yt,t.overlayMutation))}function iY(e,t){let n=t.path.lastSegment();return[e,eJ(t.path.popLast()),n]}function iZ(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:iK(r.readTime),documentKey:eJ(r.documentKey.path),largestBatchId:r.largestBatchId}}class i0{getBundleMetadata(e,t){return tz(e,tw).get(t).next(e=>{if(e)return{id:e.bundleId,createTime:i$(e.createTime),version:e.version}})}saveBundleMetadata(e,t){return tz(e,tw).put({bundleId:t.id,createTime:iK(ib(t.createTime)),version:t.version})}getNamedQuery(e,t){return tz(e,tv).get(t).next(e=>{if(e)return{name:e.name,query:iJ(e.bundledQuery),readTime:i$(e.readTime)}})}saveNamedQuery(e,t){return tz(e,tv).put({name:t.name,readTime:iK(ib(t.readTime)),bundledQuery:t.bundledQuery})}}class i1{constructor(e,t){this.serializer=e,this.userId=t}static wt(e,t){return new i1(e,t.uid||"")}getOverlay(e,t){return tz(e,tN).get(iY(this.userId,t)).next(e=>e?iX(this.serializer,e):null)}getOverlays(e,t){let n=rv();return ek.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 r0(t,i);r.push(this.St(e,s))}),ek.waitFor(r)}removeOverlaysForBatchId(e,t,n){let r=new Set;t.forEach(e=>r.add(eJ(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(tz(e,tN).Z(tM,r))}),ek.waitFor(i)}getOverlaysForCollection(e,t,n){let r=rv(),i=eJ(t),s=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,1/0],!0);return tz(e,tN).J(tM,s).next(e=>{for(let t of e){let e=iX(this.serializer,t);r.set(e.getKey(),e)}return r})}getOverlaysForCollectionGroup(e,t,n,r){let i,s=rv(),a=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,1/0],!0);return tz(e,tN).ee({index:tP,range:a},(e,t,n)=>{let a=iX(this.serializer,t);s.size()<r||a.largestBatchId===i?(s.set(a.getKey(),a),i=a.largestBatchId):n.done()}).next(()=>s)}St(e,t){return tz(e,tN).put(function(e,t,n){let[r,i,s]=iY(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:iM(e.yt,n.mutation)}}(this.serializer,this.userId,t))}}class i2{bt(e){return tz(e,tF)}getSessionToken(e){return this.bt(e).get("sessionToken").next(e=>{let t=e?.value;return t?t2.fromUint8Array(t):t2.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.bt(e).put({name:"sessionToken",value:t.toUint8Array()})}}class i5{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(t4(e.integerValue));else if("doubleValue"in e){let n=t4(e.doubleValue);isNaN(n)?this.Ft(t,13):(this.Ft(t,15),eH(n)?t.Mt(0):t.Mt(n))}else if("timestampValue"in e){let n=e.timestampValue;this.Ft(t,20),"string"==typeof n&&(n=t3(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(t6(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?nA(e)?this.Ft(t,Number.MAX_SAFE_INTEGER):nx(e)?this.kt(e.mapValue,t):(this.qt(e.mapValue,t),this.Nt(t)):"arrayValue"in e?(this.Qt(e.arrayValue,t),this.Nt(t)):O(19022,{$t:e})}Ot(e,t){this.Ft(t,25),this.Ut(e,t)}Ut(e,t){t.xt(e)}qt(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[nc].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(t4(r)),this.Ot(nc,t),this.Ct(n[nc],t)}Qt(e,t){let n=e.values||[];for(let e of(this.Ft(t,50),n))this.Ct(e,t)}
5Lt(e,t){this.Ft(t,37),es.fromName(e).path.forEach(e=>{this.Ft(t,60),this.Ut(e,t)})}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}}function i3(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)}i5.Kt=new i5;class i4{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Wt(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.Jt(n.value),n=t.next();this.Ht()}Yt(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()}Zt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Jt(e);else if(e<2048)this.Jt(960|e>>>6),this.Jt(128|63&e);else if(t<"\uD800"||"\uDBFF"<t)this.Jt(480|e>>>12),this.Jt(128|63&e>>>6),this.Jt(128|63&e);else{let e=t.codePointAt(0);this.Jt(240|e>>>18),this.Jt(128|63&e>>>12),this.Jt(128|63&e>>>6),this.Jt(128|63&e)}}this.Ht()}Xt(e){let t=this.en(e),n=i3(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=i3(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)}Jt(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)}Ht(){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 i6{constructor(e){this.cn=e}Bt(e){this.cn.Wt(e)}xt(e){this.cn.Yt(e)}Mt(e){this.cn.Xt(e)}vt(){this.cn.rn()}}class i8{constructor(e){this.cn=e}Bt(e){this.cn.jt(e)}xt(e){this.cn.Zt(e)}Mt(e){this.cn.nn(e)}vt(){this.cn._n()}}class i7{constructor(){this.cn=new i4,this.ln=new i6(this.cn),this.hn=new i8(this.cn)}seed(e){this.cn.seed(e)}Pn(e){return 0===e?this.ln:this.hn}un(){return this.cn.un()}reset(){this.cn.reset()}}class i9{constructor(e,t,n,r){this.Tn=e,this.In=t,this.En=n,this.dn=r}An(){let e=this.dn.length,t=0===e||255===this.dn[e-1]?e+1:e,n=new Uint8Array(t);return n.set(this.dn,0),t!==e?n.set([0],this.dn.length):++n[n.length-1],new i9(this.Tn,this.In,this.En,n)}Rn(e,t,n){return{indexId:this.Tn,uid:e,arrayValue:sn(this.En),directionalValue:sn(this.dn),orderedDocumentKey:sn(t),documentKey:n.path.toArray()}}Vn(e,t,n){let r=this.Rn(e,t,n);return[r.indexId,r.uid,r.arrayValue,r.directionalValue,r.orderedDocumentKey,r.documentKey]}}function se(e,t){let n=e.Tn-t.Tn;return 0!==n||0!==(n=st(e.En,t.En))||0!==(n=st(e.dn,t.dn))?n:es.comparator(e.In,t.In)}function st(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 sn(e){return(0,b.isSafariOrWebkit)()?function(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}(e):e}function sr(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 si{constructor(e){for(const t of(this.mn=new tX((e,t)=>ei.comparator(e.field,t.field)),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.fn=e.orderBy,this.gn=[],e.filters))t.isInequality()?this.mn=this.mn.add(t):this.gn.push(t)}get pn(){return this.mn.size>1}yn(e){if(L(e.collectionGroup===this.collectionId,49279),this.pn)return!1;let t=ev(e);
5if(void 0!==t&&!this.wn(t))return!1;let n=eb(e),r=new Set,i=0,s=0;for(;i<n.length&&this.wn(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;if(this.mn.size>0){let e=this.mn.getIterator().getNext();if(!r.has(e.field.canonicalString())){let t=n[i];if(!this.Sn(e,t)||!this.bn(this.fn[s++],t))return!1}++i}for(;i<n.length;++i){let e=n[i];if(s>=this.fn.length||!this.bn(this.fn[s++],e))return!1}return!0}Dn(){if(this.pn)return null;let e=new tX(ei.comparator),t=[];for(let n of this.gn)if(!n.field.isKeyField())if("array-contains"===n.op||"array-contains-any"===n.op)t.push(new eT(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new eT(n.field,0))}for(let n of this.fn)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new eT(n.field,+("asc"!==n.dir))));return new ew(ew.UNKNOWN_ID,this.collectionId,t,e_.empty())}wn(e){for(let t of this.gn)if(this.Sn(t,e))return!0;return!1}Sn(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}bn(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function ss(e){return e instanceof nq}function sa(e){return e instanceof nU&&nz(e)}function so(e){return ss(e)||sa(e)||function(e){if(e instanceof nU&&nj(e)){for(let t of e.getFilters())if(!ss(t)&&!sa(t))return!1;return!0}return!1}(e)}function sl(e,t){return L(e instanceof nq||e instanceof nU,38388),L(t instanceof nq||t instanceof nU,25473),sh(e instanceof nq?t instanceof nq?nU.create([e,t],"and"):su(e,t):t instanceof nq?su(t,e):function(e,t){if(L(e.filters.length>0&&t.filters.length>0,48005),nB(e)&&nB(t))return nK(e,t.getFilters());let n=nj(e)?e:t,r=nj(e)?t:e,i=n.filters.map(e=>sl(e,r));return nU.create(i,"or")}(e,t))}function su(e,t){if(nB(t))return nK(t,e.getFilters());{let n=t.filters.map(t=>sl(e,t));return nU.create(n,"or")}}function sh(e){if(L(e instanceof nq||e instanceof nU,11850),e instanceof nq)return e;let t=e.getFilters();if(1===t.length)return sh(t[0]);if(nG(e))return e;let n=t.map(e=>sh(e)),r=[];return n.forEach(t=>{t instanceof nq?r.push(t):t instanceof nU&&(t.op===e.op?r.push(...t.filters):r.push(t))}),1===r.length?r[0]:nU.create(r,e.op)}class sc{constructor(){this.Cn=new sd}addToCollectionParentIndex(e,t){return this.Cn.add(t),ek.resolve()}getCollectionParents(e,t){return ek.resolve(this.Cn.getEntries(t))}addFieldIndex(e,t){return ek.resolve()}deleteFieldIndex(e,t){return ek.resolve()}deleteAllFieldIndexes(e){return ek.resolve()}createTargetIndexes(e,t){return ek.resolve()}getDocumentsMatchingTarget(e,t){return ek.resolve(null)}getIndexType(e,t){return ek.resolve(0)}getFieldIndexes(e,t){return ek.resolve([])}getNextCollectionGroupToUpdate(e){return ek.resolve(null)}getMinOffset(e,t){return ek.resolve(ex.min())}getMinOffsetFromCollectionGroup(e,t){return ek.resolve(ex.min())}updateCollectionGroup(e,t,n){return ek.resolve()}updateIndexEntries(e,t){return ek.resolve()}}class sd{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new tX(en.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(en.comparator)).toArray()}}let sf="IndexedDbIndexManager",sm=new Uint8Array(0);class sg{constructor(e,t){this.databaseId=t,this.vn=new sd,this.Fn=new rm(e=>n2(e),(e,t)=>n5(e,t)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.vn.has(t)){let n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.vn.add(t)});let i={collectionId:n,parent:eJ(r)};return tz(e,tg).put(i)}return ek.resolve()}getCollectionParents(e,t){let n=[],r=IDBKeyRange.bound([t,""],[t+"\0",""],!1,!0);return tz(e,tg).J(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=tz(e,tb),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=tz(e,tT);return i.next(e=>{n.put(iZ(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){let n=tz(e,tb),r=tz(e,tT),i=tz(e,tx);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=tz(e,tb),n=tz(e,tx),r=tz(e,tT);return t.Z().next(()=>n.Z()).next(()=>r.Z())}
5createTargetIndexes(e,t){return ek.forEach(this.Mn(t),t=>this.getIndexType(e,t).next(n=>{if(0===n||1===n){let n=new si(t).Dn();if(null!=n)return this.addFieldIndex(e,n)}}))}getDocumentsMatchingTarget(e,t){let n=tz(e,tx),r=!0,i=new Map;return ek.forEach(this.Mn(t),t=>this.xn(e,t).next(e=>{r&&(r=!!e),i.set(t,e)})).next(()=>{if(r){let e=rT(),r=[];return ek.forEach(i,(i,s)=>{k(sf,`Using index id=${i.indexId}|cg=${i.collectionGroup}|f=${i.fields.map(e=>`${e.fieldPath}:${e.kind}`).join(",")} to execute ${n2(t)}`);let a=function(e,t){let n=ev(t);if(void 0===n)return null;for(let t of n4(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 eb(t))for(let t of n4(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 eb(t)){let t=0===i.kind?n6(e,i.fieldPath,e.startAt):n8(e,i.fieldPath,e.startAt);n.push(t.value),r&&(r=t.inclusive)}return new nP(n,r)}(s,i),u=function(e,t){let n=[],r=!0;for(let i of eb(t)){let t=0===i.kind?n8(e,i.fieldPath,e.endAt):n6(e,i.fieldPath,e.endAt);n.push(t.value),r&&(r=t.inclusive)}return new nP(n,r)}(s,i),h=this.On(i,s,l),c=this.On(i,s,u),d=this.Nn(i,s,o),f=this.Bn(i.indexId,a,h,l.inclusive,c,u.inclusive,d);return ek.forEach(f,i=>n.Y(i,t.limit).next(t=>{t.forEach(t=>{let n=es.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))})}))}).next(()=>r)}return ek.resolve(null)})}Mn(e){let t=this.Fn.get(e);return t||(t=0===e.filters.length?[e]:(function(e){if(0===e.getFilters().length)return[];let t=function e(t){if(L(t instanceof nq||t instanceof nU,34018),t instanceof nq)return t;if(1===t.filters.length)return e(t.filters[0]);let n=t.filters.map(t=>e(t)),r=nU.create(n,t.op);return so(r=sh(r))?r:(L(r instanceof nU,64498),L(nB(r),40251),L(r.filters.length>1,57927),r.filters.reduce((e,t)=>sl(e,t)))}(function e(t){if(L(t instanceof nq||t instanceof nU,20012),t instanceof nq){if(t instanceof nX){let e=t.value.arrayValue?.values?.map(e=>nq.create(t.field,"==",e))||[];return nU.create(e,"or")}return t}let n=t.filters.map(t=>e(t));return nU.create(n,t.op)}(e));return L(so(t),7391),ss(t)||sa(t)?[t]:t.getFilters()})(nU.create(e.filters,"and")).map(t=>n1(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)),this.Fn.set(e,t)),t}Bn(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.Ln(t[h/l]):sm,c=this.kn(e,o,n[h%l],r),d=this.qn(e,o,i[h%l],s),f=a.map(t=>this.kn(e,o,t,!0));u.push(...this.createRange(c,d,f))}return u}kn(e,t,n,r){let i=new i9(e,es.empty(),t,n);return r?i:i.An()}qn(e,t,n,r){let i=new i9(e,es.empty(),t,n);return r?i.An():i}xn(e,t){let n=new si(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.yn(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t})}getIndexType(e,t){let n=2,r=this.Mn(t);return ek.forEach(r,t=>this.xn(e,t).next(e=>{e?0!==n&&e.fields.length<function(e){let t=new tX(ei.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)}Qn(e,t){let n=new i7;for(let r of eb(e)){let e=t.data.field(r.fieldPath);if(null==e)return null;let i=n.Pn(r.kind);i5.Kt.Dt(e,i)}return n.un()}Ln(e){let t=new i7;return i5.Kt.Dt(e,t.Pn(0)),t.un()}$n(e,t){let n,r=new i7;return i5.Kt.Dt(nb(this.databaseId,t),r.Pn(0===(n=eb(e)).length?0:n[n.length-1].kind)),r.un()}Nn(e,t,n){if(null===n)return[];let r=[];r.push(new i7);let i=0;for(let s of eb(e)){let e=n[i++];for(let n of r)if(this.Un(t,s.fieldPath)&&nT(e))r=this.Kn(r,s,e);else{let t=n.Pn(s.kind);i5.Kt.Dt(e,t)}}return this.Wn(r)}
5On(e,t,n){return this.Nn(e,t,n.position)}Wn(e){let t=[];for(let n=0;n<e.length;++n)t[n]=e[n].un();return t}Kn(e,t,n){let r=[...e],i=[];for(let e of n.arrayValue.values||[])for(let n of r){let r=new i7;r.seed(n.un()),i5.Kt.Dt(e,r.Pn(t.kind)),i.push(r)}return i}Un(e,t){return!!e.filters.find(e=>e instanceof nq&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op))}getFieldIndexes(e,t){let n=tz(e,tb),r=tz(e,tT);return(t?n.J(tI,IDBKeyRange.bound(t,t)):n.J()).next(e=>{let t=[];return ek.forEach(e,e=>r.get([e.indexId,this.uid]).next(n=>{let r,i;t.push((r=n?new e_(n.sequenceNumber,new ex(i$(n.readTime),new es(eX(n.documentKey)),n.largestBatchId)):e_.empty(),i=e.fields.map(([e,t])=>new eT(ei.fromServerFormat(e),t)),new ew(e.indexId,e.collectionGroup,i,r)))})).next(()=>t)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(e=>0===e.length?null:(e.sort((e,t)=>{let n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:J(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(e,t,n){let r=tz(e,tb),i=tz(e,tT);return this.Gn(e).next(e=>r.J(tI,IDBKeyRange.bound(t,t)).next(t=>
5ek.forEach(t,t=>i.put(iZ(t.indexId,this.uid,e,n)))))}updateIndexEntries(e,t){let n=new Map;return ek.forEach(t,(t,r)=>{let i=n.get(t.collectionGroup);return(i?ek.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next(i=>(n.set(t.collectionGroup,i),ek.forEach(i,n=>this.zn(e,t,n).next(t=>{let i=this.jn(r,n);return t.isEqual(i)?ek.resolve():this.Jn(e,r,n,t,i)}))))})}Hn(e,t,n,r){return tz(e,tx).put(r.Rn(this.uid,this.$n(n,t.key),t.key))}Yn(e,t,n,r){return tz(e,tx).delete(r.Vn(this.uid,this.$n(n,t.key),t.key))}zn(e,t,n){let r=tz(e,tx),i=new tX(se);return r.ee({index:tA,range:IDBKeyRange.only([n.indexId,this.uid,sn(this.$n(n,t))])},(e,r)=>{i=i.add(new i9(n.indexId,t,sr(r.arrayValue),sr(r.directionalValue)))}).next(()=>i)}jn(e,t){let n=new tX(se),r=this.Qn(t,e);if(null==r)return n;let i=ev(t);if(null!=i){let s=e.data.field(i.fieldPath);if(nT(s))for(let i of s.arrayValue.values||[])n=n.add(new i9(t.indexId,e.key,this.Ln(i),r))}else n=n.add(new i9(t.indexId,e.key,sm,r));return n}Jn(e,t,n,r,i){k(sf,"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=tZ(s),l=tZ(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=tZ(a)):t?(i(o),o=tZ(s)):(o=tZ(s),l=tZ(a))}}(r,i,se,r=>{s.push(this.Hn(e,t,n,r))},r=>{s.push(this.Yn(e,t,n,r))}),ek.waitFor(s)}Gn(e){let t=1;return tz(e,tT).ee({index:tE,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)=>se(e,t)).filter((e,t,n)=>!t||0!==se(e,n[t-1]));let r=[];for(let i of(r.push(e),n)){let n=se(i,e),s=se(i,t);if(0===n)r[0]=e.An();else if(n>0&&s<0)r.push(i),r.push(i.An());else if(s>0)break}r.push(t);let i=[];for(let e=0;e<r.length;e+=2){if(this.Zn(r[e],r[e+1]))return[];let t=r[e].Vn(this.uid,sm,es.empty()),n=r[e+1].Vn(this.uid,sm,es.empty());i.push(IDBKeyRange.bound(t,n))}return i}Zn(e,t){return se(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(sp)}getMinOffset(e,t){return ek.mapArray(this.Mn(t),t=>this.xn(e,t).next(e=>e||O(44426))).next(sp)}}function sp(e){L(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>eC(i,t)&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new ex(t.readTime,t.documentKey,n)}let sy={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class sw{static withCacheSize(e){return new sw(e,sw.DEFAULT_COLLECTION_PERCENTILE,sw.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}}function sv(e,t,n){let r=e.store(e2),i=e.store(e8),s=[],a=IDBKeyRange.only(n.batchId),o=0,l=r.ee({range:a},(e,t,n)=>(o++,n.delete()));s.push(l.next(()=>{L(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,eJ(h),c]);s.push(i.delete(r)),u.push(e.key)}return ek.waitFor(s).next(()=>u)}function sb(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}sw.DEFAULT_COLLECTION_PERCENTILE=10,sw.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,sw.DEFAULT=new sw(0x2800000,sw.DEFAULT_COLLECTION_PERCENTILE,sw.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),sw.DISABLED=new sw(-1,0,0);class sI{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.Xn={}}static wt(e,t,n,r){return L(""!==e.uid,64387),new sI(e.isAuthenticated()?e.uid:"",t,n,r)}checkEmpty(e){let t=!0,n=IDBKeyRange.bound([this.userId,-1/0],[this.userId,1/0]);return s_(e).ee({index:e3,range:n},(e,n,r)=>{t=!1,r.done()}).next(()=>t)}addMutationBatch(e,t,n,r){let i=tz(e,e8),s=s_(e);return s.add({}).next(a=>{var o,l,u,h;let c,d;L("number"==typeof a,49019);let f=new rY(a,t,n,r),m=(o=this.serializer,l=this.userId,c=f.baseMutations.map(e=>iM(o.yt,e)),d=f.mutations.map(e=>iM(o.yt,e)),{userId:l,batchId:f.batchId,localWriteTimeMs:f.localWriteTime.toMillis(),baseMutations:c,mutations:d}),g=[],p=new tX((e,t)=>J(e.canonicalString(),t.canonicalString()));
5for(let e of r){let t=(u=this.userId,h=e.key.path,[u,eJ(h),a]);p=p.add(e.key.path.popLast()),g.push(s.put(m)),g.push(i.put(t,e6))}return p.forEach(t=>{g.push(this.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(()=>{this.Xn[a]=f.keys()}),ek.waitFor(g).next(()=>f)})}lookupMutationBatch(e,t){return s_(e).get(t).next(e=>e?(L(e.userId===this.userId,48,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),iQ(this.serializer,e)):null)}er(e,t){return this.Xn[t]?ek.resolve(this.Xn[t]):this.lookupMutationBatch(e,t).next(e=>{if(e){let n=e.keys();return this.Xn[t]=n,n}return null})}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]),i=null;return s_(e).ee({index:e3,range:r},(e,t,r)=>{t.userId===this.userId&&(L(t.batchId>=n,47524,{tr:n}),i=iQ(this.serializer,t)),r.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){let t=IDBKeyRange.upperBound([this.userId,1/0]),n=-1;return s_(e).ee({index:e3,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 s_(e).J(e3,t).next(e=>e.map(e=>iQ(this.serializer,e)))}getAllMutationBatchesAffectingDocumentKey(e,t){let n=[this.userId,eJ(t.path)],r=IDBKeyRange.lowerBound(n),i=[];return tz(e,e8).ee({range:r},(n,r,s)=>{let[a,o,l]=n,u=eX(o);if(a===this.userId&&t.path.isEqual(u))return s_(e).get(l).next(e=>{if(!e)throw O(61480,{nr:n,batchId:l});L(e.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:e.userId,batchId:l}),i.push(iQ(this.serializer,e))});s.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tX(J),r=[];return t.forEach(t=>{let i=[this.userId,eJ(t.path)],s=IDBKeyRange.lowerBound(i),a=tz(e,e8).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)}),ek.waitFor(r).next(()=>this.rr(e,n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=[this.userId,eJ(n)],s=IDBKeyRange.lowerBound(i),a=new tX(J);return tz(e,e8).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.rr(e,a))}rr(e,t){let n=[],r=[];return t.forEach(t=>{r.push(s_(e).get(t).next(e=>{if(null===e)throw O(35274,{batchId:t});L(e.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),n.push(iQ(this.serializer,e))}))}),ek.waitFor(r).next(()=>n)}removeMutationBatch(e,t){return sv(e.le,this.userId,t).next(n=>(e.addOnCommittedListener(()=>{this.ir(t.batchId)}),ek.forEach(n,t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))}ir(e){delete this.Xn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>{if(!t)return ek.resolve();let n=IDBKeyRange.lowerBound([this.userId]),r=[];return tz(e,e8).ee({range:n},(e,t,n)=>{if(e[0]===this.userId){let t=eX(e[1]);r.push(t)}else n.done()}).next(()=>{L(0===r.length,56720,{sr:r.map(e=>e.canonicalString())})})})}containsKey(e,t){return sT(e,this.userId,t)}_r(e){return tz(e,e1).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function sT(e,t,n){let r=[t,eJ(n.path)],i=r[1],s=IDBKeyRange.lowerBound(r),a=!1;return tz(e,e8).ee({range:s,X:!0},(e,n,r)=>{let[s,o,l]=e;s===t&&o===i&&(a=!0),r.done()}).next(()=>a)}function s_(e){return tz(e,e2)}class sE{constructor(e){this.ar=e}next(){return this.ar+=2,this.ar}static ur(){return new sE(0)}static cr(){return new sE(-1)}}class sS{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.lr(e).next(t=>{let n=new sE(t.highestTargetId);return t.highestTargetId=n.next(),this.hr(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.lr(e).next(e=>ey.fromTimestamp(new ep(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.lr(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(e,t,n){return this.lr(e).next(r=>(r.highestListenSequenceNumber=t,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.hr(e,r)))}addTargetData(e,t){return this.Pr(e,t).next(()=>this.lr(e).next(n=>(n.targetCount+=1,this.Tr(t,n),this.hr(e,n))))}updateTargetData(e,t){return this.Pr(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>tz(e,ta).delete(t.targetId)).next(()=>this.lr(e)).next(t=>(L(t.targetCount>0,8065),t.targetCount-=1,this.hr(e,t)))}removeTargets(e,t,n){let r=0,i=[];return tz(e,ta).ee((s,a)=>{let o=iH(a);o.sequenceNumber<=t&&null===n.get(o.targetId)&&(r++,i.push(this.removeTargetData(e,o)))}).next(()=>ek.waitFor(i)).next(()=>r)}forEachTarget(e,t){return tz(e,ta).ee((e,n)=>{t(iH(n))})}lr(e){return tz(e,tm).get(tf).next(e=>(L(null!==e,2888),e))}hr(e,t){return tz(e,tm).put(tf,t)}Pr(e,t){return tz(e,ta).put(iW(this.serializer,t))}Tr(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.lr(e).next(e=>e.targetCount)}getTargetData(e,t){let n=n2(t),r=IDBKeyRange.bound([n,-1/0],[n,1/0]),i=null;return tz(e,ta).ee({range:r,index:to},(e,n,r)=>{let s=iH(n);n5(t,s.target)&&(i=s,r.done())}).next(()=>i)}addMatchingKeys(e,t,n){let r=[],i=sx(e);return t.forEach(t=>{let s=eJ(t.path);r.push(i.put({targetId:n,path:s})),r.push(this.referenceDelegate.addReference(e,n,t))}),ek.waitFor(r)}removeMatchingKeys(e,t,n){let r=sx(e);
5return ek.forEach(t,t=>{let i=eJ(t.path);return ek.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])})}removeMatchingKeysForTargetId(e,t){let n=sx(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=sx(e),i=rT();return r.ee({range:n,X:!0},(e,t,n)=>{let r=new es(eX(e[1]));i=i.add(r)}).next(()=>i)}containsKey(e,t){let n=eJ(t.path),r=IDBKeyRange.bound([n],[n+"\0"],!1,!0),i=0;return sx(e).ee({index:tc,X:!0,range:r},([e,t],n,r)=>{0!==e&&(i++,r.done())}).next(()=>i>0)}At(e,t){return tz(e,ta).get(t).next(e=>e?iH(e):null)}}function sx(e){return tz(e,tu)}let sC="LruGarbageCollector";function sA([e,t],[n,r]){let i=J(e,n);return 0===i?J(t,r):i}class sD{constructor(e){this.Ir=e,this.buffer=new tX(sA),this.Er=0}dr(){return++this.Er}Ar(e){let t=[e,this.dr()];if(this.buffer.size<this.Ir)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>sA(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class sN{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Rr=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Vr(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return null!==this.Rr}Vr(e){k(sC,`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){eV(e)?k(sC,"Ignoring IndexedDB error during garbage collection: ",e):await eN(e)}await this.Vr(3e5)})}}class sk{constructor(e,t){this.mr=e,this.params=t}calculateTargetCount(e,t){return this.mr.gr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return ek.resolve(e$.ce);let n=new sD(t);return this.mr.forEachTarget(e,e=>n.Ar(e.sequenceNumber)).next(()=>this.mr.pr(e,e=>n.Ar(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.mr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.mr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(k("LruGarbageCollector","Garbage collection skipped; disabled"),ek.resolve(sy)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(k("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),sy):this.yr(e,t))}getCacheSize(e){return this.mr.getCacheSize(e)}yr(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?(k("LruGarbageCollector",`Capping 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(),N()<=v.LogLevel.DEBUG&&k("LruGarbageCollector",`LRU Garbage Collection 6 Counted targets in ${s-u}ms 7 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`),ek.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e})))}}class sM{constructor(e,t){this.db=e,this.garbageCollector=function(e,t){return new sk(e,t)}(this,t)}gr(e){let t=this.wr(e);return this.db.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}wr(e){let t=0;return this.pr(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}pr(e,t){return this.Sr(e,(e,n)=>t(n))}addReference(e,t,n){return sR(e,n)}removeReference(e,t,n){return sR(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return sR(e,t)}br(e,t){let n;return n=!1,tz(e,e1).te(r=>sT(e,r,t).next(e=>(e&&(n=!0),ek.resolve(!e)))).next(()=>n)}removeOrphanedDocuments(e,t){let n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[],i=0;return this.Sr(e,(s,a)=>
7{if(a<=t){let t=this.br(e,s).next(t=>{if(!t)return i++,n.getEntry(e,s).next(()=>(n.removeEntry(s,ey.min()),sx(e).delete([0,eJ(s.path)])))});r.push(t)}}).next(()=>ek.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 sR(e,t)}Sr(e,t){let n=sx(e),r,i=e$.ce;return n.ee({index:tc},([e,n],{path:s,sequenceNumber:a})=>{0===e?(i!==e$.ce&&t(new es(eX(r)),i),i=a,r=s):i=e$.ce}).next(()=>{i!==e$.ce&&t(new es(eX(r)),i)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function sR(e,t){var n;return sx(e).put((n=e.currentSequenceNumber,{targetId:0,path:eJ(t.path),sequenceNumber:n}))}class sP{constructor(){this.changes=new rm(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,nR.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return void 0!==n?ek.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 sO{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return tz(e,e7).put(n)}removeEntry(e,t,n){let r;return tz(e,e7).delete([(r=t.path.toArray()).slice(0,r.length-2),r[r.length-2],iG(n),r[r.length-1]])}updateMetadata(e,t){return this.getMetadata(e).next(n=>(n.byteSize+=t,this.Dr(e,n)))}getEntry(e,t){let n=nR.newInvalidDocument(t);return tz(e,e7).ee({index:te,range:IDBKeyRange.only(sL(t))},(e,r)=>{n=this.Cr(t,r)}).next(()=>n)}vr(e,t){let n={size:0,document:nR.newInvalidDocument(t)};return tz(e,e7).ee({index:te,range:IDBKeyRange.only(sL(t))},(e,r)=>{n={document:this.Cr(t,r),size:sb(r)}}).next(()=>n)}getEntries(e,t){let n=rg;return this.Fr(e,t,(e,t)=>{let r=this.Cr(e,t);n=n.insert(e,r)}).next(()=>n)}Mr(e,t){let n=rg,r=new tH(es.comparator);return this.Fr(e,t,(e,t)=>{let i=this.Cr(e,t);n=n.insert(e,i),r=r.insert(e,sb(t))}).next(()=>({documents:n,Or:r}))}Fr(e,t,n){if(t.isEmpty())return ek.resolve();let r=new tX(sq);t.forEach(e=>r=r.add(e));let i=IDBKeyRange.bound(sL(r.first()),sL(r.last())),s=r.getIterator(),a=s.getNext();return tz(e,e7).ee({index:te,range:i},(e,t,r)=>{let i=es.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;a&&0>sq(a,i);)n(a,null),a=s.getNext();a&&a.isEqual(i)&&(n(a,t),a=s.hasNext()?s.getNext():null),a?r.j(sL(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(),iG(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 tz(e,e7).J(IDBKeyRange.bound(a,o,!0)).next(e=>{i?.incrementDocumentReadCount(e.length);let n=rg;for(let i of e){let e=this.Cr(es.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);e.isFoundDocument()&&(rc(t,e)||r.has(e.key))&&(n=n.insert(e.key,e))}return n})}getAllFromCollectionGroup(e,t,n,r){let i=rg,s=sV(t,n),a=sV(t,ex.max());return tz(e,e7).ee({index:tn,range:IDBKeyRange.bound(s,a,!0)},(e,t,n)=>{let s=this.Cr(es.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 sF(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return tz(e,ti).get(ts).next(e=>(L(!!e,20021),e))}Dr(e,t){return tz(e,ti).put(ts,t)}Cr(e,t){if(t){let e=function(e,t){var n;let r,i;if(t.document)r=ik(e.yt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){let e=es.fromSegments(t.noDocument.path),n=i$(t.noDocument.readTime);r=nR.newNoDocument(e,n),t.hasCommittedMutations&&r.setHasCommittedMutations()}else{if(!t.unknownDocument)return O(56709);{let e=es.fromSegments(t.unknownDocument.path),n=i$(t.unknownDocument.version);r=nR.newUnknownDocument(e,n)}}return t.readTime&&r.setReadTime((i=new ep((n=t.readTime)[0],n[1]),ey.fromTimestamp(i))),r}(this.serializer,t);if(!(e.isNoDocument()&&e.version.isEqual(ey.min())))return e}return nR.newInvalidDocument(e)}}class sF extends sP{constructor(e,t){super(),this.Nr=e,this.trackRemovals=t,this.Br=new rm(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(e){let t=[],n=0,r=new tX((e,t)=>J(e.canonicalString(),t.canonicalString()));
7return this.changes.forEach((i,s)=>{let a=this.Br.get(i);if(t.push(this.Nr.removeEntry(e,i,a.readTime)),s.isValidDocument()){let o=iz(this.Nr.serializer,s);r=r.add(i.path.popLast());let l=sb(o);n+=l-a.size,t.push(this.Nr.addEntry(e,i,o))}else if(n-=a.size,this.trackRemovals){let n=iz(this.Nr.serializer,s.convertToNoDocument(ey.min()));t.push(this.Nr.addEntry(e,i,n))}}),r.forEach(n=>{t.push(this.Nr.indexManager.addToCollectionParentIndex(e,n))}),t.push(this.Nr.updateMetadata(e,n)),ek.waitFor(t)}getFromCache(e,t){return this.Nr.vr(e,t).next(e=>(this.Br.set(t,{size:e.size,readTime:e.document.readTime}),e.document))}getAllFromCache(e,t){return this.Nr.Mr(e,t).next(({documents:e,Or:t})=>(t.forEach((t,n)=>{this.Br.set(t,{size:n,readTime:e.get(t).readTime})}),e))}}function sL(e){let t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function sV(e,t){let n=t.documentKey.path.toArray();return[e,iG(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:""]}function sq(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=J(n[e],r[e]))return i;return(i=J(n.length,r.length))||(i=J(n[n.length-2],r[r.length-2]))||J(n[n.length-1],r[r.length-1])}class sU{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class sB{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&&rz(n.mutation,e,t0.empty(),ep.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,rT()).next(()=>t))}getLocalViewOfDocuments(e,t,n=rT()){let r=rv();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,n).next(e=>{let t=ry();return e.forEach((e,n)=>{t=t.insert(e,n.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let n=rv();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,rT()))}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=rg,s=rv(),a=rv();return t.forEach((e,t)=>{let a=n.get(t.key);r.has(t.key)&&(void 0===a||a.mutation instanceof r$)?i=i.insert(t.key,t):void 0!==a?(s.set(t.key,a.mutation.getFieldMask()),rz(a.mutation,t,a.mutation.getFieldMask(),ep.now())):s.set(t.key,t0.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>a.set(e,new sU(t,s.get(e)??null))),a))}recalculateAndSaveOverlays(e,t){let n=rv(),r=new tH((e,t)=>e-t),i=rT();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)||t0.empty();a=i.applyToLocalView(s,a),n.set(e,a);let o=(r.get(i.batchId)||rT()).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=rv();l.forEach(e=>{if(!i.has(e)){let r=rj(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 ek.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 es.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):rt(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):ek.resolve(rv()),a=-1,o=i;return s.next(t=>
vendor: 4,366 bytes, line 7
7ek.forEach(t,(t,n)=>(a<n.largestBatchId&&(a=n.largestBatchId),i.get(t)?ek.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,rT())).next(e=>({batchId:a,changes:rw(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new es(t)).next(e=>{let t=ry();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,s=ry();return this.indexManager.getCollectionParents(e,i).next(a=>ek.forEach(a,a=>{let o=new n7(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,nR.newInvalidDocument(r)))});let n=ry();return e.forEach((e,r)=>{let s=i.get(e);void 0!==s&&rz(s.mutation,r,t0.empty(),ep.now()),rc(t,r)&&(n=n.insert(e,r))}),n})}}class sj{constructor(e){this.serializer=e,this.Lr=new Map,this.kr=new Map}getBundleMetadata(e,t){return ek.resolve(this.Lr.get(t))}saveBundleMetadata(e,t){return this.Lr.set(t.id,{id:t.id,version:t.version,createTime:ib(t.createTime)}),ek.resolve()}getNamedQuery(e,t){return ek.resolve(this.kr.get(t))}saveNamedQuery(e,t){return this.kr.set(t.name,{name:t.name,query:iJ(t.bundledQuery),readTime:ib(t.readTime)}),ek.resolve()}}class sz{constructor(){this.overlays=new tH(es.comparator),this.qr=new Map}getOverlay(e,t){return ek.resolve(this.overlays.get(t))}getOverlays(e,t){let n=rv();return ek.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.St(e,t,r)}),ek.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.qr.get(n);return void 0!==r&&(r.forEach(e=>this.overlays=this.overlays.remove(e)),this.qr.delete(n)),ek.resolve()}getOverlaysForCollection(e,t,n){let r=rv(),i=t.length+1,s=new es(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 ek.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new tH((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=rv(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=rv(),o=i.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=r)););return ek.resolve(a)}St(e,t,n){let r=this.overlays.get(n.key);if(null!==r){let e=this.qr.get(r.largestBatchId).delete(n.key);this.qr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new r0(t,n));let i=this.qr.get(t);void 0===i&&(i=rT(),this.qr.set(t,i)),this.qr.set(t,i.add(n.key))}}class sG{constructor(){this.sessionToken=t2.EMPTY_BYTE_STRING}getSessionToken(e){return ek.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,ek.resolve()}}class sK{constructor(){this.Qr=new tX(s$.$r),this.Ur=new tX(s$.Kr)}isEmpty(){return this.Qr.isEmpty()}addReference(e,t){let n=new s$(e,t);this.Qr=this.Qr.add(n),this.Ur=this.Ur.add(n)}Wr(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Gr(new s$(e,t))}zr(e,t){e.forEach(e=>this.removeReference(e,t))}jr(e){let t=new es(new en([])),n=new s$(t,e),r=new s$(t,e+1),i=[];return this.Ur.forEachInRange([n,r],e=>{this.Gr(e),i.push(e.key)}),i}Jr(){this.Qr.forEach(e=>this.Gr(e))}Gr(e){this.Qr=this.Qr.delete(e),this.Ur=this.Ur.delete(e)}Hr(e){let t=new es(new en([])),n=new s$(t,e),r=new s$(t,e+1),i=rT();return this.Ur.forEachInRange([n,r],e=>{i=i.add(e.key)}),i}containsKey(e){let t=new s$(e,0),n=this.Qr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class s${constructor(e,t){this.key=e,this.Yr=t}static $r(e,t){return es.comparator(e.key,t.key)||J(e.Yr,t.Yr)}static Kr(e,t){return J(e.Yr,t.Yr)||es.comparator(e.key,t.key)}}class sQ{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutation
7Queue=[],this.tr=1,this.Zr=new tX(s$.$r)}checkEmpty(e){return ek.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){let i=this.tr;this.tr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new rY(i,t,n,r);for(let t of(this.mutationQueue.push(s),r))this.Zr=this.Zr.add(new s$(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return ek.resolve(s)}lookupMutationBatch(e,t){return ek.resolve(this.Xr(t))}getNextMutationBatchAfterBatchId(e,t){let n=this.ei(t+1),r=n<0?0:n;return ek.resolve(this.mutationQueue.length>r?this.mutationQueue[r]:null)}getHighestUnacknowledgedBatchId(){return ek.resolve(0===this.mutationQueue.length?-1:this.tr-1)}getAllMutationBatches(e){return ek.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new s$(t,0),r=new s$(t,1/0),i=[];return this.Zr.forEachInRange([n,r],e=>{let t=this.Xr(e.Yr);i.push(t)}),ek.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new tX(J);return t.forEach(e=>{let t=new s$(e,0),r=new s$(e,1/0);this.Zr.forEachInRange([t,r],e=>{n=n.add(e.Yr)})}),ek.resolve(this.ti(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;es.isDocumentKey(i)||(i=i.child(""));let s=new s$(new es(i),0),a=new tX(J);return this.Zr.forEachWhile(e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(a=a.add(e.Yr)),!0)},s),ek.resolve(this.ti(a))}ti(e){let t=[];return e.forEach(e=>{let n=this.Xr(e);null!==n&&t.push(n)}),t}removeMutationBatch(e,t){L(0===this.ni(t.batchId,"removed"),55003),this.mutationQueue.shift();let n=this.Zr;return ek.forEach(t.mutations,r=>{let i=new s$(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)}).next(()=>{this.Zr=n})}ir(e){}containsKey(e,t){let n=new s$(t,0),r=this.Zr.firstAfterOrEqual(n);return ek.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,ek.resolve()}ni(e,t){return this.ei(e)}ei(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Xr(e){let t=this.ei(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class sH{constructor(e){this.ri=e,this.docs=new tH(es.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.ri(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 ek.resolve(n?n.document.mutableCopy():nR.newInvalidDocument(t))}getEntries(e,t){let n=rg;return t.forEach(e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():nR.newInvalidDocument(e))}),ek.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=rg,s=t.path,a=new es(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>=eC(eS(a),n)||(r.has(a.key)||rc(t,a))&&(i=i.insert(a.key,a.mutableCopy()))}return ek.resolve(i)}getAllFromCollectionGroup(e,t,n,r){O(9500)}ii(e,t){return ek.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new sW(this)}getSize(e){return ek.resolve(this.size)}}class sW extends sP{constructor(e){super(),this.Nr=e}applyChanges(e){let t=[];
vendor: 4,785 bytes, line 7
7return this.changes.forEach((n,r)=>{r.isValidDocument()?t.push(this.Nr.addEntry(e,r)):this.Nr.removeEntry(n)}),ek.waitFor(t)}getFromCache(e,t){return this.Nr.getEntry(e,t)}getAllFromCache(e,t){return this.Nr.getEntries(e,t)}}class sJ{constructor(e){this.persistence=e,this.si=new rm(e=>n2(e),n5),this.lastRemoteSnapshotVersion=ey.min(),this.highestTargetId=0,this.oi=0,this._i=new sK,this.targetCount=0,this.ai=sE.ur()}forEachTarget(e,t){return this.si.forEach((e,n)=>t(n)),ek.resolve()}getLastRemoteSnapshotVersion(e){return ek.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ek.resolve(this.oi)}allocateTargetId(e){return this.highestTargetId=this.ai.next(),ek.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.oi&&(this.oi=t),ek.resolve()}Pr(e){this.si.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.ai=new sE(t),this.highestTargetId=t),e.sequenceNumber>this.oi&&(this.oi=e.sequenceNumber)}addTargetData(e,t){return this.Pr(t),this.targetCount+=1,ek.resolve()}updateTargetData(e,t){return this.Pr(t),ek.resolve()}removeTargetData(e,t){return this.si.delete(t.target),this._i.jr(t.targetId),this.targetCount-=1,ek.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.si.forEach((s,a)=>{a.sequenceNumber<=t&&null===n.get(a.targetId)&&(this.si.delete(s),i.push(this.removeMatchingKeysForTargetId(e,a.targetId)),r++)}),ek.waitFor(i).next(()=>r)}getTargetCount(e){return ek.resolve(this.targetCount)}getTargetData(e,t){let n=this.si.get(t)||null;return ek.resolve(n)}addMatchingKeys(e,t,n){return this._i.Wr(t,n),ek.resolve()}removeMatchingKeys(e,t,n){this._i.zr(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(t=>{i.push(r.markPotentiallyOrphaned(e,t))}),ek.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this._i.jr(t),ek.resolve()}getMatchingKeysForTargetId(e,t){let n=this._i.Hr(t);return ek.resolve(n)}containsKey(e,t){return ek.resolve(this._i.containsKey(t))}}class sX{constructor(e,t){this.ui={},this.overlays={},this.ci=new e$(0),this.li=!1,this.li=!0,this.hi=new sG,this.referenceDelegate=e(this),this.Pi=new sJ(this),this.indexManager=new sc,this.remoteDocumentCache=function(e){return new sH(e)}(e=>this.referenceDelegate.Ti(e)),this.serializer=new ij(t),this.Ii=new sj(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.li=!1,Promise.resolve()}get started(){return this.li}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new sz,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.ui[e.toKey()];return n||(n=new sQ(t,this.referenceDelegate),this.ui[e.toKey()]=n),n}getGlobalsCache(){return this.hi}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ii}runTransaction(e,t,n){k("MemoryPersistence","Starting transaction:",e);let r=new sY(this.ci.next());return this.referenceDelegate.Ei(),n(r).next(e=>this.referenceDelegate.di(r).next(()=>e)).toPromise().then(e=>(r.raiseOnCommittedEvent(),e))}Ai(e,t){return ek.or(Object.values(this.ui).map(n=>()=>n.containsKey(e,t)))}}class sY extends eD{constructor(e){super(),this.currentSequenceNumber=e}}class sZ{constructor(e){this.persistence=e,this.Ri=new sK,this.Vi=null}static mi(e){return new sZ(e)}get fi(){if(this.Vi)return this.Vi;throw O(60996)}addReference(e,t,n){return this.Ri.addReference(n,t),this.fi.delete(n.toString()),ek.resolve()}removeReference(e,t,n){return this.Ri.removeReference(n,t),this.fi.add(n.toString()),ek.resolve()}markPotentiallyOrphaned(e,t){return this.fi.add(t.toString()),ek.resolve()}removeTarget(e,t){this.Ri.jr(t.targetId).forEach(e=>this.fi.add(e.toString()));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.fi.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}Ei(){this.Vi=new Set}di(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ek.forEach(this.fi,n=>{let r=es.fromPath(n);return this.gi(e,r).next(e=>{e||t.removeEntry(r,ey.min())})}).next(()=>(this.Vi=null,t.apply(e)))}updateLimboDocument(e,t){return this.gi(e,t).next(e=>{e?this.fi.delete(t.toString()):this.fi.add(t.toString())})}Ti(e){return 0}gi(e,t){return ek.or([()=>ek.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ai(e,t)])}}class s0{constructor(e,t){this.persistence=e,this.pi=new rm(e=>eJ(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=function(e,t){return new sk(e,t)}(this,t)}static mi(e,t){return new s0(e,t)}Ei(){}di(e){return ek.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEac
7hTarget(e,t)}gr(e){let t=this.wr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}wr(e){let t=0;return this.pr(e,e=>{t++}).next(()=>t)}pr(e,t){return ek.forEach(this.pi,(n,r)=>this.br(e,n,r).next(e=>e?ek.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.ii(e,r=>this.br(e,r,t).next(e=>{e||(n++,i.removeEntry(r,ey.min()))})).next(()=>i.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.pi.set(t,e.currentSequenceNumber),ek.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.pi.set(n,e.currentSequenceNumber),ek.resolve()}removeReference(e,t,n){return this.pi.set(n,e.currentSequenceNumber),ek.resolve()}updateLimboDocument(e,t){return this.pi.set(t,e.currentSequenceNumber),ek.resolve()}Ti(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(nf(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let n=nn(t);return n?16+e(n):16;case 5:return 2*t.stringValue.length;case 6:return t6(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,tK(r.fields,(t,n)=>{i+=t.length+e(n)}),i;default:throw O(13486,{value:t})}}(e.data.value)),t}br(e,t,n){return ek.or([()=>this.persistence.Ai(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.pi.get(t);return ek.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class s1{constructor(e){this.serializer=e}k(e,t,n,r){let i=new eR("createOrUpgrade",t);n<1&&r>=1&&(e.createObjectStore(eZ),e.createObjectStore(e1,{keyPath:"userId"}),e.createObjectStore(e2,{keyPath:e5,autoIncrement:!0}).createIndex(e3,e4,{unique:!0}),e.createObjectStore(e8),s2(e),e.createObjectStore(eY));let s=ek.resolve();return n<3&&r>=3&&(0!==n&&(e.deleteObjectStore(tu),e.deleteObjectStore(ta),e.deleteObjectStore(tm),s2(e)),s=s.next(()=>{let e,t;return e=i.store(tm),t={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:ey.min().toTimestamp(),targetCount:0},e.put(tf,t)})),n<4&&r>=4&&(0!==n&&(s=s.next(()=>i.store(e2).J().next(t=>{e.deleteObjectStore(e2),e.createObjectStore(e2,{keyPath:e5,autoIncrement:!0}).createIndex(e3,e4,{unique:!0});let n=i.store(e2),r=t.map(e=>n.put(e));return ek.waitFor(r)}))),s=s.next(()=>{e.createObjectStore(ty,{keyPath:"clientId"})})),n<5&&r>=5&&(s=s.next(()=>this.yi(i))),n<6&&r>=6&&(s=s.next(()=>(e.createObjectStore(ti),this.wi(i)))),n<7&&r>=7&&(s=s.next(()=>this.Si(i))),n<8&&r>=8&&(s=s.next(()=>this.bi(e,i))),n<9&&r>=9&&(s=s.next(()=>{e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")})),n<10&&r>=10&&(s=s.next(()=>this.Di(i))),n<11&&r>=11&&(s=s.next(()=>{e.createObjectStore(tw,{keyPath:"bundleId"}),e.createObjectStore(tv,{keyPath:"name"})})),n<12&&r>=12&&(s=s.next(()=>{let t;(t=e.createObjectStore(tN,{keyPath:tk})).createIndex(tM,tR,{unique:!1}),t.createIndex(tP,tO,{unique:!1})})),n<13&&r>=13&&(s=s.next(()=>{let t;(t=e.createObjectStore(e7,{keyPath:e9})).createIndex(te,tt),t.createIndex(tn,tr)}).next(()=>this.Ci(e,i)).next(()=>e.deleteObjectStore(eY))),n<14&&r>=14&&(s=s.next(()=>this.Fi(e,i))),n<15&&r>=15&&(s=s.next(()=>{e.createObjectStore(tb,{keyPath:"indexId",autoIncrement:!0}).createIndex(tI,"collectionGroup",{unique:!1}),e.createObjectStore(tT,{keyPath:t_}).createIndex(tE,tS,{unique:!1}),e.createObjectStore(tx,{keyPath:tC}).createIndex(tA,tD,{unique:!1})})),n<16&&r>=16&&(s=s.next(()=>{t.objectStore(tT).clear()}).next(()=>{t.objectStore(tx).clear()})),n<17&&r>=17&&(s=s.next(()=>{e.createObjectStore(tF,{keyPath:"name"})})),n<18&&r>=18&&(0,b.isSafariOrWebkit)()&&(s=s.next(()=>{t.objectStore(tT).clear()}).next(()=>{t.objectStore(tx).clear()})),s}wi(e){let t=0;return e.store(eY).ee((e,n)=>{t+=sb(n)}).next(()=>{let n={byteSize:t};return e.store(ti).put(ts,n)})}yi(e){let t=e.store(e1),n=e.store(e2);return t.J().next(t=>
7ek.forEach(t,t=>{let r=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return n.J(e3,r).next(n=>ek.forEach(n,n=>{L(n.userId===t.userId,18650,"Cannot process batch from unexpected user",{batchId:n.batchId});let r=iQ(this.serializer,n);return sv(e,t.userId,r).next(()=>{})}))}))}Si(e){let t=e.store(tu),n=e.store(eY);return e.store(tm).get(tf).next(e=>{let r=[];return n.ee((n,i)=>{let s=new en(n),a=[0,eJ(s)];r.push(t.get(a).next(n=>n?ek.resolve():t.put({targetId:0,path:eJ(s),sequenceNumber:e.highestListenSequenceNumber})))}).next(()=>ek.waitFor(r))})}bi(e,t){e.createObjectStore(tg,{keyPath:tp});let n=t.store(tg),r=new sd,i=e=>{if(r.add(e)){let t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:eJ(r)})}};return t.store(eY).ee({X:!0},(e,t)=>i(new en(e).popLast())).next(()=>t.store(e8).ee({X:!0},([e,t,n],r)=>i(eX(t).popLast())))}Di(e){let t=e.store(ta);return t.ee((e,n)=>{let r=iH(n),i=iW(this.serializer,r);return t.put(i)})}Ci(e,t){let n=t.store(eY),r=[];return n.ee((e,n)=>{let i=t.store(e7),s=(n.document?new es(en.fromString(n.document.name).popFirst(5)):n.noDocument?es.fromSegments(n.noDocument.path):n.unknownDocument?es.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(()=>ek.waitFor(r))}Fi(e,t){let n=t.store(e2),r=new sO(this.serializer),i=new sX(sZ.mi,this.serializer.yt);return n.J().next(e=>{let n=new Map;return e.forEach(e=>{let t=n.get(e.userId)??rT();iQ(this.serializer,e).keys().forEach(e=>t=t.add(e)),n.set(e.userId,t)}),ek.forEach(n,(e,n)=>{let s=new C(n),a=i1.wt(this.serializer,s),o=i.getIndexManager(s);return new sB(r,sI.wt(s,this.serializer,o,i.referenceDelegate),a,o).recalculateAndSaveOverlaysForDocumentKeys(new tj(t,e$.ce),e).next()})})}}function s2(e){e.createObjectStore(tu,{keyPath:th}).createIndex(tc,td,{unique:!0}),e.createObjectStore(ta,{keyPath:"targetId"}).createIndex(to,tl,{unique:!0}),e.createObjectStore(tm)}let s5="IndexedDbPersistence",s3="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.",s4="main";class s6{constructor(e,t,n,r,i,s,a,o,l,u,h=18){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.Mi=i,this.window=s,this.document=a,this.xi=l,this.Oi=u,this.Ni=h,this.ci=null,this.li=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Bi=null,this.inForeground=!1,this.Li=null,this.ki=null,this.qi=-1/0,this.Qi=e=>Promise.resolve(),!s6.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 sM(this,r),this.$i=t+s4,this.serializer=new ij(o),this.Ui=new eP(this.$i,this.Ni,new s1(this.serializer)),this.hi=new i2,this.Pi=new sS(this.referenceDelegate,this.serializer),this.remoteDocumentCache=function(e){return new sO(e)}(this.serializer),this.Ii=new i0,this.window&&this.window.localStorage?this.Ki=this.window.localStorage:(this.Ki=null,!1===u&&M(s5,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Wi().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new q(V.FAILED_PRECONDITION,s3);return this.Gi(),this.zi(),this.ji(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.Pi.getHighestSequenceNumber(e))}).then(e=>{this.ci=new e$(e,this.xi)}).then(()=>{this.li=!0}).catch(e=>(this.Ui&&this.Ui.close(),Promise.reject(e)))}Ji(e){return this.Qi=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.Ui.$(async t=>{null===t.newVersion&&await e()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Mi.enqueueAndForget(async()=>{this.started&&await this.Wi()}))}Wi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>tz(e,ty).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.Hi(e).next(e=>{e||(this.isPrimary=!1,this.Mi.enqueueRetryable(()=>this.Qi(!1)))})}).next(()=>this.Yi(e)).next(t=>this.isPrimary&&!t?this.Zi(e).next(()=>!1):!!t&&this.Xi(e).next(()=>!0))).catch(e=>{if(eV(e))return k(s5,"Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return k(s5,"Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Mi.enqueueRetryable(()=>this.Qi(e)),this.isPrimary=e})}Hi(e){return tz(e,eZ).get(e0).next(e=>ek.resolve(this.es(e)))}ts(e){return tz(e,ty).delete(this.clientId)}async ns(){if(this.isPrimary&&!this.rs(this.qi,18e5)){this.qi=Date.now();let e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{let t=tz(e,ty);return t.J().next(e=>{let n=this.ss(e,18e5),r=e.filter(e=>-1===n.indexOf(e));
7return ek.forEach(r,e=>t.delete(e.clientId)).next(()=>r)})}).catch(()=>[]);if(this.Ki)for(let t of e)this.Ki.removeItem(this._s(t.clientId))}}ji(){this.ki=this.Mi.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.Wi().then(()=>this.ns()).then(()=>this.ji()))}es(e){return!!e&&e.ownerId===this.clientId}Yi(e){return this.Oi?ek.resolve(!0):tz(e,eZ).get(e0).next(t=>{if(null!==t&&this.rs(t.leaseTimestampMs,5e3)&&!this.us(t.ownerId)){if(this.es(t)&&this.networkEnabled)return!0;if(!this.es(t)){if(!t.allowTabSynchronization)throw new q(V.FAILED_PRECONDITION,s3);return!1}}return!(!this.networkEnabled||!this.inForeground)||tz(e,ty).J().next(e=>void 0===this.ss(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&&k(s5,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.li=!1,this.cs(),this.ki&&(this.ki.cancel(),this.ki=null),this.ls(),this.hs(),await this.Ui.runTransaction("shutdown","readwrite",[eZ,ty],e=>{let t=new tj(e,e$.ce);return this.Zi(t).next(()=>this.ts(t))}),this.Ui.close(),this.Ps()}ss(e,t){return e.filter(e=>this.rs(e.updateTimeMs,t)&&!this.us(e.clientId))}Ts(){return this.runTransaction("getActiveClients","readonly",e=>tz(e,ty).J().next(e=>this.ss(e,18e5).map(e=>e.clientId)))}get started(){return this.li}getGlobalsCache(){return this.hi}getMutationQueue(e,t){return sI.wt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new sg(e,this.serializer.yt.databaseId)}getDocumentOverlayCache(e){return i1.wt(this.serializer,e)}getBundleCache(){return this.Ii}runTransaction(e,t,n){var r;let i;k(s5,"Starting transaction:",e);let s=18===(r=this.Ni)||17===r?tB:16===r||15===r?tU:14===r||13===r?tq:12===r?tV:11===r?tL:void O(60245);return this.Ui.runTransaction(e,"readonly"===t?"readonly":"readwrite",s,r=>(i=new tj(r,this.ci?this.ci.next():e$.ce),"readwrite-primary"===t?this.Hi(i).next(e=>!!e||this.Yi(i)).next(t=>{if(!t)throw M(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.Mi.enqueueRetryable(()=>this.Qi(!1)),new q(V.FAILED_PRECONDITION,eA);return n(i)}).next(e=>
7this.Xi(i).next(()=>e)):this.Is(i).next(()=>n(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}Is(e){return tz(e,eZ).get(e0).next(e=>{if(null!==e&&this.rs(e.leaseTimestampMs,5e3)&&!this.us(e.ownerId)&&!this.es(e)&&!(this.Oi||this.allowTabSynchronization&&e.allowTabSynchronization))throw new q(V.FAILED_PRECONDITION,s3)})}Xi(e){let t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return tz(e,eZ).put(e0,t)}static v(){return eP.v()}Zi(e){let t=tz(e,eZ);return t.get(e0).next(e=>this.es(e)?(k(s5,"Releasing primary lease."),t.delete(e0)):ek.resolve())}rs(e,t){let n=Date.now();return!(e<n-t)&&(!(e>n)||(M(`Detected an update time that is in the future: ${e} > ${n}`),!1))}Gi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Li=()=>{this.Mi.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.Wi()))},this.document.addEventListener("visibilitychange",this.Li),this.inForeground="visible"===this.document.visibilityState)}ls(){this.Li&&(this.document.removeEventListener("visibilitychange",this.Li),this.Li=null)}zi(){"function"==typeof this.window?.addEventListener&&(this.Bi=()=>{this.cs();let e=/(?:Version|Mobile)\/1[456]/;(0,b.isSafari)()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.Mi.enterRestrictedMode(!0),this.Mi.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Bi))}hs(){this.Bi&&(this.window.removeEventListener("pagehide",this.Bi),this.Bi=null)}us(e){try{let t=null!==this.Ki?.getItem(this._s(e));return k(s5,`Client '${e}' ${t?"is":"is not"} zombied in LocalStorage`),t}catch(e){return M(s5,"Failed to get zombied client id.",e),!1}}cs(){if(this.Ki)try{this.Ki.setItem(this._s(this.clientId),String(Date.now()))}catch(e){M("Failed to set zombie client id.",e)}}Ps(){if(this.Ki)try{this.Ki.removeItem(this._s(this.clientId))}catch(e){}}_s(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function s8(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class s7{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Es=n,this.ds=r}static As(e,t){let n=rT(),r=rT();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 s7(e,t.fromCache,n,r)}}class s9{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class ae{constructor(){this.Rs=!1,this.Vs=!1,this.fs=100,this.gs=(0,b.isSafari)()?8:eO((0,b.getUA)())>0?6:4}initialize(e,t){this.ps=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.ys(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.ws(e,t,r,n).next(e=>{i.result=e})}).next(()=>{if(i.result)return;let n=new s9;return this.Ss(e,t,n).next(r=>{if(i.result=r,this.Vs)return this.bs(e,t,n,r.size)})}).next(()=>i.result)}bs(e,t,n,r){return n.documentReadCount<this.fs?(N()<=v.LogLevel.DEBUG&&k("QueryEngine","SDK will not create cache indexes for query:",rh(t),"since it only creates cache indexes for collection contains","more than or equal to",this.fs,"documents"),ek.resolve()):(N()<=v.LogLevel.DEBUG&&k("QueryEngine","Query:",rh(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.gs*r?(N()<=v.LogLevel.DEBUG&&k("QueryEngine","The SDK decides to create cache indexes for query:",rh(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,rr(t))):ek.resolve())}ys(e,t){if(re(t))return ek.resolve(null);let n=rr(t);return this.indexManager.getIndexType(e,n).next(r=>0===r?null:(null!==t.limit&&1===r&&(n=rr(t=ro(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,n).next(r=>{let i=rT(...r);return this.ps.getDocuments(e,i).next(r=>this.indexManager.getMinOffset(e,n).next(n=>{let s=this.Ds(t,r);return this.Cs(t,s,i,n.readTime)?this.ys(e,ro(t,null,"F")):this.vs(e,s,t,n)}))})))}ws(e,t,n,r){return re(t)||r.isEqual(ey.min())?ek.resolve(null):this.ps.getDocuments(e,n).next(i=>{let s=this.Ds(t,i);return this.Cs(t,s,n,r)?ek.resolve(null):(N()<=v.LogLevel.DEBUG&&k("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),rh(t)),this.vs(e,s,t,eE(r,-1)).next(e=>e))})}Ds(e,t){let n=new tX(rf(e));return t.forEach((t,r)=>{rc(e,r)&&(n=n.add(r))}),n}Cs(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)}
7Ss(e,t,n){return N()<=v.LogLevel.DEBUG&&k("QueryEngine","Using full collection scan to execute query:",rh(t)),this.ps.getDocumentsMatchingQuery(e,t,ex.min(),n)}vs(e,t,n,r){return this.ps.getDocumentsMatchingQuery(e,n,r).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let at="LocalStore";class an{constructor(e,t,n,r){this.persistence=e,this.Fs=t,this.serializer=r,this.Ms=new tH(J),this.xs=new rm(e=>n2(e),n5),this.Os=new Map,this.Ns=e.getRemoteDocumentCache(),this.Pi=e.getTargetCache(),this.Ii=e.getBundleCache(),this.Bs(n)}Bs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new sB(this.Ns,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ns.setIndexManager(this.indexManager),this.Fs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Ms))}}async function ar(e,t){return await e.persistence.runTransaction("Handle user change","readonly",n=>{let r;return e.mutationQueue.getAllMutationBatches(n).next(i=>(r=i,e.Bs(t),e.mutationQueue.getAllMutationBatches(n))).next(t=>{let i=[],s=[],a=rT();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=>({Ls:e,removedBatchIds:i,addedBatchIds:s}))})})}function ai(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Pi.getLastRemoteSnapshotVersion(t))}function as(e,t,n){let r=rT(),i=rT();return n.forEach(e=>r=r.add(e)),t.getEntries(e,r).next(e=>{let r=rg;return n.forEach((n,s)=>{let a=e.get(n);s.isFoundDocument()!==a.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(ey.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)):k(at,"Ignoring outdated watch update for ",n,". Current version:",a.version," Watch version:",s.version)}),{ks:r,qs:i}})}function aa(e,t){return e.persistence.runTransaction("Allocate target","readwrite",n=>{let r;return e.Pi.getTargetData(n,t).next(i=>i?(r=i,ek.resolve(r)):e.Pi.allocateTargetId(n).next(i=>(r=new iB(t,i,"TargetPurposeListen",n.currentSequenceNumber),e.Pi.addTargetData(n,r).next(()=>r))))}).then(n=>{let r=e.Ms.get(n.targetId);return(null===r||n.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(e.Ms=e.Ms.insert(n.targetId,n),e.xs.set(t,n.targetId)),n})}async function ao(e,t,n){let r=e.Ms.get(t);try{n||await e.persistence.runTransaction("Release target",n?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,r))}catch(e){if(!eV(e))throw e;k(at,`Failed to update sequence numbers for target ${t}: ${e}`)}e.Ms=e.Ms.remove(t),e.xs.delete(r.target)}function al(e,t,n){let r=ey.min(),i=rT();return e.persistence.runTransaction("Execute query","readwrite",s=>{var a;let o;return(a=rr(t),void 0!==(o=e.xs.get(a))?ek.resolve(e.Ms.get(o)):e.Pi.getTargetData(s,a)).next(t=>{if(t)return r=t.lastLimboFreeSnapshotVersion,e.Pi.getMatchingKeysForTargetId(s,t.targetId).next(e=>{i=e})}).next(()=>e.Fs.getDocumentsMatchingQuery(s,t,n?r:ey.min(),n?i:rT())).next(n=>(ac(e,rd(t),n),{documents:n,Qs:i}))})}function au(e,t){let n=e.Pi,r=e.Ms.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 ah(e,t){let n=e.Os.get(t)||ey.min();return e.persistence.runTransaction("Get new document changes","readonly",r=>e.Ns.getAllFromCollectionGroup(r,t,eE(n,-1),Number.MAX_SAFE_INTEGER)).then(n=>(ac(e,t,n),n))}function ac(e,t,n){let r=e.Os.get(t)||ey.min();n.forEach((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)}),e.Os.set(t,r)}async function ad(e,t,n,r){let i=rT(),s=rg;for(let e of n){let n=t.$s(e.metadata.name);e.document&&(i=i.add(n));let r=t.Us(e);r.setReadTime(t.Ks(e.metadata.readTime)),s=s.insert(n,r)}let a=e.Ns.newChangeBuffer({trackRemovals:!0}),o=await aa(e,rr(n9(en.fromString(`__bundle__/docs/${r}`))));return e.persistence.runTransaction("Apply bundle documents","readwrite",t=>as(t,a,s).next(e=>(a.apply(t),e)).next(n=>e.Pi.removeMatchingKeysForTargetId(t,o.targetId).next(()=>e.Pi.addMatchingKeys(t,i,o.targetId)).next(()=>e.localDocuments.getLocalViewOfDocuments(t,n.ks,n.qs)).next(()=>n.ks)))}async function af(e,t,n=rT()){let r=await aa(e,rr(iJ(t.bundledQuery)));return e.persistence.runTransaction("Save named query","readwrite",i=>{let s=ib(t.readTime);if(r.snapshotVersion.compareTo(s)>=0)return e.Ii.saveNamedQuery(i,t);let a=r.withResumeToken(t2.EMPTY_BYTE_STRING,s);return e.Ms=e.Ms.insert(a.targetId,a),e.Pi.updateTargetData(i,a).next(()=>e.Pi.removeMatchingKeysForTargetId(i,r.targetId)).next(()=>e.Pi.addMatchingKeys(i,n,r.targetId)).next(()=>e.Ii.saveNamedQuery(i,t))})}let am="firestore_clients";function ag(e,t){return`${am}_${e}_${t}`}let ap="firestore_mutations";function ay(e,t,n){let r=`${ap}_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}let aw="firestore_targets";function av(e,t){return`${aw}_${e}_${t}`}
7let ab="SharedClientState";class aI{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static Ws(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 aI(e,t,r.state,i):(M(ab,`Failed to parse mutation state for ID '${t}': ${n}`),null)}Gs(){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 aT{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Ws(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 aT(e,n.state,r):(M(ab,`Failed to parse target state for ID '${e}': ${t}`),null)}Gs(){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 a_{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Ws(e,t){let n=JSON.parse(t),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=r_;for(let e=0;r&&e<n.activeTargetIds.length;++e)r=eW(n.activeTargetIds[e]),i=i.add(n.activeTargetIds[e]);return r?new a_(e,i):(M(ab,`Failed to parse client data for instance '${e}': ${t}`),null)}}class aE{constructor(e,t){this.clientId=e,this.onlineState=t}static Ws(e){let t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new aE(t.clientId,t.onlineState):(M(ab,`Failed to parse online state: ${e}`),null)}}class aS{constructor(){this.activeTargetIds=r_}zs(e){this.activeTargetIds=this.activeTargetIds.add(e)}js(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Gs(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class ax{constructor(e,t,n,r,i){this.window=e,this.Mi=t,this.persistenceKey=n,this.Js=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Hs=this.Ys.bind(this),this.Zs=new tH(J),this.started=!1,this.Xs=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.eo=ag(this.persistenceKey,this.Js),this.no=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Zs=this.Zs.insert(this.Js,new aS),this.ro=RegExp(`^${am}_${s}_([^_]*)$`),this.io=RegExp(`^${ap}_${s}_(\\d+)(?:_(.*))?$`),this.so=RegExp(`^${aw}_${s}_(\\d+)$`),this.oo=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this._o=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this.Hs)}static v(e){return!(!e||!e.localStorage)}async start(){for(let e of(await this.syncEngine.Ts())){if(e===this.Js)continue;let t=this.getItem(ag(this.persistenceKey,e));if(t){let n=a_.Ws(e,t);n&&(this.Zs=this.Zs.insert(n.clientId,n))}}this.ao();let e=this.storage.getItem(this.oo);if(e){let t=this.uo(e);t&&this.co(t)}for(let e of this.Xs)this.Ys(e);this.Xs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.no,JSON.stringify(e))}getAllActiveQueryTargets(){return this.lo(this.Zs)}isActiveQueryTarget(e){let t=!1;return this.Zs.forEach((n,r)=>{r.activeTargetIds.has(e)&&(t=!0)}),t}addPendingMutation(e){this.ho(e,"pending")}updateMutationState(e,t,n){this.ho(e,t,n),this.Po(e)}addLocalQueryTarget(e,t=!0){let n="not-current";if(this.isActiveQueryTarget(e)){let t=this.storage.getItem(av(this.persistenceKey,e));if(t){let r=aT.Ws(e,t);r&&(n=r.state)}}return t&&this.To.zs(e),this.ao(),n}removeLocalQueryTarget(e){this.To.js(e),this.ao()}isLocalQueryTarget(e){return this.To.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(av(this.persistenceKey,e))}
7updateQueryState(e,t,n){this.Io(e,t,n)}handleUserChange(e,t,n){t.forEach(e=>{this.Po(e)}),this.currentUser=e,n.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.Eo(e)}notifyBundleLoaded(e){this.Ao(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Hs),this.removeItem(this.eo),this.started=!1)}getItem(e){let t=this.storage.getItem(e);return k(ab,"READ",e,t),t}setItem(e,t){k(ab,"SET",e,t),this.storage.setItem(e,t)}removeItem(e){k(ab,"REMOVE",e),this.storage.removeItem(e)}Ys(e){if(e.storageArea===this.storage){if(k(ab,"EVENT",e.key,e.newValue),e.key===this.eo)return void M("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Mi.enqueueRetryable(async()=>{if(this.started){if(null!==e.key){if(this.ro.test(e.key)){if(null==e.newValue){let t=this.Ro(e.key);return this.Vo(t,null)}{let t=this.mo(e.key,e.newValue);if(t)return this.Vo(t.clientId,t)}}else if(this.io.test(e.key)){if(null!==e.newValue){let t=this.fo(e.key,e.newValue);if(t)return this.po(t)}}else if(this.so.test(e.key)){if(null!==e.newValue){let t=this.yo(e.key,e.newValue);if(t)return this.wo(t)}}else if(e.key===this.oo){if(null!==e.newValue){let t=this.uo(e.newValue);if(t)return this.co(t)}}else if(e.key===this.no){let t=function(e){let t=e$.ce;if(null!=e)try{let n=JSON.parse(e);L("number"==typeof n,30636,{So:e}),t=n}catch(e){M(ab,"Failed to read sequence number from WebStorage",e)}return t}(e.newValue);t!==e$.ce&&this.sequenceNumberHandler(t)}else if(e.key===this._o){let t=this.bo(e.newValue);await Promise.all(t.map(e=>this.syncEngine.Do(e)))}}}else this.Xs.push(e)})}}get To(){return this.Zs.get(this.Js)}ao(){this.setItem(this.eo,this.To.Gs())}ho(e,t,n){let r=new aI(this.currentUser,e,t,n),i=ay(this.persistenceKey,this.currentUser,e);this.setItem(i,r.Gs())}Po(e){let t=ay(this.persistenceKey,this.currentUser,e);this.removeItem(t)}Eo(e){let t={clientId:this.Js,onlineState:e};this.storage.setItem(this.oo,JSON.stringify(t))}Io(e,t,n){let r=av(this.persistenceKey,e),i=new aT(e,t,n);this.setItem(r,i.Gs())}Ao(e){let t=JSON.stringify(Array.from(e));this.setItem(this._o,t)}Ro(e){let t=this.ro.exec(e);return t?t[1]:null}mo(e,t){let n=this.Ro(e);return a_.Ws(n,t)}fo(e,t){let n=this.io.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return aI.Ws(new C(i),r,t)}yo(e,t){let n=Number(this.so.exec(e)[1]);return aT.Ws(n,t)}uo(e){return aE.Ws(e)}bo(e){return JSON.parse(e)}async po(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.Co(e.batchId,e.state,e.error);k(ab,`Ignoring mutation for non-active user ${e.user.uid}`)}wo(e){return this.syncEngine.vo(e.targetId,e.state,e.error)}Vo(e,t){let n=t?this.Zs.insert(e,t):this.Zs.remove(e),r=this.lo(this.Zs),i=this.lo(n),s=[],a=[];return i.forEach(e=>{r.has(e)||s.push(e)}),r.forEach(e=>{i.has(e)||a.push(e)}),this.syncEngine.Fo(s,a).then(()=>{this.Zs=n})}co(e){this.Zs.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}lo(e){let t=r_;return e.forEach((e,n)=>{t=t.unionWith(n.activeTargetIds)}),t}}class aC{constructor(){this.Mo=new aS,this.xo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.Mo.zs(e),this.xo[e]||"not-current"}updateQueryState(e,t,n){this.xo[e]=t}removeLocalQueryTarget(e){this.Mo.js(e)}isLocalQueryTarget(e){return this.Mo.activeTargetIds.has(e)}clearQueryState(e){delete this.xo[e]}getAllActiveQueryTargets(){return this.Mo.activeTargetIds}isActiveQueryTarget(e){return this.Mo.activeTargetIds.has(e)}start(){return this.Mo=new aS,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class aA{Oo(e){}shutdown(){}}let aD="ConnectivityMonitor";class aN{constructor(){this.No=()=>this.Bo(),this.Lo=()=>this.ko(),this.qo=[],this.Qo()}Oo(e){this.qo.push(e)}shutdown(){window.removeEventListener("online",this.No),window.removeEventListener("offline",this.Lo)}Qo(){window.addEventListener("online",this.No),window.addEventListener("offline",this.Lo)}Bo(){for(let e of(k(aD,"Network connectivity changed: AVAILABLE"),this.qo))e(0)}ko(){for(let e of(k(aD,"Network connectivity changed: UNAVAILABLE"),this.qo))e(1)}static v(){return"u">typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let ak=null;function aM(){return null===ak?ak=0x10000000+Math.round(0x80000000*Math.random()):ak++,"0x"+ak.toString(16)}let aR="RestConnection",aP={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
7Query:"runAggregationQuery"};class aO{get $o(){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.Uo=t+"://"+e.host,this.Ko=`projects/${n}/databases/${r}`,this.Wo=this.databaseId.database===ns?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Go(e,t,n,r,i){let s=aM(),a=this.zo(e,t.toUriEncodedString());k(aR,`Sending RPC '${e}' ${s}:`,a,n);let o={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Wo};this.jo(o,r,i);let{host:l}=new URL(a),u=(0,b.isCloudWorkstation)(l);return this.Jo(e,a,o,n,u).then(t=>(k(aR,`Received RPC '${e}' ${s}: `,t),t),t=>{throw R(aR,`RPC '${e}' ${s} failed with error: `,t,"url: ",a,"request:",n),t})}Ho(e,t,n,r,i,s){return this.Go(e,t,n,r,i)}jo(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+A,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)}zo(e,t){let n=aP[e];return`${this.Uo}/v1/${t}:${n}`}terminate(){}}class aF{constructor(e){this.Yo=e.Yo,this.Zo=e.Zo}Xo(e){this.e_=e}t_(e){this.n_=e}r_(e){this.i_=e}onMessage(e){this.s_=e}close(){this.Zo()}send(e){this.Yo(e)}o_(){this.e_()}__(){this.n_()}a_(e){this.i_(e)}u_(e){this.s_(e)}}let aL="WebChannelConnection";class aV extends aO{constructor(e){super(e),this.c_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Jo(e,t,n,i,o){let l=aM();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();k(aL,`XHR for RPC '${e}' ${l} received:`,JSON.stringify(t)),o(t);break;case a.TIMEOUT:k(aL,`RPC '${e}' ${l} timed out`),u(new q(V.DEADLINE_EXCEEDED,"Request time out"));break;case a.HTTP_ERROR:let n=h.getStatus();if(k(aL,`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{k(aL,`RPC '${e}' ${l} completed.`)}});let c=JSON.stringify(i);k(aL,`RPC '${e}' ${l} sending request:`,i),h.send(t,"POST",c,n,15)})}T_(e,t,n){let r=aM(),s=[this.Uo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=h(),d=u(),f={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},m=this.longPollingOptions.timeoutSeconds;void 0!==m&&(f.longPollingTimeout=Math.round(1e3*m)),this.useFetchStreams&&(f.useFetchStreams=!0),this.jo(f.initMessageHeaders,t,n),f.encodeInitMessageHeaders=!0;let g=s.join("");k(aL,`Creating RPC '${e}' stream ${r}: ${g}`,f);let p=a.createWebChannel(g,f);this.I_(p);let y=!1,w=!1,v=new aF({Yo:t=>{w?k(aL,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(y||(k(aL,`Opening RPC '${e}' stream ${r} transport.`),p.open(),y=!0),k(aL,`RPC '${e}' stream ${r} sending:`,t),p.send(t))},Zo:()=>p.close()}),b=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};return b(p,i.EventType.OPEN,()=>{w||(k(aL,`RPC '${e}' stream ${r} transport opened.`),v.o_())}),b(p,i.EventType.CLOSE,()=>{w||(w=!0,k(aL,`RPC '${e}' stream ${r} transport closed`),v.a_(),this.E_(p))}),b(p,i.EventType.ERROR,t=>{w||(w=!0,R(aL,`RPC '${e}' stream ${r} transport errored. Name:`,t.name,"Message:",t.message),v.a_(new q(V.UNAVAILABLE,"The operation could not be completed")))}),b(p,i.EventType.MESSAGE,t=>{if(!w){let n=t.data[0];L(!!n,16349);let i=n?.error||n[0]?.error;if(i){k(aL,`RPC '${e}' stream ${r} received error:`,i);let t=i.status,n=function(e){let t=c[e];if(void 0!==t)return r3(t)}(t),s=i.message;void 0===n&&(n=V.INTERNAL,s="Unknown error status: "+t+" with message "+i.message),w=!0,v.a_(new q(n,s)),p.close()}else k(aL,`RPC '${e}' stream ${r} received:`,n),v.u_(n)}}),b(d,l.STAT_EVENT,t=>{t.stat===o.PROXY?k(aL,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===o.NOPROXY&&k(aL,`RPC '${e}' stream ${r} detected no buffering proxy`)}),setTimeout(()=>{v.__()},0),v}
7terminate(){this.c_.forEach(e=>e.close()),this.c_=[]}I_(e){this.c_.push(e)}E_(e){this.c_=this.c_.filter(t=>t===e)}}function aq(){return"u">typeof window?window:null}function aU(){return"u">typeof document?document:null}function aB(e){return new ip(e,!0)}class aj{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Mi=e,this.timerId=t,this.d_=n,this.A_=r,this.R_=i,this.V_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.V_=0}g_(){this.V_=this.R_}p_(e){this.cancel();let t=Math.floor(this.V_+this.y_()),n=Math.max(0,Date.now()-this.f_),r=Math.max(0,t-n);r>0&&k("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.V_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.m_=this.Mi.enqueueAfterDelay(this.timerId,r,()=>(this.f_=Date.now(),e())),this.V_*=this.A_,this.V_<this.d_&&(this.V_=this.d_),this.V_>this.R_&&(this.V_=this.R_)}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.V_}}let az="PersistentStream";class aG{constructor(e,t,n,r,i,s,a,o){this.Mi=e,this.S_=n,this.b_=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 aj(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.Mi.enqueueAfterDelay(this.S_,6e4,()=>this.k_()))}q_(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?(M(t.toString()),M("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.K_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.r_(t)}K_(){}auth(){this.state=1;let e=this.W_(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.W_(this.D_);this.stream=this.j_(e,t),this.stream.Xo(()=>{n(()=>this.listener.Xo())}),this.stream.t_(()=>{n(()=>(this.state=2,this.v_=this.Mi.enqueueAfterDelay(this.b_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.t_()))}),this.stream.r_(e=>{n(()=>this.z_(e))}),this.stream.onMessage(e=>{n(()=>1==++this.F_?this.J_(e):this.onNext(e))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return k(az,`close with error: ${e}`),this.stream=null,this.close(4,e)}W_(e){return t=>{this.Mi.enqueueAndForget(()=>this.D_===e?t():(k(az,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class aK extends aG{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}J_(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?(L(void 0===i||"string"==typeof i,58123),t2.fromBase64String(i||"")):(L(void 0===i||i instanceof p.Buffer||i instanceof Uint8Array,16193),t2.fromUint8Array(i||new Uint8Array))),l=t.targetChange.cause;n=new io(s,a,o,l&&new q(void 0===l.code?V.UNKNOWN:r3(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=iS(e,r.document.name),s=ib(r.document.updateTime),a=r.document.createTime?ib(r.document.createTime):ey.min(),o=new nM({mapValue:{fields:r.document.fields}}),l=nR.newFoundDocument(i,s,a,o);n=new is(r.targetIds||[],r.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let r=t.documentDelete;r.document;let i=iS(e,r.document),s=r.readTime?ib(r.readTime):ey.min(),a=nR.newNoDocument(i,s);n=new is([],r.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let r=t.documentRemove;r.document;let i=iS(e,r.document);n=new is([],r.removedTargetIds||[],i,null)}else{if(!("filter"in t))return O(11601,{Rt:t});{t.filter;let e=t.filter;e.targetId;
7let{count:r=0,unchangedNames:i}=e,s=new r2(r,i);n=new ia(e.targetId,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return ey.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?ey.min():t.readTime?ib(t.readTime):ey.min()}(e);return this.listener.H_(t,n)}Y_(e){let t,n={};n.database=iA(this.serializer),n.addTarget=function(e,t){let n,r=t.target;if((n=n3(r)?{documents:iP(e,r)}:{query:iO(e,r).ft}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=iv(e,t.resumeToken);let r=iy(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(ey.min())>0){n.readTime=iw(e,t.snapshotVersion.toTimestamp());let r=iy(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.q_(n)}Z_(e){let t={};t.database=iA(this.serializer),t.removeTarget=e,this.q_(t)}}class a$ extends aG{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 X_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}K_(){this.X_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}J_(e){return L(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,L(!e.writeResults||0===e.writeResults.length,55816),this.listener.ta()}onNext(e){var t,n;L(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();let r=(t=e.writeResults,n=e.commitTime,t&&t.length>0?(L(void 0!==n,14353),t.map(e=>{let t;return(t=e.updateTime?ib(e.updateTime):ib(n)).isEqual(ey.min())&&(t=ib(n)),new rV(t,e.transformResults||[])})):[]),i=ib(e.commitTime);return this.listener.na(i,r)}ra(){let e={};e.database=iA(this.serializer),this.q_(e)}ea(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>iM(this.serializer,e))};this.q_(t)}}class aQ{}class aH extends aQ{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.")}Go(e,t,n,r){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.Go(e,iT(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())})}Ho(e,t,n,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.connection.Ho(e,iT(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 aW{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} 8This 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?(M(t),this.aa=!1):k("OnlineStateTracker",t)}Pa(){null!==this._a&&(this._a.cancel(),this._a=null)}}let aJ="RemoteStore";class aX{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.da=[],this.Aa=i,this.Aa.Oo(e=>{n.enqueueAndForget(async()=>
8{a6(this)&&(k(aJ,"Restarting streams for network reachability change."),await async function(e){e.Ea.add(4),await aZ(e),e.Ra.set("Unknown"),e.Ea.delete(4),await aY(e)}(this))})}),this.Ra=new aW(n,r)}}async function aY(e){if(a6(e))for(let t of e.da)await t(!0)}async function aZ(e){for(let t of e.da)await t(!1)}function a0(e,t){e.Ia.has(t.targetId)||(e.Ia.set(t.targetId,t),a4(e)?a3(e):od(e).O_()&&a2(e,t))}function a1(e,t){let n=od(e);e.Ia.delete(t),n.O_()&&a5(e,t),0===e.Ia.size&&(n.O_()?n.L_():a6(e)&&e.Ra.set("Unknown"))}function a2(e,t){if(e.Va.Ue(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(ey.min())>0){let n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}od(e).Y_(t)}function a5(e,t){e.Va.Ue(t),od(e).Z_(t)}function a3(e){e.Va=new iu({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ia.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),od(e).start(),e.Ra.ua()}function a4(e){return a6(e)&&!od(e).x_()&&e.Ia.size>0}function a6(e){return 0===e.Ea.size}async function a8(e){e.Ra.set("Online")}async function a7(e){e.Ia.forEach((t,n)=>{a2(e,t)})}async function a9(e,t){e.Va=void 0,a4(e)?(e.Ra.ha(t),a3(e)):e.Ra.set("Unknown")}async function oe(e,t,n){if(e.Ra.set("Online"),t instanceof io&&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.Va.removeTarget(r))}(e,t)}catch(n){k(aJ,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await ot(e,n)}else if(t instanceof is?e.Va.Ze(t):t instanceof ia?e.Va.st(t):e.Va.tt(t),!n.isEqual(ey.min()))try{let t,r=await ai(e.localStore);n.compareTo(r)>
8=0&&await ((t=e.Va.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(t2.EMPTY_BYTE_STRING,r.snapshotVersion)),a5(e,t);let i=new iB(r.target,t,n,r.sequenceNumber);a2(e,i)}),e.remoteSyncer.applyRemoteEvent(t))}catch(t){k(aJ,"Failed to raise snapshot:",t),await ot(e,t)}}async function ot(e,t,n){if(!eV(t))throw t;e.Ea.add(1),await aZ(e),e.Ra.set("Offline"),n||(n=()=>ai(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{k(aJ,"Retrying IndexedDB access"),await n(),e.Ea.delete(1),await aY(e)})}function on(e,t){return t().catch(n=>ot(e,n,t))}async function or(e){var t;let n=of(e),r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:-1;for(;a6(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=of(e);n.O_()&&n.X_&&n.ea(t.mutations)}(e,t)}catch(t){await ot(e,t)}oi(e)&&os(e)}function oi(e){return a6(e)&&!of(e).x_()&&e.Ta.length>0}function os(e){of(e).start()}async function oa(e){of(e).ra()}async function oo(e){let t=of(e);for(let n of e.Ta)t.ea(n.mutations)}async function ol(e,t,n){let r=e.Ta.shift(),i=rZ.from(r,t,n);await on(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await or(e)}async function ou(e,t){t&&of(e).X_&&await async function(e,t){var n;if(r5(n=t.code)&&n!==V.ABORTED){let n=e.Ta.shift();of(e).B_(),await on(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await or(e)}}(e,t),oi(e)&&os(e)}async function oh(e,t){e.asyncQueue.verifyOperationInProgress(),k(aJ,"RemoteStore received new credentials");let n=a6(e);e.Ea.add(3),await aZ(e),n&&e.Ra.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ea.delete(3),await aY(e)}async function oc(e,t){t?(e.Ea.delete(2),await aY(e)):t||(e.Ea.add(2),await aZ(e),e.Ra.set("Unknown"))}function od(e){var t,n,r;return e.ma||(t=e.datastore,n=e.asyncQueue,r={Xo:a8.bind(null,e),t_:a7.bind(null,e),r_:a9.bind(null,e),H_:oe.bind(null,e)},t.sa(),e.ma=new aK(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r),e.da.push(async t=>{t?(e.ma.B_(),a4(e)?a3(e):e.Ra.set("Unknown")):(await e.ma.stop(),e.Va=void 0)})),e.ma}function of(e){var t,n,r;return e.fa||(t=e.datastore,n=e.asyncQueue,r={Xo:()=>Promise.resolve(),t_:oa.bind(null,e),r_:ou.bind(null,e),ta:oo.bind(null,e),na:ol.bind(null,e)},t.sa(),e.fa=new a$(n,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,r),e.da.push(async t=>{t?(e.fa.B_(),await or(e)):(await e.fa.stop(),e.Ta.length>0&&(k(aJ,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))})),e.fa}class om{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 om(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 og(e,t){if(M("AsyncQueue",`${t}: ${e}`),eV(e))return new q(V.UNAVAILABLE,`${t}: ${e}`);throw e}class op{static emptySet(e){return new op(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||es.comparator(t.key,n.key):(e,t)=>es.comparator(e.key,t.key),this.keyedMap=ry(),this.sortedSet=new tH(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 op)||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 op;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class oy{constructor(){this.ga=new tH(es.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,{Rt:e,pa:n}):this.ga=this.ga.insert(t,e)}ya(){let e=[];return this.ga.inorderTraversal((t,n)=>{e.push(n)}),e}}class ow{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=[];
8return t.forEach(e=>{s.push({type:0,doc:e})}),new ow(e,t,op.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)&&rl(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 ov{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some(e=>e.Da())}}class ob{constructor(){this.queries=oI(),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=oI(),t.forEach((t,n)=>{for(let t of n.Sa)t.onError(e)})}}function oI(){return new rm(e=>ru(e),rl)}async function oT(e,t){let n=3,r=t.query,i=e.queries.get(r);i?!i.ba()&&t.Da()&&(n=2):(i=new ov,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=og(n,`Initialization of query '${rh(t.query)}' failed`);return void t.onError(e)}e.queries.set(r,i),i.Sa.push(t),t.va(e.onlineState),i.wa&&t.Fa(i.wa)&&ox(e)}async function o_(e,t){let n=t.query,r=3,i=e.queries.get(n);if(i){let e=i.Sa.indexOf(t);e>=0&&(i.Sa.splice(e,1),0===i.Sa.length?r=+!t.Da():!i.ba()&&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 oE(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.Sa)e.Fa(r)&&(n=!0);i.wa=r}}n&&ox(e)}function oS(e,t,n){let r=e.queries.get(t);if(r)for(let e of r.Sa)e.onError(n);e.queries.delete(t)}function ox(e){e.Ca.forEach(e=>{e.next()})}(m=f||(f={})).Ma="default",m.Cache="cache";class oC{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 ow(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.qa||"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=ow.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 oA{constructor(e,t){this.Qa=e,this.byteLength=t}$a(){return"metadata"in this.Qa}}class oD{constructor(e){this.serializer=e}$s(e){return iS(this.serializer,e)}Us(e){return e.metadata.exists?ik(this.serializer,e.document,!1):nR.newNoDocument(this.$s(e.metadata.name),this.Ks(e.metadata.readTime))}Ks(e){return ib(e)}}class oN{constructor(e,t){this.Ua=e,this.serializer=t,this.Ka=[],this.Wa=[],this.collectionGroups=new Set,this.progress=ok(e)}get queries(){return this.Ka}get documents(){return this.Wa}Ga(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.Qa.namedQuery)this.Ka.push(e.Qa.namedQuery);else if(e.Qa.documentMetadata){this.Wa.push({metadata:e.Qa.documentMetadata}),e.Qa.documentMetadata.exists||++t;let n=en.fromString(e.Qa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.Qa.document&&(this.Wa[this.Wa.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 oD(this.serializer);for(let r of e)if(r.metadata.queries){let e=n.$s(r.metadata.name);for(let n of r.metadata.queries){let r=(t.get(n)||rT()).add(e);t.set(n,r)}}return t}async ja(e){let t=await ad(e,new oD(this.serializer),this.Wa,this.Ua.id),n=this.za(this.documents);for(let t of this.Ka)await af(e,t,n.get(t.name));return this.progress.taskState="Success",{progress:this.progress,Ja:this.collectionGroups,Ha:t}}}function ok(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class oM{constructor(e){this.key=e}}class oR{constructor(e){this.key=e}}class oP{constructor(e,t){this.query=e,this.Ya=t,this.Za=null,this.hasCachedResults=!1,this.current=!1,this.Xa=rT(),this.mutatedKeys=rT(),this.eu=rf(e),this.tu=new op(this.eu)}get nu(){return this.Ya}ru(e,t){let n=t?t.iu:new oy,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)=>
8{let u=r.get(e),h=rc(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,Cs: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,{Rt: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.Xa.size&&this.current&&!r?1:0,l=o!==this.Za;return(this.Za=o,0!==s.length||l)?{snapshot:new ow(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 oy,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{au:[]}}uu(e){return!this.Ya.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach(e=>this.Ya=this.Ya.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Ya=this.Ya.delete(e)),this.current=e.current)}_u(){if(!this.current)return[];let e=this.Xa;this.Xa=rT(),this.tu.forEach(e=>{this.uu(e.key)&&(this.Xa=this.Xa.add(e.key))});let t=[];return e.forEach(e=>{this.Xa.has(e)||t.push(new oR(e))}),this.Xa.forEach(n=>{e.has(n)||t.push(new oM(n))}),t}cu(e){this.Ya=e.Qs,this.Xa=rT();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return ow.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,0===this.Za,this.hasCachedResults)}}let oO="SyncEngine";class oF{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class oL{constructor(e){this.key=e,this.hu=!1}}class oV{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 rm(e=>ru(e),rl),this.Iu=new Map,this.Eu=new Set,this.du=new tH(es.comparator),this.Au=new Map,this.Ru=new sK,this.Vu={},this.mu=new Map,this.fu=sE.cr(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return!0===this.gu}}async function oq(e,t,n=!0){let r,i=la(e),s=i.Tu.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),r=s.view.lu()):r=await oB(i,t,n,!0),r}async function oU(e,t){let n=la(e);await oB(n,t,!0,!1)}async function oB(e,t,n,r){let i,s=await aa(e.localStore,rr(t)),a=s.targetId,o=e.sharedCl
8ientState.addLocalQueryTarget(a,n);return r&&(i=await oj(e,t,a,"current"===o,s.resumeToken)),e.isPrimaryClient&&n&&a0(e.remoteStore,s),i}async function oj(e,t,n,r,i){e.pu=(t,n,r)=>(async function(e,t,n,r){let i=t.view.ru(n);i.Cs&&(i=await al(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 o2(e,t.targetId,o.au),o.snapshot})(e,t,n,r);let s=await al(e.localStore,t,!0),a=new oP(t,s.Qs),o=a.ru(s.documents),l=ii.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),u=a.applyChanges(o,e.isPrimaryClient,l);o2(e,n,u.au);let h=new oF(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 oz(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=>!rl(e,t))),e.Tu.delete(t)):e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(r.targetId),e.sharedClientState.isActiveQueryTarget(r.targetId)||await ao(e.localStore,r.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(r.targetId),n&&a1(e.remoteStore,r.targetId),o0(e,r.targetId)}).catch(eN)):(o0(e,r.targetId),await ao(e.localStore,r.targetId,!0))}async function oG(e,t){let n=e.Tu.get(t),r=e.Iu.get(n.targetId);e.isPrimaryClient&&1===r.length&&(e.sharedClientState.removeLocalQueryTarget(n.targetId),a1(e.remoteStore,n.targetId))}async function oK(e,t,n){let r=lo(e);try{var i,s;let e,a,o,l,u,h=await (i=r.localStore,o=ep.now(),l=t.reduce((e,t)=>e.add(t.key),rT()),i.persistence.runTransaction("Locally write mutations","readwrite",n=>{let r=rg,s=rT();return i.Ns.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=rA(r.transform,e||null);null!=i&&(null===n&&(n=nM.empty()),n.set(r.field,i))}return n||null}(n,e.get(n.key).overlayedDocument);null!=t&&s.push(new r$(n.key,t,function e(t){let n=[];return tK(t.fields,(t,r)=>{let i=new ei([t]);if(nS(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 t0(n)}(t.value.mapValue),rq.exists(!0)))}
8return 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:rw(e)})));r.sharedClientState.addPendingMutation(h.batchId),s=h.batchId,(u=r.Vu[r.currentUser.toKey()])||(u=new tH(J)),u=u.insert(s,n),r.Vu[r.currentUser.toKey()]=u,await o3(r,h.changes),await or(r.remoteStore)}catch(t){let e=og(t,"Failed to persist write");n.reject(e)}}async function o$(e,t){try{var n,r;let i,s,a=await (n=e.localStore,i=(r=t).snapshotVersion,s=n.Ms,n.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{let t=n.Ns.newChangeBuffer({trackRemovals:!0});s=n.Ms;let a=[];r.targetChanges.forEach((t,o)=>{var l;let u=s.get(o);if(!u)return;a.push(n.Pi.removeMatchingKeys(e,t.removedDocuments,o).next(()=>n.Pi.addMatchingKeys(e,t.addedDocuments,o)));let h=u.withSequenceNumber(e.currentSequenceNumber);null!==r.targetMismatches.get(o)?h=h.withResumeToken(t2.EMPTY_BYTE_STRING,ey.min()).withLastLimboFreeSnapshotVersion(ey.min()):t.resumeToken.approximateByteSize()>0&&(h=h.withResumeToken(t.resumeToken,i)),s=s.insert(o,h),l=h,(0===u.resumeToken.approximateByteSize()||l.snapshotVersion.toMicroseconds()-u.snapshotVersion.toMicroseconds()>=3e8||t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size>0)&&a.push(n.Pi.updateTargetData(e,h))});let o=rg,l=rT();if(r.documentUpdates.forEach(t=>{r.resolvedLimboDocuments.has(t)&&a.push(n.persistence.referenceDelegate.updateLimboDocument(e,t))}),a.push(as(e,t,r.documentUpdates).next(e=>{o=e.ks,l=e.qs})),!i.isEqual(ey.min())){let t=n.Pi.getLastRemoteSnapshotVersion(e).next(t=>n.Pi.setTargetsMetadata(e,e.currentSequenceNumber,i));a.push(t)}return ek.waitFor(a).next(()=>t.apply(e)).next(()=>n.localDocuments.getLocalViewOfDocuments(e,o,l)).next(()=>o)}).then(e=>(n.Ms=s,e)));
8t.targetChanges.forEach((t,n)=>{let r=e.Au.get(n);r&&(L(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?r.hu=!0:t.modifiedDocuments.size>0?L(r.hu,14607):t.removedDocuments.size>0&&(L(r.hu,42227),r.hu=!1))}),await o3(e,a,t)}catch(e){await eN(e)}}function oQ(e,t,n){if(e.isPrimaryClient&&0===n||!e.isPrimaryClient&&1===n){var r;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.Sa)e.va(t)&&(n=!0)}),n&&ox(r),i.length&&e.Pu.H_(i),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function oH(e,t,n){e.sharedClientState.updateQueryState(t,"rejected",n);let r=e.Au.get(t),i=r&&r.key;if(i){let n=new tH(es.comparator);n=n.insert(i,nR.newNoDocument(i,ey.min()));let r=rT().add(i),s=new ir(ey.min(),new Map,new tH(J),n,r);await o$(e,s),e.du=e.du.remove(i),e.Au.delete(t),o5(e)}else await ao(e.localStore,t,!1).then(()=>o0(e,t,n)).catch(eN)}async function oW(e,t){let n=t.batch.batchId;try{var r,i;let s=await (r=e.localStore,i=t,r.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let t,n,s,a=i.batch.keys(),o=r.Ns.newChangeBuffer({trackRemovals:!0});return(n=(t=i.batch).keys(),s=ek.resolve(),n.forEach(n=>{s=s.next(()=>o.getEntry(e,n)).next(e=>{let r=i.docVersions.get(n);L(null!==r,48541),0>e.version.compareTo(r)&&(t.applyToRemoteDocument(e,i),e.isValidDocument()&&(e.setReadTime(i.commitVersion),o.addEntry(e)))})}),s.next(()=>r.mutationQueue.removeMutationBatch(e,t))).next(()=>o.apply(e)).next(()=>r.mutationQueue.performConsistencyCheck(e)).next(()=>r.documentOverlayCache.removeOverlaysForBatchId(e,a,i.batch.batchId)).next(()=>r.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=rT();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}(i))).next(()=>r.localDocuments.getDocuments(e,a))}));oZ(e,n,null),oY(e,n),e.sharedClientState.updateMutationState(n,"acknowledged"),await o3(e,s)}catch(e){await eN(e)}}async function oJ(e,t,n){try{var r;let i=await (r=e.localStore,r.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let n;return r.mutationQueue.lookupMutationBatch(e,t).next(t=>(L(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))}));oZ(e,t,n),oY(e,t),e.sharedClientState.updateMutationState(t,"rejected",n),await o3(e,i)}catch(e){await eN(e)}}async function oX(e,t){a6(e.remoteStore)||k(oO,"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{var n;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=og(n,"Initialization of waitForPendingWrites() operation failed");t.reject(e)}}function oY(e,t){(e.mu.get(t)||[]).forEach(e=>{e.resolve()}),e.mu.delete(t)}function oZ(e,t,n){let r=e.Vu[e.currentUser.toKey()];if(r){let i=r.get(t);i&&(n?i.reject(n):i.resolve(),r=r.remove(t)),e.Vu[e.currentUser.toKey()]=r}}function o0(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.Ru.jr(t).forEach(t=>{e.Ru.containsKey(t)||o1(e,t)})}function o1(e,t){e.Eu.delete(t.path.canonicalString());let n=e.du.get(t);null!==n&&(a1(e.remoteStore,n),e.du=e.du.remove(t),e.Au.delete(n),o5(e))}function o2(e,t,n){for(let r of n)r instanceof oM?(e.Ru.addReference(r.key,t),function(e,t){let n=t.key,r=n.path.canonicalString();e.du.get(n)||e.Eu.has(r)||(k(oO,"New document in limbo: "+n),e.Eu.add(r),o5(e))}(e,r)):r instanceof oR?(k(oO,"Document no longer in limbo: "+r.key),e.Ru.removeReference(r.key,t),e.Ru.containsKey(r.key)||o1(e,r.key)):O(19791,{wu:r})}function o5(e){for(;e.Eu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){let t=e.Eu.values().next().value;e.Eu.delete(t);let n=new es(en.fromString(t)),r=e.fu.next();e.Au.set(r,new oL(n)),e.du=e.du.insert(n,r),a0(e.remoteStore,new iB(rr(n9(n.path)),r,"TargetPurposeLimboResolution",e$.ce))}}async function o3(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;
8e.sharedClientState.updateQueryState(o.targetId,r?"current":"not-current")}if(t){r.push(t);let e=s7.As(o.targetId,t);i.push(e)}}))}),await Promise.all(s),e.Pu.H_(r),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",n=>ek.forEach(t,t=>ek.forEach(t.Es,r=>e.persistence.referenceDelegate.addReference(n,t.targetId,r)).next(()=>ek.forEach(t.ds,r=>e.persistence.referenceDelegate.removeReference(n,t.targetId,r)))))}catch(e){if(!eV(e))throw e;k(at,"Failed to update sequence numbers: "+e)}for(let n of t){let t=n.targetId;if(!n.fromCache){let n=e.Ms.get(t),r=n.snapshotVersion,i=n.withLastLimboFreeSnapshotVersion(r);e.Ms=e.Ms.insert(t,i)}}}(e.localStore,i))}async function o4(e,t){if(!e.currentUser.isEqual(t)){k(oO,"User change. New user:",t.toKey());let n=await ar(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 o3(e,n.Ls)}}function o6(e,t){let n=e.Au.get(t);if(n&&n.hu)return rT().add(n.key);{let n=rT(),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 o8(e,t){let n=await al(e.localStore,t.query,!0),r=t.view.cu(n);return e.isPrimaryClient&&o2(e,t.targetId,r.au),r}async function o7(e,t){return ah(e.localStore,t).then(t=>o3(e,t))}async function o9(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.er(e,t).next(t=>t?i.localDocuments.getDocuments(e,t):ek.resolve(null))));null!==o?("pending"===n?await or(e.remoteStore):"acknowledged"===n||"rejected"===n?(oZ(e,t,r||null),oY(e,t),s=e.localStore,s.mutationQueue.ir(t)):O(6
8720,"Unknown batchState",{Su:n}),await o3(e,o)):k(oO,"Cannot apply mutation batch with id: "+t)}async function le(e,t){if(la(e),lo(e),!0===t&&!0!==e.gu){let t=e.sharedClientState.getAllActiveQueryTargets(),n=await lt(e,t.toArray());for(let t of(e.gu=!0,await oc(e.remoteStore,!0),n))a0(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(()=>(o0(e,i),ao(e.localStore,i,!0))),a1(e.remoteStore,i)}),await n,await lt(e,t),e.Au.forEach((t,n)=>{a1(e.remoteStore,n)}),e.Ru.Jr(),e.Au=new Map,e.du=new tH(es.comparator),e.gu=!1,await oc(e.remoteStore,!1)}}async function lt(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 aa(e.localStore,rr(s[0])),s)){let t=e.Tu.get(n),r=await o8(e,t);r.snapshot&&i.push(r.snapshot)}else{let r=await au(e.localStore,n);t=await aa(e.localStore,r),await oj(e,ln(r),n,!1,t.resumeToken)}r.push(t)}return e.Pu.H_(i),r}function ln(e){var t,n,r,i,s;return t=e.path,n=e.collectionGroup,r=e.orderBy,i=e.filters,s=e.limit,new n7(t,n,r,i,s,"F",e.startAt,e.endAt)}function lr(e){return e.localStore.persistence.Ts()}async function li(e,t,n,r){if(e.gu)return void k(oO,"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 ah(e.localStore,rd(i[0])),s=ir.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,t2.EMPTY_BYTE_STRING);await o3(e,r,s);break}case"rejected":await ao(e.localStore,t,!0),o0(e,t,r);break;default:O(64155,n)}}async function ls(e,t,n){let r=la(e);if(r.gu){for(let e of t){if(r.Iu.has(e)&&r.sharedClientState.isActiveQueryTarget(e)){k(oO,"Adding an already active target "+e);continue}let t=await au(r.localStore,e),n=await aa(r.localStore,t);await oj(r,ln(t),n.targetId,!1,n.resumeToken),a0(r.remoteStore,n)}for(let e of n)r.Iu.has(e)&&await ao(r.localStore,e,!1).then(()=>{a1(r.remoteStore,e),o0(r,e)}).catch(eN)}}function la(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=o$.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=o6.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=oH.bind(null,e),e.Pu.H_=oE.bind(null,e.eventManager),e.Pu.yu=oS.bind(null,e.eventManager),e}function lo(e){return e.remoteStore.remoteSyncer.applySuccessfulWrite=oW.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=oJ.bind(null,e),e}class ll{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=aB(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 ae,new an(t,n,e.initialUser,this.serializer)}Cu(e){return new sX(sZ.mi,this.serializer)}Du(e){return new aC}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}ll.provider={build:()=>new ll};class lu extends ll{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){return L(this.persistence.referenceDelegate instanceof s0,46915),new sN(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Cu(e){let t=void 0!==this.cacheSizeBytes?sw.withCacheSize(this.cacheSizeBytes):sw.DEFAULT;return new sX(e=>s0.mi(e,t),this.serializer)}}class lh extends ll{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 lo(this.xu.syncEngine),await or(this.xu.remoteStore),await this.persistence.Ji(()=>(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 ae,new an(t,n,e.initialUser,this.serializer)}Fu(e,t){return new sN(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Mu(e,t){let n=new eK(t,this.persistence);return new eG(e.asyncQueue,n)}Cu(e){let t=s8(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?sw.withCacheSize(this.cacheSizeBytes):sw.DEFAULT;return new s6(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,aq(),aU(),this.serializer,this.sharedCl
8ientState,!!this.forceOwnership)}Du(e){return new aC}}class lc extends lh{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 ax&&(this.sharedClientState.syncEngine={Co:o9.bind(null,t),vo:li.bind(null,t),Fo:ls.bind(null,t),Ts:lr.bind(null,t),Do:o7.bind(null,t)},await this.sharedClientState.start()),await this.persistence.Ji(async e=>{await le(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=aq();if(!ax.v(t))throw new q(V.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");let n=s8(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new ax(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class ld{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=>oQ(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=o4.bind(null,this.syncEngine),await oc(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ob}createDatastore(e){var t;let n=aB(e.databaseInfo.databaseId),r=new aV(e.databaseInfo);return t=e.authCredentials,new aH(t,e.appCheckCredentials,r,n)}createRemoteStore(e){var t,n;return t=this.localStore,n=this.datastore,new aX(t,n,e.asyncQueue,e=>oQ(this.syncEngine,e,0),aN.v()?new aN:new aA)}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 oV(n,r,i,s,a,o),t&&(l.gu=!0),l}async terminate(){await async function(e){k(aJ,"RemoteStore shutting down."),e.Ea.add(5),await aZ(e),e.Aa.shutdown(),e.Ra.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}function lf(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()}}ld.provider={build:()=>new ld};class lm{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):M("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class lg{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.$a()?this.metadata.resolve(e.Qa.metadata):this.metadata.reject(Error(`The first element of the bundle is not a metadata, it is 9 ${JSON.stringify(e?.Qa)}`))},e=>this.metadata.reject(e))}close(){return this.Bu.cancel()}async getMetadata(){return this.metadata.promise}async bu(){return await this.getMetadata(),this.ku()}async ku(){let e=await this.qu();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 oA(JSON.parse(await this.$u(n)),e.length+n)}Uu(){return this.buffer.findIndex(e=>123===e)}async qu(){for(;0>this.Uu()&&!await this.Ku(););if(0===this.buffer.length)return null;let e=this.Uu();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 $u(e){for(;this.buffer.length<e;)await this.Ku()&&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 Ku(){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}}
9class lp{constructor(e,t){this.bundleData=e,this.serializer=t,this.cursor=0,this.elements=[];let n=this.bu();if(!n||!n.$a())throw Error(`The first element of the bundle is not a metadata object, it is 10 ${JSON.stringify(n?.Qa)}`);this.metadata=n;do null!==(n=this.bu())&&this.elements.push(n);while(null!==n)}getMetadata(){return this.metadata}Wu(){return this.elements}bu(){if(this.cursor===this.bundleData.length)return null;let e=this.qu();return new oA(JSON.parse(this.$u(e)),e)}$u(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)}qu(){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 ly{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=>iE(e.serializer,t))},r=await e.Ho("BatchGetDocuments",e.serializer.databaseId,en.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?(L(!!t.found,43571),t.found.name,t.found.updateTime,r=iS(n,t.found.name),s=ib(t.found.updateTime),a=t.found.createTime?ib(t.found.createTime):ey.min(),o=new nM({mapValue:{fields:t.found.fields}}),nR.newFoundDocument(r,s,a,o)):"missing"in t?(L(!!t.missing,3894),L(!!t.readTime,22933),l=iS(n,t.missing),u=ib(t.readTime),nR.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());L(!!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 rJ(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=es.fromPath(t);this.mutations.push(new rX(n,this.precondition(n)))}),await async function(e,t){let n={writes:t.map(t=>iM(e.serializer,t))};await e.Go("Commit",e.serializer.databaseId,en.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=ey.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(ey.min())?rq.exists(!1):rq.updateTime(t):rq.none()}preconditionForUpdate(e){let t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(ey.min()))throw new q(V.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return rq.updateTime(t)}return rq.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class lw{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 aj(this.asyncQueue,"transaction_retry")}ju(){this.zu-=1,this.Ju()}Ju(){this.M_.p_(async()=>{let e=new ly(this.datastore),t=this.Hu(e);t&&t.then(t=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(t)}).catch(e=>{this.Yu(e)}))}).catch(e=>{this.Yu(e)})})}Hu(e){try{let t=this.updateFunction(e);return!eQ(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}}Yu(e){this.zu>0&&this.Zu(e)?(this.zu-=1,this.asyncQueue.enqueueAndForget(()=>(this.Ju(),Promise.resolve()))):this.deferred.reject(e)}Zu(e){if("FirebaseError"===e?.name){let t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!r5(t)}return!1}}let lv="FirestoreClient";class lb{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=C.UNAUTHENTICATED,this.clientId=W.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,async e=>{k(lv,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,e=>(k(lv,"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()}
10catch(n){let t=og(n,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function lI(e,t){e.asyncQueue.verifyOperationInProgress(),k(lv,"Initializing OfflineComponentProvider");let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await ar(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function lT(e,t){e.asyncQueue.verifyOperationInProgress();let n=await l_(e);k(lv,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener(e=>oh(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,n)=>oh(t.remoteStore,n)),e._onlineComponents=t}async function l_(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){k(lv,"Using user provided OfflineComponentProvider");try{await lI(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 lI(e,new ll)}}else k(lv,"Using default OfflineComponentProvider"),await lI(e,new lu(void 0));return e._offlineComponents}async function lE(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(k(lv,"Using user provided OnlineComponentProvider"),await lT(e,e._uninitializedComponentsProvider._online)):(k(lv,"Using default OnlineComponentProvider"),await lT(e,new ld))),e._onlineComponents}function lS(e){return l_(e).then(e=>e.persistence)}function lx(e){return l_(e).then(e=>e.localStore)}function lC(e){return lE(e).then(e=>e.remoteStore)}function lA(e){return lE(e).then(e=>e.syncEngine)}function lD(e){return lE(e).then(e=>e.datastore)}async function lN(e){let t=await lE(e),n=t.eventManager;return n.onListen=oq.bind(null,t.syncEngine),n.onUnlisten=oz.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=oU.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=oG.bind(null,t.syncEngine),n}function lk(e,t,n={}){let r=new U;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await lN(e),s=e.asyncQueue,a=new lm({next:e=>{a.Nu(),s.enqueueAndForget(()=>o_(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)}),oT(i,o=new oC(n9(t.path),a,{includeMetadataChanges:!0,qa:!0}))}),r.promise}function lM(e,t,n={}){let r=new U;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await lN(e),s=e.asyncQueue,o=new oC(t,a=new lm({next:e=>{a.Nu(),s.enqueueAndForget(()=>o_(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,qa:!0}),oT(i,o)}),r.promise}function lR(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}let lP=new Map,lO="firestore.googleapis.com";class lF{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=lO,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}eo("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=lR(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 lL{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 lF({}),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 lF(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
10d 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=lP.get(this))&&(k("ComponentProvider","Removing Datastore"),lP.delete(this),e.terminate()),Promise.resolve()}}function lV(e,t,n,r={}){e=ed(e,lL);let i=(0,b.isCloudWorkstation)(t),s=e._getSettings(),a={...s,emulatorOptions:e._getEmulatorOptions()},o=`${t}:${n}`;i&&((0,b.pingServer)(`https://${o}`),(0,b.updateEmulatorBanner)("Firestore",!0)),s.host!==lO&&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,b.deepEqual)(l,a)&&(e._setSettings(l),r.mockUserToken)){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=C.MOCK_USER;else{t=(0,b.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 C(i)}e._authCredentials=new z(new B(t,n))}}class lq{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new lq(this.firestore,e,this._query)}}class lU{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 lB(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new lU(this.firestore,e,this._key)}toJSON(){return{type:lU._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,n){if(eg(t,lU._jsonSchema))return new lU(e,n||null,new es(en.fromString(t.referencePath)))}}lU._jsonSchemaVersion="firestore/documentReference/1.0",lU._jsonSchema={type:em("string",lU._jsonSchemaVersion),referencePath:em("string")};class lB extends lq{constructor(e,t,n){super(e,t,n9(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 lU(this.firestore,null,new es(e))}withConverter(e){return new lB(this.firestore,e,this._path)}}function lj(e,t,...n){if(e=(0,b.getModularInstance)(e),1==arguments.length&&(t=W.newId()),ea("doc","path",t),e instanceof lL){let r=en.fromString(t,...n);return el(r),new lU(e,null,new es(r))}{if(!(e instanceof lU||e instanceof lB))throw new q(V.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=e._path.child(en.fromString(t,...n));return el(r),new lU(e.firestore,e instanceof lB?e.converter:null,new es(r))}}function lz(e,t){return e=(0,b.getModularInstance)(e),t=(0,b.getModularInstance)(t),e instanceof lq&&t instanceof lq&&e.firestore===t.firestore&&rl(e._query,t._query)&&e.converter===t.converter}let lG="AsyncQueue";class lK{constructor(e=Promise.resolve()){this.Xu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new aj(this,"async_queue_retry"),this._c=()=>{let e=aU();e&&k(lG,"Visibility state changed to "+e.visibilityState),this.M_.w_()},this.ac=e;const t=aU();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=aU();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.Xu.push(e),this.lc()))}async lc(){if(0!==this.Xu.length){try{await this.Xu[0](),this.Xu.shift(),this.M_.reset()}catch(e){if(!eV(e))throw e;k(lG,"Operation failed with retryable error: "+e)}this.Xu.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,M("INTERNAL UNHANDLED ERROR: ",l$(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=om.createAndSchedule(this,e,t,n,e=>this.hc(e));return this.tc.push(r),r}uc(){this.nc&&O(47125,{Pc:l$(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)=>
10e.targetTimeMs-t.targetTimeMs),this.tc))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Tc()})}dc(e){this.oc.push(e)}hc(e){let t=this.tc.indexOf(e);this.tc.splice(t,1)}}function l$(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}function lQ(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 lH{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 lW extends lL{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new lK,this._persistenceKey=r?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new lK(e),this._firestoreClient=void 0,await e}}}function lJ(e){if(e._terminated)throw new q(V.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||lX(e),e._firestoreClient}function lX(e){var t,n,r;let i,s=e._freezeSettings(),a=(t=e._databaseId,n=e._app?.options.appId||"",new ni(t,n,e._persistenceKey,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,lR(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator));e._componentsProvider||s.localCache?._offlineComponentProvider&&s.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),e._firestoreClient=new lb(e._authCredentials,e._appCheckCredentials,e._queue,a,e._componentsProvider&&(r=e._componentsProvider,i=r?._online.build(),{_offline:r?._offline.build(i),_online:i}))}async function lY(e){R("enableMultiTabIndexedDbPersistence() will be deprecated
10in the future, you can use `FirestoreSettings.cache` instead.");let t=e._freezeSettings();lZ(e,ld.provider,{build:e=>new lc(e,t.cacheSizeBytes)})}function lZ(e,t,n){if((e=ed(e,lW))._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},lX(e)}function l0(e,t){let n=lJ(e=ed(e,lW)),r=new lH;return function(e,t,n,r){var i;let s=(i=aB(t),new lg(function(e){if(e instanceof Uint8Array)return lf(e,void 0);if(e instanceof ArrayBuffer)return lf(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?r6().encode(n):n),i));e.asyncQueue.enqueueAndForget(async()=>{var t=await lA(e);(async function(e,t,n){try{var r,i;let s,a=await t.getMetadata();if(await (r=e.localStore,s=ib(a.createTime),r.persistence.runTransaction("hasNewerBundle","readonly",e=>r.Ii.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(ok(a));let o=new oN(a,t.serializer),l=await t.bu();for(;l;){let e=await o.Ga(l);e&&n._updateProgress(e),l=await t.bu()}let u=await o.ja(e.localStore);return await o3(e,u.Ha,void 0),await (i=e.localStore,i.persistence.runTransaction("Save bundle","readwrite",e=>i.Ii.saveBundleMetadata(e,a))),n._completeWith(u.progress),Promise.resolve(u.Ja)}catch(e){return R(oO,`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(t,s,r).then(e=>{t.sharedClientState.notifyBundleLoaded(e)})})}(n,e._databaseId,t,r),r}function l1(e,t){var n;return(n=lJ(e=ed(e,lW)),n.asyncQueue.enqueue(async()=>{var e;return e=await lx(n),e.persistence.runTransaction("Get named query","readonly",n=>e.Ii.getNamedQuery(n,t))})).then(t=>t?new lq(e,null,t.query):null)}class l2{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class l5{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}}class l3{constructor(e){this._byteString=e}static fromBase64String(e){try{return new l3(t2.fromBase64String(e))}catch(e){throw new q(V.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new l3(t2.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:l3._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(eg(e,l3._jsonSchema))return l3.fromBase64String(e.bytes)}}l3._jsonSchemaVersion="firestore/bytes/1.0",l3._jsonSchema={type:em("string",l3._jsonSchemaVersion),bytes:em("string")};class l4{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 ei(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class l6{constructor(e){this._methodName=e}}class l8{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 J(this._lat,e._lat)||J(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:l8._jsonSchemaVersion}}static fromJSON(e){if(eg(e,l8._jsonSchema))return new l8(e.latitude,e.longitude)}}l8._jsonSchemaVersion="firestore/geoPoint/1.0",l8._jsonSchema={type:em("string",l8._jsonSchemaVersion),latitude:em("number"),longitude:em("number")};class l7{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:l7._jsonSchemaVersion,vectorValues:this._values}}
10static fromJSON(e){if(eg(e,l7._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new l7(e.vectorValues);throw new q(V.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}l7._jsonSchemaVersion="firestore/vectorValue/1.0",l7._jsonSchema={type:em("string",l7._jsonSchemaVersion),vectorValues:em("object")};let l9=/^__.*__$/;class ue{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new r$(e,this.data,this.fieldMask,t,this.fieldTransforms):new rK(e,this.data,t,this.fieldTransforms)}}class ut{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new r$(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function un(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw O(40011,{Ac:e})}}class ur{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Rc(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get Ac(){return this.settings.Ac}Vc(e){return new ur({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}mc(e){let t=this.path?.child(e),n=this.Vc({path:t,fc:!1});return n.gc(e),n}yc(e){let t=this.path?.child(e),n=this.Vc({path:t,fc:!1});return n.Rc(),n}wc(e){return this.Vc({path:void 0,fc:!0})}Sc(e){return u_(e,this.settings.methodName,this.settings.bc||!1,this.path,this.settings.Dc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}Rc(){if(this.path)for(let e=0;e<this.path.length;e++)this.gc(this.path.get(e))}gc(e){if(0===e.length)throw this.Sc("Document fields must not be empty");if(un(this.Ac)&&l9.test(e))throw this.Sc('Document fields cannot begin and end with "__"')}}class ui{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||aB(e)}Cc(e,t,n,r=!1){return new ur({Ac:e,methodName:t,Dc:n,path:ei.emptyPath(),fc:!1,bc:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function us(e){let t=e._freezeSettings(),n=aB(e._databaseId);return new ui(e._databaseId,!!t.ignoreUndefinedProperties,n)}function ua(e,t,n,r,i,s={}){let a,o,l=e.Cc(s.merge||s.mergeFields?2:0,t,n,i);uv("Data must be an object, but it was:",l,r);let u=uy(r,l);if(s.merge)a=new t0(l.fieldMask),o=l.fieldTransforms;else if(s.mergeFields){let e=[];for(let r of s.mergeFields){let i=ub(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.`);uE(e,i)||e.push(i)}a=new t0(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new ue(new nM(u),a,o)}class uo extends l6{_toFieldTransform(e){if(2!==e.Ac)throw 1===e.Ac?e.Sc(`${this._methodName}() can only appear at the top level of your update data`):e.Sc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof uo}}function ul(e,t,n){return new ur({Ac:3,Dc:t.settings.Dc,methodName:e._methodName,fc:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class uu extends l6{_toFieldTransform(e){return new rL(e.path,new rD)}isEqual(e){return e instanceof uu}}class uh extends l6{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=ul(this,e,!0),n=new rN(this.vc.map(e=>up(e,t)));return new rL(e.path,n)}isEqual(e){return e instanceof uh&&(0,b.deepEqual)(this.vc,e.vc)}}class uc extends l6{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=ul(this,e,!0),n=new rM(this.vc.map(e=>up(e,t)));return new rL(e.path,n)}isEqual(e){return e instanceof uc&&(0,b.deepEqual)(this.vc,e.vc)}}class ud extends l6{constructor(e,t){super(e),this.Fc=t}_toFieldTransform(e){let t=new rP(e.serializer,rx(e.serializer,this.Fc));return new rL(e.path,t)}isEqual(e){return e instanceof ud&&this.Fc===e.Fc}}function uf(e,t,n,r){let i=e.Cc(1,t,n);uv("Data must be an object, but it was:",i,r);let s=[],a=nM.empty();return tK(r,(e,r)=>{let o=uT(t,e,n);r=(0,b.getModularInstance)(r);let l=i.yc(o);if(r instanceof uo)s.push(o);else{let e=up(r,l);null!=e&&(s.push(o),a.set(o,e))}}),new ut(a,new t0(s),i.fieldTransforms)}function um(e,t,n,r,i,s){let a=e.Cc(1,t,n),o=[ub(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(ub(t,s[e])),l.push(s[e+1]);let u=[],h=nM.empty();for(let e=o.length-1;e>=0;
10--e)if(!uE(u,o[e])){let t=o[e],n=l[e];n=(0,b.getModularInstance)(n);let r=a.yc(t);if(n instanceof uo)u.push(t);else{let e=up(n,r);null!=e&&(u.push(t),h.set(t,e))}}return new ut(h,new t0(u),a.fieldTransforms)}function ug(e,t,n,r=!1){return up(n,e.Cc(r?4:3,t))}function up(e,t){if(uw(e=(0,b.getModularInstance)(e)))return uv("Unsupported field value:",t,e),uy(e,t);if(e instanceof l6)return function(e,t){if(!un(t.Ac))throw t.Sc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Sc(`${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.fc&&4!==t.Ac)throw t.Sc("Nested arrays are not supported");let n=[],r=0;for(let i of e){let e=up(i,t.wc(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}var n=e,r=t;if(null===(n=(0,b.getModularInstance)(n)))return{nullValue:"NULL_VALUE"};if("number"==typeof n)return rx(r.serializer,n);if("boolean"==typeof n)return{booleanValue:n};if("string"==typeof n)return{stringValue:n};if(n instanceof Date){let e=ep.fromDate(n);return{timestampValue:iw(r.serializer,e)}}if(n instanceof ep){let e=new ep(n.seconds,1e3*Math.floor(n.nanoseconds/1e3));return{timestampValue:iw(r.serializer,e)}}if(n instanceof l8)return{geoPointValue:{latitude:n.latitude,longitude:n.longitude}};if(n instanceof l3)return{bytesValue:iv(r.serializer,n._byteString)};if(n instanceof lU){let e=r.databaseId,t=n.firestore._databaseId;if(!t.isEqual(e))throw r.Sc(`Document reference is for database ${t.projectId}/${t.database} but should be for database ${e.projectId}/${e.database}`);return{referenceValue:iI(n.firestore._databaseId||r.databaseId,n._key.path)}}if(n instanceof l7)return{mapValue:{fields:{[no]:{stringValue:nh},[nc]:{arrayValue:{values:n.toArray().map(e=>{if("number"!=typeof e)throw r.Sc("VectorValues must only contain numeric values.");return rE(r.serializer,e)})}}}}};throw r.Sc(`Unsupported field value: ${ec(n)}`)}function uy(e,t){let n={};return tQ(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):tK(e,(e,r)=>{let i=up(r,t.mc(e));null!=i&&(n[e]=i)}),{mapValue:{fields:n}}}function uw(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof ep||e instanceof l8||e instanceof l3||e instanceof lU||e instanceof l6||e instanceof l7)}function uv(e,t,n){if(!uw(n)||!eh(n)){let r=ec(n);throw"an object"===r?t.Sc(e+" a custom object"):t.Sc(e+" "+r)}}function ub(e,t,n){if((t=(0,b.getModularInstance)(t))instanceof l4)return t._internalPath;if("string"==typeof t)return uT(e,t);throw u_("Field path arguments must be of type string or ",e,!1,void 0,n)}let uI=RegExp("[~\\*/\\[\\]]");function uT(e,t,n){if(t.search(uI)>=0)throw u_(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new l4(...t.split("."))._internalPath}catch(r){throw u_(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function u_(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 uE(e,t){return e.some(e=>e.isEqual(t))}class uS{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 lU(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let e=new ux(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(uC("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class ux extends uS{data(){return super.data()}}function uC(e,t){return"string"==typeof t?uT(e,t):t instanceof l4?t._internalPath:t._delegate._internalPath}function uA(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new q(V.UNIMPLEMENT
10ED,"limitToLast() queries require specifying at least one orderBy() clause")}class uD{}class uN extends uD{}class uk extends uN{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new uk(e,t,n)}_apply(e){let t=this._parse(e);return uU(e._query,t),new lq(e.firestore,e.converter,ra(e._query,t))}_parse(e){let t=us(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){uq(a,s);let t=[];for(let n of a)t.push(uV(r,e,n));o={arrayValue:{values:t}}}else o=uV(r,e,a)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||uq(a,s),o=ug(n,t,a,"in"===s||"not-in"===s);return nq.create(i,s,o)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}class uM extends uD{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new uM(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]:nU.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())uU(n,e),n=ra(n,e)}(e._query,t),new lq(e.firestore,e.converter,ra(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class uR extends uN{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new uR(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 nL(t,n)}(e._query,this._field,this._direction);return new lq(e.firestore,e.converter,(t=e._query,n=t.explicitOrderBy.concat([r]),new n7(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)))}}class uP extends uN{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new uP(e,t,n)}_apply(e){return new lq(e.firestore,e.converter,ro(e._query,this._limit,this._limitType))}}class uO extends uN{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new uO(e,t,n)}_apply(e){var t;let n=uL(e,this.type,this._docOrFields,this._inclusive);return new lq(e.firestore,e.converter,(t=e._query,new n7(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,n,t.endAt)))}}class uF extends uN{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new uF(e,t,n)}_apply(e){var t;let n=uL(e,this.type,this._docOrFields,this._inclusive);return new lq(e.firestore,e.converter,(t=e._query,new n7(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,n)))}}function uL(e,t,n,r){if(n[0]=(0,b.getModularInstance)(n[0]),n[0]instanceof uS)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 rn(e))if(n.field.isKeyField())s.push(nb(t,r.key));else{let e=r.data.field(n.field);if(nt(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 nP(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{let i=us(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];
10if(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(!rt(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(en.fromString(l));if(!es.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 es(n);o.push(nb(t,i))}else{let e=ug(n,r,l);o.push(e)}}return new nP(o,s)}(e._query,e.firestore._databaseId,i,t,n,r)}}function uV(e,t,n){if("string"==typeof(n=(0,b.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(!rt(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(en.fromString(n));if(!es.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 nb(e,new es(r))}if(n instanceof lU)return nb(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: ${ec(n)}.`)}function uq(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 uU(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 uB(e,t){if(!(t instanceof uk||t instanceof uM))throw new q(V.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class uj{convertValue(e,t="none"){switch(nf(e)){case 0:return null;case 1:return e.booleanValue;case 2:return t4(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(t6(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 tK(e,(e,r)=>{n[e]=this.convertValue(r,t)}),n}convertVectorValue(e){return new l7(e.fields?.[nc].arrayValue?.values?.map(e=>t4(e.doubleValue)))}convertGeoPoint(e){return new l8(t4(e.latitude),t4(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let n=nn(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(nr(e));default:return null}}convertTimestamp(e){let t=t3(e);return new ep(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=en.fromString(e);L(iU(n),9688,{name:e});let r=new na(n.get(1),n.get(3)),i=new es(n.popFirst(5));return r.isEqual(t)||M(`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}}function uz(e,t,n){return e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t}class uG extends uj{constructor(e){super(),this.firestore=e}convertBytes(e){return new l3(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
10return new lU(this.firestore,null,t)}}function uK(){return new l2("count")}let u$="NOT SUPPORTED";class uQ{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class uH extends uS{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 uW(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(uC("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=uH._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}}uH._jsonSchemaVersion="firestore/documentSnapshot/1.0",uH._jsonSchema={type:em("string",uH._jsonSchemaVersion),bundleSource:em("string","DocumentSnapshot"),bundleName:em("string"),bundle:em("string")};class uW extends uH{data(e={}){return super.data(e)}}class uJ{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new uQ(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 uW(this._firestore,this._userDataWriter,n.key,n,new uQ(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 uW(e._firestore,e._userDataWriter,n.doc.key,n.doc,new uQ(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 uW(e._firestore,e._userDataWriter,t.doc.key,t.doc,new uQ(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=uJ._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=W.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let t=[],n=[],r=[];return 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}}
10uJ._jsonSchemaVersion="firestore/querySnapshot/1.0",uJ._jsonSchema={type:em("string",uJ._jsonSchemaVersion),bundleSource:em("string","QuerySnapshot"),bundleName:em("string"),bundle:em("string")};class uX extends uj{constructor(e){super(),this.firestore=e}convertBytes(e){return new l3(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new lU(this.firestore,null,t)}}function uY(e,...t){var n;let r,i,s,a,o;e=(0,b.getModularInstance)(e);let l={includeMetadataChanges:!1,source:"default"},u=0;"object"!=typeof t[0]||lQ(t[u])||(l=t[u++]);let h={includeMetadataChanges:l.includeMetadataChanges,source:l.source};if(lQ(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 lU)i=ed(e.firestore,lW),s=n9(e._key.path),r={next:n=>{t[u]&&t[u](u0(i,e,n))},error:t[u+1],complete:t[u+2]};else{let n=ed(e,lq);i=ed(n.firestore,lW),s=n._query;let a=new uX(i);r={next:e=>{t[u]&&t[u](new uJ(i,a,n,e))},error:t[u+1],complete:t[u+2]},uA(e._query)}return n=lJ(i),o=new oC(s,a=new lm(r),h),n.asyncQueue.enqueueAndForget(async()=>oT(await lN(n),o)),()=>{a.Nu(),n.asyncQueue.enqueueAndForget(async()=>o_(await lN(n),o))}}function uZ(e,t){var n;let r;return n=lJ(e),r=new U,n.asyncQueue.enqueueAndForget(async()=>oK(await lA(n),t,r)),r.promise}function u0(e,t,n){let r=n.docs.get(t._key),i=new uX(e);return new uH(e,i,t._key,r,new uQ(n.hasPendingWrites,n.fromCache),t.converter)}function u1(e,t){var n;let r,i=ed(e.firestore,lW),s=lJ(i),a=t$(t,(e,t)=>new r1(t,e.aggregateType,e._internalFieldPath));return(n=e._query,r=new U,s.asyncQueue.enqueueAndForget(async()=>{try{let e=await lD(s);r.resolve(async function(e,t,n){let{request:r,gt:i,parent:s}=iF(e.serializer,ri(t),n);e.connection.$o||delete r.parent;let a=(await e.Ho("RunAggregationQuery",e.serializer.databaseId,s,r,1)).filter(e=>!!e.result);L(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 l5(e,new uX(i),t))}class u2{constructor(e){this.kind="memory",this._onlineComponentProvider=ld.provider,this._offlineComponentProvider=e?.garbageCollector?e.garbageCollector._offlineComponentProvider:{build:()=>new lu(void 0)}}toJSON(){return{kind:this.kind}}}class u5{constructor(e){let t;this.kind="persistent",e?.tabManager?(e.tabManager._initialize(e),t=e.tabManager):(t=u7(void 0))._initialize(e),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class u3{constructor(){this.kind="memoryEager",this._offlineComponentProvider=ll.provider}toJSON(){return{kind:this.kind}}}class u4{constructor(e){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new lu(e)}}toJSON(){return{kind:this.kind}}}class u6{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=ld.provider,this._offlineComponentProvider={build:t=>new lh(t,e?.cacheSizeBytes,this.forceOwnership)}}}class u8{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=ld.provider,this._offlineComponentProvider={build:t=>new lc(t,e?.cacheSizeBytes)}}}function u7(e){return new u6(e?.forceOwnership)}let u9={maxAttempts:5};class he{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=us(e)}set(e,t,n){this._verifyNotCommitted();let r=ht(e,this._firestore),i=uz(r.converter,t,n),s=ua(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,rq.none())),this}update(e,t,n,...r){let i;this._verifyNotCommitted();let s=ht(e,this._firestore);return i="string"==typeof(t=(0,b.getModularInstance)(t))||t instanceof l4?um(this._dataReader,"WriteBatch.update",s._key,t,n,r):uf(this._dataReader,"WriteBatch.update",s._key,t),this._mutations.push(i.toMutation(s._key,rq.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=ht(e,this._firestore);return this._mutations=this._mutations.concat(new rJ(t._key,rq.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 ht(e,t){if((e=(0,b.getModularInstance)(e)).firestore!==t)throw new q(V.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class hn{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=us(e)}get(e){let t=ht(e,this._firestore),n=new uG(this._firestore);return this._transaction.lookup([t._key]).then(e=>{if(!e||1!==e.length)return O(24041);let r=e[0];
10if(r.isFoundDocument())return new uS(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new uS(this._firestore,n,t._key,null,t.converter);throw O(18433,{doc:r})})}set(e,t,n){let r=ht(e,this._firestore),i=uz(r.converter,t,n),s=ua(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=ht(e,this._firestore);return i="string"==typeof(t=(0,b.getModularInstance)(t))||t instanceof l4?um(this._dataReader,"Transaction.update",s._key,t,n,r):uf(this._dataReader,"Transaction.update",s._key,t),this._transaction.update(s._key,i),this}delete(e){let t=ht(e,this._firestore);return this._transaction.delete(t._key),this}}class hr extends hn{constructor(e,t){super(e,t),this._firestore=e}get(e){let t=ht(e,this._firestore),n=new uX(this._firestore);return super.get(e).then(e=>new uH(this._firestore,n,t._key,e._document,new uQ(!1,!1),t.converter))}}function hi(e,t){if("string"!=typeof e[t])throw new q(V.INVALID_ARGUMENT,"Missing string value for: "+t);return e[t]}class hs{constructor(e){this._firestore=e,this.type="PersistentCacheIndexManager"}}function ha(e,t){var n;(n=lJ(e._firestore),n.asyncQueue.enqueue(async()=>{var e;return e=await lx(n),void(e.Fs.Vs=t)})).then(e=>k(`setting persistent cache index auto creation isEnabled=${t} succeeded`)).catch(e=>R(`setting persistent cache index auto creation isEnabled=${t} failed`,e))}let ho=new WeakMap;class hl{constructor(){this.Mc=new Map}static get instance(){return hu||function(e){if(r4)throw Error("a TestingHooksSpi instance is already set");r4=e}(hu=new hl),hu}lt(e){this.Mc.forEach(t=>t(e))}onExistenceFilterMismatch(e){let t=Symbol(),n=this.Mc;return n.set(t,e),()=>n.delete(t)}}let hu=null;!function(e=!0){A=y.SDK_VERSION,(0,y._registerComponent)(new w.Component("firestore",(t,{instanceIdentifier:n,options:r})=>{let i=t.getProvider("app").getImmediate(),s=new lW(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 na(e.options.projectId,t)}(i,n),i);return r={useFetchStreams:e,...r},s._setSettings(r),s},"PUBLIC").setMultipleInstances(!0)),(0,y.registerVersion)(S,x,void 0),(0,y.registerVersion)(S,x,"esm2020")}(),e.s(["AbstractUserDataWriter",0,uj,"AggregateField",0,l2,"AggregateQuerySnapshot",0,l5,"Bytes",0,l3,"CACHE_SIZE_UNLIMITED",0,-1,"CollectionReference",0,lB,"DocumentReference",0,lU,"DocumentSnapshot",0,uH,"FieldPath",0,l4,"FieldValue",0,l6,"Firestore",0,lW,"FirestoreError",0,q,"GeoPoint",0,l8,"LoadBundleTask",0,lH,"PersistentCacheIndexManager",0,hs,"Query",0,lq,"QueryCompositeFilterConstraint",0,uM,"QueryConstraint",0,uN,"QueryDocumentSnapshot",0,uW,"QueryEndAtConstraint",0,uF,"QueryFieldFilterConstraint",0,uk,"QueryLimitConstraint",0,uP,"QueryOrderByConstraint",0,uR,"QuerySnapshot",0,uJ,"QueryStartAtConstraint",0,uO,"SnapshotMetadata",0,uQ,"Timestamp",0,ep,"Transaction",0,hr,"VectorValue",0,l7,"WriteBatch",0,he,"_AutoId",0,W,"_ByteString",0,t2,"_DatabaseId",0,na,"_DocumentKey",0,es,"_EmptyAppCheckTokenProvider",0,class{getToken(){return Promise.resolve(new Q(""))}invalidateToken(){}start(e,t){}shutdown(){}},"_EmptyAuthCredentialsProvider",0,j,"_FieldPath",0,ei,"_TestingHooks",0,class{constructor(){throw Error("instances of this class should not be created")}static onExistenceFilterMismatch(e){return hl.instance.onExistenceFilterMismatch(e)}},"_cast",0,ed,"_debugAssert",0,function(e,t){e||O(57014,t)},"_internalAggregationQueryToProtoRunAggregationQueryRequest",0,function(e,t){let n=t$(t,(e,t)=>new r1(t,e.aggregateType,e._internalFieldPath)),r=lJ(ed(e.firestore,lW)),i=r._onlineComponents?.datastore.serializer;return void 0===i?null:iF(i,ri(e._query),n,!0).request},"_internalQueryToProtoQueryTarget",0,function(e){let t=lJ(ed(e.firestore,lW)),n=t._onlineComponents?.datastore.serializer;return void 0===n?null:iO(n,rr(e._query)).ft},"_isBase64Available",0,function(){return"u">typeof atob},"_logWarn",0,R,"_validateIsNotUsedTogether",0,eo,"addDoc",0,function(e,t){let n=ed(e.firestore,lW),r=lj(e),i=uz(e.converter,t);return uZ(n,[ua(us(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,rq.exists(!1))]).then(()=>r)},"aggregateFieldEqual",0,function(e,t){return e instanceof l2&&t instanceof l2&&e.aggregateType===t.aggregateType&&e._internalFieldPath?.canonicalString()===t._internalFieldPath?.canonicalString()}
10,"aggregateQuerySnapshotEqual",0,function(e,t){return lz(e.query,t.query)&&(0,b.deepEqual)(e.data(),t.data())},"and",0,function(...e){return e.forEach(e=>uB("and",e)),uM._create("and",e)},"arrayRemove",0,function(...e){return new uc("arrayRemove",e)},"arrayUnion",0,function(...e){return new uh("arrayUnion",e)},"average",0,function(e){return new l2("avg",ub("average",e))},"clearIndexedDbPersistence",0,function(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+s4)}(s8(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise},"collection",0,function(e,t,...n){if(e=(0,b.getModularInstance)(e),ea("collection","path",t),e instanceof lL){let r=en.fromString(t,...n);return eu(r),new lB(e,null,r)}{if(!(e instanceof lU||e instanceof lB))throw new q(V.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let r=e._path.child(en.fromString(t,...n));return eu(r),new lB(e.firestore,null,r)}},"collectionGroup",0,function(e,t){if(e=ed(e,lL),ea("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 lq(e,null,new n7(en.emptyPath(),t))},"connectFirestoreEmulator",0,lV,"count",0,uK,"deleteAllPersistentCacheIndexes",0,function(e){var t;(t=lJ(e._firestore)).asyncQueue.enqueue(async()=>{var e;let n;return n=(e=await lx(t)).indexManager,e.persistence.runTransaction("Delete All Indexes","readwrite",e=>n.deleteAllFieldIndexes(e))}).then(e=>k("deleting all persistent cache indexes succeeded")).catch(e=>R("deleting all persistent cache indexes failed",e))},"deleteDoc",0,function(e){return uZ(ed(e.firestore,lW),[new rJ(e._key,rq.none())])},"deleteField",0,function(){return new uo("deleteField")},"disableNetwork",0,function(e){var t;return(t=lJ(e=ed(e,lW))).asyncQueue.enqueue(async()=>{let e=await lS(t),n=await lC(t);return e.setNetworkEnabled(!1),async function(e){e.Ea.add(0),await aZ(e),e.Ra.set("Offline")}(n)})},"disablePersistentCacheIndexAutoCreation",0,function(e){ha(e,!1)},"doc",0,lj,"documentId",0,function(){return new l4(ee)},"documentSnapshotFromJSON",0,function(e,t,n){if(eg(t,uH._jsonSchema)){var r;if(t.bundle===u$)throw new q(V.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");let i=aB(e._databaseId),s=(r=t.bundle,new lp(r,i)),a=s.Wu(),o=new oN(s.getMetadata(),i);for(let e of a)o.Ga(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=ik(i,l[0].document),h=new es(en.fromString(t.bundleName));return new uH(e,new uG(e),h,u,new uQ(!1,!1),n||null)}},"enableIndexedDbPersistence",0,function(e,t){R("enableIndexedDbPersistence() will be deprecated
10in the future, you can use `FirestoreSettings.cache` instead.");let n=e._freezeSettings();return lZ(e,ld.provider,{build:e=>new lh(e,n.cacheSizeBytes,t?.forceOwnership)}),Promise.resolve()},"enableMultiTabIndexedDbPersistence",0,lY,"enableNetwork",0,function(e){var t;return(t=lJ(e=ed(e,lW))).asyncQueue.enqueue(async()=>{let e=await lS(t),n=await lC(t);return e.setNetworkEnabled(!0),n.Ea.delete(0),aY(n)})},"enablePersistentCacheIndexAutoCreation",0,function(e){ha(e,!0)},"endAt",0,function(...e){return uF._create("endAt",e,!0)},"endBefore",0,function(...e){return uF._create("endBefore",e,!1)},"ensureFirestoreConfigured",0,lJ,"executeWrite",0,uZ,"getAggregateFromServer",0,u1,"getCountFromServer",0,function(e){return u1(e,{count:uK()})},"getDoc",0,function(e){e=ed(e,lU);let t=ed(e.firestore,lW);return lk(lJ(t),e._key).then(n=>u0(t,e,n))},"getDocFromCache",0,function(e){var t;let n;e=ed(e,lU);let r=ed(e.firestore,lW),i=lJ(r),s=new uX(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=og(r,`Failed to get document '${t} from cache`);n.reject(e)}})(await lx(i),t,n)),n.promise).then(t=>new uH(r,s,e._key,t,new uQ(null!==t&&t.hasLocalMutations,!0),e.converter))},"getDocFromServer",0,function(e){e=ed(e,lU);let t=ed(e.firestore,lW);return lk(lJ(t),e._key,{source:"server"}).then(n=>u0(t,e,n))},"getDocs",0,function(e){e=ed(e,lq);let t=ed(e.firestore,lW),n=lJ(t),r=new uX(t);return uA(e._query),lM(n,e._query).then(n=>new uJ(t,r,e,n))},"getDocsFromCache",0,function(e){var t;let n;e=ed(e,lq);let r=ed(e.firestore,lW),i=lJ(r),s=new uX(r);return(t=e._query,n=new U,i.asyncQueue.enqueueAndForget(async()=>(async function(e,t,n){try{let r=await al(e,t,!0),i=new oP(t,r.Qs),s=i.ru(r.documents),a=i.applyChanges(s,!1);n.resolve(a.snapshot)}catch(r){let e=og(r,`Failed to execute query '${t} against cache`);n.reject(e)}})(await lx(i),t,n)),n.promise).then(t=>new uJ(r,s,e,t))},"getDocsFromServer",0,function(e){e=ed(e,lq);let t=ed(e.firestore,lW),n=lJ(t),r=new uX(t);return lM(n,e._query,{source:"server"}).then(n=>new uJ(t,r,e,n))},"getFirestore",0,function(e,t){let n="object"==typeof e?e:(0,y.getApp)(),r="string"==typeof e?e:t||ns,i=(0,y._getProvider)(n,"firestore").getImmediate({identifier:r});if(!i._initialized){let e=(0,b.getDefaultEmulatorHostnameAndPort)("firestore");e&&lV(i,...e)}return i},"getPersistentCacheIndexManager",0,function(e){e=ed(e,lW);let t=ho.get(e);if(t)return t;let n=lJ(e);if("persistent"!==n._uninitializedComponentsProvider?._offline.kind)return null;let r=new hs(e);return ho.set(e,r),r},"increment",0,function(e){return new ud("increment",e)},"initializeFirestore",0,function(e,t,n){n||(n=ns);let r=(0,y._getProvider)(e,"firestore");if(r.isInitialized(n)){let e=r.getImmediate({identifier:n}),i=r.getOptions(n);if((0,b.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,b.isCloudWorkstation)(t.host)&&(0,b.pingServer)(t.host),r.initialize({options:t,instanceIdentifier:n})},"limit",0,function(e){return ef("limit",e),uP._create("limit",e,"F")},"limitToLast",0,function(e){return ef("limitToLast",e),uP._create("limitToLast",e,"L")},"loadBundle",0,l0,"memoryEagerGarbageCollector",0,function(){return new u3},"memoryLocalCache",0,function(e){return new u2(e)},"memoryLruGarbageCollector",0,function(e){return new u4(e?.cacheSizeBytes)},"namedQuery",0,l1,"onSnapshot",0,uY,"onSnapshotResume",0,function(e,t,...n){var r,i,s,a,o,l;let u=(0,b.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;
10if("object"!=typeof n[0]||lQ(n[d])||(c=n[d++]),"QuerySnapshot"===h.bundleSource){let e,t,a=null;if("object"==typeof n[d]&&lQ(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,l0(u,h.bundle).then(()=>l1(u,h.bundleName)).then(n=>{n&&!t&&(s&&n.withConverter(s),e=uY(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]&&lQ(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,l0(u,h.bundle).then(()=>{t||(e=uY(new lU(u,l||null,es.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}`)},"onSnapshotsInSync",0,function(e,t){var n;let r;return n=lJ(e=ed(e,lW)),r=new lm(lQ(t)?t:{next:t}),n.asyncQueue.enqueueAndForget(async()=>{var e;return e=await lN(n),void(e.Ca.add(r),r.next())}),()=>{r.Nu(),n.asyncQueue.enqueueAndForget(async()=>{var e;return e=await lN(n),void e.Ca.delete(r)})}},"or",0,function(...e){return e.forEach(e=>uB("or",e)),uM._create("or",e)},"orderBy",0,function(e,t="asc"){let n=uC("orderBy",e);return uR._create(n,t)},"persistentLocalCache",0,function(e){return new u5(e)},"persistentMultipleTabManager",0,function(){return new u8},"persistentSingleTabManager",0,u7,"query",0,function(e,t,...n){let r=[];for(let i of(t instanceof uD&&r.push(t),function(e){let t=e.filter(e=>e instanceof uM).length,n=e.filter(e=>e instanceof uk).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},"queryEqual",0,lz,"querySnapshotFromJSON",0,function(e,t,n){if(eg(t,uJ._jsonSchema)){var r;if(t.bundle===u$)throw new q(V.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");let i=aB(e._databaseId),s=(r=t.bundle,new lp(r,i)),a=s.Wu(),o=new oN(s.getMetadata(),i);for(let e of a)o.Ga(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=iJ(o.queries[0].bundledQuery),u=o.documents,h=new op;u.map(e=>{let t=ik(i,e.document);h=h.add(t)});let c=ow.fromInitialDocuments(l,h,rT(),!1,!1),d=new lq(e,n||null,l);return new uJ(e,new uG(e),d,c)}},"refEqual",0,function(e,t){return e=(0,b.getModularInstance)(e),t=(0,b.getModularInstance)(t),(e instanceof lU||e instanceof lB)&&(t instanceof lU||t instanceof lB)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter},"runTransaction",0,function(e,t,n){var r,i;let s;e=ed(e,lW);let a={...u9,...n};if(a.maxAttempts<1)throw new q(V.INVALID_ARGUMENT,"Max attempts must be at least 1");return r=lJ(e),i=n=>t(new hr(e,n)),s=new U,r.asyncQueue.enqueueAndForget(async()=>{let e=await lD(r);new lw(r.asyncQueue,e,a,i,s).ju()}),s.promise},"serverTimestamp",0,function(){return new uu("serverTimestamp")},"setDoc",0,function(e,t,n){e=ed(e,lU);let r=ed(e.firestore,lW),i=uz(e.converter,t,n);return uZ(r,[ua(us(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,rq.none())])},"setIndexConfiguration",0,function(e,t){let n=lJ(e=ed(e,lW));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=hi(e,"collectionGroup"),r=[];if(Array.isArray(e.fields))for(let t of e.fields){let e=uT("setIndexConfiguration",hi(t,"fieldPath"));"CONTAINS"===t.arrayConfig?r.push(new eT(e,2)):"ASCENDING"===t.order?r.push(new eT(e,0)):"DESCENDING"===t.order&&r.push(new eT(e,1))}n.push(new ew(ew.UNKNOWN_ID,t,r,e_.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,eI,t=>{r.push(n.addFieldIndex(e,t))},t=>{r.push(n.deleteFieldIndex(e,t))})).next(()=>ek.waitFor(r)))})(await lx(n),r))},"setLogLevel",0,function(e){D.setLogLevel(e)},"snapshotEqual",0,function(e,t){return e instanceof uH&&t instanceof uH?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 uJ&&t instanceof uJ&&e._firestore===t._firestore&&lz(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)},"startAfter",0,function(...e){return uO._create("startAfter",e,!1)},"startAt",0,function(...e){return uO._create("startAt",e,!0)},"sum",0,function(e){return new l2("sum",ub("sum",e))},"terminate",0,function(e){return(0,y._removeServiceInstance)(e.app,"firestore",e._databaseId.database),e._delete()},"updateDoc",0,function(e,t,n,...r){e=ed(e,lU);let i=ed(e.firestore,lW),s=us(i);return uZ(i,[("string"==typeof(t=(0,b.getModularInstance)(t))||t instanceof l4?um(s,"updateDoc",e._key,t,n,r):uf(s,"updateDoc",e._key,t)).toMutation(e._key,rq.exists(!0))])},"vector",0,function(e){return new l7(e)},"waitForPendingWrites",0,function(e){var t;let n;return t=lJ(e=ed(e,lW)),n=new U,t.asyncQueue.enqueueAndForget(async()=>oX(await lA(t),n)),n.promise},"where",0,function(e,t,n){let r=uC("where",e);return uk._create(r,t,n)},"writeBatch",0,function(e){return lJ(e=ed(e,lW)),new he(e,t=>uZ(e,t))}],98925)}]); 11
12//# debugId=3a08f979-b312-448e-a2e3-1f91c04c676e 13//# chunkId=01a0adf6-a150-7bc2-869d-0ac013db8350
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.