1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,436180,317875,t=>{"use strict";t.i(247167);var e,n,i,r,s,a,o,l=t.i(485086),u=t.i(965233),h=t.i(68483),c=t.i(733015),d="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:t.g,f={},g=g||{},p=d||self;function m(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function y(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}function v(t,e,n){return t.call.apply(t.bind,arguments)}function w(t,e,n){if(!t)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function E(t,e,n){return(E=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?v:w).apply(null,arguments)}function T(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function b(t,e){function n(){}n.prototype=e.prototype,t.$=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.ac=function(t,n,i){for(var r=Array(arguments.length-2),s=2;s<arguments.length;s++)r[s-2]=arguments[s];return e.prototype[n].apply(t,r)}}function I(){this.s=this.s,this.o=this.o}I.prototype.s=!1,I.prototype.sa=function(){this.s||(this.s=!0,this.N())},I.prototype.N=function(){if(this.o)for(;this.o.length;)this.o.shift()()};let C=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(let n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return -1};function S(t){let e=t.length;if(0<e){let n=Array(e);for(let i=0;i<e;i++)n[i]=t[i];return n}return[]}function A(t,e){for(let e=1;e<arguments.length;e++){let n=arguments[e];if(m(n)){let e=t.length||0,i=n.length||0;t.length=e+i;for(let r=0;r<i;r++)t[e+r]=n[r]}else t.push(n)}}function _(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}_.prototype.h=function(){this.defaultPrevented=!0};var N=function(){if(!p.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{p.addEventListener("test",()=>{},e),p.removeEventListener("test",()=>{},e)}catch(t){}return t}();function x(t){return/^[\s\xa0]*$/.test(t)}function D(){var t=p.navigator;return t&&(t=t.userAgent)?t:""}function k(t){return -1!=D().indexOf(t)}function R(t){return R[" "](t),t}R[" "]=function(){};var L=k("Opera"),M=k("Trident")||k("MSIE"),O=k("Edge"),F=O||M,P=k("Gecko")&&!(-1!=D().toLowerCase().indexOf("webkit")&&!k("Edge"))&&!(k("Tri
1dent")||k("MSIE"))&&!k("Edge"),V=-1!=D().toLowerCase().indexOf("webkit")&&!k("Edge");function U(){var t=p.document;return t?t.documentMode:void 0}t:{var q,B="",j=(q=D(),P?/rv:([^\);]+)(\)|;)/.exec(q):O?/Edge\/([\d\.]+)/.exec(q):M?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(q):V?/WebKit\/(\S+)/.exec(q):L?/(?:Version)[ \/]?(\S+)/.exec(q):void 0);if(j&&(B=j?j[1]:""),M){var $=U();if(null!=$&&$>parseFloat(B)){n=String($);break t}}n=B}var z=i=p.document&&M&&(U()||parseInt(n,10))||void 0;function K(t,e){if(_.call(this,t?t.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,t){var n=this.type=t.type,i=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(P){t:{try{R(e.nodeName);var r=!0;break t}catch(t){}r=!1}r||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,i?(this.clientX=void 0!==i.clientX?i.clientX:i.pageX,this.clientY=void 0!==i.clientY?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:G[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&K.$.h.call(this)}}b(K,_);var G={2:"touch",3:"pen",4:"mouse"};K.prototype.h=function(){K.$.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var Q="closure_listenable_"+(1e6*Math.random()|0),H=0;function W(t,e,n,i,r){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!i,this.la=r,this.key=++H,this.fa=this.ia=!1}function Y(t){t.fa=!0,t.listener=null,t.proxy=null,t.src=null,t.la=null}function X(t,e,n){for(let i in t)e.call(n,t[i],i,t)}function J(t){let e={};for(let n in t)e[n]=t[n];return e}let Z="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function tt(t,e){let n,i;for(let e=1;e<arguments.length;e++){for(n in i=arguments[e])t[n]=i[n];for(let e=0;e<Z.length;e++)n=Z[e],Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}}function te(t){this.src=t,this.g={},this.h=0}function tn(t,e){var n=e.type;if(n in t.g){var i,r=t.g[n],s=C(r,e);(i=0<=s)&&Array.prototype.splice.call(r,s,1),i&&(Y(e),0==t.g[n].length&&(delete t.g[n],t.h--))}}function ti(t,e,n,i){for(var r=0;r<t.length;++r){var s=t[r];if(!s.fa&&s.listener==e&&!!n==s.capture&&s.la==i)return r}return -1}te.prototype.add=function(t,e,n,i,r){var s=t.toString();(t=this.g[s])||(t=this.g[s]=[],this.h++);var a=ti(t,e,i,r);return -1<a?(e=t[a],n||(e.ia=!1)):((e=new W(e,this.src,s,!!i,r)).ia=n,t.push(e)),e};var tr="closure_lm_"+(1e6*Math.random()|0),ts={};function ta(t,e,n,i,r,s){if(!e)throw Error("Invalid event type");var a=y(r)?!!r.capture:!!r,o=th(t);if(o||(t[tr]=o=new te(t)),(n=o.add(e,n,i,a,s)).proxy)return n;if(i=function t(e){return tu.call(t.src,t.listener,e)},n.proxy=i,i.src=t,i.listener=n,t.addEventListener)N||(r=a),void 0===r&&(r=!1),t.addEventListener(e.toString(),i,r);else if(t.attachEvent)t.attachEvent(tl(e.toString()),i);else if(t.addListener&&t.removeListener)t.addListener(i);else throw Error("addEventListener and attachEvent are unavailable.");return n}function to(t){if("number"!=typeof t&&t&&!t.fa){var e=t.src;if(e&&e[Q])tn(e.i,t);else{var n=t.type,i=t.proxy;e.removeEventListener?e.removeEventListener(n,i,t.capture):e.detachEvent?e.detachEvent(tl(n),i):e.addListener&&e.removeListener&&e.removeListener(i),(n=th(e))?(tn(n,t),0==n.h&&(n.src=null,e[tr]=null)):Y(t)}}}function tl(t){return t in ts?ts[t]:ts[t]="on"+t}function tu(t,e){if(t.fa)t=!0;else{e=new K(e,this);var n=t.listener,i=t.la||t.src;t.ia&&to(t),t=n.call(i,e)}return t}function th(t){return(t=t[tr])instanceof te?t:null}var tc="__closure_events_fn_"+(1e9*Math.random()>>>0);function td(t){return"function"==typeof t?t:(t[tc]||(t[tc]=function(e){return t.handleEvent(e)}),t[tc])}function tf(){I.call(this),this.i=new te(this),this.S=this,this.J=null}function tg(t,e){var n,i=t.J;if(i)for(n=[];i;i=i.J)n.push(i);if(t=t.S,i=e.type||e,"string"==typeof e)e=new _(e,t);else if(e instanceof _)e.target=e.target||t;else{var r=e;tt(e=new _(i,t),r)}if(r=!0,n)for(var s=n.length-1;0<=s;s--){var a=e.g=n[s];r=tp(a,i,!0,e)&&r}if(r=tp(a=e.g=t,i,!0,e)&&r,r=tp(a,i,!1,e)&&r,n)for(s=0;s<n.length;s++)r=tp(a=e.g=n[s],i,!1,e)&&r}function tp(t,e,n,i){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var r=!0,s=0;s<e.length;++s){var a=e[s];if(a&&!a.fa&&a.capture==n){var o=a.listener,l=a.la||a.src;a.ia&&tn(t.i,a),r=!1!==o.call(l,i)&&r}}return r&&!i.defaultPrevented}
1b(tf,I),tf.prototype[Q]=!0,tf.prototype.removeEventListener=function(t,e,n,i){!function t(e,n,i,r,s){if(Array.isArray(n))for(var a=0;a<n.length;a++)t(e,n[a],i,r,s);else(r=y(r)?!!r.capture:!!r,i=td(i),e&&e[Q])?(e=e.i,(n=String(n).toString())in e.g&&-1<(i=ti(a=e.g[n],i,r,s))&&(Y(a[i]),Array.prototype.splice.call(a,i,1),0==a.length&&(delete e.g[n],e.h--))):e&&(e=th(e))&&(n=e.g[n.toString()],e=-1,n&&(e=ti(n,i,r,s)),(i=-1<e?n[e]:null)&&to(i))}(this,t,e,n,i)},tf.prototype.N=function(){if(tf.$.N.call(this),this.i){var t,e=this.i;for(t in e.g){for(var n=e.g[t],i=0;i<n.length;i++)Y(n[i]);delete e.g[t],e.h--}}this.J=null},tf.prototype.O=function(t,e,n,i){return this.i.add(String(t),e,!1,n,i)},tf.prototype.P=function(t,e,n,i){return this.i.add(String(t),e,!0,n,i)};var tm=p.JSON.stringify,ty=new class{constructor(t,e){this.i=t,this.j=e,this.h=0,this.g=null}get(){let t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t}}(()=>new tv,t=>t.reset());class tv{constructor(){this.next=this.g=this.h=null}set(t,e){this.h=t,this.g=e,this.next=null}reset(){this.next=this.g=this.h=null}}let tw,tE=!1,tT=new class{constructor(){this.h=this.g=null}add(t,e){let n=ty.get();n.set(t,e),this.h?this.h.next=n:this.g=n,this.h=n}},tb=()=>{let t=p.Promise.resolve(void 0);tw=()=>{t.then(tI)}};var tI=()=>{let t;for(var e;t=null,tT.g&&(t=tT.g,tT.g=tT.g.next,tT.g||(tT.h=null),t.next=null),e=t;){try{e.h.call(e.g)}catch(t){!function(t){p.setTimeout(()=>{throw t},0)}(t)}ty.j(e),100>ty.h&&(ty.h++,e.next=ty.g,ty.g=e)}tE=!1};function tC(t,e){tf.call(this),this.h=t||1,this.g=e||p,this.j=E(this.qb,this),this.l=Date.now()}function tS(t){t.ga=!1,t.T&&(t.g.clearTimeout(t.T),t.T=null)}function tA(t,e,n){if("function"==typeof t)n&&(t=E(t,n));else if(t&&"function"==typeof t.handleEvent)t=E(t.handleEvent,t);else throw Error("Invalid listener argument");return 0x7fffffff<Number(e)?-1:p.setTimeout(t,e||0)}b(tC,tf),(o=tC.prototype).ga=!1,o.T=null,o.qb=function(){if(this.ga){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.T=this.g.setTimeout(this.j,this.h-t):(this.T&&(this.g.clearTimeout(this.T),this.T=null),tg(this,"tick"),this.ga&&(tS(this),this.start()))}},o.start=function(){this.ga=!0,this.T||(this.T=this.g.setTimeout(this.j,this.h),this.l=Date.now())},o.N=function(){tC.$.N.call(this),tS(this),delete this.g};class t_ extends I{constructor(t,e){super(),this.m=t,this.j=e,this.h=null,this.i=!1,this.g=null}l(t){this.h=arguments,this.g?this.i=!0:function t(e){e.g=tA(()=>{e.g=null,e.i&&(e.i=!1,t(e))},e.j);let n=e.h;e.h=null,e.m.apply(null,n)}(this)}N(){super.N(),this.g&&(p.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function tN(t){I.call(this),this.h=t,this.g={}}b(tN,I);var tx=[];function tD(t,e,n,i){Array.isArray(n)||(n&&(tx[0]=n.toString()),n=tx);for(var r=0;r<n.length;r++){var s=function t(e,n,i,r,s){if(r&&r.once)return function t(e,n,i,r,s){if(Array.isArray(n)){for(var a=0;a<n.length;a++)t(e,n[a],i,r,s);return null}return i=td(i),e&&e[Q]?e.P(n,i,y(r)?!!r.capture:!!r,s):ta(e,n,i,!0,r,s)}(e,n,i,r,s);if(Array.isArray(n)){for(var a=0;a<n.length;a++)t(e,n[a],i,r,s);return null}return i=td(i),e&&e[Q]?e.O(n,i,y(r)?!!r.capture:!!r,s):ta(e,n,i,!1,r,s)}(e,n[r],i||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}}function tk(t){X(t.g,function(t,e){this.g.hasOwnProperty(e)&&to(t)},t),t.g={}}function tR(){this.g=!0}function tL(t,e,n,i){t.info(function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.g)return e;if(!e)return null;try{var n=JSON.parse(e);if(n){for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var i=n[t];if(!(2>i.length)){var r=i[1];if(Array.isArray(r)&&!(1>r.length)){var s=r[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var a=1;a<r.length;a++)r[a]=""}}}}return tm(n)}catch(t){return e}}(t,n)+(i?" "+i:"")})}tN.prototype.N=function(){tN.$.N.call(this),tk(this)},tN.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},tR.prototype.Ea=function(){this.g=!1},tR.prototype.info=function(){};var tM={},tO=null;function tF(){return tO=tO||new tf}function tP(t){_.call(this,tM.Ta,t)}function tV(t){let e=tF();tg(e,new tP(e))}function tU(t,e){_.call(this,tM.STAT_EVENT,t),this.stat=e}function tq(t){let e=tF();tg(e,new tU(e,t))}function tB(t,e){_.call(this,tM.Ua,t),this.size=e}function tj(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return p.setTimeout(function(){t()},e)}tM.Ta="serverreachability",b(tP,_),tM.STAT_EVENT="statevent",b(tU,_),tM.Ua="timingevent",b(tB,_);var t$={NO_ERROR:0,rb:1,Eb:2,Db:3,yb:4,Cb:5,Fb:6,Qa:7,TIMEOUT:8,Ib:9}
1,tz={wb:"complete",Sb:"success",Ra:"error",Qa:"abort",Kb:"ready",Lb:"readystatechange",TIMEOUT:"timeout",Gb:"incrementaldata",Jb:"progress",zb:"downloadprogress",$b:"uploadprogress"};function tK(){}function tG(t){return t.h||(t.h=t.i())}function tQ(){}tK.prototype.h=null;var tH={OPEN:"a",vb:"b",Ra:"c",Hb:"d"};function tW(){_.call(this,"d")}function tY(){_.call(this,"c")}function tX(){}function tJ(t,e,n,i){this.l=t,this.j=e,this.m=n,this.W=i||1,this.U=new tN(this),this.P=t0,t=F?125:void 0,this.V=new tC(t),this.I=null,this.i=!1,this.s=this.A=this.v=this.L=this.G=this.Y=this.B=null,this.F=[],this.g=null,this.C=0,this.o=this.u=null,this.ca=-1,this.J=!1,this.O=0,this.M=null,this.ba=this.K=this.aa=this.S=!1,this.h=new tZ}function tZ(){this.i=null,this.g="",this.h=!1}b(tW,_),b(tY,_),b(tX,tK),tX.prototype.g=function(){return new XMLHttpRequest},tX.prototype.i=function(){return{}},r=new tX;var t0=45e3,t1={},t2={};function t3(t,e,n){t.L=1,t.v=ec(ea(e)),t.s=n,t.S=!0,t4(t,null)}function t4(t,e){t.G=Date.now(),t8(t),t.A=ea(t.v);var n,i,r,s,a,o,l=t.A,u=t.W;Array.isArray(u)||(u=[String(u)]),eC(l.i,"t",u),t.C=0,l=t.l.J,t.h=new tZ,t.g=nf(t.l,l?e:null,!t.s),0<t.O&&(t.M=new t_(E(t.Pa,t,t.g),t.O)),tD(t.U,t.g,"readystatechange",t.nb),e=t.I?J(t.I):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.ha(t.A,t.u,t.s,e)):(t.u="GET",t.g.ha(t.A,t.u,null,e)),tV(),n=t.j,i=t.u,r=t.A,s=t.m,a=t.W,o=t.s,n.info(function(){if(n.g)if(o)for(var t="",e=o.split("&"),l=0;l<e.length;l++){var u=e[l].split("=");if(1<u.length){var h=u[0];u=u[1];var c=h.split("_");t=2<=c.length&&"type"==c[1]?t+(h+"=")+u+"&":t+(h+"=redacted&")}}else t=null;else t=o;return"XMLHTTP REQ ("+s+") [attempt "+a+"]: "+i+"\n"+r+"\n"+t})}function t5(t){return!!t.g&&"GET"==t.u&&2!=t.L&&t.l.Ha}function t6(t,e,n){let i=!0,r;for(;!t.J&&t.C<n.length;)if((r=function(t,e){var n=t.C,i=e.indexOf("\n",n);return -1==i?t2:isNaN(n=Number(e.substring(n,i)))?t1:(i+=1)+n>e.length?t2:(e=e.slice(i,i+n),t.C=i+n,e)}(t,n))==t2){4==e&&(t.o=4,tq(14),i=!1),tL(t.j,t.m,null,"[Incomplete Response]");break}else if(r==t1){t.o=4,tq(15),tL(t.j,t.m,n,"[Invalid Chunk]"),i=!1;break}else tL(t.j,t.m,r,null),en(t,r);t5(t)&&r!=t2&&r!=t1&&(t.h.g="",t.C=0),4!=e||0!=n.length||t.h.h||(t.o=1,tq(16),i=!1),t.i=t.i&&i,i?0<n.length&&!t.ba&&(t.ba=!0,(e=t.l).g==t&&e.ca&&!e.M&&(e.l.info("Great, no buffering proxy detected. Bytes received: "+n.length),ns(e),e.M=!0,tq(11))):(tL(t.j,t.m,n,"[Invalid Chunked Response]"),ee(t),et(t))}function t8(t){t.Y=Date.now()+t.P,t7(t,t.P)}function t7(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=tj(E(t.lb,t),e)}function t9(t){t.B&&(p.clearTimeout(t.B),t.B=null)}function et(t){0==t.l.H||t.J||nl(t.l,t)}function ee(t){t9(t);var e=t.M;e&&"function"==typeof e.sa&&e.sa(),t.M=null,tS(t.V),tk(t.U),t.g&&(e=t.g,t.g=null,e.abort(),e.sa())}function en(t,e){try{var n=t.l;if(0!=n.H&&(n.g==t||ek(n.i,t))){if(!t.K&&ek(n.i,t)&&3==n.H){try{var i=n.Ja.g.parse(e)}catch(t){i=null}if(Array.isArray(i)&&3==i.length){var r=i;if(0==r[0]){t:if(!n.u){if(n.g)if(n.g.G+3e3<t.G)no(n),e8(n);else break t;nr(n),tq(18)}}else n.Fa=r[1],0<n.Fa-n.V&&37500>r[2]&&n.G&&0==n.A&&!n.v&&(n.v=tj(E(n.ib,n),6e3));if(1>=eD(n.i)&&n.oa){try{n.oa()}catch(t){}n.oa=void 0}}else nh(n,11)}else if((t.K||n.g==t)&&no(n),!x(e))for(r=n.Ja.g.parse(e),e=0;e<r.length;e++){let o=r[e];if(n.V=o[0],o=o[1],2==n.H)if("c"==o[0]){n.K=o[1],n.pa=o[2];let e=o[3];null!=e&&(n.ra=e,n.l.info("VER="+n.ra));let r=o[4];null!=r&&(n.Ga=r,n.l.info("SVER="+n.Ga));let l=o[5];null!=l&&"number"==typeof l&&0<l&&(n.L=i=1.5*l,n.l.info("backChannelRequestTimeoutMs_="+i)),i=n;let u=t.g;if(u){let t=u.g?u.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(t){var s=i.i;s.g||-1==t.indexOf("spdy")&&-1==t.indexOf("quic")&&-1==t.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(eR(s,s.h),s.h=null))}if(i.F){let t=u.g?u.g.getResponseHeader("X-HTTP-Session-Id"):null;t&&(i.Da=t,eh(i.I,i.F,t))}}if(n.H=3,n.h&&n.h.Ba(),n.ca&&(n.S=Date.now()-t.G,n.l.info("Handshake RTT: "+n.S+"ms")),(i=n).wa=nd(i,i.J?i.pa:null,i.Y),t.K){eL(i.i,t);var a=i.L;a&&t.setTimeout(a),t.B&&(t9(t),t8(t)),i.g=t}else ni(i);0<n.j.length&&e9(n)}else"stop"!=o[0]&&"close"!=o[0]||nh(n,7);else 3==n.H&&("stop"==o[0]||"close"==o[0]?"stop"==o[0]?nh(n,7):e6(n):"noop"!=o[0]&&n.h&&n.h.Aa(o),n.A=0)}}tV(4)}catch(t){}}function ei(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(m(t)||"string"==typeof t)Array.prototype.forEach.call(t,e,void 0);else for(var n=function(t){if(t.ta&&"function"==typeof t.ta)return t.ta();if(!t.Z||"function"!=typeof t.Z){if("undefined"!=typeof Map&&t instanceof Map)return Array.from(t.keys());if(!("undefined"!=typeof Set&&t instanceof Set)){if(m(t)||"string"==typeof t){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(let i in e=[],n=0,t)e[n++]=i;return e}}}(t),i=function(t){if(t.Z&&"function"==typeof t.Z)return t.Z();if("undefined"!=typeof Map&&t instanceof Map||"undefined"!=typeof Set&&t instanceof Set)return Array.from(t.values());if("string"==typeof t)return t.split("");
1if(m(t)){for(var e=[],n=t.length,i=0;i<n;i++)e.push(t[i]);return e}for(i in e=[],n=0,t)e[n++]=t[i];return e}(t),r=i.length,s=0;s<r;s++)e.call(void 0,i[s],n&&n[s],t)}(o=tJ.prototype).setTimeout=function(t){this.P=t},o.nb=function(t){t=t.target;let e=this.M;e&&3==e0(t)?e.l():this.Pa(t)},o.Pa=function(t){try{if(t==this.g)t:{let y=e0(this.g);var e=this.g.Ia();let v=this.g.da();if(!(3>y)&&(3!=y||F||this.g&&(this.h.h||this.g.ja()||e1(this.g)))){this.J||4!=y||7==e||(8==e||0>=v?tV(3):tV(2)),t9(this);var n=this.g.da();this.ca=n;e:if(t5(this)){var i=e1(this.g);t="";var r=i.length,s=4==e0(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){ee(this),et(this);var a="";break e}this.h.i=new p.TextDecoder}for(e=0;e<r;e++)this.h.h=!0,t+=this.h.i.decode(i[e],{stream:s&&e==r-1});i.splice(0,r),this.h.g+=t,this.C=0,a=this.h.g}else a=this.g.ja();if(this.i=200==n,o=this.j,l=this.u,u=this.A,h=this.m,c=this.W,d=n,o.info(function(){return"XMLHTTP RESP ("+h+") [ attempt "+c+"]: "+l+"\n"+u+"\n"+y+" "+d}),this.i){if(this.aa&&!this.K){e:{if(this.g){var o,l,u,h,c,d,f,g=this.g;if((f=g.g?g.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!x(f)){var m=f;break e}}m=null}if(n=m)tL(this.j,this.m,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,en(this,n);else{this.i=!1,this.o=3,tq(12),ee(this),et(this);break t}}this.S?(t6(this,y,a),F&&this.i&&3==y&&(tD(this.U,this.V,"tick",this.mb),this.V.start())):(tL(this.j,this.m,a,null),en(this,a)),4==y&&ee(this),this.i&&!this.J&&(4==y?nl(this.l,this):(this.i=!1,t8(this)))}else(function(t){let e={};t=(t.g&&2<=e0(t)&&t.g.getAllResponseHeaders()||"").split("\r\n");for(let i=0;i<t.length;i++){if(x(t[i]))continue;var n=function(t){var e=1;t=t.split(":");let n=[];for(;0<e&&t.length;)n.push(t.shift()),e--;return t.length&&n.push(t.join(":")),n}(t[i]);let r=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();let s=e[r]||[];e[r]=s,s.push(n)}var i=function(t){return t.join(", ")};for(let t in e)i.call(void 0,e[t],t,e)})(this.g),400==n&&0<a.indexOf("Unknown SID")?(this.o=3,tq(12)):(this.o=0,tq(13)),ee(this),et(this)}}}catch(t){}finally{}},o.mb=function(){if(this.g){var t=e0(this.g),e=this.g.ja();this.C<e.length&&(t9(this),t6(this,t,e),this.i&&4!=t&&t8(this))}},o.cancel=function(){this.J=!0,ee(this)},o.lb=function(){var t,e;this.B=null;let n=Date.now();0<=n-this.Y?(t=this.j,e=this.A,t.info(function(){return"TIMEOUT: "+e}),2!=this.L&&(tV(),tq(17)),ee(this),this.o=2,et(this)):t7(this,this.Y-n)};var er=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function es(t){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,t instanceof es){this.h=t.h,eo(this,t.j),this.s=t.s,this.g=t.g,el(this,t.m),this.l=t.l;var e=t.i,n=new eE;n.i=e.i,e.g&&(n.g=new Map(e.g),n.h=e.h),eu(this,n),this.o=t.o}else t&&(e=String(t).match(er))?(this.h=!1,eo(this,e[1]||"",!0),this.s=ed(e[2]||""),this.g=ed(e[3]||"",!0),el(this,e[4]),this.l=ed(e[5]||"",!0),eu(this,e[6]||"",!0),this.o=ed(e[7]||"")):(this.h=!1,this.i=new eE(null,this.h))}function ea(t){return new es(t)}function eo(t,e,n){t.j=n?ed(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function el(t,e){if(e){if(isNaN(e=Number(e))||0>e)throw Error("Bad port number "+e);t.m=e}else t.m=null}function eu(t,e,n){var i,r;e instanceof eE?(t.i=e,i=t.i,(r=t.h)&&!i.j&&(eT(i),i.i=null,i.g.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(eb(this,e),eC(this,n,t))},i)),i.j=r):(n||(e=ef(e,ev)),t.i=new eE(e,t.h))}function eh(t,e,n){t.i.set(e,n)}function ec(t){return eh(t,"zx",Math.floor(0x80000000*Math.random()).toString(36)+Math.abs(Math.floor(0x80000000*Math.random())^Date.now()).toString(36)),t}function ed(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function ef(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,eg),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function eg(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}es.prototype.toString=function(){var t=[],e=this.j;e&&t.push(ef(e,ep,!0),":");var n=this.g;
1return(n||"file"==e)&&(t.push("//"),(e=this.s)&&t.push(ef(e,ep,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&t.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&t.push("/"),t.push(ef(n,"/"==n.charAt(0)?ey:em,!0))),(n=this.i.toString())&&t.push("?",n),(n=this.o)&&t.push("#",ef(n,ew)),t.join("")};var ep=/[#\/\?@]/g,em=/[#\?:]/g,ey=/[#\?]/g,ev=/[#\?@]/g,ew=/#/g;function eE(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function eT(t){t.g||(t.g=new Map,t.h=0,t.i&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var i=t[n].indexOf("="),r=null;if(0<=i){var s=t[n].substring(0,i);r=t[n].substring(i+1)}else s=t[n];e(s,r?decodeURIComponent(r.replace(/\+/g," ")):"")}}}(t.i,function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)}))}function eb(t,e){eT(t),e=eS(t,e),t.g.has(e)&&(t.i=null,t.h-=t.g.get(e).length,t.g.delete(e))}function eI(t,e){return eT(t),e=eS(t,e),t.g.has(e)}function eC(t,e,n){eb(t,e),0<n.length&&(t.i=null,t.g.set(eS(t,e),S(n)),t.h+=n.length)}function eS(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}(o=eE.prototype).add=function(t,e){eT(this),this.i=null,t=eS(this,t);var n=this.g.get(t);return n||this.g.set(t,n=[]),n.push(e),this.h+=1,this},o.forEach=function(t,e){eT(this),this.g.forEach(function(n,i){n.forEach(function(n){t.call(e,n,i,this)},this)},this)},o.ta=function(){eT(this);let t=Array.from(this.g.values()),e=Array.from(this.g.keys()),n=[];for(let i=0;i<e.length;i++){let r=t[i];for(let t=0;t<r.length;t++)n.push(e[i])}return n},o.Z=function(t){eT(this);let e=[];
1if("string"==typeof t)eI(this,t)&&(e=e.concat(this.g.get(eS(this,t))));else{t=Array.from(this.g.values());for(let n=0;n<t.length;n++)e=e.concat(t[n])}return e},o.set=function(t,e){return eT(this),this.i=null,eI(this,t=eS(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},o.get=function(t,e){return t&&0<(t=this.Z(t)).length?String(t[0]):e},o.toString=function(){if(this.i)return this.i;if(!this.g)return"";let t=[],e=Array.from(this.g.keys());for(var n=0;n<e.length;n++){var i=e[n];let s=encodeURIComponent(String(i)),a=this.Z(i);for(i=0;i<a.length;i++){var r=s;""!==a[i]&&(r+="="+encodeURIComponent(String(a[i]))),t.push(r)}}return this.i=t.join("&")};var eA=class{constructor(t,e){this.g=t,this.map=e}};function e_(t){this.l=t||eN,t=p.PerformanceNavigationTiming?0<(t=p.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(p.g&&p.g.Ka&&p.g.Ka()&&p.g.Ka().ec),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var eN=10;function ex(t){return!!t.h||!!t.g&&t.g.size>=t.j}function eD(t){return t.h?1:t.g?t.g.size:0}function ek(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function eR(t,e){t.g?t.g.add(e):t.h=e}function eL(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function eM(t){if(null!=t.h)return t.i.concat(t.h.F);if(null!=t.g&&0!==t.g.size){let e=t.i;for(let n of t.g.values())e=e.concat(n.F);return e}return S(t.i)}e_.prototype.cancel=function(){if(this.i=eM(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(let t of this.g.values())t.cancel();this.g.clear()}};var eO=class{stringify(t){return p.JSON.stringify(t,void 0)}parse(t){return p.JSON.parse(t,void 0)}};function eF(){this.g=new eO}function eP(t,e,n,i,r){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,r(i)}catch(t){}}function eV(t){this.l=t.fc||null,this.j=t.ob||!1}function eU(t,e){tf.call(this),this.F=t,this.u=e,this.m=void 0,this.readyState=eq,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}b(eV,tK),eV.prototype.g=function(){return new eU(this.l,this.j)},eV.prototype.i=(e={},function(){return e}),b(eU,tf);var eq=0;function eB(t){t.j.read().then(t.Xa.bind(t)).catch(t.ka.bind(t))}function ej(t){t.readyState=4,t.l=null,t.j=null,t.A=null,e$(t)}function e$(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(o=eU.prototype).open=function(t,e){if(this.readyState!=eq)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=e,this.readyState=1,e$(this)},o.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;let e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(e.body=t),(this.F||p).fetch(new Request(this.B,e)).then(this.$a.bind(this),this.ka.bind(this))},o.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,ej(this)),this.readyState=eq},o.$a=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,e$(this)),this.g&&(this.readyState=3,e$(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ya.bind(this),this.ka.bind(this));else if(void 0!==p.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;eB(this)}else t.text().then(this.Za.bind(this),this.ka.bind(this))},o.Xa=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var e=t.value?t.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?ej(this):e$(this),3==this.readyState&&eB(this)}},o.Za=function(t){this.g&&(this.response=this.responseText=t,ej(this))},o.Ya=function(t){this.g&&(this.response=t,ej(this))},o.ka=function(){this.g&&ej(this)},o.setRequestHeader=function(t,e){this.v.append(t,e)},o.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},o.getAllResponseHeaders=function(){if(!this.h)return"";let t=[],e=this.h.entries();for(var n=e.next();!n.done;)t.push((n=n.value)[0]+": "+n[1]),n=e.next();return t.join("\r\n")},Object.defineProperty(eU.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var ez=p.JSON.parse;function eK(t){tf.call(this),this.headers=new Map,this.u=t||null,this.h=!1,this.C=this.g=null,this.I="",this.m=0,this.j="",this.l=this.G=this.v=this.F=!1,this.B=0,this.A=null,this.K=eG,this.L=this.M=!1}b(eK,tf);var eG="",eQ=/^https?$/i,eH=["POST","PUT"];function eW(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,eY(t),eJ(t)}function eY(t){t.F||(t.F=!0,tg(t,"complete"),tg(t,"error"))}function eX(t){if(t.h&&void 0!==g&&(!t.C[1]||4!=e0(t)||2!=t.da())){if(t.v&&4==e0(t))tA(t.La,0,t);else if(tg(t,"readystatechange"),4==e0(t)){t.h=!1;try{let a=t.da();switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e,n,i=!0;break;default:i=!1}
1if(!(e=i)){if(n=0===a){var r=String(t.I).match(er)[1]||null;!r&&p.self&&p.self.location&&(r=p.self.location.protocol.slice(0,-1)),n=!eQ.test(r?r.toLowerCase():"")}e=n}if(e)tg(t,"complete"),tg(t,"success");else{t.m=6;try{var s=2<e0(t)?t.g.statusText:""}catch(t){s=""}t.j=s+" ["+t.da()+"]",eY(t)}}finally{eJ(t)}}}}function eJ(t,e){if(t.g){eZ(t);let n=t.g,i=t.C[0]?()=>{}:null;t.g=null,t.C=null,e||tg(t,"ready");try{n.onreadystatechange=i}catch(t){}}}function eZ(t){t.g&&t.L&&(t.g.ontimeout=null),t.A&&(p.clearTimeout(t.A),t.A=null)}function e0(t){return t.g?t.g.readyState:0}function e1(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.K){case eG:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(t){return null}}function e2(t){let e="";return X(t,function(t,n){e+=n,e+=":",e+=t,e+="\r\n"}),e}function e3(t,e,n){t:{for(i in n){var i=!1;break t}i=!0}i||(n=e2(n),"string"==typeof t?null!=n&&encodeURIComponent(String(n)):eh(t,e,n))}function e4(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function e5(t){this.Ga=0,this.j=[],this.l=new tR,this.pa=this.wa=this.I=this.Y=this.g=this.Da=this.F=this.na=this.o=this.U=this.s=null,this.fb=this.W=0,this.cb=e4("failFast",!1,t),this.G=this.v=this.u=this.m=this.h=null,this.aa=!0,this.Fa=this.V=-1,this.ba=this.A=this.C=0,this.ab=e4("baseRetryDelayMs",5e3,t),this.hb=e4("retryDelaySeedMs",1e4,t),this.eb=e4("forwardChannelMaxRetries",2,t),this.xa=e4("forwardChannelRequestTimeoutMs",2e4,t),this.va=t&&t.xmlHttpFactory||void 0,this.Ha=t&&t.dc||!1,this.L=void 0,this.J=t&&t.supportsCrossDomainXhr||!1,this.K="",this.i=new e_(t&&t.concurrentRequestLimit),this.Ja=new eF,this.P=t&&t.fastHandshake||!1,this.O=t&&t.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.bb=t&&t.bc||!1,t&&t.Ea&&this.l.Ea(),t&&t.forceLongPolling&&(this.aa=!1),this.ca=!this.P&&this.aa&&t&&t.detectBufferingProxy||!1,this.qa=void 0,t&&t.longPollingTimeout&&0<t.longPollingTimeout&&(this.qa=t.longPollingTimeout),this.oa=void 0,this.S=0,this.M=!1,this.ma=this.B=null}function e6(t){if(e7(t),3==t.H){var e=t.W++,n=ea(t.I);if(eh(n,"SID",t.K),eh(n,"RID",e),eh(n,"TYPE","terminate"),ne(t,n),(e=new tJ(t,t.l,e)).L=2,e.v=ec(ea(n)),n=!1,p.navigator&&p.navigator.sendBeacon)try{n=p.navigator.sendBeacon(e.v.toString(),"")}catch(t){}!n&&p.Image&&((new Image).src=e.v,n=!0),n||(e.g=nf(e.l,null),e.g.ha(e.v)),e.G=Date.now(),t8(e)}nc(t)}function e8(t){t.g&&(ns(t),t.g.cancel(),t.g=null)}function e7(t){e8(t),t.u&&(p.clearTimeout(t.u),t.u=null),no(t),t.i.cancel(),t.m&&("number"==typeof t.m&&p.clearTimeout(t.m),t.m=null)}function e9(t){if(!ex(t.i)&&!t.m){t.m=!0;var e=t.Na;tw||tb(),tE||(tw(),tE=!0),tT.add(e,t),t.C=0}}function nt(t,e){var n;n=e?e.m:t.W++;let i=ea(t.I);eh(i,"SID",t.K),eh(i,"RID",n),eh(i,"AID",t.V),ne(t,i),t.o&&t.s&&e3(i,t.o,t.s),n=new tJ(t,t.l,n,t.C+1),null===t.o&&(n.I=t.s),e&&(t.j=e.F.concat(t.j)),e=nn(t,n,1e3),n.setTimeout(Math.round(.5*t.xa)+Math.round(.5*t.xa*Math.random())),eR(t.i,n),t3(n,i,e)}function ne(t,e){t.na&&X(t.na,function(t,n){eh(e,n,t)}),t.h&&ei({},function(t,n){eh(e,n,t)})}function nn(t,e,n){n=Math.min(t.j.length,n);var i=t.h?E(t.h.Va,t.h,t):null;t:{var r=t.j;let e=-1;for(;;){let t=["count="+n];-1==e?0<n?(e=r[0].g,t.push("ofs="+e)):e=0:t.push("ofs="+e);let s=!0;for(let a=0;a<n;a++){let n=r[a].g,o=r[a].map;if(0>(n-=e))e=Math.max(0,r[a].g-100),s=!1;else try{!function(t,e,n){let i=n||"";try{ei(t,function(t,n){let r=t;y(t)&&(r=tm(t)),e.push(i+n+"="+encodeURIComponent(r))})}catch(t){throw e.push(i+"type="+encodeURIComponent("_badmap")),t}}(o,t,"req"+n+"_")}catch(t){i&&i(o)}}if(s){i=t.join("&");break t}}}return e.F=t=t.j.splice(0,n),i}function ni(t){if(!t.g&&!t.u){t.ba=1;var e=t.Ma;tw||tb(),tE||(tw(),tE=!0),tT.add(e,t),t.A=0}}function nr(t){return!t.g&&!t.u&&!(3<=t.A)&&(t.ba++,t.u=tj(E(t.Ma,t),nu(t,t.A)),t.A++,!0)}function ns(t){null!=t.B&&(p.clearTimeout(t.B),t.B=null)}function na(t){t.g=new tJ(t,t.l,"rpc",t.ba),null===t.o&&(t.g.I=t.s),t.g.O=0;var e=ea(t.wa);eh(e,"RID","rpc"),eh(e,"SID",t.K),eh(e,"AID",t.V),eh(e,"CI",t.G?"0":"1"),!t.G&&t.qa&&eh(e,"TO",t.qa),eh(e,"TYPE","xmlhttp"),ne(t,e),t.o&&t.s&&e3(e,t.o,t.s),t.L&&t.g.setTimeout(t.L);var n=t.g;t=t.pa,n.L=1,n.v=ec(ea(e)),n.s=null,n.S=!0,t4(n,t)}function no(t){null!=t.v&&(p.clearTimeout(t.v),t.v=null)}function nl(t,e){var n,i=null;if(t.g==e){no(t),ns(t),t.g=null;var r=2}else{if(!ek(t.i,e))return;i=e.F,eL(t.i,e),r=1}if(0!=t.H){if(e.i)if(1==r){i=e.s?e.s.length:0,e=Date.now()-e.G;var s=t.C;tg(r=tF(),new tB(r,i)),e9(t)}else ni(t);else if(3==(s=e.o)||0==s&&0<e.ca||!(1==r&&(n=e,!(eD(t.i)>=t.i.j-!!t.m)&&(t.m?(t.j=n.F.concat(t.j),!0):1!=t.H&&2!=t.H&&!(t.C>=(t.cb?0:t.eb))&&(t.m=tj(E(t.Na,t,n),nu(t,t.C)),t.C++,!0)))||2==r&&nr(t)))switch(i&&0<i.length&&((e=t.i).i=e.i.concat(i)),s){case 1:nh(t,5);break;case 4:nh(t,10);break;case 3:nh(t,6);break;default:nh(t,2)}}}function nu(t,e){let n=t.ab+Math.floor(Math.random()*t.hb);return t.isActive()||(n*=2),n*e}function nh(t,e){if(t.l.info("Error code "+e),2==e){var n=null;t.h&&(n=null);var i=E(t.pb,t);n||(n=new es("//www.google.com/images/cleardot.gif"),p.location&&"http"==p.location.protocol||eo(n,"https"),ec(n));var r=n.toString();let e=new tR;if(p.Image){let t=new Image;t.onload=T(eP,e,t,"TestLoadImage: loaded",!0,i),t.onerror=T(eP,e,t,"TestLoadImage: error",!1,i),t.onabort=T(eP,e,t,"TestLoadImage: abort",!1,i),t.ontimeout=T(eP,e,t,"TestLoadImage: timeout",!1,i),p.setTimeout(function(){t.ontimeout&&t.ontimeout()},1e4),t.src=r}else i(!1)}else tq(2);t.H=0,t.h&&t.h.za(e),nc(t),e7(t)}function nc(t){if(t.H=0,t.ma=[],t.h){let e=eM(t.i);(0!=e.length||0!=t.j.length)&&(A(t.ma,e),A(t.ma,t.j),t.i.i.length=0,S(t.j),t.j.length=0),t.h.ya()}}
1function nd(t,e,n){var i=n instanceof es?ea(n):new es(n);if(""!=i.g)e&&(i.g=e+"."+i.g),el(i,i.m);else{var r=p.location;i=r.protocol,e=e?e+"."+r.hostname:r.hostname,r=+r.port;var s=new es(null);i&&eo(s,i),e&&(s.g=e),r&&el(s,r),n&&(s.l=n),i=s}return n=t.F,e=t.Da,n&&e&&eh(i,n,e),eh(i,"VER",t.ra),ne(t,i),i}function nf(t,e,n){if(e&&!t.J)throw Error("Can't create secondary domain capable XhrIo object.");return(e=new eK(n&&t.Ha&&!t.va?new eV({ob:!0}):t.va)).Oa(t.J),e}function ng(){}function np(){if(M&&!(10<=Number(z)))throw Error("Environmental error: no available transport.")}function nm(t,e){tf.call(this),this.g=new e5(e),this.l=t,this.h=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.s=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.Ca&&(t?t["X-WebChannel-Client-Profile"]=e.Ca:t={"X-WebChannel-Client-Profile":e.Ca}),this.g.U=t,(t=e&&e.cc)&&!x(t)&&(this.g.o=t),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!x(e)&&(this.g.F=e,null!==(t=this.h)&&e in t&&e in(t=this.h)&&delete t[e]),this.j=new nw(this)}function ny(t){tW.call(this),t.__headers__&&(this.headers=t.__headers__,this.statusCode=t.__status__,delete t.__headers__,delete t.__status__);var e=t.__sm__;if(e){t:{for(let n in e){t=n;break t}t=void 0}(this.i=t)&&(t=this.i,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function nv(){tY.call(this),this.status=1}function nw(t){this.g=t}function nE(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.m=Array(this.blockSize),this.i=this.h=0,this.reset()}function nT(t,e,n){n||(n=0);var i=Array(16);if("string"==typeof e)for(var r=0;16>r;++r)i[r]=e.charCodeAt(n++)|e.charCodeAt(n++)<<8|e.charCodeAt(n++)<<16|e.charCodeAt(n++)<<24;else for(r=0;16>r;++r)i[r]=e[n++]|e[n++]<<8|e[n++]<<16|e[n++]<<24;e=t.g[0],n=t.g[1],r=t.g[2];var s=t.g[3],a=e+(s^n&(r^s))+i[0]+0xd76aa478|0;a=s+(r^(e=n+(a<<7|a>>>25))&(n^r))+i[1]+0xe8c7b756|0,a=r+(n^(s=e+(a<<12|a>>>20))&(e^n))+i[2]+0x242070db|0,a=n+(e^(r=s+(a<<17|a>>>15))&(s^e))+i[3]+0xc1bdceee|0,a=e+(s^(n=r+(a<<22|a>>>10))&(r^s))+i[4]+0xf57c0faf|0,a=s+(r^(e=n+(a<<7|a>>>25))&(n^r))+i[5]+0x4787c62a|0,a=r+(n^(s=e+(a<<12|a>>>20))&(e^n))+i[6]+0xa8304613|0,a=n+(e^(r=s+(a<<17|a>>>15))&(s^e))+i[7]+0xfd469501|0,a=e+(s^(n=r+(a<<22|a>>>10))&(r^s))+i[8]+0x698098d8|0,a=s+(r^(e=n+(a<<7|a>>>25))&(n^r))+i[9]+0x8b44f7af|0,a=r+(n^(s=e+(a<<12|a>>>20))&(e^n))+i[10]+0xffff5bb1|0,a=n+(e^(r=s+(a<<17|a>>>15))&(s^e))+i[11]+0x895cd7be|0,a=e+(s^(n=r+(a<<22|a>>>10))&(r^s))+i[12]+0x6b901122|0,a=s+(r^(e=n+(a<<7|a>>>25))&(n^r))+i[13]+0xfd987193|0,a=r+(n^(s=e+(a<<12|a>>>20))&(e^n))+i[14]+0xa679438e|0,a=n+(e^(r=s+(a<<17|a>>>15))&(s^e))+i[15]+0x49b40821|0,n=r+(a<<22|a>>>10),a=e+(r^s&(n^r))+i[1]+0xf61e2562|0,e=n+(a<<5|a>>>27),a=s+(n^r&(e^n))+i[6]+0xc040b340|0,s=e+(a<<9|a>>>23),a=r+(e^n&(s^e))+i[11]+0x265e5a51|0,r=s+(a<<14|a>>>18),a=n+(s^e&(r^s))+i[0]+0xe9b6c7aa|0,n=r+(a<<20|a>>>12),a=e+(r^s&(n^r))+i[5]+0xd62f105d|0,e=n+(a<<5|a>>>27),a=s+(n^r&(e^n))+i[10]+0x2441453|0,s=e+(a<<9|a>>>23),a=r+(e^n&(s^e))+i[15]+0xd8a1e681|0,r=s+(a<<14|a>>>18),a=n+(s^e&(r^s))+i[4]+0xe7d3fbc8|0,n=r+(a<<20|a>>>12),a=e+(r^s&(n^r))+i[9]+0x21e1cde6|0,e=n+(a<<5|a>>>27),a=s+(n^r&(e^n))+i[14]+0xc33707d6|0,s=e+(a<<9|a>>>23),a=r+(e^n&(s^e))+i[3]+0xf4d50d87|0,r=s+(a<<14|a>>>18),a=n+(s^e&(r^s))+i[8]+0x455a14ed|0,n=r+(a<<20|a>>>12),a=e+(r^s&(n^r))+i[13]+0xa9e3e905|0,e=n+(a<<5|a>>>27),a=s+(n^r&(e^n))+i[2]+0xfcefa3f8|0,s=e+(a<<9|a>>>23),a=r+(e^n&(s^e))+i[7]+0x676f02d9|0,r=s+(a<<14|a>>>18),a=n+(s^e&(r^s))+i[12]+0x8d2a4c8a|0,a=e+((n=r+(a<<20|a>>>12))^r^s)+i[5]+0xfffa3942|0,a=s+((e=n+(a<<4|a>>>28))^n^r)+i[8]+0x8771f681|0,a=r+((s=e+(a<<11|a>>>21))^e^n)+i[11]+0x6d9d6122|0,a=n+((r=s+(a<<16|a>>>16))^s^e)+i[14]+0xfde5380c|0,a=e+((n=r+(a<<23|a>>>9))^r^s)+i[1]+0xa4beea44|0,a=s+((e=n+(a<<4|a>>>28))^n^r)+i[4]+0x4bdecfa9|0,a=r+((s=e+(a<<11|a>>>21))^e^n)+i[7]+0xf6bb4b60|0,a=n+((r=s+(a<<16|a>>>16))^s^e)+i[10]+0xbebfbc70|0,a=e+((n=r+(a<<23|a>>>9))^r^s)+i[13]+0x289b7ec6|0,a=s+((e=n+(a<<4|a>>>28))^n^r)+i[0]+0xeaa127fa|0,a=r+((s=e+(a<<11|a>>>21))^e^n)+i[3]+0xd4ef3085|0,a=n+((r=s+(a<<16|a>>>16))^s^e)+i[6]+0x4881d05|0,a=e+((n=r+(a<<23|a>>>9))^r^s)+i[9]+0xd9d4d039|0,a=s+((e=n+(a<<4|a>>>28))^n^r)+i[12]+0xe6db99e5|0,a=r+((s=e+(a<<11|a>>>21))^e^n)+i[15]+0x1fa27cf8|0,a=n+((r=s+(a<<16|a>>>16))^s^e)+i[2]+0xc4ac5665|0,n=r+(a<<23|a>>>9),a=e+(r^(n|~s))+i[0]+0xf4292244|0,e=n+(a<<6|a>>>26),a=s+(n^(e|~r))+i[7]+0x432aff97|0,s=e+(a<<10|a>>>22),a=r+(e^(s|~n))+i[14]+0xab9423a7|0,r=s+(a<<15|a>>>17),a=n+(s^(r|~e))+i[5]+0xfc93a039|0,n=r+(a<<21|a>>>11),a=e+(r^(n|~s))+i[12]+0x655b59c3|0,e=n+(a<<6|a>>>26),a=s+(n^(e|~r))+i[3]+0x8f0ccc92|0,s=e+(a<<10|a>>>22),a=r+(e^(s|~n))+i[10]+0xffeff47d|0,r=s+(a<<15|a>>>17),a=n+(s^(r|~e))+i[1]+0x85845dd1|0,n=r+(a<<21|a>>>11),a=e+(r^(n|~s))+i[8]+0x6fa87e4f|0,e=n+(a<<6|a>>>26),a=s+(n^(e|~r))+i[15]+0xfe2ce6e0|0,s=e+(a<<10|a>>>
122),a=r+(e^(s|~n))+i[6]+0xa3014314|0,r=s+(a<<15|a>>>17),a=n+(s^(r|~e))+i[13]+0x4e0811a1|0,n=r+(a<<21|a>>>11),a=e+(r^(n|~s))+i[4]+0xf7537e82|0,e=n+(a<<6|a>>>26),a=s+(n^(e|~r))+i[11]+0xbd3af235|0,s=e+(a<<10|a>>>22),a=r+(e^(s|~n))+i[2]+0x2ad7d2bb|0,r=s+(a<<15|a>>>17),a=n+(s^(r|~e))+i[9]+0xeb86d391|0,t.g[0]=t.g[0]+e|0,t.g[1]=t.g[1]+(r+(a<<21|a>>>11))|0,t.g[2]=t.g[2]+r|0,t.g[3]=t.g[3]+s|0}function nb(t,e){this.h=e;for(var n=[],i=!0,r=t.length-1;0<=r;r--){var s=0|t[r];i&&s==e||(n[r]=s,i=!1)}this.g=n}(o=eK.prototype).Oa=function(t){this.M=t},o.ha=function(t,e,n,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.I+"; newUri="+t);e=e?e.toUpperCase():"GET",this.I=t,this.j="",this.m=0,this.F=!1,this.h=!0,this.g=this.u?this.u.g():r.g(),this.C=this.u?tG(this.u):tG(r),this.g.onreadystatechange=E(this.La,this);try{this.G=!0,this.g.open(e,String(t),!0),this.G=!1}catch(t){eW(this,t);return}if(t=n||"",n=new Map(this.headers),i)if(Object.getPrototypeOf(i)===Object.prototype)for(var s in i)n.set(s,i[s]);else if("function"==typeof i.keys&&"function"==typeof i.get)for(let t of i.keys())n.set(t,i.get(t));else throw Error("Unknown input type for opt_headers: "+String(i));for(let[r,a]of(i=Array.from(n.keys()).find(t=>"content-type"==t.toLowerCase()),s=p.FormData&&t instanceof p.FormData,!(0<=C(eH,e))||i||s||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),n))this.g.setRequestHeader(r,a);this.K&&(this.g.responseType=this.K),"withCredentials"in this.g&&this.g.withCredentials!==this.M&&(this.g.withCredentials=this.M);try{var a;eZ(this),0<this.B&&((this.L=(a=this.g,M&&"number"==typeof a.timeout&&void 0!==a.ontimeout))?(this.g.timeout=this.B,this.g.ontimeout=E(this.ua,this)):this.A=tA(this.ua,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(t){eW(this,t)}},o.ua=function(){void 0!==g&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,tg(this,"timeout"),this.abort(8))},o.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,tg(this,"complete"),tg(this,"abort"),eJ(this))},o.N=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),eJ(this,!0)),eK.$.N.call(this)},o.La=function(){this.s||(this.G||this.v||this.l?eX(this):this.kb())},o.kb=function(){eX(this)},o.isActive=function(){return!!this.g},o.da=function(){try{return 2<e0(this)?this.g.status:-1}catch(t){return -1}},o.ja=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},o.Wa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),ez(e)}},o.Ia=function(){return this.m},o.Sa=function(){return"string"==typeof this.j?this.j:String(this.j)},(o=e5.prototype).ra=8,o.H=1,o.Na=function(t){if(this.m)if(this.m=null,1==this.H){if(!t){this.W=Math.floor(1e5*Math.random()),t=this.W++;let r=new tJ(this,this.l,t),s=this.s;if(this.U&&(s?tt(s=J(s),this.U):s=this.U),null!==this.o||this.O||(r.I=s,s=null),this.P)t:{for(var e=0,n=0;n<this.j.length;n++){e:{var i=this.j[n];if("__data__"in i.map&&"string"==typeof(i=i.map.__data__)){i=i.length;break e}i=void 0}if(void 0===i)break;if(4096<(e+=i)){e=n;break t}if(4096===e||n===this.j.length-1){e=n+1;break t}}e=1e3}else e=1e3;e=nn(this,r,e),eh(n=ea(this.I),"RID",t),eh(n,"CVER",22),this.F&&eh(n,"X-HTTP-Session-Id",this.F),ne(this,n),s&&(this.O?e="headers="+encodeURIComponent(String(e2(s)))+"&"+e:this.o&&e3(n,this.o,s)),eR(this.i,r),this.bb&&eh(n,"TYPE","init"),this.P?(eh(n,"$req",e),eh(n,"SID","null"),r.aa=!0,t3(r,n,null)):t3(r,n,e),this.H=2}}else 3==this.H&&(t?nt(this,t):0==this.j.length||ex(this.i)||nt(this))},o.Ma=function(){if(this.u=null,na(this),this.ca&&!(this.M||null==this.g||0>=this.S)){var t=2*this.S;this.l.info("BP detection timer enabled: "+t),this.B=tj(E(this.jb,this),t)}},o.jb=function(){this.B&&(this.B=null,this.l.info("BP detection timeout reached."),this.l.info("Buffering proxy detected and switch to long-polling!"),this.G=!1,this.M=!0,tq(10),e8(this),na(this))},o.ib=function(){null!=this.v&&(this.v=null,e8(this),nr(this),tq(19))},o.pb=function(t){t?(this.l.info("Successfully pinged google.com"),tq(2)):(this.l.info("Failed to ping google.com"),tq(1))},o.isActive=function(){return!!this.h&&this.h.isActive(this)},(o=ng.prototype).Ba=function(){},o.Aa=function(){},o.za=function(){},o.ya=function(){},o.isActive=function(){return!0},o.Va=function(){},np.prototype.g=function(t,e){return new nm(t,e)},b(nm,tf),nm.prototype.m=function(){this.g.h=this.j,this.A&&(this.g.J=!0);var t=this.g,e=this.l,n=this.h||void 0;tq(0),t.Y=e,t.na=n||{},t.G=t.aa,t.I=nd(t,null,t.Y),e9(t)},nm.prototype.close=function(){e6(this.g)},nm.prototype.u=function(t){var e=this.g;if("string"==typeof t){var n={};n.__data__=t,t=n}else this.v&&((n={}).__data__=tm(t),t=n);e.j.push(new eA(e.fb++,t)),3==e.H&&e9(e)},nm.prototype.N=function(){this.g.h=null,delete this.j,e6(this.g),delete this.g,nm.$.N.call(this)},b(ny,tW),b(nv,tY),b(nw,ng),nw.prototype.Ba=function(){tg(this.g,"a")},nw.prototype.Aa=function(t){tg(this.g,new ny(t))},nw.prototype.za=function(t){tg(this.g,new nv)},nw.prototype.ya=function(){tg(this.g,"b")},b(nE,function(){this.blockSize=-1}),nE.prototype.reset=function(){this.g[0]=0x67452301,this.g[1]=0xefcdab89,this.g[2]=0x98badcfe,this.g[3]=0x10325476,this.i=this.h=0},nE.prototype.j=function(t,e){void 0===e&&(e=t.length);for(var n=e-this.blockSize,i=this.m,r=this.h,s=0;s<e;){if(0==r)for(;s<=n;)nT(this,t,s),s+=this.blockSize;if("string"==typeof t){for(;s<e;)if(i[r++]=t.charCodeAt(s++),r==this.blockSize){nT(this,i),r=0;break}}else for(;s<e;)if(i[r++]=t[s++],r==this.blockSize){nT(this,i),r=0;break}}this.h=r,this.i+=e},nE.prototype.l=function(){var t=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);t[0]=128;for(var e=1;e<t.length-8;++e)t[e]=0;var n=8*this.i;for(e=t.length-8;e<t.length;++e)t[e]=255&n,n/=256;for(this.j(t),t=Array(16),e=n=0;4>e;++e)for(var i=0;32>i;i+=8)t[n++]=this.g[e]>>>i&255;return t};
1var nI={};function nC(t){var e;return -128<=t&&128>t?(e=function(t){return new nb([0|t],0>t?-1:0)},Object.prototype.hasOwnProperty.call(nI,t)?nI[t]:nI[t]=e(t)):new nb([0|t],0>t?-1:0)}function nS(t){if(isNaN(t)||!isFinite(t))return n_;if(0>t)return nR(nS(-t));for(var e=[],n=1,i=0;t>=n;i++)e[i]=t/n|0,n*=nA;return new nb(e,0)}var nA=0x100000000,n_=nC(0),nN=nC(1),nx=nC(0x1000000);function nD(t){if(0!=t.h)return!1;for(var e=0;e<t.g.length;e++)if(0!=t.g[e])return!1;return!0}function nk(t){return -1==t.h}function nR(t){for(var e=t.g.length,n=[],i=0;i<e;i++)n[i]=~t.g[i];return new nb(n,~t.h).add(nN)}function nL(t,e){return t.add(nR(e))}function nM(t,e){for(;(65535&t[e])!=t[e];)t[e+1]+=t[e]>>>16,t[e]&=65535,e++}function nO(t,e){this.g=t,this.h=e}function nF(t,e){if(nD(e))throw Error("division by zero");if(nD(t))return new nO(n_,n_);if(nk(t))return e=nF(nR(t),e),new nO(nR(e.g),nR(e.h));if(nk(e))return e=nF(t,nR(e)),new nO(nR(e.g),e.h);if(30<t.g.length){if(nk(t)||nk(e))throw Error("slowDivide_ only works with positive integers.");for(var n=nN,i=e;0>=i.X(t);)n=nP(n),i=nP(i);var r=nV(n,1),s=nV(i,1);for(i=nV(i,2),n=nV(n,2);!nD(i);){var a=s.add(i);0>=a.X(t)&&(r=r.add(n),s=a),i=nV(i,1),n=nV(n,1)}return e=nL(t,r.R(e)),new nO(r,e)}for(r=n_;0<=t.X(e);){for(i=48>=(i=Math.ceil(Math.log(n=Math.max(1,Math.floor(t.ea()/e.ea())))/Math.LN2))?1:Math.pow(2,i-48),a=(s=nS(n)).R(e);nk(a)||0<a.X(t);)n-=i,a=(s=nS(n)).R(e);nD(s)&&(s=nN),r=r.add(s),t=nL(t,a)}return new nO(r,t)}function nP(t){for(var e=t.g.length+1,n=[],i=0;i<e;i++)n[i]=t.D(i)<<1|t.D(i-1)>>>31;return new nb(n,t.h)}function nV(t,e){var n=e>>5;e%=32;for(var i=t.g.length-n,r=[],s=0;s<i;s++)r[s]=0<e?t.D(s+n)>>>e|t.D(s+n+1)<<32-e:t.D(s+n);return new nb(r,t.h)}(o=nb.prototype).ea=function(){if(nk(this))return-nR(this).ea();for(var t=0,e=1,n=0;n<this.g.length;n++){var i=this.D(n);t+=(0<=i?i:nA+i)*e,e*=nA}return t},o.toString=function(t){if(2>(t=t||10)||36<t)throw Error("radix out of range: "+t);if(nD(this))return"0";if(nk(this))return"-"+nR(this).toString(t);for(var e=nS(Math.pow(t,6)),n=this,i="";;){var r=nF(n,e).g,s=((0<(n=nL(n,r.R(e))).g.length?n.g[0]:n.h)>>>0).toString(t);if(nD(n=r))return s+i;for(;6>s.length;)s="0"+s;i=s+i}},o.D=function(t){return 0>t?0:t<this.g.length?this.g[t]:this.h},o.X=function(t){return nk(t=nL(this,t))?-1:+!nD(t)},o.abs=function(){return nk(this)?nR(this):this},o.add=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],i=0,r=0;r<=e;r++){var s=i+(65535&this.D(r))+(65535&t.D(r)),a=(s>>>16)+(this.D(r)>>>16)+(t.D(r)>>>16);i=a>>>16,s&=65535,a&=65535,n[r]=a<<16|s}return new nb(n,-0x80000000&n[n.length-1]?-1:0)},o.R=function(t){if(nD(this)||nD(t))return n_;if(nk(this))return nk(t)?nR(this).R(nR(t)):nR(nR(this).R(t));if(nk(t))return nR(this.R(nR(t)));if(0>this.X(nx)&&0>t.X(nx))return nS(this.ea()*t.ea());for(var e=this.g.length+t.g.length,n=[],i=0;i<2*e;i++)n[i]=0;for(i=0;i<this.g.length;i++)for(var r=0;r<t.g.length;r++){var s=this.D(i)>>>16,a=65535&this.D(i),o=t.D(r)>>>16,l=65535&t.D(r);n[2*i+2*r]+=a*l,nM(n,2*i+2*r),n[2*i+2*r+1]+=s*l,nM(n,2*i+2*r+1),n[2*i+2*r+1]+=a*o,nM(n,2*i+2*r+1),n[2*i+2*r+2]+=s*o,nM(n,2*i+2*r+2)}for(i=0;i<e;i++)n[i]=n[2*i+1]<<16|n[2*i];for(i=e;i<2*e;i++)n[i]=0;return new nb(n,0)},o.gb=function(t){return nF(this,t).h},o.and=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],i=0;i<e;i++)n[i]=this.D(i)&t.D(i);return new nb(n,this.h&t.h)},o.or=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],i=0;i<e;i++)n[i]=this.D(i)|t.D(i);return new nb(n,this.h|t.h)},o.xor=function(t){for(var e=Math.max(this.g.length,t.g.length),n=[],i=0;i<e;i++)n[i]=this.D(i)^t.D(i);return new nb(n,this.h^t.h)},np.prototype.createWebChannel=np.prototype.g,nm.prototype.send=nm.prototype.u,nm.prototype.open=nm.prototype.m,nm.prototype.close=nm.prototype.close,t$.NO_ERROR=0,t$.TIMEOUT=8,t$.HTTP_ERROR=6,tz.COMPLETE="complete",tQ.EventType=tH,tH.OPEN="a",tH.CLOSE="b",tH.ERROR="c",tH.MESSAGE="d",tf.prototype.listen=tf.prototype.O,eK.prototype.listenOnce=eK.prototype.P,eK.prototype.getLastError=eK.prototype.Sa,eK.prototype.getLastErrorCode=eK.prototype.Ia,eK.prototype.getStatus=eK.prototype.da,eK.prototype.getResponseJson=eK.prototype.Wa,eK.prototype.getResponseText=eK.prototype.ja,eK.prototype.send=eK.prototype.ha,eK.prototype.setWithCredentials=eK.prototype.Oa,nE.prototype.digest=nE.prototype.l,nE.prototype.reset=nE.prototype.reset,nE.prototype.update=nE.prototype.j,nb.prototype.add=nb.prototype.add,nb.prototype.multiply=nb.prototype.R,nb.prototype.modulo=nb.prototype.gb,nb.prototype.compare=nb.prototype.X,nb.prototype.toNumber=nb.prototype.ea,nb.prototype.toString=nb.prototype.toString,nb.prototype.getBits=nb.prototype.D,nb.fromNumber=nS,nb.fromString=function t(e,n){if(0==e.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);
1if("-"==e.charAt(0))return nR(t(e.substring(1),n));if(0<=e.indexOf("-"))throw Error('number format error: interior "-" character');for(var i=nS(Math.pow(n,8)),r=n_,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),o=parseInt(e.substring(s,s+a),n);8>a?(a=nS(Math.pow(n,a)),r=r.R(a).add(nS(o))):r=(r=r.R(i)).add(nS(o))}return r};var nU=f.createWebChannelTransport=function(){return new np},nq=f.getStatEventTarget=function(){return tF()},nB=f.ErrorCode=t$,nj=f.EventType=tz,n$=f.Event=tM,nz=f.Stat={xb:0,Ab:1,Bb:2,Ub:3,Zb:4,Wb:5,Xb:6,Vb:7,Tb:8,Yb:9,PROXY:10,NOPROXY:11,Rb:12,Nb:13,Ob:14,Mb:15,Pb:16,Qb:17,tb:18,sb:19,ub:20},nK=f.FetchXmlHttpFactory=eV,nG=f.WebChannel=tQ,nQ=f.XhrIo=eK,nH=f.Md5=nE,nW=f.Integer=nb;let nY="@firebase/firestore";class nX{constructor(t){this.uid=t}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(t){return t.uid===this.uid}}nX.UNAUTHENTICATED=new nX(null),nX.GOOGLE_CREDENTIALS=new nX("google-credentials-uid"),nX.FIRST_PARTY=new nX("first-party-uid"),nX.MOCK_USER=new nX("mock-user");let nJ="9.23.0",nZ=new h.Logger("@firebase/firestore");function n0(){return nZ.logLevel}function n1(t,...e){if(nZ.logLevel<=h.LogLevel.DEBUG){let n=e.map(n4);nZ.debug(`Firestore (${nJ}): ${t}`,...n)}}function n2(t,...e){if(nZ.logLevel<=h.LogLevel.ERROR){let n=e.map(n4);nZ.error(`Firestore (${nJ}): ${t}`,...n)}}function n3(t,...e){if(nZ.logLevel<=h.LogLevel.WARN){let n=e.map(n4);nZ.warn(`Firestore (${nJ}): ${t}`,...n)}}function n4(t){if("string"==typeof t)return t;try{return JSON.stringify(t)}catch(e){return t}}function n5(t="Unexpected state"){let e=`FIRESTORE (${nJ}) INTERNAL ASSERTION FAILED: `+t;throw n2(e),Error(e)}let n6={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class n8 extends c.FirebaseError{constructor(t,e){super(t,e),this.code=t,this.message=e,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class n7{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}class n9{constructor(t,e){this.user=e,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${t}`)}}class it{getToken(){return Promise.resolve(null)}invalidateToken(){}start(t,e){t.enqueueRetryable(()=>e(nX.UNAUTHENTICATED))}shutdown(){}}class ie{constructor(t){this.token=t,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(t,e){this.changeListener=e,t.enqueueRetryable(()=>e(this.token.user))}shutdown(){this.changeListener=null}}class ii{constructor(t){this.t=t,this.currentUser=nX.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(t,e){let n=this.i,i=t=>this.i!==n?(n=this.i,e(t)):Promise.resolve(),r=new n7;this.o=()=>{this.i++,this.currentUser=this.u(),r.resolve(),r=new n7,t.enqueueRetryable(()=>i(this.currentUser))};let s=()=>{let e=r;t.enqueueRetryable(async()=>{await e.promise,await i(this.currentUser)})},a=t=>{n1("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=t,this.auth.addAuthTokenListener(this.o),s()};this.t.onInit(t=>a(t)),setTimeout(()=>{if(!this.auth){let t=this.t.getImmediate({optional:!0});t?a(t):(n1("FirebaseAuthCredentialsProvider","Auth not yet detected"),r.resolve(),r=new n7)}},0),s()}getToken(){let t=this.i,e=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(e).then(e=>this.i!==t?(n1("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):e?("string"==typeof e.accessToken||n5(),new n9(e.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){let t=this.auth&&this.auth.getUid();return null===t||"string"==typeof t||n5(),new nX(t)}}class ir{constructor(t,e,n){this.h=t,this.l=e,this.m=n,this.type="FirstParty",this.user=nX.FIRST_PARTY,this.g=new Map}p(){return this.m?this.m():null}get headers(){this.g.set("X-Goog-AuthUser",this.h);let t=this.p();return t&&this.g.set("Authorization",t),this.l&&this.g.set("X-Goog-Iam-Authorization-Token",this.l),this.g}}class is{constructor(t,e,n){this.h=t,this.l=e,this.m=n}getToken(){return Promise.resolve(new ir(this.h,this.l,this.m))}start(t,e){t.enqueueRetryable(()=>e(nX.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class ia{constructor(t){this.value=t,this.type="AppCheck",this.headers=new Map,t&&t.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class io{constructor(t){this.I=t,this.forceRefresh=!1,this.appCheck=null,this.T=null}start(t,e){let n=t=>{null!=t.error&&n1("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${t.error.message}`);let n=t.token!==this.T;return this.T=t.token,n1("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?e(t.token):Promise.resolve()};this.o=e=>{t.enqueueRetryable(()=>n(e))};let i=t=>{n1("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=t,this.appCheck.addTokenListener(this.o)};this.I.onInit(t=>i(t)),setTimeout(()=>{if(!this.appCheck){let t=this.I.getImmediate({optional:!0});t?i(t):n1("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){let t=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(t).then(t=>t?("string"==typeof t.token||n5(),this.T=t.token,new ia(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}class il{static A(){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length,n="";for(;n.length<20;){let i=function(t){let e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(40);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(let t=0;t<40;
1t++)n[t]=Math.floor(256*Math.random());return n}(0);for(let r=0;r<i.length;++r)n.length<20&&i[r]<e&&(n+=t.charAt(i[r]%t.length))}return n}}function iu(t,e){return t<e?-1:+(t>e)}function ih(t,e,n){return t.length===e.length&&t.every((t,i)=>n(t,e[i]))}class ic{constructor(t,e){if(this.seconds=t,this.nanoseconds=e,e<0||e>=1e9)throw new n8(n6.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-0xe7791f700||t>=0x3afff44180)throw new n8(n6.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}static now(){return ic.fromMillis(Date.now())}static fromDate(t){return ic.fromMillis(t.getTime())}static fromMillis(t){let e=Math.floor(t/1e3),n=Math.floor(1e6*(t-1e3*e));return new ic(e,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(t){return this.seconds===t.seconds?iu(this.nanoseconds,t.nanoseconds):iu(this.seconds,t.seconds)}isEqual(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class id{constructor(t){this.timestamp=t}static fromTimestamp(t){return new id(t)}static min(){return new id(new ic(0,0))}static max(){return new id(new ic(0x3afff4417f,0x3b9ac9ff))}compareTo(t){return this.timestamp._compareTo(t.timestamp)}isEqual(t){return this.timestamp.isEqual(t.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class ig{constructor(t,e,n){void 0===e?e=0:e>t.length&&n5(),void 0===n?n=t.length-e:n>t.length-e&&n5(),this.segments=t,this.offset=e,this.len=n}get length(){return this.len}isEqual(t){return 0===ig.comparator(this,t)}child(t){let e=this.segments.slice(this.offset,this.limit());return t instanceof ig?t.forEach(t=>{e.push(t)}):e.push(t),this.construct(e)}limit(){return this.offset+this.length}popFirst(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(t){return this.segments[this.offset+t]}isEmpty(){return 0===this.length}isPrefixOf(t){if(t.length<this.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}isImmediateParentOf(t){if(this.length+1!==t.length)return!1;for(let e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0}forEach(t){for(let e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,e){let n=Math.min(t.length,e.length);for(let i=0;i<n;i++){let n=t.get(i),r=e.get(i);if(n<r)return -1;if(n>r)return 1}return t.length<e.length?-1:+(t.length>e.length)}}class ip extends ig{construct(t,e,n){return new ip(t,e,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...t){let e=[];for(let n of t){if(n.indexOf("//")>=0)throw new n8(n6.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);e.push(...n.split("/").filter(t=>t.length>0))}return new ip(e)}static emptyPath(){return new ip([])}}let im=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class iy extends ig{construct(t,e,n){return new iy(t,e,n)}static isValidIdentifier(t){return im.test(t)}canonicalString(){return this.toArray().map(t=>(t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),iy.isValidIdentifier(t)||(t="`"+t+"`"),t)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&"__name__"===this.get(0)}static keyField(){return new iy(["__name__"])}static fromServerFormat(t){let e=[],n="",i=0,r=()=>{if(0===n.length)throw new n8(n6.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);e.push(n),n=""},s=!1;for(;i<t.length;){let e=t[i];if("\\"===e){if(i+1===t.length)throw new n8(n6.INVALID_ARGUMENT,"Path has trailing escape character: "+t);let e=t[i+1];if("\\"!==e&&"."!==e&&"`"!==e)throw new n8(n6.INVALID_ARGUMENT,"Path has invali
1d escape sequence: "+t);n+=e,i+=2}else"`"===e?s=!s:"."!==e||s?n+=e:r(),i++}if(r(),s)throw new n8(n6.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new iy(e)}static emptyPath(){return new iy([])}}class iv{constructor(t){this.path=t}static fromPath(t){return new iv(ip.fromString(t))}static fromName(t){return new iv(ip.fromString(t).popFirst(5))}static empty(){return new iv(ip.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(t){return null!==t&&0===ip.comparator(this.path,t.path)}toString(){return this.path.toString()}static comparator(t,e){return ip.comparator(t.path,e.path)}static isDocumentKey(t){return t.length%2==0}static fromSegments(t){return new iv(new ip(t.slice()))}}class iw{constructor(t,e,n){this.readTime=t,this.documentKey=e,this.largestBatchId=n}static min(){return new iw(id.min(),iv.empty(),-1)}static max(){return new iw(id.max(),iv.empty(),-1)}}class iE{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(t){this.onCommittedListeners.push(t)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(t=>t())}}async function iT(t){if(t.code!==n6.FAILED_PRECONDITION||"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab."!==t.message)throw t;n1("LocalStore","Unexpectedly lost primary lease")}class ib{constructor(t){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(t){return this.next(void 0,t)}next(t,e){return this.callbackAttached&&n5(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(e,this.error):this.wrapSuccess(t,this.result):new ib((n,i)=>{this.nextCallback=e=>{this.wrapSuccess(t,e).next(n,i)},this.catchCallback=t=>{this.wrapFailure(e,t).next(n,i)}})}toPromise(){return new Promise((t,e)=>{this.next(t,e)})}wrapUserFunction(t){try{let e=t();return e instanceof ib?e:ib.resolve(e)}catch(t){return ib.reject(t)}}wrapSuccess(t,e){return t?this.wrapUserFunction(()=>t(e)):ib.resolve(e)}wrapFailure(t,e){return t?this.wrapUserFunction(()=>t(e)):ib.reject(e)}static resolve(t){return new ib((e,n)=>{e(t)})}static reject(t){return new ib((e,n)=>{n(t)})}static waitFor(t){return new ib((e,n)=>{let i=0,r=0,s=!1;t.forEach(t=>{++i,t.next(()=>{++r,s&&r===i&&e()},t=>n(t))}),s=!0,r===i&&e()})}static or(t){let e=ib.resolve(!1);for(let n of t)e=e.next(t=>t?ib.resolve(t):n());return e}static forEach(t,e){let n=[];return t.forEach((t,i)=>{n.push(e.call(this,t,i))}),this.waitFor(n)}static mapArray(t,e){return new ib((n,i)=>{let r=t.length,s=Array(r),a=0;for(let o=0;o<r;o++){let l=o;e(t[l]).next(t=>{s[l]=t,++a===r&&n(s)},t=>i(t))}})}static doWhile(t,e){return new ib((n,i)=>{let r=()=>{!0===t()?e().next(()=>{r()},i):n()};r()})}}function iI(t){return"IndexedDbTransactionError"===t.name}class iC{constructor(t,e){this.previousValue=t,e&&(e.sequenceNumberHandler=t=>this.ot(t),this.ut=t=>e.writeSequenceNumber(t))}ot(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue}next(){let t=++this.previousValue;return this.ut&&this.ut(t),t}}function iS(t){return 0===t&&1/t==-1/0}function iA(t){let e=0;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function i_(t,e){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function iN(t){for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}iC.ct=-1;class ix{constructor(t,e){this.comparator=t,this.root=e||ik.EMPTY}insert(t,e){return new ix(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,ik.BLACK,null,null))}remove(t){return new ix(this.comparator,this.root.remove(t,this.comparator).copy(null,null,ik.BLACK,null,null))}get(t){let e=this.root;for(;!e.isEmpty();){let n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null}indexOf(t){let e=0,n=this.root;for(;!n.isEmpty();){let i=this.comparator(t,n.key);if(0===i)return e+n.left.size;i<0?n=n.left:(e+=n.left.size+1,n=n.right)}return -1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(t){return this.root.inorderTraversal(t)}forEach(t){this.inorderTraversal((e,n)=>(t(e,n),!1))}toString(){let t=[];return this.inorderTraversal((e,n)=>(t.push(`${e}:${n}`),!1)),`{${t.join(", ")}}`}reverseTraversal(t){return this.root.reverseTraversal(t)}getIterator(){return new iD(this.root,null,this.comparator,!1)}getIteratorFrom(t){return new iD(this.root,t,this.comparator,!1)}getReverseIterator(){return new iD(this.root,null,this.comparator,!0)}getReverseIteratorFrom(t){return new iD(this.root,t,this.comparator,!0)}}class iD{constructor(t,e,n,i){this.isReverse=i,this.nodeStack=[];let r=1;for(;!t.isEmpty();)if(r=e?n(t.key,e):1,e&&i&&(r*=-1),r<0)t=this.isReverse?t.left:t.right;else{if(0===r){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}getNext(){let t=this.nodeStack.pop(),e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;let t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}}}class ik{constructor(t,e,n,i,r){this.key=t,this.value=e,this.color=null!=n?n:ik.RED,this.left=null!=i?i:ik.EMPTY,this.right=null!=r?r:ik.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,e,n,i,r){return new ik(null!=t?t:this.key,null!=e?e:this.value,
1null!=n?n:this.color,null!=i?i:this.left,null!=r?r:this.right)}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,n){let i=this,r=n(t,i.key);return(i=r<0?i.copy(null,null,null,i.left.insert(t,e,n),null):0===r?i.copy(null,e,null,null,null):i.copy(null,null,null,null,i.right.insert(t,e,n))).fixUp()}removeMin(){if(this.left.isEmpty())return ik.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),(t=t.copy(null,null,null,t.left.removeMin(),null)).fixUp()}remove(t,e){let n,i=this;if(0>e(t,i.key))i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,e),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===e(t,i.key)){if(i.right.isEmpty())return ik.EMPTY;n=i.right.min(),i=i.copy(n.key,n.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,e))}return i.fixUp()}isRed(){return this.color}fixUp(){let t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t}moveRedLeft(){let t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t}moveRedRight(){let t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t}rotateLeft(){let t=this.copy(null,null,ik.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){let t=this.copy(null,null,ik.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){let t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw n5();let t=this.left.check();if(t!==this.right.check())throw n5();return t+ +!this.isRed()}}ik.EMPTY=null,ik.RED=!0,ik.BLACK=!1,ik.EMPTY=new class{constructor(){this.size=0}get key(){throw n5()}get value(){throw n5()}get color(){throw n5()}get left(){throw n5()}get right(){throw n5()}copy(t,e,n,i,r){return this}insert(t,e,n){return new ik(t,e)}remove(t,e){return this}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class iR{constructor(t){this.comparator=t,this.data=new ix(this.comparator)}has(t){return null!==this.data.get(t)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(t){return this.data.indexOf(t)}forEach(t){this.data.inorderTraversal((e,n)=>(t(e),!1))}forEachInRange(t,e){let n=this.data.getIteratorFrom(t[0]);for(;n.hasNext();){let i=n.getNext();if(this.comparator(i.key,t[1])>=0)return;e(i.key)}}forEachWhile(t,e){let n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return}firstAfterOrEqual(t){let e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null}getIterator(){return new iL(this.data.getIterator())}getIteratorFrom(t){return new iL(this.data.getIteratorFrom(t))}add(t){return this.copy(this.data.remove(t).insert(t,!0))}delete(t){return this.has(t)?this.copy(this.data.remove(t)):this}isEmpty(){return this.data.isEmpty()}unionWith(t){let e=this;return e.size<t.size&&(e=t,t=this),t.forEach(t=>{e=e.add(t)}),e}isEqual(t){if(!(t instanceof iR)||this.size!==t.size)return!1;let e=this.data.getIterator(),n=t.data.getIterator();for(;e.hasNext();){let t=e.getNext().key,i=n.getNext().key;if(0!==this.comparator(t,i))return!1}return!0}toArray(){let t=[];
1return this.forEach(e=>{t.push(e)}),t}toString(){let t=[];return this.forEach(e=>t.push(e)),"SortedSet("+t.toString()+")"}copy(t){let e=new iR(this.comparator);return e.data=t,e}}class iL{constructor(t){this.iter=t}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class iM{constructor(t){this.fields=t,t.sort(iy.comparator)}static empty(){return new iM([])}unionWith(t){let e=new iR(iy.comparator);for(let t of this.fields)e=e.add(t);for(let n of t)e=e.add(n);return new iM(e.toArray())}covers(t){for(let e of this.fields)if(e.isPrefixOf(t))return!0;return!1}isEqual(t){return ih(this.fields,t.fields,(t,e)=>t.isEqual(e))}}class iO extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class iF{constructor(t){this.binaryString=t}static fromBase64String(t){return new iF(function(t){try{return atob(t)}catch(t){throw"undefined"!=typeof DOMException&&t instanceof DOMException?new iO("Invalid base64 string: "+t):t}}(t))}static fromUint8Array(t){return new iF(function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t))}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return btoa(this.binaryString)}toUint8Array(){var t=this.binaryString;let e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return iu(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}iF.EMPTY_BYTE_STRING=new iF("");let iP=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function iV(t){if(t||n5(),"string"==typeof t){let e=0,n=iP.exec(t);if(n||n5(),n[1]){let t=n[1];e=Number(t=(t+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(t).getTime()/1e3),nanos:e}}return{seconds:iU(t.seconds),nanos:iU(t.nanos)}}function iU(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function iq(t){return"string"==typeof t?iF.fromBase64String(t):iF.fromUint8Array(t)}function iB(t){var e,n;return"server_timestamp"===(null==(n=((null==(e=null==t?void 0:t.mapValue)?void 0:e.fields)||{}).__type__)?void 0:n.stringValue)}function ij(t){let e=t.mapValue.fields.__previous_value__;return iB(e)?ij(e):e}function i$(t){let e=iV(t.mapValue.fields.__local_write_time__.timestampValue);return new ic(e.seconds,e.nanos)}class iz{constructor(t,e,n,i,r,s,a,o,l){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=i,this.ssl=r,this.forceLongPolling=s,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l}}class iK{constructor(t,e){this.projectId=t,this.database=e||"(default)"}static empty(){return new iK("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(t){return t instanceof iK&&t.projectId===this.projectId&&t.database===this.database}}let iG={};function iQ(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?iB(t)?4:i6(t)?0x1fffffffffffff:10:n5()}function iH(t,e){if(t===e)return!0;let n=iQ(t);if(n!==iQ(e))return!1;switch(n){case 0:case 0x1fffffffffffff:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return i$(t).isEqual(i$(e));case 3:if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;let i=iV(t.timestampValue),r=iV(e.timestampValue);return i.seconds===r.seconds&&i.nanos===r.nanos;case 5:return t.stringValue===e.stringValue;case 6:return iq(t.bytesValue).isEqual(iq(e.bytesValue));case 7:return t.referenceValue===e.referenceValue;case 8:return iU(t.geoPointValue.latitude)===iU(e.geoPointValue.latitude)&&iU(t.geoPointValue.longitude)===iU(e.geoPointValue.longitude);case 2:if("integerValue"in t&&"integerValue"in e)return iU(t.integerValue)===iU(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){let n=iU(t.doubleValue),i=iU(e.doubleValue);return n===i?iS(n)===iS(i):isNaN(n)&&isNaN(i)}return!1;case 9:return ih(t.arrayValue.values||[],e.arrayValue.values||[],iH);case 10:let s=t.mapValue.fields||{},a=e.mapValue.fields||{};if(iA(s)!==iA(a))return!1;for(let t in s)if(s.hasOwnProperty(t)&&(void 0===a[t]||!iH(s[t],a[t])))return!1;return!0;default:return n5()}}function iW(t,e){return void 0!==(t.values||[]).find(t=>iH(t,e))}function iY(t,e){var n,i,r,s;if(t===e)return 0;let a=iQ(t),o=iQ(e);if(a!==o)return iu(a,o);switch(a){case 0:case 0x1fffffffffffff:return 0;case 1:return iu(t.booleanValue,e.booleanValue);case 2:let l,u;return l=iU(t.integerValue||t.doubleValue),l<(u=iU(e.integerValue||e.doubleValue))?-1:l>u?1:l===u?0:isNaN(l)?isNaN(u)?0:-1:1;case 3:return iX(t.timestampValue,e.timestampValue);case 4:return iX(i$(t),i$(e));case 5:return iu(t.stringValue,e.stringValue);case 6:let h,c;return n=t.bytesValue,i=e.bytesValue,h=iq(n),c=iq(i),h.compareTo(c);case 7:return function(t,e){let n=t.split("/"),i=e.split("/");for(let t=0;t<n.length&&t<i.length;t++){let e=iu(n[t],i[t]);if(0!==e)return e}return iu(n.length,i.length)}(t.referenceValue,e.referenceValue);case 8:let d;return r=t.geoPointValue,s=e.geoPointValue,0!==(d=iu(iU(r.latitude),iU(s.latitude)))?d:iu(iU(r.longitude),iU(s.longitude));case 9:return function(t,e){let n=t.values||[],i=e.values||[];for(let t=0;t<n.length&&t<i.length;++t){let e=iY(n[t],i[t]);if(e)return e}return iu(n.length,i.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){if(t===iG&&e===iG)return 0;if(t===iG)return 1;if(e===iG)return -1;let n=t.fields||{},i=Object.keys(n),r=e.fields||{},s=Object.keys(r);i.sort(),s.sort();for(let t=0;t<i.length&&t<s.length;++t){let e=iu(i[t],s[t]);if(0!==e)return e;let a=iY(n[i[t]],r[s[t]]);if(0!==a)return a}return iu(i.length,s.length)}(t.mapValue,e.mapValue);default:throw n5()}}function iX(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return iu(t,e);let n=iV(t),i=iV(e),r=iu(n.seconds,i.seconds);return 0!==r?r:iu(n.nanos,i.nanos)}function iJ(t){var e,n;let i;return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?(i=iV(t.timestampValue),`time(${i.seconds},${i.nanos}
1)`):"stringValue"in t?t.stringValue:"bytesValue"in t?iq(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,iv.fromName(n).toString()):"geoPointValue"in t?`geo(${(e=t.geoPointValue).latitude},${e.longitude})`:"arrayValue"in t?function(t){let e="[",n=!0;for(let i of t.values||[])n?n=!1:e+=",",e+=iJ(i);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){let e=Object.keys(t.fields||{}).sort(),n="{",i=!0;for(let r of e)i?i=!1:n+=",",n+=`${r}:${iJ(t.fields[r])}`;return n+"}"}(t.mapValue):n5()}function iZ(t,e){return{referenceValue:`projects/${t.projectId}/databases/${t.database}/documents/${e.path.canonicalString()}`}}function i0(t){return!!t&&"integerValue"in t}function i1(t){return!!t&&"arrayValue"in t}function i2(t){return!!t&&"nullValue"in t}function i3(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function i4(t){return!!t&&"mapValue"in t}function i5(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){let e={mapValue:{fields:{}}};return i_(t.mapValue.fields,(t,n)=>e.mapValue.fields[t]=i5(n)),e}if(t.arrayValue){let e={arrayValue:{values:[]}};for(let n=0;n<(t.arrayValue.values||[]).length;++n)e.arrayValue.values[n]=i5(t.arrayValue.values[n]);return e}return Object.assign({},t)}function i6(t){return"__max__"===(((t.mapValue||{}).fields||{}).__type__||{}).stringValue}class i8{constructor(t){this.value=t}static empty(){return new i8({mapValue:{}})}field(t){if(t.isEmpty())return this.value;{let e=this.value;for(let n=0;n<t.length-1;++n)if(!i4(e=(e.mapValue.fields||{})[t.get(n)]))return null;return(e=(e.mapValue.fields||{})[t.lastSegment()])||null}}set(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=i5(e)}setAll(t){let e=iy.emptyPath(),n={},i=[];t.forEach((t,r)=>{if(!e.isImmediateParentOf(r)){let t=this.getFieldsMap(e);this.applyChanges(t,n,i),n={},i=[],e=r.popLast()}t?n[r.lastSegment()]=i5(t):i.push(r.lastSegment())});let r=this.getFieldsMap(e);this.applyChanges(r,n,i)}delete(t){let e=this.field(t.popLast());i4(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]}isEqual(t){return iH(this.value,t.value)}getFieldsMap(t){let e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(let n=0;n<t.length;++n){let i=e.mapValue.fields[t.get(n)];i4(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=i),e=i}return e.mapValue.fields}applyChanges(t,e,n){for(let i of(i_(e,(e,n)=>t[e]=n),n))delete t[i]}clone(){return new i8(i5(this.value))}}class i7{constructor(t,e,n,i,r,s,a){this.key=t,this.documentType=e,this.version=n,this.readTime=i,this.createTime=r,this.data=s,this.documentState=a}static newInvalidDocument(t){return new i7(t,0,id.min(),id.min(),id.min(),i8.empty(),0)}static newFoundDocument(t,e,n,i){return new i7(t,1,e,id.min(),n,i,0)}static newNoDocument(t,e){return new i7(t,2,e,id.min(),id.min(),i8.empty(),0)}static newUnknownDocument(t,e){return new i7(t,3,e,id.min(),id.min(),i8.empty(),2)}convertToFoundDocument(t,e){return this.createTime.isEqual(id.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=t),this.version=t,this.documentType=1,this.data=e,this.documentState=0,this}convertToNoDocument(t){return this.version=t,this.documentType=2,this.data=i8.empty(),this.documentState=0,this}convertToUnknownDocument(t){return this.version=t,this.documentType=3,this.data=i8.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=id.min(),this}setReadTime(t){return this.readTime=t,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(t){return t instanceof i7&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new i7(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}
1class i9{constructor(t,e){this.position=t,this.inclusive=e}}function rt(t,e,n){let i=0;for(let r=0;r<t.position.length;r++){let s=e[r],a=t.position[r];if(i=s.field.isKeyField()?iv.comparator(iv.fromName(a.referenceValue),n.key):iY(a,n.data.field(s.field)),"desc"===s.dir&&(i*=-1),0!==i)break}return i}function re(t,e){if(null===t)return null===e;if(null===e||t.inclusive!==e.inclusive||t.position.length!==e.position.length)return!1;for(let n=0;n<t.position.length;n++)if(!iH(t.position[n],e.position[n]))return!1;return!0}class rn{constructor(t,e="asc"){this.field=t,this.dir=e}}class ri{}class rr extends ri{constructor(t,e,n){super(),this.field=t,this.op=e,this.value=n}static create(t,e,n){return t.isKeyField()?"in"===e||"not-in"===e?this.createKeyFieldInFilter(t,e,n):new rl(t,e,n):"array-contains"===e?new rd(t,n):"in"===e?new rf(t,n):"not-in"===e?new rg(t,n):"array-contains-any"===e?new rp(t,n):new rr(t,e,n)}static createKeyFieldInFilter(t,e,n){return"in"===e?new ru(t,n):new rh(t,n)}matches(t){let e=t.data.field(this.field);return"!="===this.op?null!==e&&this.matchesComparison(iY(e,this.value)):null!==e&&iQ(this.value)===iQ(e)&&this.matchesComparison(iY(e,this.value))}matchesComparison(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return n5()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}getFirstInequalityField(){return this.isInequality()?this.field:null}}class rs extends ri{constructor(t,e){super(),this.filters=t,this.op=e,this.lt=null}static create(t,e){return new rs(t,e)}matches(t){return ra(this)?void 0===this.filters.find(e=>!e.matches(t)):void 0!==this.filters.find(e=>e.matches(t))}getFlattenedFilters(){return null!==this.lt||(this.lt=this.filters.reduce((t,e)=>t.concat(e.getFlattenedFilters()),[])),this.lt}getFilters(){return Object.assign([],this.filters)}getFirstInequalityField(){let t=this.ft(t=>t.isInequality());return null!==t?t.field:null}ft(t){for(let e of this.getFlattenedFilters())if(t(e))return e;return null}}function ra(t){return"and"===t.op}function ro(t){for(let e of t.filters)if(e instanceof rs)return!1;return!0}class rl extends rr{constructor(t,e,n){super(t,e,n),this.key=iv.fromName(n.referenceValue)}matches(t){let e=iv.comparator(t.key,this.key);return this.matchesComparison(e)}}class ru extends rr{constructor(t,e){super(t,"in",e),this.keys=rc("in",e)}matches(t){return this.keys.some(e=>e.isEqual(t.key))}}class rh extends rr{constructor(t,e){super(t,"not-in",e),this.keys=rc("not-in",e)}matches(t){return!this.keys.some(e=>e.isEqual(t.key))}}function rc(t,e){var n;return((null==(n=e.arrayValue)?void 0:n.values)||[]).map(t=>iv.fromName(t.referenceValue))}class rd extends rr{constructor(t,e){super(t,"array-contains",e)}matches(t){let e=t.data.field(this.field);return i1(e)&&iW(e.arrayValue,this.value)}}class rf extends rr{constructor(t,e){super(t,"in",e)}matches(t){let e=t.data.field(this.field);return null!==e&&iW(this.value.arrayValue,e)}}class rg extends rr{constructor(t,e){super(t,"not-in",e)}matches(t){if(iW(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let e=t.data.field(this.field);return null!==e&&!iW(this.value.arrayValue,e)}}class rp extends rr{constructor(t,e){super(t,"array-contains-any",e)}matches(t){let e=t.data.field(this.field);return!(!i1(e)||!e.arrayValue.values)&&e.arrayValue.values.some(t=>iW(this.value.arrayValue,t))}}class rm{constructor(t,e=null,n=[],i=[],r=null,s=null,a=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=i,this.limit=r,this.startAt=s,this.endAt=a,this.dt=null}}function ry(t,e=null,n=[],i=[],r=null,s=null,a=null){return new rm(t,e,n,i,r,s,a)}function rv(t){if(null===t.dt){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(t=>(function t(e){if(e instanceof rr)return e.field.canonicalString()+e.op.toString()+iJ(e.value);if(ro(e)&&ra(e))return e.filters.map(e=>t(e)).join(",");{let n=e.filters.map(e=>t(e)).join(",");
1return`${e.op}(${n})`}})(t)).join(","),e+="|ob:",e+=t.orderBy.map(t=>t.field.canonicalString()+t.dir).join(","),null==t.limit||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(t=>iJ(t)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(t=>iJ(t)).join(",")),t.dt=e}return t.dt}function rw(t,e){if(t.limit!==e.limit||t.orderBy.length!==e.orderBy.length)return!1;for(let r=0;r<t.orderBy.length;r++){var n,i;if(n=t.orderBy[r],i=e.orderBy[r],!(n.dir===i.dir&&n.field.isEqual(i.field)))return!1}if(t.filters.length!==e.filters.length)return!1;for(let n=0;n<t.filters.length;n++)if(!function t(e,n){return e instanceof rr?n instanceof rr&&e.op===n.op&&e.field.isEqual(n.field)&&iH(e.value,n.value):e instanceof rs?n instanceof rs&&e.op===n.op&&e.filters.length===n.filters.length&&e.filters.reduce((e,i,r)=>e&&t(i,n.filters[r]),!0):void n5()}(t.filters[n],e.filters[n]))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!re(t.startAt,e.startAt)&&re(t.endAt,e.endAt)}function rE(t){return iv.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}class rT{constructor(t,e=null,n=[],i=[],r=null,s="F",a=null,o=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=i,this.limit=r,this.limitType=s,this.startAt=a,this.endAt=o,this.wt=null,this._t=null,this.startAt,this.endAt}}function rb(t){return new rT(t)}function rI(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}function rC(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function rS(t){for(let e of t.filters){let t=e.getFirstInequalityField();if(null!==t)return t}return null}function rA(t){return null!==t.collectionGroup}function r_(t){if(null===t.wt){t.wt=[];let e=rS(t),n=rC(t);if(null!==e&&null===n)e.isKeyField()||t.wt.push(new rn(e)),t.wt.push(new rn(iy.keyField(),"asc"));else{let e=!1;for(let n of t.explicitOrderBy)t.wt.push(n),n.field.isKeyField()&&(e=!0);if(!e){let e=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.wt.push(new rn(iy.keyField(),e))}}}return t.wt}function rN(t){if(!t._t)if("F"===t.limitType)t._t=ry(t.path,t.collectionGroup,r_(t),t.filters,t.limit,t.startAt,t.endAt);else{let e=[];for(let n of r_(t)){let t="desc"===n.dir?"asc":"desc";e.push(new rn(n.field,t))}let n=t.endAt?new i9(t.endAt.position,t.endAt.inclusive):null,i=t.startAt?new i9(t.startAt.position,t.startAt.inclusive):null;t._t=ry(t.path,t.collectionGroup,e,t.filters,t.limit,n,i)}return t._t}function rx(t,e){e.getFirstInequalityField(),rS(t);let n=t.filters.concat([e]);return new rT(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}function rD(t,e,n){return new rT(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function rk(t,e){return rw(rN(t),rN(e))&&t.limitType===e.limitType}function rR(t){return`${rv(rN(t))}|lt:${t.limitType}`}function rL(t){var e;let n;return`Query(target=${n=(e=rN(t)).path.canonicalString(),null!==e.collectionGroup&&(n+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(n+=`, filters: [${e.filters.map(t=>(function t(e){return e instanceof rr?`${e.field.canonicalString()} ${e.op} ${iJ(e.value)}`:e instanceof rs?e.op.toString()+" {"+e.getFilters().map(t).join(" ,")+"}":"Filter"})(t)).join(", ")}]`),null==e.limit||(n+=", limit: "+e.limit),e.orderBy.length>0&&(n+=`, orderBy: [${e.orderBy.map(t=>`${t.field.canonicalString()} (${t.dir})`).join(", ")}]`),e.startAt&&(n+=", startAt: ",n+=e.startAt.inclusive?"b:":"a:",n+=e.startAt.position.map(t=>iJ(t)).join(",")),e.endAt&&(n+=", endAt: ",n+=e.endAt.inclusive?"a:":"b:",n+=e.endAt.position.map(t=>iJ(t)).join(",")),`Target(${n})`}; limitType=${t.limitType})`}function rM(t,e){var n,i,r,s;let a,o,l;return e.isFoundDocument()&&(a=e.key.path,null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(a):iv.isDocumentKey(t.path)?t.path.isEqual(a):t.path.isImmediateParentOf(a))&&function(t,e){for(let n of r_(t))if(!n.field.isKeyField()&&null===e.data.field(n.field))return!1;return!0}(t,e)&&function(t,e){for(let n of t.filters)if(!n.matches(e))return!1;return!0}(t,e)&&(n=t,i=e,(!n.startAt||(r=n.startAt,o=rt(r,r_(n),i),r.inclusive?!!(o<=0):!!(o<0)))&&(!n.endAt||(s=n.endAt,l=rt(s,r_(n),i),s.inclusive?!!(l>=0):!!(l>0))))}function rO(t){return(e,n)=>{let i=!1;for(let r of r_(t)){let t=function(t,e,n){var i;let r,s,a=t.field.isKeyField()?iv.comparator(e.key,n.key):(i=t.field,r=e.data.field(i),s=n.data.field(i),null!==r&&null!==s?iY(r,s):n5());switch(t.dir){case"asc":return a;
1case"desc":return -1*a;default:return n5()}}(r,e,n);if(0!==t)return t;i=i||r.field.isKeyField()}return 0}}class rF{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){let e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n){for(let[e,i]of n)if(this.equalsFn(e,t))return i}}has(t){return void 0!==this.get(t)}set(t,e){let n=this.mapKeyFn(t),i=this.inner[n];if(void 0===i)return this.inner[n]=[[t,e]],void this.innerSize++;for(let n=0;n<i.length;n++)if(this.equalsFn(i[n][0],t))return void(i[n]=[t,e]);i.push([t,e]),this.innerSize++}delete(t){let e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],t))return 1===n.length?delete this.inner[e]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(t){i_(this.inner,(e,n)=>{for(let[e,i]of n)t(e,i)})}isEmpty(){return iN(this.inner)}size(){return this.innerSize}}let rP=new ix(iv.comparator),rV=new ix(iv.comparator);function rU(...t){let e=rV;for(let n of t)e=e.insert(n.key,n);return e}function rq(t){let e=rV;return t.forEach((t,n)=>e=e.insert(t,n.overlayedDocument)),e}function rB(){return new rF(t=>t.toString(),(t,e)=>t.isEqual(e))}let rj=new ix(iv.comparator),r$=new iR(iv.comparator);function rz(...t){let e=r$;for(let n of t)e=e.add(n);return e}let rK=new iR(iu);function rG(t,e){if(t.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:iS(e)?"-0":e}}function rQ(t){return{integerValue:""+t}}class rH{constructor(){this._=void 0}}function rW(t,e){return t instanceof r1?i0(e)||e&&"doubleValue"in e?e:{integerValue:0}:null}class rY extends rH{}class rX extends rH{constructor(t){super(),this.elements=t}}function rJ(t,e){let n=r3(e);for(let e of t.elements)n.some(t=>iH(t,e))||n.push(e);return{arrayValue:{values:n}}}class rZ extends rH{constructor(t){super(),this.elements=t}}function r0(t,e){let n=r3(e);for(let e of t.elements)n=n.filter(t=>!iH(t,e));return{arrayValue:{values:n}}}class r1 extends rH{constructor(t,e){super(),this.serializer=t,this.gt=e}}function r2(t){return iU(t.integerValue||t.doubleValue)}function r3(t){return i1(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}class r4{constructor(t,e){this.field=t,this.transform=e}}class r5{constructor(t,e){this.version=t,this.transformResults=e}}class r6{constructor(t,e){this.updateTime=t,this.exists=e}static none(){return new r6}static exists(t){return new r6(void 0,t)}static updateTime(t){return new r6(t)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)}}function r8(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}class r7{}function r9(t,e){if(!t.hasLocalMutations||e&&0===e.fields.length)return null;if(null===e)return t.isNoDocument()?new so(t.key,r6.none()):new sn(t.key,t.data,r6.none());{let n=t.data,i=i8.empty(),r=new iR(iy.comparator);for(let t of e.fields)if(!r.has(t)){let e=n.field(t);null===e&&t.length>1&&(t=t.popLast(),e=n.field(t)),null===e?i.delete(t):i.set(t,e),r=r.add(t)}return new si(t.key,i,new iM(r.toArray()),r6.none())}}function st(t,e,n,i){return t instanceof sn?function(t,e,n,i){if(!r8(t.precondition,e))return n;let r=t.value.clone(),s=sa(t.fieldTransforms,i,e);return r.setAll(s),e.convertToFoundDocument(e.version,r).setHasLocalMutations(),null}(t,e,n,i):t instanceof si?function(t,e,n,i){if(!r8(t.precondition,e))return n;let r=sa(t.fieldTransforms,i,e),s=e.data;return(s.setAll(sr(t)),s.setAll(r),e.convertToFoundDocument(e.version,s).setHasLocalMutations(),null===n)?null:n.unionWith(t.fieldMask.fields).unionWith(t.fieldTransforms.map(t=>t.field))}(t,e,n,i):r8(t.precondition,e)?(e.convertToNoDocument(e.version).setHasLocalMutations(),null):n}function se(t,e){var n,i;return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&(n=t.fieldTransforms,i=e.fieldTransforms,!!(void 0===n&&void 0===i||!(!n||!i)&&ih(n,i,(t,e)=>{var n,i;return t.field.isEqual(e.field)&&(n=t.transform,i=e.transform,n instanceof rX&&i instanceof rX||n instanceof rZ&&i instanceof rZ?ih(n.elements,i.elements,iH):n instanceof r1&&i instanceof r1?iH(n.gt,i.gt):n instanceof rY&&i instanceof rY)})))&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}class sn extends r7{constructor(t,e,n,i=[]){super(),this.key=t,this.value=e,this.prec
1ondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class si extends r7{constructor(t,e,n,i,r=[]){super(),this.key=t,this.data=e,this.fieldMask=n,this.precondition=i,this.fieldTransforms=r,this.type=1}getFieldMask(){return this.fieldMask}}function sr(t){let e=new Map;return t.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){let i=t.data.field(n);e.set(n,i)}}),e}function ss(t,e,n){var i;let r=new Map;t.length===n.length||n5();for(let s=0;s<n.length;s++){let a=t[s],o=a.transform,l=e.data.field(a.field);r.set(a.field,(i=n[s],o instanceof rX?rJ(o,l):o instanceof rZ?r0(o,l):i))}return r}function sa(t,e,n){let i=new Map;for(let r of t){let t=r.transform,s=n.data.field(r.field);i.set(r.field,function(t,e,n){var i;let r,s,a;return t instanceof rY?(i=e,r={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:n.seconds,nanos:n.nanoseconds}}}},i&&iB(i)&&(i=ij(i)),i&&(r.fields.__previous_value__=i),{mapValue:r}):t instanceof rX?rJ(t,e):t instanceof rZ?r0(t,e):(a=r2(s=rW(t,e))+r2(t.gt),i0(s)&&i0(t.gt)?rQ(a):rG(t.serializer,a))}(t,s,e))}return i}class so extends r7{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class sl extends r7{constructor(t,e){super(),this.key=t,this.precondition=e,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class su{constructor(t,e,n,i){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(t,e){let n=e.mutationResults;for(let e=0;e<this.mutations.length;e++){let i=this.mutations[e];i.key.isEqual(t.key)&&function(t,e,n){let i,r;t instanceof sn?(i=t.value.clone(),r=ss(t.fieldTransforms,e,n.transformResults),i.setAll(r),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()):t instanceof si?function(t,e,n){if(!r8(t.precondition,e))return e.convertToUnknownDocument(n.version);let i=ss(t.fieldTransforms,e,n.transformResults),r=e.data;r.setAll(sr(t)),r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(t,e,n):e.convertToNoDocument(n.version).setHasCommittedMutations()}(i,t,n[e])}}applyToLocalView(t,e){for(let n of this.baseMutations)n.key.isEqual(t.key)&&(e=st(n,t,e,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(t.key)&&(e=st(n,t,e,this.localWriteTime));return e}applyToLocalDocumentSet(t,e){let n=rB();return this.mutations.forEach(i=>{let r=t.get(i.key),s=r.overlayedDocument,a=this.applyToLocalView(s,r.mutatedFields),o=r9(s,a=e.has(i.key)?null:a);null!==o&&n.set(i.key,o),s.isValidDocument()||s.convertToNoDocument(id.min())}),n}keys(){return this.mutations.reduce((t,e)=>t.add(e.key),rz())}isEqual(t){return this.batchId===t.batchId&&ih(this.mutations,t.mutations,(t,e)=>se(t,e))&&ih(this.baseMutations,t.baseMutations,(t,e)=>se(t,e))}}class sh{constructor(t,e,n,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=i}static from(t,e,n){t.mutations.length===n.length||n5();let i=rj,r=t.mutations;for(let t=0;t<r.length;t++)i=i.insert(r[t].key,n[t].version);return new sh(t,e,n,i)}}class sc{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return null!==t&&this.mutation===t.mutation}toString(){return`Overlay{ 2 largestBatchId: ${this.largestBatchId}, 3 mutation: ${this.mutation.toString()} 4 }`}}class sd{constructor(t,e){this.count=t,this.unchangedNames=e}}function sf(t){if(void 0===t)return n2("GRPC error has no .code"),n6.UNKNOWN;switch(t){case s.OK:return n6.OK;case s.CANCELLED:return n6.CANCELLED;case s.UNKNOWN:return n6.UNKNOWN;case s.DEADLINE_EXCEEDED:return n6.DEADLINE_EXCEEDED;case s.RESOURCE_EXHAUSTED:return n6.RESOURCE_EXHAUSTED;case s.INTERNAL:return n6.INTERNAL;case s.UNAVAILABLE:return n6.UNAVAILABLE;case s.UNAUTHENTICATED:return n6.UNAUTHENTICATED;case s.INVALID_ARGUMENT:return n6.INVALID_ARGUMENT;case s.NOT_FOUND:return n6.NOT_FOUND;case s.ALREADY_EXISTS:return n6.ALREADY_EXISTS;case s.PERMISSION_DENIED:return n6.PERMISSION_DENIED;case s.FAILED_PRECONDITION:return n6.FAILED_PRECONDITION;case s.ABORTED:return n6.ABORTED;case s.OUT_OF_RANGE:return n6.OUT_OF_RANGE;
4case s.UNIMPLEMENTED:return n6.UNIMPLEMENTED;case s.DATA_LOSS:return n6.DATA_LOSS;default:return n5()}}(a=s||(s={}))[a.OK=0]="OK",a[a.CANCELLED=1]="CANCELLED",a[a.UNKNOWN=2]="UNKNOWN",a[a.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",a[a.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",a[a.NOT_FOUND=5]="NOT_FOUND",a[a.ALREADY_EXISTS=6]="ALREADY_EXISTS",a[a.PERMISSION_DENIED=7]="PERMISSION_DENIED",a[a.UNAUTHENTICATED=16]="UNAUTHENTICATED",a[a.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",a[a.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",a[a.ABORTED=10]="ABORTED",a[a.OUT_OF_RANGE=11]="OUT_OF_RANGE",a[a.UNIMPLEMENTED=12]="UNIMPLEMENTED",a[a.INTERNAL=13]="INTERNAL",a[a.UNAVAILABLE=14]="UNAVAILABLE",a[a.DATA_LOSS=15]="DATA_LOSS";class sg{constructor(){this.onExistenceFilterMismatchCallbacks=new Map}static get instance(){return sp}static getOrCreateInstance(){return null===sp&&(sp=new sg),sp}onExistenceFilterMismatch(t){let e=Symbol();return this.onExistenceFilterMismatchCallbacks.set(e,t),()=>this.onExistenceFilterMismatchCallbacks.delete(e)}notifyOnExistenceFilterMismatch(t){this.onExistenceFilterMismatchCallbacks.forEach(e=>e(t))}}let sp=null,sm=new nW([0xffffffff,0xffffffff],0);function sy(t){let e=(new TextEncoder).encode(t),n=new nH;return n.update(e),new Uint8Array(n.digest())}function sv(t){let e=new DataView(t.buffer),n=e.getUint32(0,!0),i=e.getUint32(4,!0),r=e.getUint32(8,!0),s=e.getUint32(12,!0);return[new nW([n,i],0),new nW([r,s],0)]}class sw{constructor(t,e,n){if(this.bitmap=t,this.padding=e,this.hashCount=n,e<0||e>=8)throw new sE(`Invalid padding: ${e}`);if(n<0||t.length>0&&0===this.hashCount)throw new sE(`Invalid hash count: ${n}`);if(0===t.length&&0!==e)throw new sE(`Invalid padding when bitmap length is 0: ${e}`);this.It=8*t.length-e,this.Tt=nW.fromNumber(this.It)}Et(t,e,n){let i=t.add(e.multiply(nW.fromNumber(n)));return 1===i.compare(sm)&&(i=new nW([i.getBits(0),i.getBits(1)],0)),i.modulo(this.Tt).toNumber()}At(t){return 0!=(this.bitmap[Math.floor(t/8)]&1<<t%8)}vt(t){if(0===this.It)return!1;let[e,n]=sv(sy(t));for(let t=0;t<this.hashCount;t++){let i=this.Et(e,n,t);if(!this.At(i))return!1}return!0}static create(t,e,n){let i=new sw(new Uint8Array(Math.ceil(t/8)),t%8==0?0:8-t%8,e);return n.forEach(t=>i.insert(t)),i}insert(t){if(0===this.It)return;let[e,n]=sv(sy(t));for(let t=0;t<this.hashCount;t++){let i=this.Et(e,n,t);this.Rt(i)}}Rt(t){let e=Math.floor(t/8);this.bitmap[e]|=1<<t%8}}
4class sE extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class sT{constructor(t,e,n,i,r){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=i,this.resolvedLimboDocuments=r}static createSynthesizedRemoteEventForCurrentChange(t,e,n){let i=new Map;return i.set(t,sb.createSynthesizedTargetChangeForCurrentChange(t,e,n)),new sT(id.min(),i,new ix(iu),rP,rz())}}class sb{constructor(t,e,n,i,r){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=i,this.removedDocuments=r}static createSynthesizedTargetChangeForCurrentChange(t,e,n){return new sb(n,e,rz(),rz(),rz())}}class sI{constructor(t,e,n,i){this.Pt=t,this.removedTargetIds=e,this.key=n,this.bt=i}}class sC{constructor(t,e){this.targetId=t,this.Vt=e}}class sS{constructor(t,e,n=iF.EMPTY_BYTE_STRING,i=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=i}}class sA{constructor(){this.St=0,this.Dt=sx(),this.Ct=iF.EMPTY_BYTE_STRING,this.xt=!1,this.Nt=!0}get current(){return this.xt}get resumeToken(){return this.Ct}get kt(){return 0!==this.St}get Mt(){return this.Nt}$t(t){t.approximateByteSize()>0&&(this.Nt=!0,this.Ct=t)}Ot(){let t=rz(),e=rz(),n=rz();return this.Dt.forEach((i,r)=>{switch(r){case 0:t=t.add(i);break;case 2:e=e.add(i);break;case 1:n=n.add(i);break;default:n5()}}),new sb(this.Ct,this.xt,t,e,n)}Ft(){this.Nt=!1,this.Dt=sx()}Bt(t,e){this.Nt=!0,this.Dt=this.Dt.insert(t,e)}Lt(t){this.Nt=!0,this.Dt=this.Dt.remove(t)}qt(){this.St+=1}Ut(){this.St-=1}Kt(){this.Nt=!0,this.xt=!0}}class s_{constructor(t){this.Gt=t,this.Qt=new Map,this.jt=rP,this.zt=sN(),this.Wt=new ix(iu)}Ht(t){for(let e of t.Pt)t.bt&&t.bt.isFoundDocument()?this.Jt(e,t.bt):this.Yt(e,t.key,t.bt);for(let e of t.removedTargetIds)this.Yt(e,t.key,t.bt)}Xt(t){this.forEachTarget(t,e=>{let n=this.Zt(e);switch(t.state){case 0:this.te(e)&&n.$t(t.resumeToken);break;case 1:n.Ut(),n.kt||n.Ft(),n.$t(t.resumeToken);break;case 2:n.Ut(),n.kt||this.removeTarget(e);break;case 3:this.te(e)&&(n.Kt(),n.$t(t.resumeToken));break;case 4:this.te(e)&&(this.ee(e),n.$t(t.resumeToken));break;default:n5()}})}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Qt.forEach((t,n)=>{this.te(n)&&e(n)})}ne(t){var e,n,i,r,s,a,o,l;let u=t.targetId,h=t.Vt.count,c=this.se(u);if(c){let d=c.target;if(rE(d))if(0===h){let t=new iv(d.path);this.Yt(u,t,i7.newNoDocument(t,id.min()))}else 1===h||n5();else{let c=this.ie(u);if(c!==h){let h,d,f=this.re(t,c);0!==f&&(this.ee(u),this.Wt=this.Wt.insert(u,2===f?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch")),null==(e=sg.instance)||e.notifyOnExistenceFilterMismatch((h={localCacheCount:c,existenceFilterCount:(n=t.Vt).count},(d=n.unchangedNames)&&(h.bloomFilter={applied:0===f,hashCount:null!=(i=null==d?void 0:d.hashCount)?i:0,bitmapLength:null!=(a=null==(s=null==(r=null==d?void 0:d.bits)?void 0:r.bitmap)?void 0:s.length)?a:0,padding:null!=(l=null==(o=null==d?void 0:d.bits)?void 0:o.padding)?l:0}),h))}}}}re(t,e){let n,i,{unchangedNames:r,count:s}=t.Vt;if(!r||!r.bits)return 1;let{bits:{bitmap:a="",padding:o=0},hashCount:l=0}=r;try{n=iq(a).toUint8Array()}catch(t){if(t instanceof iO)return n3("Decoding the base64 bloom filter in existence filter failed ("+t.message+"); ignoring the bloom filter and falling back to full re-query."),1;throw t}try{i=new sw(n,o,l)}catch(t){return n3(t instanceof sE?"BloomFilter error: ":"Applying bloom filter failed: ",t),1}return 0===i.It?1:2*(s!==e-this.oe(t.targetId,i))}oe(t,e){let n=this.Gt.getRemoteKeysForTarget(t),i=0;return n.forEach(n=>{let r=this.Gt.ue(),s=`projects/${r.projectId}/databases/${r.database}/documents/${n.path.canonicalString()}`;e.vt(s)||(this.Yt(t,n,null),i++)}),i}ce(t){let e=new Map;this.Qt.forEach((n,i)=>{let r=this.se(i);if(r){if(n.current&&rE(r.target)){let e=new iv(r.target.path);null!==this.jt.get(e)||this.ae(i,e)||this.Yt(i,e,i7.newNoDocument(e,t))}n.Mt&&(e.set(i,n.Ot()),n.Ft())}});let n=rz();this.zt.forEach((t,e)=>{let i=!0;e.forEachWhile(t=>{let e=this.se(t);return!e||"TargetPurposeLimboResolution"===e.purpose||(i=!1,!1)}),i&&(n=n.add(t))}),this.jt.forEach((e,n)=>n.setReadTime(t));let i=new sT(t,e,this.Wt,this.jt,n);return this.jt=rP,this.zt=sN(),this.Wt=new ix(iu),i}Jt(t,e){if(!this.te(t))return;let n=2*!!this.ae(t,e.key);this.Zt(t).Bt(e.key,n),this.jt=this.jt.insert(e.key,e),this.zt=this.zt.insert(e.key,this.he(e.key).add(t))}Yt(t,e,n){if(!this.te(t))return;let i=this.Zt(t);this.ae(t,e)?i.Bt(e,1):i.Lt(e),this.zt=this.zt.insert(e,this.he(e).delete(t)),n&&(this.jt=this.jt.insert(e,n))}removeTarget(t){this.Qt.delete(t)}ie(t){let e=this.Zt(t).Ot();return this.Gt.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}qt(t){this.Zt(t).qt()}Zt(t){let e=this.Qt.get(t);return e||(e=new sA,this.Qt.set(t,e)),e}he(t){let e=this.zt.get(t);return e||(e=new iR(iu),this.zt=this.zt.insert(t,e)),e}te(t){let e=null!==this.se(t);return e||n1("WatchChangeAggregator","Detected inactive target",t),e}se(t){let e=this.Qt.get(t);return e&&e.kt?null:this.Gt.le(t)}ee(t){this.Qt.set(t,new sA),this.Gt.getRemoteKeysForTarget(t).forEach(e
4=>{this.Yt(t,e,null)})}ae(t,e){return this.Gt.getRemoteKeysForTarget(t).has(e)}}function sN(){return new ix(iv.comparator)}function sx(){return new ix(iv.comparator)}let sD={asc:"ASCENDING",desc:"DESCENDING"},sk={"<":"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"},sR={and:"AND",or:"OR"};class sL{constructor(t,e){this.databaseId=t,this.useProto3Json=e}}function sM(t,e){return t.useProto3Json||null==e?e:{value:e}}function sO(t,e){return t.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function sF(t,e){return t.useProto3Json?e.toBase64():e.toUint8Array()}function sP(t){let e;return t||n5(),id.fromTimestamp(new ic((e=iV(t)).seconds,e.nanos))}function sV(t,e){return new ip(["projects",t.projectId,"databases",t.database]).child("documents").child(e).canonicalString()}function sU(t){let e=ip.fromString(t);return sH(e)||n5(),e}function sq(t,e){return sV(t.databaseId,e.path)}function sB(t,e){let n=sU(e);if(n.get(1)!==t.databaseId.projectId)throw new n8(n6.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new n8(n6.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new iv(sz(n))}function sj(t,e){return sV(t.databaseId,e)}function s$(t){return new ip(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function sz(t){return t.length>4&&"documents"===t.get(4)||n5(),t.popFirst(5)}function sK(t,e,n){return{name:sq(t,e),fields:n.value.mapValue.fields}}function sG(t){return{fieldPath:t.canonicalString()}}function sQ(t){return iy.fromServerFormat(t.fieldPath)}function sH(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}class sW{constructor(t,e,n,i,r=id.min(),s=id.min(),a=iF.EMPTY_BYTE_STRING,o=null){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=i,this.snapshotVersion=r,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(t){return new sW(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,e){return new sW(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new sW(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new sW(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}}class sY{constructor(t){this.fe=t}}class sX{constructor(){}_e(t,e){this.me(t,e),e.ge()}me(t,e){if("nullValue"in t)this.ye(e,5);else if("booleanValue"in t)this.ye(e,10),e.pe(+!!t.booleanValue);else if("integerValue"in t)this.ye(e,15),e.pe(iU(t.integerValue));else if("doubleValue"in t){let n=iU(t.doubleValue);isNaN(n)?this.ye(e,13):(this.ye(e,15),iS(n)?e.pe(0):e.pe(n))}else if("timestampValue"in t){let n=t.timestampValue;this.ye(e,20),"string"==typeof n?e.Ie(n):(e.Ie(`${n.seconds||""}`),e.pe(n.nanos||0))}else if("stringValue"in t)this.Te(t.stringValue,e),this.Ee(e);else if("bytesValue"in t)this.ye(e,30),e.Ae(iq(t.bytesValue)),this.Ee(e);else if("referenceValue"in t)this.ve(t.referenceValue,e);else if("geoPointValue"in t){let n=t.geoPointValue;this.ye(e,45),e.pe(n.latitude||0),e.pe(n.longitude||0)}else"mapValue"in t?i6(t)?this.ye(e,Number.MAX_SAFE_INTEGER):(this.Re(t.mapValue,e),this.Ee(e)):"arrayValue"in t?(this.Pe(t.arrayValue,e),this.Ee(e)):n5()}Te(t,e){this.ye(e,25),this.be(t,e)}be(t,e){e.Ie(t)}Re(t,e){let n=t.fields||{};for(let t of(this.ye(e,55),Object.keys(n)))this.Te(t,e),this.me(n[t],e)}Pe(t,e){let n=t.values||[];for(let t of(this.ye(e,50),n))this.me(t,e)}ve(t,e){this.ye(e,37),iv.fromName(t).path.forEach(t=>{this.ye(e,60),this.be(t,e)})}ye(t,e){t.pe(e)}Ee(t){t.pe(2)}}sX.Ve=new sX;class sJ{constructor(){this.rn=new sZ}addToCollectionParentIndex(t,e){return this.rn.add(e),ib.resolve()}getCollectionParents(t,e){return ib.resolve(this.rn.getEntries(e))}addFieldIndex(t,e){return ib.resolve()}deleteFieldIndex(t,e){return ib.resolve()}getDocumentsMatchingTarget(t,e){return ib.resolve(null)}getIndexType(t,e){return ib.resolve(0)}getFieldIndexes(t,e){return ib.resolve([])}getNextCollectionGroupToUpdate(t){return ib.resolve(null)}getMinOffset(t,e){return ib.resolve(iw.min())}getMinOffsetFromCollectionGroup(t,e){return ib.resolve(iw.min())}updateCollectionGroup(t,e,n){return ib.resolve()}updateIndexEntries(t,e){return ib.resolve()}}class sZ{constructor(){this.index={}}add(t){let e=t.lastSegment(),n=t.popLast(),i=this.index[e]||new iR(ip.comparator),r=!i.has(n);return this.index[e]=i.add(n),r}has(t){let e=t.lastSegment(),n=t.popLast(),i=this.index[e];return i&&i.has(n)}getEntries(t){return(this.index[t]||new iR(ip.comparator)).toArray()}}new Uint8Array(0);class s0{constructor(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}static withCacheSize(t){return new s0(t,s0.DEFAULT_COLLECTION_PE
4RCENTILE,s0.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}s0.DEFAULT_COLLECTION_PERCENTILE=10,s0.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,s0.DEFAULT=new s0(0x2800000,s0.DEFAULT_COLLECTION_PERCENTILE,s0.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),s0.DISABLED=new s0(-1,0,0);class s1{constructor(t){this.Nn=t}next(){return this.Nn+=2,this.Nn}static kn(){return new s1(0)}static Mn(){return new s1(-1)}}class s2{constructor(){this.changes=new rF(t=>t.toString(),(t,e)=>t.isEqual(e)),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,i7.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();let n=this.changes.get(e);return void 0!==n?ib.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}class s3{constructor(t,e){this.overlayedDocument=t,this.mutatedFields=e}}class s4{constructor(t,e,n,i){this.remoteDocumentCache=t,this.mutationQueue=e,this.documentOverlayCache=n,this.indexManager=i}getDocument(t,e){let n=null;return this.documentOverlayCache.getOverlay(t,e).next(i=>(n=i,this.remoteDocumentCache.getEntry(t,e))).next(t=>(null!==n&&st(n.mutation,t,iM.empty(),ic.now()),t))}getDocuments(t,e){return this.remoteDocumentCache.getEntries(t,e).next(e=>this.getLocalViewOfDocuments(t,e,rz()).next(()=>e))}getLocalViewOfDocuments(t,e,n=rz()){let i=rB();return this.populateOverlays(t,i,e).next(()=>this.computeViews(t,e,i,n).next(t=>{let e=rU();return t.forEach((t,n)=>{e=e.insert(t,n.overlayedDocument)}),e}))}getOverlayedDocuments(t,e){let n=rB();return this.populateOverlays(t,n,e).next(()=>this.computeViews(t,e,n,rz()))}populateOverlays(t,e,n){let i=[];return n.forEach(t=>{e.has(t)||i.push(t)}),this.documentOverlayCache.getOverlays(t,i).next(t=>{t.forEach((t,n)=>{e.set(t,n)})})}computeViews(t,e,n,i){let r=rP,s=rB(),a=rB();return e.forEach((t,e)=>{let a=n.get(e.key);i.has(e.key)&&(void 0===a||a.mutation instanceof si)?r=r.insert(e.key,e):void 0!==a?(s.set(e.key,a.mutation.getFieldMask()),st(a.mutation,e,a.mutation.getFieldMask(),ic.now())):s.set(e.key,iM.empty())}),this.recalculateAndSaveOverlays(t,r).next(t=>(t.forEach((t,e)=>s.set(t,e)),e.forEach((t,e)=>{var n;return a.set(t,new s3(e,null!=(n=s.get(t))?n:null))}),a))}recalculateAndSaveOverlays(t,e){let n=rB(),i=new ix((t,e)=>t-e),r=rz();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(t,e).next(t=>{for(let r of t)r.keys().forEach(t=>{let s=e.get(t);if(null===s)return;let a=n.get(t)||iM.empty();a=r.applyToLocalView(s,a),n.set(t,a);let o=(i.get(r.batchId)||rz()).add(t);i=i.insert(r.batchId,o)})}).next(()=>{let s=[],a=i.getReverseIterator();for(;a.hasNext();){let i=a.getNext(),o=i.key,l=i.value,u=rB();l.forEach(t=>{if(!r.has(t)){let i=r9(e.get(t),n.get(t));null!==i&&u.set(t,i),r=r.add(t)}}),s.push(this.documentOverlayCache.saveOverlays(t,o,u))}return ib.waitFor(s)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(t,e){return this.remoteDocumentCache.getEntries(t,e).next(e=>this.recalculateAndSaveOverlays(t,e))}getDocumentsMatchingQuery(t,e,n){return iv.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length?this.getDocumentsMatchingDocumentQuery(t,e.path):rA(e)?this.getDocumentsMatchingCollectionGroupQuery(t,e,n):this.getDocumentsMatchingCollectionQuery(t,e,n)}getNextDocuments(t,e,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(t,e,n,i).next(r=>{let s=i-r.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(t,e,n.largestBatchId,i-r.size):ib.resolve(rB()),a=-1,o=r;return s.next(e=>ib.forEach(e,(e,n)=>(a<n.largestBatchId&&(a=n.largestBatchId),r.get(e)?ib.resolve():this.remoteDocumentCache.getEntry(t,e).next(t=>{o=o.insert(e,t)}))).next(()=>this.populateOverlays(t,e,r)).next(()=>this.computeViews(t,o,e,rz())).next(t=>({batchId:a,changes:rq(t)})))})}getDocumentsMatchingDocumentQuery(t,e){return this.getDocument(t,new iv(e)).next(t=>{let e=rU();return t.isFoundDocument()&&(e=e.insert(t.key,t)),e})}getDocumentsMatchingCollectionGroupQuery(t,e,n){let i=e.collectionGroup,r=rU();return this.indexManager.getCollectionParents(t,i).next(s=>ib.forEach(s,s=>{let a=new rT(s.child(i),null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt);return this.getDocumentsMatchingCollectionQuery(t,a,n).next(t=>{t.forEach((t,e)=>{r=r.insert(t,e)})})}).next(()=>r))}getDocumentsMatchingCollectionQuery(t,e,n){let i;return this.documentOverlayCache.getOverlaysForCollection(t,e.path,n.largestBatchId).next(r=>(i=r,this.remoteDocumentCache.getDocumentsMatchingQuery(t,e,n,i))).next(t=>
4{i.forEach((e,n)=>{let i=n.getKey();null===t.get(i)&&(t=t.insert(i,i7.newInvalidDocument(i)))});let n=rU();return t.forEach((t,r)=>{let s=i.get(t);void 0!==s&&st(s.mutation,r,iM.empty(),ic.now()),rM(e,r)&&(n=n.insert(t,r))}),n})}}class s5{constructor(t){this.serializer=t,this.cs=new Map,this.hs=new Map}getBundleMetadata(t,e){return ib.resolve(this.cs.get(e))}saveBundleMetadata(t,e){return this.cs.set(e.id,{id:e.id,version:e.version,createTime:sP(e.createTime)}),ib.resolve()}getNamedQuery(t,e){return ib.resolve(this.hs.get(e))}saveNamedQuery(t,e){var n;let i;return this.hs.set(e.name,{name:e.name,query:(i=function(t){var e,n,i,r;let s,a,o,l,u,h=4===(s=sU(t.parent)).length?ip.emptyPath():sz(s),c=t.structuredQuery,d=c.from?c.from.length:0,f=null;if(d>0){1===d||n5();let t=c.from[0];t.allDescendants?f=t.collectionId:h=h.child(t.collectionId)}let g=[];c.where&&(g=(a=function t(e){return void 0!==e.unaryFilter?function(t){switch(t.unaryFilter.op){case"IS_NAN":let e=sQ(t.unaryFilter.field);return rr.create(e,"==",{doubleValue:NaN});case"IS_NULL":let n=sQ(t.unaryFilter.field);return rr.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let i=sQ(t.unaryFilter.field);return rr.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let r=sQ(t.unaryFilter.field);return rr.create(r,"!=",{nullValue:"NULL_VALUE"});default:return n5()}}(e):void 0!==e.fieldFilter?rr.create(sQ(e.fieldFilter.field),function(t){switch(t){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";default:return n5()}}(e.fieldFilter.op),e.fieldFilter.value):void 0!==e.compositeFilter?rs.create(e.compositeFilter.filters.map(e=>t(e)),function(t){switch(t){case"AND":return"and";case"OR":return"or";default:return n5()}}(e.compositeFilter.op)):n5()}(c.where))instanceof rs&&ro(e=a)&&ra(e)?a.getFilters():[a]);let p=[];c.orderBy&&(p=c.orderBy.map(t=>new rn(sQ(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))));let m=null;c.limit&&(m=null==(o="object"==typeof(n=c.limit)?n.value:n)?null:o);let y=null;c.startAt&&(l=!!(i=c.startAt).before,y=new i9(i.values||[],l));let v=null;return c.endAt&&(u=!(r=c.endAt).before,v=new i9(r.values||[],u)),new rT(h,f,p,g,m,"F",y,v)}({parent:(n=e.bundledQuery).parent,structuredQuery:n.structuredQuery}),"LAST"===n.limitType?rD(i,i.limit,"L"):i),readTime:sP(e.readTime)}),ib.resolve()}}class s6{constructor(){this.overlays=new ix(iv.comparator),this.ls=new Map}getOverlay(t,e){return ib.resolve(this.overlays.get(e))}getOverlays(t,e){let n=rB();return ib.forEach(e,e=>this.getOverlay(t,e).next(t=>{null!==t&&n.set(e,t)})).next(()=>n)}saveOverlays(t,e,n){return n.forEach((n,i)=>{this.we(t,e,i)}),ib.resolve()}removeOverlaysForBatchId(t,e,n){let i=this.ls.get(n);return void 0!==i&&(i.forEach(t=>this.overlays=this.overlays.remove(t)),this.ls.delete(n)),ib.resolve()}getOverlaysForCollection(t,e,n){let i=rB(),r=e.length+1,s=new iv(e.child("")),a=this.overlays.getIteratorFrom(s);for(;a.hasNext();){let t=a.getNext().value,s=t.getKey();if(!e.isPrefixOf(s.path))break;s.path.length===r&&t.largestBatchId>n&&i.set(t.getKey(),t)}return ib.resolve(i)}getOverlaysForCollectionGroup(t,e,n,i){let r=new ix((t,e)=>t-e),s=this.overlays.getIterator();for(;s.hasNext();){let t=s.getNext().value;if(t.getKey().getCollectionGroup()===e&&t.largestBatchId>n){let e=r.get(t.largestBatchId);null===e&&(e=rB(),r=r.insert(t.largestBatchId,e)),e.set(t.getKey(),t)}}let a=rB(),o=r.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((t,e)=>a.set(t,e)),!(a.size()>=i)););return ib.resolve(a)}we(t,e,n){let i=this.overlays.get(n.key);if(null!==i){let t=this.ls.get(i.largestBatchId).delete(n.key);this.ls.set(i.largestBatchId,t)}this.overlays=this.overlays.insert(n.key,new sc(e,n));let r=this.ls.get(e);void 0===r&&(r=rz(),this.ls.set(e,r)),this.ls.set(e,r.add(n.key))}}class s8{constructor(){this.fs=new iR(s7.ds),this.ws=new iR(s7._s)}isEmpty(){return this.fs.isEmpty()}addReference(t,e){let n=new s7(t,e);this.fs=this.fs.add(n),this.ws=this.ws.add(n)}gs(t,e){t.forEach(t=>this.addReference(t,e))}removeReference(t,e){this.ys(new s7(t,e))}ps(t,e){t.forEach(t=>this.removeReference(t,e))}Is(t){let e=new iv(new ip([])),n=new s7(e,t),i=new s7(e,t+1),r=[];return this.ws.forEachInRange([n,i],t=>{this.ys(t),r.push(t.key)}),r}
4Ts(){this.fs.forEach(t=>this.ys(t))}ys(t){this.fs=this.fs.delete(t),this.ws=this.ws.delete(t)}Es(t){let e=new iv(new ip([])),n=new s7(e,t),i=new s7(e,t+1),r=rz();return this.ws.forEachInRange([n,i],t=>{r=r.add(t.key)}),r}containsKey(t){let e=new s7(t,0),n=this.fs.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)}}class s7{constructor(t,e){this.key=t,this.As=e}static ds(t,e){return iv.comparator(t.key,e.key)||iu(t.As,e.As)}static _s(t,e){return iu(t.As,e.As)||iv.comparator(t.key,e.key)}}class s9{constructor(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.vs=1,this.Rs=new iR(s7.ds)}checkEmpty(t){return ib.resolve(0===this.mutationQueue.length)}addMutationBatch(t,e,n,i){let r=this.vs;this.vs++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new su(r,e,n,i);for(let e of(this.mutationQueue.push(s),i))this.Rs=this.Rs.add(new s7(e.key,r)),this.indexManager.addToCollectionParentIndex(t,e.key.path.popLast());return ib.resolve(s)}lookupMutationBatch(t,e){return ib.resolve(this.Ps(e))}getNextMutationBatchAfterBatchId(t,e){let n=this.bs(e+1),i=n<0?0:n;return ib.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ib.resolve(0===this.mutationQueue.length?-1:this.vs-1)}getAllMutationBatches(t){return ib.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(t,e){let n=new s7(e,0),i=new s7(e,1/0),r=[];return this.Rs.forEachInRange([n,i],t=>{let e=this.Ps(t.As);r.push(e)}),ib.resolve(r)}getAllMutationBatchesAffectingDocumentKeys(t,e){let n=new iR(iu);return e.forEach(t=>{let e=new s7(t,0),i=new s7(t,1/0);this.Rs.forEachInRange([e,i],t=>{n=n.add(t.As)})}),ib.resolve(this.Vs(n))}getAllMutationBatchesAffectingQuery(t,e){let n=e.path,i=n.length+1,r=n;iv.isDocumentKey(r)||(r=r.child(""));let s=new s7(new iv(r),0),a=new iR(iu);return this.Rs.forEachWhile(t=>{let e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===i&&(a=a.add(t.As)),!0)},s),ib.resolve(this.Vs(a))}Vs(t){let e=[];return t.forEach(t=>{let n=this.Ps(t);null!==n&&e.push(n)}),e}removeMutationBatch(t,e){0===this.Ss(e.batchId,"removed")||n5(),this.mutationQueue.shift();let n=this.Rs;return ib.forEach(e.mutations,i=>{let r=new s7(i.key,e.batchId);return n=n.delete(r),this.referenceDelegate.markPotentiallyOrphaned(t,i.key)}).next(()=>{this.Rs=n})}Cn(t){}containsKey(t,e){let n=new s7(e,0),i=this.Rs.firstAfterOrEqual(n);return ib.resolve(e.isEqual(i&&i.key))}performConsistencyCheck(t){return this.mutationQueue.length,ib.resolve()}Ss(t,e){return this.bs(t)}bs(t){return 0===this.mutationQueue.length?0:t-this.mutationQueue[0].batchId}Ps(t){let e=this.bs(t);return e<0||e>=this.mutationQueue.length?null:this.mutationQueue[e]}}class at{constructor(t){this.Ds=t,this.docs=new ix(iv.comparator),this.size=0}setIndexManager(t){this.indexManager=t}addEntry(t,e){let n=e.key,i=this.docs.get(n),r=i?i.size:0,s=this.Ds(e);return this.docs=this.docs.insert(n,{document:e.mutableCopy(),size:s}),this.size+=s-r,this.indexManager.addToCollectionParentIndex(t,n.path.popLast())}removeEntry(t){let e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)}getEntry(t,e){let n=this.docs.get(e);return ib.resolve(n?n.document.mutableCopy():i7.newInvalidDocument(e))}getEntries(t,e){let n=rP;return e.forEach(t=>{let e=this.docs.get(t);n=n.insert(t,e?e.document.mutableCopy():i7.newInvalidDocument(t))}),ib.resolve(n)}getDocumentsMatchingQuery(t,e,n,i){let r=rP,s=e.path,a=new iv(s.child("")),o=this.docs.getIteratorFrom(a);for(;o.hasNext();){let{key:t,value:{document:a}}=o.getNext();if(!s.isPrefixOf(t.path))break;t.path.length>s.length+1||0>=function(t,e){let n=t.readTime.compareTo(e.readTime);return 0!==n||0!==(n=iv.comparator(t.documentKey,e.documentKey))?n:iu(t.largestBatchId,e.largestBatchId)}(new iw(a.readTime,a.key,-1),n)||(i.has(a.key)||rM(e,a))&&(r=r.insert(a.key,a.mutableCopy()))}return ib.resolve(r)}getAllFromCollectionGroup(t,e,n,i){n5()}Cs(t,e){return ib.forEach(this.docs,t=>e(t))}newChangeBuffer(t){return new ae(this)}getSize(t){return ib.resolve(this.size)}}class ae extends s2{constructor(t){super(),this.os=t}applyChanges(t){let e=[];
vendor: 5,589 bytes, line 4
4return this.changes.forEach((n,i)=>{i.isValidDocument()?e.push(this.os.addEntry(t,i)):this.os.removeEntry(n)}),ib.waitFor(e)}getFromCache(t,e){return this.os.getEntry(t,e)}getAllFromCache(t,e){return this.os.getEntries(t,e)}}class an{constructor(t){this.persistence=t,this.xs=new rF(t=>rv(t),rw),this.lastRemoteSnapshotVersion=id.min(),this.highestTargetId=0,this.Ns=0,this.ks=new s8,this.targetCount=0,this.Ms=s1.kn()}forEachTarget(t,e){return this.xs.forEach((t,n)=>e(n)),ib.resolve()}getLastRemoteSnapshotVersion(t){return ib.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return ib.resolve(this.Ns)}allocateTargetId(t){return this.highestTargetId=this.Ms.next(),ib.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.Ns&&(this.Ns=e),ib.resolve()}Fn(t){this.xs.set(t.target,t);let e=t.targetId;e>this.highestTargetId&&(this.Ms=new s1(e),this.highestTargetId=e),t.sequenceNumber>this.Ns&&(this.Ns=t.sequenceNumber)}addTargetData(t,e){return this.Fn(e),this.targetCount+=1,ib.resolve()}updateTargetData(t,e){return this.Fn(e),ib.resolve()}removeTargetData(t,e){return this.xs.delete(e.target),this.ks.Is(e.targetId),this.targetCount-=1,ib.resolve()}removeTargets(t,e,n){let i=0,r=[];return this.xs.forEach((s,a)=>{a.sequenceNumber<=e&&null===n.get(a.targetId)&&(this.xs.delete(s),r.push(this.removeMatchingKeysForTargetId(t,a.targetId)),i++)}),ib.waitFor(r).next(()=>i)}getTargetCount(t){return ib.resolve(this.targetCount)}getTargetData(t,e){let n=this.xs.get(e)||null;return ib.resolve(n)}addMatchingKeys(t,e,n){return this.ks.gs(e,n),ib.resolve()}removeMatchingKeys(t,e,n){this.ks.ps(e,n);let i=this.persistence.referenceDelegate,r=[];return i&&e.forEach(e=>{r.push(i.markPotentiallyOrphaned(t,e))}),ib.waitFor(r)}removeMatchingKeysForTargetId(t,e){return this.ks.Is(e),ib.resolve()}getMatchingKeysForTargetId(t,e){let n=this.ks.Es(e);return ib.resolve(n)}containsKey(t,e){return ib.resolve(this.ks.containsKey(e))}}class ai{constructor(t,e){this.$s={},this.overlays={},this.Os=new iC(0),this.Fs=!1,this.Fs=!0,this.referenceDelegate=t(this),this.Bs=new an(this),this.indexManager=new sJ,this.remoteDocumentCache=new at(t=>this.referenceDelegate.Ls(t)),this.serializer=new sY(e),this.qs=new s5(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.Fs=!1,Promise.resolve()}get started(){return this.Fs}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(t){return this.indexManager}getDocumentOverlayCache(t){let e=this.overlays[t.toKey()];return e||(e=new s6,this.overlays[t.toKey()]=e),e}getMutationQueue(t,e){let n=this.$s[t.toKey()];return n||(n=new s9(e,this.referenceDelegate),this.$s[t.toKey()]=n),n}getTargetCache(){return this.Bs}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.qs}runTransaction(t,e,n){n1("MemoryPersistence","Starting transaction:",t);let i=new ar(this.Os.next());return this.referenceDelegate.Us(),n(i).next(t=>this.referenceDelegate.Ks(i).next(()=>t)).toPromise().then(t=>(i.raiseOnCommittedEvent(),t))}Gs(t,e){return ib.or(Object.values(this.$s).map(n=>()=>n.containsKey(t,e)))}}class ar extends iE{constructor(t){super(),this.currentSequenceNumber=t}}class as{constructor(t){this.persistence=t,this.Qs=new s8,this.js=null}static zs(t){return new as(t)}get Ws(){if(this.js)return this.js;throw n5()}addReference(t,e,n){return this.Qs.addReference(n,e),this.Ws.delete(n.toString()),ib.resolve()}removeReference(t,e,n){return this.Qs.removeReference(n,e),this.Ws.add(n.toString()),ib.resolve()}markPotentiallyOrphaned(t,e){return this.Ws.add(e.toString()),ib.resolve()}removeTarget(t,e){this.Qs.Is(e.targetId).forEach(t=>this.Ws.add(t.toString()));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(t,e.targetId).next(t=>{t.forEach(t=>this.Ws.add(t.toString()))}).next(()=>n.removeTargetData(t,e))}Us(){this.js=new Set}Ks(t){let e=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ib.forEach(this.Ws,n=>{let i=iv.fromPath(n);return this.Hs(t,i).next(t=>{t||e.removeEntry(i,id.min())})}).next(()=>(this.js=null,e.apply(t)))}updateLimboDocument(t,e){return this.Hs(t,e).next(t=>{t?this.Ws.delete(e.toString()):this.Ws.add(e.toString())})}Ls(t){return 0}Hs(t,e){return ib.or([()=>ib.resolve(this.Qs.containsKey(e)),()=>this.persistence.getTargetCache().containsKey(t,e),()=>this.persistence.Gs(t,e)])}}class aa{constructor(t,e,n,i){this.targetId=t,this.fromCache=e,this.Fi=n,this.Bi=i}static Li(t,e){let n=rz(),i=rz();for(let t of e.docChanges)switch(t.type){case 0:n=n.add(t.doc.key);break;case 1:i=i.add(t.doc.key)}return new aa(t,e.fromCache,n,i)}}class ao{constructor(){this.qi=!1}initialize(t,e){this.Ui=t,this.indexManager=e,this.qi=!0}getDocumentsMatchingQuery(t,e,n,i){return this.Ki(t,e).next(r=>r||this.Gi(t,e,i,n)).next(n=>n||this.Qi(t,e))}Ki(t,e){if(rI(e))return ib.resolve(null);let n=rN(e);return this.indexManager.getIndexType(t,n).next(i=>0===i?null:(null!==e.limit&&1===i&&(n=rN(e=rD(e,null,"F"))),this.indexManager.getDocumentsMatchingTarget(t,n).next(i=>{let r=rz(...i);return this.Ui.getDocuments(t,r).next(i=>this.indexManager.getMinOffset(t,n).next(n=>{let s=this.ji(e,i);return this.zi(e,s,r,n.readTime)?this.Ki(t,rD(e,null,"F")):this.Wi(t,s,e,n)}))})))}Gi(t,e,n,i){return rI(e)||i.isEqual(id.min())?this.Qi(t,e):this.Ui.getDocuments(t,n).next(r=>{let s,a,o=this.ji(e,r);return this.zi(e,o,n,i)?this.Qi(t,e):(n0()<=h.LogLevel.DEBUG&&n1("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),rL(e)),this.Wi(t,o,e,(s=i.toT
4imestamp().seconds,a=i.toTimestamp().nanoseconds+1,new iw(id.fromTimestamp(1e9===a?new ic(s+1,0):new ic(s,a)),iv.empty(),-1))))})}ji(t,e){let n=new iR(rO(t));return e.forEach((e,i)=>{rM(t,i)&&(n=n.add(i))}),n}zi(t,e,n,i){if(null===t.limit)return!1;if(n.size!==e.size)return!0;let r="F"===t.limitType?e.last():e.first();return!!r&&(r.hasPendingWrites||r.version.compareTo(i)>0)}Qi(t,e){return n0()<=h.LogLevel.DEBUG&&n1("QueryEngine","Using full collection scan to execute query:",rL(e)),this.Ui.getDocumentsMatchingQuery(t,e,iw.min())}Wi(t,e,n,i){return this.Ui.getDocumentsMatchingQuery(t,n,i).next(t=>(e.forEach(e=>{t=t.insert(e.key,e)}),t))}}class al{constructor(t,e,n,i){this.persistence=t,this.Hi=e,this.serializer=i,this.Ji=new ix(iu),this.Yi=new rF(t=>rv(t),rw),this.Xi=new Map,this.Zi=t.getRemoteDocumentCache(),this.Bs=t.getTargetCache(),this.qs=t.getBundleCache(),this.tr(n)}tr(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new s4(this.Zi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Zi.setIndexManager(this.indexManager),this.Hi.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",e=>t.collect(e,this.Ji))}}async function au(t,e){return await t.persistence.runTransaction("Handle user change","readonly",n=>{let i;return t.mutationQueue.getAllMutationBatches(n).next(r=>(i=r,t.tr(e),t.mutationQueue.getAllMutationBatches(n))).next(e=>{let r=[],s=[],a=rz();for(let t of i)for(let e of(r.push(t.batchId),t.mutations))a=a.add(e.key);for(let t of e)for(let e of(s.push(t.batchId),t.mutations))a=a.add(e.key);return t.localDocuments.getDocuments(n,a).next(t=>({er:t,removedBatchIds:r,addedBatchIds:s}))})})}function ah(t){return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.Bs.getLastRemoteSnapshotVersion(e))}async function ac(t,e,n){let i=t.Ji.get(e);try{n||await t.persistence.runTransaction("Release target",n?"readwrite":"readwrite-primary",e=>t.persistence.referenceDelegate.removeTarget(e,i))}catch(t){if(!iI(t))throw t;n1("LocalStore",`Failed to update sequence numbers for target ${e}: ${t}`)}t.Ji=t.Ji.remove(e),t.Yi.delete(i.target)}function ad(t,e,n){let i=id.min(),r=rz();return t.persistence.runTransaction("Execute query","readonly",s=>{var a;let o;return(a=rN(e),void 0!==(o=t.Yi.get(a))?ib.resolve(t.Ji.get(o)):t.Bs.getTargetData(s,a)).next(e=>{if(e)return i=e.lastLimboFreeSnapshotVersion,t.Bs.getMatchingKeysForTargetId(s,e.targetId).next(t=>{r=t})}).next(()=>t.Hi.getDocumentsMatchingQuery(s,e,n?i:id.min(),n?r:rz())).next(n=>{var i,s,a;let o;return i=t,s=e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2)),a=n,o=i.Xi.get(s)||id.min(),a.forEach((t,e)=>{e.readTime.compareTo(o)>0&&(o=e.readTime)}),i.Xi.set(s,o),{documents:n,ir:r}})})}class af{constructor(){this.activeTargetIds=rK}lr(t){this.activeTargetIds=this.activeTargetIds.add(t)}dr(t){this.activeTargetIds=this.activeTargetIds.delete(t)}hr(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class ag{constructor(){this.Hr=new af,this.Jr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t){return this.Hr.lr(t),this.Jr[t]||"not-current"}updateQueryState(t,e,n){this.Jr[t]=e}removeLocalQueryTarget(t){this.Hr.dr(t)}isLocalQueryTarget(t){return this.Hr.activeTargetIds.has(t)}clearQueryState(t){delete this.Jr[t]}getAllActiveQueryTargets(){return this.Hr.activeTargetIds}isActiveQueryTarget(t){return this.Hr.activeTargetIds.has(t)}start(){return this.Hr=new af,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}class ap{Yr(t){}shutdown(){}}class am{constructor(){this.Xr=()=>this.Zr(),this.eo=()=>this.no(),this.so=[],this.io()}Yr(t){this.so.push(t)}shutdown(){window.removeEventListener("online",this.Xr),window.removeEventListener("offline",this.eo)}io(){window.addEventListener("online",this.Xr),window.addEventListener("offline",this.eo)}Zr(){for(let t of(n1("ConnectivityMonitor","Network connectivity changed: AVAILABLE"),this.so))t(0)}no(){for(let t of(n1("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE"),this.so))t(1)}static D(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let ay=null;function av(){return null===ay?ay=0x10000000+Math.round(0x80000000*Math.random()):ay++,"0x"+ay.toString(16)}let aw={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
4Query:"runAggregationQuery"};class aE{constructor(t){this.ro=t.ro,this.oo=t.oo}uo(t){this.co=t}ao(t){this.ho=t}onMessage(t){this.lo=t}close(){this.oo()}send(t){this.ro(t)}fo(){this.co()}wo(t){this.ho(t)}_o(t){this.lo(t)}}let aT="WebChannelConnection";class ab extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.mo=e+"://"+t.host,this.yo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get po(){return!1}Io(t,e,n,i,r){let s=av(),a=this.To(t,e);n1("RestConnection",`Sending RPC '${t}' ${s}:`,a,n);let o={};return this.Eo(o,i,r),this.Ao(t,a,o,n).then(e=>(n1("RestConnection",`Received RPC '${t}' ${s}: `,e),e),e=>{throw n3("RestConnection",`RPC '${t}' ${s} failed with error: `,e,"url: ",a,"request:",n),e})}vo(t,e,n,i,r,s){return this.Io(t,e,n,i,r)}Eo(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+nJ,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach((e,n)=>t[n]=e),n&&n.headers.forEach((e,n)=>t[n]=e)}To(t,e){let n=aw[t];return`${this.mo}/v1/${e}:${n}`}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams,this.longPollingOptions=t.longPollingOptions}Ao(t,e,n,i){let r=av();return new Promise((s,a)=>{let o=new nQ;o.setWithCredentials(!0),o.listenOnce(nj.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case nB.NO_ERROR:let e=o.getResponseJson();n1(aT,`XHR for RPC '${t}' ${r} received:`,JSON.stringify(e)),s(e);break;case nB.TIMEOUT:n1(aT,`RPC '${t}' ${r} timed out`),a(new n8(n6.DEADLINE_EXCEEDED,"Request time out"));break;case nB.HTTP_ERROR:let n=o.getStatus();if(n1(aT,`RPC '${t}' ${r} failed with status:`,n,"response text:",o.getResponseText()),n>0){let t=o.getResponseJson();Array.isArray(t)&&(t=t[0]);let e=null==t?void 0:t.error;if(e&&e.status&&e.message){let t,n=(t=e.status.toLowerCase().replace(/_/g,"-"),Object.values(n6).indexOf(t)>=0?t:n6.UNKNOWN);a(new n8(n,e.message))}else a(new n8(n6.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new n8(n6.UNAVAILABLE,"Connection failed."));break;default:n5()}}finally{n1(aT,`RPC '${t}' ${r} completed.`)}});let l=JSON.stringify(i);n1(aT,`RPC '${t}' ${r} sending request:`,i),o.send(e,"POST",l,n,15)})}Ro(t,e,n){let i=av(),r=[this.mo,"/","google.firestore.v1.Firestore","/",t,"/channel"],a=nU(),o=nq(),l={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},u=this.longPollingOptions.timeoutSeconds;void 0!==u&&(l.longPollingTimeout=Math.round(1e3*u)),this.useFetchStreams&&(l.xmlHttpFactory=new nK({})),this.Eo(l.initMessageHeaders,e,n),l.encodeInitMessageHeaders=!0;let h=r.join("");n1(aT,`Creating RPC '${t}' stream ${i}: ${h}`,l);let c=a.createWebChannel(h,l),d=!1,f=!1,g=new aE({ro:e=>{f?n1(aT,`Not sending because RPC '${t}' stream ${i} is closed:`,e):(d||(n1(aT,`Opening RPC '${t}' stream ${i} transport.`),c.open(),d=!0),n1(aT,`RPC '${t}' stream ${i} sending:`,e),c.send(e))},oo:()=>c.close()}),p=(t,e,n)=>{t.listen(e,t=>{try{n(t)}catch(t){setTimeout(()=>{throw t},0)}})};return p(c,nG.EventType.OPEN,()=>{f||n1(aT,`RPC '${t}' stream ${i} transport opened.`)}),p(c,nG.EventType.CLOSE,()=>{f||(f=!0,n1(aT,`RPC '${t}' stream ${i} transport closed`),g.wo())}),p(c,nG.EventType.ERROR,e=>{f||(f=!0,n3(aT,`RPC '${t}' stream ${i} transport errored:`,e),g.wo(new n8(n6.UNAVAILABLE,"The operation could not be completed")))}),p(c,nG.EventType.MESSAGE,e=>{var n;if(!f){let r=e.data[0];r||n5();let a=r.error||(null==(n=r[0])?void 0:n.error);if(a){n1(aT,`RPC '${t}' stream ${i} received error:`,a);let e=a.status,n=function(t){let e=s[t];if(void 0!==e)return sf(e)}(e),r=a.message;void 0===n&&(n=n6.INTERNAL,r="Unknown error status: "+e+" with message "+a.message),f=!0,g.wo(new n8(n,r)),c.close()}else n1(aT,`RPC '${t}' stream ${i} received:`,r),g._o(r)}
4}),p(o,n$.STAT_EVENT,e=>{e.stat===nz.PROXY?n1(aT,`RPC '${t}' stream ${i} detected buffering proxy`):e.stat===nz.NOPROXY&&n1(aT,`RPC '${t}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{g.fo()},0),g}}function aI(){return"undefined"!=typeof document?document:null}function aC(t){return new sL(t,!0)}class aS{constructor(t,e,n=1e3,i=1.5,r=6e4){this.ii=t,this.timerId=e,this.Po=n,this.bo=i,this.Vo=r,this.So=0,this.Do=null,this.Co=Date.now(),this.reset()}reset(){this.So=0}xo(){this.So=this.Vo}No(t){this.cancel();let e=Math.floor(this.So+this.ko()),n=Math.max(0,Date.now()-this.Co),i=Math.max(0,e-n);i>0&&n1("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.So} ms, delay with jitter: ${e} ms, last attempt: ${n} ms ago)`),this.Do=this.ii.enqueueAfterDelay(this.timerId,i,()=>(this.Co=Date.now(),t())),this.So*=this.bo,this.So<this.Po&&(this.So=this.Po),this.So>this.Vo&&(this.So=this.Vo)}Mo(){null!==this.Do&&(this.Do.skipDelay(),this.Do=null)}cancel(){null!==this.Do&&(this.Do.cancel(),this.Do=null)}ko(){return(Math.random()-.5)*this.So}}class aA{constructor(t,e,n,i,r,s,a,o){this.ii=t,this.$o=n,this.Oo=i,this.connection=r,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.Fo=0,this.Bo=null,this.Lo=null,this.stream=null,this.qo=new aS(t,e)}Uo(){return 1===this.state||5===this.state||this.Ko()}Ko(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.Go()}async stop(){this.Uo()&&await this.close(0)}Qo(){this.state=0,this.qo.reset()}jo(){this.Ko()&&null===this.Bo&&(this.Bo=this.ii.enqueueAfterDelay(this.$o,6e4,()=>this.zo()))}Wo(t){this.Ho(),this.stream.send(t)}async zo(){if(this.Ko())return this.close(0)}Ho(){this.Bo&&(this.Bo.cancel(),this.Bo=null)}Jo(){this.Lo&&(this.Lo.cancel(),this.Lo=null)}async close(t,e){this.Ho(),this.Jo(),this.qo.cancel(),this.Fo++,4!==t?this.qo.reset():e&&e.code===n6.RESOURCE_EXHAUSTED?(n2(e.toString()),n2("Using maximum backoff delay to prevent overloading the backend."),this.qo.xo()):e&&e.code===n6.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Yo(),this.stream.close(),this.stream=null),this.state=t,await this.listener.ao(e)}Yo(){}auth(){this.state=1;let t=this.Xo(this.Fo),e=this.Fo;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([t,n])=>{this.Fo===e&&this.Zo(t,n)},e=>{t(()=>{let t=new n8(n6.UNKNOWN,"Fetching auth token failed: "+e.message);return this.tu(t)})})}Zo(t,e){let n=this.Xo(this.Fo);this.stream=this.eu(t,e),this.stream.uo(()=>{n(()=>(this.state=2,this.Lo=this.ii.enqueueAfterDelay(this.Oo,1e4,()=>(this.Ko()&&(this.state=3),Promise.resolve())),this.listener.uo()))}),this.stream.ao(t=>{n(()=>this.tu(t))}),this.stream.onMessage(t=>{n(()=>this.onMessage(t))})}Go(){this.state=5,this.qo.No(async()=>{this.state=0,this.start()})}tu(t){return n1("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}Xo(t){return e=>{this.ii.enqueueAndForget(()=>this.Fo===t?e():(n1("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class a_ extends aA{constructor(t,e,n,i,r,s){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,i,s),this.serializer=r}eu(t,e){return this.connection.Ro("Listen",t,e)}onMessage(t){this.qo.reset();let e=function(t,e){let n;if("targetChange"in e){var i,r;e.targetChange;let s="NO_CHANGE"===(i=e.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===i?1:"REMOVE"===i?2:"CURRENT"===i?3:"RESET"===i?4:n5(),a=e.targetChange.targetIds||[],o=(r=e.targetChange.resumeToken,t.useProto3Json?(void 0===r||"string"==typeof r||n5(),iF.fromBase64String(r||"")):(void 0===r||r instanceof Uint8Array||n5(),iF.fromUint8Array(r||new Uint8Array))),l=e.targetChange.cause;n=new sS(s,a,o,l&&new n8(void 0===l.code?n6.UNKNOWN:sf(l.code),l.message||"")||null)}else if("documentChange"in e){e.documentChange;let i=e.documentChange;i.document,i.document.name,i.document.updateTime;let r=sB(t,i.document.name),s=sP(i.document.updateTime),a=i.document.createTime?sP(i.document.createTime):id.min(),o=new i8({mapValue:{fields:i.document.fields}}),l=i7.newFoundDocument(r,s,a,o);n=new sI(i.targetIds||[],i.removedTargetIds||[],l.key,l)}else if("documentDelete"in e){e.documentDelete;let i=e.documentDelete;i.document;let r=sB(t,i.document),s=i.readTime?sP(i.readTime):id.min(),a=i7.newNoDocument(r,s);n=new sI([],i.removedTargetIds||[],a.key,a)}else if("documentRemove"in e){e.documentRemove;let i=e.documentRemove;i.document;let r=sB(t,i.document);n=new sI([],i.removedTargetIds||[],r,null)}else{if(!("filter"in e))return n5();{e.filter;let t=e.filter;t.targetId;
4let{count:i=0,unchangedNames:r}=t,s=new sd(i,r);n=new sC(t.targetId,s)}}return n}(this.serializer,t),n=function(t){if(!("targetChange"in t))return id.min();let e=t.targetChange;return e.targetIds&&e.targetIds.length?id.min():e.readTime?sP(e.readTime):id.min()}(t);return this.listener.nu(e,n)}su(t){let e,n={};n.database=s$(this.serializer),n.addTarget=function(t,e){var n,i;let r,s,a,o,l,u,h=e.target;if((r=rE(h)?{documents:{documents:[sj(t,h.path)]}}:{query:(s={structuredQuery:{}},a=h.path,null!==h.collectionGroup?(s.parent=sj(t,a),s.structuredQuery.from=[{collectionId:h.collectionGroup,allDescendants:!0}]):(s.parent=sj(t,a.popLast()),s.structuredQuery.from=[{collectionId:a.lastSegment()}]),(o=function(t){if(0!==t.length)return function t(e){var n;let i;return e instanceof rr?function(t){if("=="===t.op){if(i3(t.value))return{unaryFilter:{field:sG(t.field),op:"IS_NAN"}};if(i2(t.value))return{unaryFilter:{field:sG(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(i3(t.value))return{unaryFilter:{field:sG(t.field),op:"IS_NOT_NAN"}};if(i2(t.value))return{unaryFilter:{field:sG(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:sG(t.field),op:sk[t.op],value:t.value}}}(e):e instanceof rs?1===(i=(n=e).getFilters().map(e=>t(e))).length?i[0]:{compositeFilter:{op:sR[n.op],filters:i}}:n5()}(rs.create(t,"and"))}(h.filters))&&(s.structuredQuery.where=o),(l=function(t){if(0!==t.length)return t.map(t=>({field:sG(t.field),direction:sD[t.dir]}))}(h.orderBy))&&(s.structuredQuery.orderBy=l),null!==(u=sM(t,h.limit))&&(s.structuredQuery.limit=u),h.startAt&&(s.structuredQuery.startAt={before:(n=h.startAt).inclusive,values:n.position}),h.endAt&&(s.structuredQuery.endAt={before:!(i=h.endAt).inclusive,values:i.position}),s)}).targetId=e.targetId,e.resumeToken.approximateByteSize()>0){r.resumeToken=sF(t,e.resumeToken);let n=sM(t,e.expectedCount);null!==n&&(r.expectedCount=n)}else if(e.snapshotVersion.compareTo(id.min())>0){r.readTime=sO(t,e.snapshotVersion.toTimestamp());let n=sM(t,e.expectedCount);null!==n&&(r.expectedCount=n)}return r}(this.serializer,t);let i=(this.serializer,null==(e=function(t){switch(t){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return n5()}}(t.purpose))?null:{"goog-listen-tags":e});i&&(n.labels=i),this.Wo(n)}iu(t){let e={};e.database=s$(this.serializer),e.removeTarget=t,this.Wo(e)}}class aN extends aA{constructor(t,e,n,i,r,s){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,i,s),this.serializer=r,this.ru=!1}get ou(){return this.ru}start(){this.ru=!1,this.lastStreamToken=void 0,super.start()}Yo(){this.ru&&this.uu([])}eu(t,e){return this.connection.Ro("Write",t,e)}onMessage(t){var e,n;if(t.streamToken||n5(),this.lastStreamToken=t.streamToken,this.ru){this.qo.reset();let i=(e=t.writeResults,n=t.commitTime,e&&e.length>0?(void 0!==n||n5(),e.map(t=>{let e;return(e=t.updateTime?sP(t.updateTime):sP(n)).isEqual(id.min())&&(e=sP(n)),new r5(e,t.transformResults||[])})):[]),r=sP(t.commitTime);return this.listener.cu(r,i)}return t.writeResults&&0!==t.writeResults.length&&n5(),this.ru=!0,this.listener.au()}hu(){let t={};t.database=s$(this.serializer),this.Wo(t)}uu(t){let e={streamToken:this.lastStreamToken,writes:t.map(t=>(function(t,e){var n,i;let r;if(e instanceof sn)r={update:sK(t,e.key,e.value)};else if(e instanceof so)r={delete:sq(t,e.key)};else if(e instanceof si){let n;r={update:sK(t,e.key,e.data),updateMask:(i=e.fieldMask,n=[],i.fields.forEach(t=>n.push(t.canonicalString())),{fieldPaths:n})}}else{if(!(e instanceof sl))return n5();r={verify:sq(t,e.key)}}return e.fieldTransforms.length>0&&(r.updateTransforms=e.fieldTransforms.map(t=>(function(t,e){let n=e.transform;if(n instanceof rY)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof rX)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof rZ)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof r1)return{fieldPath:e.field.canonicalString(),increment:n.gt};throw n5()})(0,t))),e.precondition.isNone||(r.currentDocument=void 0!==(n=e.precondition).updateTime?{updateTime:sO(t,n.updateTime.toTimestamp())}:void 0!==n.exists?{exists:n.exists}:n5()),r})(this.serializer,t))};this.Wo(e)}}class ax extends class{}{constructor(t,e,n,i){super(),this.authCredentials=t,this.appCheckCredentials=e,this.connection=n,this.serializer
4=i,this.lu=!1}fu(){if(this.lu)throw new n8(n6.FAILED_PRECONDITION,"The client has already been terminated.")}Io(t,e,n){return this.fu(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,r])=>this.connection.Io(t,e,n,i,r)).catch(t=>{throw"FirebaseError"===t.name?(t.code===n6.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new n8(n6.UNKNOWN,t.toString())})}vo(t,e,n,i){return this.fu(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([r,s])=>this.connection.vo(t,e,n,r,s,i)).catch(t=>{throw"FirebaseError"===t.name?(t.code===n6.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),t):new n8(n6.UNKNOWN,t.toString())})}terminate(){this.lu=!0}}class aD{constructor(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.wu=0,this._u=null,this.mu=!0}gu(){0===this.wu&&(this.yu("Unknown"),this._u=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._u=null,this.pu("Backend didn't respond within 10 seconds."),this.yu("Offline"),Promise.resolve())))}Iu(t){"Online"===this.state?this.yu("Unknown"):(this.wu++,this.wu>=1&&(this.Tu(),this.pu(`Connection failed 1 times. Most recent error: ${t.toString()}`),this.yu("Offline")))}set(t){this.Tu(),this.wu=0,"Online"===t&&(this.mu=!1),this.yu(t)}yu(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))}pu(t){let e=`Could not reach Cloud Firestore backend. ${t} 5This 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.mu?(n2(e),this.mu=!1):n1("OnlineStateTracker",e)}Tu(){null!==this._u&&(this._u.cancel(),this._u=null)}}class ak{constructor(t,e,n,i,r){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.Eu=[],this.Au=new Map,this.vu=new Set,this.Ru=[],this.Pu=r,this.Pu.Yr(t=>{n.enqueueAndForget(async()=>{aq(this)&&(n1("RemoteStore","Restarting streams for network reachability change."),await async function(t){t.vu.add(4),await aL(t),t.bu.set("Unknown"),t.vu.delete(4),await aR(t)}(this))})}),this.bu=new aD(n,i)}}async function aR(t){if(aq(t))for(let e of t.Ru)await e(!0)}async function aL(t){for(let e of t.Ru)await e(!1)}function aM(t,e){t.Au.has(e.targetId)||(t.Au.set(e.targetId,e),aU(t)?aV(t):a1(t).Ko()&&aF(t,e))}function aO(t,e){let n=a1(t);t.Au.delete(e),n.Ko()&&aP(t,e),0===t.Au.size&&(n.Ko()?n.jo():aq(t)&&t.bu.set("Unknown"))}function aF(t,e){if(t.Vu.qt(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(id.min())>0){let n=t.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(n)}a1(t).su(e)}function aP(t,e){t.Vu.qt(e),a1(t).iu(e)}function aV(t){t.Vu=new s_({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),le:e=>t.Au.get(e)||null,ue:()=>t.datastore.serializer.databaseId}),a1(t).start(),t.bu.gu()}function aU(t){return aq(t)&&!a1(t).Uo()&&t.Au.size>0}function aq(t){return 0===t.vu.size}async function aB(t){t.Au.forEach((e,n)=>{aF(t,e)})}async function aj(t,e){t.Vu=void 0,aU(t)?(t.bu.Iu(e),aV(t)):t.bu.set("Unknown")}async function a$(t,e,n){if(t.bu.set("Online"),e instanceof sS&&2===e.state&&e.cause)try{await async function(t,e){let n=e.cause;for(let i of e.targetIds)t.Au.has(i)&&(await t.remoteSyncer.rejectListen(i,n),t.Au.delete(i),t.Vu.removeTarget(i))}(t,e)}catch(n){n1("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await az(t,n)}else if(e instanceof sI?t.Vu.Ht(e):e instanceof sC?t.Vu.ne(e):t.Vu.Xt(e),!n.isEqual(id.min()))try{let e,i=await ah(t.localStore);n.compareTo(i)>
5=0&&await ((e=t.Vu.ce(n)).targetChanges.forEach((e,i)=>{if(e.resumeToken.approximateByteSize()>0){let r=t.Au.get(i);r&&t.Au.set(i,r.withResumeToken(e.resumeToken,n))}}),e.targetMismatches.forEach((e,n)=>{let i=t.Au.get(e);if(!i)return;t.Au.set(e,i.withResumeToken(iF.EMPTY_BYTE_STRING,i.snapshotVersion)),aP(t,e);let r=new sW(i.target,e,n,i.sequenceNumber);aF(t,r)}),t.remoteSyncer.applyRemoteEvent(e))}catch(e){n1("RemoteStore","Failed to raise snapshot:",e),await az(t,e)}}async function az(t,e,n){if(!iI(e))throw e;t.vu.add(1),await aL(t),t.bu.set("Offline"),n||(n=()=>ah(t.localStore)),t.asyncQueue.enqueueRetryable(async()=>{n1("RemoteStore","Retrying IndexedDB access"),await n(),t.vu.delete(1),await aR(t)})}function aK(t,e){return e().catch(n=>az(t,n,e))}async function aG(t){var e;let n=a2(t),i=t.Eu.length>0?t.Eu[t.Eu.length-1].batchId:-1;for(;aq(e=t)&&e.Eu.length<10;)try{let e=await function(t,e){return t.persistence.runTransaction("Get next mutation batch","readonly",n=>(void 0===e&&(e=-1),t.mutationQueue.getNextMutationBatchAfterBatchId(n,e)))}(t.localStore,i);if(null===e){0===t.Eu.length&&n.jo();break}i=e.batchId,function(t,e){t.Eu.push(e);let n=a2(t);n.Ko()&&n.ou&&n.uu(e.mutations)}(t,e)}catch(e){await az(t,e)}aQ(t)&&aH(t)}function aQ(t){return aq(t)&&!a2(t).Uo()&&t.Eu.length>0}function aH(t){a2(t).start()}async function aW(t){a2(t).hu()}async function aY(t){let e=a2(t);for(let n of t.Eu)e.uu(n.mutations)}async function aX(t,e,n){let i=t.Eu.shift(),r=sh.from(i,e,n);await aK(t,()=>t.remoteSyncer.applySuccessfulWrite(r)),await aG(t)}async function aJ(t,e){e&&a2(t).ou&&await async function(t,e){var n;if(function(t){switch(t){default:return n5();case n6.CANCELLED:case n6.UNKNOWN:case n6.DEADLINE_EXCEEDED:case n6.RESOURCE_EXHAUSTED:case n6.INTERNAL:case n6.UNAVAILABLE:case n6.UNAUTHENTICATED:return!1;case n6.INVALID_ARGUMENT:case n6.NOT_FOUND:case n6.ALREADY_EXISTS:case n6.PERMISSION_DENIED:case n6.FAILED_PRECONDITION:case n6.ABORTED:case n6.OUT_OF_RANGE:case n6.UNIMPLEMENTED:case n6.DATA_LOSS:return!0}}(n=e.code)&&n!==n6.ABORTED){let n=t.Eu.shift();a2(t).Qo(),await aK(t,()=>t.remoteSyncer.rejectFailedWrite(n.batchId,e)),await aG(t)}}(t,e),aQ(t)&&aH(t)}async function aZ(t,e){t.asyncQueue.verifyOperationInProgress(),n1("RemoteStore","RemoteStore received new credentials");let n=aq(t);t.vu.add(3),await aL(t),n&&t.bu.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.vu.delete(3),await aR(t)}async function a0(t,e){e?(t.vu.delete(2),await aR(t)):e||(t.vu.add(2),await aL(t),t.bu.set("Unknown"))}function a1(t){var e,n,i;return t.Su||(e=t.datastore,n=t.asyncQueue,i={uo:aB.bind(null,t),ao:aj.bind(null,t),nu:a$.bind(null,t)},e.fu(),t.Su=new a_(n,e.connection,e.authCredentials,e.appCheckCredentials,e.serializer,i),t.Ru.push(async e=>{e?(t.Su.Qo(),aU(t)?aV(t):t.bu.set("Unknown")):(await t.Su.stop(),t.Vu=void 0)})),t.Su}function a2(t){var e,n,i;return t.Du||(e=t.datastore,n=t.asyncQueue,i={uo:aW.bind(null,t),ao:aJ.bind(null,t),au:aY.bind(null,t),cu:aX.bind(null,t)},e.fu(),t.Du=new aN(n,e.connection,e.authCredentials,e.appCheckCredentials,e.serializer,i),t.Ru.push(async e=>{e?(t.Du.Qo(),await aG(t)):(await t.Du.stop(),t.Eu.length>0&&(n1("RemoteStore",`Stopping write stream with ${t.Eu.length} pending writes`),t.Eu=[]))})),t.Du}class a3{constructor(t,e,n,i,r){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=i,this.removalCallback=r,this.deferred=new n7,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(t=>{})}static createAndSchedule(t,e,n,i,r){let s=new a3(t,e,Date.now()+n,i,r);return s.start(n),s}start(t){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),t)}skipDelay(){return this.handleDelayElapsed()}cancel(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new n8(n6.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
5)}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(t=>this.deferred.resolve(t))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function a4(t,e){if(n2("AsyncQueue",`${e}: ${t}`),iI(t))return new n8(n6.UNAVAILABLE,`${e}: ${t}`);throw t}class a5{constructor(t){this.comparator=t?(e,n)=>t(e,n)||iv.comparator(e.key,n.key):(t,e)=>iv.comparator(t.key,e.key),this.keyedMap=rU(),this.sortedSet=new ix(this.comparator)}static emptySet(t){return new a5(t.comparator)}has(t){return null!=this.keyedMap.get(t)}get(t){return this.keyedMap.get(t)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(t){let e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1}get size(){return this.sortedSet.size}forEach(t){this.sortedSet.inorderTraversal((e,n)=>(t(e),!1))}add(t){let e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))}delete(t){let e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this}isEqual(t){if(!(t instanceof a5)||this.size!==t.size)return!1;let e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();for(;e.hasNext();){let t=e.getNext().key,i=n.getNext().key;if(!t.isEqual(i))return!1}return!0}toString(){let t=[];return this.forEach(e=>{t.push(e.toString())}),0===t.length?"DocumentSet ()":"DocumentSet (\n "+t.join(" \n")+"\n)"}copy(t,e){let n=new a5;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n}}class a6{constructor(){this.Cu=new ix(iv.comparator)}track(t){let e=t.doc.key,n=this.Cu.get(e);n?0!==t.type&&3===n.type?this.Cu=this.Cu.insert(e,t):3===t.type&&1!==n.type?this.Cu=this.Cu.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.Cu=this.Cu.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.Cu=this.Cu.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.Cu=this.Cu.remove(e):1===t.type&&2===n.type?this.Cu=this.Cu.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.Cu=this.Cu.insert(e,{type:2,doc:t.doc}):n5():this.Cu=this.Cu.insert(e,t)}xu(){let t=[];return this.Cu.inorderTraversal((e,n)=>{t.push(n)}),t}}class a8{constructor(t,e,n,i,r,s,a,o,l){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=i,this.mutatedKeys=r,this.fromCache=s,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(t,e,n,i,r){let s=[];return e.forEach(t=>{s.push({type:0,doc:t})}),new a8(t,e,a5.emptySet(e),s,n,i,!0,!1,r)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(t){if(!(this.fromCache===t.fromCache&&this.hasCachedResults===t.hasCachedResults&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&rk(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;let e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].type!==n[t].type||!e[t].doc.isEqual(n[t].doc))return!1;return!0}}class a7{constructor(){this.Nu=void 0,this.listeners=[]}}class a9{constructor(){this.queries=new rF(t=>rR(t),rk),this.onlineState="Unknown",this.ku=new Set}}async function ot(t,e){let n=e.query,i=!1,r=t.queries.get(n);if(r||(i=!0,r=new a7),i)try{r.Nu=await t.onListen(n)}catch(n){let t=a4(n,`Initialization of query '${rL(e.query)}' failed`);return void e.onError(t)}t.queries.set(n,r),r.listeners.push(e),e.Mu(t.onlineState),r.Nu&&e.$u(r.Nu)&&or(t)}async function oe(t,e){let n=e.query,i=!1,r=t.queries.get(n);if(r){let t=r.listeners.indexOf(e);t>=0&&(r.listeners.splice(t,1),i=0===r.listeners.length)}if(i)return t.queries.delete(n),t.onUnlisten(n)}function on(t,e){let n=!1;for(let i of e){let e=i.query,r=t.queries.get(e);if(r){for(let t of r.listeners)t.$u(i)&&(n=!0);r.Nu=i}}n&&or(t)}function oi(t,e,n){let i=t.queries.get(e);if(i)for(let t of i.listeners)t.onError(n);t.queries.delete(e)}function or(t){t.ku.forEach(t=>{t.next()})}class os{constructor(t,e,n){this.query=t,this.Ou=e,this.Fu=!1,this.Bu=null,this.onlineState="Unknown",this.options=n||{}}$u(t){if(!this.options.includeMetadataChanges){let e=[];for(let n of t.docChanges)3!==n.type&&e.push(n);t=new a8(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.Fu?this.Lu(t)&&(this.Ou.next(t),e=!0):this.qu(t,this.onlineState)&&(this.Uu(t),e=!0),this.Bu=t,e}onError(t){this.Ou.error(t)}Mu(t){this.onlineState=t;let e=!1;return this.Bu&&!this.Fu&&this.qu(this.Bu,t)&&(this.Uu(this.Bu),e=!0),e}qu(t,e){return!t.fromCache||(!this.options.Ku||"Offline"===e)&&(!t.docs.isEmpty()||t.hasCachedResults||"Offline"===e)}Lu(t){if(t.docChanges.length>0)return!0;let e=this.Bu&&this.Bu.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges}Uu(t){t=a8.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.Fu=!0,this.Ou.next(t)}}class oa{constructor(t){this.key=t}}class oo{constructor(t){this.key=t}}class ol{constructor(t,e){this.query=t,this.Yu=e,this.Xu=null,this.hasCachedResults=!1,this.current=!1,this.Zu=rz(),this.mutatedKeys=rz(),this.tc=rO(t),this.ec=new a5(this.tc)}get nc(){return this.Yu}sc(t,e){let n=e?e.ic:new a6,i=e?e.ec:this.ec,r=e?e.mutatedKeys:this.mutatedKeys,s=i,a=!1,o="F"===this.query.limitType&&i.size===this.query.limit?i.last(
5):null,l="L"===this.query.limitType&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal((t,e)=>{let u=i.get(t),h=rM(this.query,e)?e: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.rc(u,h)||(n.track({type:2,doc:h}),f=!0,(o&&this.tc(h,o)>0||l&&0>this.tc(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),r=d?r.add(t):r.delete(t)):(s=s.delete(t),r=r.delete(t)))}),null!==this.query.limit)for(;s.size>this.query.limit;){let t="F"===this.query.limitType?s.last():s.first();s=s.delete(t.key),r=r.delete(t.key),n.track({type:1,doc:t})}return{ec:s,ic:n,zi:a,mutatedKeys:r}}rc(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations}applyChanges(t,e,n){let i=this.ec;this.ec=t.ec,this.mutatedKeys=t.mutatedKeys;let r=t.ic.xu();r.sort((t,e)=>{var n,i;let r;return n=t.type,i=e.type,(r=t=>{switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return n5()}})(n)-r(i)||this.tc(t.doc,e.doc)}),this.oc(n);let s=e?this.uc():[],a=0===this.Zu.size&&this.current?1:0,o=a!==this.Xu;return(this.Xu=a,0!==r.length||o)?{snapshot:new a8(this.query,t.ec,i,r,t.mutatedKeys,0===a,o,!1,!!n&&n.resumeToken.approximateByteSize()>0),cc:s}:{cc:s}}Mu(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({ec:this.ec,ic:new a6,mutatedKeys:this.mutatedKeys,zi:!1},!1)):{cc:[]}}ac(t){return!this.Yu.has(t)&&!!this.ec.has(t)&&!this.ec.get(t).hasLocalMutations}oc(t){t&&(t.addedDocuments.forEach(t=>this.Yu=this.Yu.add(t)),t.modifiedDocuments.forEach(t=>{}),t.removedDocuments.forEach(t=>this.Yu=this.Yu.delete(t)),this.current=t.current)}uc(){if(!this.current)return[];let t=this.Zu;this.Zu=rz(),this.ec.forEach(t=>{this.ac(t.key)&&(this.Zu=this.Zu.add(t.key))});let e=[];return t.forEach(t=>{this.Zu.has(t)||e.push(new oo(t))}),this.Zu.forEach(n=>{t.has(n)||e.push(new oa(n))}),e}hc(t){this.Yu=t.ir,this.Zu=rz();let e=this.sc(t.documents);return this.applyChanges(e,!0)}lc(){return a8.fromInitialDocuments(this.query,this.ec,this.mutatedKeys,0===this.Xu,this.hasCachedResults)}}class ou{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class oh{constructor(t){this.key=t,this.fc=!1}}class oc{constructor(t,e,n,i,r,s){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=i,this.currentUser=r,this.maxConcurrentLimboResolutions=s,this.dc={},this.wc=new rF(t=>rR(t),rk),this._c=new Map,this.mc=new Set,this.gc=new ix(iv.comparator),this.yc=new Map,this.Ic=new s8,this.Tc={},this.Ec=new Map,this.Ac=s1.Mn(),this.onlineState="Unknown",this.vc=void 0}get isPrimaryClient(){return!0===this.vc}}async function od(t,e){var n,i,r;let s,a,o=((n=t).remoteStore.remoteSyncer.applyRemoteEvent=om.bind(null,n),n.remoteStore.remoteSyncer.getRemoteKeysForTarget=ox.bind(null,n),n.remoteStore.remoteSyncer.rejectListen=ov.bind(null,n),n.dc.nu=on.bind(null,n.eventManager),n.dc.Pc=oi.bind(null,n.eventManager),n),l=o.wc.get(e);if(l)s=l.targetId,o.sharedClientState.addLocalQueryTarget(s),a=l.view.lc();else{let t=await (i=o.localStore,r=rN(e),i.persistence.runTransaction("Allocate target","readwrite",t=>{let e;return i.Bs.getTargetData(t,r).next(n=>n?(e=n,ib.resolve(e)):i.Bs.allocateTargetId(t).next(n=>(e=new sW(r,n,"TargetPurposeListen",t.currentSequenceNumber),i.Bs.addTargetData(t,e).next(()=>e))))}).then(t=>{let e=i.Ji.get(t.targetId);return(null===e||t.snapshotVersion.compareTo(e.snapshotVersion)>0)&&(i.Ji=i.Ji.insert(t.targetId,t),i.Yi.set(r,t.targetId)),t})),n=o.sharedClientState.addLocalQueryTarget(t.targetId);s=t.targetId,a=await of(o,e,s,"current"===n,t.resumeToken),o.isPrimaryClient&&aM(o.remoteStore,t)}return a}async function of(t,e,n,i,r){t.Rc=(e,n,i)=>(async function(t,e,n,i){let r=e.view.sc(n);r.zi&&(r=await ad(t.localStore,e.query,!1).then(({documents:t})=>e.view.sc(t,r)));let s=i&&i.targetChanges.get(e.targetId),a=e.view.applyChanges(r,t.isPrimaryClient,s);return oS(t,e.targetId,a.cc),a.snapshot})(t,e,n,i);let s=await ad(t.localStore,e,!0),a=new ol(e,s.ir),o=a.sc(s.documents),l=sb.createSynthesizedTargetChangeForCurrentChange(n,i&&"Offline"!==t.onlineState,r),u=a.applyChanges(o,t.isPrimaryClient,l);oS(t,n,u.cc);let h=new ou(e,n,a);return t.wc.set(e,h),t._c.has(n)?t._c.get(n).push(e):t._c.set(n,[e]),u.snapshot}async function og(t,e){let n=t.wc.get(e),i=t._c.get(n.targetId);i.length>1?(t._c.set(n.targetId,i.filter(t=>
5!rk(t,e))),t.wc.delete(e)):t.isPrimaryClient?(t.sharedClientState.removeLocalQueryTarget(n.targetId),t.sharedClientState.isActiveQueryTarget(n.targetId)||await ac(t.localStore,n.targetId,!1).then(()=>{t.sharedClientState.clearQueryState(n.targetId),aO(t.remoteStore,n.targetId),oI(t,n.targetId)}).catch(iT)):(oI(t,n.targetId),await ac(t.localStore,n.targetId,!0))}async function op(t,e,n){var i,r,s;let a=((i=t).remoteStore.remoteSyncer.applySuccessfulWrite=ow.bind(null,i),i.remoteStore.remoteSyncer.rejectFailedWrite=oE.bind(null,i),i);try{let t,i,o,l,u,h=await (r=a.localStore,o=ic.now(),l=e.reduce((t,e)=>t.add(e.key),rz()),r.persistence.runTransaction("Locally write mutations","readwrite",n=>{let s=rP,a=rz();return r.Zi.getEntries(n,l).next(t=>{(s=t).forEach((t,e)=>{e.isValidDocument()||(a=a.add(t))})}).next(()=>r.localDocuments.getOverlayedDocuments(n,s)).next(i=>{t=i;let s=[];for(let n of e){let e=function(t,e){let n=null;for(let i of t.fieldTransforms){let t=e.data.field(i.field),r=rW(i.transform,t||null);null!=r&&(null===n&&(n=i8.empty()),n.set(i.field,r))}return n||null}(n,t.get(n.key).overlayedDocument);null!=e&&s.push(new si(n.key,e,function t(e){let n=[];return i_(e.fields,(e,i)=>{let r=new iy([e]);if(i4(i)){let e=t(i.mapValue).fields;if(0===e.length)n.push(r);else for(let t of e)n.push(r.child(t))}else n.push(r)}),new iM(n)}(e.value.mapValue),r6.exists(!0)))}return r.mutationQueue.addMutationBatch(n,o,s,e)}).next(e=>{i=e;let s=e.applyToLocalDocumentSet(t,a);return r.documentOverlayCache.saveOverlays(n,e.batchId,s)})}).then(()=>({batchId:i.batchId,changes:rq(t)})));a.sharedClientState.addPendingMutation(h.batchId),s=h.batchId,(u=a.Tc[a.currentUser.toKey()])||(u=new ix(iu)),u=u.insert(s,n),a.Tc[a.currentUser.toKey()]=u,await o_(a,h.changes),await aG(a.remoteStore)}catch(e){let t=a4(e,"Failed to persist write");n.reject(t)}}async function om(t,e){var n;try{let i,r,s=await (n=t.localStore,i=e.snapshotVersion,r=n.Ji,n.persistence.runTransaction("Apply remote event","readwrite-primary",t=>{var s,a,o;let l,u,h=n.Zi.newChangeBuffer({trackRemovals:!0});r=n.Ji;let c=[];
5e.targetChanges.forEach((s,a)=>{var o;let l=r.get(a);if(!l)return;c.push(n.Bs.removeMatchingKeys(t,s.removedDocuments,a).next(()=>n.Bs.addMatchingKeys(t,s.addedDocuments,a)));let u=l.withSequenceNumber(t.currentSequenceNumber);null!==e.targetMismatches.get(a)?u=u.withResumeToken(iF.EMPTY_BYTE_STRING,id.min()).withLastLimboFreeSnapshotVersion(id.min()):s.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(s.resumeToken,i)),r=r.insert(a,u),o=u,(0===l.resumeToken.approximateByteSize()||o.snapshotVersion.toMicroseconds()-l.snapshotVersion.toMicroseconds()>=3e8||s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size>0)&&c.push(n.Bs.updateTargetData(t,u))});let d=rP,f=rz();if(e.documentUpdates.forEach(i=>{e.resolvedLimboDocuments.has(i)&&c.push(n.persistence.referenceDelegate.updateLimboDocument(t,i))}),c.push((s=t,a=h,o=e.documentUpdates,l=rz(),u=rz(),o.forEach(t=>l=l.add(t)),a.getEntries(s,l).next(t=>{let e=rP;return o.forEach((n,i)=>{let r=t.get(n);i.isFoundDocument()!==r.isFoundDocument()&&(u=u.add(n)),i.isNoDocument()&&i.version.isEqual(id.min())?(a.removeEntry(n,i.readTime),e=e.insert(n,i)):!r.isValidDocument()||i.version.compareTo(r.version)>0||0===i.version.compareTo(r.version)&&r.hasPendingWrites?(a.addEntry(i),e=e.insert(n,i)):n1("LocalStore","Ignoring outdated watch update for ",n,". Current version:",r.version," Watch version:",i.version)}),{nr:e,sr:u}})).next(t=>{d=t.nr,f=t.sr})),!i.isEqual(id.min())){let e=n.Bs.getLastRemoteSnapshotVersion(t).next(e=>n.Bs.setTargetsMetadata(t,t.currentSequenceNumber,i));c.push(e)}return ib.waitFor(c).next(()=>h.apply(t)).next(()=>n.localDocuments.getLocalViewOfDocuments(t,d,f)).next(()=>d)}).then(t=>(n.Ji=r,t)));
5e.targetChanges.forEach((e,n)=>{let i=t.yc.get(n);i&&(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1||n5(),e.addedDocuments.size>0?i.fc=!0:e.modifiedDocuments.size>0?i.fc||n5():e.removedDocuments.size>0&&(i.fc||n5(),i.fc=!1))}),await o_(t,s,e)}catch(t){await iT(t)}}function oy(t,e,n){var i;if(t.isPrimaryClient&&0===n||!t.isPrimaryClient&&1===n){let n,r=[];t.wc.forEach((t,n)=>{let i=n.view.Mu(e);i.snapshot&&r.push(i.snapshot)}),(i=t.eventManager).onlineState=e,n=!1,i.queries.forEach((t,i)=>{for(let t of i.listeners)t.Mu(e)&&(n=!0)}),n&&or(i),r.length&&t.dc.nu(r),t.onlineState=e,t.isPrimaryClient&&t.sharedClientState.setOnlineState(e)}}async function ov(t,e,n){t.sharedClientState.updateQueryState(e,"rejected",n);let i=t.yc.get(e),r=i&&i.key;if(r){let n=new ix(iv.comparator);n=n.insert(r,i7.newNoDocument(r,id.min()));let i=rz().add(r),s=new sT(id.min(),new Map,new ix(iu),n,i);await om(t,s),t.gc=t.gc.remove(r),t.yc.delete(e),oA(t)}else await ac(t.localStore,e,!1).then(()=>oI(t,e,n)).catch(iT)}async function ow(t,e){var n;let i=e.batch.batchId;try{let r=await (n=t.localStore,n.persistence.runTransaction("Acknowledge batch","readwrite-primary",t=>{let i,r,s,a=e.batch.keys(),o=n.Zi.newChangeBuffer({trackRemovals:!0});return(r=(i=e.batch).keys(),s=ib.resolve(),r.forEach(n=>{s=s.next(()=>o.getEntry(t,n)).next(t=>{let r=e.docVersions.get(n);null!==r||n5(),0>t.version.compareTo(r)&&(i.applyToRemoteDocument(t,e),t.isValidDocument()&&(t.setReadTime(e.commitVersion),o.addEntry(t)))})}),s.next(()=>n.mutationQueue.removeMutationBatch(t,i))).next(()=>o.apply(t)).next(()=>n.mutationQueue.performConsistencyCheck(t)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(t,a,e.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,function(t){let e=rz();for(let n=0;n<t.mutationResults.length;++n)t.mutationResults[n].transformResults.length>0&&(e=e.add(t.batch.mutations[n].key));return e}(e))).next(()=>n.localDocuments.getDocuments(t,a))}));ob(t,i,null),oT(t,i),t.sharedClientState.updateMutationState(i,"acknowledged"),await o_(t,r)}catch(t){await iT(t)}}async function oE(t,e,n){var i;try{let r=await (i=t.localStore,i.persistence.runTransaction("Reject batch","readwrite-primary",t=>{let n;
5return i.mutationQueue.lookupMutationBatch(t,e).next(e=>(null!==e||n5(),n=e.keys(),i.mutationQueue.removeMutationBatch(t,e))).next(()=>i.mutationQueue.performConsistencyCheck(t)).next(()=>i.documentOverlayCache.removeOverlaysForBatchId(t,n,e)).next(()=>i.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,n)).next(()=>i.localDocuments.getDocuments(t,n))}));ob(t,e,n),oT(t,e),t.sharedClientState.updateMutationState(e,"rejected",n),await o_(t,r)}catch(t){await iT(t)}}function oT(t,e){(t.Ec.get(e)||[]).forEach(t=>{t.resolve()}),t.Ec.delete(e)}function ob(t,e,n){let i=t.Tc[t.currentUser.toKey()];if(i){let r=i.get(e);r&&(n?r.reject(n):r.resolve(),i=i.remove(e)),t.Tc[t.currentUser.toKey()]=i}}function oI(t,e,n=null){for(let i of(t.sharedClientState.removeLocalQueryTarget(e),t._c.get(e)))t.wc.delete(i),n&&t.dc.Pc(i,n);t._c.delete(e),t.isPrimaryClient&&t.Ic.Is(e).forEach(e=>{t.Ic.containsKey(e)||oC(t,e)})}function oC(t,e){t.mc.delete(e.path.canonicalString());let n=t.gc.get(e);null!==n&&(aO(t.remoteStore,n),t.gc=t.gc.remove(e),t.yc.delete(n),oA(t))}function oS(t,e,n){for(let i of n)i instanceof oa?(t.Ic.addReference(i.key,e),function(t,e){let n=e.key,i=n.path.canonicalString();t.gc.get(n)||t.mc.has(i)||(n1("SyncEngine","New document in limbo: "+n),t.mc.add(i),oA(t))}(t,i)):i instanceof oo?(n1("SyncEngine","Document no longer in limbo: "+i.key),t.Ic.removeReference(i.key,e),t.Ic.containsKey(i.key)||oC(t,i.key)):n5()}function oA(t){for(;t.mc.size>0&&t.gc.size<t.maxConcurrentLimboResolutions;){let e=t.mc.values().next().value;t.mc.delete(e);let n=new iv(ip.fromString(e)),i=t.Ac.next();t.yc.set(i,new oh(n)),t.gc=t.gc.insert(n,i),aM(t.remoteStore,new sW(rN(rb(n.path)),i,"TargetPurposeLimboResolution",iC.ct))}}async function o_(t,e,n){let i=[],r=[],s=[];t.wc.isEmpty()||(t.wc.forEach((a,o)=>{s.push(t.Rc(o,e,n).then(e=>{if((e||n)&&t.isPrimaryClient&&t.sharedClientState.updateQueryState(o.targetId,(null==e?void 0:e.fromCache)?"not-current":"current"),e){i.push(e);let t=aa.Li(o.targetId,e);r.push(t)}}))}),await Promise.all(s),t.dc.nu(i),await async function(t,e){try{await t.persistence.runTransaction("notifyLocalViewChanges","readwrite",n=>ib.forEach(e,e=>ib.forEach(e.Fi,i=>t.persistence.referenceDelegate.addReference(n,e.targetId,i)).next(()=>ib.forEach(e.Bi,i=>t.persistence.referenceDelegate.removeReference(n,e.targetId,i)))))}catch(t){if(!iI(t))throw t;n1("LocalStore","Failed to update sequence numbers: "+t)}for(let n of e){let e=n.targetId;if(!n.fromCache){let n=t.Ji.get(e),i=n.snapshotVersion,r=n.withLastLimboFreeSnapshotVersion(i);t.Ji=t.Ji.insert(e,r)}}}(t.localStore,r))}async function oN(t,e){if(!t.currentUser.isEqual(e)){n1("SyncEngine","User change. New user:",e.toKey());let n=await au(t.localStore,e);t.currentUser=e,t.Ec.forEach(t=>{t.forEach(t=>{t.reject(new n8(n6.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),t.Ec.clear(),t.sharedClientState.handleUserChange(e,n.removedBatchIds,n.addedBatchIds),await o_(t,n.er)}}function ox(t,e){let n=t.yc.get(e);if(n&&n.fc)return rz().add(n.key);{let n=rz(),i=t._c.get(e);if(!i)return n;for(let e of i){let i=t.wc.get(e);n=n.unionWith(i.view.nc)}return n}}class oD{constructor(){this.synchronizeTabs=!1}async initialize(t){this.serializer=aC(t.databaseInfo.databaseId),this.sharedClientState=this.createSharedClientState(t),this.persistence=this.createPersistence(t),await this.persistence.start(),this.localStore=this.createLocalStore(t),this.gcScheduler=this.createGarbageCollectionScheduler(t,this.localStore),this.indexBackfillerScheduler=this.createIndexBackfillerScheduler(t,this.localStore)}createGarbageCollectionScheduler(t,e){return null}createIndexBackfillerScheduler(t,e){return null}createLocalStore(t){var e,n;return e=this.persistence,n=new ao,new al(e,n,t.initialUser,this.serializer)}createPersistence(t){return new ai(as.zs,this.serializer)}createSharedClientState(t){return new ag}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class ok{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedCl
5ientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=t=>oy(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=oN.bind(null,this.syncEngine),await a0(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new a9}createDatastore(t){var e;let n=aC(t.databaseInfo.databaseId),i=new ab(t.databaseInfo);return e=t.authCredentials,new ax(e,t.appCheckCredentials,i,n)}createRemoteStore(t){var e,n;return e=this.localStore,n=this.datastore,new ak(e,n,t.asyncQueue,t=>oy(this.syncEngine,t,0),am.D()?new am:new ap)}createSyncEngine(t,e){var n,i,r,s,a,o;let l;return n=this.localStore,i=this.remoteStore,r=this.eventManager,s=this.sharedClientState,a=t.initialUser,o=t.maxConcurrentLimboResolutions,l=new oc(n,i,r,s,a,o),e&&(l.vc=!0),l}terminate(){return async function(t){n1("RemoteStore","RemoteStore shutting down."),t.vu.add(5),await aL(t),t.Pu.shutdown(),t.bu.set("Unknown")}(this.remoteStore)}}class oR{constructor(t){this.observer=t,this.muted=!1}next(t){this.observer.next&&this.Sc(this.observer.next,t)}error(t){this.observer.error?this.Sc(this.observer.error,t):n2("Uncaught Error in snapshot listener:",t.toString())}Dc(){this.muted=!0}Sc(t,e){this.muted||setTimeout(()=>{this.muted||t(e)},0)}}class oL{constructor(t,e,n,i){this.authCredentials=t,this.appCheckCredentials=e,this.asyncQueue=n,this.databaseInfo=i,this.user=nX.UNAUTHENTICATED,this.clientId=il.A(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(n,async t=>{n1("FirestoreClient","Received user=",t.uid),await this.authCredentialListener(t),this.user=t}),this.appCheckCredentials.start(n,t=>(n1("FirestoreClient","Received new app check token=",t),this.appCheckCredentialListener(t,this.user)))}async getConfiguration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(t){this.authCredentialListener=t}setAppCheckTokenChangeListener(t){this.appCheckCredentialListener=t}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new n8(n6.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();let t=new n7;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),t.resolve()}catch(n){let e=a4(n,"Failed to shutdown persistence");t.reject(e)}}),t.promise}}async function oM(t,e){t.asyncQueue.verifyOperationInProgress(),n1("FirestoreClient","Initializing OfflineComponentProvider");let n=await t.getConfiguration();await e.initialize(n);let i=n.initialUser;t.setCredentialChangeListener(async t=>{i.isEqual(t)||(await au(e.localStore,t),i=t)}),e.persistence.setDatabaseDeletedListener(()=>t.terminate()),t._offlineComponents=e}async function oO(t,e){t.asyncQueue.verifyOperationInProgress();let n=await oF(t);n1("FirestoreClient","Initializing OnlineComponentProvider");let i=await t.getConfiguration();await e.initialize(n,i),t.setCredentialChangeListener(t=>aZ(e.remoteStore,t)),t.setAppCheckTokenChangeListener((t,n)=>aZ(e.remoteStore,n)),t._onlineComponents=e}async function oF(t){if(!t._offlineComponents)if(t._uninitializedComponentsProvider){n1("FirestoreClient","Using user provided OfflineComponentProvider");try{await oM(t,t._uninitializedComponentsProvider._offline)}catch(e){if(!("FirebaseError"===e.name?e.code===n6.FAILED_PRECONDITION||e.code===n6.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||22===e.code||20===e.code||11===e.code))throw e;n3("Error using user provided cache. Falling back to memory cache: "+e),await oM(t,new oD)}}else n1("FirestoreClient","Using default OfflineComponentProvider"),await oM(t,new oD);return t._offlineComponents}async function oP(t){return t._onlineComponents||(t._uninitializedComponentsProvider?(n1("FirestoreClient","Using user provided OnlineComponentProvider"),await oO(t,t._uninitializedComponentsProvider._online)):(n1("FirestoreClient","Using default OnlineComponentProvider"),await oO(t,new ok))),t._onlineComponents}async function oV(t){let e=await oP(t),n=e.eventManager;return n.onListen=od.bind(null,e.syncEngine),n.onUnlisten=og.bind(null,e.syncEngine),n}function oU(t){let e={};return void 0!==t.timeoutSeconds&&(e.timeoutSeconds=t.timeoutSeconds),e}let oq=new Map;function oB(t,e,n){if(!n)throw new n8(n6.INVALID_ARGUMENT,`Function ${t}() cannot be called with an empty ${e}.`)}function oj(t){if(!iv.isDocumentKey(t))throw new n8(n6.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${t} has ${t.length}.`)}function o$(t){if(iv.isDocumentKey(t))throw new n8(n6.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${t} has ${t.length}.`)}function oz(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=`${t.substring(0,20)}...`),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";{var e;let n=(e=t).constructor?e.constructor.name:null;return n?`a custom ${n} object`:"an object"}}return"function"==typeof t?"a function":n5()}function oK(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new n8(n6.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let n=oz(t);throw new n8(n6.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${n}`)}}return t}class oG{constructor(t){var e,n;if(void 0===t.host){if(void 0!==t.ssl)throw new n8(n6.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null==(e=t.ssl)||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,this.cache=t.localCache,void 0===t.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new n8(n6.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}(function(t,e,n,i){if(!0===e&&!0===i)throw new n8(n6.INVALID_ARGUMENT,`${t} and ${n} cannot be used together.`)})("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===t.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=oU(null!=(n=t.experimentalLongPollingOptions)?n:{}),function(t){if(void 0!==t.timeoutSeconds){if(isNaN(t.timeoutSeconds))throw new n8(n6.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (must not be NaN)`);if(t.timeoutSeconds<5)throw new n8(n6.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (minimum allowed value is 5)`);if(t.timeoutSeconds>30)throw new n8(n6.INVALID_ARGUMENT,`invalid long polling timeout: ${t.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!t.useFetchStreams}isEqual(t){var e,n;return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&(e=this.experimentalLongPollingOptions,n=t.experimentalLongPollingOptions,e.timeoutSeconds===n.timeoutSeconds)&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams}}class oQ{constructor(t,e,n,i){this._authCredentials=t,this._appCheckCredentials=e,this._databaseId=n,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new oG({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new n8(n6.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 void 0!==this._terminateTask}_setSettings(t){if(this._settingsFrozen)throw new n8(n6.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 oG(t),void 0!==t.credentials&&(this._authCredentials=function(t){if(!t)return new it;switch(t.type){case"firstParty":return new is(t.sessionIndex||"0",t.i
5amToken||null,t.authTokenFactory||null);case"provider":return t.client;default:throw new n8(n6.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(t.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){let t;return(t=oq.get(this))&&(n1("ComponentProvider","Removing Datastore"),oq.delete(this),t.terminate()),Promise.resolve()}}class oH{constructor(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new oY(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new oH(this.firestore,t,this._key)}}class oW{constructor(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}withConverter(t){return new oW(this.firestore,t,this._query)}}class oY extends oW{constructor(t,e,n){super(t,e,rb(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let t=this._path.popLast();return t.isEmpty()?null:new oH(this.firestore,null,new iv(t))}withConverter(t){return new oY(this.firestore,t,this._path)}}function oX(t,e,...n){if(t=(0,c.getModularInstance)(t),oB("collection","path",e),t instanceof oQ){let i=ip.fromString(e,...n);return o$(i),new oY(t,null,i)}{if(!(t instanceof oH||t instanceof oY))throw new n8(n6.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let i=t._path.child(ip.fromString(e,...n));return o$(i),new oY(t.firestore,null,i)}}function oJ(t,e,...n){if(t=(0,c.getModularInstance)(t),1==arguments.length&&(e=il.A()),oB("doc","path",e),t instanceof oQ){let i=ip.fromString(e,...n);return oj(i),new oH(t,null,new iv(i))}{if(!(t instanceof oH||t instanceof oY))throw new n8(n6.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let i=t._path.child(ip.fromString(e,...n));return oj(i),new oH(t.firestore,t instanceof oY?t.converter:null,new iv(i))}}class oZ{constructor(){this.Gc=Promise.resolve(),this.Qc=[],this.jc=!1,this.zc=[],this.Wc=null,this.Hc=!1,this.Jc=!1,this.Yc=[],this.qo=new aS(this,"async_queue_retry"),this.Xc=()=>{let t=aI();t&&n1("AsyncQueue","Visibility state changed to "+t.visibilityState),this.qo.Mo()};const t=aI();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.Xc)}get isShuttingDown(){return this.jc}enqueueAndForget(t){this.enqueue(t)}enqueueAndForgetEvenWhileRestricted(t){this.Zc(),this.ta(t)}enterRestrictedMode(t){if(!this.jc){this.jc=!0,this.Jc=t||!1;let e=aI();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Xc)}}enqueue(t){if(this.Zc(),this.jc)return new Promise(()=>{});let e=new n7;return this.ta(()=>this.jc&&this.Jc?Promise.resolve():(t().then(e.resolve,e.reject),e.promise)).then(()=>e.promise)}enqueueRetryable(t){this.enqueueAndForget(()=>(this.Qc.push(t),this.ea()))}async ea(){if(0!==this.Qc.length){try{await this.Qc[0](),this.Qc.shift(),this.qo.reset()}catch(t){if(!iI(t))throw t;n1("AsyncQueue","Operation failed with retryable error: "+t)}this.Qc.length>0&&this.qo.No(()=>this.ea())}}ta(t){let e=this.Gc.then(()=>(this.Hc=!0,t().catch(t=>{let e;throw this.Wc=t,this.Hc=!1,n2("INTERNAL UNHANDLED ERROR: ",(e=t.message||"",t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e)),t}).then(t=>(this.Hc=!1,t))));return this.Gc=e,e}enqueueAfterDelay(t,e,n){this.Zc(),this.Yc.indexOf(t)>-1&&(e=0);let i=a3.createAndSchedule(this,t,e,n,t=>this.na(t));return this.zc.push(i),i}Zc(){this.Wc&&n5()}verifyOperationInProgress(){}async sa(){let t;do t=this.Gc,await t;while(t!==this.Gc)}ia(t){for(let e of this.zc)if(e.timerId===t)return!0;return!1}ra(t){return this.sa().then(()=>{for(let e of(this.zc.sort((t,e)=>t.targetTimeMs-e.targetTimeMs),this.zc))if(e.skipDelay(),"all"!==t&&e.timerId===t)break;return this.sa()})}
5oa(t){this.Yc.push(t)}na(t){let e=this.zc.indexOf(t);this.zc.splice(e,1)}}function o0(t){if("object"!=typeof t||null===t)return!1;for(let e of["next","error","complete"])if(e in t&&"function"==typeof t[e])return!0;return!1}class o1 extends oQ{constructor(t,e,n,i){super(t,e,n,i),this.type="firestore",this._queue=new oZ,this._persistenceKey=(null==i?void 0:i.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||o4(this),this._firestoreClient.terminate()}}function o2(t,e){let n="object"==typeof t?t:(0,l.getApp)(),i=(0,l._getProvider)(n,"firestore").getImmediate({identifier:"string"==typeof t?t:e||"(default)"});if(!i._initialized){let t=(0,c.getDefaultEmulatorHostnameAndPort)("firestore");t&&function(t,e,n,i={}){var r;let s=(t=oK(t,oQ))._getSettings(),a=`${e}:${n}`;if("firestore.googleapis.com"!==s.host&&s.host!==a&&n3("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used."),t._setSettings(Object.assign(Object.assign({},s),{host:a,ssl:!1})),i.mockUserToken){let e,n;if("string"==typeof i.mockUserToken)e=i.mockUserToken,n=nX.MOCK_USER;else{e=(0,c.createMockUserToken)(i.mockUserToken,null==(r=t._app)?void 0:r.options.projectId);let s=i.mockUserToken.sub||i.mockUserToken.user_id;if(!s)throw new n8(n6.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new nX(s)}t._authCredentials=new ie(new n9(e,n))}}(i,...t)}return i}function o3(t){return t._firestoreClient||o4(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function o4(t){var e,n,i,r,s;let a=t._freezeSettings(),o=(r=t._databaseId,s=(null==(e=t._app)?void 0:e.options.appId)||"",new iz(r,s,t._persistenceKey,a.host,a.ssl,a.experimentalForceLongPolling,a.experimentalAutoDetectLongPolling,oU(a.experimentalLongPollingOptions),a.useFetchStreams));t._firestoreClient=new oL(t._authCredentials,t._appCheckCredentials,t._queue,o),(null==(n=a.cache)?void 0:n._offlineComponentProvider)&&(null==(i=a.cache)?void 0:i._onlineComponentProvider)&&(t._firestoreClient._uninitializedComponentsProvider={_offlineKind:a.cache.kind,_offline:a.cache._offlineComponentProvider,_online:a.cache._onlineComponentProvider})}class o5{constructor(t){this._byteString=t}static fromBase64String(t){try{return new o5(iF.fromBase64String(t))}catch(t){throw new n8(n6.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new o5(iF.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}class o6{constructor(...t){for(let e=0;e<t.length;++e)if(0===t[e].length)throw new n8(n6.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new iy(t)}isEqual(t){return this._internalPath.isEqual(t._internalPath)}}function o8(){return new o6("__name__")}class o7{constructor(t){this._methodName=t}}class o9{constructor(t,e){if(!isFinite(t)||t<-90||t>90)throw new n8(n6.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new n8(n6.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}get latitude(){return this._lat}get longitude(){return this._long}isEqual(t){return this._lat===t._lat&&this._long===t._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(t){return iu(this._lat,t._lat)||iu(this._long,t._long)}}let lt=/^__.*__$/;class le{constructor(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}toMutation(t,e){return null!==this.fieldMask?new si(t,this.data,this.fieldMask,e,this.fieldTransforms):new sn(t,this.data,e,this.fieldTransforms)}}function ln(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw n5()}}class li{constructor(t,e,n,i,r,s){this.settings=t,this.databaseId=e,this.serializer=n,this.ignoreUndefinedProperties=i,void 0===r&&this.ua(),this.fieldTransforms=r||[],this.fieldMask=s||[]}get path(){return this.settings.path}get ca(){return this.settings.ca}aa(t){return new li(Object.assign(Object.assign({},this.settings),t),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ha(t){var e;let n=null==(e=this.path)?void 0:e.child(t),i=this.aa({path:n,la:!1});return i.fa(t),i}da(t){var e;let n=null==(e=this.path)?void 0:e.child(t),i=this.aa({path:n,la:!1});return i.ua(),i}wa(t){return this.aa({path:void 0,la:!0})}_a(t){return lf(t,this.settings.methodName,this.settings.ma||!1,this.path,this.settings.ga)}contains(t){return void 0!==this.fieldMask.find(e=>t.isPrefixOf(e))||void 0!==this.fieldTransforms.find(e=>t.isPrefixOf(e.field))}ua(){if(this.path)for(let t=0;t<this.path.length;t++)this.fa(this.path.get(t))}fa(t){if(0===t.length)throw this._a("Document fields must not be empty");if(ln(this.ca)&<.test(t))throw this._a('Document fields cannot begin and end with "__"')}}class lr{constructor(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.serializer
5=n||aC(t)}ya(t,e,n,i=!1){return new li({ca:t,methodName:e,ga:n,path:iy.emptyPath(),la:!1,ma:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function ls(t){let e=t._freezeSettings(),n=aC(t._databaseId);return new lr(t._databaseId,!!e.ignoreUndefinedProperties,n)}class la extends o7{_toFieldTransform(t){return new r4(t.path,new rY)}isEqual(t){return t instanceof la}}function lo(t,e){if(lu(t=(0,c.getModularInstance)(t)))return lh("Unsupported field value:",e,t),ll(t,e);if(t instanceof o7)return function(t,e){if(!ln(e.ca))throw e._a(`${t._methodName}() can only be used with update() and set()`);if(!e.path)throw e._a(`${t._methodName}() is not currently supported inside arrays`);let n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.la&&4!==e.ca)throw e._a("Nested arrays are not supported");let n=[],i=0;for(let r of t){let t=lo(r,e.wa(i));null==t&&(t={nullValue:"NULL_VALUE"}),n.push(t),i++}return{arrayValue:{values:n}}}return function(t,e){if(null===(t=(0,c.getModularInstance)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t){var n,i,r;return n=e.serializer,"number"==typeof(r=i=t)&&Number.isInteger(r)&&!iS(r)&&r<=Number.MAX_SAFE_INTEGER&&r>=Number.MIN_SAFE_INTEGER?rQ(i):rG(n,i)}if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){let n=ic.fromDate(t);return{timestampValue:sO(e.serializer,n)}}if(t instanceof ic){let n=new ic(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:sO(e.serializer,n)}}if(t instanceof o9)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof o5)return{bytesValue:sF(e.serializer,t._byteString)};if(t instanceof oH){let n=e.databaseId,i=t.firestore._databaseId;if(!i.isEqual(n))throw e._a(`Document reference is for database ${i.projectId}/${i.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:sV(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e._a(`Unsupported field value: ${oz(t)}`)}(t,e)}function ll(t,e){let n={};return iN(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):i_(t,(t,i)=>{let r=lo(i,e.ha(t));null!=r&&(n[t]=r)}),{mapValue:{fields:n}}}function lu(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof ic||t instanceof o9||t instanceof o5||t instanceof oH||t instanceof o7)}function lh(t,e,n){if(!lu(n)||"object"!=typeof n||null===n||Object.getPrototypeOf(n)!==Object.prototype&&null!==Object.getPrototypeOf(n)){let i=oz(n);throw"an object"===i?e._a(t+" a custom object"):e._a(t+" "+i)}}let lc=RegExp("[~\\*/\\[\\]]");function ld(t,e,n){if(e.search(lc)>=0)throw lf(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,t,!1,void 0,n);try{return new o6(...e.split("."))._internalPath}catch(i){throw lf(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,t,!1,void 0,n)}}function lf(t,e,n,i,r){let s=i&&!i.isEmpty(),a=void 0!==r,o=`Function ${e}() called with invalid data`;n&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(s||a)&&(l+=" (found",s&&(l+=` in field ${i}`),a&&(l+=` in document ${r}`),l+=")"),new n8(n6.INVALID_ARGUMENT,o+t+l)}class lg{constructor(t,e,n,i,r){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=i,this._converter=r}get id(){return this._key.path.lastSegment()}get ref(){return new oH(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let t=new lp(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}}get(t){if(this._document){let e=this._document.data.field(lm("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}}}class lp extends lg{data(){return super.data()}}function lm(t,e){return"string"==typeof e?ld(t,e):e instanceof o6?e._internalPath:e._delegate._internalPath}function ly(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new n8(n6.UNIMPLEMENT
5ED,"limitToLast() queries require specifying at least one orderBy() clause")}class lv{}class lw extends lv{}function lE(t,e,...n){let i=[];for(let r of(e instanceof lv&&i.push(e),function(t){let e=t.filter(t=>t instanceof lI).length,n=t.filter(t=>t instanceof lT).length;if(e>1||e>0&&n>0)throw new n8(n6.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(...)))`.")}(i=i.concat(n)),i))t=r._apply(t);return t}class lT extends lw{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new lT(t,e,n)}_apply(t){let e=this._parse(t);return lN(t._query,e),new oW(t.firestore,t.converter,rx(t._query,e))}_parse(t){let e=ls(t.firestore);return function(t,e,n,i,r,s,a){let o;if(r.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new n8(n6.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){l_(a,s);let e=[];for(let n of a)e.push(lA(i,t,n));o={arrayValue:{values:e}}}else o=lA(i,t,a)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||l_(a,s),o=function(t,e,n,i=!1){return lo(n,t.ya(i?4:3,e))}(n,e,a,"in"===s||"not-in"===s);return rr.create(r,s,o)}(t._query,"where",e,t.firestore._databaseId,this._field,this._op,this._value)}}function lb(t,e,n){let i=lm("where",t);return lT._create(i,e,n)}class lI extends lv{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new lI(t,e)}_parse(t){let e=this._queryConstraints.map(e=>e._parse(t)).filter(t=>t.getFilters().length>0);return 1===e.length?e[0]:rs.create(e,this._getOperator())}_apply(t){let e=this._parse(t);return 0===e.getFilters().length?t:(function(t,e){let n=t;for(let t of e.getFlattenedFilters())lN(n,t),n=rx(n,t)}(t._query,e),new oW(t.firestore,t.converter,rx(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class lC extends lw{constructor(t,e){super(),this._field=t,this._direction=e,this.type="orderBy"}static _create(t,e){return new lC(t,e)}_apply(t){var e;let n,i=function(t,e,n){if(null!==t.startAt)throw new n8(n6.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new n8(n6.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");let i=new rn(e,n);return function(t,e){if(null===rC(t)){let n=rS(t);null!==n&&lx(t,n,e.field)}}(t,i),i}(t._query,this._field,this._direction);return new oW(t.firestore,t.converter,(e=t._query,n=e.explicitOrderBy.concat([i]),new rT(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)))}}function lS(t,e="asc"){let n=lm("orderBy",t);return lC._create(n,e)}function lA(t,e,n){if("string"==typeof(n=(0,c.getModularInstance)(n))){if(""===n)throw new n8(n6.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!rA(e)&&-1!==n.indexOf("/"))throw new n8(n6.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let i=e.path.child(ip.fromString(n));if(!iv.isDocumentKey(i))throw new n8(n6.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${i}' is not because it has an odd number of segments (${i.length}).`);return iZ(t,new iv(i))}if(n instanceof oH)return iZ(t,n._key);throw new n8(n6.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${oz(n)}.`)}function l_(t,e){if(!Array.isArray(t)||0===t.length)throw new n8(n6.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function lN(t,e){if(e.isInequality()){let n=rS(t),i=e.field;if(null!==n&&!n.isEqual(i))throw new n8(n6.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${i.toString()}'`);let r=rC(t);null!==r&&lx(t,i,r)}let n=function(t,e){for(let n of t)for(let t of n.getFlattenedFilters())if(e.indexOf(t.op)>=0)return t.op;return null}(t.filters,function(t){switch(t){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[]}}(e.op));if(null!==n)throw n===e.op?new n8(n6.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new n8(n6.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}function lx(t,e,n){if(!n.isEqual(e))throw new n8(n6.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}class lD{convertValue(t,e="none"){switch(iQ(t)){case 0:return null;case 1:return t.booleanValue;case 2:return iU(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(iq(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw n5()}}convertObject(t,e){return this.convertObjectMap(t.fields,e)}convertObjectMap(t,e="none"){let n={};return i_(t,(t,i)=>{n[t]=this.convertValue(i,e)}),n}convertGeoPoint(t){return new o9(iU(t.latitude),iU(t.longitude))}convertArray(t,e){return(t.values||[]).map(t=>this.convertValue(t,e))}convertServerTimestamp(t,e){switch(e){case"previous":let n=ij(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(i$(t));default:return null}}convertTimestamp(t){let e=iV(t);return new ic(e.seconds,e.nanos)}convertDocumentKey(t,e){let n=ip.fromString(t);sH(n)||n5();let i=new iK(n.get(1),n.get(3)),r=new iv(n.popFirst(5));
5return i.isEqual(e)||n2(`Document ${r} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),r}}class lk{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache}}class lR extends lg{constructor(t,e,n,i,r,s){super(t,e,n,i,s),this._firestore=t,this._firestoreImpl=t,this.metadata=r}exists(){return super.exists()}data(t={}){if(this._document){if(this._converter){let e=new lL(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}}get(t,e={}){if(this._document){let n=this._document.data.field(lm("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}}}class lL extends lR{data(t={}){return super.data(t)}}class lM{constructor(t,e,n,i){this._firestore=t,this._userDataWriter=e,this._snapshot=i,this.metadata=new lk(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){let t=[];return this.forEach(e=>t.push(e)),t}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(t,e){this._snapshot.docs.forEach(n=>{t.call(e,new lL(this._firestore,this._userDataWriter,n.key,n,new lk(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(t={}){let e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new n8(n6.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){let e=0;return t._snapshot.docChanges.map(n=>{let i=new lL(t._firestore,t._userDataWriter,n.doc.key,n.doc,new lk(t._snapshot.mutatedKeys.has(n.doc.key),t._snapshot.fromCache),t.query.converter);return n.doc,{type:"added",doc:i,oldIndex:-1,newIndex:e++}})}{let n=t._snapshot.oldDocs;return t._snapshot.docChanges.filter(t=>e||3!==t.type).map(e=>{let i=new lL(t._firestore,t._userDataWriter,e.doc.key,e.doc,new lk(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter),r=-1,s=-1;return 0!==e.type&&(r=n.indexOf(e.doc.key),n=n.delete(e.doc.key)),1!==e.type&&(s=(n=n.add(e.doc)).indexOf(e.doc.key)),{type:function(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return n5()}}(e.type),doc:i,oldIndex:r,newIndex:s}})}}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges}}function lO(t){t=oK(t,oH);let e=oK(t.firestore,o1);return(function(t,e,n={}){let i=new n7;return t.asyncQueue.enqueueAndForget(async()=>{var r,s;let a,o;return r=await oV(t),s=t.asyncQueue,a=new oR({next:t=>{s.enqueueAndForget(()=>oe(r,o));let a=t.docs.has(e);!a&&t.fromCache?i.reject(new n8(n6.UNAVAILABLE,"Failed to get document because the client is offline.")):a&&t.fromCache&&n&&"server"===n.source?i.reject(new n8(n6.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.)')):i.resolve(t)},error:t=>i.reject(t)}),ot(r,o=new os(rb(e.path),a,{includeMetadataChanges:!0,Ku:!0}))}),i.promise})(o3(e),t._key).then(n=>lq(e,t,n))}class lF extends lD{constructor(t){super(),this.firestore=t}convertBytes(t){return new o5(t)}convertReference(t){let e=this.convertDocumentKey(t,this.firestore._databaseId);return new oH(this.firestore,null,e)}}function lP(t){t=oK(t,oW);let e=oK(t.firestore,o1),n=o3(e),i=new lF(e);return ly(t._query),(function(t,e,n={}){let i=new n7;return t.asyncQueue.enqueueAndForget(async()=>{var r,s;let a;return r=await oV(t),s=t.asyncQueue,a=new os(e,new oR({next:t=>{s.enqueueAndForget(()=>oe(r,a)),t.fromCache&&"server"===n.source?i.reject(new n8(n6.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.)')):i.resolve(t)},error:t=>i.reject(t)}),{includeMetadataChanges:!0,Ku:!0}),ot(r,a)}),i.promise})(n,t._query).then(n=>new lM(e,i,t,n))}function lV(t,e){var n;let i=oK(t.firestore,o1),r=oJ(t),s=(n=t.converter,n?n.toFirestore(e):e);return(function(t,e){var n;let i;return n=o3(t),i=new n7,n.asyncQueue.enqueueAndForget(async()=>op(await oP(n).then(t=>t.syncEngine),e,i)),i.promise})(i,[(function(t,e,n,i,r,s={}){let a,o,l=t.ya(s.merge||s.mergeFields?2:0,e,n,r);lh("Data must be an object, but it was:",l,i);let u=ll(i,l);if(s.merge)a=new iM(l.fieldMask),o=l.fieldTransforms;else if(s.mergeFields){let t=[];
5for(let i of s.mergeFields){let r=function(t,e,n){if((e=(0,c.getModularInstance)(e))instanceof o6)return e._internalPath;if("string"==typeof e)return ld(t,e);throw lf("Field path arguments must be of type string or ",t,!1,void 0,n)}(e,i,n);if(!l.contains(r))throw new n8(n6.INVALID_ARGUMENT,`Field '${r}' is specified in your field mask but missing from your input data.`);(function(t,e){return t.some(t=>t.isEqual(e))})(t,r)||t.push(r)}a=new iM(t),o=l.fieldTransforms.filter(t=>a.covers(t.field))}else a=null,o=l.fieldTransforms;return new le(new i8(u),a,o)})(ls(t.firestore),"addDoc",r._key,s,null!==t.converter,{}).toMutation(r._key,r6.exists(!1))]).then(()=>r)}function lU(t,...e){var n,i,r,s;let a,o,l,u,h;t=(0,c.getModularInstance)(t);let d={includeMetadataChanges:!1},f=0;"object"!=typeof e[0]||o0(e[f])||(d=e[f],f++);let g={includeMetadataChanges:d.includeMetadataChanges};if(o0(e[f])){let t=e[f];e[f]=null==(n=t.next)?void 0:n.bind(t),e[f+1]=null==(i=t.error)?void 0:i.bind(t),e[f+2]=null==(r=t.complete)?void 0:r.bind(t)}if(t instanceof oH)o=oK(t.firestore,o1),l=rb(t._key.path),a={next:n=>{e[f]&&e[f](lq(o,t,n))},error:e[f+1],complete:e[f+2]};else{let n=oK(t,oW);o=oK(n.firestore,o1),l=n._query;let i=new lF(o);a={next:t=>{e[f]&&e[f](new lM(o,i,n,t))},error:e[f+1],complete:e[f+2]},ly(t._query)}
5return s=o3(o),h=new os(l,u=new oR(a),g),s.asyncQueue.enqueueAndForget(async()=>ot(await oV(s),h)),()=>{u.Dc(),s.asyncQueue.enqueueAndForget(async()=>oe(await oV(s),h))}}function lq(t,e,n){let i=n.docs.get(e._key),r=new lF(t);return new lR(t,r,e._key,i,new lk(n.hasPendingWrites,n.fromCache),e.converter)}function lB(){return new la("serverTimestamp")}!function(t=!0){nJ=l.SDK_VERSION,(0,l._registerComponent)(new u.Component("firestore",(e,{instanceIdentifier:n,options:i})=>{let r=e.getProvider("app").getImmediate(),s=new o1(new ii(e.getProvider("auth-internal")),new io(e.getProvider("app-check-internal")),function(t,e){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new n8(n6.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new iK(t.options.projectId,e)}(r,n),r);return i=Object.assign({useFetchStreams:t},i),s._setSettings(i),s},"PUBLIC").setMultipleInstances(!0)),(0,l.registerVersion)(nY,"3.13.0",void 0),(0,l.registerVersion)(nY,"3.13.0","esm2017")}(),t.s(["Timestamp",()=>ic,"addDoc",()=>lV,"collection",()=>oX,"doc",()=>oJ,"documentId",()=>o8,"getDoc",()=>lO,"getDocs",()=>lP,"getFirestore",()=>o2,"onSnapshot",()=>lU,"orderBy",()=>lS,"query",()=>lE,"serverTimestamp",()=>lB,"where",()=>lb],317875),t.s([],436180)}]);
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.