text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).firebase=e()}(this,function(){"use strict";!function(t){if(!t.fetch){var e="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,a="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),r="FormData"in t,i="ArrayBuffer"in t;if(i)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],s=function(t){return t&&DataView.prototype.isPrototypeOf(t)},u=ArrayBuffer.isView||function(t){return t&&-1<o.indexOf(Object.prototype.toString.call(t))};d.prototype.append=function(t,e){t=l(t),e=f(e);var n=this.map[t];this.map[t]=n?n+","+e:e},d.prototype.delete=function(t){delete this.map[l(t)]},d.prototype.get=function(t){return t=l(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(l(t))},d.prototype.set=function(t,e){this.map[l(t)]=f(e)},d.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},d.prototype.keys=function(){var n=[];return this.forEach(function(t,e){n.push(e)}),p(n)},d.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),p(e)},d.prototype.entries=function(){var n=[];return this.forEach(function(t,e){n.push([e,t])}),p(n)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var c=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},T.error=function(){var t=new T(null,{status:0,statusText:""});return t.type="error",t};var h=[301,302,303,307,308];T.redirect=function(t,e){if(-1===h.indexOf(e))throw new RangeError("Invalid status code");return new T(null,{status:e,headers:{location:t}})},t.Headers=d,t.Request=w,t.Response=T,t.fetch=function(i,o){return new Promise(function(n,t){var e=new w(i,o),r=new XMLHttpRequest;r.onload=function(){var t={status:r.status,statusText:r.statusText,headers:function(t){var i=new d;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var e=t.split(":"),n=e.shift().trim();if(n){var r=e.join(":").trim();i.append(n,r)}}),i}(r.getAllResponseHeaders()||"")};t.url="responseURL"in r?r.responseURL:t.headers.get("X-Request-URL");var e="response"in r?r.response:r.responseText;n(new T(e,t))},r.onerror=function(){t(new TypeError("Network request failed"))},r.ontimeout=function(){t(new TypeError("Network request failed"))},r.open(e.method,e.url,!0),"include"===e.credentials?r.withCredentials=!0:"omit"===e.credentials&&(r.withCredentials=!1),"responseType"in r&&a&&(r.responseType="blob"),e.headers.forEach(function(t,e){r.setRequestHeader(e,t)}),r.send(void 0===e._bodyInit?null:e._bodyInit)})},t.fetch.polyfill=!0}function l(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function p(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach(function(t,e){this.append(e,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function m(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function y(n){return new Promise(function(t,e){n.onload=function(){t(n.result)},n.onerror=function(){e(n.error)}})}function g(t){var e=new FileReader,n=y(e);return e.readAsArrayBuffer(t),n}function v(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t)if("string"==typeof t)this._bodyText=t;else if(a&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(r&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(i&&a&&s(t))this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!i||!ArrayBuffer.prototype.isPrototypeOf(t)&&!u(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=v(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var t=m(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?m(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var t=m(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,n=y(e);return e.readAsText(t),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r&&(this.formData=function(){return this.text().then(_)}),this.json=function(){return this.text().then(JSON.parse)},this}function w(t,e){var n=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=function(t){var e=t.toUpperCase();return-1<c.indexOf(e)?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function _(t){var i=new FormData;return t.trim().split("&").forEach(function(t){if(t){var e=t.split("="),n=e.shift().replace(/\+/g," "),r=e.join("=").replace(/\+/g," ");i.append(decodeURIComponent(n),decodeURIComponent(r))}}),i}function T(t,e){e=e||{},this.type="default",this.status=void 0===e.status?200:e.status,this.ok=200<=this.status&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:void 0);var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.Math==Math&&t}function y(t){try{return!!t()}catch(t){return!0}}function g(t){return"object"==typeof t?null!==t:"function"==typeof t}function i(t){return l?u.createElement(t):{}}function d(t){if(!g(t))throw TypeError(String(t)+" is not an object");return t}function o(t,e){if(!g(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!g(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!g(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!g(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}function v(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}function h(e,n){try{_(b,e,n)}catch(t){b[e]=n}return n}function c(t,e){return I.call(t,e)}function s(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++C+N).toString(36)}function r(t){return c(D,t)||(A&&c(R,t)?D[t]=R[t]:D[t]=O("Symbol."+t)),D[t]}var b=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||Function("return this")(),a=!1,f=!y(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),u=b.document,l=g(u)&&g(u.createElement),p=!f&&!y(function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}),m=Object.defineProperty,w={f:f?m:function(t,e,n){if(d(t),e=o(e,!0),d(n),p)try{return m(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},_=f?function(t,e,n){return w.f(t,e,v(1,n))}:function(t,e,n){return t[e]=n,t},T="__core-js_shared__",E=b[T]||h(T,{}),S=e(function(t){(t.exports=function(t,e){return E[t]||(E[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.4.8",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),I={}.hasOwnProperty,C=0,N=Math.random(),A=!!Object.getOwnPropertySymbols&&!y(function(){return!String(Symbol())}),k=A&&!Symbol.sham&&"symbol"==typeof Symbol(),D=S("wks"),R=b.Symbol,O=k?R:s,P={};P[r("toStringTag")]="z";var M="[object z]"===String(P),x=Function.toString;"function"!=typeof E.inspectSource&&(E.inspectSource=function(t){return x.call(t)});function L(t){return W[t]||(W[t]=s(t))}var F,U,V,q=E.inspectSource,B=b.WeakMap,j="function"==typeof B&&/native code/.test(q(B)),W=S("keys"),K={},Q=b.WeakMap;if(j){var H=new Q,G=H.get,z=H.has,Y=H.set;F=function(t,e){return Y.call(H,t,e),e},U=function(t){return G.call(H,t)||{}},V=function(t){return z.call(H,t)}}else{var X=L("state");K[X]=!0,F=function(t,e){return _(t,X,e),e},U=function(t){return c(t,X)?t[X]:{}},V=function(t){return c(t,X)}}function J(t){return tt.call(t).slice(8,-1)}var $={set:F,get:U,has:V,enforce:function(t){return V(t)?U(t):F(t,{})},getterFor:function(n){return function(t){var e;if(!g(t)||(e=U(t)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return e}}},Z=e(function(t){var e=$.get,s=$.enforce,u=String(String).split("String");(t.exports=function(t,e,n,r){var i=!!r&&!!r.unsafe,o=!!r&&!!r.enumerable,a=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof e||c(n,"name")||_(n,"name",e),s(n).source=u.join("string"==typeof e?e:"")),t!==b?(i?!a&&t[e]&&(o=!0):delete t[e],o?t[e]=n:_(t,e,n)):o?t[e]=n:h(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||q(this)})}),tt={}.toString,et=r("toStringTag"),nt="Arguments"==J(function(){return arguments}()),rt=M?J:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),et))?n:nt?J(e):"Object"==(r=J(e))&&"function"==typeof e.callee?"Arguments":r},it=M?{}.toString:function(){return"[object "+rt(this)+"]"};M||Z(Object.prototype,"toString",it,{unsafe:!0});function ot(t){return isNaN(t=+t)?0:(0<t?Tt:_t)(t)}function at(t){if(null==t)throw TypeError("Can't call method on "+t);return t}function st(s){return function(t,e){var n,r,i=String(at(t)),o=ot(e),a=i.length;return o<0||a<=o?s?"":void 0:(n=i.charCodeAt(o))<55296||56319<n||o+1===a||(r=i.charCodeAt(o+1))<56320||57343<r?s?i.charAt(o):n:s?i.slice(o,o+2):r-56320+(n-55296<<10)+65536}}function ut(t){return At(at(t))}function ct(t){return"function"==typeof t?t:void 0}function ht(t,e){return arguments.length<2?ct(Rt[t])||ct(b[t]):Rt[t]&&Rt[t][e]||b[t]&&b[t][e]}function lt(t){return 0<t?Ot(ot(t),9007199254740991):0}function ft(s){return function(t,e,n){var r,i=ut(t),o=lt(i.length),a=function(t,e){var n=ot(t);return n<0?Pt(n+e,0):Mt(n,e)}(n,o);if(s&&e!=e){for(;a<o;)if((r=i[a++])!=r)return!0}else for(;a<o;a++)if((s||a in i)&&i[a]===e)return s||a||0;return!s&&-1}}function pt(t,e){var n,r=ut(t),i=0,o=[];for(n in r)!c(K,n)&&c(r,n)&&o.push(n);for(;e.length>i;)c(r,n=e[i++])&&(~xt(o,n)||o.push(n));return o}function dt(t,e){for(var n=qt(e),r=w.f,i=Dt.f,o=0;o<n.length;o++){var a=n[o];c(t,a)||r(t,a,i(e,a))}}function mt(t,e){var n=Wt[jt(t)];return n==Qt||n!=Kt&&("function"==typeof e?y(e):!!e)}function yt(t,e){var n,r,i,o,a,s=t.target,u=t.global,c=t.stat;if(n=u?b:c?b[s]||h(s,{}):(b[s]||{}).prototype)for(r in e){if(o=e[r],i=t.noTargetGet?(a=Gt(n,r))&&a.value:n[r],!Ht(u?r:s+(c?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;dt(o,i)}(t.sham||i&&i.sham)&&_(o,"sham",!0),Z(n,r,o,t)}}function gt(t){return Object(at(t))}var vt,bt,wt,_t=Math.ceil,Tt=Math.floor,Et={codeAt:st(!1),charAt:st(!0)},St={}.propertyIsEnumerable,It=Object.getOwnPropertyDescriptor,Ct={f:It&&!St.call({1:2},1)?function(t){var e=It(this,t);return!!e&&e.enumerable}:St},Nt="".split,At=y(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==J(t)?Nt.call(t,""):Object(t)}:Object,kt=Object.getOwnPropertyDescriptor,Dt={f:f?kt:function(t,e){if(t=ut(t),e=o(e,!0),p)try{return kt(t,e)}catch(t){}if(c(t,e))return v(!Ct.f.call(t,e),t[e])}},Rt=b,Ot=Math.min,Pt=Math.max,Mt=Math.min,xt={includes:ft(!0),indexOf:ft(!1)}.indexOf,Lt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ft=Lt.concat("length","prototype"),Ut={f:Object.getOwnPropertyNames||function(t){return pt(t,Ft)}},Vt={f:Object.getOwnPropertySymbols},qt=ht("Reflect","ownKeys")||function(t){var e=Ut.f(d(t)),n=Vt.f;return n?e.concat(n(t)):e},Bt=/#|\.prototype\./,jt=mt.normalize=function(t){return String(t).replace(Bt,".").toLowerCase()},Wt=mt.data={},Kt=mt.NATIVE="N",Qt=mt.POLYFILL="P",Ht=mt,Gt=Dt.f,zt=!y(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Yt=L("IE_PROTO"),Xt=Object.prototype,Jt=zt?Object.getPrototypeOf:function(t){return t=gt(t),c(t,Yt)?t[Yt]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Xt:null},$t=r("iterator"),Zt=!1;[].keys&&("next"in(wt=[].keys())?(bt=Jt(Jt(wt)))!==Object.prototype&&(vt=bt):Zt=!0),null==vt&&(vt={}),c(vt,$t)||_(vt,$t,function(){return this});function te(){}var ee={IteratorPrototype:vt,BUGGY_SAFARI_ITERATORS:Zt},ne=Object.keys||function(t){return pt(t,Lt)},re=f?Object.defineProperties:function(t,e){d(t);for(var n,r=ne(e),i=r.length,o=0;o<i;)w.f(t,n=r[o++],e[n]);return t},ie=ht("document","documentElement"),oe=L("IE_PROTO"),ae="prototype",se=function(){var t,e=i("iframe"),n=Lt.length,r="script";for(e.style.display="none",ie.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write("<script>document.F=Object</"+r+">"),t.close(),se=t.F;n--;)delete se[ae][Lt[n]];return se()},ue=Object.create||function(t,e){var n;return null!==t?(te[ae]=d(t),n=new te,te[ae]=null,n[oe]=t):n=se(),void 0===e?n:re(n,e)};K[oe]=!0;function ce(t,e,n){t&&!c(t=n?t:t.prototype,de)&&pe(t,de,{configurable:!0,value:e})}function he(){return this}function le(){return this}function fe(t,e,n,r,i,o,a){function s(t){if(t===i&&m)return m;if(!be&&t in p)return p[t];switch(t){case"keys":case _e:case Te:return function(){return new n(this,t)}}return function(){return new n(this)}}!function(t,e,n){var r=e+" Iterator";t.prototype=ue(ye,{next:v(1,n)}),ce(t,r,!1),me[r]=he}(n,e,r);var u,c,h,l=e+" Iterator",f=!1,p=t.prototype,d=p[we]||p["@@iterator"]||i&&p[i],m=!be&&d||s(i),y="Array"==e&&p.entries||d;if(y&&(u=Jt(y.call(new t)),ve!==Object.prototype&&u.next&&(Jt(u)!==ve&&(ge?ge(u,ve):"function"!=typeof u[we]&&_(u,we,le)),ce(u,l,!0))),i==_e&&d&&d.name!==_e&&(f=!0,m=function(){return d.call(this)}),p[we]!==m&&_(p,we,m),me[e]=m,i)if(c={values:s(_e),keys:o?m:s("keys"),entries:s(Te)},a)for(h in c)!be&&!f&&h in p||Z(p,h,c[h]);else yt({target:e,proto:!0,forced:be||f},c);return c}var pe=w.f,de=r("toStringTag"),me={},ye=ee.IteratorPrototype,ge=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),r=t instanceof Array}catch(t){}return function(t,e){return d(t),function(t){if(!g(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(e),r?n.call(t,e):t.__proto__=e,t}}():void 0),ve=ee.IteratorPrototype,be=ee.BUGGY_SAFARI_ITERATORS,we=r("iterator"),_e="values",Te="entries",Ee=Et.charAt,Se="String Iterator",Ie=$.set,Ce=$.getterFor(Se);fe(String,"String",function(t){Ie(this,{type:Se,string:String(t),index:0})},function(){var t,e=Ce(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=Ee(n,r),e.index+=t.length,{value:t,done:!1})});var Ne={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Ae=r("unscopables"),ke=Array.prototype;null==ke[Ae]&&_(ke,Ae,ue(null));function De(t){ke[Ae][t]=!0}var Re="Array Iterator",Oe=$.set,Pe=$.getterFor(Re),Me=fe(Array,"Array",function(t,e){Oe(this,{type:Re,target:ut(t),index:0,kind:e})},function(){var t=Pe(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?{value:t.target=void 0,done:!0}:"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}},"values");me.Arguments=me.Array,De("keys"),De("values"),De("entries");var xe=r("iterator"),Le=r("toStringTag"),Fe=Me.values;for(var Ue in Ne){var Ve=b[Ue],qe=Ve&&Ve.prototype;if(qe){if(qe[xe]!==Fe)try{_(qe,xe,Fe)}catch(zs){qe[xe]=Fe}if(qe[Le]||_(qe,Le,Ue),Ne[Ue])for(var Be in Me)if(qe[Be]!==Me[Be])try{_(qe,Be,Me[Be])}catch(zs){qe[Be]=Me[Be]}}}function je(t,e,n){for(var r in e)Z(t,r,e[r],n);return t}function We(t){var e=ht(t),n=w.f;f&&e&&!e[Je]&&n(e,Je,{configurable:!0,get:function(){return this}})}function Ke(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}function Qe(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return t}function He(t){return void 0!==t&&(me.Array===t||Ze[$e]===t)}function Ge(r,i,t){if(Ke(r),void 0===i)return r;switch(t){case 0:return function(){return r.call(i)};case 1:return function(t){return r.call(i,t)};case 2:return function(t,e){return r.call(i,t,e)};case 3:return function(t,e,n){return r.call(i,t,e,n)}}return function(){return r.apply(i,arguments)}}function ze(t){if(null!=t)return t[tn]||t["@@iterator"]||me[rt(t)]}function Ye(e,t,n,r){try{return r?t(d(n)[0],n[1]):t(n)}catch(t){var i=e.return;throw void 0!==i&&d(i.call(e)),t}}var Xe=b.Promise,Je=r("species"),$e=r("iterator"),Ze=Array.prototype,tn=r("iterator"),en=e(function(t){function p(t,e){this.stopped=t,this.result=e}(t.exports=function(t,e,n,r,i){var o,a,s,u,c,h,l,f=Ge(e,n,r?2:1);if(i)o=t;else{if("function"!=typeof(a=ze(t)))throw TypeError("Target is not iterable");if(He(a)){for(s=0,u=lt(t.length);s<u;s++)if((c=r?f(d(l=t[s])[0],l[1]):f(t[s]))&&c instanceof p)return c;return new p(!1)}o=a.call(t)}for(h=o.next;!(l=h.call(o)).done;)if("object"==typeof(c=Ye(o,f,l.value,r))&&c&&c instanceof p)return c;return new p(!1)}).stop=function(t){return new p(!0,t)}}),nn=r("iterator"),rn=!1;try{var on=0,an={next:function(){return{done:!!on++}},return:function(){rn=!0}};an[nn]=function(){return this},Array.from(an,function(){throw 2})}catch(zs){}function sn(t,e){if(!e&&!rn)return!1;var n=!1;try{var r={};r[nn]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}function un(t,e){var n,r=d(t).constructor;return void 0===r||null==(n=d(r)[yn])?e:Ke(n)}function cn(t){if(Cn.hasOwnProperty(t)){var e=Cn[t];delete Cn[t],e()}}function hn(t){return function(){cn(t)}}function ln(t){cn(t.data)}function fn(t){b.postMessage(t+"",bn.protocol+"//"+bn.host)}var pn,dn,mn,yn=r("species"),gn=ht("navigator","userAgent")||"",vn=/(iphone|ipod|ipad).*applewebkit/i.test(gn),bn=b.location,wn=b.setImmediate,_n=b.clearImmediate,Tn=b.process,En=b.MessageChannel,Sn=b.Dispatch,In=0,Cn={},Nn="onreadystatechange";wn&&_n||(wn=function(t){for(var e=[],n=1;n<arguments.length;)e.push(arguments[n++]);return Cn[++In]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},pn(In),In},_n=function(t){delete Cn[t]},"process"==J(Tn)?pn=function(t){Tn.nextTick(hn(t))}:Sn&&Sn.now?pn=function(t){Sn.now(hn(t))}:En&&!vn?(mn=(dn=new En).port2,dn.port1.onmessage=ln,pn=Ge(mn.postMessage,mn,1)):!b.addEventListener||"function"!=typeof postMessage||b.importScripts||y(fn)?pn=Nn in i("script")?function(t){ie.appendChild(i("script"))[Nn]=function(){ie.removeChild(this),cn(t)}}:function(t){setTimeout(hn(t),0)}:(pn=fn,b.addEventListener("message",ln,!1)));var An,kn,Dn,Rn,On,Pn,Mn,xn,Ln={set:wn,clear:_n},Fn=Dt.f,Un=Ln.set,Vn=b.MutationObserver||b.WebKitMutationObserver,qn=b.process,Bn=b.Promise,jn="process"==J(qn),Wn=Fn(b,"queueMicrotask"),Kn=Wn&&Wn.value;Kn||(An=function(){var t,e;for(jn&&(t=qn.domain)&&t.exit();kn;){e=kn.fn,kn=kn.next;try{e()}catch(t){throw kn?Rn():Dn=void 0,t}}Dn=void 0,t&&t.enter()},Rn=jn?function(){qn.nextTick(An)}:Vn&&!vn?(On=!0,Pn=document.createTextNode(""),new Vn(An).observe(Pn,{characterData:!0}),function(){Pn.data=On=!On}):Bn&&Bn.resolve?(Mn=Bn.resolve(void 0),xn=Mn.then,function(){xn.call(Mn,An)}):function(){Un.call(b,An)});function Qn(t){var n,r;this.promise=new t(function(t,e){if(void 0!==n||void 0!==r)throw TypeError("Bad Promise constructor");n=t,r=e}),this.resolve=Ke(n),this.reject=Ke(r)}function Hn(t,e){if(d(t),g(e)&&e.constructor===t)return e;var n=Jn.f(t);return(0,n.resolve)(e),n.promise}function Gn(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}var zn,Yn,Xn=Kn||function(t){var e={fn:t,next:void 0};Dn&&(Dn.next=e),kn||(kn=e,Rn()),Dn=e},Jn={f:function(t){return new Qn(t)}},$n=b.process,Zn=$n&&$n.versions,tr=Zn&&Zn.v8;tr?Yn=(zn=tr.split("."))[0]+zn[1]:gn&&(!(zn=gn.match(/Edge\/(\d+)/))||74<=zn[1])&&(zn=gn.match(/Chrome\/(\d+)/))&&(Yn=zn[1]);function er(t){var e;return!(!g(t)||"function"!=typeof(e=t.then))&&e}function nr(l,f,p){if(!f.notified){f.notified=!0;var d=f.reactions;Xn(function(){for(var t=f.value,e=1==f.state,n=0;d.length>n;){var r,i,o,a=d[n++],s=e?a.ok:a.fail,u=a.resolve,c=a.reject,h=a.domain;try{s?(e||(2===f.rejection&&Rr(l,f),f.rejection=1),!0===s?r=t:(h&&h.enter(),r=s(t),h&&(h.exit(),o=!0)),r===a.promise?c(vr("Promise-chain cycle")):(i=er(r))?i.call(r,u,c):u(r)):c(t)}catch(t){h&&!o&&h.exit(),c(t)}}f.reactions=[],f.notified=!1,p&&!f.rejection&&kr(l,f)})}}function rr(t,e,n){var r,i;Ir?((r=br.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),b.dispatchEvent(r)):r={promise:e,reason:n},(i=b["on"+t])?i(r):t===Cr&&function(t,e){var n=b.console;n&&n.error&&(1===arguments.length?n.error(t):n.error(t,e))}("Unhandled promise rejection",n)}function ir(e,n,r,i){return function(t){e(n,r,t,i)}}function or(t,e,n,r){e.done||(e.done=!0,r&&(e=r),e.value=n,e.state=2,nr(t,e,!0))}var ar,sr,ur,cr,hr=Yn&&+Yn,lr=Ln.set,fr=r("species"),pr="Promise",dr=$.get,mr=$.set,yr=$.getterFor(pr),gr=Xe,vr=b.TypeError,br=b.document,wr=b.process,_r=ht("fetch"),Tr=Jn.f,Er=Tr,Sr="process"==J(wr),Ir=!!(br&&br.createEvent&&b.dispatchEvent),Cr="unhandledrejection",Nr=Ht(pr,function(){if(!(q(gr)!==String(gr))){if(66===hr)return!0;if(!Sr&&"function"!=typeof PromiseRejectionEvent)return!0}if(51<=hr&&/native code/.test(gr))return!1;function t(t){t(function(){},function(){})}var e=gr.resolve(1);return(e.constructor={})[fr]=t,!(e.then(function(){})instanceof t)}),Ar=Nr||!sn(function(t){gr.all(t).catch(function(){})}),kr=function(n,r){lr.call(b,function(){var t,e=r.value;if(Dr(r)&&(t=Gn(function(){Sr?wr.emit("unhandledRejection",e,n):rr(Cr,n,e)}),r.rejection=Sr||Dr(r)?2:1,t.error))throw t.value})},Dr=function(t){return 1!==t.rejection&&!t.parent},Rr=function(t,e){lr.call(b,function(){Sr?wr.emit("rejectionHandled",t):rr("rejectionhandled",t,e.value)})},Or=function(n,r,t,e){if(!r.done){r.done=!0,e&&(r=e);try{if(n===t)throw vr("Promise can't be resolved itself");var i=er(t);i?Xn(function(){var e={done:!1};try{i.call(t,ir(Or,n,e,r),ir(or,n,e,r))}catch(t){or(n,e,t,r)}}):(r.value=t,r.state=1,nr(n,r,!1))}catch(t){or(n,{done:!1},t,r)}}};Nr&&(gr=function(t){Qe(this,gr,pr),Ke(t),ar.call(this);var e=dr(this);try{t(ir(Or,this,e),ir(or,this,e))}catch(t){or(this,e,t)}},(ar=function(t){mr(this,{type:pr,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=je(gr.prototype,{then:function(t,e){var n=yr(this),r=Tr(un(this,gr));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=Sr?wr.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&nr(this,n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),sr=function(){var t=new ar,e=dr(t);this.promise=t,this.resolve=ir(Or,t,e),this.reject=ir(or,t,e)},Jn.f=Tr=function(t){return t===gr||t===ur?new sr(t):Er(t)},"function"==typeof Xe&&(cr=Xe.prototype.then,Z(Xe.prototype,"then",function(t,e){var n=this;return new gr(function(t,e){cr.call(n,t,e)}).then(t,e)},{unsafe:!0}),"function"==typeof _r&&yt({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return Hn(gr,_r.apply(b,arguments))}}))),yt({global:!0,wrap:!0,forced:Nr},{Promise:gr}),ce(gr,pr,!1),We(pr),ur=ht(pr),yt({target:pr,stat:!0,forced:Nr},{reject:function(t){var e=Tr(this);return e.reject.call(void 0,t),e.promise}}),yt({target:pr,stat:!0,forced:Nr},{resolve:function(t){return Hn(this,t)}}),yt({target:pr,stat:!0,forced:Ar},{all:function(t){var s=this,e=Tr(s),u=e.resolve,c=e.reject,n=Gn(function(){var r=Ke(s.resolve),i=[],o=0,a=1;en(t,function(t){var e=o++,n=!1;i.push(void 0),a++,r.call(s,t).then(function(t){n||(n=!0,i[e]=t,--a||u(i))},c)}),--a||u(i)});return n.error&&c(n.value),e.promise},race:function(t){var n=this,r=Tr(n),i=r.reject,e=Gn(function(){var e=Ke(n.resolve);en(t,function(t){e.call(n,t).then(r.resolve,i)})});return e.error&&i(e.value),r.promise}}),yt({target:"Promise",stat:!0},{allSettled:function(t){var s=this,e=Jn.f(s),u=e.resolve,n=e.reject,r=Gn(function(){var r=Ke(s.resolve),i=[],o=0,a=1;en(t,function(t){var e=o++,n=!1;i.push(void 0),a++,r.call(s,t).then(function(t){n||(n=!0,i[e]={status:"fulfilled",value:t},--a||u(i))},function(t){n||(n=!0,i[e]={status:"rejected",reason:t},--a||u(i))})}),--a||u(i)});return r.error&&n(r.value),e.promise}});var Pr=!!Xe&&y(function(){Xe.prototype.finally.call({then:function(){}},function(){})});yt({target:"Promise",proto:!0,real:!0,forced:Pr},{finally:function(e){var n=un(this,ht("Promise")),t="function"==typeof e;return this.then(t?function(t){return Hn(n,e()).then(function(){return t})}:e,t?function(t){return Hn(n,e()).then(function(){throw t})}:e)}}),"function"!=typeof Xe||Xe.prototype.finally||Z(Xe.prototype,"finally",ht("Promise").prototype.finally);Rt.Promise;var Mr=$.set,xr=$.getterFor("AggregateError"),Lr=function(t,e){var n=this;if(!(n instanceof Lr))return new Lr(t,e);ge&&(n=ge(new Error(e),Jt(n)));var r=[];return en(t,r.push,r),f?Mr(n,{errors:r,type:"AggregateError"}):n.errors=r,void 0!==e&&_(n,"message",String(e)),n};Lr.prototype=ue(Error.prototype,{constructor:v(5,Lr),message:v(5,""),name:v(5,"AggregateError")}),f&&w.f(Lr.prototype,"errors",{get:function(){return xr(this).errors},configurable:!0}),yt({global:!0},{AggregateError:Lr}),yt({target:"Promise",stat:!0},{try:function(t){var e=Jn.f(this),n=Gn(t);return(n.error?e.reject:e.resolve)(n.value),e.promise}});var Fr="No one promise resolved";yt({target:"Promise",stat:!0},{any:function(t){var u=this,e=Jn.f(u),c=e.resolve,h=e.reject,n=Gn(function(){var r=Ke(u.resolve),i=[],o=0,a=1,s=!1;en(t,function(t){var e=o++,n=!1;i.push(void 0),a++,r.call(u,t).then(function(t){n||s||(s=!0,c(t))},function(t){n||s||(n=!0,i[e]=t,--a||h(new(ht("AggregateError"))(i,Fr)))})}),--a||h(new(ht("AggregateError"))(i,Fr))});return n.error&&h(n.value),e.promise}});function Ur(t,e){var n;return qr(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!qr(n.prototype)?g(n)&&null===(n=n[Br])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)}function Vr(p){var d=1==p,m=2==p,y=3==p,g=4==p,v=6==p,b=5==p||v;return function(t,e,n,r){for(var i,o,a=gt(t),s=At(a),u=Ge(e,n,3),c=lt(s.length),h=0,l=r||Ur,f=d?l(t,c):m?l(t,0):void 0;h<c;h++)if((b||h in s)&&(o=u(i=s[h],h,a),p))if(d)f[h]=o;else if(o)switch(p){case 3:return!0;case 5:return i;case 6:return h;case 2:jr.call(f,i)}else if(g)return!1;return v?-1:y||g?g:f}}var qr=Array.isArray||function(t){return"Array"==J(t)},Br=r("species"),jr=[].push,Wr={forEach:Vr(0),map:Vr(1),filter:Vr(2),some:Vr(3),every:Vr(4),find:Vr(5),findIndex:Vr(6)},Kr=Wr.find,Qr="find",Hr=!0;Qr in[]&&Array(1)[Qr](function(){Hr=!1}),yt({target:"Array",proto:!0,forced:Hr},{find:function(t,e){return Kr(this,t,1<arguments.length?e:void 0)}}),De(Qr);function Gr(t,e,n){return Ge(zr,b[t].prototype[e],n)}var zr=Function.call,Yr=(Gr("Array","find"),Wr.findIndex),Xr="findIndex",Jr=!0;Xr in[]&&Array(1)[Xr](function(){Jr=!1}),yt({target:"Array",proto:!0,forced:Jr},{findIndex:function(t,e){return Yr(this,t,1<arguments.length?e:void 0)}}),De(Xr);function $r(t,e,n){var r=o(e);r in t?w.f(t,r,v(0,n)):t[r]=n}Gr("Array","findIndex");var Zr=!sn(function(t){Array.from(t)});yt({target:"Array",stat:!0,forced:Zr},{from:function(t,e,n){var r,i,o,a,s,u=gt(t),c="function"==typeof this?this:Array,h=arguments.length,l=1<h?e:void 0,f=void 0!==l,p=0,d=ze(u);if(f&&(l=Ge(l,2<h?n:void 0,2)),null==d||c==Array&&He(d))for(i=new c(r=lt(u.length));p<r;p++)$r(i,p,f?l(u[p],p):u[p]);else for(s=(a=d.call(u)).next,i=new c;!(o=s.call(a)).done;p++)$r(i,p,f?Ye(a,l,[o.value,p],!0):o.value);return i.length=p,i}});Rt.Array.from;var ti,ei,ni,ri=Wr.some;yt({target:"Array",proto:!0,forced:(ti="some",ni=[][ti],!ni||!y(function(){ni.call(null,ei||function(){throw 1},1)}))},{some:function(t,e){return ri(this,t,1<arguments.length?e:void 0)}});Gr("Array","some");function ii(t){return g(t)&&c(wi,rt(t))}var oi,ai=w.f,si=b.DataView,ui=si&&si.prototype,ci=b.Int8Array,hi=ci&&ci.prototype,li=b.Uint8ClampedArray,fi=li&&li.prototype,pi=ci&&Jt(ci),di=hi&&Jt(hi),mi=Object.prototype,yi=(mi.isPrototypeOf,r("toStringTag")),gi=s("TYPED_ARRAY_TAG"),vi=!(!b.ArrayBuffer||!si),bi=vi&&!!ge&&"Opera"!==rt(b.opera),wi={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8};for(oi in wi)b[oi]||(bi=!1);if((!bi||"function"!=typeof pi||pi===Function.prototype)&&(pi=function(){throw TypeError("Incorrect invocation")},bi))for(oi in wi)b[oi]&&ge(b[oi],pi);if((!bi||!di||di===mi)&&(di=pi.prototype,bi))for(oi in wi)b[oi]&&ge(b[oi].prototype,di);if(bi&&Jt(fi)!==di&&ge(fi,di),f&&!c(di,yi))for(oi in!0,ai(di,yi,{get:function(){return g(this)?this[gi]:void 0}}),wi)b[oi]&&_(b[oi],gi,oi);vi&&ge&&Jt(ui)!==mi&&ge(ui,mi);function _i(){return Ci.call(ki(this))}var Ti=function(t){if(ii(t))return t;throw TypeError("Target is not a typed array")},Ei=function(t,e,n){if(f){if(n)for(var r in wi){var i=b[r];i&&c(i.prototype,t)&&delete i.prototype[t]}di[t]&&!n||Z(di,t,n?e:bi&&hi[t]||e)}},Si=r("iterator"),Ii=b.Uint8Array,Ci=Me.values,Ni=Me.keys,Ai=Me.entries,ki=Ti,Di=Ei,Ri=Ii&&Ii.prototype[Si],Oi=!!Ri&&("values"==Ri.name||null==Ri.name);Di("entries",function(){return Ai.call(ki(this))}),Di("keys",function(){return Ni.call(ki(this))}),Di("values",_i,!Oi),Di(Si,_i,!Oi);var Pi=Object.assign,Mi=Object.defineProperty,xi=!Pi||y(function(){if(f&&1!==Pi({b:1},Pi(Mi({},"a",{enumerable:!0,get:function(){Mi(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=Pi({},t)[n]||ne(Pi({},e)).join("")!=r})?function(t,e){for(var n=gt(t),r=arguments.length,i=1,o=Vt.f,a=Ct.f;i<r;)for(var s,u=At(arguments[i++]),c=o?ne(u).concat(o(u)):ne(u),h=c.length,l=0;l<h;)s=c[l++],f&&!a.call(u,s)||(n[s]=u[s]);return n}:Pi;yt({target:"Object",stat:!0,forced:Object.assign!==xi},{assign:xi});Rt.Object.assign;function Li(s){return function(t){for(var e,n=ut(t),r=ne(n),i=r.length,o=0,a=[];o<i;)e=r[o++],f&&!Fi.call(n,e)||a.push(s?[e,n[e]]:n[e]);return a}}var Fi=Ct.f,Ui={entries:Li(!0),values:Li(!1)},Vi=Ui.entries;yt({target:"Object",stat:!0},{entries:function(t){return Vi(t)}});Rt.Object.entries;var qi=Ui.values;yt({target:"Object",stat:!0},{values:function(t){return qi(t)}});Rt.Object.values;function Bi(t){if(function(t){var e;return g(t)&&(void 0!==(e=t[Wi])?!!e:"RegExp"==J(t))}(t))throw TypeError("The method doesn't accept regular expressions");return t}function ji(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Ki]=!1,"/./"[e](n)}catch(t){}}return!1}var Wi=r("match"),Ki=r("match");yt({target:"String",proto:!0,forced:!ji("includes")},{includes:function(t,e){return!!~String(at(this)).indexOf(Bi(t),1<arguments.length?e:void 0)}});Gr("String","includes");var Qi,Hi=Dt.f,Gi="".startsWith,zi=Math.min,Yi=ji("startsWith"),Xi=!(Yi||(!(Qi=Hi(String.prototype,"startsWith"))||Qi.writable));yt({target:"String",proto:!0,forced:!Xi&&!Yi},{startsWith:function(t,e){var n=String(at(this));Bi(t);var r=lt(zi(1<arguments.length?e:void 0,n.length)),i=String(t);return Gi?Gi.call(n,i,r):n.slice(r,r+i.length)===i}});Gr("String","startsWith");yt({target:"String",proto:!0},{repeat:"".repeat||function(t){var e=String(at(this)),n="",r=ot(t);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;0<r;(r>>>=1)&&(e+=e))1&r&&(n+=e);return n}});Gr("String","repeat");function Ji(t){if(!g(t))return!1;var e=t[to];return void 0!==e?!!e:qr(t)}var $i,Zi=r("species"),to=r("isConcatSpreadable"),eo=9007199254740991,no="Maximum allowed index exceeded",ro=51<=hr||!y(function(){var t=[];return t[to]=!1,t.concat()[0]!==t}),io=($i="concat",51<=hr||!y(function(){var t=[];return(t.constructor={})[Zi]=function(){return{foo:1}},1!==t[$i](Boolean).foo}));yt({target:"Array",proto:!0,forced:!ro||!io},{concat:function(t){var e,n,r,i,o,a=gt(this),s=Ur(a,0),u=0;for(e=-1,r=arguments.length;e<r;e++)if(Ji(o=-1===e?a:arguments[e])){if(i=lt(o.length),eo<u+i)throw TypeError(no);for(n=0;n<i;n++,u++)n in o&&$r(s,u,o[n])}else{if(eo<=u)throw TypeError(no);$r(s,u++,o)}return s.length=u,s}});function oo(t){var e=Rt.Symbol||(Rt.Symbol={});c(e,t)||yo(e,t,{value:mo.f(t)})}function ao(t,e){var n=Ro[t]=ue(Io[wo]);return To(n,{type:bo,tag:t,description:e}),f||(n.description=e),n}function so(e,t){d(e);var n=ut(t),r=ne(n).concat(jo(n));return go(r,function(t){f&&!Bo.call(n,t)||qo(e,t,n[t])}),e}function uo(t,e){var n=ut(t),r=o(e,!0);if(n!==So||!c(Ro,r)||c(Oo,r)){var i=No(n,r);return!i||!c(Ro,r)||c(n,vo)&&n[vo][r]||(i.enumerable=!0),i}}function co(t){var e=ko(ut(t)),n=[];return go(e,function(t){c(Ro,t)||c(K,t)||n.push(t)}),n}var ho=Ut.f,lo={}.toString,fo="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],po={f:function(t){return fo&&"[object Window]"==lo.call(t)?function(t){try{return ho(t)}catch(t){return fo.slice()}}(t):ho(ut(t))}},mo={f:r},yo=w.f,go=Wr.forEach,vo=L("hidden"),bo="Symbol",wo="prototype",_o=r("toPrimitive"),To=$.set,Eo=$.getterFor(bo),So=Object[wo],Io=b.Symbol,Co=ht("JSON","stringify"),No=Dt.f,Ao=w.f,ko=po.f,Do=Ct.f,Ro=S("symbols"),Oo=S("op-symbols"),Po=S("string-to-symbol-registry"),Mo=S("symbol-to-string-registry"),xo=S("wks"),Lo=b.QObject,Fo=!Lo||!Lo[wo]||!Lo[wo].findChild,Uo=f&&y(function(){return 7!=ue(Ao({},"a",{get:function(){return Ao(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=No(So,e);r&&delete So[e],Ao(t,e,n),r&&t!==So&&Ao(So,e,r)}:Ao,Vo=A&&"symbol"==typeof Io.iterator?function(t){return"symbol"==typeof t}:function(t){return Object(t)instanceof Io},qo=function(t,e,n){t===So&&qo(Oo,e,n),d(t);var r=o(e,!0);return d(n),c(Ro,r)?(n.enumerable?(c(t,vo)&&t[vo][r]&&(t[vo][r]=!1),n=ue(n,{enumerable:v(0,!1)})):(c(t,vo)||Ao(t,vo,v(1,{})),t[vo][r]=!0),Uo(t,r,n)):Ao(t,r,n)},Bo=function(t){var e=o(t,!0),n=Do.call(this,e);return!(this===So&&c(Ro,e)&&!c(Oo,e))&&(!(n||!c(this,e)||!c(Ro,e)||c(this,vo)&&this[vo][e])||n)},jo=function(t){var e=t===So,n=ko(e?Oo:ut(t)),r=[];return go(n,function(t){!c(Ro,t)||e&&!c(So,t)||r.push(Ro[t])}),r};if(A||(Z((Io=function(t){if(this instanceof Io)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==t?String(t):void 0,n=s(e),r=function(t){this===So&&r.call(Oo,t),c(this,vo)&&c(this[vo],n)&&(this[vo][n]=!1),Uo(this,n,v(1,t))};return f&&Fo&&Uo(So,n,{configurable:!0,set:r}),ao(n,e)})[wo],"toString",function(){return Eo(this).tag}),Ct.f=Bo,w.f=qo,Dt.f=uo,Ut.f=po.f=co,Vt.f=jo,f&&(Ao(Io[wo],"description",{configurable:!0,get:function(){return Eo(this).description}}),Z(So,"propertyIsEnumerable",Bo,{unsafe:!0}))),k||(mo.f=function(t){return ao(r(t),t)}),yt({global:!0,wrap:!0,forced:!A,sham:!A},{Symbol:Io}),go(ne(xo),function(t){oo(t)}),yt({target:bo,stat:!0,forced:!A},{for:function(t){var e=String(t);if(c(Po,e))return Po[e];var n=Io(e);return Po[e]=n,Mo[n]=e,n},keyFor:function(t){if(!Vo(t))throw TypeError(t+" is not a symbol");if(c(Mo,t))return Mo[t]},useSetter:function(){Fo=!0},useSimple:function(){Fo=!1}}),yt({target:"Object",stat:!0,forced:!A,sham:!f},{create:function(t,e){return void 0===e?ue(t):so(ue(t),e)},defineProperty:qo,defineProperties:so,getOwnPropertyDescriptor:uo}),yt({target:"Object",stat:!0,forced:!A},{getOwnPropertyNames:co,getOwnPropertySymbols:jo}),yt({target:"Object",stat:!0,forced:y(function(){Vt.f(1)})},{getOwnPropertySymbols:function(t){return Vt.f(gt(t))}}),Co){var Wo=!A||y(function(){var t=Io();return"[null]"!=Co([t])||"{}"!=Co({a:t})||"{}"!=Co(Object(t))});yt({target:"JSON",stat:!0,forced:Wo},{stringify:function(t,e,n){for(var r,i=[t],o=1;o<arguments.length;)i.push(arguments[o++]);if((g(r=e)||void 0!==t)&&!Vo(t))return qr(e)||(e=function(t,e){if("function"==typeof r&&(e=r.call(this,t,e)),!Vo(e))return e}),i[1]=e,Co.apply(null,i)}})}Io[wo][_o]||_(Io[wo],_o,Io[wo].valueOf),ce(Io,bo),K[vo]=!0,oo("asyncIterator");var Ko=w.f,Qo=b.Symbol;if(!(!f||"function"!=typeof Qo||"description"in Qo.prototype&&void 0===Qo().description)){var Ho={},Go=function(t){var e=arguments.length<1||void 0===t?void 0:String(t),n=this instanceof Go?new Qo(e):void 0===e?Qo():Qo(e);return""===e&&(Ho[n]=!0),n};dt(Go,Qo);var zo=Go.prototype=Qo.prototype;zo.constructor=Go;var Yo=zo.toString,Xo="Symbol(test)"==String(Qo("test")),Jo=/^Symbol\((.*)\)[^)]+$/;Ko(zo,"description",{configurable:!0,get:function(){var t=g(this)?this.valueOf():this,e=Yo.call(t);if(c(Ho,t))return"";var n=Xo?e.slice(7,-1):e.replace(Jo,"$1");return""===n?void 0:n}}),yt({global:!0,forced:!0},{Symbol:Go})}oo("hasInstance"),oo("isConcatSpreadable"),oo("iterator"),oo("match"),oo("matchAll"),oo("replace"),oo("search"),oo("species"),oo("split"),oo("toPrimitive"),oo("toStringTag"),oo("unscopables"),ce(Math,"Math",!0),ce(b.JSON,"JSON",!0);Rt.Symbol;oo("asyncDispose"),oo("dispose"),oo("observable"),oo("patternMatch"),oo("replaceAll");mo.f("iterator");function $o(r,t,e){function n(t){var n=u[t];Z(u,t,"add"==t?function(t){return n.call(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!g(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return o&&!g(t)?void 0:n.call(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!g(t))&&n.call(this,0===t?0:t)}:function(t,e){return n.call(this,0===t?0:t,e),this})}var i=-1!==r.indexOf("Map"),o=-1!==r.indexOf("Weak"),a=i?"set":"add",s=b[r],u=s&&s.prototype,c=s,h={};if(Ht(r,"function"!=typeof s||!(o||u.forEach&&!y(function(){(new s).entries().next()}))))c=e.getConstructor(t,r,i,a),ea.REQUIRED=!0;else if(Ht(r,!0)){var l=new c,f=l[a](o?{}:-0,1)!=l,p=y(function(){l.has(1)}),d=sn(function(t){new s(t)}),m=!o&&y(function(){for(var t=new s,e=5;e--;)t[a](e,e);return!t.has(-0)});d||(((c=t(function(t,e){Qe(t,c,r);var n=function(t,e,n){var r,i;return ge&&"function"==typeof(r=e.constructor)&&r!==n&&g(i=r.prototype)&&i!==n.prototype&&ge(t,i),t}(new s,t,c);return null!=e&&en(e,n[a],n,i),n})).prototype=u).constructor=c),(p||m)&&(n("delete"),n("has"),i&&n("get")),(m||f)&&n(a),o&&u.clear&&delete u.clear}return h[r]=c,yt({global:!0,forced:c!=s},h),ce(c,r),o||e.setStrong(c,r,i),c}function Zo(t,e,n){var r,i,o,a,s=arguments.length,u=1<s?e:void 0;return Ke(this),(r=void 0!==u)&&Ke(u),null==t?new this:(i=[],r?(o=0,a=Ge(u,2<s?n:void 0,2),en(t,function(t){i.push(a(t,o++))})):en(t,i.push,i),new this(i))}var ta=!y(function(){return Object.isExtensible(Object.preventExtensions({}))}),ea=e(function(t){function n(t){e(t,r,{value:{objectID:"O"+ ++i,weakData:{}}})}var e=w.f,r=s("meta"),i=0,o=Object.isExtensible||function(){return!0},a=t.exports={REQUIRED:!1,fastKey:function(t,e){if(!g(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!c(t,r)){if(!o(t))return"F";if(!e)return"E";n(t)}return t[r].objectID},getWeakData:function(t,e){if(!c(t,r)){if(!o(t))return!0;if(!e)return!1;n(t)}return t[r].weakData},onFreeze:function(t){return ta&&a.REQUIRED&&o(t)&&!c(t,r)&&n(t),t}};K[r]=!0}),na=(ea.REQUIRED,ea.fastKey,ea.getWeakData,ea.onFreeze,w.f),ra=ea.fastKey,ia=$.set,oa=$.getterFor,aa={getConstructor:function(t,n,r,i){function o(t,e,n){var r,i,o=s(t),a=u(t,e);return a?a.value=n:(o.last=a={index:i=ra(e,!0),key:e,value:n,previous:r=o.last,next:void 0,removed:!1},o.first||(o.first=a),r&&(r.next=a),f?o.size++:t.size++,"F"!==i&&(o.index[i]=a)),t}var a=t(function(t,e){Qe(t,a,n),ia(t,{type:n,index:ue(null),first:void 0,last:void 0,size:0}),f||(t.size=0),null!=e&&en(e,t[i],t,r)}),s=oa(n),u=function(t,e){var n,r=s(t),i=ra(e);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==e)return n};return je(a.prototype,{clear:function(){for(var t=s(this),e=t.index,n=t.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete e[n.index],n=n.next;t.first=t.last=void 0,f?t.size=0:this.size=0},delete:function(t){var e=s(this),n=u(this,t);if(n){var r=n.next,i=n.previous;delete e.index[n.index],n.removed=!0,i&&(i.next=r),r&&(r.previous=i),e.first==n&&(e.first=r),e.last==n&&(e.last=i),f?e.size--:this.size--}return!!n},forEach:function(t,e){for(var n,r=s(this),i=Ge(t,1<arguments.length?e:void 0,3);n=n?n.next:r.first;)for(i(n.value,n.key,this);n&&n.removed;)n=n.previous},has:function(t){return!!u(this,t)}}),je(a.prototype,r?{get:function(t){var e=u(this,t);return e&&e.value},set:function(t,e){return o(this,0===t?0:t,e)}}:{add:function(t){return o(this,t=0===t?0:t,t)}}),f&&na(a.prototype,"size",{get:function(){return s(this).size}}),a},setStrong:function(t,e,n){var r=e+" Iterator",i=oa(e),o=oa(r);fe(t,e,function(t,e){ia(this,{type:r,target:t,state:i(t),kind:e,last:void 0})},function(){for(var t=o(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?"keys"==e?{value:n.key,done:!1}:"values"==e?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:{value:t.target=void 0,done:!0}},n?"entries":"values",!n,!0),We(e)}};$o("Map",function(e){return function(t){return e(this,arguments.length?t:void 0)}},aa),Rt.Map;yt({target:"Map",stat:!0},{from:Zo});function sa(){for(var t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return new this(e)}yt({target:"Map",stat:!0},{of:sa});function ua(){for(var t,e=d(this),n=Ke(e.delete),r=!0,i=0,o=arguments.length;i<o;i++)t=n.call(e,arguments[i]),r=r&&t;return!!r}yt({target:"Map",proto:!0,real:!0,forced:a},{deleteAll:function(){return ua.apply(this,arguments)}});function ca(t){return Map.prototype.entries.call(t)}yt({target:"Map",proto:!0,real:!0,forced:a},{every:function(t,e){var n=d(this),r=ca(n),i=Ge(t,1<arguments.length?e:void 0,3);return!en(r,function(t,e){if(!i(e,t,n))return en.stop()},void 0,!0,!0).stopped}}),yt({target:"Map",proto:!0,real:!0,forced:a},{filter:function(t,e){var n=d(this),r=ca(n),i=Ge(t,1<arguments.length?e:void 0,3),o=new(un(n,ht("Map"))),a=Ke(o.set);return en(r,function(t,e){i(e,t,n)&&a.call(o,t,e)},void 0,!0,!0),o}}),yt({target:"Map",proto:!0,real:!0,forced:a},{find:function(t,e){var n=d(this),r=ca(n),i=Ge(t,1<arguments.length?e:void 0,3);return en(r,function(t,e){if(i(e,t,n))return en.stop(e)},void 0,!0,!0).result}}),yt({target:"Map",proto:!0,real:!0,forced:a},{findKey:function(t,e){var n=d(this),r=ca(n),i=Ge(t,1<arguments.length?e:void 0,3);return en(r,function(t,e){if(i(e,t,n))return en.stop(t)},void 0,!0,!0).result}}),yt({target:"Map",stat:!0},{groupBy:function(t,n){var r=new this;Ke(n);var i=Ke(r.has),o=Ke(r.get),a=Ke(r.set);return en(t,function(t){var e=n(t);i.call(r,e)?o.call(r,e).push(t):a.call(r,e,[t])}),r}});yt({target:"Map",proto:!0,real:!0,forced:a},{includes:function(n){return en(ca(d(this)),function(t,e){if(function(t,e){return t===e||t!=t&&e!=e}(e,n))return en.stop()},void 0,!0,!0).stopped}}),yt({target:"Map",stat:!0},{keyBy:function(t,e){var n=new this;Ke(e);var r=Ke(n.set);return en(t,function(t){r.call(n,e(t),t)}),n}}),yt({target:"Map",proto:!0,real:!0,forced:a},{keyOf:function(n){return en(ca(d(this)),function(t,e){if(e===n)return en.stop(t)},void 0,!0,!0).result}}),yt({target:"Map",proto:!0,real:!0,forced:a},{mapKeys:function(t,e){var n=d(this),r=ca(n),i=Ge(t,1<arguments.length?e:void 0,3),o=new(un(n,ht("Map"))),a=Ke(o.set);return en(r,function(t,e){a.call(o,i(e,t,n),e)},void 0,!0,!0),o}}),yt({target:"Map",proto:!0,real:!0,forced:a},{mapValues:function(t,e){var n=d(this),r=ca(n),i=Ge(t,1<arguments.length?e:void 0,3),o=new(un(n,ht("Map"))),a=Ke(o.set);return en(r,function(t,e){a.call(o,t,i(e,t,n))},void 0,!0,!0),o}}),yt({target:"Map",proto:!0,real:!0,forced:a},{merge:function(t){for(var e=d(this),n=Ke(e.set),r=0;r<arguments.length;)en(arguments[r++],n,e,!0);return e}}),yt({target:"Map",proto:!0,real:!0,forced:a},{reduce:function(n,t){var r=d(this),e=ca(r),i=arguments.length<2,o=i?void 0:t;if(Ke(n),en(e,function(t,e){o=i?(i=!1,e):n(o,e,t,r)},void 0,!0,!0),i)throw TypeError("Reduce of empty map with no initial value");return o}}),yt({target:"Map",proto:!0,real:!0,forced:a},{some:function(t,e){var n=d(this),r=ca(n),i=Ge(t,1<arguments.length?e:void 0,3);return en(r,function(t,e){if(i(e,t,n))return en.stop()},void 0,!0,!0).stopped}}),yt({target:"Map",proto:!0,real:!0,forced:a},{update:function(t,e,n){var r=d(this),i=arguments.length;Ke(e);var o=r.has(t);if(!o&&i<3)throw TypeError("Updating absent value");var a=o?r.get(t):Ke(2<i?n:void 0)(t,r);return r.set(t,e(a,t,r)),r}});function ha(t,e,n){var r,i=d(this),o=2<arguments.length?n:void 0;if("function"!=typeof e&&"function"!=typeof o)throw TypeError("At least one callback required");return i.has(t)?(r=i.get(t),"function"==typeof e&&(r=e(r),i.set(t,r))):"function"==typeof o&&(r=o(),i.set(t,r)),r}yt({target:"Map",proto:!0,real:!0,forced:a},{upsert:ha}),yt({target:"Map",proto:!0,real:!0,forced:a},{updateOrInsert:ha});$o("Set",function(e){return function(t){return e(this,arguments.length?t:void 0)}},aa),Rt.Set;yt({target:"Set",stat:!0},{from:Zo}),yt({target:"Set",stat:!0},{of:sa});yt({target:"Set",proto:!0,real:!0,forced:a},{addAll:function(){return function(){for(var t=d(this),e=Ke(t.add),n=0,r=arguments.length;n<r;n++)e.call(t,arguments[n]);return t}.apply(this,arguments)}}),yt({target:"Set",proto:!0,real:!0,forced:a},{deleteAll:function(){return ua.apply(this,arguments)}});function la(t){return Set.prototype.values.call(t)}yt({target:"Set",proto:!0,real:!0,forced:a},{every:function(t,e){var n=d(this),r=la(n),i=Ge(t,1<arguments.length?e:void 0,3);return!en(r,function(t){if(!i(t,t,n))return en.stop()},void 0,!1,!0).stopped}}),yt({target:"Set",proto:!0,real:!0,forced:a},{difference:function(t){var e=d(this),n=new(un(e,ht("Set")))(e),r=Ke(n.delete);return en(t,function(t){r.call(n,t)}),n}}),yt({target:"Set",proto:!0,real:!0,forced:a},{filter:function(t,e){var n=d(this),r=la(n),i=Ge(t,1<arguments.length?e:void 0,3),o=new(un(n,ht("Set"))),a=Ke(o.add);return en(r,function(t){i(t,t,n)&&a.call(o,t)},void 0,!1,!0),o}}),yt({target:"Set",proto:!0,real:!0,forced:a},{find:function(t,e){var n=d(this),r=la(n),i=Ge(t,1<arguments.length?e:void 0,3);return en(r,function(t){if(i(t,t,n))return en.stop(t)},void 0,!1,!0).result}}),yt({target:"Set",proto:!0,real:!0,forced:a},{intersection:function(t){var e=d(this),n=new(un(e,ht("Set"))),r=Ke(e.has),i=Ke(n.add);return en(t,function(t){r.call(e,t)&&i.call(n,t)}),n}}),yt({target:"Set",proto:!0,real:!0,forced:a},{isDisjointFrom:function(t){var e=d(this),n=Ke(e.has);return!en(t,function(t){if(!0===n.call(e,t))return en.stop()}).stopped}}),yt({target:"Set",proto:!0,real:!0,forced:a},{isSubsetOf:function(t){var e=function(t){var e=ze(t);if("function"!=typeof e)throw TypeError(String(t)+" is not iterable");return d(e.call(t))}(this),n=d(t),r=n.has;return"function"!=typeof r&&(n=new(ht("Set"))(t),r=Ke(n.has)),!en(e,function(t){if(!1===r.call(n,t))return en.stop()},void 0,!1,!0).stopped}}),yt({target:"Set",proto:!0,real:!0,forced:a},{isSupersetOf:function(t){var e=d(this),n=Ke(e.has);return!en(t,function(t){if(!1===n.call(e,t))return en.stop()}).stopped}}),yt({target:"Set",proto:!0,real:!0,forced:a},{join:function(t){var e=d(this),n=la(e),r=void 0===t?",":String(t),i=[];return en(n,i.push,i,!1,!0),i.join(r)}}),yt({target:"Set",proto:!0,real:!0,forced:a},{map:function(t,e){var n=d(this),r=la(n),i=Ge(t,1<arguments.length?e:void 0,3),o=new(un(n,ht("Set"))),a=Ke(o.add);return en(r,function(t){a.call(o,i(t,t,n))},void 0,!1,!0),o}}),yt({target:"Set",proto:!0,real:!0,forced:a},{reduce:function(e,t){var n=d(this),r=la(n),i=arguments.length<2,o=i?void 0:t;if(Ke(e),en(r,function(t){o=i?(i=!1,t):e(o,t,t,n)},void 0,!1,!0),i)throw TypeError("Reduce of empty set with no initial value");return o}}),yt({target:"Set",proto:!0,real:!0,forced:a},{some:function(t,e){var n=d(this),r=la(n),i=Ge(t,1<arguments.length?e:void 0,3);return en(r,function(t){if(i(t,t,n))return en.stop()},void 0,!1,!0).stopped}}),yt({target:"Set",proto:!0,real:!0,forced:a},{symmetricDifference:function(t){var e=d(this),n=new(un(e,ht("Set")))(e),r=Ke(n.delete),i=Ke(n.add);return en(t,function(t){r.call(n,t)||i.call(n,t)}),n}}),yt({target:"Set",proto:!0,real:!0,forced:a},{union:function(t){var e=d(this),n=new(un(e,ht("Set")))(e);return en(t,Ke(n.add),n),n}});var fa=Math.floor;yt({target:"Number",stat:!0},{isInteger:function(t){return!g(t)&&isFinite(t)&&fa(t)===t}});Rt.Number.isInteger;var pa=function(t,e){return(pa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function da(t,e){function n(){this.constructor=t}pa(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var ma=function(){return(ma=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function ya(o,a,s,u){return new(s=s||Promise)(function(t,e){function n(t){try{i(u.next(t))}catch(t){e(t)}}function r(t){try{i(u.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new s(function(t){t(e.value)}).then(n,r)}i((u=u.apply(o,a||[])).next())})}function ga(n,r){var i,o,a,t,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(a=2&e[0]?o.return:e[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,e[1])).done)return a;switch(o=0,a&&(e=[2&e[0],a.value]),e[0]){case 0:case 1:a=e;break;case 4:return s.label++,{value:e[1],done:!1};case 5:s.label++,o=e[1],e=[0];continue;case 7:e=s.ops.pop(),s.trys.pop();continue;default:if(!(a=0<(a=s.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){s=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3])){s.label=e[1];break}if(6===e[0]&&s.label<a[1]){s.label=a[1],a=e;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(e);break}a[2]&&s.ops.pop(),s.trys.pop();continue}e=r.call(n,s)}catch(t){e=[6,t],o=0}finally{i=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}function va(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function ba(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function wa(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ba(arguments[e]));return t}function _a(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}function Ta(t){for(var e=[],n=0,r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?e[n++]=i:(i<2048?e[n++]=i>>6|192:(55296==(64512&i)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&t.charCodeAt(++r)),e[n++]=i>>18|240,e[n++]=i>>12&63|128):e[n++]=i>>12|224,e[n++]=i>>6&63|128),e[n++]=63&i|128)}return e}function Ea(t){try{return Na.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}var Sa={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},Ia=function(t,e){if(!t)throw Ca(e)},Ca=function(t){return new Error("Firebase Database ("+Sa.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},Na={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray:function(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();for(var n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[],i=0;i<t.length;i+=3){var o=t[i],a=i+1<t.length,s=a?t[i+1]:0,u=i+2<t.length,c=u?t[i+2]:0,h=o>>2,l=(3&o)<<4|s>>4,f=(15&s)<<2|c>>6,p=63&c;u||(p=64,a||(f=64)),r.push(n[h],n[l],n[f],n[p])}return r.join("")},encodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(Ta(t),e)},decodeString:function(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){for(var e=[],n=0,r=0;n<t.length;){var i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(191<i&&i<224){var o=t[n++];e[r++]=String.fromCharCode((31&i)<<6|63&o)}else if(239<i&&i<365){var a=((7&i)<<18|(63&(o=t[n++]))<<12|(63&(s=t[n++]))<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(a>>10)),e[r++]=String.fromCharCode(56320+(1023&a))}else{o=t[n++];var s=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&o)<<6|63&s)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray:function(t,e){this.init_();for(var n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[],i=0;i<t.length;){var o=n[t.charAt(i++)],a=i<t.length?n[t.charAt(i)]:0,s=++i<t.length?n[t.charAt(i)]:64,u=++i<t.length?n[t.charAt(i)]:64;if(++i,null==o||null==a||null==s||null==u)throw Error();var c=o<<2|a>>4;if(r.push(c),64!==s){var h=a<<4&240|s>>2;if(r.push(h),64!==u){var l=s<<6&192|u;r.push(l)}}}return r},init_:function(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(var t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),(this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t)>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};function Aa(t){return ka(void 0,t)}function ka(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n in e)e.hasOwnProperty(n)&&(t[n]=ka(t[n],e[n]));return t}var Da=(Ra.prototype.wrapCallback=function(n){var r=this;return function(t,e){t?r.reject(t):r.resolve(e),"function"==typeof n&&(r.promise.catch(function(){}),1===n.length?n(t):n(t,e))}},Ra);function Ra(){var n=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}function Oa(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function Pa(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Oa())}function Ma(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function xa(){return!0===Sa.NODE_ADMIN}var La,Fa=(da(Ua,La=Error),Ua);function Ua(t,e){var n=La.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,Ua.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,Va.prototype.create),n}var Va=(qa.prototype.create=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=e[0]||{},i=this.service+"/"+t,o=this.errors[t],a=o?function(t,r){return t.replace(Ba,function(t,e){var n=r[e];return null!=n?n.toString():"<"+e+"?>"})}(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new Fa(i,s),c=0,h=Object.keys(r);c<h.length;c++){var l=h[c];"_"!==l.slice(-1)&&(l in u&&console.warn('Overwriting FirebaseError base field "'+l+'" can cause unexpected behavior.'),u[l]=r[l])}return u},qa);function qa(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var Ba=/\{\$([^}]+)}/g;function ja(t){return JSON.parse(t)}function Wa(t){return JSON.stringify(t)}function Ka(t){var e={},n={},r={},i="";try{var o=t.split(".");e=ja(Ea(o[0])||""),n=ja(Ea(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(t){}return{header:e,claims:n,data:r,signature:i}}function Qa(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ha(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Ga(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function za(t,e,n){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=e.call(n,t[i],i,t));return r}var Ya=(Xa.prototype.reset=function(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0},Xa.prototype.compress_=function(t,e){e=e||0;var n=this.W_;if("string"==typeof t)for(var r=0;r<16;r++)n[r]=t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|t.charCodeAt(e+3),e+=4;else for(r=0;r<16;r++)n[r]=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3],e+=4;for(r=16;r<80;r++){var i=n[r-3]^n[r-8]^n[r-14]^n[r-16];n[r]=4294967295&(i<<1|i>>>31)}var o,a,s=this.chain_[0],u=this.chain_[1],c=this.chain_[2],h=this.chain_[3],l=this.chain_[4];for(r=0;r<80;r++)a=r<40?r<20?(o=h^u&(c^h),1518500249):(o=u^c^h,1859775393):r<60?(o=u&c|h&(u|c),2400959708):(o=u^c^h,3395469782),i=(s<<5|s>>>27)+o+l+a+n[r]&4294967295,l=h,h=c,c=4294967295&(u<<30|u>>>2),u=s,s=i;this.chain_[0]=this.chain_[0]+s&4294967295,this.chain_[1]=this.chain_[1]+u&4294967295,this.chain_[2]=this.chain_[2]+c&4294967295,this.chain_[3]=this.chain_[3]+h&4294967295,this.chain_[4]=this.chain_[4]+l&4294967295},Xa.prototype.update=function(t,e){if(null!=t){void 0===e&&(e=t.length);for(var n=e-this.blockSize,r=0,i=this.buf_,o=this.inbuf_;r<e;){if(0===o)for(;r<=n;)this.compress_(t,r),r+=this.blockSize;if("string"==typeof t){for(;r<e;)if(i[o]=t.charCodeAt(r),++r,++o===this.blockSize){this.compress_(i),o=0;break}}else for(;r<e;)if(i[o]=t[r],++r,++o===this.blockSize){this.compress_(i),o=0;break}}this.inbuf_=o,this.total_+=e}},Xa.prototype.digest=function(){var t=[],e=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(var n=this.blockSize-1;56<=n;n--)this.buf_[n]=255&e,e/=256;this.compress_(this.buf_);var r=0;for(n=0;n<5;n++)for(var i=24;0<=i;i-=8)t[r]=this.chain_[n]>>i&255,++r;return t},Xa);function Xa(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(var t=1;t<this.blockSize;++t)this.pad_[t]=0;this.reset()}function Ja(t,e){var n=new $a(t,e);return n.subscribe.bind(n)}var $a=(Za.prototype.next=function(e){this.forEachObserver(function(t){t.next(e)})},Za.prototype.error=function(e){this.forEachObserver(function(t){t.error(e)}),this.close(e)},Za.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},Za.prototype.subscribe=function(t,e,n){var r,i=this;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=0,r=e;n<r.length;n++){var i=r[n];if(i in t&&"function"==typeof t[i])return!0}return!1}(t,["next","error","complete"])?t:{next:t,error:e,complete:n}).next&&(r.next=ts),void 0===r.error&&(r.error=ts),void 0===r.complete&&(r.complete=ts);var o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(function(){try{i.finalError?r.error(i.finalError):r.complete()}catch(t){}}),this.observers.push(r),o},Za.prototype.unsubscribeOne=function(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))},Za.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},Za.prototype.sendOne=function(t,e){var n=this;this.task.then(function(){if(void 0!==n.observers&&void 0!==n.observers[t])try{e(n.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}})},Za.prototype.close=function(t){var e=this;this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then(function(){e.observers=void 0,e.onNoObservers=void 0}))},Za);function Za(t,e){var n=this;this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then(function(){t(n)}).catch(function(t){n.error(t)})}function ts(){}function es(t,e,n,r){var i;if(r<e?i="at least "+e:n<r&&(i=0===n?"none":"no more than "+n),i)throw new Error(t+" failed: Was called with "+r+(1===r?" argument.":" arguments.")+" Expects "+i+".")}function ns(t,e,n){var r="";switch(e){case 1:r=n?"first":"First";break;case 2:r=n?"second":"Second";break;case 3:r=n?"third":"Third";break;case 4:r=n?"fourth":"Fourth";break;default:throw new Error("errorPrefix called with argumentNumber > 4.  Need to update it?")}var i=t+" failed: ";return i+=r+" argument "}function rs(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(ns(t,e,r)+"must be a valid function.")}function is(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(ns(t,e,r)+"must be a valid context object.")}function os(t){for(var e=0,n=0;n<t.length;n++){var r=t.charCodeAt(n);r<128?e++:r<2048?e+=2:55296<=r&&r<=56319?(e+=4,n++):e+=3}return e}var as=(ss.prototype.setInstantiationMode=function(t){return this.instantiationMode=t,this},ss.prototype.setMultipleInstances=function(t){return this.multipleInstances=t,this},ss.prototype.setServiceProps=function(t){return this.serviceProps=t,this},ss);function ss(t,e,n){this.name=t,this.instanceFactory=e,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY"}var us="[DEFAULT]",cs=(hs.prototype.get=function(t){void 0===t&&(t=us);var e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){var n=new Da;this.instancesDeferred.set(e,n);try{var r=this.getOrInitializeService(e);r&&n.resolve(r)}catch(t){}}return this.instancesDeferred.get(e).promise},hs.prototype.getImmediate=function(t){var e=ma({identifier:us,optional:!1},t),n=e.identifier,r=e.optional,i=this.normalizeInstanceIdentifier(n);try{var o=this.getOrInitializeService(i);if(o)return o;if(r)return null;throw Error("Service "+this.name+" is not available")}catch(t){if(r)return null;throw t}},hs.prototype.getComponent=function(){return this.component},hs.prototype.setComponent=function(t){var e,n;if(t.name!==this.name)throw Error("Mismatching Component "+t.name+" for Provider "+this.name+".");if(this.component)throw Error("Component for "+this.name+" has already been provided");if(function(t){return"EAGER"===t.instantiationMode}(this.component=t))try{this.getOrInitializeService(us)}catch(t){}try{for(var r=va(this.instancesDeferred.entries()),i=r.next();!i.done;i=r.next()){var o=ba(i.value,2),a=o[0],s=o[1],u=this.normalizeInstanceIdentifier(a);try{var c=this.getOrInitializeService(u);s.resolve(c)}catch(t){}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}},hs.prototype.clearInstance=function(t){void 0===t&&(t=us),this.instancesDeferred.delete(t),this.instances.delete(t)},hs.prototype.delete=function(){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return e=Array.from(this.instances.values()),[4,Promise.all(e.filter(function(t){return"INTERNAL"in t}).map(function(t){return t.INTERNAL.delete()}))];case 1:return t.sent(),[2]}})})},hs.prototype.isComponentSet=function(){return null!=this.component},hs.prototype.getOrInitializeService=function(t){var e=this.instances.get(t);return!e&&this.component&&(e=this.component.instanceFactory(this.container,function(t){return t===us?void 0:t}(t)),this.instances.set(t,e)),e||null},hs.prototype.normalizeInstanceIdentifier=function(t){return this.component?this.component.multipleInstances?t:us:t},hs);function hs(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map}var ls,fs,ps=(ds.prototype.addComponent=function(t){var e=this.getProvider(t.name);if(e.isComponentSet())throw new Error("Component "+t.name+" has already been registered with "+this.name);e.setComponent(t)},ds.prototype.addOrOverwriteComponent=function(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)},ds.prototype.getProvider=function(t){if(this.providers.has(t))return this.providers.get(t);var e=new cs(t,this);return this.providers.set(t,e),e},ds.prototype.getProviders=function(){return Array.from(this.providers.values())},ds);function ds(t){this.name=t,this.providers=new Map}function ms(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(fs=ls=ls||{})[fs.DEBUG=0]="DEBUG",fs[fs.VERBOSE=1]="VERBOSE",fs[fs.INFO=2]="INFO",fs[fs.WARN=3]="WARN",fs[fs.ERROR=4]="ERROR",fs[fs.SILENT=5]="SILENT";function ys(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(!(e<t.logLevel)){var i=(new Date).toISOString();switch(e){case ls.DEBUG:case ls.VERBOSE:console.log.apply(console,ms(["["+i+"]  "+t.name+":"],n));break;case ls.INFO:console.info.apply(console,ms(["["+i+"]  "+t.name+":"],n));break;case ls.WARN:console.warn.apply(console,ms(["["+i+"]  "+t.name+":"],n));break;case ls.ERROR:console.error.apply(console,ms(["["+i+"]  "+t.name+":"],n));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+e+")")}}}var gs,vs=ls.INFO,bs=(Object.defineProperty(ws.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in ls))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(ws.prototype,"logHandler",{get:function(){return this._logHandler},set:function(t){if("function"!=typeof t)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=t},enumerable:!0,configurable:!0}),ws.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,ms([this,ls.DEBUG],t))},ws.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,ms([this,ls.VERBOSE],t))},ws.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,ms([this,ls.INFO],t))},ws.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,ms([this,ls.WARN],t))},ws.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,ms([this,ls.ERROR],t))},ws);function ws(t){this.name=t,this._logLevel=vs,this._logHandler=ys}var _s,Ts=((gs={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",gs["bad-app-name"]="Illegal App name: '{$appName}",gs["duplicate-app"]="Firebase App named '{$appName}' already exists",gs["app-deleted"]="Firebase App named '{$appName}' already deleted",gs["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",gs),Es=new Va("app","Firebase",Ts),Ss="@firebase/app",Is="[DEFAULT]",Cs=((_s={})[Ss]="fire-core",_s["@firebase/analytics"]="fire-analytics",_s["@firebase/auth"]="fire-auth",_s["@firebase/database"]="fire-rtdb",_s["@firebase/functions"]="fire-fn",_s["@firebase/installations"]="fire-iid",_s["@firebase/messaging"]="fire-fcm",_s["@firebase/performance"]="fire-perf",_s["@firebase/remote-config"]="fire-rc",_s["@firebase/storage"]="fire-gcs",_s["@firebase/firestore"]="fire-fst",_s["fire-js"]="fire-js",_s["firebase-wrapper"]="fire-js-all",_s),Ns=new bs("@firebase/app"),As=(Object.defineProperty(ks.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(t){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=t},enumerable:!0,configurable:!0}),Object.defineProperty(ks.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(ks.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),ks.prototype.delete=function(){var e=this;return new Promise(function(t){e.checkDestroyed_(),t()}).then(function(){return e.firebase_.INTERNAL.removeApp(e.name_),Promise.all(e.container.getProviders().map(function(t){return t.delete()}))}).then(function(){e.isDeleted_=!0})},ks.prototype._getService=function(t,e){return void 0===e&&(e=Is),this.checkDestroyed_(),this.container.getProvider(t).getImmediate({identifier:e})},ks.prototype._removeServiceInstance=function(t,e){void 0===e&&(e=Is),this.container.getProvider(t).clearInstance(e)},ks.prototype._addComponent=function(e){try{this.container.addComponent(e)}catch(t){Ns.debug("Component "+e.name+" failed to register with FirebaseApp "+this.name,t)}},ks.prototype._addOrOverwriteComponent=function(t){this.container.addOrOverwriteComponent(t)},ks.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw Es.create("app-deleted",{appName:this.name_})},ks);function ks(t,e,n){var r,i,o=this;this.firebase_=n,this.isDeleted_=!1,this.name_=e.name,this.automaticDataCollectionEnabled_=e.automaticDataCollectionEnabled||!1,this.options_=Aa(t),this.container=new ps(e.name),this._addComponent(new as("app",function(){return o},"PUBLIC"));try{for(var a=va(this.firebase_.INTERNAL.components.values()),s=a.next();!s.done;s=a.next()){var u=s.value;this._addComponent(u)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}}As.prototype.name&&As.prototype.options||As.prototype.delete||console.log("dc");var Ds="7.6.0";function Rs(u){var c={},h=new Map,l={__esModule:!0,initializeApp:function(t,e){void 0===e&&(e={});if("object"!=typeof e||null===e){e={name:e}}var n=e;void 0===n.name&&(n.name=Is);var r=n.name;if("string"!=typeof r||!r)throw Es.create("bad-app-name",{appName:String(r)});if(Qa(c,r))throw Es.create("duplicate-app",{appName:r});var i=new u(t,n,l);return c[r]=i},app:f,registerVersion:function(t,e,n){var r,i=null!==(r=Cs[t])&&void 0!==r?r:t;n&&(i+="-"+n);var o=i.match(/\s|\//),a=e.match(/\s|\//);if(o||a){var s=['Unable to register library "'+i+'" with version "'+e+'":'];return o&&s.push('library name "'+i+'" contains illegal characters (whitespace or "/")'),o&&a&&s.push("and"),a&&s.push('version name "'+e+'" contains illegal characters (whitespace or "/")'),void Ns.warn(s.join(" "))}p(new as(i+"-version",function(){return{library:i,version:e}},"VERSION"))},apps:null,SDK_VERSION:Ds,INTERNAL:{registerComponent:p,removeApp:function(t){delete c[t]},components:h,useAsService:function(t,e){return"serverAuth"!==e?e:null}}};function f(t){if(!Qa(c,t=t||Is))throw Es.create("no-app",{appName:t});return c[t]}function p(n){var e,t,r=n.name;if(h.has(r))return Ns.debug("There were multiple attempts to register component "+r+"."),"PUBLIC"===n.type?l[r]:null;if(h.set(r,n),"PUBLIC"===n.type){var i=function(t){if(void 0===t&&(t=f()),"function"!=typeof t[r])throw Es.create("invalid-app-argument",{appName:r});return t[r]()};void 0!==n.serviceProps&&ka(i,n.serviceProps),l[r]=i,u.prototype[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._getService.bind(this,r).apply(this,n.multipleInstances?t:[])}}try{for(var o=va(Object.keys(c)),a=o.next();!a.done;a=o.next()){var s=a.value;c[s]._addComponent(n)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return"PUBLIC"===n.type?l[r]:null}return l.default=l,Object.defineProperty(l,"apps",{get:function(){return Object.keys(c).map(function(t){return c[t]})}}),f.App=u,l}var Os=function t(){var e=Rs(As);return e.INTERNAL=ma(ma({},e.INTERNAL),{createFirebaseNamespace:t,extendNamespace:function(t){ka(e,t)},createSubscribe:Ja,ErrorFactory:Va,deepExtend:ka}),e}(),Ps=(Ms.prototype.getPlatformInfoString=function(){return this.container.getProviders().map(function(t){if(function(t){var e,n=t.getComponent();return"VERSION"===(null===(e=n)||void 0===e?void 0:e.type)}(t)){var e=t.getImmediate();return e.library+"/"+e.version}return null}).filter(function(t){return t}).join(" ")},Ms);function Ms(t){this.container=t}if("object"==typeof self&&self.self===self&&void 0!==self.firebase){Ns.warn("\n    Warning: Firebase is already defined in the global scope. Please make sure\n    Firebase library is only loaded once.\n  ");var xs=self.firebase.SDK_VERSION;xs&&0<=xs.indexOf("LITE")&&Ns.warn("\n    Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n    You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n    ")}var Ls=Os.initializeApp;Os.initializeApp=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(){try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(t){return!1}}()&&Ns.warn('\n      Warning: This is a browser-targeted Firebase bundle but it appears it is being\n      run in a Node environment.  If running in a Node environment, make sure you\n      are using the bundle specified by the "main" field in package.json.\n      \n      If you are using Webpack, you can specify "main" as the first item in\n      "resolve.mainFields":\n      https://webpack.js.org/configuration/resolve/#resolvemainfields\n      \n      If using Rollup, use the rollup-plugin-node-resolve plugin and specify "main"\n      as the first item in "mainFields", e.g. [\'main\', \'module\'].\n      https://github.com/rollup/rollup-plugin-node-resolve\n      '),Ls.apply(void 0,t)};var Fs,Us,fl=Os;(Fs=fl).INTERNAL.registerComponent(new as("platform-logger",function(t){return new Ps(t)},"PRIVATE")),Fs.registerVersion(Ss,"0.5.0",Us),Fs.registerVersion("fire-js","");fl.registerVersion("firebase","7.6.0","app");(function(){var t,o="function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){t!=Array.prototype&&t!=Object.prototype&&(t[e]=n.value)},a="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function c(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):{next:function(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}}(t)}}!function(t,e){if(e){var n=a;t=t.split(".");for(var r=0;r<t.length-1;r++){var i=t[r];i in n||(n[i]={}),n=n[i]}(e=e(r=n[t=t[t.length-1]]))!=r&&null!=e&&o(n,t,{configurable:!0,writable:!0,value:e})}}("Promise",function(t){function s(t){this.b=0,this.c=void 0,this.a=[];var e=this.f();try{t(e.resolve,e.reject)}catch(t){e.reject(t)}}function e(){this.a=null}function u(e){return e instanceof s?e:new s(function(t){t(e)})}if(t)return t;e.prototype.b=function(t){if(null==this.a){this.a=[];var e=this;this.c(function(){e.g()})}this.a.push(t)};var n=a.setTimeout;e.prototype.c=function(t){n(t,0)},e.prototype.g=function(){for(;this.a&&this.a.length;){var t=this.a;this.a=[];for(var e=0;e<t.length;++e){var n=t[e];t[e]=null;try{n()}catch(t){this.f(t)}}}this.a=null},e.prototype.f=function(t){this.c(function(){throw t})},s.prototype.f=function(){function t(e){return function(t){r||(r=!0,e.call(n,t))}}var n=this,r=!1;return{resolve:t(this.m),reject:t(this.g)}},s.prototype.m=function(t){if(t===this)this.g(new TypeError("A Promise cannot resolve to itself"));else if(t instanceof s)this.o(t);else{t:switch(typeof t){case"object":var e=null!=t;break t;case"function":e=!0;break t;default:e=!1}e?this.u(t):this.h(t)}},s.prototype.u=function(t){var e=void 0;try{e=t.then}catch(t){return void this.g(t)}"function"==typeof e?this.v(e,t):this.h(t)},s.prototype.g=function(t){this.i(2,t)},s.prototype.h=function(t){this.i(1,t)},s.prototype.i=function(t,e){if(0!=this.b)throw Error("Cannot settle("+t+", "+e+"): Promise already settled in state"+this.b);this.b=t,this.c=e,this.l()},s.prototype.l=function(){if(null!=this.a){for(var t=0;t<this.a.length;++t)i.b(this.a[t]);this.a=null}};var i=new e;return s.prototype.o=function(t){var e=this.f();t.La(e.resolve,e.reject)},s.prototype.v=function(t,e){var n=this.f();try{t.call(e,n.resolve,n.reject)}catch(t){n.reject(t)}},s.prototype.then=function(t,e){function n(e,t){return"function"==typeof e?function(t){try{r(e(t))}catch(t){i(t)}}:t}var r,i,o=new s(function(t,e){r=t,i=e});return this.La(n(t,r),n(e,i)),o},s.prototype.catch=function(t){return this.then(void 0,t)},s.prototype.La=function(t,e){function n(){switch(r.b){case 1:t(r.c);break;case 2:e(r.c);break;default:throw Error("Unexpected state: "+r.b)}}var r=this;null==this.a?i.b(n):this.a.push(n)},s.resolve=u,s.reject=function(n){return new s(function(t,e){e(n)})},s.race=function(i){return new s(function(t,e){for(var n=c(i),r=n.next();!r.done;r=n.next())u(r.value).La(t,e)})},s.all=function(t){var o=c(t),a=o.next();return a.done?u([]):new s(function(n,t){function e(e){return function(t){r[e]=t,0==--i&&n(r)}}for(var r=[],i=0;r.push(void 0),i++,u(a.value).La(e(r.length-1),t),!(a=o.next()).done;);})},s});var u=u||{},l=this||self;function h(t){return"string"==typeof t}function n(t){return"boolean"==typeof t}var s=/^[\w+/_-]+[=]{0,2}$/,f=null;function p(){}function r(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function i(t){return null===t}function d(t){return"array"==r(t)}function m(t){var e=r(t);return"array"==e||"object"==e&&"number"==typeof t.length}function y(t){return"function"==r(t)}function g(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var e="closure_uid_"+(1e9*Math.random()>>>0),v=0;function b(t,e,n){return t.call.apply(t.bind,arguments)}function w(e,n,t){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var t=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(t,r),e.apply(n,t)}}return function(){return e.apply(n,arguments)}}function _(t,e,n){return(_=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?b:w).apply(null,arguments)}function T(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}var E=Date.now||function(){return+new Date};function S(t,o){function e(){}e.prototype=o.prototype,t.qb=o.prototype,t.prototype=new e,(t.prototype.constructor=t).gd=function(t,e,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return o.prototype[e].apply(t,r)}}function I(t){if(!t)return!1;try{return!!t.$goog_Thenable}catch(t){return!1}}function C(t){if(Error.captureStackTrace)Error.captureStackTrace(this,C);else{var e=Error().stack;e&&(this.stack=e)}t&&(this.message=String(t))}function N(t,e){for(var n="",r=(t=t.split("%s")).length-1,i=0;i<r;i++)n+=t[i]+(i<e.length?e[i]:"%s");C.call(this,n+t[r])}function A(t,e){throw new N("Failure"+(t?": "+t:""),Array.prototype.slice.call(arguments,1))}function k(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function D(t,e){t.f(e),t.b<100&&(t.b++,e.next=t.a,t.a=e)}function R(){this.b=this.a=null}S(C,Error),C.prototype.name="CustomError",S(N,C),N.prototype.name="AssertionError",k.prototype.get=function(){if(0<this.b){this.b--;var t=this.a;this.a=t.next,t.next=null}else t=this.c();return t};var O=new k(function(){return new P},function(t){t.reset()});function P(){this.next=this.b=this.a=null}function M(t,e){t:{try{var n=t&&t.ownerDocument,r=n&&(n.defaultView||n.parentWindow);if((r=r||l).Element&&r.Location){var i=r;break t}}catch(t){}i=null}if(i&&void 0!==i[e]&&(!t||!(t instanceof i[e])&&(t instanceof i.Location||t instanceof i.Element))){if(g(t))try{var o=t.constructor.displayName||t.constructor.name||Object.prototype.toString.call(t)}catch(t){o="<object could not be stringified>"}else o=void 0===t?"undefined":null===t?"null":typeof t;A("Argument is not a %s (or a non-Element, non-Location mock); got: %s",e,o)}}R.prototype.add=function(t,e){var n=O.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},P.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null},P.prototype.reset=function(){this.next=this.b=this.a=null};var x=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(h(t))return h(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},L=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=h(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};var F=Array.prototype.map?function(t,e){return Array.prototype.map.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=Array(n),i=h(t)?t.split(""):t,o=0;o<n;o++)o in i&&(r[o]=e.call(void 0,i[o],o,t));return r},U=Array.prototype.some?function(t,e){return Array.prototype.some.call(t,e,void 0)}:function(t,e){for(var n=t.length,r=h(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t))return!0;return!1};function V(t,e){return 0<=x(t,e)}function q(t,e){var n;return(n=0<=(e=x(t,e)))&&Array.prototype.splice.call(t,e,1),n}function B(n,r){!function(t,e){for(var n=h(t)?t.split(""):t,r=t.length-1;0<=r;--r)r in n&&e.call(void 0,n[r],r,t)}(n,function(t,e){r.call(void 0,t,e,n)&&1==Array.prototype.splice.call(n,e,1).length&&0})}function j(t){return Array.prototype.concat.apply([],arguments)}function W(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function K(t,e){for(var n in t)e.call(void 0,t[n],n,t)}function Q(t){for(var e in t)return!1;return!0}function H(t){var e,n={};for(e in t)n[e]=t[e];return n}var G="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function z(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var o=0;o<G.length;o++)n=G[o],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function Y(t,e){this.a=t===$&&e||"",this.b=J}function X(t){return t instanceof Y&&t.constructor===Y&&t.b===J?t.a:(A("expected object of type Const, got '"+t+"'"),"type_error:Const")}Y.prototype.qa=!0,Y.prototype.pa=function(){return this.a},Y.prototype.toString=function(){return"Const{"+this.a+"}"};var J={},$={},Z=new Y($,"");function tt(){this.a="",this.b=ot}function et(t){return t instanceof tt&&t.constructor===tt&&t.b===ot?t.a:(A("expected object of type TrustedResourceUrl, got '"+t+"' of type "+r(t)),"type_error:TrustedResourceUrl")}function nt(t,n){var r=X(t);if(!it.test(r))throw Error("Invalid TrustedResourceUrl format: "+r);return at(t=r.replace(rt,function(t,e){if(!Object.prototype.hasOwnProperty.call(n,e))throw Error('Found marker, "'+e+'", in format string, "'+r+'", but no valid label mapping found in args: '+JSON.stringify(n));return(t=n[e])instanceof Y?X(t):encodeURIComponent(String(t))}))}tt.prototype.qa=!0,tt.prototype.pa=function(){return this.a.toString()},tt.prototype.toString=function(){return"TrustedResourceUrl{"+this.a+"}"};var rt=/%{(\w+)}/g,it=/^((https:)?\/\/[0-9a-z.:[\]-]+\/|\/[^/\\]|[^:/\\%]+\/|[^:/\\%]*[?#]|about:blank#)/i,ot={};function at(t){var e=new tt;return e.a=t,e}var st=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]},ut=/&/g,ct=/</g,ht=/>/g,lt=/"/g,ft=/'/g,pt=/\x00/g,dt=/[\x00&<>"']/;function mt(t,e){return-1!=t.indexOf(e)}function yt(t,e){return t<e?-1:e<t?1:0}function gt(){this.a="",this.b=Tt}function vt(t){return t instanceof gt&&t.constructor===gt&&t.b===Tt?t.a:(A("expected object of type SafeUrl, got '"+t+"' of type "+r(t)),"type_error:SafeUrl")}gt.prototype.qa=!0,gt.prototype.pa=function(){return this.a.toString()},gt.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};var bt=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;function wt(t){return t instanceof gt?t:(t="object"==typeof t&&t.qa?t.pa():String(t),bt.test(t)||(t="about:invalid#zClosurez"),Et(t))}var _t,Tt={};function Et(t){var e=new gt;return e.a=t,e}Et("about:blank");t:{var St=l.navigator;if(St){var It=St.userAgent;if(It){_t=It;break t}}_t=""}function Ct(t){return mt(_t,t)}function Nt(){this.a="",this.b=kt}function At(t){return t instanceof Nt&&t.constructor===Nt&&t.b===kt?t.a:(A("expected object of type SafeHtml, got '"+t+"' of type "+r(t)),"type_error:SafeHtml")}Nt.prototype.qa=!0,Nt.prototype.pa=function(){return this.a.toString()},Nt.prototype.toString=function(){return"SafeHtml{"+this.a+"}"};var kt={};function Dt(t){var e=new Nt;return e.a=t,e}Dt("<!DOCTYPE html>");var Rt,Ot,Pt=Dt("");function Mt(t,e){for(var n=t.split("%s"),r="",i=Array.prototype.slice.call(arguments,1);i.length&&1<n.length;)r+=n.shift()+i.shift();return r+n.join("%s")}function xt(t){return dt.test(t)&&(-1!=t.indexOf("&")&&(t=t.replace(ut,"&amp;")),-1!=t.indexOf("<")&&(t=t.replace(ct,"&lt;")),-1!=t.indexOf(">")&&(t=t.replace(ht,"&gt;")),-1!=t.indexOf('"')&&(t=t.replace(lt,"&quot;")),-1!=t.indexOf("'")&&(t=t.replace(ft,"&#39;")),-1!=t.indexOf("\0")&&(t=t.replace(pt,"&#0;"))),t}function Lt(t){l.setTimeout(function(){throw t},0)}function Ft(){var t=l.MessageChannel;if(void 0===t&&"undefined"!=typeof window&&window.postMessage&&window.addEventListener&&!Ct("Presto")&&(t=function(){var t=document.createElement("IFRAME");t.style.display="none",function(t){var e=at(X(Z));M(t,"HTMLIFrameElement"),t.src=et(e).toString()}(t),document.documentElement.appendChild(t);var e=t.contentWindow;(t=e.document).open(),t.write(At(Pt)),t.close();var n="callImmediate"+Math.random(),r="file:"==e.location.protocol?"*":e.location.protocol+"//"+e.location.host;t=_(function(t){"*"!=r&&t.origin!=r||t.data!=n||this.port1.onmessage()},this),e.addEventListener("message",t,!1),this.port1={},this.port2={postMessage:function(){e.postMessage(n,r)}}}),void 0===t||Ct("Trident")||Ct("MSIE"))return"undefined"!=typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(t){var e=document.createElement("SCRIPT");e.onreadystatechange=function(){e.onreadystatechange=null,e.parentNode.removeChild(e),e=null,t(),t=null},document.documentElement.appendChild(e)}:function(t){l.setTimeout(t,0)};var e=new t,n={},r=n;return e.port1.onmessage=function(){if(void 0!==n.next){var t=(n=n.next).yb;n.yb=null,t()}},function(t){r.next={yb:t},r=r.next,e.port2.postMessage(0)}}function Ut(t,e){Ot||function(){if(l.Promise&&l.Promise.resolve){var t=l.Promise.resolve(void 0);Ot=function(){t.then(Bt)}}else Ot=function(){var t=Bt;!y(l.setImmediate)||l.Window&&l.Window.prototype&&!Ct("Edge")&&l.Window.prototype.setImmediate==l.setImmediate?(Rt=Rt||Ft())(t):l.setImmediate(t)}}(),Vt||(Ot(),Vt=!0),qt.add(t,e)}Dt("<br>");var Vt=!1,qt=new R;function Bt(){for(var t;n=e=void 0,n=null,(e=qt).a&&(n=e.a,e.a=e.a.next,e.a||(e.b=null),n.next=null),t=n;){try{t.a.call(t.b)}catch(t){Lt(t)}D(O,t)}var e,n;Vt=!1}function jt(t,e){if(this.a=Wt,this.i=void 0,this.f=this.b=this.c=null,this.g=this.h=!1,t!=p)try{var n=this;t.call(e,function(t){ee(n,Kt,t)},function(t){if(!(t instanceof ue))try{if(t instanceof Error)throw t;throw Error("Promise rejected.")}catch(t){}ee(n,Qt,t)})}catch(t){ee(this,Qt,t)}}var Wt=0,Kt=2,Qt=3;function Ht(){this.next=this.f=this.b=this.g=this.a=null,this.c=!1}Ht.prototype.reset=function(){this.f=this.b=this.g=this.a=null,this.c=!1};var Gt=new k(function(){return new Ht},function(t){t.reset()});function zt(t,e,n){var r=Gt.get();return r.g=t,r.b=e,r.f=n,r}function Yt(t){if(t instanceof jt)return t;var e=new jt(p);return ee(e,Kt,t),e}function Xt(n){return new jt(function(t,e){e(n)})}function Jt(t,e,n){ne(t,e,n,null)||Ut(T(e,t))}function $t(n){return new jt(function(r){var i=n.length,o=[];if(i)for(var t=function(t,e,n){i--,o[t]=e?{Gb:!0,value:n}:{Gb:!1,reason:n},0==i&&r(o)},e=0;e<n.length;e++)Jt(n[e],T(t,e,!0),T(t,e,!1));else r(o)})}function Zt(t,e){t.b||t.a!=Kt&&t.a!=Qt||re(t),t.f?t.f.next=e:t.b=e,t.f=e}function te(t,i,o,a){var e=zt(null,null,null);return e.a=new jt(function(n,r){e.g=i?function(t){try{var e=i.call(a,t);n(e)}catch(t){r(t)}}:n,e.b=o?function(t){try{var e=o.call(a,t);void 0===e&&t instanceof ue?r(t):n(e)}catch(t){r(t)}}:r}),Zt(e.a.c=t,e),e.a}function ee(t,e,n){t.a==Wt&&(t===n&&(e=Qt,n=new TypeError("Promise cannot resolve to itself")),t.a=1,ne(n,t.Oc,t.Pc,t)||(t.i=n,t.a=e,t.c=null,re(t),e!=Qt||n instanceof ue||function(t,e){t.g=!0,Ut(function(){t.g&&se.call(null,e)})}(t,n)))}function ne(t,e,n,r){if(t instanceof jt)return Zt(t,zt(e||p,n||null,r)),!0;if(I(t))return t.then(e,n,r),!0;if(g(t))try{var i=t.then;if(y(i))return function(t,e,n,r,i){function o(t){a||(a=!0,r.call(i,t))}var a=!1;try{e.call(t,function(t){a||(a=!0,n.call(i,t))},o)}catch(t){o(t)}}(t,i,e,n,r),!0}catch(t){return n.call(r,t),!0}return!1}function re(t){t.h||(t.h=!0,Ut(t.Zb,t))}function ie(t){var e=null;return t.b&&(e=t.b,t.b=e.next,e.next=null),t.b||(t.f=null),e}function oe(t,e,n,r){if(n==Qt&&e.b&&!e.c)for(;t&&t.g;t=t.c)t.g=!1;if(e.a)e.a.c=null,ae(e,n,r);else try{e.c?e.g.call(e.f):ae(e,n,r)}catch(t){se.call(null,t)}D(Gt,e)}function ae(t,e,n){e==Kt?t.g.call(t.f,n):t.b&&t.b.call(t.f,n)}jt.prototype.then=function(t,e,n){return te(this,y(t)?t:null,y(e)?e:null,n)},jt.prototype.$goog_Thenable=!0,(t=jt.prototype).ka=function(t,e){return(t=zt(t,t,e)).c=!0,Zt(this,t),this},t.s=function(t,e){return te(this,null,t,e)},t.cancel=function(t){this.a==Wt&&Ut(function(){!function t(e,n){if(e.a==Wt)if(e.c){var r=e.c;if(r.b){for(var i=0,o=null,a=null,s=r.b;s&&(s.c||(i++,s.a==e&&(o=s),!(o&&1<i)));s=s.next)o||(a=s);o&&(r.a==Wt&&1==i?t(r,n):(a?((i=a).next==r.f&&(r.f=i),i.next=i.next.next):ie(r),oe(r,o,Qt,n)))}e.c=null}else ee(e,Qt,n)}(this,new ue(t))},this)},t.Oc=function(t){this.a=Wt,ee(this,Kt,t)},t.Pc=function(t){this.a=Wt,ee(this,Qt,t)},t.Zb=function(){for(var t;t=ie(this);)oe(this,t,this.a,this.i);this.h=!1};var se=Lt;function ue(t){C.call(this,t)}function ce(){this.va=this.va,this.la=this.la}S(ue,C);var he=0;function le(t){if(!t.va&&(t.va=!0,t.za(),0!=he))t[e]||(t[e]=++v)}function fe(t){return fe[" "](t),t}ce.prototype.va=!(ue.prototype.name="cancel"),ce.prototype.za=function(){if(this.la)for(;this.la.length;)this.la.shift()()},fe[" "]=p;var pe,de,me=Ct("Opera"),ye=Ct("Trident")||Ct("MSIE"),ge=Ct("Edge"),ve=ge||ye,be=Ct("Gecko")&&!(mt(_t.toLowerCase(),"webkit")&&!Ct("Edge"))&&!(Ct("Trident")||Ct("MSIE"))&&!Ct("Edge"),we=mt(_t.toLowerCase(),"webkit")&&!Ct("Edge");function _e(){var t=l.document;return t?t.documentMode:void 0}t:{var Te="",Ee=(de=_t,be?/rv:([^\);]+)(\)|;)/.exec(de):ge?/Edge\/([\d\.]+)/.exec(de):ye?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(de):we?/WebKit\/(\S+)/.exec(de):me?/(?:Version)[ \/]?(\S+)/.exec(de):void 0);if(Ee&&(Te=Ee?Ee[1]:""),ye){var Se=_e();if(null!=Se&&Se>parseFloat(Te)){pe=String(Se);break t}}pe=Te}var Ie,Ce={};function Ne(s){return function(t,e){var n=Ce;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(s,function(){for(var t=0,e=st(String(pe)).split("."),n=st(String(s)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i<r;i++){var o=e[i]||"",a=n[i]||"";do{if(o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],0==o[0].length&&0==a[0].length)break;t=yt(0==o[1].length?0:parseInt(o[1],10),0==a[1].length?0:parseInt(a[1],10))||yt(0==o[2].length,0==a[2].length)||yt(o[2],a[2]),o=o[3],a=a[3]}while(0==t)}return 0<=t})}Ie=l.document&&ye?_e():void 0;var Ae=Object.freeze||function(t){return t},ke=!ye||9<=Number(Ie),De=ye&&!Ne("9"),Re=function(){if(!l.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{l.addEventListener("test",p,e),l.removeEventListener("test",p,e)}catch(t){}return t}();function Oe(t,e){this.type=t,this.b=this.target=e,this.Mb=!0}function Pe(t,e){if(Oe.call(this,t?t.type:""),this.relatedTarget=this.b=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.pointerId=0,this.pointerType="",this.a=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.b=e,e=t.relatedTarget){if(be){t:{try{fe(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==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=h(t.pointerType)?t.pointerType:Me[t.pointerType]||"",(this.a=t).defaultPrevented&&this.preventDefault()}}Oe.prototype.preventDefault=function(){this.Mb=!1},S(Pe,Oe);var Me=Ae({2:"touch",3:"pen",4:"mouse"});Pe.prototype.preventDefault=function(){Pe.qb.preventDefault.call(this);var t=this.a;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,De)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}},Pe.prototype.f=function(){return this.a};var xe="closure_listenable_"+(1e6*Math.random()|0),Le=0;function Fe(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.Pa=i,this.key=++Le,this.ta=this.Ka=!1}function Ue(t){t.ta=!0,t.listener=null,t.proxy=null,t.src=null,t.Pa=null}function Ve(t){this.src=t,this.a={},this.b=0}function qe(t,e){var n=e.type;n in t.a&&q(t.a[n],e)&&(Ue(e),0==t.a[n].length&&(delete t.a[n],t.b--))}function Be(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.ta&&o.listener==e&&o.capture==!!n&&o.Pa==r)return i}return-1}Ve.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=Be(t,e,r,i);return-1<a?(e=t[a],n||(e.Ka=!1)):((e=new Fe(e,this.src,o,!!r,i)).Ka=n,t.push(e)),e};var je="closure_lm_"+(1e6*Math.random()|0),We={};function Ke(t,e,n,r,i){if(r&&r.once)He(t,e,n,r,i);else if(d(e))for(var o=0;o<e.length;o++)Ke(t,e[o],n,r,i);else n=en(n),t&&t[xe]?rn(t,e,n,g(r)?!!r.capture:!!r,i):Qe(t,e,n,!1,r,i)}function Qe(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=g(i)?!!i.capture:!!i,s=Ze(t);if(s||(t[je]=s=new Ve(t)),!(n=s.add(e,n,r,a,o)).proxy)if(r=function(){var e=$e,n=ke?function(t){return e.call(n.src,n.listener,t)}:function(t){if(!(t=e.call(n.src,n.listener,t)))return t};return n}(),(n.proxy=r).src=t,r.listener=n,t.addEventListener)Re||(i=a),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Ye(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}}function He(t,e,n,r,i){if(d(e))for(var o=0;o<e.length;o++)He(t,e[o],n,r,i);else n=en(n),t&&t[xe]?on(t,e,n,g(r)?!!r.capture:!!r,i):Qe(t,e,n,!0,r,i)}function Ge(t,e,n,r,i){if(d(e))for(var o=0;o<e.length;o++)Ge(t,e[o],n,r,i);else r=g(r)?!!r.capture:!!r,n=en(n),t&&t[xe]?(t=t.u,(e=String(e).toString())in t.a&&(-1<(n=Be(o=t.a[e],n,r,i))&&(Ue(o[n]),Array.prototype.splice.call(o,n,1),0==o.length&&(delete t.a[e],t.b--)))):(t=t&&Ze(t))&&(e=t.a[e.toString()],t=-1,e&&(t=Be(e,n,r,i)),(n=-1<t?e[t]:null)&&ze(n))}function ze(t){if("number"!=typeof t&&t&&!t.ta){var e=t.src;if(e&&e[xe])qe(e.u,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Ye(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=Ze(e))?(qe(n,t),0==n.b&&(n.src=null,e[je]=null)):Ue(t)}}}function Ye(t){return t in We?We[t]:We[t]="on"+t}function Xe(t,e,n,r){var i=!0;if((t=Ze(t))&&(e=t.a[e.toString()]))for(e=e.concat(),t=0;t<e.length;t++){var o=e[t];o&&o.capture==n&&!o.ta&&(o=Je(o,r),i=i&&!1!==o)}return i}function Je(t,e){var n=t.listener,r=t.Pa||t.src;return t.Ka&&ze(t),n.call(r,e)}function $e(t,e){if(t.ta)return!0;if(ke)return Je(t,new Pe(e,this));if(!e)t:{e=["window","event"];for(var n=l,r=0;r<e.length;r++)if(null==(n=n[e[r]])){e=null;break t}e=n}if(e=new Pe(r=e,this),n=!0,!(r.keyCode<0||null!=r.returnValue)){t:{var i=!1;if(0==r.keyCode)try{r.keyCode=-1;break t}catch(t){i=!0}!i&&null!=r.returnValue||(r.returnValue=!0)}for(r=[],i=e.b;i;i=i.parentNode)r.push(i);for(t=t.type,i=r.length-1;0<=i;i--){e.b=r[i];var o=Xe(r[i],t,!0,e);n=n&&o}for(i=0;i<r.length;i++)e.b=r[i],o=Xe(r[i],t,!1,e),n=n&&o}return n}function Ze(t){return(t=t[je])instanceof Ve?t:null}var tn="__closure_events_fn_"+(1e9*Math.random()>>>0);function en(e){return y(e)?e:(e[tn]||(e[tn]=function(t){return e.handleEvent(t)}),e[tn])}function nn(){ce.call(this),this.u=new Ve(this),(this.Sb=this).Xa=null}function rn(t,e,n,r,i){t.u.add(String(e),n,!1,r,i)}function on(t,e,n,r,i){t.u.add(String(e),n,!0,r,i)}function an(t,e,n,r){if(!(e=t.u.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var a=e[o];if(a&&!a.ta&&a.capture==n){var s=a.listener,u=a.Pa||a.src;a.Ka&&qe(t.u,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Mb}function sn(t,e,n){if(y(t))n&&(t=_(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=_(t.handleEvent,t)}return 2147483647<Number(e)?-1:l.setTimeout(t,e||0)}function un(n){var r=null;return new jt(function(t,e){-1==(r=sn(function(){t(void 0)},n))&&e(Error("Failed to schedule timer."))}).s(function(t){throw l.clearTimeout(r),t})}function cn(t){if(t.U&&"function"==typeof t.U)return t.U();if(h(t))return t.split("");if(m(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}function hn(t){if(t.X&&"function"==typeof t.X)return t.X();if(!t.U||"function"!=typeof t.U){if(m(t)||h(t)){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(var r in e=[],n=0,t)e[n++]=r;return e}}function ln(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof ln)for(n=t.X(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function fn(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];pn(t.b,r)&&(t.a[n++]=r),e++}t.a.length=n}if(t.c!=t.a.length){var i={};for(n=e=0;e<t.a.length;)pn(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function pn(t,e){return Object.prototype.hasOwnProperty.call(t,e)}S(nn,ce),nn.prototype[xe]=!0,nn.prototype.addEventListener=function(t,e,n,r){Ke(this,t,e,n,r)},nn.prototype.removeEventListener=function(t,e,n,r){Ge(this,t,e,n,r)},nn.prototype.dispatchEvent=function(t){var e,n=this.Xa;if(n)for(e=[];n;n=n.Xa)e.push(n);n=this.Sb;var r=t.type||t;if(h(t))t=new Oe(t,n);else if(t instanceof Oe)t.target=t.target||n;else{var i=t;z(t=new Oe(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.b=e[o];i=an(a,r,!0,t)&&i}if(i=an(a=t.b=n,r,!0,t)&&i,i=an(a,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=an(a=t.b=e[o],r,!1,t)&&i;return i},nn.prototype.za=function(){if(nn.qb.za.call(this),this.u){var t,e=this.u;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)Ue(n[r]);delete e.a[t],e.b--}}this.Xa=null},(t=ln.prototype).U=function(){fn(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},t.X=function(){return fn(this),this.a.concat()},t.clear=function(){this.b={},this.c=this.a.length=0},t.get=function(t,e){return pn(this.b,t)?this.b[t]:e},t.set=function(t,e){pn(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},t.forEach=function(t,e){for(var n=this.X(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var dn=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function mn(t,e){var n;this.b=this.i=this.f="",this.l=null,this.g=this.c="",this.h=!1,t instanceof mn?(this.h=void 0!==e?e:t.h,yn(this,t.f),this.i=t.i,this.b=t.b,gn(this,t.l),this.c=t.c,vn(this,Fn(t.a)),this.g=t.g):t&&(n=String(t).match(dn))?(this.h=!!e,yn(this,n[1]||"",!0),this.i=En(n[2]||""),this.b=En(n[3]||"",!0),gn(this,n[4]),this.c=En(n[5]||"",!0),vn(this,n[6]||"",!0),this.g=En(n[7]||"")):(this.h=!!e,this.a=new Rn(null,this.h))}function yn(t,e,n){t.f=n?En(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function gn(t,e){if(e){if(e=Number(e),isNaN(e)||e<0)throw Error("Bad port number "+e);t.l=e}else t.l=null}function vn(t,e,n){e instanceof Rn?(t.a=e,function(t,e){e&&!t.f&&(On(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(Mn(this,e),Ln(this,n,t))},t)),t.f=e}(t.a,t.h)):(n||(e=Sn(e,kn)),t.a=new Rn(e,t.h))}function bn(t,e,n){t.a.set(e,n)}function wn(t,e){return t.a.get(e)}function _n(t){return t instanceof mn?new mn(t):new mn(t,void 0)}function Tn(t,e){var n=new mn(null,void 0);return yn(n,"https"),t&&(n.b=t),e&&(n.c=e),n}function En(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Sn(t,e,n){return h(t)?(t=encodeURI(t).replace(e,In),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function In(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}mn.prototype.toString=function(){var t=[],e=this.f;e&&t.push(Sn(e,Cn,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.i)&&t.push(Sn(e,Cn,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.l)&&t.push(":",String(n))),(n=this.c)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(Sn(n,"/"==n.charAt(0)?An:Nn,!0))),(n=this.a.toString())&&t.push("?",n),(n=this.g)&&t.push("#",Sn(n,Dn)),t.join("")},mn.prototype.resolve=function(t){var e=new mn(this),n=!!t.f;n?yn(e,t.f):n=!!t.i,n?e.i=t.i:n=!!t.b,n?e.b=t.b:n=null!=t.l;var r=t.c;if(n)gn(e,t.l);else if(n=!!t.c){if("/"!=r.charAt(0))if(this.b&&!this.c)r="/"+r;else{var i=e.c.lastIndexOf("/");-1!=i&&(r=e.c.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(mt(i,"./")||mt(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],a=0;a<i.length;){var s=i[a++];"."==s?r&&a==i.length&&o.push(""):".."==s?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),r&&a==i.length&&o.push("")):(o.push(s),r=!0)}r=o.join("/")}else r=i}return n?e.c=r:n=""!==t.a.toString(),n?vn(e,Fn(t.a)):n=!!t.g,n&&(e.g=t.g),e};var Cn=/[#\/\?@]/g,Nn=/[#\?:]/g,An=/[#\?]/g,kn=/[#\?@]/g,Dn=/#/g;function Rn(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function On(n){n.a||(n.a=new ln,n.b=0,n.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var o=t[n].substring(0,r);i=t[n].substring(r+1)}else o=t[n];e(o,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(n.c,function(t,e){n.add(decodeURIComponent(t.replace(/\+/g," ")),e)}))}function Pn(t){var e=hn(t);if(void 0===e)throw Error("Keys are undefined");var n=new Rn(null,void 0);t=cn(t);for(var r=0;r<e.length;r++){var i=e[r],o=t[r];d(o)?Ln(n,i,o):n.add(i,o)}return n}function Mn(t,e){On(t),e=Un(t,e),pn(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,pn((t=t.a).b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&fn(t)))}function xn(t,e){return On(t),e=Un(t,e),pn(t.a.b,e)}function Ln(t,e,n){Mn(t,e),0<n.length&&(t.c=null,t.a.set(Un(t,e),W(n)),t.b+=n.length)}function Fn(t){var e=new Rn;return e.c=t.c,t.a&&(e.a=new ln(t.a),e.b=t.b),e}function Un(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}(t=Rn.prototype).add=function(t,e){On(this),this.c=null,t=Un(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},t.clear=function(){this.a=this.c=null,this.b=0},t.forEach=function(n,r){On(this),this.a.forEach(function(t,e){L(t,function(t){n.call(r,t,e,this)},this)},this)},t.X=function(){On(this);for(var t=this.a.U(),e=this.a.X(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},t.U=function(t){On(this);var e=[];if(h(t))xn(this,t)&&(e=j(e,this.a.get(Un(this,t))));else{t=this.a.U();for(var n=0;n<t.length;n++)e=j(e,t[n])}return e},t.set=function(t,e){return On(this),this.c=null,xn(this,t=Un(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},t.get=function(t,e){return t&&0<(t=this.U(t)).length?String(t[0]):e},t.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.X(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.U(r);for(var o=0;o<r.length;o++){var a=i;""!==r[o]&&(a+="="+encodeURIComponent(String(r[o]))),t.push(a)}}return this.c=t.join("&")};var Vn=!ye||9<=Number(Ie);function qn(t){var e=document;return h(t)?e.getElementById(t):t}function Bn(n,t){K(t,function(t,e){t&&"object"==typeof t&&t.qa&&(t=t.pa()),"style"==e?n.style.cssText=t:"class"==e?n.className=t:"for"==e?n.htmlFor=t:jn.hasOwnProperty(e)?n.setAttribute(jn[e],t):0==e.lastIndexOf("aria-",0)||0==e.lastIndexOf("data-",0)?n.setAttribute(e,t):n[e]=t})}var jn={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",frameborder:"frameBorder",height:"height",maxlength:"maxLength",nonce:"nonce",role:"role",rowspan:"rowSpan",type:"type",usemap:"useMap",valign:"vAlign",width:"width"};function Wn(t,e,n){var r=arguments,i=document,o=String(r[0]),a=r[1];if(!Vn&&a&&(a.name||a.type)){if(o=["<",o],a.name&&o.push(' name="',xt(a.name),'"'),a.type){o.push(' type="',xt(a.type),'"');var s={};z(s,a),delete s.type,a=s}o.push(">"),o=o.join("")}return o=i.createElement(o),a&&(h(a)?o.className=a:d(a)?o.className=a.join(" "):Bn(o,a)),2<r.length&&function(e,n,t){function r(t){t&&n.appendChild(h(t)?e.createTextNode(t):t)}for(var i=2;i<t.length;i++){var o=t[i];!m(o)||g(o)&&0<o.nodeType?r(o):L(Kn(o)?W(o):o,r)}}(i,o,r),o}function Kn(t){if(t&&"number"==typeof t.length){if(g(t))return"function"==typeof t.item||"string"==typeof t.item;if(y(t))return"function"==typeof t.item}return!1}function Qn(t){var e=[];return function t(e,n,r){if(null==n)r.push("null");else{if("object"==typeof n){if(d(n)){var i=n;n=i.length,r.push("[");for(var o="",a=0;a<n;a++)r.push(o),t(e,i[a],r),o=",";return void r.push("]")}if(!(n instanceof String||n instanceof Number||n instanceof Boolean)){for(i in r.push("{"),o="",n)Object.prototype.hasOwnProperty.call(n,i)&&("function"!=typeof(a=n[i])&&(r.push(o),Yn(i,r),r.push(":"),t(e,a,r),o=","));return void r.push("}")}n=n.valueOf()}switch(typeof n){case"string":Yn(n,r);break;case"number":r.push(isFinite(n)&&!isNaN(n)?String(n):"null");break;case"boolean":r.push(String(n));break;case"function":r.push("null");break;default:throw Error("Unknown type: "+typeof n)}}}(new Hn,t,e),e.join("")}function Hn(){}var Gn={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\u000b"},zn=/\uffff/.test("")?/[\\"\x00-\x1f\x7f-\uffff]/g:/[\\"\x00-\x1f\x7f-\xff]/g;function Yn(t,e){e.push('"',t.replace(zn,function(t){var e=Gn[t];return e||(e="\\u"+(65536|t.charCodeAt(0)).toString(16).substr(1),Gn[t]=e),e}),'"')}function Xn(){var t=mr();return ye&&!!Ie&&11==Ie||/Edge\/\d+/.test(t)}function Jn(){return l.window&&l.window.location.href||self&&self.location&&self.location.href||""}function $n(t,e){e=e||l.window;var n="about:blank";t&&(n=vt(wt(t)).toString()),e.location.href=n}function Zn(t){return!!((t=(t||mr()).toLowerCase()).match(/android/)||t.match(/webos/)||t.match(/iphone|ipad|ipod/)||t.match(/blackberry/)||t.match(/windows phone/)||t.match(/iemobile/))}function tr(t){t=t||l.window;try{t.close()}catch(t){}}function er(t,e,n){var r=Math.floor(1e9*Math.random()).toString();e=e||500,n=n||600;var i=(window.screen.availHeight-n)/2,o=(window.screen.availWidth-e)/2;for(a in e={width:e,height:n,top:0<i?i:0,left:0<o?o:0,location:!0,resizable:!0,statusbar:!0,toolbar:!1},n=mr().toLowerCase(),r&&(e.target=r,mt(n,"crios/")&&(e.target="_blank")),fr(mr())==hr&&(t=t||"http://localhost",e.scrollbars=!0),n=t||"",(t=e)||(t={}),r=window,e=n instanceof gt?n:wt(void 0!==n.href?n.href:String(n)),n=t.target||n.target,i=[],t)switch(a){case"width":case"height":case"top":case"left":i.push(a+"="+t[a]);break;case"target":case"noopener":case"noreferrer":break;default:i.push(a+"="+(t[a]?1:0))}var a=i.join(",");if((Ct("iPhone")&&!Ct("iPod")&&!Ct("iPad")||Ct("iPad")||Ct("iPod"))&&r.navigator&&r.navigator.standalone&&n&&"_self"!=n?(M(a=r.document.createElement("A"),"HTMLAnchorElement"),e instanceof gt||e instanceof gt||(e="object"==typeof e&&e.qa?e.pa():String(e),bt.test(e)||(e="about:invalid#zClosurez"),e=Et(e)),a.href=vt(e),a.setAttribute("target",n),t.noreferrer&&a.setAttribute("rel","noreferrer"),(t=document.createEvent("MouseEvent")).initMouseEvent("click",!0,!0,r,1),a.dispatchEvent(t),a={}):t.noreferrer?(a=r.open("",n,a),t=vt(e).toString(),a&&(ve&&mt(t,";")&&(t="'"+t.replace(/'/g,"%27")+"'"),a.opener=null,t=Dt('<meta name="referrer" content="no-referrer"><meta http-equiv="refresh" content="0; url='+xt(t)+'">'),a.document.write(At(t)),a.document.close())):(a=r.open(vt(e).toString(),n,a))&&t.noopener&&(a.opener=null),a)try{a.focus()}catch(t){}return a}var nr=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,rr=/^[^@]+@[^@]+$/;function ir(){var e=null;return new jt(function(t){"complete"==l.document.readyState?t():(e=function(){t()},He(window,"load",e))}).s(function(t){throw Ge(window,"load",e),t})}function or(t){return t=t||mr(),!("file:"!==wr()&&"ionic:"!==wr()||!t.toLowerCase().match(/iphone|ipad|ipod|android/))}function ar(){var t=l.window;try{return!(!t||t==t.top)}catch(t){return!1}}function sr(){return void 0!==l.WorkerGlobalScope&&"function"==typeof l.importScripts}function ur(){return fl.INTERNAL.hasOwnProperty("reactNative")?"ReactNative":fl.INTERNAL.hasOwnProperty("node")?"Node":sr()?"Worker":"Browser"}function cr(){var t=ur();return"ReactNative"===t||"Node"===t}var hr="Firefox",lr="Chrome";function fr(t){var e=t.toLowerCase();return mt(e,"opera/")||mt(e,"opr/")||mt(e,"opios/")?"Opera":mt(e,"iemobile")?"IEMobile":mt(e,"msie")||mt(e,"trident/")?"IE":mt(e,"edge/")?"Edge":mt(e,"firefox/")?hr:mt(e,"silk/")?"Silk":mt(e,"blackberry")?"Blackberry":mt(e,"webos")?"Webos":!mt(e,"safari/")||mt(e,"chrome/")||mt(e,"crios/")||mt(e,"android")?!mt(e,"chrome/")&&!mt(e,"crios/")||mt(e,"edge/")?mt(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":lr:"Safari"}var pr={Wc:"FirebaseCore-web",Yc:"FirebaseUI-web"};function dr(t,e){e=e||[];var n,r=[],i={};for(n in pr)i[pr[n]]=!0;for(n=0;n<e.length;n++)void 0!==i[e[n]]&&(delete i[e[n]],r.push(e[n]));return r.sort(),(e=r).length||(e=["FirebaseCore-web"]),"Browser"===(r=ur())?r=fr(i=mr()):"Worker"===r&&(r=fr(i=mr())+"-"+r),r+"/JsCore/"+t+"/"+e.join(",")}function mr(){return l.navigator&&l.navigator.userAgent||""}function yr(t,e){t=t.split("."),e=e||l;for(var n=0;n<t.length&&"object"==typeof e&&null!=e;n++)e=e[t[n]];return n!=t.length&&(e=void 0),e}function gr(){try{var t=l.localStorage,e=Ir();if(t)return t.setItem(e,"1"),t.removeItem(e),!Xn()||!!l.indexedDB}catch(t){return sr()&&!!l.indexedDB}return!1}function vr(){return(br()||"chrome-extension:"===wr()||or())&&!cr()&&gr()&&!sr()}function br(){return"http:"===wr()||"https:"===wr()}function wr(){return l.location&&l.location.protocol||null}function _r(t){return!Zn(t=t||mr())&&fr(t)!=hr}function Tr(t){return void 0===t?null:Qn(t)}function Er(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&null!==t[e]&&void 0!==t[e]&&(n[e]=t[e]);return n}function Sr(t){if(null!==t)return JSON.parse(t)}function Ir(t){return t||Math.floor(1e9*Math.random()).toString()}function Cr(t){return"Safari"!=fr(t=t||mr())&&!t.toLowerCase().match(/iphone|ipad|ipod/)}function Nr(){var t=l.___jsl;if(t&&t.H)for(var e in t.H)if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=t.H[e].L.concat(),t.CP)for(var n=0;n<t.CP.length;n++)t.CP[n]=null}function Ar(t,e){if(e<t)throw Error("Short delay should be less than long delay!");this.a=t,this.c=e,t=mr(),e=ur(),this.b=Zn(t)||"ReactNative"===e}function kr(){var t=l.document;return!t||void 0===t.visibilityState||"visible"==t.visibilityState}function Dr(t){try{var e=new Date(parseInt(t,10));if(!isNaN(e.getTime())&&!/[^0-9]/.test(t))return e.toUTCString()}catch(t){}return null}function Rr(){return!(!yr("fireauth.oauthhelper",l)&&!yr("fireauth.iframe",l))}Ar.prototype.get=function(){var t=l.navigator;return!t||"boolean"!=typeof t.onLine||!br()&&"chrome-extension:"!==wr()&&void 0===t.connection||t.onLine?this.b?this.c:this.a:Math.min(5e3,this.a)};var Or,Pr={};function Mr(t){Pr[t]||(Pr[t]=!0,"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t))}try{var xr={};Object.defineProperty(xr,"abcd",{configurable:!0,enumerable:!0,value:1}),Object.defineProperty(xr,"abcd",{configurable:!0,enumerable:!0,value:2}),Or=2==xr.abcd}catch(t){Or=!1}function Lr(t,e,n){Or?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,value:n}):t[e]=n}function Fr(t,e){if(e)for(var n in e)e.hasOwnProperty(n)&&Lr(t,n,e[n])}function Ur(t){var e={};return Fr(e,t),e}function Vr(t){var e=t;if("object"==typeof t&&null!=t)for(var n in e="length"in t?[]:{},t)Lr(e,n,Vr(t[n]));return e}function qr(t){var e={},n=t[jr],r=t[Wr];if(!(t=t[Kr])||t!=Br&&!n)throw Error("Invalid provider user info!");e[Hr]=r||null,e[Qr]=n||null,Lr(this,zr,t),Lr(this,Gr,Vr(e))}var Br="EMAIL_SIGNIN",jr="email",Wr="newEmail",Kr="requestType",Qr="email",Hr="fromEmail",Gr="data",zr="operation";function Yr(t,e){this.code=Jr+t,this.message=e||$r[t]||""}function Xr(t){var e=t&&t.code;return e?new Yr(e.substring(Jr.length),t.message):null}S(Yr,Error),Yr.prototype.A=function(){return{code:this.code,message:this.message}},Yr.prototype.toJSON=function(){return this.A()};var Jr="auth/",$r={"admin-restricted-operation":"This operation is restricted to administrators only.","argument-error":"","app-not-authorized":"This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.","app-not-installed":"The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.","captcha-check-failed":"The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.","code-expired":"The SMS code has expired. Please re-send the verification code to try again.","cordova-not-ready":"Cordova framework is not ready.","cors-unsupported":"This browser is not supported.","credential-already-in-use":"This credential is already associated with a different user account.","custom-token-mismatch":"The custom token corresponds to a different audience.","requires-recent-login":"This operation is sensitive and requires recent authentication. Log in again before retrying this request.","dynamic-link-not-activated":"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.","email-already-in-use":"The email address is already in use by another account.","expired-action-code":"The action code has expired. ","cancelled-popup-request":"This operation has been cancelled due to another conflicting popup being opened.","internal-error":"An internal error has occurred.","invalid-app-credential":"The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.","invalid-app-id":"The mobile app identifier is not registed for the current project.","invalid-user-token":"This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.","invalid-auth-event":"An internal error has occurred.","invalid-verification-code":"The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure use the verification code provided by the user.","invalid-continue-uri":"The continue URL provided in the request is invalid.","invalid-cordova-configuration":"The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.","invalid-custom-token":"The custom token format is incorrect. Please check the documentation.","invalid-dynamic-link-domain":"The provided dynamic link domain is not configured or authorized for the current project.","invalid-email":"The email address is badly formatted.","invalid-api-key":"Your API key is invalid, please check you have copied it correctly.","invalid-cert-hash":"The SHA-1 certificate hash provided is invalid.","invalid-credential":"The supplied auth credential is malformed or has expired.","invalid-message-payload":"The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-oauth-provider":"EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.","invalid-oauth-client-id":"The OAuth client ID provided is either invalid or does not match the specified API key.","unauthorized-domain":"This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.","invalid-action-code":"The action code is invalid. This can happen if the code is malformed, expired, or has already been used.","wrong-password":"The password is invalid or the user does not have a password.","invalid-persistence-type":"The specified persistence type is invalid. It can only be local, session or none.","invalid-phone-number":"The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].","invalid-provider-id":"The specified provider ID is invalid.","invalid-recipient-email":"The email corresponding to this action failed to send as the provided recipient email address is invalid.","invalid-sender":"The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.","invalid-verification-id":"The verification ID used to create the phone auth credential is invalid.","invalid-tenant-id":"The Auth instance's tenant ID is invalid.","missing-android-pkg-name":"An Android Package Name must be provided if the Android App is required to be installed.","auth-domain-config-required":"Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.","missing-app-credential":"The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.","missing-verification-code":"The phone auth credential was created with an empty SMS verification code.","missing-continue-uri":"A continue URL must be provided in the request.","missing-iframe-start":"An internal error has occurred.","missing-ios-bundle-id":"An iOS Bundle ID must be provided if an App Store ID is provided.","missing-or-invalid-nonce":"The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.","missing-phone-number":"To send verification codes, provide a phone number for the recipient.","missing-verification-id":"The phone auth credential was created with an empty verification ID.","app-deleted":"This instance of FirebaseApp has been deleted.","account-exists-with-different-credential":"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.","network-request-failed":"A network error (such as timeout, interrupted connection or unreachable host) has occurred.","no-auth-event":"An internal error has occurred.","no-such-provider":"User was not linked to an account with the given provider.","null-user":"A null user object was provided as the argument for an operation which requires a non-null user object.","operation-not-allowed":"The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.","operation-not-supported-in-this-environment":'This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.',"popup-blocked":"Unable to establish a connection with the popup. It may have been blocked by the browser.","popup-closed-by-user":"The popup has been closed by the user before finalizing the operation.","provider-already-linked":"User can only be linked to one identity for the given provider.","quota-exceeded":"The project's quota for this operation has been exceeded.","redirect-cancelled-by-user":"The redirect operation has been cancelled by the user before finalizing.","redirect-operation-pending":"A redirect sign-in operation is already pending.","rejected-credential":"The request contains malformed or mismatching credentials.","tenant-id-mismatch":"The provided tenant ID does not match the Auth instance's tenant ID",timeout:"The operation has timed out.","user-token-expired":"The user's credential is no longer valid. The user must sign in again.","too-many-requests":"We have blocked all requests from this device due to unusual activity. Try again later.","unauthorized-continue-uri":"The domain of the continue URL is not whitelisted.  Please whitelist the domain in the Firebase console.","unsupported-persistence-type":"The current environment does not support the specified persistence type.","unsupported-tenant-operation":"This operation is not supported in a multi-tenant context.","user-cancelled":"The user did not grant your application the permissions it requested.","user-not-found":"There is no user record corresponding to this identifier. The user may have been deleted.","user-disabled":"The user account has been disabled by an administrator.","user-mismatch":"The supplied credentials do not correspond to the previously signed in user.","user-signed-out":"","weak-password":"The password must be 6 characters long or more.","web-storage-unsupported":"This browser is not supported or 3rd party cookies and data may be disabled."};function Zr(t){var e=wn(t=_n(t),ti)||null,n=wn(t,ei)||null,r=wn(t,ii)||null;if(r=r&&ai[r]||null,!e||!n||!r)throw new Yr("argument-error",ti+", "+ei+"and "+ii+" are required in a valid action code URL.");Fr(this,{apiKey:e,operation:r,code:n,continueUrl:wn(t,ni)||null,languageCode:wn(t,ri)||null,tenantId:wn(t,oi)||null})}var ti="apiKey",ei="oobCode",ni="continueUrl",ri="languageCode",ii="mode",oi="tenantId",ai={recoverEmail:"RECOVER_EMAIL",resetPassword:"PASSWORD_RESET",signIn:Br,verifyEmail:"VERIFY_EMAIL"};function si(t){try{return new Zr(t)}catch(t){return null}}function ui(t){var e=t[pi];if(void 0===e)throw new Yr("missing-continue-uri");if("string"!=typeof e||"string"==typeof e&&!e.length)throw new Yr("invalid-continue-uri");this.h=e,this.b=this.a=null,this.g=!1;var n=t[ci];if(n&&"object"==typeof n){e=n[yi];var r=n[di];if(n=n[mi],"string"==typeof e&&e.length){if(this.a=e,void 0!==r&&"boolean"!=typeof r)throw new Yr("argument-error",di+" property must be a boolean when specified.");if(this.g=!!r,void 0!==n&&("string"!=typeof n||"string"==typeof n&&!n.length))throw new Yr("argument-error",mi+" property must be a non empty string when specified.");this.b=n||null}else{if(void 0!==e)throw new Yr("argument-error",yi+" property must be a non empty string when specified.");if(void 0!==r||void 0!==n)throw new Yr("missing-android-pkg-name")}}else if(void 0!==n)throw new Yr("argument-error",ci+" property must be a non null object when specified.");if(this.f=null,(e=t[fi])&&"object"==typeof e){if("string"==typeof(e=e[gi])&&e.length)this.f=e;else if(void 0!==e)throw new Yr("argument-error",gi+" property must be a non empty string when specified.")}else if(void 0!==e)throw new Yr("argument-error",fi+" property must be a non null object when specified.");if(void 0!==(e=t[li])&&"boolean"!=typeof e)throw new Yr("argument-error",li+" property must be a boolean when specified.");if(this.c=!!e,void 0!==(t=t[hi])&&("string"!=typeof t||"string"==typeof t&&!t.length))throw new Yr("argument-error",hi+" property must be a non empty string when specified.");this.i=t||null}var ci="android",hi="dynamicLinkDomain",li="handleCodeInApp",fi="iOS",pi="url",di="installApp",mi="minimumVersion",yi="packageName",gi="bundleId";function vi(t){var e={};for(var n in e.continueUrl=t.h,e.canHandleCodeInApp=t.c,(e.androidPackageName=t.a)&&(e.androidMinimumVersion=t.b,e.androidInstallApp=t.g),e.iOSBundleId=t.f,e.dynamicLinkDomain=t.i,e)null===e[n]&&delete e[n];return e}var bi=null,wi=null;function _i(t){var e="";return function(r,t){function e(t){for(;i<r.length;){var e=r.charAt(i++),n=wi[e];if(null!=n)return n;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return t}!function(){if(!bi){bi={},wi={};for(var t=0;t<65;t++)bi[t]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(t),62<=(wi[bi[t]]=t)&&(wi["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.".charAt(t)]=t)}}();for(var i=0;;){var n=e(-1),o=e(0),a=e(64),s=e(64);if(64===s&&-1===n)break;t(n<<2|o>>4),64!=a&&(t(o<<4&240|a>>2),64!=s&&t(a<<6&192|s))}}(t,function(t){e+=String.fromCharCode(t)}),e}function Ti(t){this.f=t.sub,this.a=t.provider_id||t.firebase&&t.firebase.sign_in_provider||null,this.c=t.firebase&&t.firebase.tenant||null,this.b=!!t.is_anonymous||"anonymous"==this.a}function Ei(t){return(t=Si(t))&&t.sub&&t.iss&&t.aud&&t.exp?new Ti(t):null}function Si(t){if(!t)return null;if(3!=(t=t.split(".")).length)return null;for(var e=(4-(t=t[1]).length%4)%4,n=0;n<e;n++)t+=".";try{return JSON.parse(_i(t))}catch(t){}return null}Ti.prototype.R=function(){return this.c},Ti.prototype.g=function(){return this.b};var Ii,Ci={bd:{cb:"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://securetoken.googleapis.com/v1/token",id:"p"},dd:{cb:"https://staging-www.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://staging-securetoken.sandbox.googleapis.com/v1/token",id:"s"},ed:{cb:"https://www-googleapis-test.sandbox.google.com/identitytoolkit/v3/relyingparty/",ib:"https://test-securetoken.sandbox.googleapis.com/v1/token",id:"t"}};function Ni(t){for(var e in Ci)if(Ci[e].id===t)return{firebaseEndpoint:(t=Ci[e]).cb,secureTokenEndpoint:t.ib};return null}Ii=Ni("__EID__")?"__EID__":void 0;var Ai="oauth_consumer_key oauth_nonce oauth_signature oauth_signature_method oauth_timestamp oauth_token oauth_version".split(" "),ki=["client_id","response_type","scope","redirect_uri","state"],Di={Xc:{Ea:"locale",sa:700,ra:600,Fa:"facebook.com",Qa:ki},Zc:{Ea:null,sa:500,ra:750,Fa:"github.com",Qa:ki},$c:{Ea:"hl",sa:515,ra:680,Fa:"google.com",Qa:ki},fd:{Ea:"lang",sa:485,ra:705,Fa:"twitter.com",Qa:Ai},Vc:{Ea:"locale",sa:600,ra:600,Fa:"apple.com",Qa:[]}};function Ri(t){for(var e in Di)if(Di[e].Fa==t)return Di[e];return null}function Oi(t){var e={};e["facebook.com"]=Fi,e["google.com"]=Vi,e["github.com"]=Ui,e["twitter.com"]=qi;var n=t&&t[Mi];try{if(n)return e[n]?new e[n](t):new Li(t);if(void 0!==t[Pi])return new xi(t)}catch(t){}return null}var Pi="idToken",Mi="providerId";function xi(t){var e=t[Mi];if(!e&&t[Pi]){var n=Ei(t[Pi]);n&&n.a&&(e=n.a)}if(!e)throw Error("Invalid additional user info!");"anonymous"!=e&&"custom"!=e||(e=null),n=!1,void 0!==t.isNewUser?n=!!t.isNewUser:"identitytoolkit#SignupNewUserResponse"===t.kind&&(n=!0),Lr(this,"providerId",e),Lr(this,"isNewUser",n)}function Li(t){xi.call(this,t),Lr(this,"profile",Vr((t=Sr(t.rawUserInfo||"{}"))||{}))}function Fi(t){if(Li.call(this,t),"facebook.com"!=this.providerId)throw Error("Invalid provider ID!")}function Ui(t){if(Li.call(this,t),"github.com"!=this.providerId)throw Error("Invalid provider ID!");Lr(this,"username",this.profile&&this.profile.login||null)}function Vi(t){if(Li.call(this,t),"google.com"!=this.providerId)throw Error("Invalid provider ID!")}function qi(t){if(Li.call(this,t),"twitter.com"!=this.providerId)throw Error("Invalid provider ID!");Lr(this,"username",t.screenName||null)}function Bi(t){var e=_n(t),n=wn(e,"link"),r=wn(_n(n),"link");return wn(_n(e=wn(e,"deep_link_id")),"link")||e||r||n||t}function ji(){}function Wi(t,n){return t.then(function(t){if(t[Oa]){var e=Ei(t[Oa]);if(!e||n!=e.f)throw new Yr("user-mismatch");return t}throw new Yr("user-mismatch")}).s(function(t){throw t&&t.code&&t.code==Jr+"user-not-found"?new Yr("user-mismatch"):t})}function Ki(t,e){if(!e)throw new Yr("internal-error","failed to construct a credential");this.a=e,Lr(this,"providerId",t),Lr(this,"signInMethod",t)}function Qi(t){return{pendingToken:t.a,requestUri:"http://localhost"}}function Hi(t){if(t&&t.providerId&&t.signInMethod&&0==t.providerId.indexOf("saml.")&&t.pendingToken)try{return new Ki(t.providerId,t.pendingToken)}catch(t){}return null}function Gi(t,e,n){if(this.a=null,e.idToken||e.accessToken)e.idToken&&Lr(this,"idToken",e.idToken),e.accessToken&&Lr(this,"accessToken",e.accessToken),e.nonce&&!e.pendingToken&&Lr(this,"nonce",e.nonce),e.pendingToken&&(this.a=e.pendingToken);else{if(!e.oauthToken||!e.oauthTokenSecret)throw new Yr("internal-error","failed to construct a credential");Lr(this,"accessToken",e.oauthToken),Lr(this,"secret",e.oauthTokenSecret)}Lr(this,"providerId",t),Lr(this,"signInMethod",n)}function zi(t){var e={};return t.idToken&&(e.id_token=t.idToken),t.accessToken&&(e.access_token=t.accessToken),t.secret&&(e.oauth_token_secret=t.secret),e.providerId=t.providerId,t.nonce&&!t.a&&(e.nonce=t.nonce),e={postBody:Pn(e).toString(),requestUri:"http://localhost"},t.a&&(delete e.postBody,e.pendingToken=t.a),e}function Yi(t){if(t&&t.providerId&&t.signInMethod){var e={idToken:t.oauthIdToken,accessToken:t.oauthTokenSecret?null:t.oauthAccessToken,oauthTokenSecret:t.oauthTokenSecret,oauthToken:t.oauthTokenSecret&&t.oauthAccessToken,nonce:t.nonce,pendingToken:t.pendingToken};try{return new Gi(t.providerId,e,t.signInMethod)}catch(t){}}return null}function Xi(t,e){this.Fc=e||[],Fr(this,{providerId:t,isOAuthProvider:!0}),this.zb={},this.eb=(Ri(t)||{}).Ea||null,this.bb=null}function Ji(t){if("string"!=typeof t||0!=t.indexOf("saml."))throw new Yr("argument-error",'SAML provider IDs must be prefixed with "saml."');Xi.call(this,t,[])}function $i(t){Xi.call(this,t,ki),this.a=[]}function Zi(){$i.call(this,"facebook.com")}function to(t){if(!t)throw new Yr("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return g(t)&&(e=t.accessToken),(new Zi).credential({accessToken:e})}function eo(){$i.call(this,"github.com")}function no(t){if(!t)throw new Yr("argument-error","credential failed: expected 1 argument (the OAuth access token).");var e=t;return g(t)&&(e=t.accessToken),(new eo).credential({accessToken:e})}function ro(){$i.call(this,"google.com"),this.ya("profile")}function io(t,e){var n=t;return g(t)&&(n=t.idToken,e=t.accessToken),(new ro).credential({idToken:n,accessToken:e})}function oo(){Xi.call(this,"twitter.com",Ai)}function ao(t,e){var n=t;if(g(n)||(n={oauthToken:t,oauthTokenSecret:e}),!n.oauthToken||!n.oauthTokenSecret)throw new Yr("argument-error","credential failed: expected 2 arguments (the OAuth access token and secret).");return new Gi("twitter.com",n,"twitter.com")}function so(t,e,n){this.a=t,this.c=e,Lr(this,"providerId","password"),Lr(this,"signInMethod",n===co.EMAIL_LINK_SIGN_IN_METHOD?co.EMAIL_LINK_SIGN_IN_METHOD:co.EMAIL_PASSWORD_SIGN_IN_METHOD)}function uo(t){return t&&t.email&&t.password?new so(t.email,t.password,t.signInMethod):null}function co(){Fr(this,{providerId:"password",isOAuthProvider:!1})}function ho(t,e){if(!(e=lo(e)))throw new Yr("argument-error","Invalid email link!");return new so(t,e.code,co.EMAIL_LINK_SIGN_IN_METHOD)}function lo(t){return(t=si(t=Bi(t)))&&t.operation===Br?t:null}function fo(t){if(!(t.Va&&t.Ua||t.Ha&&t.ba))throw new Yr("internal-error");this.a=t,Lr(this,"providerId","phone"),Lr(this,"signInMethod","phone")}function po(e){if(e&&"phone"===e.providerId&&(e.verificationId&&e.verificationCode||e.temporaryProof&&e.phoneNumber)){var n={};return L(["verificationId","verificationCode","temporaryProof","phoneNumber"],function(t){e[t]&&(n[t]=e[t])}),new fo(n)}return null}function mo(t){return t.a.Ha&&t.a.ba?{temporaryProof:t.a.Ha,phoneNumber:t.a.ba}:{sessionInfo:t.a.Va,code:t.a.Ua}}function yo(t){try{this.a=t||fl.auth()}catch(t){throw new Yr("argument-error","Either an instance of firebase.auth.Auth must be passed as an argument to the firebase.auth.PhoneAuthProvider constructor, or the default firebase App instance must be initialized via firebase.initializeApp().")}Fr(this,{providerId:"phone",isOAuthProvider:!1})}function go(t,e){if(!t)throw new Yr("missing-verification-id");if(!e)throw new Yr("missing-verification-code");return new fo({Va:t,Ua:e})}function vo(t){if(t.temporaryProof&&t.phoneNumber)return new fo({Ha:t.temporaryProof,ba:t.phoneNumber});var e=t&&t.providerId;if(!e||"password"===e)return null;var n=t&&t.oauthAccessToken,r=t&&t.oauthTokenSecret,i=t&&t.nonce,o=t&&t.oauthIdToken,a=t&&t.pendingToken;try{switch(e){case"google.com":return io(o,n);case"facebook.com":return to(n);case"github.com":return no(n);case"twitter.com":return ao(n,r);default:return n||r||o||a?a?0==e.indexOf("saml.")?new Ki(e,a):new Gi(e,{pendingToken:a,idToken:t.oauthIdToken,accessToken:t.oauthAccessToken},e):new $i(e).credential({idToken:o,accessToken:n,rawNonce:i}):null}}catch(t){return null}}function bo(t){if(!t.isOAuthProvider)throw new Yr("invalid-oauth-provider")}function wo(t,e,n,r,i,o,a){if(this.c=t,this.b=e||null,this.g=n||null,this.f=r||null,this.i=o||null,this.h=a||null,this.a=i||null,!this.g&&!this.a)throw new Yr("invalid-auth-event");if(this.g&&this.a)throw new Yr("invalid-auth-event");if(this.g&&!this.f)throw new Yr("invalid-auth-event")}function _o(t){return(t=t||{}).type?new wo(t.type,t.eventId,t.urlResponse,t.sessionId,t.error&&Xr(t.error),t.postBody,t.tenantId):null}function To(){this.b=null,this.a=[]}S(Li,xi),S(Fi,Li),S(Ui,Li),S(Vi,Li),S(qi,Li),Ki.prototype.na=function(t){return Xa(t,Qi(this))},Ki.prototype.b=function(t,e){var n=Qi(this);return n.idToken=e,Ja(t,n)},Ki.prototype.f=function(t,e){return Wi($a(t,Qi(this)),e)},Ki.prototype.A=function(){return{providerId:this.providerId,signInMethod:this.signInMethod,pendingToken:this.a}},Gi.prototype.na=function(t){return Xa(t,zi(this))},Gi.prototype.b=function(t,e){var n=zi(this);return n.idToken=e,Ja(t,n)},Gi.prototype.f=function(t,e){return Wi($a(t,zi(this)),e)},Gi.prototype.A=function(){var t={providerId:this.providerId,signInMethod:this.signInMethod};return this.idToken&&(t.oauthIdToken=this.idToken),this.accessToken&&(t.oauthAccessToken=this.accessToken),this.secret&&(t.oauthTokenSecret=this.secret),this.nonce&&(t.nonce=this.nonce),this.a&&(t.pendingToken=this.a),t},Xi.prototype.Ga=function(t){return this.zb=H(t),this},S(Ji,Xi),S($i,Xi),$i.prototype.ya=function(t){return V(this.a,t)||this.a.push(t),this},$i.prototype.Hb=function(){return W(this.a)},$i.prototype.credential=function(t,e){var n;if(!(n=g(t)?{idToken:t.idToken||null,accessToken:t.accessToken||null,nonce:t.rawNonce||null}:{idToken:t||null,accessToken:e||null}).idToken&&!n.accessToken)throw new Yr("argument-error","credential failed: must provide the ID token and/or the access token.");return new Gi(this.providerId,n,this.providerId)},S(Zi,$i),Lr(Zi,"PROVIDER_ID","facebook.com"),Lr(Zi,"FACEBOOK_SIGN_IN_METHOD","facebook.com"),S(eo,$i),Lr(eo,"PROVIDER_ID","github.com"),Lr(eo,"GITHUB_SIGN_IN_METHOD","github.com"),S(ro,$i),Lr(ro,"PROVIDER_ID","google.com"),Lr(ro,"GOOGLE_SIGN_IN_METHOD","google.com"),S(oo,Xi),Lr(oo,"PROVIDER_ID","twitter.com"),Lr(oo,"TWITTER_SIGN_IN_METHOD","twitter.com"),so.prototype.na=function(t){return this.signInMethod==co.EMAIL_LINK_SIGN_IN_METHOD?Ns(t,as,{email:this.a,oobCode:this.c}):Ns(t,Es,{email:this.a,password:this.c})},so.prototype.b=function(t,e){return this.signInMethod==co.EMAIL_LINK_SIGN_IN_METHOD?Ns(t,ss,{idToken:e,email:this.a,oobCode:this.c}):Ns(t,gs,{idToken:e,email:this.a,password:this.c})},so.prototype.f=function(t,e){return Wi(this.na(t),e)},so.prototype.A=function(){return{email:this.a,password:this.c,signInMethod:this.signInMethod}},Fr(co,{PROVIDER_ID:"password"}),Fr(co,{EMAIL_LINK_SIGN_IN_METHOD:"emailLink"}),Fr(co,{EMAIL_PASSWORD_SIGN_IN_METHOD:"password"}),fo.prototype.na=function(t){return t.Wa(mo(this))},fo.prototype.b=function(t,e){var n=mo(this);return n.idToken=e,Ns(t,Is,n)},fo.prototype.f=function(t,e){var n=mo(this);return n.operation="REAUTH",Wi(t=Ns(t,Cs,n),e)},fo.prototype.A=function(){var t={providerId:"phone"};return this.a.Va&&(t.verificationId=this.a.Va),this.a.Ua&&(t.verificationCode=this.a.Ua),this.a.Ha&&(t.temporaryProof=this.a.Ha),this.a.ba&&(t.phoneNumber=this.a.ba),t},yo.prototype.Wa=function(e,n){var r=this.a.b;return Yt(n.verify()).then(function(t){if(!h(t))throw new Yr("argument-error","An implementation of firebase.auth.ApplicationVerifier.prototype.verify() must return a firebase.Promise that resolves with a string.");switch(n.type){case"recaptcha":return function(t,e){return Ns(t,ms,e)}(r,{phoneNumber:e,recaptchaToken:t}).then(function(t){return"function"==typeof n.reset&&n.reset(),t},function(t){throw"function"==typeof n.reset&&n.reset(),t});default:throw new Yr("argument-error",'Only firebase.auth.ApplicationVerifiers with type="recaptcha" are currently supported.')}})},Fr(yo,{PROVIDER_ID:"phone"}),Fr(yo,{PHONE_SIGN_IN_METHOD:"phone"}),wo.prototype.getUid=function(){var t=[];return t.push(this.c),this.b&&t.push(this.b),this.f&&t.push(this.f),this.h&&t.push(this.h),t.join("-")},wo.prototype.R=function(){return this.h},wo.prototype.A=function(){return{type:this.c,eventId:this.b,urlResponse:this.g,sessionId:this.f,postBody:this.i,tenantId:this.h,error:this.a&&this.a.A()}};var Eo,So=null;function Io(t){var e="unauthorized-domain",n=void 0,r=_n(t);t=r.b,"chrome-extension"==(r=r.f)?n=Mt("This chrome extension ID (chrome-extension://%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):"http"==r||"https"==r?n=Mt("This domain (%s) is not authorized to run this operation. Add it to the OAuth redirect domains list in the Firebase console -> Auth section -> Sign in method tab.",t):e="operation-not-supported-in-this-environment",Yr.call(this,e,n)}function Co(t,e,n){Yr.call(this,t,n),(t=e||{}).Ab&&Lr(this,"email",t.Ab),t.ba&&Lr(this,"phoneNumber",t.ba),t.credential&&Lr(this,"credential",t.credential),t.Qb&&Lr(this,"tenantId",t.Qb)}function No(t){if(t.code){var e=t.code||"";0==e.indexOf(Jr)&&(e=e.substring(Jr.length));var n={credential:vo(t),Qb:t.tenantId};if(t.email)n.Ab=t.email;else if(t.phoneNumber)n.ba=t.phoneNumber;else if(!n.credential)return new Yr(e,t.message||void 0);return new Co(e,n,t.message)}return null}function Ao(){}function ko(t){return t.c||(t.c=t.b())}function Do(){}function Ro(t){if(t.f||"undefined"!=typeof XMLHttpRequest||"undefined"==typeof ActiveXObject)return t.f;for(var e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],n=0;n<e.length;n++){var r=e[n];try{return new ActiveXObject(r),t.f=r}catch(t){}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}function Oo(){}function Po(){this.a=new XDomainRequest,this.readyState=0,this.onreadystatechange=null,this.responseType=this.responseText=this.response="",this.status=-1,this.statusText="",this.a.onload=_(this.fc,this),this.a.onerror=_(this.Ib,this),this.a.onprogress=_(this.gc,this),this.a.ontimeout=_(this.kc,this)}function Mo(t,e){t.readyState=e,t.onreadystatechange&&t.onreadystatechange()}function xo(t,e,n){this.reset(t,e,n,void 0,void 0)}function Lo(t){this.f=t,this.b=this.c=this.a=null}function Fo(t,e){this.name=t,this.value=e}S(Io,Yr),S(Co,Yr),Co.prototype.A=function(){var t={code:this.code,message:this.message};this.email&&(t.email=this.email),this.phoneNumber&&(t.phoneNumber=this.phoneNumber),this.tenantId&&(t.tenantId=this.tenantId);var e=this.credential&&this.credential.A();return e&&z(t,e),t},Co.prototype.toJSON=function(){return this.A()},Ao.prototype.c=null,S(Do,Ao),Do.prototype.a=function(){var t=Ro(this);return t?new ActiveXObject(t):new XMLHttpRequest},Do.prototype.b=function(){var t={};return Ro(this)&&(t[0]=!0,t[1]=!0),t},Eo=new Do,S(Oo,Ao),Oo.prototype.a=function(){var t=new XMLHttpRequest;if("withCredentials"in t)return t;if("undefined"!=typeof XDomainRequest)return new Po;throw Error("Unsupported browser")},Oo.prototype.b=function(){return{}},(t=Po.prototype).open=function(t,e,n){if(null!=n&&!n)throw Error("Only async requests are supported.");this.a.open(t,e)},t.send=function(t){if(t){if("string"!=typeof t)throw Error("Only string data is supported");this.a.send(t)}else this.a.send()},t.abort=function(){this.a.abort()},t.setRequestHeader=function(){},t.getResponseHeader=function(t){return"content-type"==t.toLowerCase()?this.a.contentType:""},t.fc=function(){this.status=200,this.response=this.responseText=this.a.responseText,Mo(this,4)},t.Ib=function(){this.status=500,this.response=this.responseText="",Mo(this,4)},t.kc=function(){this.Ib()},t.gc=function(){this.status=200,Mo(this,1)},t.getAllResponseHeaders=function(){return"content-type: "+this.a.contentType},xo.prototype.a=null,xo.prototype.reset=function(t,e,n,r,i){delete this.a},Fo.prototype.toString=function(){return this.name};var Uo=new Fo("SEVERE",1e3),Vo=new Fo("WARNING",900),qo=new Fo("CONFIG",700),Bo=new Fo("FINE",500);Lo.prototype.log=function(t,e,n){if(t.value>=function t(e){return e.c?e.c:e.a?t(e.a):(A("Root logger has no level set."),null)}(this).value)for(y(e)&&(e=e()),t=new xo(t,String(e),this.f),n&&(t.a=n),n=this;n;)n=n.a};var jo,Wo={},Ko=null;function Qo(t){var e;if(Ko||(Ko=new Lo(""),(Wo[""]=Ko).c=qo),!(e=Wo[t])){e=new Lo(t);var n=t.lastIndexOf("."),r=t.substr(n+1);(n=Qo(t.substr(0,n))).b||(n.b={}),(n.b[r]=e).a=n,Wo[t]=e}return e}function Ho(t,e){t&&t.log(Bo,e,void 0)}function Go(t){this.f=t}function zo(t){nn.call(this),this.o=t,this.readyState=Yo,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.i=new Headers,this.b=null,this.m="GET",this.g="",this.a=!1,this.h=Qo("goog.net.FetchXmlHttp"),this.l=this.c=this.f=null}S(Go,Ao),Go.prototype.a=function(){return new zo(this.f)},Go.prototype.b=(jo={},function(){return jo}),S(zo,nn);var Yo=0;function Xo(t){t.c.read().then(t.ec.bind(t)).catch(t.Oa.bind(t))}function Jo(t,e){e&&t.f&&(t.status=t.f.status,t.statusText=t.f.statusText),t.readyState=4,t.f=null,t.c=null,t.l=null,$o(t)}function $o(t){t.onreadystatechange&&t.onreadystatechange.call(t)}function Zo(t){nn.call(this),this.headers=new ln,this.B=t||null,this.c=!1,this.w=this.a=null,this.h=this.O=this.l="",this.f=this.J=this.i=this.I=!1,this.g=0,this.o=null,this.m=ta,this.v=this.P=!1}(t=zo.prototype).open=function(t,e){if(this.readyState!=Yo)throw this.abort(),Error("Error reopening a connection");this.m=t,this.g=e,this.readyState=1,$o(this)},t.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.a=!0;var e={headers:this.i,method:this.m,credentials:void 0,cache:void 0};t&&(e.body=t),this.o.fetch(new Request(this.g,e)).then(this.jc.bind(this),this.Oa.bind(this))},t.abort=function(){this.response=this.responseText="",this.i=new Headers,this.status=0,this.c&&this.c.cancel("Request was aborted."),1<=this.readyState&&this.a&&4!=this.readyState&&(this.a=!1,Jo(this,!1)),this.readyState=Yo},t.jc=function(t){this.a&&(this.f=t,this.b||(this.b=t.headers,this.readyState=2,$o(this)),this.a&&(this.readyState=3,$o(this),this.a&&("arraybuffer"===this.responseType?t.arrayBuffer().then(this.hc.bind(this),this.Oa.bind(this)):void 0!==l.ReadableStream&&"body"in t?(this.response=this.responseText="",this.c=t.body.getReader(),this.l=new TextDecoder,Xo(this)):t.text().then(this.ic.bind(this),this.Oa.bind(this)))))},t.ec=function(t){if(this.a){var e=this.l.decode(t.value?t.value:new Uint8Array(0),{stream:!t.done});e&&(this.response=this.responseText+=e),t.done?Jo(this,!0):$o(this),3==this.readyState&&Xo(this)}},t.ic=function(t){this.a&&(this.response=this.responseText=t,Jo(this,!0))},t.hc=function(t){this.a&&(this.response=t,Jo(this,!0))},t.Oa=function(t){var e=this.h;e&&e.log(Vo,"Failed to fetch url "+this.g,t instanceof Error?t:Error(t)),this.a&&Jo(this,!0)},t.setRequestHeader=function(t,e){this.i.append(t,e)},t.getResponseHeader=function(t){return this.b?this.b.get(t.toLowerCase())||"":((t=this.h)&&t.log(Vo,"Attempting to get response header but no headers have been received for url: "+this.g,void 0),"")},t.getAllResponseHeaders=function(){if(!this.b){var t=this.h;return t&&t.log(Vo,"Attempting to get all response headers but no headers have been received for url: "+this.g,void 0),""}t=[];for(var e=this.b.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},S(Zo,nn);var ta="";Zo.prototype.b=Qo("goog.net.XhrIo");var ea=/^https?$/i,na=["POST","PUT"];function ra(e,t,n,r,i){if(e.a)throw Error("[goog.net.XhrIo] Object is active with another request="+e.l+"; newUri="+t);n=n?n.toUpperCase():"GET",e.l=t,e.h="",e.O=n,e.I=!1,e.c=!0,e.a=e.B?e.B.a():Eo.a(),e.w=e.B?ko(e.B):ko(Eo),e.a.onreadystatechange=_(e.Lb,e);try{Ho(e.b,fa(e,"Opening Xhr")),e.J=!0,e.a.open(n,String(t),!0),e.J=!1}catch(t){return Ho(e.b,fa(e,"Error opening Xhr: "+t.message)),void oa(e,t)}t=r||"";var o=new ln(e.headers);i&&function(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(m(t)||h(t))L(t,e,void 0);else for(var n=hn(t),r=cn(t),i=r.length,o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}(i,function(t,e){o.set(e,t)}),i=function(t){t:{for(var e=ia,n=t.length,r=h(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return e<0?null:h(t)?t.charAt(e):t[e]}(o.X()),r=l.FormData&&t instanceof l.FormData,!V(na,n)||i||r||o.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),o.forEach(function(t,e){this.a.setRequestHeader(e,t)},e),e.m&&(e.a.responseType=e.m),"withCredentials"in e.a&&e.a.withCredentials!==e.P&&(e.a.withCredentials=e.P);try{ca(e),0<e.g&&(e.v=function(t){return ye&&Ne(9)&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(e.a),Ho(e.b,fa(e,"Will abort after "+e.g+"ms if incomplete, xhr2 "+e.v)),e.v?(e.a.timeout=e.g,e.a.ontimeout=_(e.Ia,e)):e.o=sn(e.Ia,e.g,e)),Ho(e.b,fa(e,"Sending request")),e.i=!0,e.a.send(t),e.i=!1}catch(t){Ho(e.b,fa(e,"Send error: "+t.message)),oa(e,t)}}function ia(t){return"content-type"==t.toLowerCase()}function oa(t,e){t.c=!1,t.a&&(t.f=!0,t.a.abort(),t.f=!1),t.h=e,aa(t),ua(t)}function aa(t){t.I||(t.I=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function sa(e){if(e.c&&void 0!==u)if(e.w[1]&&4==ha(e)&&2==la(e))Ho(e.b,fa(e,"Local request error detected and ignored"));else if(e.i&&4==ha(e))sn(e.Lb,0,e);else if(e.dispatchEvent("readystatechange"),4==ha(e)){Ho(e.b,fa(e,"Request complete")),e.c=!1;try{var t,n=la(e);t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(t=r)){var i;if(i=0===n){var o=String(e.l).match(dn)[1]||null;if(!o&&l.self&&l.self.location){var a=l.self.location.protocol;o=a.substr(0,a.length-1)}i=!ea.test(o?o.toLowerCase():"")}t=i}if(t)e.dispatchEvent("complete"),e.dispatchEvent("success");else{try{var s=2<ha(e)?e.a.statusText:""}catch(t){Ho(e.b,"Can not get status: "+t.message),s=""}e.h=s+" ["+la(e)+"]",aa(e)}}finally{ua(e)}}}function ua(e,t){if(e.a){ca(e);var n=e.a,r=e.w[0]?p:null;e.a=null,e.w=null,t||e.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){(e=e.b)&&e.log(Uo,"Problem encountered resetting onreadystatechange: "+t.message,void 0)}}}function ca(t){t.a&&t.v&&(t.a.ontimeout=null),t.o&&(l.clearTimeout(t.o),t.o=null)}function ha(t){return t.a?t.a.readyState:0}function la(t){try{return 2<ha(t)?t.a.status:-1}catch(t){return-1}}function fa(t,e){return e+" ["+t.O+" "+t.l+" "+la(t)+"]"}function pa(t){var e=Sa;this.g=[],this.v=e,this.o=t||null,this.f=this.a=!1,this.c=void 0,this.u=this.w=this.i=!1,this.h=0,this.b=null,this.l=0}function da(t,e,n){t.a=!0,t.c=n,t.f=!e,va(t)}function ma(t){if(t.a){if(!t.u)throw new ba(t);t.u=!1}}function ya(t,e,n,r){t.g.push([e,n,r]),t.a&&va(t)}function ga(t){return U(t.g,function(t){return y(t[1])})}function va(e){if(e.h&&e.a&&ga(e)){var n=e.h,r=Ta[n];r&&(l.clearTimeout(r.a),delete Ta[n]),e.h=0}e.b&&(e.b.l--,delete e.b),n=e.c;for(var t=r=!1;e.g.length&&!e.i;){var i=e.g.shift(),o=i[0],a=i[1];if(i=i[2],o=e.f?a:o)try{var s=o.call(i||e.o,n);void 0!==s&&(e.f=e.f&&(s==n||s instanceof Error),e.c=n=s),(I(n)||"function"==typeof l.Promise&&n instanceof l.Promise)&&(t=!0,e.i=!0)}catch(t){n=t,e.f=!0,ga(e)||(r=!0)}}e.c=n,t&&(s=_(e.m,e,!0),t=_(e.m,e,!1),n instanceof pa?(ya(n,s,t),n.w=!0):n.then(s,t)),r&&(n=new _a(n),Ta[n.a]=n,e.h=n.a)}function ba(){C.call(this)}function wa(){C.call(this)}function _a(t){this.a=l.setTimeout(_(this.c,this),0),this.b=t}(t=Zo.prototype).Ia=function(){void 0!==u&&this.a&&(this.h="Timed out after "+this.g+"ms, aborting",Ho(this.b,fa(this,this.h)),this.dispatchEvent("timeout"),this.abort(8))},t.abort=function(){this.a&&this.c&&(Ho(this.b,fa(this,"Aborting")),this.c=!1,this.f=!0,this.a.abort(),this.f=!1,this.dispatchEvent("complete"),this.dispatchEvent("abort"),ua(this))},t.za=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),ua(this,!0)),Zo.qb.za.call(this)},t.Lb=function(){this.va||(this.J||this.i||this.f?sa(this):this.yc())},t.yc=function(){sa(this)},t.getResponse=function(){try{if(!this.a)return null;if("response"in this.a)return this.a.response;switch(this.m){case ta:case"text":return this.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in this.a)return this.a.mozResponseArrayBuffer}var t=this.b;return t&&t.log(Uo,"Response type "+this.m+" is not supported on this browser",void 0),null}catch(t){return Ho(this.b,"Can not get response: "+t.message),null}},pa.prototype.cancel=function(t){if(this.a)this.c instanceof pa&&this.c.cancel();else{if(this.b){var e=this.b;delete this.b,t?e.cancel(t):(e.l--,e.l<=0&&e.cancel())}this.v?this.v.call(this.o,this):this.u=!0,this.a||(t=new wa(this),ma(this),da(this,!1,t))}},pa.prototype.m=function(t,e){this.i=!1,da(this,t,e)},pa.prototype.then=function(t,e,n){var r,i,o=new jt(function(t,e){r=t,i=e});return ya(this,r,function(t){t instanceof wa?o.cancel():i(t)}),o.then(t,e,n)},pa.prototype.$goog_Thenable=!0,S(ba,C),ba.prototype.message="Deferred has already fired",ba.prototype.name="AlreadyCalledError",S(wa,C),wa.prototype.message="Deferred was canceled",wa.prototype.name="CanceledError",_a.prototype.c=function(){throw delete Ta[this.a],this.b};var Ta={};function Ea(t){var e,n=document,r=et(t).toString(),i=document.createElement("SCRIPT"),o={Nb:i,Ia:void 0},a=new pa(o);return e=window.setTimeout(function(){Ia(i,!0);var t=new Aa(Na,"Timeout reached for loading script "+r);ma(a),da(a,!1,t)},5e3),o.Ia=e,i.onload=i.onreadystatechange=function(){i.readyState&&"loaded"!=i.readyState&&"complete"!=i.readyState||(Ia(i,!1,e),ma(a),da(a,!0,null))},i.onerror=function(){Ia(i,!0,e);var t=new Aa(Ca,"Error while loading script "+r);ma(a),da(a,!1,t)},z(o={},{type:"text/javascript",charset:"UTF-8"}),Bn(i,o),function(t,e){M(t,"HTMLScriptElement"),t.src=et(e),null===f&&(f=(e=(e=l.document).querySelector&&e.querySelector("script[nonce]"))&&(e=e.nonce||e.getAttribute("nonce"))&&s.test(e)?e:""),(e=f)&&t.setAttribute("nonce",e)}(i,t),function(t){var e;return(e=(t||document).getElementsByTagName("HEAD"))&&0!=e.length?e[0]:t.documentElement}(n).appendChild(i),a}function Sa(){if(this&&this.Nb){var t=this.Nb;t&&"SCRIPT"==t.tagName&&Ia(t,!0,this.Ia)}}function Ia(t,e,n){null!=n&&l.clearTimeout(n),t.onload=p,t.onerror=p,t.onreadystatechange=p,e&&window.setTimeout(function(){t&&t.parentNode&&t.parentNode.removeChild(t)},0)}var Ca=0,Na=1;function Aa(t,e){var n="Jsloader error (code #"+t+")";e&&(n+=": "+e),C.call(this,n),this.code=t}function ka(t){this.f=t}function Da(t,e,n){if(this.c=t,t=e||{},this.l=t.secureTokenEndpoint||"https://securetoken.googleapis.com/v1/token",this.u=t.secureTokenTimeout||Pa,this.g=H(t.secureTokenHeaders||Ma),this.h=t.firebaseEndpoint||"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",this.i=t.firebaseTimeout||xa,this.a=H(t.firebaseHeaders||La),n&&(this.a["X-Client-Version"]=n,this.g["X-Client-Version"]=n),n="Node"==ur(),!(n=l.XMLHttpRequest||n&&fl.INTERNAL.node&&fl.INTERNAL.node.XMLHttpRequest)&&!sr())throw new Yr("internal-error","The XMLHttpRequest compatibility library was not found.");this.f=void 0,sr()?this.f=new Go(self):cr()?this.f=new ka(n):this.f=new Oo,this.b=null}S(Aa,C),S(ka,Ao),ka.prototype.a=function(){return new this.f},ka.prototype.b=function(){return{}};var Ra,Oa="idToken",Pa=new Ar(3e4,6e4),Ma={"Content-Type":"application/x-www-form-urlencoded"},xa=new Ar(3e4,6e4),La={"Content-Type":"application/json"};function Fa(t,e){e?t.a["X-Firebase-Locale"]=e:delete t.a["X-Firebase-Locale"]}function Ua(t,e){e?(t.a["X-Client-Version"]=e,t.g["X-Client-Version"]=e):(delete t.a["X-Client-Version"],delete t.g["X-Client-Version"])}function Va(t,e,n,r,i,o,a){(t=function(){var t=mr();return!((t=fr(t)!=lr?null:(t=t.match(/\sChrome\/(\d+)/i))&&2==t.length?parseInt(t[1],10):null)&&t<30)&&(!ye||!Ie||9<Ie)}()||sr()?_(t.o,t):(Ra=Ra||new jt(function(t,e){!function(t,e){if(((window.gapi||{}).client||{}).request)t();else{l[Ba]=function(){((window.gapi||{}).client||{}).request?t():e(Error("CORS_UNSUPPORTED"))},function(t,e){ya(t,null,e,void 0)}(Ea(nt(qa,{onload:Ba})),function(){e(Error("CORS_UNSUPPORTED"))})}}(t,e)}),_(t.m,t)))(e,n,r,i,o,a)}Da.prototype.R=function(){return this.b},Da.prototype.o=function(t,n,e,r,i,o){if(sr()&&(void 0===l.fetch||void 0===l.Headers||void 0===l.Request))throw new Yr("operation-not-supported-in-this-environment","fetch, Headers and Request native APIs or equivalent Polyfills must be available to support HTTP requests from a Worker environment.");var a=new Zo(this.f);if(o){a.g=Math.max(0,o);var s=setTimeout(function(){a.dispatchEvent("timeout")},o)}rn(a,"complete",function(){s&&clearTimeout(s);var e=null;try{e=JSON.parse(function(e){try{return e.a?e.a.responseText:""}catch(t){return Ho(e.b,"Can not get responseText: "+t.message),""}}(this))||null}catch(t){e=null}n&&n(e)}),on(a,"ready",function(){s&&clearTimeout(s),le(this)}),on(a,"timeout",function(){s&&clearTimeout(s),le(this),n&&n(null)}),ra(a,t,e,r,i)};var qa=new Y($,"https://apis.google.com/js/client.js?onload=%{onload}"),Ba="__fcb"+Math.floor(1e6*Math.random()).toString();function ja(t){if(!h(t=t.email)||!rr.test(t))throw new Yr("invalid-email")}function Wa(t){"email"in t&&ja(t)}function Ka(t){if(!t[Oa])throw new Yr("internal-error")}function Qa(t){if(t.phoneNumber||t.temporaryProof){if(!t.phoneNumber||!t.temporaryProof)throw new Yr("internal-error")}else{if(!t.sessionInfo)throw new Yr("missing-verification-id");if(!t.code)throw new Yr("missing-verification-code")}}Da.prototype.m=function(t,n,r,i,o){var a=this;Ra.then(function(){window.gapi.client.setApiKey(a.c);var e=window.gapi.auth.getToken();window.gapi.auth.setToken(null),window.gapi.client.request({path:t,method:r,body:i,headers:o,authType:"none",callback:function(t){window.gapi.auth.setToken(e),n&&n(t)}})}).s(function(t){n&&n({error:{message:t&&t.message||"CORS_UNSUPPORTED"}})})},Da.prototype.ob=function(){return Ns(this,vs,{})},Da.prototype.rb=function(t,e){return Ns(this,ys,{idToken:t,email:e})},Da.prototype.sb=function(t,e){return Ns(this,gs,{idToken:t,password:e})};var Ha={displayName:"DISPLAY_NAME",photoUrl:"PHOTO_URL"};function Ga(t){if(!t.requestUri||!t.sessionId&&!t.postBody&&!t.pendingToken)throw new Yr("internal-error")}function za(t,e){return e.oauthIdToken&&e.providerId&&0==e.providerId.indexOf("oidc.")&&!e.pendingToken&&(t.sessionId?e.nonce=t.sessionId:t.postBody&&(xn(t=new Rn(t.postBody),"nonce")&&(e.nonce=t.get("nonce")))),e}function Ya(t){var e=null;if(t.needConfirmation?(t.code="account-exists-with-different-credential",e=No(t)):"FEDERATED_USER_ID_ALREADY_LINKED"==t.errorMessage?(t.code="credential-already-in-use",e=No(t)):"EMAIL_EXISTS"==t.errorMessage?(t.code="email-already-in-use",e=No(t)):t.errorMessage&&(e=As(t.errorMessage)),e)throw e;if(!t[Oa])throw new Yr("internal-error")}function Xa(t,e){return e.returnIdpCredential=!0,Ns(t,bs,e)}function Ja(t,e){return e.returnIdpCredential=!0,Ns(t,_s,e)}function $a(t,e){return e.returnIdpCredential=!0,e.autoCreate=!1,Ns(t,ws,e)}function Za(t){if(!t.oobCode)throw new Yr("invalid-action-code")}(t=Da.prototype).tb=function(t,r){var i={idToken:t},o=[];return K(Ha,function(t,e){var n=r[e];null===n?o.push(t):e in r&&(i[e]=n)}),o.length&&(i.deleteAttribute=o),Ns(this,ys,i)},t.kb=function(t,e){return z(t={requestType:"PASSWORD_RESET",email:t},e),Ns(this,ls,t)},t.lb=function(t,e){return z(t={requestType:"EMAIL_SIGNIN",email:t},e),Ns(this,cs,t)},t.jb=function(t,e){return z(t={requestType:"VERIFY_EMAIL",idToken:t},e),Ns(this,hs,t)},t.Wa=function(t){return Ns(this,Ss,t)},t.ab=function(t,e){return Ns(this,ds,{oobCode:t,newPassword:e})},t.Ma=function(t){return Ns(this,es,{oobCode:t})},t.Ya=function(t){return Ns(this,ts,{oobCode:t})};var ts={endpoint:"setAccountInfo",D:Za,fa:"email",F:!0},es={endpoint:"resetPassword",D:Za,K:function(t){var e=t.requestType;if(!e||!t.email&&"EMAIL_SIGNIN"!=e)throw new Yr("internal-error")},F:!0},ns={endpoint:"signupNewUser",D:function(t){if(ja(t),!t.password)throw new Yr("weak-password")},K:Ka,T:!0,F:!0},rs={endpoint:"createAuthUri",F:!0},is={endpoint:"deleteAccount",V:["idToken"]},os={endpoint:"setAccountInfo",V:["idToken","deleteProvider"],D:function(t){if(!d(t.deleteProvider))throw new Yr("internal-error")}},as={endpoint:"emailLinkSignin",V:["email","oobCode"],D:ja,K:Ka,T:!0,F:!0},ss={endpoint:"emailLinkSignin",V:["idToken","email","oobCode"],D:ja,K:Ka,T:!0},us={endpoint:"getAccountInfo"},cs={endpoint:"getOobConfirmationCode",V:["requestType"],D:function(t){if("EMAIL_SIGNIN"!=t.requestType)throw new Yr("internal-error");ja(t)},fa:"email",F:!0},hs={endpoint:"getOobConfirmationCode",V:["idToken","requestType"],D:function(t){if("VERIFY_EMAIL"!=t.requestType)throw new Yr("internal-error")},fa:"email",F:!0},ls={endpoint:"getOobConfirmationCode",V:["requestType"],D:function(t){if("PASSWORD_RESET"!=t.requestType)throw new Yr("internal-error");ja(t)},fa:"email",F:!0},fs={wb:!0,endpoint:"getProjectConfig",Kb:"GET"},ps={wb:!0,endpoint:"getRecaptchaParam",Kb:"GET",K:function(t){if(!t.recaptchaSiteKey)throw new Yr("internal-error")}},ds={endpoint:"resetPassword",D:Za,fa:"email",F:!0},ms={endpoint:"sendVerificationCode",V:["phoneNumber","recaptchaToken"],fa:"sessionInfo",F:!0},ys={endpoint:"setAccountInfo",V:["idToken"],D:Wa,T:!0},gs={endpoint:"setAccountInfo",V:["idToken"],D:function(t){if(Wa(t),!t.password)throw new Yr("weak-password")},K:Ka,T:!0},vs={endpoint:"signupNewUser",K:Ka,T:!0,F:!0},bs={endpoint:"verifyAssertion",D:Ga,Ra:za,K:Ya,T:!0,F:!0},ws={endpoint:"verifyAssertion",D:Ga,Ra:za,K:function(t){if(t.errorMessage&&"USER_NOT_FOUND"==t.errorMessage)throw new Yr("user-not-found");if(t.errorMessage)throw As(t.errorMessage);if(!t[Oa])throw new Yr("internal-error")},T:!0,F:!0},_s={endpoint:"verifyAssertion",D:function(t){if(Ga(t),!t.idToken)throw new Yr("internal-error")},Ra:za,K:Ya,T:!0},Ts={endpoint:"verifyCustomToken",D:function(t){if(!t.token)throw new Yr("invalid-custom-token")},K:Ka,T:!0,F:!0},Es={endpoint:"verifyPassword",D:function(t){if(ja(t),!t.password)throw new Yr("wrong-password")},K:Ka,T:!0,F:!0},Ss={endpoint:"verifyPhoneNumber",D:Qa,K:Ka,F:!0},Is={endpoint:"verifyPhoneNumber",D:function(t){if(!t.idToken)throw new Yr("internal-error");Qa(t)},K:function(t){if(t.temporaryProof)throw t.code="credential-already-in-use",No(t);Ka(t)}},Cs={Yb:{USER_NOT_FOUND:"user-not-found"},endpoint:"verifyPhoneNumber",D:Qa,K:Ka,F:!0};function Ns(t,e,n){if(!function(t,e){if(!e||!e.length)return!0;if(!t)return!1;for(var n=0;n<e.length;n++){var r=t[e[n]];if(null==r||""===r)return!1}return!0}(n,e.V))return Xt(new Yr("internal-error"));var r,i=e.Kb||"POST";return Yt(n).then(e.D).then(function(){return e.T&&(n.returnSecureToken=!0),e.F&&t.b&&void 0===n.tenantId&&(n.tenantId=t.b),function(t,e,r,i,o,n){var a=_n(t.h+e);bn(a,"key",t.c),n&&bn(a,"cb",E().toString());var s="GET"==r;if(s)for(var u in i)i.hasOwnProperty(u)&&bn(a,u,i[u]);return new jt(function(e,n){Va(t,a.toString(),function(t){t?t.error?n(ks(t,o||{})):e(t):n(new Yr("network-request-failed"))},r,s?void 0:Qn(Er(i)),t.a,t.i.get())})}(t,e.endpoint,i,n,e.Yb,e.wb||!1)}).then(function(t){return r=t,e.Ra?e.Ra(n,r):r}).then(e.K).then(function(){if(!e.fa)return r;if(!(e.fa in r))throw new Yr("internal-error");return r[e.fa]})}function As(t){return ks({error:{errors:[{message:t}],code:400,message:t}})}function ks(t,e){var n=(t.error&&t.error.errors&&t.error.errors[0]||{}).reason||"",r={keyInvalid:"invalid-api-key",ipRefererBlocked:"app-not-authorized"};if(n=r[n]?new Yr(r[n]):null)return n;for(var i in n=t.error&&t.error.message||"",z(r={INVALID_CUSTOM_TOKEN:"invalid-custom-token",CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_EMAIL:"invalid-email",INVALID_PASSWORD:"wrong-password",USER_DISABLED:"user-disabled",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_OR_INVALID_NONCE:"missing-or-invalid-nonce",INVALID_MESSAGE_PAYLOAD:"invalid-message-payload",INVALID_RECIPIENT_EMAIL:"invalid-recipient-email",INVALID_SENDER:"invalid-sender",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",INVALID_PROVIDER_ID:"invalid-provider-id",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",CORS_UNSUPPORTED:"cors-unsupported",DYNAMIC_LINK_NOT_ACTIVATED:"dynamic-link-not-activated",INVALID_APP_ID:"invalid-app-id",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",WEAK_PASSWORD:"weak-password",OPERATION_NOT_ALLOWED:"operation-not-allowed",USER_CANCELLED:"user-cancelled",CAPTCHA_CHECK_FAILED:"captcha-check-failed",INVALID_APP_CREDENTIAL:"invalid-app-credential",INVALID_CODE:"invalid-verification-code",INVALID_PHONE_NUMBER:"invalid-phone-number",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_APP_CREDENTIAL:"missing-app-credential",MISSING_CODE:"missing-verification-code",MISSING_PHONE_NUMBER:"missing-phone-number",MISSING_SESSION_INFO:"missing-verification-id",QUOTA_EXCEEDED:"quota-exceeded",SESSION_EXPIRED:"code-expired",REJECTED_CREDENTIAL:"rejected-credential",INVALID_CONTINUE_URI:"invalid-continue-uri",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",MISSING_IOS_BUNDLE_ID:"missing-ios-bundle-id",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_DYNAMIC_LINK_DOMAIN:"invalid-dynamic-link-domain",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",INVALID_CERT_HASH:"invalid-cert-hash",UNSUPPORTED_TENANT_OPERATION:"unsupported-tenant-operation",INVALID_TENANT_ID:"invalid-tenant-id",TENANT_ID_MISMATCH:"tenant-id-mismatch",ADMIN_ONLY_OPERATION:"admin-restricted-operation"},e||{}),e=(e=n.match(/^[^\s]+\s*:\s*([\s\S]*)$/))&&1<e.length?e[1]:void 0,r)if(0===n.indexOf(i))return new Yr(r[i],e);return!e&&t&&(e=Tr(t)),new Yr("internal-error",e)}function Ds(t){this.b=t,this.a=null,this.gb=function(o){return(Ms=Ms||new jt(function(t,e){function n(){Nr(),yr("gapi.load")("gapi.iframes",{callback:t,ontimeout:function(){Nr(),e(Error("Network Error"))},timeout:Os.get()})}if(yr("gapi.iframes.Iframe"))t();else if(yr("gapi.load"))n();else{var r="__iframefcb"+Math.floor(1e6*Math.random()).toString();l[r]=function(){yr("gapi.load")?n():e(Error("Network Error"))},Yt(Ea(r=nt(Rs,{onload:r}))).s(function(){e(Error("Network Error"))})}}).s(function(t){throw Ms=null,t})).then(function(){return new jt(function(r,i){yr("gapi.iframes.getContext")().open({where:document.body,url:o.b,messageHandlersFilter:yr("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"),attributes:{style:{position:"absolute",top:"-100px",width:"1px",height:"1px"}},dontclear:!0},function(t){function e(){clearTimeout(n),r()}o.a=t,o.a.restyle({setHideOnLeave:!1});var n=setTimeout(function(){i(Error("Network Error"))},Ps.get());t.ping(e).then(e,function(){i(Error("Network Error"))})})})})}(this)}var Rs=new Y($,"https://apis.google.com/js/api.js?onload=%{onload}"),Os=new Ar(3e4,6e4),Ps=new Ar(5e3,15e3),Ms=null;function xs(t,e,n){this.i=t,this.g=e,this.h=n,this.f=null,this.a=Tn(this.i,"/__/auth/iframe"),bn(this.a,"apiKey",this.g),bn(this.a,"appName",this.h),this.b=null,this.c=[]}function Ls(t,e,n,r,i){this.o=t,this.m=e,this.c=n,this.u=r,this.i=this.g=this.l=null,this.a=i,this.h=this.f=null}function Fs(t){try{return fl.app(t).auth().Ca()}catch(t){return[]}}function Us(t,e,n,r,i){this.u=t,this.f=e,this.b=n,this.c=r||null,this.h=i||null,this.m=this.o=this.v=null,this.g=[],this.l=this.a=null}function Vs(t){var s=Jn();return function(t){return Ns(t,fs,{}).then(function(t){return t.authorizedDomains||[]})}(t).then(function(t){t:{var e=_n(s),n=e.f;e=e.b;for(var r=0;r<t.length;r++){var i=t[r],o=e,a=n;if(o=0==i.indexOf("chrome-extension://")?_n(i).b==o&&"chrome-extension"==a:("http"==a||"https"==a)&&(nr.test(i)?o==i:(i=i.split(".").join("\\."),new RegExp("^(.+\\."+i+"|"+i+")$","i").test(o)))){t=!0;break t}}t=!1}if(!t)throw new Io(Jn())})}function qs(i){return i.l||(i.l=ir().then(function(){if(!i.o){var t=i.c,e=i.h,n=Fs(i.b),r=new xs(i.u,i.f,i.b);r.f=t,r.b=e,r.c=W(n||[]),i.o=r.toString()}i.i=new Ds(i.o),function(r){if(!r.i)throw Error("IfcHandler must be initialized!");!function(t,e){t.gb.then(function(){t.a.register("authEvent",e,yr("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})}(r.i,function(t){var e={};if(t&&t.authEvent){var n=!1;for(t=_o(t.authEvent),e=0;e<r.g.length;e++)n=r.g[e](t)||n;return(e={}).status=n?"ACK":"ERROR",Yt(e)}return e.status="ERROR",Yt(e)})}(i)})),i.l}function Bs(t){return t.m||(t.v=t.c?dr(t.c,Fs(t.b)):null,t.m=new Da(t.f,Ni(t.h),t.v)),t.m}function js(t,e,n,r,i,o,a,s,u,c,h){return(t=new Ls(t,e,n,r,i)).l=o,t.g=a,t.i=s,t.b=H(u||null),t.f=c,t.nb(h).toString()}function Ws(t){if(this.a=t||fl.INTERNAL.reactNative&&fl.INTERNAL.reactNative.AsyncStorage,!this.a)throw new Yr("internal-error","The React Native compatibility library was not found.");this.type="asyncStorage"}function Ks(t){this.b=t,this.a={},this.f=_(this.c,this)}xs.prototype.toString=function(){return this.f?bn(this.a,"v",this.f):Mn(this.a.a,"v"),this.b?bn(this.a,"eid",this.b):Mn(this.a.a,"eid"),this.c.length?bn(this.a,"fw",this.c.join(",")):Mn(this.a.a,"fw"),this.a.toString()},Ls.prototype.nb=function(t){return this.h=t,this},Ls.prototype.toString=function(){var t=Tn(this.o,"/__/auth/handler");if(bn(t,"apiKey",this.m),bn(t,"appName",this.c),bn(t,"authType",this.u),this.a.isOAuthProvider){var e=this.a;try{var n=fl.app(this.c).auth().ha()}catch(t){n=null}for(var r in e.bb=n,bn(t,"providerId",this.a.providerId),n=Er((e=this.a).zb))n[r]=n[r].toString();r=e.Fc,n=H(n);for(var i=0;i<r.length;i++){var o=r[i];o in n&&delete n[o]}e.eb&&e.bb&&!n[e.eb]&&(n[e.eb]=e.bb),Q(n)||bn(t,"customParameters",Tr(n))}if("function"==typeof this.a.Hb&&((e=this.a.Hb()).length&&bn(t,"scopes",e.join(","))),this.l?bn(t,"redirectUrl",this.l):Mn(t.a,"redirectUrl"),this.g?bn(t,"eventId",this.g):Mn(t.a,"eventId"),this.i?bn(t,"v",this.i):Mn(t.a,"v"),this.b)for(var a in this.b)this.b.hasOwnProperty(a)&&!wn(t,a)&&bn(t,a,this.b[a]);return this.h?bn(t,"tid",this.h):Mn(t.a,"tid"),this.f?bn(t,"eid",this.f):Mn(t.a,"eid"),(a=Fs(this.c)).length&&bn(t,"fw",a.join(",")),t.toString()},(t=Us.prototype).Fb=function(e,n,t){var r=new Yr("popup-closed-by-user"),i=new Yr("web-storage-unsupported"),o=this,a=!1;return this.ia().then(function(){(function(t){var e={type:"webStorageSupport"};return qs(t).then(function(){return function(e,n){return e.gb.then(function(){return new jt(function(t){e.a.send(n.type,n,t,yr("gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER"))})})}(t.i,e)}).then(function(t){if(t&&t.length&&void 0!==t[0].webStorageSupport)return t[0].webStorageSupport;throw Error()})})(o).then(function(t){t||(e&&tr(e),n(i),a=!0)})}).s(function(){}).then(function(){if(!a)return function(n){return new jt(function(e){return function t(){un(2e3).then(function(){if(n&&!n.closed)return t();e()})}()})}(e)}).then(function(){if(!a)return un(t).then(function(){n(r)})})},t.Ob=function(){var t=mr();return!_r(t)&&!Cr(t)},t.Jb=function(){return!1},t.Db=function(e,t,n,r,i,o,a,s){if(!e)return Xt(new Yr("popup-blocked"));if(a&&!_r())return this.ia().s(function(t){tr(e),i(t)}),r(),Yt();this.a||(this.a=Vs(Bs(this)));var u=this;return this.a.then(function(){var t=u.ia().s(function(t){throw tr(e),i(t),t});return r(),t}).then(function(){bo(n),a||$n(js(u.u,u.f,u.b,t,n,null,o,u.c,void 0,u.h,s),e)}).s(function(t){throw"auth/network-request-failed"==t.code&&(u.a=null),t})},t.Eb=function(t,e,n,r){this.a||(this.a=Vs(Bs(this)));var i=this;return this.a.then(function(){bo(e),$n(js(i.u,i.f,i.b,t,e,Jn(),n,i.c,void 0,i.h,r))}).s(function(t){throw"auth/network-request-failed"==t.code&&(i.a=null),t})},t.ia=function(){var t=this;return qs(this).then(function(){return t.i.gb}).s(function(){throw t.a=null,new Yr("network-request-failed")})},t.Rb=function(){return!0},t.Aa=function(t){this.g.push(t)},t.Na=function(e){B(this.g,function(t){return t==e})},(t=Ws.prototype).get=function(t){return Yt(this.a.getItem(t)).then(function(t){return t&&Sr(t)})},t.set=function(t,e){return Yt(this.a.setItem(t,Tr(e)))},t.S=function(t){return Yt(this.a.removeItem(t))},t.$=function(){},t.ea=function(){};var Qs,Hs=[];function Gs(t,e,n){Q(t.a)&&t.b.addEventListener("message",t.f),void 0===t.a[e]&&(t.a[e]=[]),t.a[e].push(n)}function zs(t){this.a=t}function Ys(t){this.c=t,this.b=!1,this.a=[]}function Xs(r,t,e,n){var i,o,a,s,u=e||{},c=null;if(r.b)return Xt(Error("connection_unavailable"));var h=n?800:50,l="undefined"!=typeof MessageChannel?new MessageChannel:null;return new jt(function(e,n){l?(i=Math.floor(Math.random()*Math.pow(10,20)).toString(),l.port1.start(),a=setTimeout(function(){n(Error("unsupported_event"))},h),c={messageChannel:l,onMessage:o=function(t){t.data.eventId===i&&("ack"===t.data.status?(clearTimeout(a),s=setTimeout(function(){n(Error("timeout"))},3e3)):"done"===t.data.status?(clearTimeout(s),void 0!==t.data.response?e(t.data.response):n(Error("unknown_error"))):(clearTimeout(a),clearTimeout(s),n(Error("invalid_response"))))}},r.a.push(c),l.port1.addEventListener("message",o),r.c.postMessage({eventType:t,eventId:i,data:u},[l.port2])):n(Error("connection_unavailable"))}).then(function(t){return Js(r,c),t}).s(function(t){throw Js(r,c),t})}function Js(t,e){if(e){var n=e.messageChannel,r=e.onMessage;n&&(n.port1.removeEventListener("message",r),n.port1.close()),B(t.a,function(t){return t==e})}}function $s(){if(!eu())throw new Yr("web-storage-unsupported");this.c={},this.a=[],this.b=0,this.u=l.indexedDB,this.type="indexedDB",this.g=this.l=this.f=this.i=null,this.o=!1,this.h=null;var r=this;sr()&&self?(this.l=function(){var e=sr()?self:null;if(L(Hs,function(t){t.b==e&&(n=t)}),!n){var n=new Ks(e);Hs.push(n)}return n}(),Gs(this.l,"keyChanged",function(t,n){return au(r).then(function(e){return 0<e.length&&L(r.a,function(t){t(e)}),{keyProcessed:V(e,n.key)}})}),Gs(this.l,"ping",function(){return Yt(["keyChanged"])})):function(){var t=l.navigator;return t&&t.serviceWorker?Yt().then(function(){return t.serviceWorker.ready}).then(function(t){return t.active||null}).s(function(){return null}):Yt(null)}().then(function(t){(r.h=t)&&(r.g=new Ys(new zs(t)),Xs(r.g,"ping",null,!0).then(function(t){t[0].fulfilled&&V(t[0].value,"keyChanged")&&(r.o=!0)}).s(function(){}))})}function Zs(r){return new jt(function(e,n){var t=r.u.open("firebaseLocalStorageDb",1);t.onerror=function(t){try{t.preventDefault()}catch(t){}n(Error(t.target.error))},t.onupgradeneeded=function(t){t=t.target.result;try{t.createObjectStore("firebaseLocalStorage",{keyPath:"fbase_key"})}catch(t){n(t)}},t.onsuccess=function(t){(t=t.target.result).objectStoreNames.contains("firebaseLocalStorage")?e(t):function(r){return new jt(function(t,e){var n=r.u.deleteDatabase("firebaseLocalStorageDb");n.onsuccess=function(){t()},n.onerror=function(t){e(Error(t.target.error))}})}(r).then(function(){return Zs(r)}).then(function(t){e(t)}).s(function(t){n(t)})}})}function tu(t){return t.m||(t.m=Zs(t)),t.m}function eu(){try{return!!l.indexedDB}catch(t){return!1}}function nu(t){return t.objectStore("firebaseLocalStorage")}function ru(t,e){return t.transaction(["firebaseLocalStorage"],e?"readwrite":"readonly")}function iu(t){return new jt(function(e,n){t.onsuccess=function(t){t&&t.target?e(t.target.result):e()},t.onerror=function(t){n(t.target.error)}})}function ou(t,e){return t.g&&t.h&&function(){var t=l.navigator;return t&&t.serviceWorker&&t.serviceWorker.controller||null}()===t.h?Xs(t.g,"keyChanged",{key:e},t.o).then(function(){}).s(function(){}):Yt()}function au(r){return tu(r).then(function(t){var i=nu(ru(t,!1));return i.getAll?iu(i.getAll()):new jt(function(e,n){var r=[],t=i.openCursor();t.onsuccess=function(t){(t=t.target.result)?(r.push(t.value),t.continue()):e(r)},t.onerror=function(t){n(t.target.error)}})}).then(function(t){var e={},n=[];if(0==r.b){for(n=0;n<t.length;n++)e[t[n].fbase_key]=t[n].value;n=function t(e,n){var r,i=[];for(r in e)r in n?typeof e[r]!=typeof n[r]?i.push(r):"object"==typeof e[r]&&null!=e[r]&&null!=n[r]?0<t(e[r],n[r]).length&&i.push(r):e[r]!==n[r]&&i.push(r):i.push(r);for(r in n)r in e||i.push(r);return i}(r.c,e),r.c=e}return n})}function su(t){t.i&&t.i.cancel("STOP_EVENT"),t.f&&(clearTimeout(t.f),t.f=null)}function uu(t){var r=this,i=null;this.a=[],this.type="indexedDB",this.c=t,this.b=Yt().then(function(){if(eu()){var e=Ir(),n="__sak"+e;return Qs=Qs||new $s,(i=Qs).set(n,e).then(function(){return i.get(n)}).then(function(t){if(t!==e)throw Error("indexedDB not supported!");return i.S(n)}).then(function(){return i}).s(function(){return r.c})}return r.c}).then(function(t){return r.type=t.type,t.$(function(e){L(r.a,function(t){t(e)})}),t})}function cu(){this.a={},this.type="inMemory"}function hu(){if(!function(){var t="Node"==ur();if(!(t=lu()||t&&fl.INTERNAL.node&&fl.INTERNAL.node.localStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==ur())throw new Yr("internal-error","The LocalStorage compatibility library was not found.");throw new Yr("web-storage-unsupported")}this.a=lu()||fl.INTERNAL.node.localStorage,this.type="localStorage"}function lu(){try{var t=l.localStorage,e=Ir();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}function fu(){this.type="nullStorage"}function pu(){if(!function(){var t="Node"==ur();if(!(t=du()||t&&fl.INTERNAL.node&&fl.INTERNAL.node.sessionStorage))return!1;try{return t.setItem("__sak","1"),t.removeItem("__sak"),!0}catch(t){return!1}}()){if("Node"==ur())throw new Yr("internal-error","The SessionStorage compatibility library was not found.");throw new Yr("web-storage-unsupported")}this.a=du()||fl.INTERNAL.node.sessionStorage,this.type="sessionStorage"}function du(){try{var t=l.sessionStorage,e=Ir();return t&&(t.setItem(e,"1"),t.removeItem(e)),t}catch(t){return null}}function mu(){var t={};t.Browser=vu,t.Node=bu,t.ReactNative=wu,t.Worker=_u,this.a=t[ur()]}Ks.prototype.c=function(n){var r=n.data.eventType,i=n.data.eventId,t=this.a[r];if(t&&0<t.length){n.ports[0].postMessage({status:"ack",eventId:i,eventType:r,response:null});var e=[];L(t,function(t){e.push(Yt().then(function(){return t(n.origin,n.data.data)}))}),$t(e).then(function(t){var e=[];L(t,function(t){e.push({fulfilled:t.Gb,value:t.value,reason:t.reason?t.reason.message:void 0})}),L(e,function(t){for(var e in t)void 0===t[e]&&delete t[e]}),n.ports[0].postMessage({status:"done",eventId:i,eventType:r,response:e})})}},zs.prototype.postMessage=function(t,e){this.a.postMessage(t,e)},Ys.prototype.close=function(){for(;0<this.a.length;)Js(this,this.a[0]);this.b=!0},(t=$s.prototype).set=function(n,r){var i,o=!1,a=this;return tu(this).then(function(t){return iu((t=nu(ru(i=t,!0))).get(n))}).then(function(t){var e=nu(ru(i,!0));return t?(t.value=r,iu(e.put(t))):(a.b++,o=!0,(t={}).fbase_key=n,t.value=r,iu(e.add(t)))}).then(function(){return a.c[n]=r,ou(a,n)}).ka(function(){o&&a.b--})},t.get=function(e){return tu(this).then(function(t){return iu(nu(ru(t,!1)).get(e))}).then(function(t){return t&&t.value})},t.S=function(e){var n=!1,r=this;return tu(this).then(function(t){return n=!0,r.b++,iu(nu(ru(t,!0)).delete(e))}).then(function(){return delete r.c[e],ou(r,e)}).ka(function(){n&&r.b--})},t.$=function(t){0==this.a.length&&function(t){su(t),function e(){t.f=setTimeout(function(){t.i=au(t).then(function(e){0<e.length&&L(t.a,function(t){t(e)})}).then(function(){e()}).s(function(t){"STOP_EVENT"!=t.message&&e()})},800)}()}(this),this.a.push(t)},t.ea=function(e){B(this.a,function(t){return t==e}),0==this.a.length&&su(this)},(t=uu.prototype).get=function(e){return this.b.then(function(t){return t.get(e)})},t.set=function(e,n){return this.b.then(function(t){return t.set(e,n)})},t.S=function(e){return this.b.then(function(t){return t.S(e)})},t.$=function(t){this.a.push(t)},t.ea=function(e){B(this.a,function(t){return t==e})},(t=cu.prototype).get=function(t){return Yt(this.a[t])},t.set=function(t,e){return this.a[t]=e,Yt()},t.S=function(t){return delete this.a[t],Yt()},t.$=function(){},t.ea=function(){},(t=hu.prototype).get=function(t){var e=this;return Yt().then(function(){return Sr(e.a.getItem(t))})},t.set=function(e,n){var r=this;return Yt().then(function(){var t=Tr(n);null===t?r.S(e):r.a.setItem(e,t)})},t.S=function(t){var e=this;return Yt().then(function(){e.a.removeItem(t)})},t.$=function(t){l.window&&Ke(l.window,"storage",t)},t.ea=function(t){l.window&&Ge(l.window,"storage",t)},(t=fu.prototype).get=function(){return Yt(null)},t.set=function(){return Yt()},t.S=function(){return Yt()},t.$=function(){},t.ea=function(){},(t=pu.prototype).get=function(t){var e=this;return Yt().then(function(){return Sr(e.a.getItem(t))})},t.set=function(e,n){var r=this;return Yt().then(function(){var t=Tr(n);null===t?r.S(e):r.a.setItem(e,t)})},t.S=function(t){var e=this;return Yt().then(function(){e.a.removeItem(t)})},t.$=function(){},t.ea=function(){};var yu,gu,vu={C:hu,Ta:pu},bu={C:hu,Ta:pu},wu={C:Ws,Ta:fu},_u={C:hu,Ta:fu},Tu={ad:"local",NONE:"none",cd:"session"};function Eu(){var t=!(Cr(mr())||!ar()),e=_r(),n=gr();this.m=t,this.h=e,this.l=n,this.a={},t=yu=yu||new mu;try{this.g=!Xn()&&Rr()||!l.indexedDB?new t.a.C:new uu(sr()?new cu:new t.a.C)}catch(t){this.g=new cu,this.h=!0}try{this.i=new t.a.Ta}catch(t){this.i=new cu}this.u=new cu,this.f=_(this.Pb,this),this.b={}}function Su(){return gu=gu||new Eu}function Iu(t,e){switch(e){case"session":return t.i;case"none":return t.u;default:return t.g}}function Cu(t,e){return"firebase:"+t.name+(e?":"+e:"")}function Nu(t,e,n){return n=Cu(e,n),"local"==e.C&&(t.b[n]=null),Iu(t,e.C).S(n)}function Au(t){t.c&&(clearInterval(t.c),t.c=null)}function ku(t){this.a=t,this.b=Su()}(t=Eu.prototype).get=function(t,e){return Iu(this,t.C).get(Cu(t,e))},t.set=function(e,t,n){var r=Cu(e,n),i=this,o=Iu(this,e.C);return o.set(r,t).then(function(){return o.get(r)}).then(function(t){"local"==e.C&&(i.b[r]=t)})},t.addListener=function(t,e,n){t=Cu(t,e),this.l&&(this.b[t]=l.localStorage.getItem(t)),Q(this.a)&&(Iu(this,"local").$(this.f),this.h||(Xn()||!Rr())&&l.indexedDB||!this.l||function(r){Au(r),r.c=setInterval(function(){for(var t in r.a){var e=l.localStorage.getItem(t),n=r.b[t];e!=n&&(r.b[t]=e,e=new Pe({type:"storage",key:t,target:window,oldValue:n,newValue:e,a:!0}),r.Pb(e))}},1e3)}(this)),this.a[t]||(this.a[t]=[]),this.a[t].push(n)},t.removeListener=function(t,e,n){t=Cu(t,e),this.a[t]&&(B(this.a[t],function(t){return t==n}),0==this.a[t].length&&delete this.a[t]),Q(this.a)&&(Iu(this,"local").ea(this.f),Au(this))},t.Pb=function(t){if(t&&t.f){var e=t.a.key;if(null==e)for(var n in this.a){var r=this.b[n];void 0===r&&(r=null);var i=l.localStorage.getItem(n);i!==r&&(this.b[n]=i,this.$a(n))}else if(0==e.indexOf("firebase:")&&this.a[e]){if(void 0!==t.a.a?Iu(this,"local").ea(this.f):Au(this),this.m)if(n=l.localStorage.getItem(e),(r=t.a.newValue)!==n)null!==r?l.localStorage.setItem(e,r):l.localStorage.removeItem(e);else if(this.b[e]===r&&void 0===t.a.a)return;var o=this;n=function(){void 0===t.a.a&&o.b[e]===l.localStorage.getItem(e)||(o.b[e]=l.localStorage.getItem(e),o.$a(e))},ye&&Ie&&10==Ie&&l.localStorage.getItem(e)!==t.a.newValue&&t.a.newValue!==t.a.oldValue?setTimeout(n,10):n()}}else L(t,_(this.$a,this))},t.$a=function(t){this.a[t]&&L(this.a[t],function(t){t()})};var Du,Ru={name:"authEvent",C:"local"};function Ou(){this.a=Su()}function Pu(t,e){this.b=Mu,this.f=l.Uint8Array?new Uint8Array(this.b):Array(this.b),this.g=this.c=0,this.a=[],this.i=t,this.h=e,this.l=l.Int32Array?new Int32Array(64):Array(64),void 0!==Du||(Du=l.Int32Array?new Int32Array(Bu):Bu),this.reset()}S(Pu,function(){this.b=-1});for(var Mu=64,xu=Mu-1,Lu=[],Fu=0;Fu<xu;Fu++)Lu[Fu]=0;var Uu=j(128,Lu);function Vu(t){for(var e=t.f,n=t.l,r=0,i=0;i<e.length;)n[r++]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3],i=4*r;for(e=16;e<64;e++){i=0|n[e-15],r=0|n[e-2];var o=(0|n[e-16])+((i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3)|0,a=(0|n[e-7])+((r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10)|0;n[e]=o+a|0}r=0|t.a[0],i=0|t.a[1];var s=0|t.a[2],u=0|t.a[3],c=0|t.a[4],h=0|t.a[5],l=0|t.a[6];for(o=0|t.a[7],e=0;e<64;e++){var f=((r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10))+(r&i^r&s^i&s)|0;a=(o=o+((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))|0)+((a=(a=c&h^~c&l)+(0|Du[e])|0)+(0|n[e])|0)|0,o=l,l=h,h=c,c=u+a|0,u=s,s=i,i=r,r=a+f|0}t.a[0]=t.a[0]+r|0,t.a[1]=t.a[1]+i|0,t.a[2]=t.a[2]+s|0,t.a[3]=t.a[3]+u|0,t.a[4]=t.a[4]+c|0,t.a[5]=t.a[5]+h|0,t.a[6]=t.a[6]+l|0,t.a[7]=t.a[7]+o|0}function qu(t,e,n){void 0===n&&(n=e.length);var r=0,i=t.c;if(h(e))for(;r<n;)t.f[i++]=e.charCodeAt(r++),i==t.b&&(Vu(t),i=0);else{if(!m(e))throw Error("message must be string or array");for(;r<n;){var o=e[r++];if(!("number"==typeof o&&0<=o&&o<=255&&o==(0|o)))throw Error("message must be a byte array");t.f[i++]=o,i==t.b&&(Vu(t),i=0)}}t.c=i,t.g+=n}Pu.prototype.reset=function(){this.g=this.c=0,this.a=l.Int32Array?new Int32Array(this.h):W(this.h)};var Bu=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function ju(){Pu.call(this,8,Wu)}S(ju,Pu);var Wu=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];function Ku(t,e,n,r,i){this.u=t,this.i=e,this.l=n,this.m=r||null,this.o=i||null,this.h=e+":"+n,this.v=new Ou,this.g=new ku(this.h),this.f=null,this.b=[],this.a=this.c=null}function Qu(t){return new Yr("invalid-cordova-configuration",t)}function Hu(t){var e=new ju;qu(e,t),t=[];var n=8*e.g;e.c<56?qu(e,Uu,56-e.c):qu(e,Uu,e.b-(e.c-56));for(var r=63;56<=r;r--)e.f[r]=255&n,n/=256;for(Vu(e),r=n=0;r<e.i;r++)for(var i=24;0<=i;i-=8)t[n++]=e.a[r]>>i&255;return function(t){return F(t,function(t){return 1<(t=t.toString(16)).length?t:"0"+t}).join("")}(t)}function Gu(t,e){for(var n=0;n<t.b.length;n++)try{t.b[n](e)}catch(t){}}function zu(r){return r.f||(r.f=r.ia().then(function(){return new jt(function(n){r.Aa(function t(e){return n(e),r.Na(t),!1}),function(i){function e(r){t=!0,n&&n.cancel(),Yu(i).then(function(t){var e=o;if(t&&r&&r.url){var n=null;-1!=(e=Bi(r.url)).indexOf("/__/auth/callback")&&(n=(n="object"==typeof(n=Sr(wn(n=_n(e),"firebaseError")||null))?Xr(n):null)?new wo(t.c,t.b,null,null,n,null,t.R()):new wo(t.c,t.b,e,t.f,null,null,t.R())),e=n||o}Gu(i,e)})}var o=new wo("unknown",null,null,null,new Yr("no-auth-event")),t=!1,n=un(500).then(function(){return Yu(i).then(function(){t||Gu(i,o)})}),r=l.handleOpenURL;l.handleOpenURL=function(t){if(0==t.toLowerCase().indexOf(yr("BuildInfo.packageName",l).toLowerCase()+"://")&&e({url:t}),"function"==typeof r)try{r(t)}catch(t){console.error(t)}},So=So||new To,function(t){var n=So;n.a.push(t),n.b||(n.b=function(t){for(var e=0;e<n.a.length;e++)n.a[e](t)},"function"==typeof(t=yr("universalLinks.subscribe",l))&&t(null,n.b))}(e)}(r)})})),r.f}function Yu(e){var n=null;return function(t){return t.b.get(Ru,t.a).then(function(t){return _o(t)})}(e.g).then(function(t){return n=t,Nu((t=e.g).b,Ru,t.a)}).then(function(){return n})}function Xu(t){this.a=t,this.b=Su()}(t=Ku.prototype).ia=function(){return this.Da?this.Da:this.Da=(or(void 0)?ir().then(function(){return new jt(function(t,e){var n=l.document,r=setTimeout(function(){e(Error("Cordova framework is not ready."))},1e3);n.addEventListener("deviceready",function(){clearTimeout(r),t()},!1)})}):Xt(Error("Cordova must run in an Android or iOS file scheme."))).then(function(){if("function"!=typeof yr("universalLinks.subscribe",l))throw Qu("cordova-universal-links-plugin-fix is not installed");if(void 0===yr("BuildInfo.packageName",l))throw Qu("cordova-plugin-buildinfo is not installed");if("function"!=typeof yr("cordova.plugins.browsertab.openUrl",l))throw Qu("cordova-plugin-browsertab is not installed");if("function"!=typeof yr("cordova.InAppBrowser.open",l))throw Qu("cordova-plugin-inappbrowser is not installed")},function(){throw new Yr("cordova-not-ready")})},t.Fb=function(t,e){return e(new Yr("operation-not-supported-in-this-environment")),Yt()},t.Db=function(){return Xt(new Yr("operation-not-supported-in-this-environment"))},t.Rb=function(){return!1},t.Ob=function(){return!0},t.Jb=function(){return!0},t.Eb=function(t,e,n,r){if(this.c)return Xt(new Yr("redirect-operation-pending"));var i=this,o=l.document,a=null,s=null,u=null,c=null;return this.c=Yt().then(function(){return bo(e),zu(i)}).then(function(){return function(n,t,e,r,i){var o=function(){for(var t=20,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}(),a=new wo(t,r,null,o,new Yr("no-auth-event"),null,i),s=yr("BuildInfo.packageName",l);if("string"!=typeof s)throw new Yr("invalid-cordova-configuration");var u=yr("BuildInfo.displayName",l),c={};if(mr().toLowerCase().match(/iphone|ipad|ipod/))c.ibi=s;else{if(!mr().toLowerCase().match(/android/))return Xt(new Yr("operation-not-supported-in-this-environment"));c.apn=s}u&&(c.appDisplayName=u),o=Hu(o),c.sessionId=o;var h=js(n.u,n.i,n.l,t,e,null,r,n.m,c,n.o,i);return n.ia().then(function(){var t=n.h;return n.v.a.set(Ru,a.A(),t)}).then(function(){var t=yr("cordova.plugins.browsertab.isAvailable",l);if("function"!=typeof t)throw new Yr("invalid-cordova-configuration");var e=null;t(function(t){if(t){if("function"!=typeof(e=yr("cordova.plugins.browsertab.openUrl",l)))throw new Yr("invalid-cordova-configuration");e(h)}else{if("function"!=typeof(e=yr("cordova.InAppBrowser.open",l)))throw new Yr("invalid-cordova-configuration");t=mr(),n.a=e(h,t.match(/(iPad|iPhone|iPod).*OS 7_\d/i)||t.match(/(iPad|iPhone|iPod).*OS 8_\d/i)?"_blank":"_system","location=yes")}})})}(i,t,e,n,r)}).then(function(){return new jt(function(e,t){s=function(){var t=yr("cordova.plugins.browsertab.close",l);return e(),"function"==typeof t&&t(),i.a&&"function"==typeof i.a.close&&(i.a.close(),i.a=null),!1},i.Aa(s),u=function(){a=a||un(2e3).then(function(){t(new Yr("redirect-cancelled-by-user"))})},c=function(){kr()&&u()},o.addEventListener("resume",u,!1),mr().toLowerCase().match(/android/)||o.addEventListener("visibilitychange",c,!1)}).s(function(t){return Yu(i).then(function(){throw t})})}).ka(function(){u&&o.removeEventListener("resume",u,!1),c&&o.removeEventListener("visibilitychange",c,!1),a&&a.cancel(),s&&i.Na(s),i.c=null})},t.Aa=function(e){this.b.push(e),zu(this).s(function(t){"auth/invalid-cordova-configuration"===t.code&&(t=new wo("unknown",null,null,null,new Yr("no-auth-event")),e(t))})},t.Na=function(e){B(this.b,function(t){return t==e})};var Ju={name:"pendingRedirect",C:"session"};function $u(t){return Nu(t.b,Ju,t.a)}function Zu(t,e,n){this.i={},this.v=0,this.B=t,this.u=e,this.m=n,this.h=[],this.f=!1,this.l=_(this.o,this),this.b=new pc,this.w=new vc,this.g=new Xu(this.u+":"+this.m),this.c={},this.c.unknown=this.b,this.c.signInViaRedirect=this.b,this.c.linkViaRedirect=this.b,this.c.reauthViaRedirect=this.b,this.c.signInViaPopup=this.w,this.c.linkViaPopup=this.w,this.c.reauthViaPopup=this.w,this.a=tc(this.B,this.u,this.m,Ii)}function tc(t,e,n,r){var i=fl.SDK_VERSION||null;return or()?new Ku(t,e,n,i,r):new Us(t,e,n,i,r)}function ec(e){e.f||(e.f=!0,e.a.Aa(e.l));var n=e.a;return e.a.ia().s(function(t){throw e.a==n&&e.reset(),t})}function nc(n){n.a.Ob()&&ec(n).s(function(t){var e=new wo("unknown",null,null,null,new Yr("operation-not-supported-in-this-environment"));uc(t)&&n.o(e)}),n.a.Jb()||dc(n.b)}function rc(n,t){V(n.h,t)||n.h.push(t),n.f||function(t){return t.b.get(Ju,t.a).then(function(t){return"pending"==t})}(n.g).then(function(t){t?$u(n.g).then(function(){ec(n).s(function(t){var e=new wo("unknown",null,null,null,new Yr("operation-not-supported-in-this-environment"));uc(t)&&n.o(e)})}):nc(n)}).s(function(){nc(n)})}function ic(t,e){B(t.h,function(t){return t==e})}Zu.prototype.reset=function(){this.f=!1,this.a.Na(this.l),this.a=tc(this.B,this.u,this.m),this.i={}},Zu.prototype.o=function(t){if(!t)throw new Yr("invalid-auth-event");if(6e5<=E()-this.v&&(this.i={},this.v=0),t&&t.getUid()&&this.i.hasOwnProperty(t.getUid()))return!1;for(var e=!1,n=0;n<this.h.length;n++){var r=this.h[n];if(r.xb(t.c,t.b)){(e=this.c[t.c])&&(e.h(t,r),t&&(t.f||t.b)&&(this.i[t.getUid()]=!0,this.v=E())),e=!0;break}}return dc(this.b),e};var oc=new Ar(2e3,1e4),ac=new Ar(3e4,6e4);function sc(t,e,n,r,i,o,a){return t.a.Db(e,n,r,function(){t.f||(t.f=!0,t.a.Aa(t.l))},function(){t.reset()},i,o,a)}function uc(t){return!(!t||"auth/cordova-not-ready"!=t.code)}function cc(e,t,n,r,i){var o;return function(t){return t.b.set(Ju,"pending",t.a)}(e.g).then(function(){return e.a.Eb(t,n,r,i).s(function(t){if(uc(t))throw new Yr("operation-not-supported-in-this-environment");return o=t,$u(e.g).then(function(){throw o})}).then(function(){return e.a.Rb()?new jt(function(){}):$u(e.g).then(function(){return e.oa()}).then(function(){}).s(function(){})})})}function hc(t,e,n,r,i){return t.a.Fb(r,function(t){e.ja(n,null,t,i)},oc.get())}Zu.prototype.oa=function(){return this.b.oa()};var lc={};function fc(t,e,n){var r=e+":"+n;return lc[r]||(lc[r]=new Zu(t,e,n)),lc[r]}function pc(){this.b=null,this.f=[],this.c=[],this.a=null,this.i=this.g=!1}function dc(t){t.g||(t.g=!0,gc(t,!1,null,null))}function mc(t){t.g&&!t.i&&gc(t,!1,null,null)}function yc(t,e){if(t.b=function(){return Yt(e)},t.f.length)for(var n=0;n<t.f.length;n++)t.f[n](e)}function gc(t,e,n,r){e?r?function(t,e){if(t.b=function(){return Xt(e)},t.c.length)for(var n=0;n<t.c.length;n++)t.c[n](e)}(t,r):yc(t,n):yc(t,{user:null}),t.f=[],t.c=[]}function vc(){}function bc(){this.vb=!1,Object.defineProperty(this,"appVerificationDisabled",{get:function(){return this.vb},set:function(t){this.vb=t},enumerable:!1})}function wc(t,e){this.a=e,Lr(this,"verificationId",t)}function _c(t,e,n,r){return new yo(t).Wa(e,n).then(function(t){return new wc(t,r)})}function Tc(t){var e=Si(t);if(!(e&&e.exp&&e.auth_time&&e.iat))throw new Yr("internal-error","An internal error occurred. The token obtained by Firebase appears to be malformed. Please retry the operation.");Fr(this,{token:t,expirationTime:Dr(1e3*e.exp),authTime:Dr(1e3*e.auth_time),issuedAtTime:Dr(1e3*e.iat),signInProvider:e.firebase&&e.firebase.sign_in_provider?e.firebase.sign_in_provider:null,claims:e})}function Ec(t,e,n){if(this.h=t,this.i=e,this.g=n,this.c=3e4,this.f=96e4,this.b=null,this.a=this.c,this.f<this.c)throw Error("Proactive refresh lower bound greater than upper bound!")}function Sc(t,e){return e?(t.a=t.c,t.g()):(e=t.a,t.a*=2,t.a>t.f&&(t.a=t.f),e)}function Ic(t){this.f=t,this.b=this.a=null,this.c=0}function Cc(t,e){var n=e[Oa],r=e.refreshToken;e=Nc(e.expiresIn),t.b=n,t.c=e,t.a=r}function Nc(t){return E()+1e3*parseInt(t,10)}function Ac(e,t){return function(t,r){return new jt(function(e,n){"refresh_token"==r.grant_type&&r.refresh_token||"authorization_code"==r.grant_type&&r.code?Va(t,t.l+"?key="+encodeURIComponent(t.c),function(t){t?t.error?n(ks(t)):t.access_token&&t.refresh_token?e(t):n(new Yr("internal-error")):n(new Yr("network-request-failed"))},"POST",Pn(r).toString(),t.g,t.u.get()):n(new Yr("internal-error"))})}(e.f,t).then(function(t){return e.b=t.access_token,e.c=Nc(t.expires_in),e.a=t.refresh_token,{accessToken:e.b,expirationTime:e.c,refreshToken:e.a}}).s(function(t){throw"auth/user-token-expired"==t.code&&(e.a=null),t})}function kc(t,e){this.a=t||null,this.b=e||null,Fr(this,{lastSignInTime:Dr(e||null),creationTime:Dr(t||null)})}function Dc(t,e,n,r,i,o){Fr(this,{uid:t,displayName:r||null,photoURL:i||null,email:n||null,phoneNumber:o||null,providerId:e})}function Rc(t,e){for(var n in Oe.call(this,t),e)this[n]=e[n]}function Oc(t,e,n){this.I=[],this.l=t.apiKey,this.m=t.appName,this.o=t.authDomain||null,t=fl.SDK_VERSION?dr(fl.SDK_VERSION):null,this.a=new Da(this.l,Ni(Ii),t),this.b=new Ic(this.a),Vc(this,e[Oa]),Cc(this.b,e),Lr(this,"refreshToken",this.b.a),jc(this,n||{}),nn.call(this),this.J=!1,this.o&&vr()&&(this.i=fc(this.o,this.l,this.m)),this.O=[],this.h=null,this.w=function(e){return new Ec(function(){return e.G(!0)},function(t){return!(!t||"auth/network-request-failed"!=t.code)},function(){var t=e.b.c-E()-3e5;return 0<t?t:0})}(this),this.W=_(this.Ja,this);var r=this;this.ga=null,this.xa=function(t){r.ua(t.g)},this.Z=null,this.P=[],this.wa=function(t){Mc(r,t.c)},this.Y=null}function Pc(t,e){t.Z&&Ge(t.Z,"languageCodeChanged",t.xa),(t.Z=e)&&Ke(e,"languageCodeChanged",t.xa)}function Mc(t,e){t.P=e,Ua(t.a,fl.SDK_VERSION?dr(fl.SDK_VERSION,t.P):null)}function xc(t,e){t.Y&&Ge(t.Y,"frameworkChanged",t.wa),(t.Y=e)&&Ke(e,"frameworkChanged",t.wa)}function Lc(e){try{return fl.app(e.m).auth()}catch(t){throw new Yr("internal-error","No firebase.auth.Auth instance is available for the Firebase App '"+e.m+"'!")}}function Fc(t){t.B||t.w.b||(t.w.start(),Ge(t,"tokenChanged",t.W),Ke(t,"tokenChanged",t.W))}function Uc(t){Ge(t,"tokenChanged",t.W),t.w.stop()}function Vc(t,e){t.ma=e,Lr(t,"_lat",e)}function qc(t){for(var e=[],n=0;n<t.O.length;n++)e.push(t.O[n](t));return $t(e).then(function(){return t})}function Bc(t){t.i&&!t.J&&(t.J=!0,rc(t.i,t))}function jc(t,e){Fr(t,{uid:e.uid,displayName:e.displayName||null,photoURL:e.photoURL||null,email:e.email||null,emailVerified:e.emailVerified||!1,phoneNumber:e.phoneNumber||null,isAnonymous:e.isAnonymous||!1,tenantId:e.tenantId||null,metadata:new kc(e.createdAt,e.lastLoginAt),providerData:[]}),t.a.b=t.tenantId}function Wc(){}function Kc(t){return Yt().then(function(){if(t.B)throw new Yr("app-deleted")})}function Qc(t){return F(t.providerData,function(t){return t.providerId})}function Hc(t,e){e&&(Gc(t,e.providerId),t.providerData.push(e))}function Gc(t,e){B(t.providerData,function(t){return t.providerId==e})}function zc(t,e,n){("uid"!=e||n)&&t.hasOwnProperty(e)&&Lr(t,e,n)}function Yc(e,t){e!=t&&(Fr(e,{uid:t.uid,displayName:t.displayName,photoURL:t.photoURL,email:t.email,emailVerified:t.emailVerified,phoneNumber:t.phoneNumber,isAnonymous:t.isAnonymous,tenantId:t.tenantId,providerData:[]}),t.metadata?Lr(e,"metadata",function(t){return new kc(t.a,t.b)}(t.metadata)):Lr(e,"metadata",new kc),L(t.providerData,function(t){Hc(e,t)}),function(t,e){t.b=e.b,t.a=e.a,t.c=e.c}(e.b,t.b),Lr(e,"refreshToken",e.b.a))}function Xc(n){return n.G().then(function(t){var e=n.isAnonymous;return function(t,e){return Ns(t.a,us,{idToken:e}).then(_(t.zc,t))}(n,t).then(function(){return e||zc(n,"isAnonymous",!1),t})})}function Jc(t,e){e[Oa]&&t.ma!=e[Oa]&&(Cc(t.b,e),t.dispatchEvent(new Rc("tokenChanged")),Vc(t,e[Oa]),zc(t,"refreshToken",t.b.a))}function $c(t,e){return Xc(t).then(function(){if(V(Qc(t),e))return qc(t).then(function(){throw new Yr("provider-already-linked")})})}function Zc(t,e,n){return Ur({user:t,credential:vo(e),additionalUserInfo:e=Oi(e),operationType:n})}function th(t,e){return Jc(t,e),t.reload().then(function(){return t})}function eh(n,r,t,e,i){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));if(n.h&&!i)return Xt(n.h);var o=Ri(t.providerId),a=Ir(n.uid+":::"),s=null;(!_r()||ar())&&n.o&&t.isOAuthProvider&&(s=js(n.o,n.l,n.m,r,t,null,a,fl.SDK_VERSION||null,null,null,n.tenantId));var u=er(s,o&&o.sa,o&&o.ra);return e=e().then(function(){if(rh(n),!i)return n.G().then(function(){})}).then(function(){return sc(n.i,u,r,t,a,!!s,n.tenantId)}).then(function(){return new jt(function(t,e){n.ja(r,null,new Yr("cancelled-popup-request"),n.g||null),n.f=t,n.v=e,n.g=a,n.c=hc(n.i,n,r,u,a)})}).then(function(t){return u&&tr(u),t?Ur(t):null}).s(function(t){throw u&&tr(u),t}),ih(n,e,i)}function nh(e,t,n,r,i){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));if(e.h&&!i)return Xt(e.h);var o=null,a=Ir(e.uid+":::");return r=r().then(function(){if(rh(e),!i)return e.G().then(function(){})}).then(function(){return e.ca=a,qc(e)}).then(function(t){return e.da&&(t=(t=e.da).b.set(sh,e.A(),t.a)),t}).then(function(){return cc(e.i,t,n,a,e.tenantId)}).s(function(t){if(o=t,e.da)return uh(e.da);throw o}).then(function(){if(o)throw o}),ih(e,r,i)}function rh(t){if(!t.i||!t.J){if(t.i&&!t.J)throw new Yr("internal-error");throw new Yr("auth-domain-config-required")}}function ih(t,e,n){var r=function(e,t,n){return e.h&&!n?(t.cancel(),Xt(e.h)):t.s(function(t){throw!t||"auth/user-disabled"!=t.code&&"auth/user-token-expired"!=t.code||(e.h||e.dispatchEvent(new Rc("userInvalidated")),e.h=t),t})}(t,e,n);return t.I.push(r),r.ka(function(){q(t.I,r)}),r}function oh(t){if(!t.apiKey)return null;var e={apiKey:t.apiKey,authDomain:t.authDomain,appName:t.appName},n={};if(!(t.stsTokenManager&&t.stsTokenManager.accessToken&&t.stsTokenManager.expirationTime))return null;n[Oa]=t.stsTokenManager.accessToken,n.refreshToken=t.stsTokenManager.refreshToken||null,n.expiresIn=(t.stsTokenManager.expirationTime-E())/1e3;var r=new Oc(e,n,t);return t.providerData&&L(t.providerData,function(t){t&&Hc(r,Ur(t))}),t.redirectEventId&&(r.ca=t.redirectEventId),r}function ah(t){this.a=t,this.b=Su()}pc.prototype.reset=function(){this.b=null,this.a&&(this.a.cancel(),this.a=null)},pc.prototype.h=function(t,e){if(t){this.reset(),this.g=!0;var n=t.c,r=t.b,i=t.a&&"auth/web-storage-unsupported"==t.a.code,o=t.a&&"auth/operation-not-supported-in-this-environment"==t.a.code;this.i=!(!i&&!o),"unknown"!=n||i||o?t.a?(gc(this,!0,null,t.a),Yt()):e.Ba(n,r)?function(e,t,n){n=n.Ba(t.c,t.b);var r=t.g,i=t.f,o=t.i,a=t.R(),s=!!t.c.match(/Redirect$/);n(r,i,a,o).then(function(t){gc(e,s,t,null)}).s(function(t){gc(e,s,null,t)})}(this,t,e):Xt(new Yr("invalid-auth-event")):(gc(this,!1,null,null),Yt())}else Xt(new Yr("invalid-auth-event"))},pc.prototype.oa=function(){var n=this;return new jt(function(t,e){n.b?n.b().then(t,e):(n.f.push(t),n.c.push(e),function(t){var e=new Yr("timeout");t.a&&t.a.cancel(),t.a=un(ac.get()).then(function(){t.b||(t.g=!0,gc(t,!0,null,e))})}(n))})},vc.prototype.h=function(t,e){if(t){var n=t.c,r=t.b;t.a?(e.ja(t.c,null,t.a,t.b),Yt()):e.Ba(n,r)?function(t,e){var n=t.b,r=t.c;e.Ba(r,n)(t.g,t.f,t.R(),t.i).then(function(t){e.ja(r,t,null,n)}).s(function(t){e.ja(r,null,t,n)})}(t,e):Xt(new Yr("invalid-auth-event"))}else Xt(new Yr("invalid-auth-event"))},wc.prototype.confirm=function(t){return t=go(this.verificationId,t),this.a(t)},Ec.prototype.start=function(){this.a=this.c,function e(n,t){n.stop();n.b=un(Sc(n,t)).then(function(){return e=l.document,n=null,kr()||!e?Yt():new jt(function(t){n=function(){kr()&&(e.removeEventListener("visibilitychange",n,!1),t())},e.addEventListener("visibilitychange",n,!1)}).s(function(t){throw e.removeEventListener("visibilitychange",n,!1),t});var e,n}).then(function(){return n.h()}).then(function(){e(n,!0)}).s(function(t){n.i(t)&&e(n,!1)})}(this,!0)},Ec.prototype.stop=function(){this.b&&(this.b.cancel(),this.b=null)},Ic.prototype.A=function(){return{apiKey:this.f.c,refreshToken:this.a,accessToken:this.b,expirationTime:this.c}},Ic.prototype.getToken=function(t){return t=!!t,this.b&&!this.a?Xt(new Yr("user-token-expired")):t||!this.b||E()>this.c-3e4?this.a?Ac(this,{grant_type:"refresh_token",refresh_token:this.a}):Yt(null):Yt({accessToken:this.b,expirationTime:this.c,refreshToken:this.a})},kc.prototype.A=function(){return{lastLoginAt:this.b,createdAt:this.a}},S(Rc,Oe),S(Oc,nn),Oc.prototype.ua=function(t){this.ga=t,Fa(this.a,t)},Oc.prototype.ha=function(){return this.ga},Oc.prototype.Ca=function(){return W(this.P)},Oc.prototype.Ja=function(){this.w.b&&(this.w.stop(),this.w.start())},Lr(Oc.prototype,"providerId","firebase"),(t=Oc.prototype).reload=function(){var t=this;return ih(this,Kc(this).then(function(){return Xc(t).then(function(){return qc(t)}).then(Wc)}))},t.dc=function(t){return this.G(t).then(function(t){return new Tc(t)})},t.G=function(t){var e=this;return ih(this,Kc(this).then(function(){return e.b.getToken(t)}).then(function(t){if(!t)throw new Yr("internal-error");return t.accessToken!=e.ma&&(Vc(e,t.accessToken),e.dispatchEvent(new Rc("tokenChanged"))),zc(e,"refreshToken",t.refreshToken),t.accessToken}))},t.zc=function(t){if(!(t=t.users)||!t.length)throw new Yr("internal-error");jc(this,{uid:(t=t[0]).localId,displayName:t.displayName,photoURL:t.photoUrl,email:t.email,emailVerified:!!t.emailVerified,phoneNumber:t.phoneNumber,lastLoginAt:t.lastLoginAt,createdAt:t.createdAt,tenantId:t.tenantId});for(var e=function(t){return(t=t.providerUserInfo)&&t.length?F(t,function(t){return new Dc(t.rawId,t.providerId,t.email,t.displayName,t.photoUrl,t.phoneNumber)}):[]}(t),n=0;n<e.length;n++)Hc(this,e[n]);zc(this,"isAnonymous",!(this.email&&t.passwordHash||this.providerData&&this.providerData.length))},t.Ac=function(t){return Mr("firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.reauthenticateWithCredential instead."),this.hb(t)},t.hb=function(t){var e=this,n=null;return ih(this,t.f(this.a,this.uid).then(function(t){return Jc(e,t),n=Zc(e,t,"reauthenticate"),e.h=null,e.reload()}).then(function(){return n}),!0)},t.rc=function(t){return Mr("firebase.User.prototype.linkAndRetrieveDataWithCredential is deprecated. Please use firebase.User.prototype.linkWithCredential instead."),this.fb(t)},t.fb=function(e){var n=this,r=null;return ih(this,$c(this,e.providerId).then(function(){return n.G()}).then(function(t){return e.b(n.a,t)}).then(function(t){return r=Zc(n,t,"link"),th(n,t)}).then(function(){return r}))},t.sc=function(t,e){var n=this;return ih(this,$c(this,"phone").then(function(){return _c(Lc(n),t,e,_(n.fb,n))}))},t.Bc=function(t,e){var n=this;return ih(this,Yt().then(function(){return _c(Lc(n),t,e,_(n.hb,n))}),!0)},t.rb=function(e){var n=this;return ih(this,this.G().then(function(t){return n.a.rb(t,e)}).then(function(t){return Jc(n,t),n.reload()}))},t.Sc=function(e){var n=this;return ih(this,this.G().then(function(t){return e.b(n.a,t)}).then(function(t){return Jc(n,t),n.reload()}))},t.sb=function(e){var n=this;return ih(this,this.G().then(function(t){return n.a.sb(t,e)}).then(function(t){return Jc(n,t),n.reload()}))},t.tb=function(e){if(void 0===e.displayName&&void 0===e.photoURL)return Kc(this);var n=this;return ih(this,this.G().then(function(t){return n.a.tb(t,{displayName:e.displayName,photoUrl:e.photoURL})}).then(function(t){return Jc(n,t),zc(n,"displayName",t.displayName||null),zc(n,"photoURL",t.photoUrl||null),L(n.providerData,function(t){"password"===t.providerId&&(Lr(t,"displayName",n.displayName),Lr(t,"photoURL",n.photoURL))}),qc(n)}).then(Wc))},t.Qc=function(e){var n=this;return ih(this,Xc(this).then(function(t){return V(Qc(n),e)?function(t,e,n){return Ns(t,os,{idToken:e,deleteProvider:n})}(n.a,t,[e]).then(function(t){var e={};return L(t.providerUserInfo||[],function(t){e[t.providerId]=!0}),L(Qc(n),function(t){e[t]||Gc(n,t)}),e[yo.PROVIDER_ID]||Lr(n,"phoneNumber",null),qc(n)}):qc(n).then(function(){throw new Yr("no-such-provider")})}))},t.delete=function(){var e=this;return ih(this,this.G().then(function(t){return Ns(e.a,is,{idToken:t})}).then(function(){e.dispatchEvent(new Rc("userDeleted"))})).then(function(){for(var t=0;t<e.I.length;t++)e.I[t].cancel("app-deleted");Pc(e,null),xc(e,null),e.I=[],e.B=!0,Uc(e),Lr(e,"refreshToken",null),e.i&&ic(e.i,e)})},t.xb=function(t,e){return!!("linkViaPopup"==t&&(this.g||null)==e&&this.f||"reauthViaPopup"==t&&(this.g||null)==e&&this.f||"linkViaRedirect"==t&&(this.ca||null)==e||"reauthViaRedirect"==t&&(this.ca||null)==e)},t.ja=function(t,e,n,r){"linkViaPopup"!=t&&"reauthViaPopup"!=t||r!=(this.g||null)||(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.Ba=function(t,e){return"linkViaPopup"==t&&e==(this.g||null)?_(this.Bb,this):"reauthViaPopup"==t&&e==(this.g||null)?_(this.Cb,this):"linkViaRedirect"==t&&(this.ca||null)==e?_(this.Bb,this):"reauthViaRedirect"==t&&(this.ca||null)==e?_(this.Cb,this):null},t.tc=function(t){var e=this;return eh(this,"linkViaPopup",t,function(){return $c(e,t.providerId).then(function(){return qc(e)})},!1)},t.Cc=function(t){return eh(this,"reauthViaPopup",t,function(){return Yt()},!0)},t.uc=function(t){var e=this;return nh(this,"linkViaRedirect",t,function(){return $c(e,t.providerId)},!1)},t.Dc=function(t){return nh(this,"reauthViaRedirect",t,function(){return Yt()},!0)},t.Bb=function(e,n,t,r){var i=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return t=this.G().then(function(t){return Ja(i.a,{requestUri:e,postBody:r,sessionId:n,idToken:t})}).then(function(t){return o=Zc(i,t,"link"),th(i,t)}).then(function(){return o}),ih(this,t)},t.Cb=function(t,e,n,r){var i=this;this.c&&(this.c.cancel(),this.c=null);var o=null;return ih(this,Yt().then(function(){return Wi($a(i.a,{requestUri:t,sessionId:e,postBody:r,tenantId:n}),i.uid)}).then(function(t){return o=Zc(i,t,"reauthenticate"),Jc(i,t),i.h=null,i.reload()}).then(function(){return o}),!0)},t.jb=function(e){var n=this,r=null;return ih(this,this.G().then(function(t){return r=t,void 0===e||Q(e)?{}:vi(new ui(e))}).then(function(t){return n.a.jb(r,t)}).then(function(t){if(n.email!=t)return n.reload()}).then(function(){}))},t.toJSON=function(){return this.A()},t.A=function(){var e={uid:this.uid,displayName:this.displayName,photoURL:this.photoURL,email:this.email,emailVerified:this.emailVerified,phoneNumber:this.phoneNumber,isAnonymous:this.isAnonymous,tenantId:this.tenantId,providerData:[],apiKey:this.l,appName:this.m,authDomain:this.o,stsTokenManager:this.b.A(),redirectEventId:this.ca||null};return this.metadata&&z(e,this.metadata.A()),L(this.providerData,function(t){e.providerData.push(function(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&(n[e]=t[e]);return n}(t))}),e};var sh={name:"redirectUser",C:"session"};function uh(t){return Nu(t.b,sh,t.a)}function ch(t){this.a=t,this.b=Su(),this.c=null,this.f=function(e){var n=fh("local"),r=fh("session"),i=fh("none");return function(n,r,i){var o=Cu(r,i),a=Iu(n,r.C);return n.get(r,i).then(function(t){var e=null;try{e=Sr(l.localStorage.getItem(o))}catch(t){}if(e&&!t)return l.localStorage.removeItem(o),n.set(r,e,i);e&&t&&"localStorage"!=a.type&&l.localStorage.removeItem(o)})}(e.b,n,e.a).then(function(){return e.b.get(r,e.a)}).then(function(t){return t?r:e.b.get(i,e.a).then(function(t){return t?i:e.b.get(n,e.a).then(function(t){return t?n:e.b.get(lh,e.a).then(function(t){return t?fh(t):n})})})}).then(function(t){return e.c=t,hh(e,t.C)}).s(function(){e.c||(e.c=n)})}(this),this.b.addListener(fh("local"),this.a,_(this.g,this))}function hh(t,e){var n,r=[];for(n in Tu)Tu[n]!==e&&r.push(Nu(t.b,fh(Tu[n]),t.a));return r.push(Nu(t.b,lh,t.a)),function(s){return new jt(function(n,e){var r=s.length,i=[];if(r)for(var t=function(t,e){r--,i[t]=e,0==r&&n(i)},o=function(t){e(t)},a=0;a<s.length;a++)Jt(s[a],T(t,a),o);else n(i)})}(r)}ch.prototype.g=function(){var e=this,n=fh("local");yh(this,function(){return Yt().then(function(){return e.c&&"local"!=e.c.C?e.b.get(n,e.a):null}).then(function(t){if(t)return hh(e,"local").then(function(){e.c=n})})})};var lh={name:"persistence",C:"session"};function fh(t){return{name:"authUser",C:t}}function ph(t,e){return yh(t,function(){return t.b.set(t.c,e.A(),t.a)})}function dh(t){return yh(t,function(){return Nu(t.b,t.c,t.a)})}function mh(t,e){return yh(t,function(){return t.b.get(t.c,t.a).then(function(t){return t&&e&&(t.authDomain=e),oh(t||{})})})}function yh(t,e){return t.f=t.f.then(e,e),t.f}function gh(t){if(this.l=!1,Lr(this,"settings",new bc),Lr(this,"app",t),!Ih(this).options||!Ih(this).options.apiKey)throw new Yr("invalid-api-key");t=fl.SDK_VERSION?dr(fl.SDK_VERSION):null,this.b=new Da(Ih(this).options&&Ih(this).options.apiKey,Ni(Ii),t),this.O=[],this.m=[],this.J=[],this.Ub=fl.INTERNAL.createSubscribe(_(this.oc,this)),this.W=void 0,this.Vb=fl.INTERNAL.createSubscribe(_(this.pc,this)),Eh(this,null),this.h=new ch(Ih(this).options.apiKey+":"+Ih(this).name),this.w=new ah(Ih(this).options.apiKey+":"+Ih(this).name),this.Y=kh(this,function(n){var t=Ih(n).options.authDomain,e=function(e){var t=function(t,e){return t.b.get(sh,t.a).then(function(t){return t&&e&&(t.authDomain=e),oh(t||{})})}(e.w,Ih(e).options.authDomain).then(function(t){return(e.B=t)&&(t.da=e.w),uh(e.w)});return kh(e,t)}(n).then(function(){return mh(n.h,t)}).then(function(e){return e?(e.da=n.w,n.B&&(n.B.ca||null)==(e.ca||null)?e:e.reload().then(function(){return ph(n.h,e).then(function(){return e})}).s(function(t){return"auth/network-request-failed"==t.code?e:dh(n.h)})):null}).then(function(t){Eh(n,t||null)});return kh(n,e)}(this)),this.i=kh(this,function(e){return e.Y.then(function(){return _h(e)}).s(function(){}).then(function(){if(!e.l)return e.ma()}).s(function(){}).then(function(){if(!e.l){e.ga=!0;var t=e.h;t.b.addListener(fh("local"),t.a,e.ma)}})}(this)),this.ga=!1,this.ma=_(this.Nc,this),this.ub=_(this.aa,this),this.wa=_(this.bc,this),this.xa=_(this.mc,this),this.Ja=_(this.nc,this),this.a=null,function(e){var n=Ih(e).options.authDomain,r=Ih(e).options.apiKey;n&&vr()&&(e.Tb=e.Y.then(function(){if(!e.l){if(e.a=fc(n,r,Ih(e).name),rc(e.a,e),Ch(e)&&Bc(Ch(e)),e.B){Bc(e.B);var t=e.B;t.ua(e.ha()),Pc(t,e),Mc(t=e.B,e.I),xc(t,e),e.B=null}return e.a}}))}(this),this.INTERNAL={},this.INTERNAL.delete=_(this.delete,this),this.INTERNAL.logFramework=_(this.vc,this),this.o=0,nn.call(this),function(t){Object.defineProperty(t,"lc",{get:function(){return this.ha()},set:function(t){this.ua(t)},enumerable:!1}),t.Z=null,Object.defineProperty(t,"ti",{get:function(){return this.R()},set:function(t){this.nb(t)},enumerable:!1}),t.P=null}(this),this.I=[]}function vh(t){Oe.call(this,"languageCodeChanged"),this.g=t}function bh(t){Oe.call(this,"frameworkChanged"),this.c=t}function wh(t){return t.Tb||Xt(new Yr("auth-domain-config-required"))}function _h(t){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));var e=wh(t).then(function(){return t.a.oa()}).then(function(t){return t?Ur(t):null});return kh(t,e)}function Th(e,t){var n={};return n.apiKey=Ih(e).options.apiKey,n.authDomain=Ih(e).options.authDomain,n.appName=Ih(e).name,e.Y.then(function(){return function(t,e,n,r){var i=new Oc(t,e);return n&&(i.da=n),r&&Mc(i,r),i.reload().then(function(){return i})}(n,t,e.w,e.Ca())}).then(function(t){return Ch(e)&&t.uid==Ch(e).uid?Yc(Ch(e),t):(Eh(e,t),Bc(t)),e.aa(t)}).then(function(){Ah(e)})}function Eh(t,e){Ch(t)&&(function(t,e){B(t.O,function(t){return t==e})}(Ch(t),t.ub),Ge(Ch(t),"tokenChanged",t.wa),Ge(Ch(t),"userDeleted",t.xa),Ge(Ch(t),"userInvalidated",t.Ja),Uc(Ch(t))),e&&(e.O.push(t.ub),Ke(e,"tokenChanged",t.wa),Ke(e,"userDeleted",t.xa),Ke(e,"userInvalidated",t.Ja),0<t.o&&Fc(e)),Lr(t,"currentUser",e),e&&(e.ua(t.ha()),Pc(e,t),Mc(e,t.I),xc(e,t))}function Sh(e,t){var n=null,r=null;return kh(e,t.then(function(t){return n=vo(t),r=Oi(t),Th(e,t)}).then(function(){return Ur({user:Ch(e),credential:n,additionalUserInfo:r,operationType:"signIn"})}))}function Ih(t){return t.app}function Ch(t){return t.currentUser}function Nh(t){return Ch(t)&&Ch(t)._lat||null}function Ah(t){if(t.ga){for(var e=0;e<t.m.length;e++)t.m[e]&&t.m[e](Nh(t));if(t.W!==t.getUid()&&t.J.length)for(t.W=t.getUid(),e=0;e<t.J.length;e++)t.J[e]&&t.J[e](Nh(t))}}function kh(t,e){return t.O.push(e),e.ka(function(){q(t.O,e)}),e}function Dh(){}function Rh(){this.a={},this.b=1e12}ch.prototype.mb=function(e){var n=null,r=this;return function(t){var e=new Yr("invalid-persistence-type"),n=new Yr("unsupported-persistence-type");t:{for(r in Tu)if(Tu[r]==t){var r=!0;break t}r=!1}if(!r||"string"!=typeof t)throw e;switch(ur()){case"ReactNative":if("session"===t)throw n;break;case"Node":if("none"!==t)throw n;break;default:if(!gr()&&"none"!==t)throw n}}(e),yh(this,function(){return e!=r.c.C?r.b.get(r.c,r.a).then(function(t){return n=t,hh(r,e)}).then(function(){if(r.c=fh(e),n)return r.b.set(r.c,n,r.a)}):Yt()})},S(gh,nn),S(vh,Oe),S(bh,Oe),(t=gh.prototype).mb=function(t){return t=this.h.mb(t),kh(this,t)},t.ua=function(t){this.Z===t||this.l||(this.Z=t,Fa(this.b,this.Z),this.dispatchEvent(new vh(this.ha())))},t.ha=function(){return this.Z},t.Tc=function(){var t=l.navigator;this.ua(t&&(t.languages&&t.languages[0]||t.language||t.userLanguage)||null)},t.vc=function(t){this.I.push(t),Ua(this.b,fl.SDK_VERSION?dr(fl.SDK_VERSION,this.I):null),this.dispatchEvent(new bh(this.I))},t.Ca=function(){return W(this.I)},t.nb=function(t){this.P===t||this.l||(this.P=t,this.b.b=this.P)},t.R=function(){return this.P},t.toJSON=function(){return{apiKey:Ih(this).options.apiKey,authDomain:Ih(this).options.authDomain,appName:Ih(this).name,currentUser:Ch(this)&&Ch(this).A()}},t.xb=function(t,e){switch(t){case"unknown":case"signInViaRedirect":return!0;case"signInViaPopup":return this.g==e&&!!this.f;default:return!1}},t.ja=function(t,e,n,r){"signInViaPopup"==t&&this.g==r&&(n&&this.v?this.v(n):e&&!n&&this.f&&this.f(e),this.c&&(this.c.cancel(),this.c=null),delete this.f,delete this.v)},t.Ba=function(t,e){return"signInViaRedirect"==t||"signInViaPopup"==t&&this.g==e&&this.f?_(this.ac,this):null},t.ac=function(t,e,n,r){var i=this;t={requestUri:t,postBody:r,sessionId:e,tenantId:n},this.c&&(this.c.cancel(),this.c=null);var o=null,a=null,s=Xa(i.b,t).then(function(t){return o=vo(t),a=Oi(t),t});return kh(this,t=i.Y.then(function(){return s}).then(function(t){return Th(i,t)}).then(function(){return Ur({user:Ch(i),credential:o,additionalUserInfo:a,operationType:"signIn"})}))},t.Lc=function(e){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));var n=this,t=Ri(e.providerId),r=Ir(),i=null;(!_r()||ar())&&Ih(this).options.authDomain&&e.isOAuthProvider&&(i=js(Ih(this).options.authDomain,Ih(this).options.apiKey,Ih(this).name,"signInViaPopup",e,null,r,fl.SDK_VERSION||null,null,null,this.R()));var o=er(i,t&&t.sa,t&&t.ra);return kh(this,t=wh(this).then(function(t){return sc(t,o,"signInViaPopup",e,r,!!i,n.R())}).then(function(){return new jt(function(t,e){n.ja("signInViaPopup",null,new Yr("cancelled-popup-request"),n.g),n.f=t,n.v=e,n.g=r,n.c=hc(n.a,n,"signInViaPopup",o,r)})}).then(function(t){return o&&tr(o),t?Ur(t):null}).s(function(t){throw o&&tr(o),t}))},t.Mc=function(t){if(!vr())return Xt(new Yr("operation-not-supported-in-this-environment"));var e=this;return kh(this,wh(this).then(function(){return function(t){return yh(t,function(){return t.b.set(lh,t.c.C,t.a)})}(e.h)}).then(function(){return cc(e.a,"signInViaRedirect",t,void 0,e.R())}))},t.oa=function(){var e=this;return _h(this).then(function(t){return e.a&&mc(e.a.b),t}).s(function(t){throw e.a&&mc(e.a.b),t})},t.Rc=function(t){if(!t)return Xt(new Yr("null-user"));if(this.P!=t.tenantId)return Xt(new Yr("tenant-id-mismatch"));var e=this,n={};n.apiKey=Ih(this).options.apiKey,n.authDomain=Ih(this).options.authDomain,n.appName=Ih(this).name;var r=function(t,e,n,r){e=e||{apiKey:t.l,authDomain:t.o,appName:t.m};var i=t.b,o={};return o[Oa]=i.b,o.refreshToken=i.a,o.expiresIn=(i.c-E())/1e3,e=new Oc(e,o),n&&(e.da=n),r&&Mc(e,r),Yc(e,t),e}(t,n,e.w,e.Ca());return kh(this,this.i.then(function(){if(Ih(e).options.apiKey!=t.l)return r.reload()}).then(function(){return Ch(e)&&t.uid==Ch(e).uid?(Yc(Ch(e),t),e.aa(t)):(Eh(e,r),Bc(r),e.aa(r))}).then(function(){Ah(e)}))},t.pb=function(){var t=this,e=this.i.then(function(){return t.a&&mc(t.a.b),Ch(t)?(Eh(t,null),dh(t.h).then(function(){Ah(t)})):Yt()});return kh(this,e)},t.Nc=function(){var r=this;return mh(this.h,Ih(this).options.authDomain).then(function(t){if(!r.l){var e;if(e=Ch(r)&&t){e=Ch(r).uid;var n=t.uid;e=null!=e&&""!==e&&null!=n&&""!==n&&e==n}if(e)return Yc(Ch(r),t),Ch(r).G();(Ch(r)||t)&&(Eh(r,t),t&&(Bc(t),t.da=r.w),r.a&&rc(r.a,r),Ah(r))}})},t.aa=function(t){return ph(this.h,t)},t.bc=function(){Ah(this),this.aa(Ch(this))},t.mc=function(){this.pb()},t.nc=function(){this.pb()},t.oc=function(t){var e=this;this.addAuthTokenListener(function(){t.next(Ch(e))})},t.pc=function(t){var e=this;!function(t,e){t.J.push(e),kh(t,t.i.then(function(){!t.l&&V(t.J,e)&&t.W!==t.getUid()&&(t.W=t.getUid(),e(Nh(t)))}))}(this,function(){t.next(Ch(e))})},t.xc=function(t,e,n){var r=this;return this.ga&&Promise.resolve().then(function(){y(t)?t(Ch(r)):y(t.next)&&t.next(Ch(r))}),this.Ub(t,e,n)},t.wc=function(t,e,n){var r=this;return this.ga&&Promise.resolve().then(function(){r.W=r.getUid(),y(t)?t(Ch(r)):y(t.next)&&t.next(Ch(r))}),this.Vb(t,e,n)},t.cc=function(t){var e=this,n=this.i.then(function(){return Ch(e)?Ch(e).G(t).then(function(t){return{accessToken:t}}):null});return kh(this,n)},t.Hc=function(t){var n=this;return this.i.then(function(){return Sh(n,Ns(n.b,Ts,{token:t}))}).then(function(t){var e=t.user;return zc(e,"isAnonymous",!1),n.aa(e),t})},t.Ic=function(t,e){var n=this;return this.i.then(function(){return Sh(n,Ns(n.b,Es,{email:t,password:e}))})},t.Xb=function(t,e){var n=this;return this.i.then(function(){return Sh(n,Ns(n.b,ns,{email:t,password:e}))})},t.Sa=function(t){var e=this;return this.i.then(function(){return Sh(e,t.na(e.b))})},t.Gc=function(t){return Mr("firebase.auth.Auth.prototype.signInAndRetrieveDataWithCredential is deprecated. Please use firebase.auth.Auth.prototype.signInWithCredential instead."),this.Sa(t)},t.ob=function(){var n=this;return this.i.then(function(){var t=Ch(n);return t&&t.isAnonymous?Ur({user:t,credential:null,additionalUserInfo:Ur({providerId:null,isNewUser:!1}),operationType:"signIn"}):Sh(n,n.b.ob()).then(function(t){var e=t.user;return zc(e,"isAnonymous",!0),n.aa(e),t})})},t.getUid=function(){return Ch(this)&&Ch(this).uid||null},t.Wb=function(t){this.addAuthTokenListener(t),this.o++,0<this.o&&Ch(this)&&Fc(Ch(this))},t.Ec=function(e){var n=this;L(this.m,function(t){t==e&&n.o--}),this.o<0&&(this.o=0),0==this.o&&Ch(this)&&Uc(Ch(this)),this.removeAuthTokenListener(e)},t.addAuthTokenListener=function(t){var e=this;this.m.push(t),kh(this,this.i.then(function(){e.l||V(e.m,t)&&t(Nh(e))}))},t.removeAuthTokenListener=function(e){B(this.m,function(t){return t==e})},t.delete=function(){this.l=!0;for(var t=0;t<this.O.length;t++)this.O[t].cancel("app-deleted");return this.O=[],this.h&&(t=this.h).b.removeListener(fh("local"),t.a,this.ma),this.a&&(ic(this.a,this),mc(this.a.b)),Promise.resolve()},t.$b=function(t){return kh(this,function(t,e){return Ns(t,rs,{identifier:e,continueUri:br()?Jn():"http://localhost"}).then(function(t){return t.signinMethods||[]})}(this.b,t))},t.qc=function(t){return!!lo(t)},t.lb=function(e,n){var r=this;return kh(this,Yt().then(function(){var t=new ui(n);if(!t.c)throw new Yr("argument-error",li+" must be true when sending sign in link to email");return vi(t)}).then(function(t){return r.b.lb(e,t)}).then(function(){}))},t.Uc=function(t){return this.Ma(t).then(function(t){return t.data.email})},t.ab=function(t,e){return kh(this,this.b.ab(t,e).then(function(){}))},t.Ma=function(t){return kh(this,this.b.Ma(t).then(function(t){return new qr(t)}))},t.Ya=function(t){return kh(this,this.b.Ya(t).then(function(){}))},t.kb=function(e,t){var n=this;return kh(this,Yt().then(function(){return void 0===t||Q(t)?{}:vi(new ui(t))}).then(function(t){return n.b.kb(e,t)}).then(function(){}))},t.Kc=function(t,e){return kh(this,_c(this,t,e,_(this.Sa,this)))},t.Jc=function(n,r){var i=this;return kh(this,Yt().then(function(){var t=r||Jn(),e=ho(n,t);if(!(t=lo(t)))throw new Yr("argument-error","Invalid email link!");if(t.tenantId!==i.R())throw new Yr("tenant-id-mismatch");return i.Sa(e)}))},Dh.prototype.render=function(){},Dh.prototype.reset=function(){},Dh.prototype.getResponse=function(){},Dh.prototype.execute=function(){};var Oh=null;function Ph(t,e){return(e=Mh(e))&&t.a[e]||null}function Mh(t){return(t=void 0===t?1e12:t)?t.toString():null}function xh(t,e){this.g=!1,this.c=e,this.a=this.b=null,this.h="invisible"!==this.c.size,this.f=qn(t);var n=this;this.i=function(){n.execute()},this.h?this.execute():Ke(this.f,"click",this.i)}function Lh(t){if(t.g)throw Error("reCAPTCHA mock was already deleted!")}function Fh(){}Rh.prototype.render=function(t,e){return this.a[this.b.toString()]=new xh(t,e),this.b++},Rh.prototype.reset=function(t){var e=Ph(this,t);t=Mh(t),e&&t&&(e.delete(),delete this.a[t])},Rh.prototype.getResponse=function(t){return(t=Ph(this,t))?t.getResponse():null},Rh.prototype.execute=function(t){(t=Ph(this,t))&&t.execute()},xh.prototype.getResponse=function(){return Lh(this),this.b},xh.prototype.execute=function(){Lh(this);var n=this;this.a||(this.a=setTimeout(function(){n.b=function(){for(var t=50,e=[];0<t;)e.push("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(Math.floor(62*Math.random()))),t--;return e.join("")}();var t=n.c.callback,e=n.c["expired-callback"];if(t)try{t(n.b)}catch(t){}n.a=setTimeout(function(){if(n.a=null,n.b=null,e)try{e()}catch(t){}n.h&&n.execute()},6e4)},500))},xh.prototype.delete=function(){Lh(this),this.g=!0,clearTimeout(this.a),this.a=null,Ge(this.f,"click",this.i)},Fh.prototype.g=function(){return Yt(Oh=Oh||new Rh)},Fh.prototype.c=function(){};var Uh=null;function Vh(){this.b=l.grecaptcha?1/0:0,this.f=null,this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}var qh=new Y($,"https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}"),Bh=new Ar(3e4,6e4);Vh.prototype.g=function(i){var o=this;return new jt(function(t,e){var r=setTimeout(function(){e(new Yr("network-request-failed"))},Bh.get());!l.grecaptcha||i!==o.f&&!o.b?(l[o.a]=function(){if(l.grecaptcha){o.f=i;var n=l.grecaptcha.render;l.grecaptcha.render=function(t,e){return t=n(t,e),o.b++,t},clearTimeout(r),t(l.grecaptcha)}else clearTimeout(r),e(new Yr("internal-error"));delete l[o.a]},Yt(Ea(nt(qh,{onload:o.a,hl:i||""}))).s(function(){clearTimeout(r),e(new Yr("internal-error","Unable to load external reCAPTCHA dependencies!"))})):(clearTimeout(r),t(l.grecaptcha))})},Vh.prototype.c=function(){this.b--};var jh=null;function Wh(t,e,n,r,i,o,a){if(Lr(this,"type","recaptcha"),this.c=this.f=null,this.B=!1,this.u=e,this.g=null,a=a?Uh=Uh||new Fh:jh=jh||new Vh,this.m=a,this.a=n||{theme:"light",type:"image"},this.h=[],this.a[Hh])throw new Yr("argument-error","sitekey should not be provided for reCAPTCHA as one is automatically provisioned for the current project.");if(this.i="invisible"===this.a[Gh],!l.document)throw new Yr("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.");if(!qn(e)||!this.i&&qn(e).hasChildNodes())throw new Yr("argument-error","reCAPTCHA container is either not found or already contains inner elements!");this.o=new Da(t,o||null,i||null),this.v=r||function(){return null};var s=this;this.l=[];var u=this.a[Kh];this.a[Kh]=function(t){if(zh(s,t),"function"==typeof u)u(t);else if("string"==typeof u){var e=yr(u,l);"function"==typeof e&&e(t)}};var c=this.a[Qh];this.a[Qh]=function(){if(zh(s,null),"function"==typeof c)c();else if("string"==typeof c){var t=yr(c,l);"function"==typeof t&&t()}}}var Kh="callback",Qh="expired-callback",Hh="sitekey",Gh="size";function zh(t,e){for(var n=0;n<t.l.length;n++)try{t.l[n](e)}catch(t){}}function Yh(t,e){return t.h.push(e),e.ka(function(){q(t.h,e)}),e}function Xh(t){if(t.B)throw new Yr("internal-error","RecaptchaVerifier instance has been destroyed.")}function Jh(t,e,n){var r=!1;try{this.b=n||fl.app()}catch(t){throw new Yr("argument-error","No firebase.app.App instance is currently initialized.")}if(!this.b.options||!this.b.options.apiKey)throw new Yr("invalid-api-key");n=this.b.options.apiKey;var i=this,o=null;try{o=this.b.auth().Ca()}catch(t){}try{r=this.b.auth().settings.appVerificationDisabledForTesting}catch(t){}o=fl.SDK_VERSION?dr(fl.SDK_VERSION,o):null,Wh.call(this,n,t,e,function(){try{var e=i.b.auth().ha()}catch(t){e=null}return e},o,Ni(Ii),r)}function $h(t,e,n,r){t:{n=Array.prototype.slice.call(n);for(var i=0,o=!1,a=0;a<e.length;a++)if(e[a].optional)o=!0;else{if(o)throw new Yr("internal-error","Argument validator encountered a required argument after an optional argument.");i++}if(o=e.length,n.length<i||o<n.length)r="Expected "+(i==o?1==i?"1 argument":i+" arguments":i+"-"+o+" arguments")+" but got "+n.length+".";else{for(i=0;i<n.length;i++)if(o=e[i].optional&&void 0===n[i],!e[i].N(n[i])&&!o){if(e=e[i],i<0||i>=Zh.length)throw new Yr("internal-error","Argument validator received an unsupported number of arguments.");n=Zh[i],r=(r?"":n+" argument ")+(e.name?'"'+e.name+'" ':"")+"must be "+e.M+".";break t}r=null}}if(r)throw new Yr("argument-error",t+" failed: "+r)}(t=Wh.prototype).Da=function(){var e=this;return this.f?this.f:this.f=Yh(this,Yt().then(function(){if(br()&&!sr())return ir();throw new Yr("operation-not-supported-in-this-environment","RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment.")}).then(function(){return e.m.g(e.v())}).then(function(t){return e.g=t,Ns(e.o,ps,{})}).then(function(t){e.a[Hh]=t.recaptchaSiteKey}).s(function(t){throw e.f=null,t}))},t.render=function(){Xh(this);var n=this;return Yh(this,this.Da().then(function(){if(null===n.c){var t=n.u;if(!n.i){var e=qn(t);t=Wn("DIV"),e.appendChild(t)}n.c=n.g.render(t,n.a)}return n.c}))},t.verify=function(){Xh(this);var i=this;return Yh(this,this.render().then(function(r){return new jt(function(e){var t=i.g.getResponse(r);if(t)e(t);else{var n=function(t){t&&(function(t,e){B(t.l,function(t){return t==e})}(i,n),e(t))};i.l.push(n),i.i&&i.g.execute(i.c)}})}))},t.reset=function(){Xh(this),null!==this.c&&this.g.reset(this.c)},t.clear=function(){Xh(this),this.B=!0,this.m.c();for(var t=0;t<this.h.length;t++)this.h[t].cancel("RecaptchaVerifier instance has been destroyed.");if(!this.i){t=qn(this.u);for(var e;e=t.firstChild;)t.removeChild(e)}},S(Jh,Wh);var Zh="First Second Third Fourth Fifth Sixth Seventh Eighth Ninth".split(" ");function tl(t,e){return{name:t||"",M:"a valid string",optional:!!e,N:h}}function el(t,e){return{name:t||"",M:"a boolean",optional:!!e,N:n}}function nl(t,e){return{name:t||"",M:"a valid object",optional:!!e,N:g}}function rl(t,e){return{name:t||"",M:"a function",optional:!!e,N:y}}function il(t,e){return{name:t||"",M:"null",optional:!!e,N:i}}function ol(n){return{name:n?n+"Credential":"credential",M:n?"a valid "+n+" credential":"a valid credential",optional:!1,N:function(t){if(!t)return!1;var e=!n||t.providerId===n;return!(!t.na||!e)}}}function al(){return{name:"applicationVerifier",M:"an implementation of firebase.auth.ApplicationVerifier",optional:!1,N:function(t){return!!(t&&h(t.type)&&y(t.verify))}}}function sl(e,n,t,r){return{name:t||"",M:e.M+" or "+n.M,optional:!!r,N:function(t){return e.N(t)||n.N(t)}}}function ul(t,e){for(var n in e){var r=e[n].name;t[r]=ll(r,t[n],e[n].j)}}function cl(t,e){for(var n in e){var r=e[n].name;r!==n&&Object.defineProperty(t,r,{get:T(function(t){return this[t]},n),set:T(function(t,e,n,r){$h(t,[n],[r],!0),this[e]=r},r,n,e[n].Za),enumerable:!0})}}function hl(t,e,n,r){t[e]=ll(e,n,r)}function ll(t,e,n){function r(){var t=Array.prototype.slice.call(arguments);return $h(o,n,t),e.apply(this,t)}if(!n)return e;var i,o=function(t){return(t=t.split("."))[t.length-1]}(t);for(i in e)r[i]=e[i];for(i in e.prototype)r.prototype[i]=e.prototype[i];return r}ul(gh.prototype,{Ya:{name:"applyActionCode",j:[tl("code")]},Ma:{name:"checkActionCode",j:[tl("code")]},ab:{name:"confirmPasswordReset",j:[tl("code"),tl("newPassword")]},Xb:{name:"createUserWithEmailAndPassword",j:[tl("email"),tl("password")]},$b:{name:"fetchSignInMethodsForEmail",j:[tl("email")]},oa:{name:"getRedirectResult",j:[]},qc:{name:"isSignInWithEmailLink",j:[tl("emailLink")]},wc:{name:"onAuthStateChanged",j:[sl(nl(),rl(),"nextOrObserver"),rl("opt_error",!0),rl("opt_completed",!0)]},xc:{name:"onIdTokenChanged",j:[sl(nl(),rl(),"nextOrObserver"),rl("opt_error",!0),rl("opt_completed",!0)]},kb:{name:"sendPasswordResetEmail",j:[tl("email"),sl(nl("opt_actionCodeSettings",!0),il(null,!0),"opt_actionCodeSettings",!0)]},lb:{name:"sendSignInLinkToEmail",j:[tl("email"),nl("actionCodeSettings")]},mb:{name:"setPersistence",j:[tl("persistence")]},Gc:{name:"signInAndRetrieveDataWithCredential",j:[ol()]},ob:{name:"signInAnonymously",j:[]},Sa:{name:"signInWithCredential",j:[ol()]},Hc:{name:"signInWithCustomToken",j:[tl("token")]},Ic:{name:"signInWithEmailAndPassword",j:[tl("email"),tl("password")]},Jc:{name:"signInWithEmailLink",j:[tl("email"),tl("emailLink",!0)]},Kc:{name:"signInWithPhoneNumber",j:[tl("phoneNumber"),al()]},Lc:{name:"signInWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Mc:{name:"signInWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Rc:{name:"updateCurrentUser",j:[sl({name:"user",M:"an instance of Firebase User",optional:!1,N:function(t){return!!(t&&t instanceof Oc)}},il(),"user")]},pb:{name:"signOut",j:[]},toJSON:{name:"toJSON",j:[tl(null,!0)]},Tc:{name:"useDeviceLanguage",j:[]},Uc:{name:"verifyPasswordResetCode",j:[tl("code")]}}),cl(gh.prototype,{lc:{name:"languageCode",Za:sl(tl(),il(),"languageCode")},ti:{name:"tenantId",Za:sl(tl(),il(),"tenantId")}}),(gh.Persistence=Tu).LOCAL="local",gh.Persistence.SESSION="session",gh.Persistence.NONE="none",ul(Oc.prototype,{delete:{name:"delete",j:[]},dc:{name:"getIdTokenResult",j:[el("opt_forceRefresh",!0)]},G:{name:"getIdToken",j:[el("opt_forceRefresh",!0)]},rc:{name:"linkAndRetrieveDataWithCredential",j:[ol()]},fb:{name:"linkWithCredential",j:[ol()]},sc:{name:"linkWithPhoneNumber",j:[tl("phoneNumber"),al()]},tc:{name:"linkWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},uc:{name:"linkWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Ac:{name:"reauthenticateAndRetrieveDataWithCredential",j:[ol()]},hb:{name:"reauthenticateWithCredential",j:[ol()]},Bc:{name:"reauthenticateWithPhoneNumber",j:[tl("phoneNumber"),al()]},Cc:{name:"reauthenticateWithPopup",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},Dc:{name:"reauthenticateWithRedirect",j:[{name:"authProvider",M:"a valid Auth provider",optional:!1,N:function(t){return!!(t&&t.providerId&&t.hasOwnProperty&&t.hasOwnProperty("isOAuthProvider"))}}]},reload:{name:"reload",j:[]},jb:{name:"sendEmailVerification",j:[sl(nl("opt_actionCodeSettings",!0),il(null,!0),"opt_actionCodeSettings",!0)]},toJSON:{name:"toJSON",j:[tl(null,!0)]},Qc:{name:"unlink",j:[tl("provider")]},rb:{name:"updateEmail",j:[tl("email")]},sb:{name:"updatePassword",j:[tl("password")]},Sc:{name:"updatePhoneNumber",j:[ol("phone")]},tb:{name:"updateProfile",j:[nl("profile")]}}),ul(Rh.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),ul(Dh.prototype,{execute:{name:"execute"},render:{name:"render"},reset:{name:"reset"},getResponse:{name:"getResponse"}}),ul(jt.prototype,{ka:{name:"finally"},s:{name:"catch"},then:{name:"then"}}),cl(bc.prototype,{appVerificationDisabled:{name:"appVerificationDisabledForTesting",Za:el("appVerificationDisabledForTesting")}}),ul(wc.prototype,{confirm:{name:"confirm",j:[tl("verificationCode")]}}),hl(ji,"fromJSON",function(t){t=h(t)?JSON.parse(t):t;for(var e,n=[Yi,uo,po,Hi],r=0;r<n.length;r++)if(e=n[r](t))return e;return null},[sl(tl(),nl(),"json")]),hl(co,"credential",function(t,e){return new so(t,e)},[tl("email"),tl("password")]),ul(so.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),ul(Zi.prototype,{ya:{name:"addScope",j:[tl("scope")]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(Zi,"credential",to,[sl(tl(),nl(),"token")]),hl(co,"credentialWithLink",ho,[tl("email"),tl("emailLink")]),ul(eo.prototype,{ya:{name:"addScope",j:[tl("scope")]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(eo,"credential",no,[sl(tl(),nl(),"token")]),ul(ro.prototype,{ya:{name:"addScope",j:[tl("scope")]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(ro,"credential",io,[sl(tl(),sl(nl(),il()),"idToken"),sl(tl(),il(),"accessToken",!0)]),ul(oo.prototype,{Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(oo,"credential",ao,[sl(tl(),nl(),"token"),tl("secret",!0)]),ul($i.prototype,{ya:{name:"addScope",j:[tl("scope")]},credential:{name:"credential",j:[sl(tl(),sl(nl(),il()),"optionsOrIdToken"),sl(tl(),il(),"accessToken",!0)]},Ga:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),ul(Gi.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),ul(Ki.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),hl(yo,"credential",go,[tl("verificationId"),tl("verificationCode")]),ul(yo.prototype,{Wa:{name:"verifyPhoneNumber",j:[tl("phoneNumber"),al()]}}),ul(fo.prototype,{A:{name:"toJSON",j:[tl(null,!0)]}}),ul(Yr.prototype,{toJSON:{name:"toJSON",j:[tl(null,!0)]}}),ul(Co.prototype,{toJSON:{name:"toJSON",j:[tl(null,!0)]}}),ul(Io.prototype,{toJSON:{name:"toJSON",j:[tl(null,!0)]}}),ul(Jh.prototype,{clear:{name:"clear",j:[]},render:{name:"render",j:[]},verify:{name:"verify",j:[]}}),hl(Zr,"parseLink",si,[tl("link")]),function(){if(void 0===fl||!fl.INTERNAL||!fl.INTERNAL.registerComponent)throw Error("Cannot find the firebase namespace; be sure to include firebase-app.js before this library.");var t={ActionCodeInfo:{Operation:{EMAIL_SIGNIN:Br,PASSWORD_RESET:"PASSWORD_RESET",RECOVER_EMAIL:"RECOVER_EMAIL",VERIFY_EMAIL:"VERIFY_EMAIL"}},Auth:gh,AuthCredential:ji,Error:Yr};hl(t,"EmailAuthProvider",co,[]),hl(t,"FacebookAuthProvider",Zi,[]),hl(t,"GithubAuthProvider",eo,[]),hl(t,"GoogleAuthProvider",ro,[]),hl(t,"TwitterAuthProvider",oo,[]),hl(t,"OAuthProvider",$i,[tl("providerId")]),hl(t,"SAMLAuthProvider",Ji,[tl("providerId")]),hl(t,"PhoneAuthProvider",yo,[{name:"auth",M:"an instance of Firebase Auth",optional:!0,N:function(t){return!!(t&&t instanceof gh)}}]),hl(t,"RecaptchaVerifier",Jh,[sl(tl(),{name:"",M:"an HTML element",optional:!1,N:function(t){return!!(t&&t instanceof Element)}},"recaptchaContainer"),nl("recaptchaParameters",!0),{name:"app",M:"an instance of Firebase App",optional:!0,N:function(t){return!!(t&&t instanceof fl.app.App)}}]),hl(t,"ActionCodeURL",Zr,[]),fl.INTERNAL.registerComponent({name:"auth",instanceFactory:function(t){return new gh(t=t.getProvider("app").getImmediate())},multipleInstances:!1,serviceProps:t,instantiationMode:"LAZY",type:"PUBLIC"}),fl.INTERNAL.registerComponent({name:"auth-internal",instanceFactory:function(t){return{getUid:_((t=t.getProvider("auth").getImmediate()).getUid,t),getToken:_(t.cc,t),addAuthTokenListener:_(t.Wb,t),removeAuthTokenListener:_(t.Ec,t)}},multipleInstances:!1,instantiationMode:"LAZY",type:"PRIVATE"}),fl.registerVersion("@firebase/auth","0.13.3"),fl.INTERNAL.extendNamespace({User:Oc})}()}).apply("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Vs=(qs.prototype.set=function(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),Wa(e))},qs.prototype.get=function(t){var e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:ja(e)},qs.prototype.remove=function(t){this.domStorage_.removeItem(this.prefixedName_(t))},qs.prototype.prefixedName_=function(t){return this.prefix_+t},qs.prototype.toString=function(){return this.domStorage_.toString()},qs);function qs(t){this.domStorage_=t,this.prefix_="firebase:"}var Bs=(js.prototype.set=function(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e},js.prototype.get=function(t){return Qa(this.cache_,t)?this.cache_[t]:null},js.prototype.remove=function(t){delete this.cache_[t]},js);function js(){this.cache_={},this.isInMemoryStorage=!0}function Ws(t){try{if("undefined"!=typeof window&&void 0!==window[t]){var e=window[t];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new Vs(e)}}catch(t){}return new Bs}function Ks(t){var e=function(t){for(var e=[],n=0,r=0;r<t.length;r++){var i=t.charCodeAt(r);if(55296<=i&&i<=56319){var o=i-55296;Ia(++r<t.length,"Surrogate pair missing trail surrogate."),i=65536+(o<<10)+(t.charCodeAt(r)-56320)}i<128?e[n++]=i:(i<2048?e[n++]=i>>6|192:(i<65536?e[n++]=i>>12|224:(e[n++]=i>>18|240,e[n++]=i>>12&63|128),e[n++]=i>>6&63|128),e[n++]=63&i|128)}return e}(t),n=new Ya;n.update(e);var r=n.digest();return Na.encodeByteArray(r)}function Qs(t,e){Ia(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(iu.logLevel=ls.VERBOSE,su=iu.log.bind(iu),e&&ru.set("logging_enabled",!0)):"function"==typeof t?su=t:(su=null,ru.remove("logging_enabled"))}function Hs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!0===uu&&(uu=!1,null===su&&!0===ru.get("logging_enabled")&&Qs(!0)),su){var n=au.apply(null,t);su(n)}}function Gs(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Hs.apply(void 0,wa([n],t))}}function zs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE INTERNAL ERROR: "+au.apply(void 0,wa(t));iu.error(n)}function Ys(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE FATAL ERROR: "+au.apply(void 0,wa(t));throw iu.error(n),new Error(n)}function Xs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE WARNING: "+au.apply(void 0,wa(t));iu.warn(n)}function Js(t){return"number"==typeof t&&(t!=t||t==Number.POSITIVE_INFINITY||t==Number.NEGATIVE_INFINITY)}function $s(t,e){return t===e?0:t<e?-1:1}function Zs(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+Wa(e))}function tu(t,e){var n=t.length;if(n<=e)return[t];for(var r=[],i=0;i<n;i+=e)n<i+e?r.push(t.substring(i,n)):r.push(t.substring(i,i+e));return r}var eu,nu=Ws("localStorage"),ru=Ws("sessionStorage"),iu=new bs("@firebase/database"),ou=(eu=1,function(){return eu++}),au=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n="",r=0;r<t.length;r++)Array.isArray(t[r])||t[r]&&"object"==typeof t[r]&&"number"==typeof t[r].length?n+=au.apply(null,t[r]):"object"==typeof t[r]?n+=Wa(t[r]):n+=t[r],n+=" ";return n},su=null,uu=!0,cu="[MIN_NAME]",hu="[MAX_NAME]",lu=function(t,e){if(t===e)return 0;if(t===cu||e===hu)return-1;if(e===cu||t===hu)return 1;var n=vu(t),r=vu(e);return null!==n?null!==r?n-r==0?t.length-e.length:n-r:-1:null!==r?1:t<e?-1:1},fu=function(t){if("object"!=typeof t||null===t)return Wa(t);var e=[];for(var n in t)e.push(n);e.sort();for(var r="{",i=0;i<e.length;i++)0!==i&&(r+=","),r+=Wa(e[i]),r+=":",r+=fu(t[e[i]]);return r+="}"};function pu(t,e){for(var n in t)t.hasOwnProperty(n)&&e(n,t[n])}function du(t){var e,n,r,i,o,a,s;for(Ia(!Js(t),"Invalid JSON number"),0===t?e=1/t==-1/(r=n=0)?1:0:(e=t<0,r=(t=Math.abs(t))>=Math.pow(2,-1022)?(n=(i=Math.min(Math.floor(Math.log(t)/Math.LN2),1023))+1023,Math.round(t*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,Math.round(t/Math.pow(2,-1074)))),a=[],o=52;o;o-=1)a.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)a.push(n%2?1:0),n=Math.floor(n/2);a.push(e?1:0),a.reverse(),s=a.join("");var u="";for(o=0;o<64;o+=8){var c=parseInt(s.substr(o,8),2).toString(16);1===c.length&&(c="0"+c),u+=c}return u.toLowerCase()}function mu(t){try{t()}catch(e){setTimeout(function(){var t=e.stack||"";throw Xs("Exception was thrown by user callback.",t),e},Math.floor(0))}}function yu(t,e){var n=setTimeout(t,e);return"object"==typeof n&&n.unref&&n.unref(),n}var gu=new RegExp("^-?(0*)\\d{1,10}$"),vu=function(t){if(gu.test(t)){var e=Number(t);if(-2147483648<=e&&e<=2147483647)return e}return null},bu=(Object.defineProperty(wu,"Empty",{get:function(){return new wu("")},enumerable:!0,configurable:!0}),wu.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},wu.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},wu.prototype.popFront=function(){var t=this.pieceNum_;return t<this.pieces_.length&&t++,new wu(this.pieces_,t)},wu.prototype.getBack=function(){return this.pieceNum_<this.pieces_.length?this.pieces_[this.pieces_.length-1]:null},wu.prototype.toString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+this.pieces_[e]);return t||"/"},wu.prototype.toUrlEncodedString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+encodeURIComponent(String(this.pieces_[e])));return t||"/"},wu.prototype.slice=function(t){return void 0===t&&(t=0),this.pieces_.slice(this.pieceNum_+t)},wu.prototype.parent=function(){if(this.pieceNum_>=this.pieces_.length)return null;for(var t=[],e=this.pieceNum_;e<this.pieces_.length-1;e++)t.push(this.pieces_[e]);return new wu(t,0)},wu.prototype.child=function(t){for(var e=[],n=this.pieceNum_;n<this.pieces_.length;n++)e.push(this.pieces_[n]);if(t instanceof wu)for(n=t.pieceNum_;n<t.pieces_.length;n++)e.push(t.pieces_[n]);else{var r=t.split("/");for(n=0;n<r.length;n++)0<r[n].length&&e.push(r[n])}return new wu(e,0)},wu.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},wu.relativePath=function(t,e){var n=t.getFront(),r=e.getFront();if(null===n)return e;if(n===r)return wu.relativePath(t.popFront(),e.popFront());throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")},wu.comparePaths=function(t,e){for(var n=t.slice(),r=e.slice(),i=0;i<n.length&&i<r.length;i++){var o=lu(n[i],r[i]);if(0!==o)return o}return n.length===r.length?0:n.length<r.length?-1:1},wu.prototype.equals=function(t){if(this.getLength()!==t.getLength())return!1;for(var e=this.pieceNum_,n=t.pieceNum_;e<=this.pieces_.length;e++,n++)if(this.pieces_[e]!==t.pieces_[n])return!1;return!0},wu.prototype.contains=function(t){var e=this.pieceNum_,n=t.pieceNum_;if(this.getLength()>t.getLength())return!1;for(;e<this.pieces_.length;){if(this.pieces_[e]!==t.pieces_[n])return!1;++e,++n}return!0},wu);function wu(t,e){if(void 0===e){this.pieces_=t.split("/");for(var n=0,r=0;r<this.pieces_.length;r++)0<this.pieces_[r].length&&(this.pieces_[n]=this.pieces_[r],n++);this.pieces_.length=n,this.pieceNum_=0}else this.pieces_=t,this.pieceNum_=e}var _u=(Object.defineProperty(Tu,"MAX_PATH_DEPTH",{get:function(){return 32},enumerable:!0,configurable:!0}),Object.defineProperty(Tu,"MAX_PATH_LENGTH_BYTES",{get:function(){return 768},enumerable:!0,configurable:!0}),Tu.prototype.push=function(t){0<this.parts_.length&&(this.byteLength_+=1),this.parts_.push(t),this.byteLength_+=os(t),this.checkValid_()},Tu.prototype.pop=function(){var t=this.parts_.pop();this.byteLength_-=os(t),0<this.parts_.length&&(this.byteLength_-=1)},Tu.prototype.checkValid_=function(){if(this.byteLength_>Tu.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+Tu.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>Tu.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+Tu.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},Tu.prototype.toErrorString=function(){return 0==this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},Tu);function Tu(t,e){this.errorPrefix_=e,this.parts_=t.slice(),this.byteLength_=Math.max(1,this.parts_.length);for(var n=0;n<this.parts_.length;n++)this.byteLength_+=os(this.parts_[n]);this.checkValid_()}var Eu="firebaseio.com",Su="websocket",Iu="long_polling",Cu=(Nu.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()||this.includeNamespaceInQueryParams},Nu.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},Nu.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},Nu.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},Nu.prototype.updateHost=function(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&nu.set("host:"+this.host,this.internalHost))},Nu.prototype.connectionURL=function(t,e){var n;if(Ia("string"==typeof t,"typeof type must == string"),Ia("object"==typeof e,"typeof params must == object"),t===Su)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(t!==Iu)throw new Error("Unknown connection type: "+t);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(e.ns=this.namespace);var r=[];return pu(e,function(t,e){r.push(t+"="+e)}),n+r.join("&")},Nu.prototype.toString=function(){var t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t},Nu.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},Nu);function Nu(t,e,n,r,i,o){void 0===i&&(i=""),void 0===o&&(o=!1),this.secure=e,this.namespace=n,this.webSocketOnly=r,this.persistenceKey=i,this.includeNamespaceInQueryParams=o,this.host=t.toLowerCase(),this.domain=this.host.substr(this.host.indexOf(".")+1),this.internalHost=nu.get("host:"+t)||this.host}function Au(t){var e=qu(t),n=e.namespace;"firebase"===e.domain&&Ys(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!=n||"localhost"===e.domain||Ys("Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com"),e.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Xs("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");var r="ws"===e.scheme||"wss"===e.scheme;return{repoInfo:new Cu(e.host,e.secure,n,r,"",n!=e.subdomain),path:new bu(e.pathString)}}function ku(t){return"string"==typeof t&&0!==t.length&&!Bu.test(t)}function Du(t){return"string"==typeof t&&0!==t.length&&!ju.test(t)}function Ru(t){return null===t||"string"==typeof t||"number"==typeof t&&!Js(t)||t&&"object"==typeof t&&Qa(t,".sv")}function Ou(t,e,n,r,i){i&&void 0===n||Ku(ns(t,e,i),n,r)}function Pu(t,e,n,r,i){if(!i||void 0!==n){var o=ns(t,e,i);if(!n||"object"!=typeof n||Array.isArray(n))throw new Error(o+" must be an object containing the children to replace.");var a=[];pu(n,function(t,e){var n=new bu(t);if(Ku(o,e,r.child(n)),".priority"===n.getBack()&&!Ru(e))throw new Error(o+"contains an invalid value for '"+n.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");a.push(n)}),function(t,e){var n,r;for(n=0;n<e.length;n++)for(var i=(r=e[n]).slice(),o=0;o<i.length;o++)if(".priority"===i[o]&&o===i.length-1);else if(!ku(i[o]))throw new Error(t+"contains an invalid key ("+i[o]+") in path "+r.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');e.sort(bu.comparePaths);var a=null;for(n=0;n<e.length;n++){if(r=e[n],null!==a&&a.contains(r))throw new Error(t+"contains a path "+a.toString()+" that is ancestor of another path "+r.toString());a=r}}(o,a)}}function Mu(t,e,n,r){if(!r||void 0!==n){if(Js(n))throw new Error(ns(t,e,r)+"is "+n.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!Ru(n))throw new Error(ns(t,e,r)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function xu(t,e,n,r){if(!r||void 0!==n)switch(n){case"value":case"child_added":case"child_removed":case"child_changed":case"child_moved":break;default:throw new Error(ns(t,e,r)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}function Lu(t,e,n,r){if(!(r&&void 0===n||ku(n)))throw new Error(ns(t,e,r)+'was an invalid key = "'+n+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')}function Fu(t,e,n,r){if(!(r&&void 0===n||Du(n)))throw new Error(ns(t,e,r)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')}function Uu(t,e){if(".info"===e.getFront())throw new Error(t+" failed = Can't modify data under /.info/")}function Vu(t,e,n){var r=n.path.toString();if("string"!=typeof n.repoInfo.host||0===n.repoInfo.host.length||!ku(n.repoInfo.namespace)&&"localhost"!==n.repoInfo.host.split(":")[0]||0!==r.length&&!function(t){return t=t&&t.replace(/^\/*\.info(\/|$)/,"/"),Du(t)}(r))throw new Error(ns(t,e,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')}var qu=function(t){var e="",n="",r="",i="",o="",a=!0,s="https",u=443;if("string"==typeof t){var c=t.indexOf("//");0<=c&&(s=t.substring(0,c-1),t=t.substring(c+2));var h=t.indexOf("/");-1===h&&(h=t.length);var l=t.indexOf("?");-1===l&&(l=t.length),e=t.substring(0,Math.min(h,l)),h<l&&(i=function(t){for(var e="",n=t.split("/"),r=0;r<n.length;r++)if(0<n[r].length){var i=n[r];try{i=decodeURIComponent(i.replace(/\+/g," "))}catch(t){}e+="/"+i}return e}(t.substring(h,l)));var f=function(t){var e,n,r={};"?"===t.charAt(0)&&(t=t.substring(1));try{for(var i=va(t.split("&")),o=i.next();!o.done;o=i.next()){var a=o.value;if(0!==a.length){var s=a.split("=");2===s.length?r[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):Xs("Invalid query segment '"+a+"' in query '"+t+"'")}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}(t.substring(Math.min(t.length,l)));0<=(c=e.indexOf(":"))?(a="https"===s||"wss"===s,u=parseInt(e.substring(c+1),10)):c=t.length;var p=e.split(".");3===p.length?(n=p[1],o=r=p[0].toLowerCase()):2===p.length?n=p[0]:"localhost"===p[0].slice(0,c).toLowerCase()&&(n="localhost"),"ns"in f&&(o=f.ns)}return{host:e,port:u,domain:n,subdomain:r,secure:a,scheme:s,pathString:i,namespace:o}},Bu=/[\[\].#$\/\u0000-\u001F\u007F]/,ju=/[\[\].#$\u0000-\u001F\u007F]/,Wu=10485760,Ku=function(n,t,e){var r=e instanceof bu?new _u(e,n):e;if(void 0===t)throw new Error(n+"contains undefined "+r.toErrorString());if("function"==typeof t)throw new Error(n+"contains a function "+r.toErrorString()+" with contents = "+t.toString());if(Js(t))throw new Error(n+"contains "+t.toString()+" "+r.toErrorString());if("string"==typeof t&&t.length>Wu/3&&os(t)>Wu)throw new Error(n+"contains a string greater than "+Wu+" utf8 bytes "+r.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var i=!1,o=!1;if(pu(t,function(t,e){if(".value"===t)i=!0;else if(".priority"!==t&&".sv"!==t&&(o=!0,!ku(t)))throw new Error(n+" contains an invalid key ("+t+") "+r.toErrorString()+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');r.push(t),Ku(n,e,r),r.pop()}),i&&o)throw new Error(n+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},Qu=(Hu.prototype.cancel=function(t){es("OnDisconnect.cancel",0,1,arguments.length),rs("OnDisconnect.cancel",1,t,!0);var e=new Da;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},Hu.prototype.remove=function(t){es("OnDisconnect.remove",0,1,arguments.length),Uu("OnDisconnect.remove",this.path_),rs("OnDisconnect.remove",1,t,!0);var e=new Da;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},Hu.prototype.set=function(t,e){es("OnDisconnect.set",1,2,arguments.length),Uu("OnDisconnect.set",this.path_),Ou("OnDisconnect.set",1,t,this.path_,!1),rs("OnDisconnect.set",2,e,!0);var n=new Da;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},Hu.prototype.setWithPriority=function(t,e,n){es("OnDisconnect.setWithPriority",2,3,arguments.length),Uu("OnDisconnect.setWithPriority",this.path_),Ou("OnDisconnect.setWithPriority",1,t,this.path_,!1),Mu("OnDisconnect.setWithPriority",2,e,!1),rs("OnDisconnect.setWithPriority",3,n,!0);var r=new Da;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},Hu.prototype.update=function(t,e){if(es("OnDisconnect.update",1,2,arguments.length),Uu("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,Xs("Passing an Array to firebase.database.onDisconnect().update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}Pu("OnDisconnect.update",1,t,this.path_,!1),rs("OnDisconnect.update",2,e,!0);var i=new Da;return this.repo_.onDisconnectUpdate(this.path_,t,i.wrapCallback(e)),i.promise},Hu);function Hu(t,e){this.repo_=t,this.path_=e}var Gu=(zu.prototype.toJSON=function(){return es("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},zu);function zu(t,e){this.committed=t,this.snapshot=e}var Yu,Xu,Ju,$u=(Yu="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Xu=0,Ju=[],function(t){var e,n=t===Xu;Xu=t;var r=new Array(8);for(e=7;0<=e;e--)r[e]=Yu.charAt(t%64),t=Math.floor(t/64);Ia(0===t,"Cannot push at time == 0");var i=r.join("");if(n){for(e=11;0<=e&&63===Ju[e];e--)Ju[e]=0;Ju[e]++}else for(e=0;e<12;e++)Ju[e]=Math.floor(64*Math.random());for(e=0;e<12;e++)i+=Yu.charAt(Ju[e]);return Ia(20===i.length,"nextPushId: Length should be 20."),i}),Zu=(tc.Wrap=function(t,e){return new tc(t,e)},tc);function tc(t,e){this.name=t,this.node=e}var ec,nc=(rc.prototype.getCompare=function(){return this.compare.bind(this)},rc.prototype.indexedValueChanged=function(t,e){var n=new Zu(cu,t),r=new Zu(cu,e);return 0!==this.compare(n,r)},rc.prototype.minPost=function(){return Zu.MIN},rc);function rc(){}var ic,oc=(da(ac,ic=nc),Object.defineProperty(ac,"__EMPTY_NODE",{get:function(){return ec},set:function(t){ec=t},enumerable:!0,configurable:!0}),ac.prototype.compare=function(t,e){return lu(t.name,e.name)},ac.prototype.isDefinedOn=function(t){throw Ca("KeyIndex.isDefinedOn not expected to be called.")},ac.prototype.indexedValueChanged=function(t,e){return!1},ac.prototype.minPost=function(){return Zu.MIN},ac.prototype.maxPost=function(){return new Zu(hu,ec)},ac.prototype.makePost=function(t,e){return Ia("string"==typeof t,"KeyIndex indexValue must always be a string."),new Zu(t,ec)},ac.prototype.toString=function(){return".key"},ac);function ac(){return null!==ic&&ic.apply(this,arguments)||this}var sc,uc=new oc;function cc(t){return"number"==typeof t?"number:"+du(t):"string:"+t}function hc(t){if(t.isLeafNode()){var e=t.val();Ia("string"==typeof e||"number"==typeof e||"object"==typeof e&&Qa(e,".sv"),"Priority must be a string or number.")}else Ia(t===sc||t.isEmpty(),"priority of unexpected type.");Ia(t===sc||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}var lc,fc,pc,dc,mc=(Object.defineProperty(yc,"__childrenNodeConstructor",{get:function(){return lc},set:function(t){lc=t},enumerable:!0,configurable:!0}),yc.prototype.isLeafNode=function(){return!0},yc.prototype.getPriority=function(){return this.priorityNode_},yc.prototype.updatePriority=function(t){return new yc(this.value_,t)},yc.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:yc.__childrenNodeConstructor.EMPTY_NODE},yc.prototype.getChild=function(t){return t.isEmpty()?this:".priority"===t.getFront()?this.priorityNode_:yc.__childrenNodeConstructor.EMPTY_NODE},yc.prototype.hasChild=function(){return!1},yc.prototype.getPredecessorChildName=function(t,e){return null},yc.prototype.updateImmediateChild=function(t,e){return".priority"===t?this.updatePriority(e):e.isEmpty()&&".priority"!==t?this:yc.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,e).updatePriority(this.priorityNode_)},yc.prototype.updateChild=function(t,e){var n=t.getFront();return null===n?e:e.isEmpty()&&".priority"!==n?this:(Ia(".priority"!==n||1===t.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(n,yc.__childrenNodeConstructor.EMPTY_NODE.updateChild(t.popFront(),e)))},yc.prototype.isEmpty=function(){return!1},yc.prototype.numChildren=function(){return 0},yc.prototype.forEachChild=function(t,e){return!1},yc.prototype.val=function(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},yc.prototype.hash=function(){if(null===this.lazyHash_){var t="";this.priorityNode_.isEmpty()||(t+="priority:"+cc(this.priorityNode_.val())+":");var e=typeof this.value_;t+=e+":",t+="number"==e?du(this.value_):this.value_,this.lazyHash_=Ks(t)}return this.lazyHash_},yc.prototype.getValue=function(){return this.value_},yc.prototype.compareTo=function(t){return t===yc.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof yc.__childrenNodeConstructor?-1:(Ia(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},yc.prototype.compareToLeafNode_=function(t){var e=typeof t.value_,n=typeof this.value_,r=yc.VALUE_TYPE_ORDER.indexOf(e),i=yc.VALUE_TYPE_ORDER.indexOf(n);return Ia(0<=r,"Unknown leaf type: "+e),Ia(0<=i,"Unknown leaf type: "+n),r===i?"object"==n?0:this.value_<t.value_?-1:this.value_===t.value_?0:1:i-r},yc.prototype.withIndex=function(){return this},yc.prototype.isIndexed=function(){return!0},yc.prototype.equals=function(t){if(t===this)return!0;if(t.isLeafNode()){var e=t;return this.value_===e.value_&&this.priorityNode_.equals(e.priorityNode_)}return!1},yc.VALUE_TYPE_ORDER=["object","boolean","number","string"],yc);function yc(t,e){void 0===e&&(e=yc.__childrenNodeConstructor.EMPTY_NODE),this.value_=t,this.priorityNode_=e,this.lazyHash_=null,Ia(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),hc(this.priorityNode_)}function gc(){return null!==dc&&dc.apply(this,arguments)||this}var vc=new(da(gc,dc=nc),gc.prototype.compare=function(t,e){var n=t.node.getPriority(),r=e.node.getPriority(),i=n.compareTo(r);return 0===i?lu(t.name,e.name):i},gc.prototype.isDefinedOn=function(t){return!t.getPriority().isEmpty()},gc.prototype.indexedValueChanged=function(t,e){return!t.getPriority().equals(e.getPriority())},gc.prototype.minPost=function(){return Zu.MIN},gc.prototype.maxPost=function(){return new Zu(hu,new mc("[PRIORITY-POST]",pc))},gc.prototype.makePost=function(t,e){var n=fc(t);return new Zu(e,new mc("[PRIORITY-POST]",n))},gc.prototype.toString=function(){return".priority"},gc),bc=(wc.prototype.getNext=function(){if(0===this.nodeStack_.length)return null;var t,e=this.nodeStack_.pop();if(t=this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value},this.isReverse_)for(e=e.left;!e.isEmpty();)this.nodeStack_.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack_.push(e),e=e.left;return t},wc.prototype.hasNext=function(){return 0<this.nodeStack_.length},wc.prototype.peek=function(){if(0===this.nodeStack_.length)return null;var t=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value}},wc);function wc(t,e,n,r,i){void 0===i&&(i=null),this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];for(var o=1;!t.isEmpty();)if(t=t,o=e?n(t.key,e):1,r&&(o*=-1),o<0)t=this.isReverse_?t.left:t.right;else{if(0===o){this.nodeStack_.push(t);break}this.nodeStack_.push(t),t=this.isReverse_?t.right:t.left}}var _c=(Tc.prototype.copy=function(t,e,n,r,i){return new Tc(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)},Tc.prototype.count=function(){return this.left.count()+1+this.right.count()},Tc.prototype.isEmpty=function(){return!1},Tc.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},Tc.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},Tc.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},Tc.prototype.minKey=function(){return this.min_().key},Tc.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},Tc.prototype.insert=function(t,e,n){var r,i;return(i=(r=n(t,(i=this).key))<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_()},Tc.prototype.removeMin_=function(){if(this.left.isEmpty())return Ic.EMPTY_NODE;var t=this;return t.left.isRed_()||t.left.left.isRed_()||(t=t.moveRedLeft_()),(t=t.copy(null,null,null,t.left.removeMin_(),null)).fixUp_()},Tc.prototype.remove=function(t,e){var n,r;if(e(t,(n=this).key)<0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(t,e),null);else{if(n.left.isRed_()&&(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===e(t,n.key)){if(n.right.isEmpty())return Ic.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(t,e))}return n.fixUp_()},Tc.prototype.isRed_=function(){return this.color},Tc.prototype.fixUp_=function(){var 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},Tc.prototype.moveRedLeft_=function(){var t=this.colorFlip_();return t.right.left.isRed_()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight_())).rotateLeft_()).colorFlip_()),t},Tc.prototype.moveRedRight_=function(){var t=this.colorFlip_();return t.left.left.isRed_()&&(t=(t=t.rotateRight_()).colorFlip_()),t},Tc.prototype.rotateLeft_=function(){var t=this.copy(null,null,Tc.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},Tc.prototype.rotateRight_=function(){var t=this.copy(null,null,Tc.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},Tc.prototype.colorFlip_=function(){var 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)},Tc.prototype.checkMaxDepth_=function(){var t=this.check_();return Math.pow(2,t)<=this.count()+1},Tc.prototype.check_=function(){var t;if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");if((t=this.left.check_())!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)},Tc.RED=!0,Tc.BLACK=!1,Tc);function Tc(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:Tc.RED,this.left=null!=r?r:Ic.EMPTY_NODE,this.right=null!=i?i:Ic.EMPTY_NODE}var Ec=(Sc.prototype.copy=function(t,e,n,r,i){return this},Sc.prototype.insert=function(t,e,n){return new _c(t,e,null)},Sc.prototype.remove=function(t,e){return this},Sc.prototype.count=function(){return 0},Sc.prototype.isEmpty=function(){return!0},Sc.prototype.inorderTraversal=function(t){return!1},Sc.prototype.reverseTraversal=function(t){return!1},Sc.prototype.minKey=function(){return null},Sc.prototype.maxKey=function(){return null},Sc.prototype.check_=function(){return 0},Sc.prototype.isRed_=function(){return!1},Sc);function Sc(){}var Ic=(Cc.prototype.insert=function(t,e){return new Cc(this.comparator_,this.root_.insert(t,e,this.comparator_).copy(null,null,_c.BLACK,null,null))},Cc.prototype.remove=function(t){return new Cc(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,_c.BLACK,null,null))},Cc.prototype.get=function(t){for(var e,n=this.root_;!n.isEmpty();){if(0===(e=this.comparator_(t,n.key)))return n.value;e<0?n=n.left:0<e&&(n=n.right)}return null},Cc.prototype.getPredecessorKey=function(t){for(var e,n=this.root_,r=null;!n.isEmpty();){if(0===(e=this.comparator_(t,n.key))){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}e<0?n=n.left:0<e&&(n=(r=n).right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")},Cc.prototype.isEmpty=function(){return this.root_.isEmpty()},Cc.prototype.count=function(){return this.root_.count()},Cc.prototype.minKey=function(){return this.root_.minKey()},Cc.prototype.maxKey=function(){return this.root_.maxKey()},Cc.prototype.inorderTraversal=function(t){return this.root_.inorderTraversal(t)},Cc.prototype.reverseTraversal=function(t){return this.root_.reverseTraversal(t)},Cc.prototype.getIterator=function(t){return new bc(this.root_,null,this.comparator_,!1,t)},Cc.prototype.getIteratorFrom=function(t,e){return new bc(this.root_,t,this.comparator_,!1,e)},Cc.prototype.getReverseIteratorFrom=function(t,e){return new bc(this.root_,t,this.comparator_,!0,e)},Cc.prototype.getReverseIterator=function(t){return new bc(this.root_,null,this.comparator_,!0,t)},Cc.EMPTY_NODE=new Ec,Cc);function Cc(t,e){void 0===e&&(e=Cc.EMPTY_NODE),this.comparator_=t,this.root_=e}var Nc=Math.log(2),Ac=(kc.prototype.nextBitIsOne=function(){var t=!(this.bits_&1<<this.current_);return this.current_--,t},kc);function kc(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/Nc,10)),this.current_=this.count-1;var n,r=(n=this.count,parseInt(Array(n+1).join("1"),2));this.bits_=t+1&r}var Dc,Rc,Oc=function(c,t,h,e){c.sort(t);var l=function(t,e){var n,r,i=e-t;if(0==i)return null;if(1==i)return n=c[t],r=h?h(n):n,new _c(r,n.node,_c.BLACK,null,null);var o=parseInt(i/2,10)+t,a=l(t,o),s=l(o+1,e);return n=c[o],r=h?h(n):n,new _c(r,n.node,_c.BLACK,a,s)},n=function(t){for(var e=null,n=null,s=c.length,r=function(t,e){var n=s-t,r=s;s-=t;var i=l(1+n,r),o=c[n],a=h?h(o):o;u(new _c(a,o.node,e,null,i))},u=function(t){e=e?e.left=t:n=t},i=0;i<t.count;++i){var o=t.nextBitIsOne(),a=Math.pow(2,t.count-(i+1));o?r(a,_c.BLACK):(r(a,_c.BLACK),r(a,_c.RED))}return n}(new Ac(c.length));return new Ic(e||t,n)},Pc={},Mc=(Object.defineProperty(xc,"Default",{get:function(){return Ia(vc,"ChildrenNode.ts has not been loaded"),Dc=Dc||new xc({".priority":Pc},{".priority":vc})},enumerable:!0,configurable:!0}),xc.prototype.get=function(t){var e=Ha(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e instanceof Ic?e:null},xc.prototype.hasIndex=function(t){return Qa(this.indexSet_,t.toString())},xc.prototype.addIndex=function(t,e){Ia(t!==uc,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var n,r=[],i=!1,o=e.getIterator(Zu.Wrap),a=o.getNext();a;)i=i||t.isDefinedOn(a.node),r.push(a),a=o.getNext();n=i?Oc(r,t.getCompare()):Pc;var s=t.toString(),u=ma({},this.indexSet_);u[s]=t;var c=ma({},this.indexes_);return c[s]=n,new xc(c,u)},xc.prototype.addToIndexes=function(u,c){var h=this;return new xc(za(this.indexes_,function(t,e){var n=Ha(h.indexSet_,e);if(Ia(n,"Missing index implementation for "+e),t===Pc){if(n.isDefinedOn(u.node)){for(var r=[],i=c.getIterator(Zu.Wrap),o=i.getNext();o;)o.name!=u.name&&r.push(o),o=i.getNext();return r.push(u),Oc(r,n.getCompare())}return Pc}var a=c.get(u.name),s=t;return a&&(s=s.remove(new Zu(u.name,a))),s.insert(u,u.node)}),this.indexSet_)},xc.prototype.removeFromIndexes=function(n,r){return new xc(za(this.indexes_,function(t){if(t===Pc)return t;var e=r.get(n.name);return e?t.remove(new Zu(n.name,e)):t}),this.indexSet_)},xc);function xc(t,e){this.indexes_=t,this.indexSet_=e}function Lc(t,e){return lu(t.name,e.name)}function Fc(t,e){return lu(t,e)}var Uc,Vc=(Object.defineProperty(qc,"EMPTY_NODE",{get:function(){return Rc=Rc||new qc(new Ic(Fc),null,Mc.Default)},enumerable:!0,configurable:!0}),qc.prototype.isLeafNode=function(){return!1},qc.prototype.getPriority=function(){return this.priorityNode_||Rc},qc.prototype.updatePriority=function(t){return this.children_.isEmpty()?this:new qc(this.children_,t,this.indexMap_)},qc.prototype.getImmediateChild=function(t){if(".priority"===t)return this.getPriority();var e=this.children_.get(t);return null===e?Rc:e},qc.prototype.getChild=function(t){var e=t.getFront();return null===e?this:this.getImmediateChild(e).getChild(t.popFront())},qc.prototype.hasChild=function(t){return null!==this.children_.get(t)},qc.prototype.updateImmediateChild=function(t,e){if(Ia(e,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(e);var n,r=new Zu(t,e),i=void 0,o=void 0;return o=e.isEmpty()?(i=this.children_.remove(t),this.indexMap_.removeFromIndexes(r,this.children_)):(i=this.children_.insert(t,e),this.indexMap_.addToIndexes(r,this.children_)),n=i.isEmpty()?Rc:this.priorityNode_,new qc(i,n,o)},qc.prototype.updateChild=function(t,e){var n=t.getFront();if(null===n)return e;Ia(".priority"!==t.getFront()||1===t.getLength(),".priority must be the last token in a path");var r=this.getImmediateChild(n).updateChild(t.popFront(),e);return this.updateImmediateChild(n,r)},qc.prototype.isEmpty=function(){return this.children_.isEmpty()},qc.prototype.numChildren=function(){return this.children_.count()},qc.prototype.val=function(n){if(this.isEmpty())return null;var r={},i=0,o=0,a=!0;if(this.forEachChild(vc,function(t,e){r[t]=e.val(n),i++,a&&qc.INTEGER_REGEXP_.test(t)?o=Math.max(o,Number(t)):a=!1}),!n&&a&&o<2*i){var t=[];for(var e in r)t[e]=r[e];return t}return n&&!this.getPriority().isEmpty()&&(r[".priority"]=this.getPriority().val()),r},qc.prototype.hash=function(){if(null===this.lazyHash_){var r="";this.getPriority().isEmpty()||(r+="priority:"+cc(this.getPriority().val())+":"),this.forEachChild(vc,function(t,e){var n=e.hash();""!==n&&(r+=":"+t+":"+n)}),this.lazyHash_=""===r?"":Ks(r)}return this.lazyHash_},qc.prototype.getPredecessorChildName=function(t,e,n){var r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new Zu(t,e));return i?i.name:null}return this.children_.getPredecessorKey(t)},qc.prototype.getFirstChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.minKey();return n&&n.name}return this.children_.minKey()},qc.prototype.getFirstChild=function(t){var e=this.getFirstChildName(t);return e?new Zu(e,this.children_.get(e)):null},qc.prototype.getLastChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.maxKey();return n&&n.name}return this.children_.maxKey()},qc.prototype.getLastChild=function(t){var e=this.getLastChildName(t);return e?new Zu(e,this.children_.get(e)):null},qc.prototype.forEachChild=function(t,e){var n=this.resolveIndex_(t);return n?n.inorderTraversal(function(t){return e(t.name,t.node)}):this.children_.inorderTraversal(e)},qc.prototype.getIterator=function(t){return this.getIteratorFrom(t.minPost(),t)},qc.prototype.getIteratorFrom=function(t,e){var n=this.resolveIndex_(e);if(n)return n.getIteratorFrom(t,function(t){return t});for(var r=this.children_.getIteratorFrom(t.name,Zu.Wrap),i=r.peek();null!=i&&e.compare(i,t)<0;)r.getNext(),i=r.peek();return r},qc.prototype.getReverseIterator=function(t){return this.getReverseIteratorFrom(t.maxPost(),t)},qc.prototype.getReverseIteratorFrom=function(t,e){var n=this.resolveIndex_(e);if(n)return n.getReverseIteratorFrom(t,function(t){return t});for(var r=this.children_.getReverseIteratorFrom(t.name,Zu.Wrap),i=r.peek();null!=i&&0<e.compare(i,t);)r.getNext(),i=r.peek();return r},qc.prototype.compareTo=function(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===jc?-1:0},qc.prototype.withIndex=function(t){if(t===uc||this.indexMap_.hasIndex(t))return this;var e=this.indexMap_.addIndex(t,this.children_);return new qc(this.children_,this.priorityNode_,e)},qc.prototype.isIndexed=function(t){return t===uc||this.indexMap_.hasIndex(t)},qc.prototype.equals=function(t){if(t===this)return!0;if(t.isLeafNode())return!1;var e=t;if(this.getPriority().equals(e.getPriority())){if(this.children_.count()!==e.children_.count())return!1;for(var n=this.getIterator(vc),r=e.getIterator(vc),i=n.getNext(),o=r.getNext();i&&o;){if(i.name!==o.name||!i.node.equals(o.node))return!1;i=n.getNext(),o=r.getNext()}return null===i&&null===o}return!1},qc.prototype.resolveIndex_=function(t){return t===uc?null:this.indexMap_.get(t.toString())},qc.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,qc);function qc(t,e,n){this.children_=t,this.priorityNode_=e,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&hc(this.priorityNode_),this.children_.isEmpty()&&Ia(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}function Bc(){return Uc.call(this,new Ic(Fc),Vc.EMPTY_NODE,Mc.Default)||this}var jc=new(da(Bc,Uc=Vc),Bc.prototype.compareTo=function(t){return t===this?0:1},Bc.prototype.equals=function(t){return t===this},Bc.prototype.getPriority=function(){return this},Bc.prototype.getImmediateChild=function(t){return Vc.EMPTY_NODE},Bc.prototype.isEmpty=function(){return!1},Bc);Object.defineProperties(Zu,{MIN:{value:new Zu(cu,Vc.EMPTY_NODE)},MAX:{value:new Zu(hu,jc)}}),oc.__EMPTY_NODE=Vc.EMPTY_NODE,mc.__childrenNodeConstructor=Vc,sc=jc,pc=jc;var Wc,Kc=!0;function Qc(r,t){if(void 0===t&&(t=null),null===r)return Vc.EMPTY_NODE;if("object"==typeof r&&".priority"in r&&(t=r[".priority"]),Ia(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&&".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof r&&".value"in r&&null!==r[".value"]&&(r=r[".value"]),"object"!=typeof r||".sv"in r)return new mc(r,Qc(t));if(r instanceof Array||!Kc){var i=Vc.EMPTY_NODE;return pu(r,function(t,e){if(Qa(r,t)&&"."!==t.substring(0,1)){var n=Qc(e);!n.isLeafNode()&&n.isEmpty()||(i=i.updateImmediateChild(t,n))}}),i.updatePriority(Qc(t))}var o=[],a=!1;if(pu(r,function(t,e){if("."!==t.substring(0,1)){var n=Qc(e);n.isEmpty()||(a=a||!n.getPriority().isEmpty(),o.push(new Zu(t,n)))}}),0==o.length)return Vc.EMPTY_NODE;var e=Oc(o,Lc,function(t){return t.name},Fc);if(a){var n=Oc(o,vc.getCompare());return new Vc(e,Qc(t),new Mc({".priority":n},{".priority":vc}))}return new Vc(e,Qc(t),Mc.Default)}function Hc(){return null!==Wc&&Wc.apply(this,arguments)||this}fc=Qc;var Gc,zc=new(da(Hc,Wc=nc),Hc.prototype.compare=function(t,e){var n=t.node.compareTo(e.node);return 0===n?lu(t.name,e.name):n},Hc.prototype.isDefinedOn=function(t){return!0},Hc.prototype.indexedValueChanged=function(t,e){return!t.equals(e)},Hc.prototype.minPost=function(){return Zu.MIN},Hc.prototype.maxPost=function(){return Zu.MAX},Hc.prototype.makePost=function(t,e){var n=Qc(t);return new Zu(e,n)},Hc.prototype.toString=function(){return".value"},Hc),Yc=(da(Xc,Gc=nc),Xc.prototype.extractChild=function(t){return t.getChild(this.indexPath_)},Xc.prototype.isDefinedOn=function(t){return!t.getChild(this.indexPath_).isEmpty()},Xc.prototype.compare=function(t,e){var n=this.extractChild(t.node),r=this.extractChild(e.node),i=n.compareTo(r);return 0===i?lu(t.name,e.name):i},Xc.prototype.makePost=function(t,e){var n=Qc(t),r=Vc.EMPTY_NODE.updateChild(this.indexPath_,n);return new Zu(e,r)},Xc.prototype.maxPost=function(){var t=Vc.EMPTY_NODE.updateChild(this.indexPath_,jc);return new Zu(hu,t)},Xc.prototype.toString=function(){return this.indexPath_.slice().join("/")},Xc);function Xc(t){var e=Gc.call(this)||this;return e.indexPath_=t,Ia(!t.isEmpty()&&".priority"!==t.getFront(),"Can't create PathIndex with empty path or .priority key"),e}var Jc=($c.prototype.val=function(){return es("DataSnapshot.val",0,0,arguments.length),this.node_.val()},$c.prototype.exportVal=function(){return es("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},$c.prototype.toJSON=function(){return es("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},$c.prototype.exists=function(){return es("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},$c.prototype.child=function(t){es("DataSnapshot.child",0,1,arguments.length),t=String(t),Fu("DataSnapshot.child",1,t,!1);var e=new bu(t),n=this.ref_.child(e);return new $c(this.node_.getChild(e),n,vc)},$c.prototype.hasChild=function(t){es("DataSnapshot.hasChild",1,1,arguments.length),Fu("DataSnapshot.hasChild",1,t,!1);var e=new bu(t);return!this.node_.getChild(e).isEmpty()},$c.prototype.getPriority=function(){return es("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},$c.prototype.forEach=function(n){var r=this;return es("DataSnapshot.forEach",1,1,arguments.length),rs("DataSnapshot.forEach",1,n,!1),!this.node_.isLeafNode()&&!!this.node_.forEachChild(this.index_,function(t,e){return n(new $c(e,r.ref_.child(t),vc))})},$c.prototype.hasChildren=function(){return es("DataSnapshot.hasChildren",0,0,arguments.length),!this.node_.isLeafNode()&&!this.node_.isEmpty()},Object.defineProperty($c.prototype,"key",{get:function(){return this.ref_.getKey()},enumerable:!0,configurable:!0}),$c.prototype.numChildren=function(){return es("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},$c.prototype.getRef=function(){return es("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty($c.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),$c);function $c(t,e,n){this.node_=t,this.ref_=e,this.index_=n}var Zc=(th.prototype.getPath=function(){var t=this.snapshot.getRef();return"value"===this.eventType?t.path:t.getParent().path},th.prototype.getEventType=function(){return this.eventType},th.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},th.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+Wa(this.snapshot.exportVal())},th);function th(t,e,n,r){this.eventType=t,this.eventRegistration=e,this.snapshot=n,this.prevName=r}var eh=(nh.prototype.getPath=function(){return this.path},nh.prototype.getEventType=function(){return"cancel"},nh.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},nh.prototype.toString=function(){return this.path.toString()+":cancel"},nh);function nh(t,e,n){this.eventRegistration=t,this.error=e,this.path=n}var rh=(ih.prototype.respondsTo=function(t){return"value"===t},ih.prototype.createEvent=function(t,e){var n=e.getQueryParams().getIndex();return new Zc("value",this,new Jc(t.snapshotNode,e.getRef(),n))},ih.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){Ia(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(e,t.error)}}var r=this.callback_;return function(){r.call(e,t.snapshot)}},ih.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new eh(this,t,e):null},ih.prototype.matches=function(t){return t instanceof ih&&(!t.callback_||!this.callback_||t.callback_===this.callback_&&t.context_===this.context_)},ih.prototype.hasAnyCallback=function(){return null!==this.callback_},ih);function ih(t,e,n){this.callback_=t,this.cancelCallback_=e,this.context_=n}var oh,ah=(sh.prototype.respondsTo=function(t){var e="children_added"===t?"child_added":t;return e="children_removed"===e?"child_removed":e,Qa(this.callbacks_,e)},sh.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new eh(this,t,e):null},sh.prototype.createEvent=function(t,e){Ia(null!=t.childName,"Child events should have a childName.");var n=e.getRef().child(t.childName),r=e.getQueryParams().getIndex();return new Zc(t.type,this,new Jc(t.snapshotNode,n,r),t.prevName)},sh.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){Ia(this.cancelCallback_,"Raising a cancel event on a listener with no cancel callback");var n=this.cancelCallback_;return function(){n.call(e,t.error)}}var r=this.callbacks_[t.eventType];return function(){r.call(e,t.snapshot,t.prevName)}},sh.prototype.matches=function(e){var n=this;if(e instanceof sh){if(!this.callbacks_||!e.callbacks_)return!0;if(this.context_===e.context_){var t=Object.keys(e.callbacks_),r=Object.keys(this.callbacks_),i=t.length;if(i===r.length){if(1!==i)return r.every(function(t){return e.callbacks_[t]===n.callbacks_[t]});var o=t[0],a=r[0];return!(a!==o||e.callbacks_[o]&&this.callbacks_[a]&&e.callbacks_[o]!==this.callbacks_[a])}}}return!1},sh.prototype.hasAnyCallback=function(){return null!==this.callbacks_},sh);function sh(t,e,n){this.callbacks_=t,this.cancelCallback_=e,this.context_=n}var uh=(Object.defineProperty(ch,"__referenceConstructor",{get:function(){return Ia(oh,"Reference.ts has not been loaded"),oh},set:function(t){oh=t},enumerable:!0,configurable:!0}),ch.validateQueryEndpoints_=function(t){var e=null,n=null;if(t.hasStart()&&(e=t.getIndexStartValue()),t.hasEnd()&&(n=t.getIndexEndValue()),t.getIndex()===uc){var r="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",i="Query: When ordering by key, the argument passed to startAt(), endAt(),or equalTo() must be a string.";if(t.hasStart()){if(t.getIndexStartName()!=cu)throw new Error(r);if("string"!=typeof e)throw new Error(i)}if(t.hasEnd()){if(t.getIndexEndName()!=hu)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(t.getIndex()===vc){if(null!=e&&!Ru(e)||null!=n&&!Ru(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), endAt(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if(Ia(t.getIndex()instanceof Yc||t.getIndex()===zc,"unknown index type."),null!=e&&"object"==typeof e||null!=n&&"object"==typeof n)throw new Error("Query: First argument passed to startAt(), endAt(), or equalTo() cannot be an object.")},ch.validateLimit_=function(t){if(t.hasStart()&&t.hasEnd()&&t.hasLimit()&&!t.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), endAt(), and limit(). Use limitToFirst() or limitToLast() instead.")},ch.prototype.validateNoPreviousOrderByCall_=function(t){if(!0===this.orderByCalled_)throw new Error(t+": You can't combine multiple orderBy calls.")},ch.prototype.getQueryParams=function(){return this.queryParams_},ch.prototype.getRef=function(){return es("Query.ref",0,0,arguments.length),new ch.__referenceConstructor(this.repo,this.path)},ch.prototype.on=function(t,e,n,r){es("Query.on",2,4,arguments.length),xu("Query.on",1,t,!1),rs("Query.on",2,e,!1);var i=ch.getCancelAndContextArgs_("Query.on",n,r);if("value"===t)this.onValueEvent(e,i.cancel,i.context);else{var o={};o[t]=e,this.onChildEvent(o,i.cancel,i.context)}return e},ch.prototype.onValueEvent=function(t,e,n){var r=new rh(t,e||null,n||null);this.repo.addEventCallbackForQuery(this,r)},ch.prototype.onChildEvent=function(t,e,n){var r=new ah(t,e,n);this.repo.addEventCallbackForQuery(this,r)},ch.prototype.off=function(t,e,n){es("Query.off",0,3,arguments.length),xu("Query.off",1,t,!0),rs("Query.off",2,e,!0),is("Query.off",3,n,!0);var r=null,i=null;"value"===t?r=new rh(e||null,null,n||null):t&&(e&&((i={})[t]=e),r=new ah(i,null,n||null)),this.repo.removeEventCallbackForQuery(this,r)},ch.prototype.once=function(e,n,t,r){var i=this;es("Query.once",1,4,arguments.length),xu("Query.once",1,e,!1),rs("Query.once",2,n,!0);var o=ch.getCancelAndContextArgs_("Query.once",t,r),a=!0,s=new Da;s.promise.catch(function(){});var u=function(t){a&&(a=!1,i.off(e,u),n&&n.bind(o.context)(t),s.resolve(t))};return this.on(e,u,function(t){i.off(e,u),o.cancel&&o.cancel.bind(o.context)(t),s.reject(t)}),s.promise},ch.prototype.limitToFirst=function(t){if(es("Query.limitToFirst",1,1,arguments.length),"number"!=typeof t||Math.floor(t)!==t||t<=0)throw new Error("Query.limitToFirst: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToFirst: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new ch(this.repo,this.path,this.queryParams_.limitToFirst(t),this.orderByCalled_)},ch.prototype.limitToLast=function(t){if(es("Query.limitToLast",1,1,arguments.length),"number"!=typeof t||Math.floor(t)!==t||t<=0)throw new Error("Query.limitToLast: First argument must be a positive integer.");if(this.queryParams_.hasLimit())throw new Error("Query.limitToLast: Limit was already set (by another call to limit, limitToFirst, or limitToLast).");return new ch(this.repo,this.path,this.queryParams_.limitToLast(t),this.orderByCalled_)},ch.prototype.orderByChild=function(t){if(es("Query.orderByChild",1,1,arguments.length),"$key"===t)throw new Error('Query.orderByChild: "$key" is invalid.  Use Query.orderByKey() instead.');if("$priority"===t)throw new Error('Query.orderByChild: "$priority" is invalid.  Use Query.orderByPriority() instead.');if("$value"===t)throw new Error('Query.orderByChild: "$value" is invalid.  Use Query.orderByValue() instead.');Fu("Query.orderByChild",1,t,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild");var e=new bu(t);if(e.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path.  Use Query.orderByValue() instead.");var n=new Yc(e),r=this.queryParams_.orderBy(n);return ch.validateQueryEndpoints_(r),new ch(this.repo,this.path,r,!0)},ch.prototype.orderByKey=function(){es("Query.orderByKey",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByKey");var t=this.queryParams_.orderBy(uc);return ch.validateQueryEndpoints_(t),new ch(this.repo,this.path,t,!0)},ch.prototype.orderByPriority=function(){es("Query.orderByPriority",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByPriority");var t=this.queryParams_.orderBy(vc);return ch.validateQueryEndpoints_(t),new ch(this.repo,this.path,t,!0)},ch.prototype.orderByValue=function(){es("Query.orderByValue",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByValue");var t=this.queryParams_.orderBy(zc);return ch.validateQueryEndpoints_(t),new ch(this.repo,this.path,t,!0)},ch.prototype.startAt=function(t,e){void 0===t&&(t=null),es("Query.startAt",0,2,arguments.length),Ou("Query.startAt",1,t,this.path,!0),Lu("Query.startAt",2,e,!0);var n=this.queryParams_.startAt(t,e);if(ch.validateLimit_(n),ch.validateQueryEndpoints_(n),this.queryParams_.hasStart())throw new Error("Query.startAt: Starting point was already set (by another call to startAt or equalTo).");return void 0===t&&(e=t=null),new ch(this.repo,this.path,n,this.orderByCalled_)},ch.prototype.endAt=function(t,e){void 0===t&&(t=null),es("Query.endAt",0,2,arguments.length),Ou("Query.endAt",1,t,this.path,!0),Lu("Query.endAt",2,e,!0);var n=this.queryParams_.endAt(t,e);if(ch.validateLimit_(n),ch.validateQueryEndpoints_(n),this.queryParams_.hasEnd())throw new Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new ch(this.repo,this.path,n,this.orderByCalled_)},ch.prototype.equalTo=function(t,e){if(es("Query.equalTo",1,2,arguments.length),Ou("Query.equalTo",1,t,this.path,!1),Lu("Query.equalTo",2,e,!0),this.queryParams_.hasStart())throw new Error("Query.equalTo: Starting point was already set (by another call to startAt or equalTo).");if(this.queryParams_.hasEnd())throw new Error("Query.equalTo: Ending point was already set (by another call to endAt or equalTo).");return this.startAt(t,e).endAt(t,e)},ch.prototype.toString=function(){return es("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},ch.prototype.toJSON=function(){return es("Query.toJSON",0,1,arguments.length),this.toString()},ch.prototype.queryObject=function(){return this.queryParams_.getQueryObject()},ch.prototype.queryIdentifier=function(){var t=this.queryObject(),e=fu(t);return"{}"===e?"default":e},ch.prototype.isEqual=function(t){if(es("Query.isEqual",1,1,arguments.length),!(t instanceof ch))throw new Error("Query.isEqual failed: First argument must be an instance of firebase.database.Query.");var e=this.repo===t.repo,n=this.path.equals(t.path),r=this.queryIdentifier()===t.queryIdentifier();return e&&n&&r},ch.getCancelAndContextArgs_=function(t,e,n){var r={cancel:null,context:null};if(e&&n)r.cancel=e,rs(t,3,r.cancel,!0),r.context=n,is(t,4,r.context,!0);else if(e)if("object"==typeof e&&null!==e)r.context=e;else{if("function"!=typeof e)throw new Error(ns(t,3,!0)+" must either be a cancel callback or a context object.");r.cancel=e}return r},Object.defineProperty(ch.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),ch);function ch(t,e,n,r){this.repo=t,this.path=e,this.queryParams_=n,this.orderByCalled_=r}var hh=(lh.prototype.find=function(t){if(null!=this.value)return this.value.getChild(t);if(!t.isEmpty()&&0<this.children.size){var e=t.getFront();return t=t.popFront(),this.children.has(e)?this.children.get(e).find(t):null}return null},lh.prototype.remember=function(t,e){if(t.isEmpty())this.value=e,this.children.clear();else if(null!==this.value)this.value=this.value.updateChild(t,e);else{var n=t.getFront();this.children.has(n)||this.children.set(n,new lh);var r=this.children.get(n);t=t.popFront(),r.remember(t,e)}},lh.prototype.forget=function(t){if(t.isEmpty())return this.value=null,this.children.clear(),!0;if(null!==this.value){if(this.value.isLeafNode())return!1;var e=this.value;this.value=null;var n=this;return e.forEachChild(vc,function(t,e){n.remember(new bu(t),e)}),this.forget(t)}if(0<this.children.size){var r=t.getFront();return t=t.popFront(),!this.children.has(r)||this.children.get(r).forget(t)&&this.children.delete(r),0===this.children.size}return!0},lh.prototype.forEachTree=function(r,i){null!==this.value?i(r,this.value):this.forEachChild(function(t,e){var n=new bu(r.toString()+"/"+t);e.forEachTree(n,i)})},lh.prototype.forEachChild=function(n){this.children.forEach(function(t,e){n(e,t)})},lh);function lh(){this.value=null,this.children=new Map}function fh(t,e,n){return t&&"object"==typeof t?(Ia(".sv"in t,"Unexpected leaf node or priority contents"),"string"==typeof t[".sv"]?mh(t[".sv"],e,n):"object"==typeof t[".sv"]?yh(t[".sv"],e):void Ia(!1,"Unexpected server value: "+JSON.stringify(t,null,2))):t}var ph,dh,mh=function(t,e,n){switch(t){case"timestamp":return n.timestamp;default:Ia(!1,"Unexpected server value: "+t)}},yh=function(t,e,n){t.hasOwnProperty("increment")||Ia(!1,"Unexpected server value: "+JSON.stringify(t,null,2));var r=t.increment;if("number"!=typeof r&&Ia(!1,"Unexpected increment value: "+r),!e.isLeafNode())return r;var i=e.getValue();return"number"!=typeof i?r:i+r},gh=function(t,r,i){var o,e=t.getPriority().val(),n=fh(e,r.getPriority(),i);if(t.isLeafNode()){var a=t,s=fh(a.getValue(),r,i);return s!==a.getValue()||n!==a.getPriority().val()?new mc(s,Qc(n)):t}var u=t;return n!==(o=u).getPriority().val()&&(o=o.updatePriority(new mc(n))),u.forEachChild(vc,function(t,e){var n=gh(e,r.getImmediateChild(t),i);n!==e&&(o=o.updateImmediateChild(t,n))}),o};(dh=ph=ph||{})[dh.OVERWRITE=0]="OVERWRITE",dh[dh.MERGE=1]="MERGE",dh[dh.ACK_USER_WRITE=2]="ACK_USER_WRITE",dh[dh.LISTEN_COMPLETE=3]="LISTEN_COMPLETE";var vh=(bh.User=new bh(!0,!1,null,!1),bh.Server=new bh(!1,!0,null,!1),bh.forServerTaggedQuery=function(t){return new bh(!1,!0,t,!0)},bh);function bh(t,e,n,r){this.fromUser=t,this.fromServer=e,this.queryId=n,this.tagged=r,Ia(!r||e,"Tagged queries must be from server.")}var wh,_h=(Th.prototype.operationForChild=function(t){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return Ia(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var e=this.affectedTree.subtree(new bu(t));return new Th(bu.Empty,e,this.revert)}return Ia(this.path.getFront()===t,"operationForChild called for unrelated child."),new Th(this.path.popFront(),this.affectedTree,this.revert)},Th);function Th(t,e,n){this.path=t,this.affectedTree=e,this.revert=n,this.type=ph.ACK_USER_WRITE,this.source=vh.User}var Eh=(Sh.fromObject=function(t){var n=Sh.Empty;return pu(t,function(t,e){n=n.set(new bu(t),e)}),n},Sh.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},Sh.prototype.findRootMostMatchingPathAndValue=function(t,e){if(null!=this.value&&e(this.value))return{path:bu.Empty,value:this.value};if(t.isEmpty())return null;var n=t.getFront(),r=this.children.get(n);if(null===r)return null;var i=r.findRootMostMatchingPathAndValue(t.popFront(),e);return null==i?null:{path:new bu(n).child(i.path),value:i.value}},Sh.prototype.findRootMostValueAndPath=function(t){return this.findRootMostMatchingPathAndValue(t,function(){return!0})},Sh.prototype.subtree=function(t){if(t.isEmpty())return this;var e=t.getFront(),n=this.children.get(e);return null!==n?n.subtree(t.popFront()):Sh.Empty},Sh.prototype.set=function(t,e){if(t.isEmpty())return new Sh(e,this.children);var n=t.getFront(),r=(this.children.get(n)||Sh.Empty).set(t.popFront(),e),i=this.children.insert(n,r);return new Sh(this.value,i)},Sh.prototype.remove=function(t){if(t.isEmpty())return this.children.isEmpty()?Sh.Empty:new Sh(null,this.children);var e=t.getFront(),n=this.children.get(e);if(n){var r=n.remove(t.popFront()),i=void 0;return i=r.isEmpty()?this.children.remove(e):this.children.insert(e,r),null===this.value&&i.isEmpty()?Sh.Empty:new Sh(this.value,i)}return this},Sh.prototype.get=function(t){if(t.isEmpty())return this.value;var e=t.getFront(),n=this.children.get(e);return n?n.get(t.popFront()):null},Sh.prototype.setTree=function(t,e){if(t.isEmpty())return e;var n=t.getFront(),r=(this.children.get(n)||Sh.Empty).setTree(t.popFront(),e),i=void 0;return i=r.isEmpty()?this.children.remove(n):this.children.insert(n,r),new Sh(this.value,i)},Sh.prototype.fold=function(t){return this.fold_(bu.Empty,t)},Sh.prototype.fold_=function(n,r){var i={};return this.children.inorderTraversal(function(t,e){i[t]=e.fold_(n.child(t),r)}),r(n,this.value,i)},Sh.prototype.findOnPath=function(t,e){return this.findOnPath_(t,bu.Empty,e)},Sh.prototype.findOnPath_=function(t,e,n){var r=!!this.value&&n(e,this.value);if(r)return r;if(t.isEmpty())return null;var i=t.getFront(),o=this.children.get(i);return o?o.findOnPath_(t.popFront(),e.child(i),n):null},Sh.prototype.foreachOnPath=function(t,e){return this.foreachOnPath_(t,bu.Empty,e)},Sh.prototype.foreachOnPath_=function(t,e,n){if(t.isEmpty())return this;this.value&&n(e,this.value);var r=t.getFront(),i=this.children.get(r);return i?i.foreachOnPath_(t.popFront(),e.child(r),n):Sh.Empty},Sh.prototype.foreach=function(t){this.foreach_(bu.Empty,t)},Sh.prototype.foreach_=function(n,r){this.children.inorderTraversal(function(t,e){e.foreach_(n.child(t),r)}),this.value&&r(n,this.value)},Sh.prototype.foreachChild=function(n){this.children.inorderTraversal(function(t,e){e.value&&n(t,e.value)})},Sh.Empty=new Sh(null),Sh);function Sh(t,e){void 0===e&&(e=wh=wh||new Ic($s)),this.value=t,this.children=e}var Ih=(Ch.prototype.operationForChild=function(t){return this.path.isEmpty()?new Ch(this.source,bu.Empty):new Ch(this.source,this.path.popFront())},Ch);function Ch(t,e){this.source=t,this.path=e,this.type=ph.LISTEN_COMPLETE}var Nh=(Ah.prototype.operationForChild=function(t){return this.path.isEmpty()?new Ah(this.source,bu.Empty,this.snap.getImmediateChild(t)):new Ah(this.source,this.path.popFront(),this.snap)},Ah);function Ah(t,e,n){this.source=t,this.path=e,this.snap=n,this.type=ph.OVERWRITE}var kh=(Dh.prototype.operationForChild=function(t){if(this.path.isEmpty()){var e=this.children.subtree(new bu(t));return e.isEmpty()?null:e.value?new Nh(this.source,bu.Empty,e.value):new Dh(this.source,bu.Empty,e)}return Ia(this.path.getFront()===t,"Can't get a merge for a child not on the path of the operation"),new Dh(this.source,this.path.popFront(),this.children)},Dh.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},Dh);function Dh(t,e,n){this.source=t,this.path=e,this.children=n,this.type=ph.MERGE}var Rh=(Oh.prototype.isFullyInitialized=function(){return this.fullyInitialized_},Oh.prototype.isFiltered=function(){return this.filtered_},Oh.prototype.isCompleteForPath=function(t){if(t.isEmpty())return this.isFullyInitialized()&&!this.filtered_;var e=t.getFront();return this.isCompleteForChild(e)},Oh.prototype.isCompleteForChild=function(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)},Oh.prototype.getNode=function(){return this.node_},Oh);function Oh(t,e,n){this.node_=t,this.fullyInitialized_=e,this.filtered_=n}var Ph=(Mh.prototype.updateEventSnap=function(t,e,n){return new Mh(new Rh(t,e,n),this.serverCache_)},Mh.prototype.updateServerSnap=function(t,e,n){return new Mh(this.eventCache_,new Rh(t,e,n))},Mh.prototype.getEventCache=function(){return this.eventCache_},Mh.prototype.getCompleteEventSnap=function(){return this.eventCache_.isFullyInitialized()?this.eventCache_.getNode():null},Mh.prototype.getServerCache=function(){return this.serverCache_},Mh.prototype.getCompleteServerSnap=function(){return this.serverCache_.isFullyInitialized()?this.serverCache_.getNode():null},Mh.Empty=new Mh(new Rh(Vc.EMPTY_NODE,!1,!1),new Rh(Vc.EMPTY_NODE,!1,!1)),Mh);function Mh(t,e){this.eventCache_=t,this.serverCache_=e}var xh=(Lh.valueChange=function(t){return new Lh(Lh.VALUE,t)},Lh.childAddedChange=function(t,e){return new Lh(Lh.CHILD_ADDED,e,t)},Lh.childRemovedChange=function(t,e){return new Lh(Lh.CHILD_REMOVED,e,t)},Lh.childChangedChange=function(t,e,n){return new Lh(Lh.CHILD_CHANGED,e,t,n)},Lh.childMovedChange=function(t,e){return new Lh(Lh.CHILD_MOVED,e,t)},Lh.CHILD_ADDED="child_added",Lh.CHILD_REMOVED="child_removed",Lh.CHILD_CHANGED="child_changed",Lh.CHILD_MOVED="child_moved",Lh.VALUE="value",Lh);function Lh(t,e,n,r,i){this.type=t,this.snapshotNode=e,this.childName=n,this.oldSnap=r,this.prevName=i}var Fh=(Uh.prototype.updateChild=function(t,e,n,r,i,o){Ia(t.isIndexed(this.index_),"A node must be indexed if only a child is updated");var a=t.getImmediateChild(e);return a.getChild(r).equals(n.getChild(r))&&a.isEmpty()==n.isEmpty()?t:(null!=o&&(n.isEmpty()?t.hasChild(e)?o.trackChildChange(xh.childRemovedChange(e,a)):Ia(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(xh.childAddedChange(e,n)):o.trackChildChange(xh.childChangedChange(e,n,a))),t.isLeafNode()&&n.isEmpty()?t:t.updateImmediateChild(e,n).withIndex(this.index_))},Uh.prototype.updateFullNode=function(r,n,i){return null!=i&&(r.isLeafNode()||r.forEachChild(vc,function(t,e){n.hasChild(t)||i.trackChildChange(xh.childRemovedChange(t,e))}),n.isLeafNode()||n.forEachChild(vc,function(t,e){if(r.hasChild(t)){var n=r.getImmediateChild(t);n.equals(e)||i.trackChildChange(xh.childChangedChange(t,e,n))}else i.trackChildChange(xh.childAddedChange(t,e))})),n.withIndex(this.index_)},Uh.prototype.updatePriority=function(t,e){return t.isEmpty()?Vc.EMPTY_NODE:t.updatePriority(e)},Uh.prototype.filtersNodes=function(){return!1},Uh.prototype.getIndexedFilter=function(){return this},Uh.prototype.getIndex=function(){return this.index_},Uh);function Uh(t){this.index_=t}var Vh=(qh.prototype.trackChildChange=function(t){var e=t.type,n=t.childName;Ia(e==xh.CHILD_ADDED||e==xh.CHILD_CHANGED||e==xh.CHILD_REMOVED,"Only child changes supported for tracking"),Ia(".priority"!==n,"Only non-priority child changes can be tracked.");var r=this.changeMap.get(n);if(r){var i=r.type;if(e==xh.CHILD_ADDED&&i==xh.CHILD_REMOVED)this.changeMap.set(n,xh.childChangedChange(n,t.snapshotNode,r.snapshotNode));else if(e==xh.CHILD_REMOVED&&i==xh.CHILD_ADDED)this.changeMap.delete(n);else if(e==xh.CHILD_REMOVED&&i==xh.CHILD_CHANGED)this.changeMap.set(n,xh.childRemovedChange(n,r.oldSnap));else if(e==xh.CHILD_CHANGED&&i==xh.CHILD_ADDED)this.changeMap.set(n,xh.childAddedChange(n,t.snapshotNode));else{if(e!=xh.CHILD_CHANGED||i!=xh.CHILD_CHANGED)throw Ca("Illegal combination of changes: "+t+" occurred after "+r);this.changeMap.set(n,xh.childChangedChange(n,t.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,t)},qh.prototype.getChanges=function(){return Array.from(this.changeMap.values())},qh);function qh(){this.changeMap=new Map}function Bh(){}var jh=new(Bh.prototype.getCompleteChild=function(t){return null},Bh.prototype.getChildAfterChild=function(t,e,n){return null},Bh),Wh=(Kh.prototype.getCompleteChild=function(t){var e=this.viewCache_.getEventCache();if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);var n=null!=this.optCompleteServerCache_?new Rh(this.optCompleteServerCache_,!0,!1):this.viewCache_.getServerCache();return this.writes_.calcCompleteChild(t,n)},Kh.prototype.getChildAfterChild=function(t,e,n){var r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:this.viewCache_.getCompleteServerSnap(),i=this.writes_.calcIndexedSlice(r,e,1,n,t);return 0===i.length?null:i[0]},Kh);function Kh(t,e,n){void 0===n&&(n=null),this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=n}var Qh=function(t,e){this.viewCache=t,this.changes=e},Hh=(Gh.prototype.assertIndexed=function(t){Ia(t.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed"),Ia(t.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},Gh.prototype.applyOperation=function(t,e,n,r){var i,o,a=new Vh;if(e.type===ph.OVERWRITE){var s=e;i=s.source.fromUser?this.applyUserOverwrite_(t,s.path,s.snap,n,r,a):(Ia(s.source.fromServer,"Unknown source."),o=s.source.tagged||t.getServerCache().isFiltered()&&!s.path.isEmpty(),this.applyServerOverwrite_(t,s.path,s.snap,n,r,o,a))}else if(e.type===ph.MERGE){var u=e;i=u.source.fromUser?this.applyUserMerge_(t,u.path,u.children,n,r,a):(Ia(u.source.fromServer,"Unknown source."),o=u.source.tagged||t.getServerCache().isFiltered(),this.applyServerMerge_(t,u.path,u.children,n,r,o,a))}else if(e.type===ph.ACK_USER_WRITE){var c=e;i=c.revert?this.revertUserWrite_(t,c.path,n,r,a):this.ackUserWrite_(t,c.path,c.affectedTree,n,r,a)}else{if(e.type!==ph.LISTEN_COMPLETE)throw Ca("Unknown operation type: "+e.type);i=this.listenComplete_(t,e.path,n,a)}var h=a.getChanges();return Gh.maybeAddValueEvent_(t,i,h),new Qh(i,h)},Gh.maybeAddValueEvent_=function(t,e,n){var r=e.getEventCache();if(r.isFullyInitialized()){var i=r.getNode().isLeafNode()||r.getNode().isEmpty(),o=t.getCompleteEventSnap();(0<n.length||!t.getEventCache().isFullyInitialized()||i&&!r.getNode().equals(o)||!r.getNode().getPriority().equals(o.getPriority()))&&n.push(xh.valueChange(e.getCompleteEventSnap()))}},Gh.prototype.generateEventCacheAfterServerEvent_=function(t,e,n,r,i){var o=t.getEventCache();if(null!=n.shadowingWrite(e))return t;var a=void 0,s=void 0;if(e.isEmpty())if(Ia(t.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),t.getServerCache().isFiltered()){var u=t.getCompleteServerSnap(),c=u instanceof Vc?u:Vc.EMPTY_NODE,h=n.calcCompleteEventChildren(c);a=this.filter_.updateFullNode(t.getEventCache().getNode(),h,i)}else{var l=n.calcCompleteEventCache(t.getCompleteServerSnap());a=this.filter_.updateFullNode(t.getEventCache().getNode(),l,i)}else{var f=e.getFront();if(".priority"==f){Ia(1==e.getLength(),"Can't have a priority with additional path components");var p=o.getNode();s=t.getServerCache().getNode();var d=n.calcEventCacheAfterServerOverwrite(e,p,s);a=null!=d?this.filter_.updatePriority(p,d):o.getNode()}else{var m=e.popFront(),y=void 0;if(o.isCompleteForChild(f)){s=t.getServerCache().getNode();var g=n.calcEventCacheAfterServerOverwrite(e,o.getNode(),s);y=null!=g?o.getNode().getImmediateChild(f).updateChild(m,g):o.getNode().getImmediateChild(f)}else y=n.calcCompleteChild(f,t.getServerCache());a=null!=y?this.filter_.updateChild(o.getNode(),f,y,m,r,i):o.getNode()}}return t.updateEventSnap(a,o.isFullyInitialized()||e.isEmpty(),this.filter_.filtersNodes())},Gh.prototype.applyServerOverwrite_=function(t,e,n,r,i,o,a){var s,u=t.getServerCache(),c=o?this.filter_:this.filter_.getIndexedFilter();if(e.isEmpty())s=c.updateFullNode(u.getNode(),n,null);else if(c.filtersNodes()&&!u.isFiltered()){var h=u.getNode().updateChild(e,n);s=c.updateFullNode(u.getNode(),h,null)}else{var l=e.getFront();if(!u.isCompleteForPath(e)&&1<e.getLength())return t;var f=e.popFront(),p=u.getNode().getImmediateChild(l).updateChild(f,n);s=".priority"==l?c.updatePriority(u.getNode(),p):c.updateChild(u.getNode(),l,p,f,jh,null)}var d=t.updateServerSnap(s,u.isFullyInitialized()||e.isEmpty(),c.filtersNodes()),m=new Wh(r,d,i);return this.generateEventCacheAfterServerEvent_(d,e,r,m,a)},Gh.prototype.applyUserOverwrite_=function(t,e,n,r,i,o){var a,s,u=t.getEventCache(),c=new Wh(r,t,i);if(e.isEmpty())s=this.filter_.updateFullNode(t.getEventCache().getNode(),n,o),a=t.updateEventSnap(s,!0,this.filter_.filtersNodes());else{var h=e.getFront();if(".priority"===h)s=this.filter_.updatePriority(t.getEventCache().getNode(),n),a=t.updateEventSnap(s,u.isFullyInitialized(),u.isFiltered());else{var l=e.popFront(),f=u.getNode().getImmediateChild(h),p=void 0;if(l.isEmpty())p=n;else{var d=c.getCompleteChild(h);p=null!=d?".priority"===l.getBack()&&d.getChild(l.parent()).isEmpty()?d:d.updateChild(l,n):Vc.EMPTY_NODE}if(f.equals(p))a=t;else{var m=this.filter_.updateChild(u.getNode(),h,p,l,c,o);a=t.updateEventSnap(m,u.isFullyInitialized(),this.filter_.filtersNodes())}}}return a},Gh.cacheHasChild_=function(t,e){return t.getEventCache().isCompleteForChild(e)},Gh.prototype.applyUserMerge_=function(r,i,t,o,a,s){var u=this,c=r;return t.foreach(function(t,e){var n=i.child(t);Gh.cacheHasChild_(r,n.getFront())&&(c=u.applyUserOverwrite_(c,n,e,o,a,s))}),t.foreach(function(t,e){var n=i.child(t);Gh.cacheHasChild_(r,n.getFront())||(c=u.applyUserOverwrite_(c,n,e,o,a,s))}),c},Gh.prototype.applyMerge_=function(n,t){return t.foreach(function(t,e){n=n.updateChild(t,e)}),n},Gh.prototype.applyServerMerge_=function(o,t,e,a,s,u,c){var h=this;if(o.getServerCache().getNode().isEmpty()&&!o.getServerCache().isFullyInitialized())return o;var n,l=o;n=t.isEmpty()?e:Eh.Empty.setTree(t,e);var f=o.getServerCache().getNode();return n.children.inorderTraversal(function(t,e){if(f.hasChild(t)){var n=o.getServerCache().getNode().getImmediateChild(t),r=h.applyMerge_(n,e);l=h.applyServerOverwrite_(l,new bu(t),r,a,s,u,c)}}),n.children.inorderTraversal(function(t,e){var n=!o.getServerCache().isCompleteForChild(t)&&null==e.value;if(!f.hasChild(t)&&!n){var r=o.getServerCache().getNode().getImmediateChild(t),i=h.applyMerge_(r,e);l=h.applyServerOverwrite_(l,new bu(t),i,a,s,u,c)}}),l},Gh.prototype.ackUserWrite_=function(t,r,e,n,i,o){if(null!=n.shadowingWrite(r))return t;var a=t.getServerCache().isFiltered(),s=t.getServerCache();if(null!=e.value){if(r.isEmpty()&&s.isFullyInitialized()||s.isCompleteForPath(r))return this.applyServerOverwrite_(t,r,s.getNode().getChild(r),n,i,a,o);if(r.isEmpty()){var u=Eh.Empty;return s.getNode().forEachChild(uc,function(t,e){u=u.set(new bu(t),e)}),this.applyServerMerge_(t,r,u,n,i,a,o)}return t}var c=Eh.Empty;return e.foreach(function(t,e){var n=r.child(t);s.isCompleteForPath(n)&&(c=c.set(t,s.getNode().getChild(n)))}),this.applyServerMerge_(t,r,c,n,i,a,o)},Gh.prototype.listenComplete_=function(t,e,n,r){var i=t.getServerCache(),o=t.updateServerSnap(i.getNode(),i.isFullyInitialized()||e.isEmpty(),i.isFiltered());return this.generateEventCacheAfterServerEvent_(o,e,n,jh,r)},Gh.prototype.revertUserWrite_=function(t,e,n,r,i){var o;if(null!=n.shadowingWrite(e))return t;var a=new Wh(n,t,r),s=t.getEventCache().getNode(),u=void 0;if(e.isEmpty()||".priority"===e.getFront()){var c=void 0;if(t.getServerCache().isFullyInitialized())c=n.calcCompleteEventCache(t.getCompleteServerSnap());else{var h=t.getServerCache().getNode();Ia(h instanceof Vc,"serverChildren would be complete if leaf node"),c=n.calcCompleteEventChildren(h)}c=c,u=this.filter_.updateFullNode(s,c,i)}else{var l=e.getFront(),f=n.calcCompleteChild(l,t.getServerCache());null==f&&t.getServerCache().isCompleteForChild(l)&&(f=s.getImmediateChild(l)),(u=null!=f?this.filter_.updateChild(s,l,f,e.popFront(),a,i):t.getEventCache().getNode().hasChild(l)?this.filter_.updateChild(s,l,Vc.EMPTY_NODE,e.popFront(),a,i):s).isEmpty()&&t.getServerCache().isFullyInitialized()&&(o=n.calcCompleteEventCache(t.getCompleteServerSnap())).isLeafNode()&&(u=this.filter_.updateFullNode(u,o,i))}return o=t.getServerCache().isFullyInitialized()||null!=n.shadowingWrite(bu.Empty),t.updateEventSnap(u,o,this.filter_.filtersNodes())},Gh);function Gh(t){this.filter_=t}var zh=(Yh.prototype.generateEventsForChanges=function(t,e,n){var r=this,i=[],o=[];return t.forEach(function(t){t.type===xh.CHILD_CHANGED&&r.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&o.push(xh.childMovedChange(t.childName,t.snapshotNode))}),this.generateEventsForType_(i,xh.CHILD_REMOVED,t,n,e),this.generateEventsForType_(i,xh.CHILD_ADDED,t,n,e),this.generateEventsForType_(i,xh.CHILD_MOVED,o,n,e),this.generateEventsForType_(i,xh.CHILD_CHANGED,t,n,e),this.generateEventsForType_(i,xh.VALUE,t,n,e),i},Yh.prototype.generateEventsForType_=function(r,e,t,i,o){var a=this,n=t.filter(function(t){return t.type===e});n.sort(this.compareChanges_.bind(this)),n.forEach(function(e){var n=a.materializeSingleChange_(e,o);i.forEach(function(t){t.respondsTo(e.type)&&r.push(t.createEvent(n,a.query_))})})},Yh.prototype.materializeSingleChange_=function(t,e){return"value"===t.type||"child_removed"===t.type||(t.prevName=e.getPredecessorChildName(t.childName,t.snapshotNode,this.index_)),t},Yh.prototype.compareChanges_=function(t,e){if(null==t.childName||null==e.childName)throw Ca("Should only compare child_ events.");var n=new Zu(t.childName,t.snapshotNode),r=new Zu(e.childName,e.snapshotNode);return this.index_.compare(n,r)},Yh);function Yh(t){this.query_=t,this.index_=this.query_.getQueryParams().getIndex()}var Xh,Jh=($h.prototype.getQuery=function(){return this.query_},$h.prototype.getServerCache=function(){return this.viewCache_.getServerCache().getNode()},$h.prototype.getCompleteServerCache=function(t){var e=this.viewCache_.getCompleteServerSnap();return e&&(this.query_.getQueryParams().loadsAllData()||!t.isEmpty()&&!e.getImmediateChild(t.getFront()).isEmpty())?e.getChild(t):null},$h.prototype.isEmpty=function(){return 0===this.eventRegistrations_.length},$h.prototype.addEventRegistration=function(t){this.eventRegistrations_.push(t)},$h.prototype.removeEventRegistration=function(t,n){var r=[];if(n){Ia(null==t,"A cancel should cancel all event registrations.");var i=this.query_.path;this.eventRegistrations_.forEach(function(t){n=n;var e=t.createCancelEvent(n,i);e&&r.push(e)})}if(t){for(var e=[],o=0;o<this.eventRegistrations_.length;++o){var a=this.eventRegistrations_[o];if(a.matches(t)){if(t.hasAnyCallback()){e=e.concat(this.eventRegistrations_.slice(o+1));break}}else e.push(a)}this.eventRegistrations_=e}else this.eventRegistrations_=[];return r},$h.prototype.applyOperation=function(t,e,n){t.type===ph.MERGE&&null!==t.source.queryId&&(Ia(this.viewCache_.getCompleteServerSnap(),"We should always have a full cache before handling merges"),Ia(this.viewCache_.getCompleteEventSnap(),"Missing event cache, even though we have a server cache"));var r=this.viewCache_,i=this.processor_.applyOperation(r,t,e,n);return this.processor_.assertIndexed(i.viewCache),Ia(i.viewCache.getServerCache().isFullyInitialized()||!r.getServerCache().isFullyInitialized(),"Once a server snap is complete, it should never go back"),this.viewCache_=i.viewCache,this.generateEventsForChanges_(i.changes,i.viewCache.getEventCache().getNode(),null)},$h.prototype.getInitialEvents=function(t){var e=this.viewCache_.getEventCache(),n=[];return e.getNode().isLeafNode()||e.getNode().forEachChild(vc,function(t,e){n.push(xh.childAddedChange(t,e))}),e.isFullyInitialized()&&n.push(xh.valueChange(e.getNode())),this.generateEventsForChanges_(n,e.getNode(),t)},$h.prototype.generateEventsForChanges_=function(t,e,n){var r=n?[n]:this.eventRegistrations_;return this.eventGenerator_.generateEventsForChanges(t,e,r)},$h);function $h(t,e){this.query_=t,this.eventRegistrations_=[];var n=this.query_.getQueryParams(),r=new Fh(n.getIndex()),i=n.getNodeFilter();this.processor_=new Hh(i);var o=e.getServerCache(),a=e.getEventCache(),s=r.updateFullNode(Vc.EMPTY_NODE,o.getNode(),null),u=i.updateFullNode(Vc.EMPTY_NODE,a.getNode(),null),c=new Rh(s,o.isFullyInitialized(),r.filtersNodes()),h=new Rh(u,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=new Ph(h,c),this.eventGenerator_=new zh(this.query_)}var Zh=(Object.defineProperty(tl,"__referenceConstructor",{get:function(){return Ia(Xh,"Reference.ts has not been loaded"),Xh},set:function(t){Ia(!Xh,"__referenceConstructor has already been defined"),Xh=t},enumerable:!0,configurable:!0}),tl.prototype.isEmpty=function(){return 0===this.views.size},tl.prototype.applyOperation=function(t,e,n){var r,i,o=t.source.queryId;if(null!==o){var a=this.views.get(o);return Ia(null!=a,"SyncTree gave us an op for an invalid query."),a.applyOperation(t,e,n)}var s=[];try{for(var u=va(this.views.values()),c=u.next();!c.done;c=u.next())a=c.value,s=s.concat(a.applyOperation(t,e,n))}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}return s},tl.prototype.addEventRegistration=function(t,e,n,r,i){var o=t.queryIdentifier(),a=this.views.get(o);if(!a){var s=n.calcCompleteEventCache(i?r:null),u=!1;u=!!s||(s=r instanceof Vc?n.calcCompleteEventChildren(r):Vc.EMPTY_NODE,!1);var c=new Ph(new Rh(s,u,!1),new Rh(r,i,!1));a=new Jh(t,c),this.views.set(o,a)}return a.addEventRegistration(e),a.getInitialEvents(e)},tl.prototype.removeEventRegistration=function(t,e,n){var r,i,o=t.queryIdentifier(),a=[],s=[],u=this.hasCompleteView();if("default"===o)try{for(var c=va(this.views.entries()),h=c.next();!h.done;h=c.next()){var l=ba(h.value,2),f=l[0],p=l[1];s=s.concat(p.removeEventRegistration(e,n)),p.isEmpty()&&(this.views.delete(f),p.getQuery().getQueryParams().loadsAllData()||a.push(p.getQuery()))}}catch(t){r={error:t}}finally{try{h&&!h.done&&(i=c.return)&&i.call(c)}finally{if(r)throw r.error}}else(p=this.views.get(o))&&(s=s.concat(p.removeEventRegistration(e,n)),p.isEmpty()&&(this.views.delete(o),p.getQuery().getQueryParams().loadsAllData()||a.push(p.getQuery())));return u&&!this.hasCompleteView()&&a.push(new tl.__referenceConstructor(t.repo,t.path)),{removed:a,events:s}},tl.prototype.getQueryViews=function(){var e,t,n=[];try{for(var r=va(this.views.values()),i=r.next();!i.done;i=r.next()){var o=i.value;o.getQuery().getQueryParams().loadsAllData()||n.push(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},tl.prototype.getCompleteServerCache=function(t){var e,n,r=null;try{for(var i=va(this.views.values()),o=i.next();!o.done;o=i.next()){var a=o.value;r=r||a.getCompleteServerCache(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r},tl.prototype.viewForQuery=function(t){if(t.getQueryParams().loadsAllData())return this.getCompleteView();var e=t.queryIdentifier();return this.views.get(e)},tl.prototype.viewExistsForQuery=function(t){return null!=this.viewForQuery(t)},tl.prototype.hasCompleteView=function(){return null!=this.getCompleteView()},tl.prototype.getCompleteView=function(){var e,t;try{for(var n=va(this.views.values()),r=n.next();!r.done;r=n.next()){var i=r.value;if(i.getQuery().getQueryParams().loadsAllData())return i}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return null},tl);function tl(){this.views=new Map}var el=(nl.prototype.addWrite=function(t,e){if(t.isEmpty())return new nl(new Eh(e));var n=this.writeTree_.findRootMostValueAndPath(t);if(null!=n){var r=n.path,i=n.value,o=bu.relativePath(r,t);return i=i.updateChild(o,e),new nl(this.writeTree_.set(r,i))}var a=new Eh(e);return new nl(this.writeTree_.setTree(t,a))},nl.prototype.addWrites=function(n,t){var r=this;return pu(t,function(t,e){r=r.addWrite(n.child(t),e)}),r},nl.prototype.removeWrite=function(t){return t.isEmpty()?nl.Empty:new nl(this.writeTree_.setTree(t,Eh.Empty))},nl.prototype.hasCompleteWrite=function(t){return null!=this.getCompleteNode(t)},nl.prototype.getCompleteNode=function(t){var e=this.writeTree_.findRootMostValueAndPath(t);return null!=e?this.writeTree_.get(e.path).getChild(bu.relativePath(e.path,t)):null},nl.prototype.getCompleteChildren=function(){var n=[],t=this.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(vc,function(t,e){n.push(new Zu(t,e))}):this.writeTree_.children.inorderTraversal(function(t,e){null!=e.value&&n.push(new Zu(t,e.value))}),n},nl.prototype.childCompoundWrite=function(t){if(t.isEmpty())return this;var e=this.getCompleteNode(t);return new nl(null!=e?new Eh(e):this.writeTree_.subtree(t))},nl.prototype.isEmpty=function(){return this.writeTree_.isEmpty()},nl.prototype.apply=function(t){return function n(r,t,i){if(null!=t.value)return i.updateChild(r,t.value);var o=null;return t.children.inorderTraversal(function(t,e){".priority"===t?(Ia(null!==e.value,"Priority writes must always be leaf nodes"),o=e.value):i=n(r.child(t),e,i)}),i.getChild(r).isEmpty()||null===o||(i=i.updateChild(r.child(".priority"),o)),i}(bu.Empty,this.writeTree_,t)},nl.Empty=new nl(new Eh(null)),nl);function nl(t){this.writeTree_=t}var rl=(il.prototype.childWrites=function(t){return new ol(t,this)},il.prototype.addOverwrite=function(t,e,n,r){Ia(n>this.lastWriteId_,"Stacking an older write on top of newer ones"),void 0===r&&(r=!0),this.allWrites_.push({path:t,snap:e,writeId:n,visible:r}),r&&(this.visibleWrites_=this.visibleWrites_.addWrite(t,e)),this.lastWriteId_=n},il.prototype.addMerge=function(t,e,n){Ia(n>this.lastWriteId_,"Stacking an older merge on top of newer ones"),this.allWrites_.push({path:t,children:e,writeId:n,visible:!0}),this.visibleWrites_=this.visibleWrites_.addWrites(t,e),this.lastWriteId_=n},il.prototype.getWrite=function(t){for(var e=0;e<this.allWrites_.length;e++){var n=this.allWrites_[e];if(n.writeId===t)return n}return null},il.prototype.removeWrite=function(e){var n=this,t=this.allWrites_.findIndex(function(t){return t.writeId===e});Ia(0<=t,"removeWrite called with nonexistent writeId.");var r=this.allWrites_[t];this.allWrites_.splice(t,1);for(var i=r.visible,o=!1,a=this.allWrites_.length-1;i&&0<=a;){var s=this.allWrites_[a];s.visible&&(t<=a&&this.recordContainsPath_(s,r.path)?i=!1:r.path.contains(s.path)&&(o=!0)),a--}return!!i&&(o?this.resetTree_():r.snap?this.visibleWrites_=this.visibleWrites_.removeWrite(r.path):pu(r.children,function(t){n.visibleWrites_=n.visibleWrites_.removeWrite(r.path.child(t))}),!0)},il.prototype.getCompleteWriteData=function(t){return this.visibleWrites_.getCompleteNode(t)},il.prototype.calcCompleteEventCache=function(e,t,n,r){if(n||r){var i=this.visibleWrites_.childCompoundWrite(e);if(!r&&i.isEmpty())return t;if(r||null!=t||i.hasCompleteWrite(bu.Empty)){var o=il.layerTree_(this.allWrites_,function(t){return(t.visible||r)&&(!n||!~n.indexOf(t.writeId))&&(t.path.contains(e)||e.contains(t.path))},e);return u=t||Vc.EMPTY_NODE,o.apply(u)}return null}var a=this.visibleWrites_.getCompleteNode(e);if(null!=a)return a;var s=this.visibleWrites_.childCompoundWrite(e);if(s.isEmpty())return t;if(null!=t||s.hasCompleteWrite(bu.Empty)){var u=t||Vc.EMPTY_NODE;return s.apply(u)}return null},il.prototype.calcCompleteEventChildren=function(t,e){var r=Vc.EMPTY_NODE,n=this.visibleWrites_.getCompleteNode(t);if(n)return n.isLeafNode()||n.forEachChild(vc,function(t,e){r=r.updateImmediateChild(t,e)}),r;if(e){var i=this.visibleWrites_.childCompoundWrite(t);return e.forEachChild(vc,function(t,e){var n=i.childCompoundWrite(new bu(t)).apply(e);r=r.updateImmediateChild(t,n)}),i.getCompleteChildren().forEach(function(t){r=r.updateImmediateChild(t.name,t.node)}),r}return this.visibleWrites_.childCompoundWrite(t).getCompleteChildren().forEach(function(t){r=r.updateImmediateChild(t.name,t.node)}),r},il.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n,r){Ia(n||r,"Either existingEventSnap or existingServerSnap must exist");var i=t.child(e);if(this.visibleWrites_.hasCompleteWrite(i))return null;var o=this.visibleWrites_.childCompoundWrite(i);return o.isEmpty()?r.getChild(e):o.apply(r.getChild(e))},il.prototype.calcCompleteChild=function(t,e,n){var r=t.child(e),i=this.visibleWrites_.getCompleteNode(r);return null!=i?i:n.isCompleteForChild(e)?this.visibleWrites_.childCompoundWrite(r).apply(n.getNode().getImmediateChild(e)):null},il.prototype.shadowingWrite=function(t){return this.visibleWrites_.getCompleteNode(t)},il.prototype.calcIndexedSlice=function(t,e,n,r,i,o){var a,s=this.visibleWrites_.childCompoundWrite(t),u=s.getCompleteNode(bu.Empty);if(null!=u)a=u;else{if(null==e)return[];a=s.apply(e)}if((a=a.withIndex(o)).isEmpty()||a.isLeafNode())return[];for(var c=[],h=o.getCompare(),l=i?a.getReverseIteratorFrom(n,o):a.getIteratorFrom(n,o),f=l.getNext();f&&c.length<r;)0!==h(f,n)&&c.push(f),f=l.getNext();return c},il.prototype.recordContainsPath_=function(t,e){if(t.snap)return t.path.contains(e);for(var n in t.children)if(t.children.hasOwnProperty(n)&&t.path.child(n).contains(e))return!0;return!1},il.prototype.resetTree_=function(){this.visibleWrites_=il.layerTree_(this.allWrites_,il.DefaultFilter_,bu.Empty),0<this.allWrites_.length?this.lastWriteId_=this.allWrites_[this.allWrites_.length-1].writeId:this.lastWriteId_=-1},il.DefaultFilter_=function(t){return t.visible},il.layerTree_=function(t,e,n){for(var r=el.Empty,i=0;i<t.length;++i){var o=t[i];if(e(o)){var a=o.path,s=void 0;if(o.snap)n.contains(a)?(s=bu.relativePath(n,a),r=r.addWrite(s,o.snap)):a.contains(n)&&(s=bu.relativePath(a,n),r=r.addWrite(bu.Empty,o.snap.getChild(s)));else{if(!o.children)throw Ca("WriteRecord should have .snap or .children");if(n.contains(a))s=bu.relativePath(n,a),r=r.addWrites(s,o.children);else if(a.contains(n))if((s=bu.relativePath(a,n)).isEmpty())r=r.addWrites(bu.Empty,o.children);else{var u=Ha(o.children,s.getFront());if(u){var c=u.getChild(s.popFront());r=r.addWrite(bu.Empty,c)}}}}}return r},il);function il(){this.visibleWrites_=el.Empty,this.allWrites_=[],this.lastWriteId_=-1}var ol=(al.prototype.calcCompleteEventCache=function(t,e,n){return this.writeTree_.calcCompleteEventCache(this.treePath_,t,e,n)},al.prototype.calcCompleteEventChildren=function(t){return this.writeTree_.calcCompleteEventChildren(this.treePath_,t)},al.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n){return this.writeTree_.calcEventCacheAfterServerOverwrite(this.treePath_,t,e,n)},al.prototype.shadowingWrite=function(t){return this.writeTree_.shadowingWrite(this.treePath_.child(t))},al.prototype.calcIndexedSlice=function(t,e,n,r,i){return this.writeTree_.calcIndexedSlice(this.treePath_,t,e,n,r,i)},al.prototype.calcCompleteChild=function(t,e){return this.writeTree_.calcCompleteChild(this.treePath_,t,e)},al.prototype.child=function(t){return new al(this.treePath_.child(t),this.writeTree_)},al);function al(t,e){this.treePath_=t,this.writeTree_=e}var sl=(ul.prototype.applyUserOverwrite=function(t,e,n,r){return this.pendingWriteTree_.addOverwrite(t,e,n,r),r?this.applyOperationToSyncPoints_(new Nh(vh.User,t,e)):[]},ul.prototype.applyUserMerge=function(t,e,n){this.pendingWriteTree_.addMerge(t,e,n);var r=Eh.fromObject(e);return this.applyOperationToSyncPoints_(new kh(vh.User,t,r))},ul.prototype.ackUserWrite=function(t,e){void 0===e&&(e=!1);var n=this.pendingWriteTree_.getWrite(t);if(this.pendingWriteTree_.removeWrite(t)){var r=Eh.Empty;return null!=n.snap?r=r.set(bu.Empty,!0):pu(n.children,function(t,e){r=r.set(new bu(t),e)}),this.applyOperationToSyncPoints_(new _h(n.path,r,e))}return[]},ul.prototype.applyServerOverwrite=function(t,e){return this.applyOperationToSyncPoints_(new Nh(vh.Server,t,e))},ul.prototype.applyServerMerge=function(t,e){var n=Eh.fromObject(e);return this.applyOperationToSyncPoints_(new kh(vh.Server,t,n))},ul.prototype.applyListenComplete=function(t){return this.applyOperationToSyncPoints_(new Ih(vh.Server,t))},ul.prototype.applyTaggedQueryOverwrite=function(t,e,n){var r=this.queryKeyForTag_(n);if(null==r)return[];var i=ul.parseQueryKey_(r),o=i.path,a=i.queryId,s=bu.relativePath(o,t),u=new Nh(vh.forServerTaggedQuery(a),s,e);return this.applyTaggedOperation_(o,u)},ul.prototype.applyTaggedQueryMerge=function(t,e,n){var r=this.queryKeyForTag_(n);if(r){var i=ul.parseQueryKey_(r),o=i.path,a=i.queryId,s=bu.relativePath(o,t),u=Eh.fromObject(e),c=new kh(vh.forServerTaggedQuery(a),s,u);return this.applyTaggedOperation_(o,c)}return[]},ul.prototype.applyTaggedListenComplete=function(t,e){var n=this.queryKeyForTag_(e);if(n){var r=ul.parseQueryKey_(n),i=r.path,o=r.queryId,a=bu.relativePath(i,t),s=new Ih(vh.forServerTaggedQuery(o),a);return this.applyTaggedOperation_(i,s)}return[]},ul.prototype.addEventRegistration=function(t,e){var r=t.path,i=null,o=!1;this.syncPointTree_.foreachOnPath(r,function(t,e){var n=bu.relativePath(t,r);i=i||e.getCompleteServerCache(n),o=o||e.hasCompleteView()});var n,a=this.syncPointTree_.get(r);a?(o=o||a.hasCompleteView(),i=i||a.getCompleteServerCache(bu.Empty)):(a=new Zh,this.syncPointTree_=this.syncPointTree_.set(r,a)),null!=i?n=!0:(n=!1,i=Vc.EMPTY_NODE,this.syncPointTree_.subtree(r).foreachChild(function(t,e){var n=e.getCompleteServerCache(bu.Empty);n&&(i=i.updateImmediateChild(t,n))}));var s=a.viewExistsForQuery(t);if(!s&&!t.getQueryParams().loadsAllData()){var u=ul.makeQueryKey_(t);Ia(!this.queryToTagMap.has(u),"View does not exist, but we have a tag");var c=ul.getNextQueryTag_();this.queryToTagMap.set(u,c),this.tagToQueryMap.set(c,u)}var h=this.pendingWriteTree_.childWrites(r),l=a.addEventRegistration(t,e,h,i,n);if(!s&&!o){var f=a.viewForQuery(t);l=l.concat(this.setupListener_(t,f))}return l},ul.prototype.removeEventRegistration=function(t,e,n){var r=this,i=t.path,o=this.syncPointTree_.get(i),a=[];if(o&&("default"===t.queryIdentifier()||o.viewExistsForQuery(t))){var s=o.removeEventRegistration(t,e,n);o.isEmpty()&&(this.syncPointTree_=this.syncPointTree_.remove(i));var u=s.removed;a=s.events;var c=-1!==u.findIndex(function(t){return t.getQueryParams().loadsAllData()}),h=this.syncPointTree_.findOnPath(i,function(t,e){return e.hasCompleteView()});if(c&&!h){var l=this.syncPointTree_.subtree(i);if(!l.isEmpty())for(var f=this.collectDistinctViewsForSubTree_(l),p=0;p<f.length;++p){var d=f[p],m=d.getQuery(),y=this.createListenerForView_(d);this.listenProvider_.startListening(ul.queryForListening_(m),this.tagForQuery_(m),y.hashFn,y.onComplete)}}!h&&0<u.length&&!n&&(c?this.listenProvider_.stopListening(ul.queryForListening_(t),null):u.forEach(function(t){var e=r.queryToTagMap.get(ul.makeQueryKey_(t));r.listenProvider_.stopListening(ul.queryForListening_(t),e)})),this.removeTags_(u)}return a},ul.prototype.calcCompleteEventCache=function(i,t){var e=this.pendingWriteTree_,n=this.syncPointTree_.findOnPath(i,function(t,e){var n=bu.relativePath(t,i),r=e.getCompleteServerCache(n);if(r)return r});return e.calcCompleteEventCache(i,n,t,!0)},ul.prototype.collectDistinctViewsForSubTree_=function(t){return t.fold(function(t,e,n){if(e&&e.hasCompleteView())return[e.getCompleteView()];var r=[];return e&&(r=e.getQueryViews()),pu(n,function(t,e){r=r.concat(e)}),r})},ul.prototype.removeTags_=function(t){for(var e=0;e<t.length;++e){var n=t[e];if(!n.getQueryParams().loadsAllData()){var r=ul.makeQueryKey_(n),i=this.queryToTagMap.get(r);this.queryToTagMap.delete(r),this.tagToQueryMap.delete(i)}}},ul.queryForListening_=function(t){return t.getQueryParams().loadsAllData()&&!t.getQueryParams().isDefault()?t.getRef():t},ul.prototype.setupListener_=function(t,e){var n=t.path,r=this.tagForQuery_(t),i=this.createListenerForView_(e),o=this.listenProvider_.startListening(ul.queryForListening_(t),r,i.hashFn,i.onComplete),a=this.syncPointTree_.subtree(n);if(r)Ia(!a.value.hasCompleteView(),"If we're adding a query, it shouldn't be shadowed");else for(var s=a.fold(function(t,e,n){if(!t.isEmpty()&&e&&e.hasCompleteView())return[e.getCompleteView().getQuery()];var r=[];return e&&(r=r.concat(e.getQueryViews().map(function(t){return t.getQuery()}))),pu(n,function(t,e){r=r.concat(e)}),r}),u=0;u<s.length;++u){var c=s[u];this.listenProvider_.stopListening(ul.queryForListening_(c),this.tagForQuery_(c))}return o},ul.prototype.createListenerForView_=function(t){var n=this,r=t.getQuery(),i=this.tagForQuery_(r);return{hashFn:function(){return(t.getServerCache()||Vc.EMPTY_NODE).hash()},onComplete:function(t){if("ok"===t)return i?n.applyTaggedListenComplete(r.path,i):n.applyListenComplete(r.path);var e=function(t,e){var n="Unknown Error";"too_big"===t?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"==t?n="Client doesn't have permission to access the desired data.":"unavailable"==t&&(n="The service is unavailable");var r=new Error(t+" at "+e.path.toString()+": "+n);return r.code=t.toUpperCase(),r}(t,r);return n.removeEventRegistration(r,null,e)}}},ul.makeQueryKey_=function(t){return t.path.toString()+"$"+t.queryIdentifier()},ul.parseQueryKey_=function(t){var e=t.indexOf("$");return Ia(-1!==e&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new bu(t.substr(0,e))}},ul.prototype.queryKeyForTag_=function(t){return this.tagToQueryMap.get(t)},ul.prototype.tagForQuery_=function(t){var e=ul.makeQueryKey_(t);return this.queryToTagMap.get(e)},ul.getNextQueryTag_=function(){return ul.nextQueryTag_++},ul.prototype.applyTaggedOperation_=function(t,e){var n=this.syncPointTree_.get(t);Ia(n,"Missing sync point for query tag that we're tracking");var r=this.pendingWriteTree_.childWrites(t);return n.applyOperation(e,r,null)},ul.prototype.applyOperationToSyncPoints_=function(t){return this.applyOperationHelper_(t,this.syncPointTree_,null,this.pendingWriteTree_.childWrites(bu.Empty))},ul.prototype.applyOperationHelper_=function(t,e,n,r){if(t.path.isEmpty())return this.applyOperationDescendantsHelper_(t,e,n,r);var i=e.get(bu.Empty);null==n&&null!=i&&(n=i.getCompleteServerCache(bu.Empty));var o=[],a=t.path.getFront(),s=t.operationForChild(a),u=e.children.get(a);if(u&&s){var c=n?n.getImmediateChild(a):null,h=r.child(a);o=o.concat(this.applyOperationHelper_(s,u,c,h))}return i&&(o=o.concat(i.applyOperation(t,r,n))),o},ul.prototype.applyOperationDescendantsHelper_=function(o,t,a,s){var u=this,e=t.get(bu.Empty);null==a&&null!=e&&(a=e.getCompleteServerCache(bu.Empty));var c=[];return t.children.inorderTraversal(function(t,e){var n=a?a.getImmediateChild(t):null,r=s.child(t),i=o.operationForChild(t);i&&(c=c.concat(u.applyOperationDescendantsHelper_(i,e,n,r)))}),e&&(c=c.concat(e.applyOperation(o,s,a))),c},ul.nextQueryTag_=1,ul);function ul(t){this.listenProvider_=t,this.syncPointTree_=Eh.Empty,this.pendingWriteTree_=new rl,this.tagToQueryMap=new Map,this.queryToTagMap=new Map}var cl=(hl.prototype.getNode=function(t){return this.rootNode_.getChild(t)},hl.prototype.updateSnapshot=function(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)},hl);function hl(){this.rootNode_=Vc.EMPTY_NODE}var ll=(pl.prototype.getToken=function(t){return this.auth_?this.auth_.getToken(t).catch(function(t){return t&&"auth/token-not-initialized"===t.code?(Hs("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(t)}):Promise.resolve(null)},pl.prototype.addTokenChangeListener=function(e){this.auth_?this.auth_.addAuthTokenListener(e):(setTimeout(function(){return e(null)},0),this.authProvider_.get().then(function(t){return t.addAuthTokenListener(e)}))},pl.prototype.removeTokenChangeListener=function(e){this.authProvider_.get().then(function(t){return t.removeAuthTokenListener(e)})},pl.prototype.notifyForInvalidToken=function(){var t='Provided authentication credentials for the app named "'+this.app_.name+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.app_.options?t+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.app_.options?t+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':t+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Xs(t)},pl);function pl(t,e){var n=this;this.app_=t,this.authProvider_=e,this.auth_=null,this.auth_=e.getImmediate({optional:!0}),this.auth_||e.get().then(function(t){return n.auth_=t})}var dl=(ml.prototype.incrementCounter=function(t,e){void 0===e&&(e=1),Qa(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e},ml.prototype.get=function(){return Aa(this.counters_)},ml);function ml(){this.counters_={}}var yl=(gl.getCollection=function(t){var e=t.toString();return this.collections_[e]||(this.collections_[e]=new dl),this.collections_[e]},gl.getOrCreateReporter=function(t,e){var n=t.toString();return this.reporters_[n]||(this.reporters_[n]=e()),this.reporters_[n]},gl.collections_={},gl.reporters_={},gl);function gl(){}var vl=(bl.prototype.get=function(){var t=this.collection_.get(),n=ma({},t);return this.last_&&pu(this.last_,function(t,e){n[t]=n[t]-e}),this.last_=t,n},bl);function bl(t){this.collection_=t,this.last_=null}var wl=(_l.prototype.includeStat=function(t){this.statsToReport_[t]=!0},_l.prototype.reportStats_=function(){var n=this,t=this.statsListener_.get(),r={},i=!1;pu(t,function(t,e){0<e&&Qa(n.statsToReport_,t)&&(r[t]=e,i=!0)}),i&&this.server_.reportStats(r),yu(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},_l);function _l(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new vl(t);var n=1e4+2e4*Math.random();yu(this.reportStats_.bind(this),Math.floor(n))}var Tl=(El.prototype.queueEvents=function(t){for(var e=null,n=0;n<t.length;n++){var r=t[n],i=r.getPath();null===e||i.equals(e.getPath())||(this.eventLists_.push(e),e=null),null===e&&(e=new Sl(i)),e.add(r)}e&&this.eventLists_.push(e)},El.prototype.raiseEventsAtPath=function(e,t){this.queueEvents(t),this.raiseQueuedEventsMatchingPredicate_(function(t){return t.equals(e)})},El.prototype.raiseEventsForChangedPath=function(e,t){this.queueEvents(t),this.raiseQueuedEventsMatchingPredicate_(function(t){return t.contains(e)||e.contains(t)})},El.prototype.raiseQueuedEventsMatchingPredicate_=function(t){this.recursionDepth_++;for(var e=!0,n=0;n<this.eventLists_.length;n++){var r=this.eventLists_[n];r&&(t(r.getPath())?(this.eventLists_[n].raise(),this.eventLists_[n]=null):e=!1)}e&&(this.eventLists_=[]),this.recursionDepth_--},El);function El(){this.eventLists_=[],this.recursionDepth_=0}var Sl=(Il.prototype.add=function(t){this.events_.push(t)},Il.prototype.raise=function(){for(var t=0;t<this.events_.length;t++){var e=this.events_[t];if(null!==e){this.events_[t]=null;var n=e.getEventRunner();su&&Hs("event: "+e.toString()),mu(n)}}},Il.prototype.getPath=function(){return this.path_},Il);function Il(t){this.path_=t,this.events_=[]}var Cl=(Nl.prototype.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Array.isArray(this.listeners_[t]))for(var r=wa(this.listeners_[t]),i=0;i<r.length;i++)r[i].callback.apply(r[i].context,e)},Nl.prototype.on=function(t,e,n){this.validateEventType_(t),this.listeners_[t]=this.listeners_[t]||[],this.listeners_[t].push({callback:e,context:n});var r=this.getInitialEvent(t);r&&e.apply(n,r)},Nl.prototype.off=function(t,e,n){this.validateEventType_(t);for(var r=this.listeners_[t]||[],i=0;i<r.length;i++)if(r[i].callback===e&&(!n||n===r[i].context))return void r.splice(i,1)},Nl.prototype.validateEventType_=function(e){Ia(this.allowedEvents_.find(function(t){return t===e}),"Unknown event: "+e)},Nl);function Nl(t){this.allowedEvents_=t,this.listeners_={},Ia(Array.isArray(t)&&0<t.length,"Requires a non-empty array")}var Al,kl=(da(Dl,Al=Cl),Dl.getInstance=function(){return new Dl},Dl.prototype.getInitialEvent=function(t){return Ia("visible"===t,"Unknown event type: "+t),[this.visible_]},Dl);function Dl(){var e,t,n=Al.call(this,["visible"])||this;return"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(t="visibilitychange",e="hidden"):void 0!==document.mozHidden?(t="mozvisibilitychange",e="mozHidden"):void 0!==document.msHidden?(t="msvisibilitychange",e="msHidden"):void 0!==document.webkitHidden&&(t="webkitvisibilitychange",e="webkitHidden")),n.visible_=!0,t&&document.addEventListener(t,function(){var t=!document[e];t!==n.visible_&&(n.visible_=t,n.trigger("visible",t))},!1),n}var Rl,Ol=(da(Pl,Rl=Cl),Pl.getInstance=function(){return new Pl},Pl.prototype.getInitialEvent=function(t){return Ia("online"===t,"Unknown event type: "+t),[this.online_]},Pl.prototype.currentlyOnline=function(){return this.online_},Pl);function Pl(){var t=Rl.call(this,["online"])||this;return t.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||Pa()||(window.addEventListener("online",function(){t.online_||(t.online_=!0,t.trigger("online",!0))},!1),window.addEventListener("offline",function(){t.online_&&(t.online_=!1,t.trigger("online",!1))},!1)),t}var Ml=(xl.prototype.closeAfter=function(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)},xl.prototype.handleResponse=function(t,e){var r=this;this.pendingResponses[t]=e;for(var n=function(){var e=i.pendingResponses[i.currentResponseNum];delete i.pendingResponses[i.currentResponseNum];for(var t=function(t){e[t]&&mu(function(){r.onMessage_(e[t])})},n=0;n<e.length;++n)t(n);if(i.currentResponseNum===i.closeAfterResponse)return i.onClose&&(i.onClose(),i.onClose=null),"break";i.currentResponseNum++},i=this;this.pendingResponses[this.currentResponseNum]&&"break"!==n(););},xl);function xl(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}var Ll=(Fl.prototype.open=function(t,e){var a=this;this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Ml(t),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout(function(){a.log_("Timed out trying to connect."),a.onClosed_(),a.connectTimeoutTimer_=null},Math.floor(3e4)),function(t){if("complete"===document.readyState)t();else{var e=!1,n=function(){document.body?e||(e=!0,t()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&n()}),window.attachEvent("onload",n))}}(function(){if(!a.isClosed_){a.scriptTagHolder=new Ul(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ba(t,5),r=n[0],i=n[1],o=n[2];if(n[3],n[4],a.incrementIncomingBytes_(t),a.scriptTagHolder)if(a.connectTimeoutTimer_&&(clearTimeout(a.connectTimeoutTimer_),a.connectTimeoutTimer_=null),a.everConnected_=!0,"start"==r)a.id=i,a.password=o;else{if("close"!==r)throw new Error("Unrecognized command received: "+r);i?(a.scriptTagHolder.sendNewPolls=!1,a.myPacketOrderer.closeAfter(i,function(){a.onClosed_()})):a.onClosed_()}},function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ba(t,2),r=n[0],i=n[1];a.incrementIncomingBytes_(t),a.myPacketOrderer.handleResponse(r,i)},function(){a.onClosed_()},a.urlFn);var t={start:"t"};t.ser=Math.floor(1e8*Math.random()),a.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=a.scriptTagHolder.uniqueCallbackIdentifier),t.v="5",a.transportSessionId&&(t.s=a.transportSessionId),a.lastSessionId&&(t.ls=a.lastSessionId),"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf(Eu)&&(t.r="f");var e=a.urlFn(t);a.log_("Connecting via long-poll to "+e),a.scriptTagHolder.addTag(e,function(){})}})},Fl.prototype.start=function(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)},Fl.forceAllow=function(){Fl.forceAllow_=!0},Fl.forceDisallow=function(){Fl.forceDisallow_=!0},Fl.isAvailable=function(){return!!Fl.forceAllow_||!(Fl.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI)},Fl.prototype.markConnectionHealthy=function(){},Fl.prototype.shutdown_=function(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)},Fl.prototype.onClosed_=function(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))},Fl.prototype.close=function(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())},Fl.prototype.send=function(t){var e=Wa(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);for(var n=function(t){var e=Ta(t);return Na.encodeByteArray(e,!0)}(e),r=tu(n,1840),i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++},Fl.prototype.addDisconnectPingFrame=function(t,e){this.myDisconnFrame=document.createElement("iframe");var n={dframe:"t"};n.id=t,n.pw=e,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)},Fl.prototype.incrementIncomingBytes_=function(t){var e=Wa(t).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)},Fl);function Fl(t,e,n,r){this.connId=t,this.repoInfo=e,this.transportSessionId=n,this.lastSessionId=r,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Gs(t),this.stats_=yl.getCollection(e),this.urlFn=function(t){return e.connectionURL(Iu,t)}}var Ul=(Vl.createIFrame_=function(){var e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||Hs("No IE domain setting required")}catch(t){var n=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&&(e.doc=e.document),e},Vl.prototype.close=function(){var t=this;this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.innerHTML="",setTimeout(function(){null!==t.myIFrame&&(document.body.removeChild(t.myIFrame),t.myIFrame=null)},Math.floor(0)));var e=this.onDisconnect;e&&(this.onDisconnect=null,e())},Vl.prototype.startLongPoll=function(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););},Vl.prototype.newRequest_=function(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(0<this.pendingSegs.length?2:1)){this.currentSerial++;var t={};t.id=this.myID,t.pw=this.myPW,t.ser=this.currentSerial;for(var e=this.urlFn(t),n="",r=0;0<this.pendingSegs.length&&this.pendingSegs[0].d.length+30+n.length<=1870;){var i=this.pendingSegs.shift();n=n+"&seg"+r+"="+i.seg+"&ts"+r+"="+i.ts+"&d"+r+"="+i.d,r++}return e+=n,this.addLongPollTag_(e,this.currentSerial),!0}return!1},Vl.prototype.enqueueSegment=function(t,e,n){this.pendingSegs.push({seg:t,ts:e,d:n}),this.alive&&this.newRequest_()},Vl.prototype.addLongPollTag_=function(t,e){var n=this;function r(){n.outstandingRequests.delete(e),n.newRequest_()}this.outstandingRequests.add(e);var i=setTimeout(r,Math.floor(25e3));this.addTag(t,function(){clearTimeout(i),r()})},Vl.prototype.addTag=function(t,n){var r=this;setTimeout(function(){try{if(!r.sendNewPolls)return;var e=r.myIFrame.doc.createElement("script");e.type="text/javascript",e.async=!0,e.src=t,e.onload=e.onreadystatechange=function(){var t=e.readyState;t&&"loaded"!==t&&"complete"!==t||(e.onload=e.onreadystatechange=null,e.parentNode&&e.parentNode.removeChild(e),n())},e.onerror=function(){Hs("Long-poll script failed to load: "+t),r.sendNewPolls=!1,r.close()},r.myIFrame.doc.body.appendChild(e)}catch(t){}},Math.floor(1))},Vl);function Vl(t,e,n,r){this.onDisconnect=n,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,this.uniqueCallbackIdentifier=ou(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=e,this.myIFrame=Vl.createIFrame_();var i="";this.myIFrame.src&&"javascript:"===this.myIFrame.src.substr(0,"javascript:".length)&&(i='<script>document.domain="'+document.domain+'";<\/script>');var o="<html><body>"+i+"</body></html>";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(o),this.myIFrame.doc.close()}catch(t){Hs("frame writing exception"),t.stack&&Hs(t.stack),Hs(t)}}var ql="";var Bl=null;"undefined"!=typeof MozWebSocket?Bl=MozWebSocket:"undefined"!=typeof WebSocket&&(Bl=WebSocket);var jl=(Wl.connectionURL_=function(t,e,n){var r={v:"5"};return"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf(Eu)&&(r.r="f"),e&&(r.s=e),n&&(r.ls=n),t.connectionURL(Su,r)},Wl.prototype.open=function(t,e){var n=this;this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,nu.set("previous_websocket_failure",!0);try{if(xa()){var r=Sa.NODE_ADMIN?"AdminNode":"Node",i={headers:{"User-Agent":"Firebase/5/"+ql+"/"+process.platform+"/"+r}},o=process.env,a=0==this.connURL.indexOf("wss://")?o.HTTPS_PROXY||o.https_proxy:o.HTTP_PROXY||o.http_proxy;a&&(i.proxy={origin:a}),this.mySock=new Bl(this.connURL,[],i)}else this.mySock=new Bl(this.connURL)}catch(t){this.log_("Error instantiating WebSocket.");var s=t.message||t.data;return s&&this.log_(s),void this.onClosed_()}this.mySock.onopen=function(){n.log_("Websocket connected."),n.everConnected_=!0},this.mySock.onclose=function(){n.log_("Websocket connection was disconnected."),n.mySock=null,n.onClosed_()},this.mySock.onmessage=function(t){n.handleIncomingFrame(t)},this.mySock.onerror=function(t){n.log_("WebSocket error.  Closing connection.");var e=t.message||t.data;e&&n.log_(e),n.onClosed_()}},Wl.prototype.start=function(){},Wl.forceDisallow=function(){Wl.forceDisallow_=!0},Wl.isAvailable=function(){var t=!1;if("undefined"!=typeof navigator&&navigator.userAgent){var e=navigator.userAgent.match(/Android ([0-9]{0,}\.[0-9]{0,})/);e&&1<e.length&&parseFloat(e[1])<4.4&&(t=!0)}return!t&&null!==Bl&&!Wl.forceDisallow_},Wl.previouslyFailed=function(){return nu.isInMemoryStorage||!0===nu.get("previous_websocket_failure")},Wl.prototype.markConnectionHealthy=function(){nu.remove("previous_websocket_failure")},Wl.prototype.appendFrame_=function(t){if(this.frames.push(t),this.frames.length==this.totalFrames){var e=this.frames.join("");this.frames=null;var n=ja(e);this.onMessage(n)}},Wl.prototype.handleNewFrameCount_=function(t){this.totalFrames=t,this.frames=[]},Wl.prototype.extractFrameCount_=function(t){if(Ia(null===this.frames,"We already have a frame buffer"),t.length<=6){var e=Number(t);if(!isNaN(e))return this.handleNewFrameCount_(e),null}return this.handleNewFrameCount_(1),t},Wl.prototype.handleIncomingFrame=function(t){if(null!==this.mySock){var e=t.data;if(this.bytesReceived+=e.length,this.stats_.incrementCounter("bytes_received",e.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(e);else{var n=this.extractFrameCount_(e);null!==n&&this.appendFrame_(n)}}},Wl.prototype.send=function(t){this.resetKeepAlive();var e=Wa(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);var n=tu(e,16384);1<n.length&&this.sendString_(String(n.length));for(var r=0;r<n.length;r++)this.sendString_(n[r])},Wl.prototype.shutdown_=function(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)},Wl.prototype.onClosed_=function(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))},Wl.prototype.close=function(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())},Wl.prototype.resetKeepAlive=function(){var t=this;clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(function(){t.mySock&&t.sendString_("0"),t.resetKeepAlive()},Math.floor(45e3))},Wl.prototype.sendString_=function(t){try{this.mySock.send(t)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}},Wl.responsesRequiredToBeHealthy=2,Wl.healthyTimeout=3e4,Wl);function Wl(t,e,n,r){this.connId=t,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Gs(this.connId),this.stats_=yl.getCollection(e),this.connURL=Wl.connectionURL_(e,n,r)}var Kl=(Object.defineProperty(Ql,"ALL_TRANSPORTS",{get:function(){return[Ll,jl]},enumerable:!0,configurable:!0}),Ql.prototype.initTransports_=function(t){var e,n,r=jl&&jl.isAvailable(),i=r&&!jl.previouslyFailed();if(t.webSocketOnly&&(r||Xs("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),i=!0),i)this.transports_=[jl];else{var o=this.transports_=[];try{for(var a=va(Ql.ALL_TRANSPORTS),s=a.next();!s.done;s=a.next()){var u=s.value;u&&u.isAvailable()&&o.push(u)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}}},Ql.prototype.initialTransport=function(){if(0<this.transports_.length)return this.transports_[0];throw new Error("No transports available")},Ql.prototype.upgradeTransport=function(){return 1<this.transports_.length?this.transports_[1]:null},Ql);function Ql(t){this.initTransports_(t)}var Hl=(Gl.prototype.start_=function(){var t=this,e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,void 0,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.conn_),r=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout(function(){t.conn_&&t.conn_.open(n,r)},Math.floor(0));var i=e.healthyTimeout||0;0<i&&(this.healthyTimeout_=yu(function(){t.healthyTimeout_=null,t.isHealthy_||(t.conn_&&102400<t.conn_.bytesReceived?(t.log_("Connection exceeded healthy timeout but has received "+t.conn_.bytesReceived+" bytes.  Marking connection healthy."),t.isHealthy_=!0,t.conn_.markConnectionHealthy()):t.conn_&&10240<t.conn_.bytesSent?t.log_("Connection exceeded healthy timeout but has sent "+t.conn_.bytesSent+" bytes.  Leaving connection alive."):(t.log_("Closing unhealthy connection after timeout."),t.close()))},Math.floor(i)))},Gl.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},Gl.prototype.disconnReceiver_=function(e){var n=this;return function(t){e===n.conn_?n.onConnectionLost_(t):e===n.secondaryConn_?(n.log_("Secondary connection lost."),n.onSecondaryConnectionLost_()):n.log_("closing an old connection")}},Gl.prototype.connReceiver_=function(e){var n=this;return function(t){2!=n.state_&&(e===n.rx_?n.onPrimaryMessageReceived_(t):e===n.secondaryConn_?n.onSecondaryMessageReceived_(t):n.log_("message on old connection"))}},Gl.prototype.sendRequest=function(t){var e={t:"d",d:t};this.sendData_(e)},Gl.prototype.tryCleanupConnection=function(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)},Gl.prototype.onSecondaryControl_=function(t){if("t"in t){var e=t.t;"a"===e?this.upgradeIfSecondaryHealthy_():"r"===e?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===e&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}},Gl.prototype.onSecondaryMessageReceived_=function(t){var e=Zs("t",t),n=Zs("d",t);if("c"==e)this.onSecondaryControl_(n);else{if("d"!=e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(n)}},Gl.prototype.upgradeIfSecondaryHealthy_=function(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))},Gl.prototype.proceedWithUpgrade_=function(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()},Gl.prototype.onPrimaryMessageReceived_=function(t){var e=Zs("t",t),n=Zs("d",t);"c"==e?this.onControl_(n):"d"==e&&this.onDataMessage_(n)},Gl.prototype.onDataMessage_=function(t){this.onPrimaryResponse_(),this.onMessage_(t)},Gl.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},Gl.prototype.onControl_=function(t){var e=Zs("t",t);if("d"in t){var n=t.d;if("h"===e)this.onHandshake_(n);else if("n"===e){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(var r=0;r<this.pendingDataMessages.length;++r)this.onDataMessage_(this.pendingDataMessages[r]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===e?this.onConnectionShutdown_(n):"r"===e?this.onReset_(n):"e"===e?zs("Server Error: "+n):"o"===e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):zs("Unknown control packet command: "+e)}},Gl.prototype.onHandshake_=function(t){var e=t.ts,n=t.v,r=t.h;this.sessionId=t.s,this.repoInfo_.updateHost(r),0==this.state_&&(this.conn_.start(),this.onConnectionEstablished_(this.conn_,e),"5"!==n&&Xs("Protocol version mismatch detected"),this.tryStartUpgrade_())},Gl.prototype.tryStartUpgrade_=function(){var t=this.transportManager_.upgradeTransport();t&&this.startUpgrade_(t)},Gl.prototype.startUpgrade_=function(t){var e=this;this.secondaryConn_=new t(this.nextTransportId_(),this.repoInfo_,this.sessionId),this.secondaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;var n=this.connReceiver_(this.secondaryConn_),r=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(n,r),yu(function(){e.secondaryConn_&&(e.log_("Timed out trying to upgrade."),e.secondaryConn_.close())},Math.floor(6e4))},Gl.prototype.onReset_=function(t){this.log_("Reset packet received.  New host: "+t),this.repoInfo_.updateHost(t),1===this.state_?this.close():(this.closeConnections_(),this.start_())},Gl.prototype.onConnectionEstablished_=function(t,e){var n=this;this.log_("Realtime connection established."),this.conn_=t,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):yu(function(){n.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))},Gl.prototype.sendPingOnPrimaryIfNecessary_=function(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))},Gl.prototype.onSecondaryConnectionLost_=function(){var t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()},Gl.prototype.onConnectionLost_=function(t){this.conn_=null,t||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(nu.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()},Gl.prototype.onConnectionShutdown_=function(t){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(t),this.onKill_=null),this.onDisconnect_=null,this.close()},Gl.prototype.sendData_=function(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)},Gl.prototype.close=function(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))},Gl.prototype.closeConnections_=function(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)},Gl);function Gl(t,e,n,r,i,o,a){this.id=t,this.repoInfo_=e,this.onMessage_=n,this.onReady_=r,this.onDisconnect_=i,this.onKill_=o,this.lastSessionId=a,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Gs("c:"+this.id+":"),this.transportManager_=new Kl(e),this.log_("Connection created"),this.start_()}var zl=(Yl.prototype.put=function(t,e,n,r){},Yl.prototype.merge=function(t,e,n,r){},Yl.prototype.refreshAuthToken=function(t){},Yl.prototype.onDisconnectPut=function(t,e,n){},Yl.prototype.onDisconnectMerge=function(t,e,n){},Yl.prototype.onDisconnectCancel=function(t,e){},Yl.prototype.reportStats=function(t){},Yl);function Yl(){}var Xl,Jl=(da($l,Xl=zl),$l.prototype.sendRequest=function(t,e,n){var r=++this.requestNumber_,i={r:r,a:t,b:e};this.log_(Wa(i)),Ia(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&&(this.requestCBHash_[r]=n)},$l.prototype.listen=function(t,e,n,r){var i=t.queryIdentifier(),o=t.path.toString();this.log_("Listen called for "+o+" "+i),this.listens.has(o)||this.listens.set(o,new Map),Ia(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"listen() called for non-default but complete query"),Ia(!this.listens.get(o).has(i),"listen() called twice for same path/queryId.");var a={onComplete:r,hashFn:e,query:t,tag:n};this.listens.get(o).set(i,a),this.connected_&&this.sendListen_(a)},$l.prototype.sendListen_=function(r){var i=this,o=r.query,a=o.path.toString(),s=o.queryIdentifier();this.log_("Listen on "+a+" for "+s);var t={p:a};r.tag&&(t.q=o.queryObject(),t.t=r.tag),t.h=r.hashFn(),this.sendRequest("q",t,function(t){var e=t.d,n=t.s;$l.warnOnListenWarnings_(e,o),(i.listens.get(a)&&i.listens.get(a).get(s))===r&&(i.log_("listen response",t),"ok"!==n&&i.removeListen_(a,s),r.onComplete&&r.onComplete(n,e))})},$l.warnOnListenWarnings_=function(t,e){if(t&&"object"==typeof t&&Qa(t,"w")){var n=Ha(t,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var r='".indexOn": "'+e.getQueryParams().getIndex().toString()+'"',i=e.path.toString();Xs("Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding "+r+" at "+i+" to your security rules for better performance.")}}},$l.prototype.refreshAuthToken=function(t){this.authToken_=t,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},function(){}),this.reduceReconnectDelayIfAdminCredential_(t)},$l.prototype.reduceReconnectDelayIfAdminCredential_=function(t){(t&&40===t.length||function(t){var e=Ka(t).claims;return"object"==typeof e&&!0===e.admin}(t))&&(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)},$l.prototype.tryAuth=function(){var r=this;if(this.connected_&&this.authToken_){var i=this.authToken_,t=function(t){var e=Ka(t).claims;return!!e&&"object"==typeof e&&e.hasOwnProperty("iat")}(i)?"auth":"gauth",e={cred:i};null===this.authOverride_?e.noauth=!0:"object"==typeof this.authOverride_&&(e.authvar=this.authOverride_),this.sendRequest(t,e,function(t){var e=t.s,n=t.d||"error";r.authToken_===i&&("ok"===e?r.invalidAuthTokenCount_=0:r.onAuthRevoked_(e,n))})}},$l.prototype.unlisten=function(t,e){var n=t.path.toString(),r=t.queryIdentifier();this.log_("Unlisten called for "+n+" "+r),Ia(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,r)&&this.connected_&&this.sendUnlisten_(n,r,t.queryObject(),e)},$l.prototype.sendUnlisten_=function(t,e,n,r){this.log_("Unlisten on "+t+" for "+e);var i={p:t};r&&(i.q=n,i.t=r),this.sendRequest("n",i)},$l.prototype.onDisconnectPut=function(t,e,n){this.connected_?this.sendOnDisconnect_("o",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"o",data:e,onComplete:n})},$l.prototype.onDisconnectMerge=function(t,e,n){this.connected_?this.sendOnDisconnect_("om",t,e,n):this.onDisconnectRequestQueue_.push({pathString:t,action:"om",data:e,onComplete:n})},$l.prototype.onDisconnectCancel=function(t,e){this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})},$l.prototype.sendOnDisconnect_=function(t,e,n,r){var i={p:e,d:n};this.log_("onDisconnect "+t,i),this.sendRequest(t,i,function(t){r&&setTimeout(function(){r(t.s,t.d)},Math.floor(0))})},$l.prototype.put=function(t,e,n,r){this.putInternal("p",t,e,n,r)},$l.prototype.merge=function(t,e,n,r){this.putInternal("m",t,e,n,r)},$l.prototype.putInternal=function(t,e,n,r,i){var o={p:e,d:n};void 0!==i&&(o.h=i),this.outstandingPuts_.push({action:t,request:o,onComplete:r}),this.outstandingPutCount_++;var a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+e)},$l.prototype.sendPut_=function(e){var n=this,r=this.outstandingPuts_[e].action,t=this.outstandingPuts_[e].request,i=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(r,t,function(t){n.log_(r+" response",t),delete n.outstandingPuts_[e],n.outstandingPutCount_--,0===n.outstandingPutCount_&&(n.outstandingPuts_=[]),i&&i(t.s,t.d)})},$l.prototype.reportStats=function(t){var n=this;if(this.connected_){var e={c:t};this.log_("reportStats",e),this.sendRequest("s",e,function(t){if("ok"!==t.s){var e=t.d;n.log_("reportStats","Error sending stats: "+e)}})}},$l.prototype.onDataMessage_=function(t){if("r"in t){this.log_("from server: "+Wa(t));var e=t.r,n=this.requestCBHash_[e];n&&(delete this.requestCBHash_[e],n(t.b))}else{if("error"in t)throw"A server-side error has occurred: "+t.error;"a"in t&&this.onDataPush_(t.a,t.b)}},$l.prototype.onDataPush_=function(t,e){this.log_("handleServerMessage",t,e),"d"===t?this.onDataUpdate_(e.p,e.d,!1,e.t):"m"===t?this.onDataUpdate_(e.p,e.d,!0,e.t):"c"===t?this.onListenRevoked_(e.p,e.q):"ac"===t?this.onAuthRevoked_(e.s,e.d):"sd"===t?this.onSecurityDebugPacket_(e):zs("Unrecognized action received from server: "+Wa(t)+"\nAre you using the latest client?")},$l.prototype.onReady_=function(t,e){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(t),this.lastSessionId=e,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)},$l.prototype.scheduleConnect_=function(t){var e=this;Ia(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout(function(){e.establishConnectionTimer_=null,e.establishConnection_()},Math.floor(t))},$l.prototype.onVisible_=function(t){t&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)),this.visible_=t},$l.prototype.onOnline_=function(t){t?(this.log_("Browser went online."),this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&&this.realtime_.close())},$l.prototype.onRealtimeDisconnect_=function(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&(3e4<(new Date).getTime()-this.lastConnectionEstablishedTime_&&(this.reconnectDelay_=1e3),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());var t=(new Date).getTime()-this.lastConnectionAttemptTime_,e=Math.max(0,this.reconnectDelay_-t);e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)},$l.prototype.establishConnection_=function(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;var e=this.onDataMessage_.bind(this),n=this.onReady_.bind(this),r=this.onRealtimeDisconnect_.bind(this),i=this.id+":"+$l.nextConnectionId_++,o=this,a=this.lastSessionId,s=!1,u=null,c=function(){u?u.close():(s=!0,r())};this.realtime_={close:c,sendRequest:function(t){Ia(u,"sendRequest call when we're not connected not allowed."),u.sendRequest(t)}};var t=this.forceTokenRefresh_;this.forceTokenRefresh_=!1,this.authTokenProvider_.getToken(t).then(function(t){s?Hs("getToken() completed but was canceled"):(Hs("getToken() completed. Creating connection."),o.authToken_=t&&t.accessToken,u=new Hl(i,o.repoInfo_,e,n,r,function(t){Xs(t+" ("+o.repoInfo_.toString()+")"),o.interrupt("server_kill")},a))}).then(null,function(t){o.log_("Failed to get token: "+t),s||c()})}},$l.prototype.interrupt=function(t){Hs("Interrupting connection for reason: "+t),this.interruptReasons_[t]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())},$l.prototype.resume=function(t){Hs("Resuming connection for reason: "+t),delete this.interruptReasons_[t],Ga(this.interruptReasons_)&&(this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0))},$l.prototype.handleTimestamp_=function(t){var e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})},$l.prototype.cancelSentTransactions_=function(){for(var t=0;t<this.outstandingPuts_.length;t++){var e=this.outstandingPuts_[t];e&&"h"in e.request&&e.queued&&(e.onComplete&&e.onComplete("disconnect"),delete this.outstandingPuts_[t],this.outstandingPutCount_--)}0===this.outstandingPutCount_&&(this.outstandingPuts_=[])},$l.prototype.onListenRevoked_=function(t,e){var n;n=e?e.map(function(t){return fu(t)}).join("$"):"default";var r=this.removeListen_(t,n);r&&r.onComplete&&r.onComplete("permission_denied")},$l.prototype.removeListen_=function(t,e){var n,r=new bu(t).toString();if(this.listens.has(r)){var i=this.listens.get(r);n=i.get(e),i.delete(e),0===i.size&&this.listens.delete(r)}else n=void 0;return n},$l.prototype.onAuthRevoked_=function(t,e){Hs("Auth token revoked: "+t+"/"+e),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAuthTokenCount_++,3<=this.invalidAuthTokenCount_&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))},$l.prototype.onSecurityDebugPacket_=function(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))},$l.prototype.restoreState_=function(){var e,t,n,r;this.tryAuth();try{for(var i=va(this.listens.values()),o=i.next();!o.done;o=i.next()){var a=o.value;try{for(var s=(n=void 0,va(a.values())),u=s.next();!u.done;u=s.next()){var c=u.value;this.sendListen_(c)}}catch(t){n={error:t}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}for(var h=0;h<this.outstandingPuts_.length;h++)this.outstandingPuts_[h]&&this.sendPut_(h);for(;this.onDisconnectRequestQueue_.length;){var l=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(l.action,l.pathString,l.data,l.onComplete)}},$l.prototype.sendConnectStats_=function(){var t={};t["sdk.js."+ql.replace(/\./g,"-")]=1,Pa()?t["framework.cordova"]=1:Ma()&&(t["framework.reactnative"]=1),this.reportStats(t)},$l.prototype.shouldReconnect_=function(){var t=Ol.getInstance().currentlyOnline();return Ga(this.interruptReasons_)&&t},$l.nextPersistentConnectionId_=0,$l.nextConnectionId_=0,$l);function $l(t,e,n,r,i,o){var a=Xl.call(this)||this;if(a.repoInfo_=t,a.onDataUpdate_=e,a.onConnectStatus_=n,a.onServerInfoUpdate_=r,a.authTokenProvider_=i,a.authOverride_=o,a.id=$l.nextPersistentConnectionId_++,a.log_=Gs("p:"+a.id+":"),a.interruptReasons_={},a.listens=new Map,a.outstandingPuts_=[],a.outstandingPutCount_=0,a.onDisconnectRequestQueue_=[],a.connected_=!1,a.reconnectDelay_=1e3,a.maxReconnectDelay_=3e5,a.securityDebugCallback_=null,a.lastSessionId=null,a.establishConnectionTimer_=null,a.visible_=!1,a.requestCBHash_={},a.requestNumber_=0,a.realtime_=null,a.authToken_=null,a.forceTokenRefresh_=!1,a.invalidAuthTokenCount_=0,a.firstConnection_=!0,a.lastConnectionAttemptTime_=null,a.lastConnectionEstablishedTime_=null,o&&!xa())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return a.scheduleConnect_(0),kl.getInstance().on("visible",a.onVisible_,a),-1===t.host.indexOf("fblocal")&&Ol.getInstance().on("online",a.onOnline_,a),a}var Zl,tf=(da(ef,Zl=zl),ef.prototype.reportStats=function(t){throw new Error("Method not implemented.")},ef.getListenId_=function(t,e){return void 0!==e?"tag$"+e:(Ia(t.getQueryParams().isDefault(),"should have a tag if it's not a default query."),t.path.toString())},ef.prototype.listen=function(t,e,r,i){var o=this,a=t.path.toString();this.log_("Listen called for "+a+" "+t.queryIdentifier());var s=ef.getListenId_(t,r),u={};this.listens_[s]=u;var n=t.getQueryParams().toRestQueryStringParameters();this.restRequest_(a+".json",n,function(t,e){var n=e;404===t&&(t=n=null),null===t&&o.onDataUpdate_(a,n,!1,r),Ha(o.listens_,s)===u&&i(t?401==t?"permission_denied":"rest_error:"+t:"ok",null)})},ef.prototype.unlisten=function(t,e){var n=ef.getListenId_(t,e);delete this.listens_[n]},ef.prototype.refreshAuthToken=function(t){},ef.prototype.restRequest_=function(i,o,a){var s=this;void 0===o&&(o={}),o.format="export",this.authTokenProvider_.getToken(!1).then(function(t){var e=t&&t.accessToken;e&&(o.auth=e);var n=(s.repoInfo_.secure?"https://":"http://")+s.repoInfo_.host+i+"?ns="+s.repoInfo_.namespace+function(t){for(var n=[],e=function(e,t){Array.isArray(t)?t.forEach(function(t){n.push(encodeURIComponent(e)+"="+encodeURIComponent(t))}):n.push(encodeURIComponent(e)+"="+encodeURIComponent(t))},r=0,i=Object.entries(t);r<i.length;r++){var o=i[r];e(o[0],o[1])}return n.length?"&"+n.join("&"):""}(o);s.log_("Sending REST request for "+n);var r=new XMLHttpRequest;r.onreadystatechange=function(){if(a&&4===r.readyState){s.log_("REST Response for "+n+" received. status:",r.status,"response:",r.responseText);var t=null;if(200<=r.status&&r.status<300){try{t=ja(r.responseText)}catch(t){Xs("Failed to parse JSON response for "+n+": "+r.responseText)}a(null,t)}else 401!==r.status&&404!==r.status&&Xs("Got unsuccessful REST response for "+n+" Status: "+r.status),a(r.status);a=null}},r.open("GET",n,!0),r.send()})},ef);function ef(t,e,n){var r=Zl.call(this)||this;return r.repoInfo_=t,r.onDataUpdate_=e,r.authTokenProvider_=n,r.log_=Gs("p:rest:"),r.listens_={},r}var nf="repo_interrupt",rf=(of.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},of.prototype.name=function(){return this.repoInfo_.namespace},of.prototype.serverTime=function(){var t=this.infoData_.getNode(new bu(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t},of.prototype.generateServerValues=function(){return function(t){return(t=t||{}).timestamp=t.timestamp||(new Date).getTime(),t}({timestamp:this.serverTime()})},of.prototype.onDataUpdate_=function(t,e,n,r){this.dataUpdateCount++;var i=new bu(t);e=this.interceptServerDataCallback_?this.interceptServerDataCallback_(t,e):e;var o=[];if(r)if(n){var a=za(e,function(t){return Qc(t)});o=this.serverSyncTree_.applyTaggedQueryMerge(i,a,r)}else{var s=Qc(e);o=this.serverSyncTree_.applyTaggedQueryOverwrite(i,s,r)}else if(n){var u=za(e,function(t){return Qc(t)});o=this.serverSyncTree_.applyServerMerge(i,u)}else{var c=Qc(e);o=this.serverSyncTree_.applyServerOverwrite(i,c)}var h=i;0<o.length&&(h=this.rerunTransactions_(i)),this.eventQueue_.raiseEventsForChangedPath(h,o)},of.prototype.interceptServerData_=function(t){this.interceptServerDataCallback_=t},of.prototype.onConnectStatus_=function(t){this.updateInfo_("connected",t),!1===t&&this.runOnDisconnectEvents_()},of.prototype.onServerInfoUpdate_=function(t){var n=this;pu(t,function(t,e){n.updateInfo_(t,e)})},of.prototype.updateInfo_=function(t,e){var n=new bu("/.info/"+t),r=Qc(e);this.infoData_.updateSnapshot(n,r);var i=this.infoSyncTree_.applyServerOverwrite(n,r);this.eventQueue_.raiseEventsForChangedPath(n,i)},of.prototype.getNextWriteId_=function(){return this.nextWriteId_++},of.prototype.setWithPriority=function(i,t,e,o){var a=this;this.log_("set",{path:i.toString(),value:t,priority:e});var n=this.generateServerValues(),r=Qc(t,e),s=this.serverSyncTree_.calcCompleteEventCache(i),u=gh(r,s,n),c=this.getNextWriteId_(),h=this.serverSyncTree_.applyUserOverwrite(i,u,c,!0);this.eventQueue_.queueEvents(h),this.server_.put(i.toString(),r.val(!0),function(t,e){var n="ok"===t;n||Xs("set at "+i+" failed: "+t);var r=a.serverSyncTree_.ackUserWrite(c,!n);a.eventQueue_.raiseEventsForChangedPath(i,r),a.callOnCompleteCallback(o,t,e)});var l=this.abortTransactions_(i);this.rerunTransactions_(l),this.eventQueue_.raiseEventsForChangedPath(l,[])},of.prototype.update=function(o,t,a){var s=this;this.log_("update",{path:o.toString(),value:t});var r=!0,i=this.generateServerValues(),u={};if(pu(t,function(t,e){r=!1;var n=Qc(e);u[t]=gh(n,s.serverSyncTree_.calcCompleteEventCache(o),i)}),r)Hs("update() called with empty data.  Don't do anything."),this.callOnCompleteCallback(a,"ok");else{var c=this.getNextWriteId_(),e=this.serverSyncTree_.applyUserMerge(o,u,c);this.eventQueue_.queueEvents(e),this.server_.merge(o.toString(),t,function(t,e){var n="ok"===t;n||Xs("update at "+o+" failed: "+t);var r=s.serverSyncTree_.ackUserWrite(c,!n),i=0<r.length?s.rerunTransactions_(o):o;s.eventQueue_.raiseEventsForChangedPath(i,r),s.callOnCompleteCallback(a,t,e)}),pu(t,function(t){var e=s.abortTransactions_(o.child(t));s.rerunTransactions_(e)}),this.eventQueue_.raiseEventsForChangedPath(o,[])}},of.prototype.runOnDisconnectEvents_=function(){var r=this;this.log_("onDisconnectEvents");var t=this.generateServerValues(),e=function(t,r,i){var o=new hh;return t.forEachTree(new bu(""),function(t,e){var n=r.calcCompleteEventCache(t);Ia(null!=n,"Expected ChildrenNode.EMPTY_NODE for nulls"),o.remember(t,gh(e,n,i))}),o}(this.onDisconnect_,this.serverSyncTree_,t),i=[];e.forEachTree(bu.Empty,function(t,e){i=i.concat(r.serverSyncTree_.applyServerOverwrite(t,e));var n=r.abortTransactions_(t);r.rerunTransactions_(n)}),this.onDisconnect_=new hh,this.eventQueue_.raiseEventsForChangedPath(bu.Empty,i)},of.prototype.onDisconnectCancel=function(n,r){var i=this;this.server_.onDisconnectCancel(n.toString(),function(t,e){"ok"===t&&i.onDisconnect_.forget(n),i.callOnCompleteCallback(r,t,e)})},of.prototype.onDisconnectSet=function(n,t,r){var i=this,o=Qc(t);this.server_.onDisconnectPut(n.toString(),o.val(!0),function(t,e){"ok"===t&&i.onDisconnect_.remember(n,o),i.callOnCompleteCallback(r,t,e)})},of.prototype.onDisconnectSetWithPriority=function(n,t,e,r){var i=this,o=Qc(t,e);this.server_.onDisconnectPut(n.toString(),o.val(!0),function(t,e){"ok"===t&&i.onDisconnect_.remember(n,o),i.callOnCompleteCallback(r,t,e)})},of.prototype.onDisconnectUpdate=function(r,n,i){var o=this;if(Ga(n))return Hs("onDisconnect().update() called with empty data.  Don't do anything."),void this.callOnCompleteCallback(i,"ok");this.server_.onDisconnectMerge(r.toString(),n,function(t,e){"ok"===t&&pu(n,function(t,e){var n=Qc(e);o.onDisconnect_.remember(r.child(t),n)}),o.callOnCompleteCallback(i,t,e)})},of.prototype.addEventCallbackForQuery=function(t,e){var n;n=".info"===t.path.getFront()?this.infoSyncTree_.addEventRegistration(t,e):this.serverSyncTree_.addEventRegistration(t,e),this.eventQueue_.raiseEventsAtPath(t.path,n)},of.prototype.removeEventCallbackForQuery=function(t,e){var n;n=".info"===t.path.getFront()?this.infoSyncTree_.removeEventRegistration(t,e):this.serverSyncTree_.removeEventRegistration(t,e),this.eventQueue_.raiseEventsAtPath(t.path,n)},of.prototype.interrupt=function(){this.persistentConnection_&&this.persistentConnection_.interrupt(nf)},of.prototype.resume=function(){this.persistentConnection_&&this.persistentConnection_.resume(nf)},of.prototype.stats=function(t){if(void 0===t&&(t=!1),"undefined"!=typeof console){var e;e=t?(this.statsListener_||(this.statsListener_=new vl(this.stats_)),this.statsListener_.get()):this.stats_.get();var i=Object.keys(e).reduce(function(t,e){return Math.max(e.length,t)},0);pu(e,function(t,e){for(var n=t,r=t.length;r<i+2;r++)n+=" ";console.log(n+e)})}},of.prototype.statsIncrementCounter=function(t){this.stats_.incrementCounter(t),this.statsReporter_.includeStat(t)},of.prototype.log_=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="";this.persistentConnection_&&(n=this.persistentConnection_.id+":"),Hs.apply(void 0,wa([n],t))},of.prototype.callOnCompleteCallback=function(r,i,o){r&&mu(function(){if("ok"==i)r(null);else{var t=(i||"error").toUpperCase(),e=t;o&&(e+=": "+o);var n=new Error(e);n.code=t,r(n)}})},Object.defineProperty(of.prototype,"database",{get:function(){return this.__database||(this.__database=new Sf(this))},enumerable:!0,configurable:!0}),of);function of(t,e,n,r){var a=this;this.repoInfo_=t,this.app=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Tl,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new hh,this.persistentConnection_=null;var i=new ll(n,r);if(this.stats_=yl.getCollection(t),e||0<=("object"==typeof window&&window.navigator&&window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i))this.server_=new tf(this.repoInfo_,this.onDataUpdate_.bind(this),i),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{var o=n.options.databaseAuthVariableOverride;if(null!=o){if("object"!=typeof o)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{Wa(o)}catch(t){throw new Error("Invalid authOverride provided: "+t)}}this.persistentConnection_=new Jl(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),i,o),this.server_=this.persistentConnection_}i.addTokenChangeListener(function(t){a.server_.refreshAuthToken(t)}),this.statsReporter_=yl.getOrCreateReporter(t,function(){return new wl(a.stats_,a.server_)}),this.transactions_init_(),this.infoData_=new cl,this.infoSyncTree_=new sl({startListening:function(t,e,n,r){var i=[],o=a.infoData_.getNode(t.path);return o.isEmpty()||(i=a.infoSyncTree_.applyServerOverwrite(t.path,o),setTimeout(function(){r("ok")},0)),i},stopListening:function(){}}),this.updateInfo_("connected",!1),this.serverSyncTree_=new sl({startListening:function(r,t,e,i){return a.server_.listen(r,e,t,function(t,e){var n=i(t,e);a.eventQueue_.raiseEventsForChangedPath(r.path,n)}),[]},stopListening:function(t,e){a.server_.unlisten(t,e)}})}var af=(sf.prototype.getStartPost=function(){return this.startPost_},sf.prototype.getEndPost=function(){return this.endPost_},sf.prototype.matches=function(t){return this.index_.compare(this.getStartPost(),t)<=0&&this.index_.compare(t,this.getEndPost())<=0},sf.prototype.updateChild=function(t,e,n,r,i,o){return this.matches(new Zu(e,n))||(n=Vc.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,n,r,i,o)},sf.prototype.updateFullNode=function(t,e,n){e.isLeafNode()&&(e=Vc.EMPTY_NODE);var r=e.withIndex(this.index_);r=r.updatePriority(Vc.EMPTY_NODE);var i=this;return e.forEachChild(vc,function(t,e){i.matches(new Zu(t,e))||(r=r.updateImmediateChild(t,Vc.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(t,r,n)},sf.prototype.updatePriority=function(t,e){return t},sf.prototype.filtersNodes=function(){return!0},sf.prototype.getIndexedFilter=function(){return this.indexedFilter_},sf.prototype.getIndex=function(){return this.index_},sf.getStartPost_=function(t){if(t.hasStart()){var e=t.getIndexStartName();return t.getIndex().makePost(t.getIndexStartValue(),e)}return t.getIndex().minPost()},sf.getEndPost_=function(t){if(t.hasEnd()){var e=t.getIndexEndName();return t.getIndex().makePost(t.getIndexEndValue(),e)}return t.getIndex().maxPost()},sf);function sf(t){this.indexedFilter_=new Fh(t.getIndex()),this.index_=t.getIndex(),this.startPost_=sf.getStartPost_(t),this.endPost_=sf.getEndPost_(t)}var uf=(cf.prototype.updateChild=function(t,e,n,r,i,o){return this.rangedFilter_.matches(new Zu(e,n))||(n=Vc.EMPTY_NODE),t.getImmediateChild(e).equals(n)?t:t.numChildren()<this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(t,e,n,r,i,o):this.fullLimitUpdateChild_(t,e,n,i,o)},cf.prototype.updateFullNode=function(t,e,n){var r;if(e.isLeafNode()||e.isEmpty())r=Vc.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<e.numChildren()&&e.isIndexed(this.index_)){r=Vc.EMPTY_NODE.withIndex(this.index_);var i=void 0;i=this.reverse_?e.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):e.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);for(var o=0;i.hasNext()&&o<this.limit_;){var a=i.getNext();if(!(this.reverse_?this.index_.compare(this.rangedFilter_.getStartPost(),a)<=0:this.index_.compare(a,this.rangedFilter_.getEndPost())<=0))break;r=r.updateImmediateChild(a.name,a.node),o++}}else{r=(r=e.withIndex(this.index_)).updatePriority(Vc.EMPTY_NODE);var s=void 0,u=void 0,c=void 0;if(i=void 0,this.reverse_){i=r.getReverseIterator(this.index_),s=this.rangedFilter_.getEndPost(),u=this.rangedFilter_.getStartPost();var h=this.index_.getCompare();c=function(t,e){return h(e,t)}}else i=r.getIterator(this.index_),s=this.rangedFilter_.getStartPost(),u=this.rangedFilter_.getEndPost(),c=this.index_.getCompare();o=0;for(var l=!1;i.hasNext();)a=i.getNext(),!l&&c(s,a)<=0&&(l=!0),l&&o<this.limit_&&c(a,u)<=0?o++:r=r.updateImmediateChild(a.name,Vc.EMPTY_NODE)}return this.rangedFilter_.getIndexedFilter().updateFullNode(t,r,n)},cf.prototype.updatePriority=function(t,e){return t},cf.prototype.filtersNodes=function(){return!0},cf.prototype.getIndexedFilter=function(){return this.rangedFilter_.getIndexedFilter()},cf.prototype.getIndex=function(){return this.index_},cf.prototype.fullLimitUpdateChild_=function(t,e,n,r,i){var o;if(this.reverse_){var a=this.index_.getCompare();o=function(t,e){return a(e,t)}}else o=this.index_.getCompare();var s=t;Ia(s.numChildren()==this.limit_,"");var u=new Zu(e,n),c=this.reverse_?s.getFirstChild(this.index_):s.getLastChild(this.index_),h=this.rangedFilter_.matches(u);if(s.hasChild(e)){for(var l=s.getImmediateChild(e),f=r.getChildAfterChild(this.index_,c,this.reverse_);null!=f&&(f.name==e||s.hasChild(f.name));)f=r.getChildAfterChild(this.index_,f,this.reverse_);var p=null==f?1:o(f,u);if(h&&!n.isEmpty()&&0<=p)return null!=i&&i.trackChildChange(xh.childChangedChange(e,n,l)),s.updateImmediateChild(e,n);null!=i&&i.trackChildChange(xh.childRemovedChange(e,l));var d=s.updateImmediateChild(e,Vc.EMPTY_NODE);return null!=f&&this.rangedFilter_.matches(f)?(null!=i&&i.trackChildChange(xh.childAddedChange(f.name,f.node)),d.updateImmediateChild(f.name,f.node)):d}return n.isEmpty()?t:h&&0<=o(c,u)?(null!=i&&(i.trackChildChange(xh.childRemovedChange(c.name,c.node)),i.trackChildChange(xh.childAddedChange(e,n))),s.updateImmediateChild(e,n).updateImmediateChild(c.name,Vc.EMPTY_NODE)):t},cf);function cf(t){this.rangedFilter_=new af(t),this.index_=t.getIndex(),this.limit_=t.getLimit(),this.reverse_=!t.isViewFromLeft()}var hf=(lf.prototype.hasStart=function(){return this.startSet_},lf.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:this.viewFrom_===lf.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT},lf.prototype.getIndexStartValue=function(){return Ia(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},lf.prototype.getIndexStartName=function(){return Ia(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:cu},lf.prototype.hasEnd=function(){return this.endSet_},lf.prototype.getIndexEndValue=function(){return Ia(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},lf.prototype.getIndexEndName=function(){return Ia(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:hu},lf.prototype.hasLimit=function(){return this.limitSet_},lf.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},lf.prototype.getLimit=function(){return Ia(this.limitSet_,"Only valid if limit has been set"),this.limit_},lf.prototype.getIndex=function(){return this.index_},lf.prototype.copy_=function(){var t=new lf;return t.limitSet_=this.limitSet_,t.limit_=this.limit_,t.startSet_=this.startSet_,t.indexStartValue_=this.indexStartValue_,t.startNameSet_=this.startNameSet_,t.indexStartName_=this.indexStartName_,t.endSet_=this.endSet_,t.indexEndValue_=this.indexEndValue_,t.endNameSet_=this.endNameSet_,t.indexEndName_=this.indexEndName_,t.index_=this.index_,t.viewFrom_=this.viewFrom_,t},lf.prototype.limit=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_="",e},lf.prototype.limitToFirst=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_=lf.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT,e},lf.prototype.limitToLast=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_=lf.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_RIGHT,e},lf.prototype.startAt=function(t,e){var n=this.copy_();return n.startSet_=!0,void 0===t&&(t=null),n.indexStartValue_=t,null!=e?(n.startNameSet_=!0,n.indexStartName_=e):(n.startNameSet_=!1,n.indexStartName_=""),n},lf.prototype.endAt=function(t,e){var n=this.copy_();return n.endSet_=!0,void 0===t&&(t=null),n.indexEndValue_=t,void 0!==e?(n.endNameSet_=!0,n.indexEndName_=e):(n.endNameSet_=!1,n.indexEndName_=""),n},lf.prototype.orderBy=function(t){var e=this.copy_();return e.index_=t,e},lf.prototype.getQueryObject=function(){var t=lf.WIRE_PROTOCOL_CONSTANTS_,e={};if(this.startSet_&&(e[t.INDEX_START_VALUE]=this.indexStartValue_,this.startNameSet_&&(e[t.INDEX_START_NAME]=this.indexStartName_)),this.endSet_&&(e[t.INDEX_END_VALUE]=this.indexEndValue_,this.endNameSet_&&(e[t.INDEX_END_NAME]=this.indexEndName_)),this.limitSet_){e[t.LIMIT]=this.limit_;var n=this.viewFrom_;""===n&&(n=this.isViewFromLeft()?t.VIEW_FROM_LEFT:t.VIEW_FROM_RIGHT),e[t.VIEW_FROM]=n}return this.index_!==vc&&(e[t.INDEX]=this.index_.toString()),e},lf.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},lf.prototype.isDefault=function(){return this.loadsAllData()&&this.index_==vc},lf.prototype.getNodeFilter=function(){return this.loadsAllData()?new Fh(this.getIndex()):this.hasLimit()?new uf(this):new af(this)},lf.prototype.toRestQueryStringParameters=function(){var t,e=lf.REST_QUERY_CONSTANTS_,n={};return this.isDefault()||(t=this.index_===vc?e.PRIORITY_INDEX:this.index_===zc?e.VALUE_INDEX:this.index_===uc?e.KEY_INDEX:(Ia(this.index_ instanceof Yc,"Unrecognized index type!"),this.index_.toString()),n[e.ORDER_BY]=Wa(t),this.startSet_&&(n[e.START_AT]=Wa(this.indexStartValue_),this.startNameSet_&&(n[e.START_AT]+=","+Wa(this.indexStartName_))),this.endSet_&&(n[e.END_AT]=Wa(this.indexEndValue_),this.endNameSet_&&(n[e.END_AT]+=","+Wa(this.indexEndName_))),this.limitSet_&&(this.isViewFromLeft()?n[e.LIMIT_TO_FIRST]=this.limit_:n[e.LIMIT_TO_LAST]=this.limit_)),n},lf.WIRE_PROTOCOL_CONSTANTS_={INDEX_START_VALUE:"sp",INDEX_START_NAME:"sn",INDEX_END_VALUE:"ep",INDEX_END_NAME:"en",LIMIT:"l",VIEW_FROM:"vf",VIEW_FROM_LEFT:"l",VIEW_FROM_RIGHT:"r",INDEX:"i"},lf.REST_QUERY_CONSTANTS_={ORDER_BY:"orderBy",PRIORITY_INDEX:"$priority",VALUE_INDEX:"$value",KEY_INDEX:"$key",START_AT:"startAt",END_AT:"endAt",LIMIT_TO_FIRST:"limitToFirst",LIMIT_TO_LAST:"limitToLast"},lf.DEFAULT=new lf,lf);function lf(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=vc}var ff,pf=(da(df,ff=uh),df.prototype.getKey=function(){return es("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},df.prototype.child=function(t){return es("Reference.child",1,1,arguments.length),"number"==typeof t?t=String(t):t instanceof bu||(null===this.path.getFront()?function(t,e,n,r){n=n&&n.replace(/^\/*\.info(\/|$)/,"/"),Fu(t,e,n,r)}("Reference.child",1,t,!1):Fu("Reference.child",1,t,!1)),new df(this.repo,this.path.child(t))},df.prototype.getParent=function(){es("Reference.parent",0,0,arguments.length);var t=this.path.parent();return null===t?null:new df(this.repo,t)},df.prototype.getRoot=function(){es("Reference.root",0,0,arguments.length);for(var t=this;null!==t.getParent();)t=t.getParent();return t},df.prototype.databaseProp=function(){return this.repo.database},df.prototype.set=function(t,e){es("Reference.set",1,2,arguments.length),Uu("Reference.set",this.path),Ou("Reference.set",1,t,this.path,!1),rs("Reference.set",2,e,!0);var n=new Da;return this.repo.setWithPriority(this.path,t,null,n.wrapCallback(e)),n.promise},df.prototype.update=function(t,e){if(es("Reference.update",1,2,arguments.length),Uu("Reference.update",this.path),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,Xs("Passing an Array to Firebase.update() is deprecated. Use set() if you want to overwrite the existing data, or an Object with integer keys if you really do want to only update some of the children.")}Pu("Reference.update",1,t,this.path,!1),rs("Reference.update",2,e,!0);var i=new Da;return this.repo.update(this.path,t,i.wrapCallback(e)),i.promise},df.prototype.setWithPriority=function(t,e,n){if(es("Reference.setWithPriority",2,3,arguments.length),Uu("Reference.setWithPriority",this.path),Ou("Reference.setWithPriority",1,t,this.path,!1),Mu("Reference.setWithPriority",2,e,!1),rs("Reference.setWithPriority",3,n,!0),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.setWithPriority failed: "+this.getKey()+" is a read-only object.";var r=new Da;return this.repo.setWithPriority(this.path,t,e,r.wrapCallback(n)),r.promise},df.prototype.remove=function(t){return es("Reference.remove",0,1,arguments.length),Uu("Reference.remove",this.path),rs("Reference.remove",1,t,!0),this.set(null,t)},df.prototype.transaction=function(t,r,e){if(es("Reference.transaction",1,3,arguments.length),Uu("Reference.transaction",this.path),rs("Reference.transaction",1,t,!1),rs("Reference.transaction",2,r,!0),function(t,e,n,r){if((!r||void 0!==n)&&"boolean"!=typeof n)throw new Error(ns(t,e,r)+"must be a boolean.")}("Reference.transaction",3,e,!0),".length"===this.getKey()||".keys"===this.getKey())throw"Reference.transaction failed: "+this.getKey()+" is a read-only object.";void 0===e&&(e=!0);var i=new Da;return"function"==typeof r&&i.promise.catch(function(){}),this.repo.startTransaction(this.path,t,function(t,e,n){t?i.reject(t):i.resolve(new Gu(e,n)),"function"==typeof r&&r(t,e,n)},e),i.promise},df.prototype.setPriority=function(t,e){es("Reference.setPriority",1,2,arguments.length),Uu("Reference.setPriority",this.path),Mu("Reference.setPriority",1,t,!1),rs("Reference.setPriority",2,e,!0);var n=new Da;return this.repo.setWithPriority(this.path.child(".priority"),t,null,n.wrapCallback(e)),n.promise},df.prototype.push=function(t,e){es("Reference.push",0,2,arguments.length),Uu("Reference.push",this.path),Ou("Reference.push",1,t,this.path,!0),rs("Reference.push",2,e,!0);var n,r=this.repo.serverTime(),i=$u(r),o=this.child(i),a=this.child(i);return n=null!=t?o.set(t,e).then(function(){return a}):Promise.resolve(a),o.then=n.then.bind(n),o.catch=n.then.bind(n,void 0),"function"==typeof e&&n.catch(function(){}),o},df.prototype.onDisconnect=function(){return Uu("Reference.onDisconnect",this.path),new Qu(this.repo,this.path)},Object.defineProperty(df.prototype,"database",{get:function(){return this.databaseProp()},enumerable:!0,configurable:!0}),Object.defineProperty(df.prototype,"key",{get:function(){return this.getKey()},enumerable:!0,configurable:!0}),Object.defineProperty(df.prototype,"parent",{get:function(){return this.getParent()},enumerable:!0,configurable:!0}),Object.defineProperty(df.prototype,"root",{get:function(){return this.getRoot()},enumerable:!0,configurable:!0}),df);function df(t,e){if(!(t instanceof rf))throw new Error("new Reference() no longer supported - use app.database().");return ff.call(this,t,e,hf.DEFAULT,!1)||this}uh.__referenceConstructor=pf,Zh.__referenceConstructor=pf;var mf,yf,gf=function(){this.children={},this.childCount=0,this.value=null},vf=(bf.prototype.subTree=function(t){for(var e,n=t instanceof bu?t:new bu(t),r=this;null!==(e=n.getFront());)r=new bf(e,r,Ha(r.node_.children,e)||new gf),n=n.popFront();return r},bf.prototype.getValue=function(){return this.node_.value},bf.prototype.setValue=function(t){Ia(void 0!==t,"Cannot set value to undefined"),this.node_.value=t,this.updateParents_()},bf.prototype.clear=function(){this.node_.value=null,this.node_.children={},this.node_.childCount=0,this.updateParents_()},bf.prototype.hasChildren=function(){return 0<this.node_.childCount},bf.prototype.isEmpty=function(){return null===this.getValue()&&!this.hasChildren()},bf.prototype.forEachChild=function(n){var r=this;pu(this.node_.children,function(t,e){n(new bf(t,r,e))})},bf.prototype.forEachDescendant=function(e,t,n){t&&!n&&e(this),this.forEachChild(function(t){t.forEachDescendant(e,!0,n)}),t&&n&&e(this)},bf.prototype.forEachAncestor=function(t,e){for(var n=e?this:this.parent();null!==n;){if(t(n))return!0;n=n.parent()}return!1},bf.prototype.forEachImmediateDescendantWithValue=function(e){this.forEachChild(function(t){null!==t.getValue()?e(t):t.forEachImmediateDescendantWithValue(e)})},bf.prototype.path=function(){return new bu(null===this.parent_?this.name_:this.parent_.path()+"/"+this.name_)},bf.prototype.name=function(){return this.name_},bf.prototype.parent=function(){return this.parent_},bf.prototype.updateParents_=function(){null!==this.parent_&&this.parent_.updateChild_(this.name_,this)},bf.prototype.updateChild_=function(t,e){var n=e.isEmpty(),r=Qa(this.node_.children,t);n&&r?(delete this.node_.children[t],this.node_.childCount--,this.updateParents_()):n||r||(this.node_.children[t]=e.node_,this.node_.childCount++,this.updateParents_())},bf);function bf(t,e,n){void 0===t&&(t=""),void 0===e&&(e=null),void 0===n&&(n=new gf),this.name_=t,this.parent_=e,this.node_=n}(yf=mf=mf||{})[yf.RUN=0]="RUN",yf[yf.SENT=1]="SENT",yf[yf.COMPLETED=2]="COMPLETED",yf[yf.SENT_NEEDS_ABORT=3]="SENT_NEEDS_ABORT",yf[yf.NEEDS_ABORT=4]="NEEDS_ABORT",rf.MAX_TRANSACTION_RETRIES_=25,rf.prototype.transactions_init_=function(){this.transactionQueueTree_=new vf},rf.prototype.startTransaction=function(t,e,n,r){this.log_("transaction on "+t);function i(){}var o=new pf(this,t);o.on("value",i);var a={path:t,update:e,onComplete:n,status:null,order:ou(),applyLocally:r,retryCount:0,unwatcher:function(){o.off("value",i)},abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},s=this.getLatestState_(t);a.currentInputSnapshot=s;var u=a.update(s.val());if(void 0===u){if(a.unwatcher(),a.currentOutputSnapshotRaw=null,a.currentOutputSnapshotResolved=null,a.onComplete){var c=new Jc(a.currentInputSnapshot,new pf(this,a.path),vc);a.onComplete(null,!1,c)}}else{Ku("transaction failed: Data returned ",u,a.path),a.status=mf.RUN;var h=this.transactionQueueTree_.subTree(t),l=h.getValue()||[];l.push(a),h.setValue(l);var f=void 0;if("object"==typeof u&&null!==u&&Qa(u,".priority"))f=Ha(u,".priority"),Ia(Ru(f),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.");else f=(this.serverSyncTree_.calcCompleteEventCache(t)||Vc.EMPTY_NODE).getPriority().val();f=f;var p=this.generateServerValues(),d=Qc(u,f),m=gh(d,s,p);a.currentOutputSnapshotRaw=d,a.currentOutputSnapshotResolved=m,a.currentWriteId=this.getNextWriteId_();var y=this.serverSyncTree_.applyUserOverwrite(t,m,a.currentWriteId,a.applyLocally);this.eventQueue_.raiseEventsForChangedPath(t,y),this.sendReadyTransactions_()}},rf.prototype.getLatestState_=function(t,e){return this.serverSyncTree_.calcCompleteEventCache(t,e)||Vc.EMPTY_NODE},rf.prototype.sendReadyTransactions_=function(t){var e=this;if(void 0===t&&(t=this.transactionQueueTree_),t||this.pruneCompletedTransactionsBelowNode_(t),null!==t.getValue()){var n=this.buildTransactionQueue_(t);Ia(0<n.length,"Sending zero length transaction queue"),n.every(function(t){return t.status===mf.RUN})&&this.sendTransactionQueue_(t.path(),n)}else t.hasChildren()&&t.forEachChild(function(t){e.sendReadyTransactions_(t)})},rf.prototype.sendTransactionQueue_=function(s,u){for(var c=this,t=u.map(function(t){return t.currentWriteId}),e=this.getLatestState_(s,t),n=e,r=e.hash(),i=0;i<u.length;i++){var o=u[i];Ia(o.status===mf.RUN,"tryToSendTransactionQueue_: items in queue should all be run."),o.status=mf.SENT,o.retryCount++;var a=bu.relativePath(s,o.path);n=n.updateChild(a,o.currentOutputSnapshotRaw)}var h=n.val(!0),l=s;this.server_.put(l.toString(),h,function(t){c.log_("transaction put response",{path:l.toString(),status:t});var e=[];if("ok"===t){for(var n=[],r=0;r<u.length;r++){if(u[r].status=mf.COMPLETED,e=e.concat(c.serverSyncTree_.ackUserWrite(u[r].currentWriteId)),u[r].onComplete){var i=u[r].currentOutputSnapshotResolved,o=new pf(c,u[r].path),a=new Jc(i,o,vc);n.push(u[r].onComplete.bind(null,null,!0,a))}u[r].unwatcher()}c.pruneCompletedTransactionsBelowNode_(c.transactionQueueTree_.subTree(s)),c.sendReadyTransactions_(),c.eventQueue_.raiseEventsForChangedPath(s,e);for(r=0;r<n.length;r++)mu(n[r])}else{if("datastale"===t)for(r=0;r<u.length;r++)u[r].status===mf.SENT_NEEDS_ABORT?u[r].status=mf.NEEDS_ABORT:u[r].status=mf.RUN;else{Xs("transaction at "+l.toString()+" failed: "+t);for(r=0;r<u.length;r++)u[r].status=mf.NEEDS_ABORT,u[r].abortReason=t}c.rerunTransactions_(s)}},r)},rf.prototype.rerunTransactions_=function(t){var e=this.getAncestorTransactionNode_(t),n=e.path(),r=this.buildTransactionQueue_(e);return this.rerunTransactionQueue_(r,n),n},rf.prototype.rerunTransactionQueue_=function(t,e){if(0!==t.length){for(var n,r=[],i=[],o=t.filter(function(t){return t.status===mf.RUN}).map(function(t){return t.currentWriteId}),a=0;a<t.length;a++){var s=t[a],u=bu.relativePath(e,s.path),c=!1,h=void 0;if(Ia(null!==u,"rerunTransactionsUnderNode_: relativePath should not be null."),s.status===mf.NEEDS_ABORT)c=!0,h=s.abortReason,i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0));else if(s.status===mf.RUN)if(s.retryCount>=rf.MAX_TRANSACTION_RETRIES_)c=!0,h="maxretry",i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0));else{var l=this.getLatestState_(s.path,o);s.currentInputSnapshot=l;var f=t[a].update(l.val());if(void 0!==f){Ku("transaction failed: Data returned ",f,s.path);var p=Qc(f);"object"==typeof f&&null!=f&&Qa(f,".priority")||(p=p.updatePriority(l.getPriority()));var d=s.currentWriteId,m=this.generateServerValues(),y=gh(p,l,m);s.currentOutputSnapshotRaw=p,s.currentOutputSnapshotResolved=y,s.currentWriteId=this.getNextWriteId_(),o.splice(o.indexOf(d),1),i=(i=i.concat(this.serverSyncTree_.applyUserOverwrite(s.path,y,s.currentWriteId,s.applyLocally))).concat(this.serverSyncTree_.ackUserWrite(d,!0))}else c=!0,h="nodata",i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0))}if(this.eventQueue_.raiseEventsForChangedPath(e,i),i=[],c&&(t[a].status=mf.COMPLETED,n=t[a].unwatcher,setTimeout(n,Math.floor(0)),t[a].onComplete))if("nodata"===h){var g=new pf(this,t[a].path),v=t[a].currentInputSnapshot,b=new Jc(v,g,vc);r.push(t[a].onComplete.bind(null,null,!1,b))}else r.push(t[a].onComplete.bind(null,new Error(h),!1,null))}this.pruneCompletedTransactionsBelowNode_(this.transactionQueueTree_);for(a=0;a<r.length;a++)mu(r[a]);this.sendReadyTransactions_()}},rf.prototype.getAncestorTransactionNode_=function(t){for(var e,n=this.transactionQueueTree_;null!==(e=t.getFront())&&null===n.getValue();)n=n.subTree(e),t=t.popFront();return n},rf.prototype.buildTransactionQueue_=function(t){var e=[];return this.aggregateTransactionQueuesForNode_(t,e),e.sort(function(t,e){return t.order-e.order}),e},rf.prototype.aggregateTransactionQueuesForNode_=function(t,e){var n=this,r=t.getValue();if(null!==r)for(var i=0;i<r.length;i++)e.push(r[i]);t.forEachChild(function(t){n.aggregateTransactionQueuesForNode_(t,e)})},rf.prototype.pruneCompletedTransactionsBelowNode_=function(t){var e=this,n=t.getValue();if(n){for(var r=0,i=0;i<n.length;i++)n[i].status!==mf.COMPLETED&&(n[r]=n[i],r++);n.length=r,t.setValue(0<n.length?n:null)}t.forEachChild(function(t){e.pruneCompletedTransactionsBelowNode_(t)})},rf.prototype.abortTransactions_=function(t){var e=this,n=this.getAncestorTransactionNode_(t).path(),r=this.transactionQueueTree_.subTree(t);return r.forEachAncestor(function(t){e.abortTransactionsOnNode_(t)}),this.abortTransactionsOnNode_(r),r.forEachDescendant(function(t){e.abortTransactionsOnNode_(t)}),n},rf.prototype.abortTransactionsOnNode_=function(t){var e=t.getValue();if(null!==e){for(var n=[],r=[],i=-1,o=0;o<e.length;o++)if(e[o].status===mf.SENT_NEEDS_ABORT);else if(e[o].status===mf.SENT)Ia(i===o-1,"All SENT items should be at beginning of queue."),e[i=o].status=mf.SENT_NEEDS_ABORT,e[o].abortReason="set";else if(Ia(e[o].status===mf.RUN,"Unexpected transaction status in abort"),e[o].unwatcher(),r=r.concat(this.serverSyncTree_.ackUserWrite(e[o].currentWriteId,!0)),e[o].onComplete){n.push(e[o].onComplete.bind(null,new Error("set"),!1,null))}-1===i?t.setValue(null):e.length=i+1,this.eventQueue_.raiseEventsForChangedPath(t.path(),r);for(o=0;o<n.length;o++)mu(n[o])}};var wf,_f="databaseURL",Tf=(Ef.getInstance=function(){return wf=wf||new Ef},Ef.prototype.interrupt=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].interrupt()},Ef.prototype.resume=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].resume()},Ef.prototype.databaseFromApp=function(t,e,n){var r=n||t.options[_f];void 0===r&&Ys("Can't determine Firebase Database URL.  Be sure to include "+_f+" option when calling firebase.initializeApp().");var i=Au(r),o=i.repoInfo,a=void 0;return"undefined"!=typeof process&&(a=process.env.FIREBASE_DATABASE_EMULATOR_HOST),a&&(r="http://"+a+"?ns="+o.namespace,o=(i=Au(r)).repoInfo),Vu("Invalid Firebase Database URL",1,i),i.path.isEmpty()||Ys("Database URL must point to the root of a Firebase Database (not including a child path)."),this.createRepo(o,t,e).database},Ef.prototype.deleteRepo=function(t){var e=Ha(this.repos_,t.app.name);e&&Ha(e,t.repoInfo_.toURLString())===t||Ys("Database "+t.app.name+"("+t.repoInfo_+") has already been deleted."),t.interrupt(),delete e[t.repoInfo_.toURLString()]},Ef.prototype.createRepo=function(t,e,n){var r=Ha(this.repos_,e.name);r||(r={},this.repos_[e.name]=r);var i=Ha(r,t.toURLString());return i&&Ys("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),i=new rf(t,this.useRestClient_,e,n),r[t.toURLString()]=i},Ef.prototype.forceRestClient=function(t){this.useRestClient_=t},Ef);function Ef(){this.repos_={},this.useRestClient_=!1}var Sf=(Object.defineProperty(If.prototype,"app",{get:function(){return this.repo_.app},enumerable:!0,configurable:!0}),If.prototype.ref=function(t){return this.checkDeleted_("ref"),es("database.ref",0,1,arguments.length),t instanceof pf?this.refFromURL(t.toString()):void 0!==t?this.root_.child(t):this.root_},If.prototype.refFromURL=function(t){var e="database.refFromURL";this.checkDeleted_(e),es(e,1,1,arguments.length);var n=Au(t);Vu(e,1,n);var r=n.repoInfo;return r.host!==this.repo_.repoInfo_.host&&Ys(e+": Host name does not match the current database: (found "+r.host+" but expected "+this.repo_.repoInfo_.host+")"),this.ref(n.path.toString())},If.prototype.checkDeleted_=function(t){null===this.repo_&&Ys("Cannot call "+t+" on a deleted database.")},If.prototype.goOffline=function(){es("database.goOffline",0,0,arguments.length),this.checkDeleted_("goOffline"),this.repo_.interrupt()},If.prototype.goOnline=function(){es("database.goOnline",0,0,arguments.length),this.checkDeleted_("goOnline"),this.repo_.resume()},If.ServerValue={TIMESTAMP:{".sv":"timestamp"},_increment:function(t){return{".sv":{increment:t}}}},If);function If(t){(this.repo_=t)instanceof rf||Ys("Don't call new Database() directly - please use firebase.database()."),this.root_=new pf(t,bu.Empty),this.INTERNAL=new Cf(this)}var Cf=(Nf.prototype.delete=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return this.database.checkDeleted_("delete"),Tf.getInstance().deleteRepo(this.database.repo_),this.database.repo_=null,this.database.root_=null,this.database.INTERNAL=null,this.database=null,[2]})})},Nf);function Nf(t){this.database=t}var Af=Object.freeze({__proto__:null,forceLongPolling:function(){jl.forceDisallow(),Ll.forceAllow()},forceWebSockets:function(){Ll.forceDisallow()},isWebSocketsAvailable:function(){return jl.isAvailable()},setSecurityDebugCallback:function(t,e){t.repo.persistentConnection_.securityDebugCallback_=e},stats:function(t,e){t.repo.stats(e)},statsIncrementCounter:function(t,e){t.repo.statsIncrementCounter(e)},dataUpdateCount:function(t){return t.repo.dataUpdateCount},interceptServerData:function(t,e){return t.repo.interceptServerData_(e)}}),kf=Jl;Jl.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},Jl.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};var Df,Rf,Of=Hl,Pf=Cu,Mf=Object.freeze({__proto__:null,DataConnection:kf,RealTimeConnection:Of,hijackHash:function(i){var o=Jl.prototype.put;return Jl.prototype.put=function(t,e,n,r){void 0!==r&&(r=i()),o.call(this,t,e,n,r)},function(){Jl.prototype.put=o}},ConnectionTarget:Pf,queryIdentifier:function(t){return t.queryIdentifier()},forceRestClient:function(t){Tf.getInstance().forceRestClient(t)}}),xf=Sf.ServerValue;Df=(Rf=fl).SDK_VERSION,ql=Df,Rf.INTERNAL.registerComponent(new as("database",function(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal");return Tf.getInstance().databaseFromApp(n,r,e)},"PUBLIC").setServiceProps({Reference:pf,Query:uh,Database:Sf,DataSnapshot:Jc,enableLogging:Qs,INTERNAL:Af,ServerValue:xf,TEST_ACCESS:Mf}).setMultipleInstances(!0)),Rf.registerVersion("@firebase/database","0.5.16");var Lf,Ff="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Uf=Uf||{},Vf=Ff;function qf(t){return"string"==typeof t}function Bf(t){return"number"==typeof t}function jf(t,e){t=t.split("."),e=e||Vf;for(var n=0;n<t.length;n++)if(null==(e=e[t[n]]))return null;return e}function Wf(){}function Kf(t){var e=typeof t;if("object"==e){if(!t)return"null";if(t instanceof Array)return"array";if(t instanceof Object)return e;var n=Object.prototype.toString.call(t);if("[object Window]"==n)return"object";if("[object Array]"==n||"number"==typeof t.length&&void 0!==t.splice&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("splice"))return"array";if("[object Function]"==n||void 0!==t.call&&void 0!==t.propertyIsEnumerable&&!t.propertyIsEnumerable("call"))return"function"}else if("function"==e&&void 0===t.call)return"object";return e}function Qf(t){return"array"==Kf(t)}function Hf(t){var e=Kf(t);return"array"==e||"object"==e&&"number"==typeof t.length}function Gf(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var zf="closure_uid_"+(1e9*Math.random()>>>0),Yf=0;function Xf(t,e,n){return t.call.apply(t.bind,arguments)}function Jf(e,n,t){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var t=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(t,r),e.apply(n,t)}}return function(){return e.apply(n,arguments)}}function $f(t,e,n){return($f=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?Xf:Jf).apply(null,arguments)}function Zf(e){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}var tp=Date.now||function(){return+new Date};function ep(t,o){function e(){}e.prototype=o.prototype,t.N=o.prototype,t.prototype=new e,(t.prototype.constructor=t).xb=function(t,e,n){for(var r=Array(arguments.length-2),i=2;i<arguments.length;i++)r[i-2]=arguments[i];return o.prototype[e].apply(t,r)}}function np(){this.j=this.j,this.i=this.i}np.prototype.j=!1,np.prototype.la=function(){if(!this.j&&(this.j=!0,this.G(),0))this[zf]||(this[zf]=++Yf)},np.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var rp=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(qf(t))return qf(e)&&1==e.length?t.indexOf(e,0):-1;for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1},ip=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=qf(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function op(){return Array.prototype.concat.apply([],arguments)}function ap(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function sp(t){return/^[\s\xa0]*$/.test(t)}var up,cp=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function hp(t,e){return-1!=t.indexOf(e)}function lp(t,e){return t<e?-1:e<t?1:0}t:{var fp=Vf.navigator;if(fp){var pp=fp.userAgent;if(pp){up=pp;break t}}up=""}function dp(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function mp(t){var e,n={};for(e in t)n[e]=t[e];return n}var yp="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function gp(t){for(var e,n,r=1;r<arguments.length;r++){for(e in n=arguments[r])t[e]=n[e];for(var i=0;i<yp.length;i++)e=yp[i],Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}}function vp(t){return vp[" "](t),t}vp[" "]=Wf;var bp,wp,_p=hp(up,"Opera"),Tp=hp(up,"Trident")||hp(up,"MSIE"),Ep=hp(up,"Edge"),Sp=Ep||Tp,Ip=hp(up,"Gecko")&&!(hp(up.toLowerCase(),"webkit")&&!hp(up,"Edge"))&&!(hp(up,"Trident")||hp(up,"MSIE"))&&!hp(up,"Edge"),Cp=hp(up.toLowerCase(),"webkit")&&!hp(up,"Edge");function Np(){var t=Vf.document;return t?t.documentMode:void 0}t:{var Ap="",kp=(wp=up,Ip?/rv:([^\);]+)(\)|;)/.exec(wp):Ep?/Edge\/([\d\.]+)/.exec(wp):Tp?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(wp):Cp?/WebKit\/(\S+)/.exec(wp):_p?/(?:Version)[ \/]?(\S+)/.exec(wp):void 0);if(kp&&(Ap=kp?kp[1]:""),Tp){var Dp=Np();if(null!=Dp&&Dp>parseFloat(Ap)){bp=String(Dp);break t}}bp=Ap}var Rp,Op={};function Pp(s){return function(t,e){var n=Op;return Object.prototype.hasOwnProperty.call(n,t)?n[t]:n[t]=e(t)}(s,function(){for(var t=0,e=cp(String(bp)).split("."),n=cp(String(s)).split("."),r=Math.max(e.length,n.length),i=0;0==t&&i<r;i++){var o=e[i]||"",a=n[i]||"";do{if(o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],a=/(\d*)(\D*)(.*)/.exec(a)||["","","",""],0==o[0].length&&0==a[0].length)break;t=lp(0==o[1].length?0:parseInt(o[1],10),0==a[1].length?0:parseInt(a[1],10))||lp(0==o[2].length,0==a[2].length)||lp(o[2],a[2]),o=o[3],a=a[3]}while(0==t)}return 0<=t})}var Mp=Vf.document;Rp=Mp&&Tp?Np()||("CSS1Compat"==Mp.compatMode?parseInt(bp,10):5):void 0;var xp=!Tp||9<=Number(Rp),Lp=Tp&&!Pp("9"),Fp=function(){if(!Vf.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{Vf.addEventListener("test",Wf,e),Vf.removeEventListener("test",Wf,e)}catch(t){}return t}();function Up(t,e){this.type=t,this.a=this.target=e,this.Ia=!0}function Vp(t,e){if(Up.call(this,t?t.type:""),this.relatedTarget=this.a=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.pointerId=0,this.pointerType="",this.c=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.a=e,e=t.relatedTarget){if(Ip){t:{try{vp(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==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=qf(t.pointerType)?t.pointerType:qp[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}Up.prototype.b=function(){this.Ia=!1},ep(Vp,Up);var qp={2:"touch",3:"pen",4:"mouse"};Vp.prototype.b=function(){Vp.N.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,Lp)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}};var Bp="closure_listenable_"+(1e6*Math.random()|0),jp=0;function Wp(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.da=i,this.key=++jp,this.X=this.Z=!1}function Kp(t){t.X=!0,t.listener=null,t.proxy=null,t.src=null,t.da=null}function Qp(t){this.src=t,this.a={},this.b=0}function Hp(t,e){var n=e.type;if(n in t.a){var r,i=t.a[n],o=rp(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(Kp(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function Gp(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i];if(!o.X&&o.listener==e&&o.capture==!!n&&o.da==r)return i}return-1}Qp.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=Gp(t,e,r,i);return-1<a?(e=t[a],n||(e.Z=!1)):((e=new Wp(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var zp="closure_lm_"+(1e6*Math.random()|0),Yp={};function Xp(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(Qf(n)){for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);return null}r=id(r);return e&&e[Bp]?e.Aa(n,r,Gf(i)?!!i.capture:!!i,o):Jp(e,n,r,!0,i,o)}(t,e,n,r,i);if(Qf(e)){for(var o=0;o<e.length;o++)Xp(t,e[o],n,r,i);return null}return n=id(n),t&&t[Bp]?t.za(e,n,Gf(r)?!!r.capture:!!r,i):Jp(t,e,n,!1,r,i)}function Jp(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=Gf(i)?!!i.capture:!!i;if(a&&!xp)return null;var s=nd(t);if(s||(t[zp]=s=new Qp(t)),(n=s.add(e,n,r,a,o)).proxy)return n;if(r=function(){var e=ed,n=xp?function(t){return e.call(n.src,n.listener,t)}:function(t){if(!(t=e.call(n.src,n.listener,t)))return t};return n}(),(n.proxy=r).src=t,r.listener=n,t.addEventListener)Fp||(i=a),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Zp(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function $p(t){if(!Bf(t)&&t&&!t.X){var e=t.src;if(e&&e[Bp])Hp(e.c,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Zp(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=nd(e))?(Hp(n,t),0==n.b&&(n.src=null,e[zp]=null)):Kp(t)}}}function Zp(t){return t in Yp?Yp[t]:Yp[t]="on"+t}function td(t,e){var n=t.listener,r=t.da||t.src;return t.Z&&$p(t),n.call(r,e)}function ed(t,e){return!!t.X||(xp?td(t,new Vp(e,this)):td(t,e=new Vp(e||jf("window.event"),this)))}function nd(t){return(t=t[zp])instanceof Qp?t:null}var rd="__closure_events_fn_"+(1e9*Math.random()>>>0);function id(e){return"function"==Kf(e)?e:(e[rd]||(e[rd]=function(t){return e.handleEvent(t)}),e[rd])}function od(){np.call(this),this.c=new Qp(this),(this.J=this).B=null}function ad(t,e,n,r){if(!(e=t.c.a[String(e)]))return!0;e=e.concat();for(var i=!0,o=0;o<e.length;++o){var a=e[o];if(a&&!a.X&&a.capture==n){var s=a.listener,u=a.da||a.src;a.Z&&Hp(t.c,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Ia}ep(od,np),od.prototype[Bp]=!0,(Lf=od.prototype).addEventListener=function(t,e,n,r){Xp(this,t,e,n,r)},Lf.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(Qf(n))for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);else i=Gf(i)?!!i.capture:!!i,r=id(r),e&&e[Bp]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=Gp(a=e.a[n],r,i,o))&&(Kp(a[r]),Array.prototype.splice.call(a,r,1),0==a.length&&(delete e.a[n],e.b--))):(e=e&&nd(e))&&(n=e.a[n.toString()],e=-1,n&&(e=Gp(n,r,i,o)),(r=-1<e?n[e]:null)&&$p(r))}(this,t,e,n,r)},Lf.dispatchEvent=function(t){var e,n=this.B;if(n)for(e=[];n;n=n.B)e.push(n);n=this.J;var r=t.type||t;if(qf(t))t=new Up(t,n);else if(t instanceof Up)t.target=t.target||n;else{var i=t;gp(t=new Up(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.a=e[o];i=ad(a,r,!0,t)&&i}if(i=ad(a=t.a=n,r,!0,t)&&i,i=ad(a,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=ad(a=t.a=e[o],r,!1,t)&&i;return i},Lf.G=function(){if(od.N.G.call(this),this.c){var t,e=this.c;for(t in e.a){for(var n=e.a[t],r=0;r<n.length;r++)Kp(n[r]);delete e.a[t],e.b--}}this.B=null},Lf.za=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},Lf.Aa=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var sd=Vf.JSON.stringify;function ud(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function cd(){this.b=this.a=null}ud.prototype.get=function(){if(0<this.b){this.b--;var t=this.a;this.a=t.next,t.next=null}else t=this.c();return t};var hd,ld=new ud(function(){return new fd},function(t){t.reset()});function fd(){this.next=this.b=this.a=null}function pd(t){Vf.setTimeout(function(){throw t},0)}function dd(t,e){hd||function(){var t=Vf.Promise.resolve(void 0);hd=function(){t.then(gd)}}(),md||(hd(),md=!0),yd.add(t,e)}cd.prototype.add=function(t,e){var n=ld.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},fd.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var md=!(fd.prototype.reset=function(){this.next=this.b=this.a=null}),yd=new cd;function gd(){for(var t;r=n=void 0,r=null,(n=yd).a&&(r=n.a,n.a=n.a.next,n.a||(n.b=null),r.next=null),t=r;){try{t.a.call(t.b)}catch(t){pd(t)}var e=ld;e.f(t),e.b<100&&(e.b++,t.next=e.a,e.a=t)}var n,r;md=!1}function vd(t,e){od.call(this),this.b=t||1,this.a=e||Vf,this.f=$f(this.fb,this),this.g=tp()}function bd(t){t.ba=!1,t.L&&(t.a.clearTimeout(t.L),t.L=null)}function wd(t,e,n){if("function"==Kf(t))n&&(t=$f(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=$f(t.handleEvent,t)}return 2147483647<Number(e)?-1:Vf.setTimeout(t,e||0)}function _d(t,e,n){np.call(this),this.f=null!=n?$f(t,n):t,this.c=e,this.b=$f(this.$a,this),this.a=[]}function Td(t){t.U=wd(t.b,t.c),t.f.apply(null,t.a)}function Ed(t){np.call(this),this.b=t,this.a={}}ep(vd,od),(Lf=vd.prototype).ba=!1,Lf.L=null,Lf.fb=function(){if(this.ba){var t=tp()-this.g;0<t&&t<.8*this.b?this.L=this.a.setTimeout(this.f,this.b-t):(this.L&&(this.a.clearTimeout(this.L),this.L=null),this.dispatchEvent("tick"),this.ba&&(bd(this),this.start()))}},Lf.start=function(){this.ba=!0,this.L||(this.L=this.a.setTimeout(this.f,this.b),this.g=tp())},Lf.G=function(){vd.N.G.call(this),bd(this),delete this.a},ep(_d,np),(Lf=_d.prototype).ea=!1,Lf.U=null,Lf.Ta=function(t){this.a=arguments,this.U?this.ea=!0:Td(this)},Lf.G=function(){_d.N.G.call(this),this.U&&(Vf.clearTimeout(this.U),this.U=null,this.ea=!1,this.a=[])},Lf.$a=function(){this.U=null,this.ea&&(this.ea=!1,Td(this))},ep(Ed,np);var Sd=[];function Id(t,e,n,r){Qf(n)||(n&&(Sd[0]=n.toString()),n=Sd);for(var i=0;i<n.length;i++){var o=Xp(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function Cd(t){dp(t.a,function(t,e){this.a.hasOwnProperty(e)&&$p(t)},t),t.a={}}function Nd(){}Ed.prototype.G=function(){Ed.N.G.call(this),Cd(this)},Ed.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Ad=new od;function kd(t){Up.call(this,"serverreachability",t)}function Dd(t){Ad.dispatchEvent(new kd(Ad,t))}function Rd(t){Up.call(this,"statevent",t)}function Od(t){Ad.dispatchEvent(new Rd(Ad,t))}function Pd(t){Up.call(this,"timingevent",t)}function Md(t,e){if("function"!=Kf(t))throw Error("Fn must not be null and must be a function");return Vf.setTimeout(function(){t()},e)}ep(kd,Up),ep(Rd,Up),ep(Pd,Up);var xd={NO_ERROR:0,gb:1,nb:2,mb:3,jb:4,lb:5,ob:6,La:7,TIMEOUT:8,rb:9},Ld={ib:"complete",vb:"success",Ma:"error",La:"abort",tb:"ready",ub:"readystatechange",TIMEOUT:"timeout",pb:"incrementaldata",sb:"progress",kb:"downloadprogress",wb:"uploadprogress"};function Fd(){}function Ud(t){var e;return(e=t.a)||(e=t.a={}),e}function Vd(){}Fd.prototype.a=null;var qd,Bd={OPEN:"a",hb:"b",Ma:"c",qb:"d"};function jd(){Up.call(this,"d")}function Wd(){Up.call(this,"c")}function Kd(){}function Qd(t,e,n){this.g=t,this.W=e,this.V=n||1,this.I=new Ed(this),this.O=Hd,t=Sp?125:void 0,this.P=new vd(t),this.h=null,this.b=!1,this.l=this.D=this.f=this.F=this.v=this.R=this.i=null,this.j=[],this.a=null,this.A=0,this.c=this.w=null,this.o=-1,this.m=!1,this.J=0,this.B=null,this.s=this.S=this.H=!1}ep(jd,Up),ep(Wd,Up),ep(Kd,Fd),qd=new Kd;var Hd=45e3,Gd={},zd={};function Yd(t,e,n){t.F=1,t.f=wm(pm(e)),t.l=n,t.H=!0,Jd(t,null)}function Xd(t,e,n,r){t.F=1,t.f=wm(pm(e)),t.l=null,t.H=n,Jd(t,r)}function Jd(t,e){t.v=tp(),tm(t),t.D=pm(t.f),bm(t.D,"t",t.V),t.A=0,t.a=t.g.$(t.g.Y()?e:null),0<t.J&&(t.B=new _d($f(t.Ja,t,t.a),t.J)),Id(t.I,t.a,"readystatechange",t.cb),e=t.h?mp(t.h):{},t.l?(t.w||(t.w="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.a.ca(t.D,t.w,t.l,e)):(t.w="GET",t.a.ca(t.D,t.w,null,e)),Dd(1)}function $d(t,e,n){for(var r=!0;!t.m&&t.A<n.length;){var i=Zd(t,n);if(i==zd){4==e&&(t.c=4,Od(14),r=!1);break}if(i==Gd){t.c=4,Od(15),r=!1;break}om(t,i)}4==e&&0==n.length&&(t.c=1,Od(16),r=!1),t.b=t.b&&r,r||(im(t),rm(t))}function Zd(t,e){var n=t.A,r=e.indexOf("\n",n);return-1==r?zd:(n=Number(e.substring(n,r)),isNaN(n)?Gd:(r+=1)+n>e.length?zd:(e=e.substr(r,n),t.A=r+n,e))}function tm(t){t.R=tp()+t.O,em(t,t.O)}function em(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=Md($f(t.ab,t),e)}function nm(t){t.i&&(Vf.clearTimeout(t.i),t.i=null)}function rm(t){t.g.Ca()||t.m||t.g.na(t)}function im(t){nm(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,bd(t.P),Cd(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function om(t,e){try{t.g.Fa(t,e),Dd(4)}catch(t){}}function am(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(Hf(t)||qf(t))ip(t,e,void 0);else{if(t.K&&"function"==typeof t.K)var n=t.K();else if(t.C&&"function"==typeof t.C)n=void 0;else if(Hf(t)||qf(t)){n=[];for(var r=t.length,i=0;i<r;i++)n.push(i)}else for(i in n=[],r=0,t)n[r++]=i;i=(r=function(t){if(t.C&&"function"==typeof t.C)return t.C();if(qf(t))return t.split("");if(Hf(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t)).length;for(var o=0;o<i;o++)e.call(void 0,r[o],n&&n[o],t)}}function sm(t,e){this.b={},this.a=[],this.c=0;var n=arguments.length;if(1<n){if(n%2)throw Error("Uneven number of arguments");for(var r=0;r<n;r+=2)this.set(arguments[r],arguments[r+1])}else if(t)if(t instanceof sm)for(n=t.K(),r=0;r<n.length;r++)this.set(n[r],t.get(n[r]));else for(r in t)this.set(r,t[r])}function um(t,e){hm(t.b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&cm(t))}function cm(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];hm(t.b,r)&&(t.a[n++]=r),e++}t.a.length=n}if(t.c!=t.a.length){var i={};for(n=e=0;e<t.a.length;)hm(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function hm(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(Lf=Qd.prototype).setTimeout=function(t){this.O=t},Lf.cb=function(t){t=t.target;var e=this.B;e&&3==fy(t)?e.Ta():this.Ja(t)},Lf.Ja=function(t){try{if(t==this.a)t:{var e=fy(this.a),n=this.a.ya(),r=this.a.T();if(!(e<3||3==e&&!Sp&&!this.a.aa())){this.m||4!=e||7==n||Dd(8==n||r<=0?3:2),nm(this);var i=this.a.T();this.o=i;var o=this.a.aa();if(this.b=200==i){if(this.S&&!this.s){e:{if(this.a){var a=py(this.a,"X-HTTP-Initial-Response");if(a&&!sp(a)){var s=a;break e}}s=null}if(!s){this.b=!1,this.c=3,Od(12),im(this),rm(this);break t}this.s=!0,om(this,s)}this.H?($d(this,e,o),Sp&&this.b&&3==e&&(Id(this.I,this.P,"tick",this.bb),this.P.start())):om(this,o),4==e&&im(this),this.b&&!this.m&&(4==e?this.g.na(this):(this.b=!1,tm(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.c=3,Od(12)):(this.c=0,Od(13)),im(this),rm(this)}}}catch(t){}},Lf.bb=function(){if(this.a){var t=fy(this.a),e=this.a.aa();this.A<e.length&&(nm(this),$d(this,t,e),this.b&&4!=t&&tm(this))}},Lf.cancel=function(){this.m=!0,im(this)},Lf.ab=function(){this.i=null;var t=tp();0<=t-this.R?(2!=this.F&&(Dd(3),Od(17)),im(this),this.c=2,rm(this)):em(this,this.R-t)},(Lf=sm.prototype).C=function(){cm(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},Lf.K=function(){return cm(this),this.a.concat()},Lf.get=function(t,e){return hm(this.b,t)?this.b[t]:e},Lf.set=function(t,e){hm(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},Lf.forEach=function(t,e){for(var n=this.K(),r=0;r<n.length;r++){var i=n[r],o=this.get(i);t.call(e,o,i,this)}};var lm=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function fm(t,e){var n;this.b=this.j=this.f="",this.i=null,this.g=this.a="",this.h=!1,t instanceof fm?(this.h=void 0!==e?e:t.h,dm(this,t.f),this.j=t.j,mm(this,t.b),ym(this,t.i),this.a=t.a,gm(this,Mm(t.c)),this.g=t.g):t&&(n=String(t).match(lm))?(this.h=!!e,dm(this,n[1]||"",!0),this.j=_m(n[2]||""),mm(this,n[3]||"",!0),ym(this,n[4]),this.a=_m(n[5]||"",!0),gm(this,n[6]||"",!0),this.g=_m(n[7]||"")):(this.h=!!e,this.c=new km(null,this.h))}function pm(t){return new fm(t)}function dm(t,e,n){t.f=n?_m(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function mm(t,e,n){t.b=n?_m(e,!0):e}function ym(t,e){if(e){if(e=Number(e),isNaN(e)||e<0)throw Error("Bad port number "+e);t.i=e}else t.i=null}function gm(t,e,n){e instanceof km?(t.c=e,function(t,e){e&&!t.f&&(Dm(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(Rm(this,e),Pm(this,n,t))},t)),t.f=e}(t.c,t.h)):(n||(e=Tm(e,Nm)),t.c=new km(e,t.h))}function vm(t,e,n){t.c.set(e,n)}function bm(t,e,n){Qf(n)||(n=[String(n)]),Pm(t.c,e,n)}function wm(t){return vm(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^tp()).toString(36)),t}function _m(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Tm(t,e,n){return qf(t)?(t=encodeURI(t).replace(e,Em),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Em(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}fm.prototype.toString=function(){var t=[],e=this.f;e&&t.push(Tm(e,Sm,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(Tm(e,Sm,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.i)&&t.push(":",String(n))),(n=this.a)&&(this.b&&"/"!=n.charAt(0)&&t.push("/"),t.push(Tm(n,"/"==n.charAt(0)?Cm:Im,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",Tm(n,Am)),t.join("")},fm.prototype.resolve=function(t){var e=pm(this),n=!!t.f;n?dm(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?mm(e,t.b):n=null!=t.i;var r=t.a;if(n)ym(e,t.i);else if(n=!!t.a){if("/"!=r.charAt(0))if(this.b&&!this.a)r="/"+r;else{var i=e.a.lastIndexOf("/");-1!=i&&(r=e.a.substr(0,i+1)+r)}if(".."==(i=r)||"."==i)r="";else if(hp(i,"./")||hp(i,"/.")){r=0==i.lastIndexOf("/",0),i=i.split("/");for(var o=[],a=0;a<i.length;){var s=i[a++];"."==s?r&&a==i.length&&o.push(""):".."==s?((1<o.length||1==o.length&&""!=o[0])&&o.pop(),r&&a==i.length&&o.push("")):(o.push(s),r=!0)}r=o.join("/")}else r=i}return n?e.a=r:n=""!==t.c.toString(),n?gm(e,Mm(t.c)):n=!!t.g,n&&(e.g=t.g),e};var Sm=/[#\/\?@]/g,Im=/[#\?:]/g,Cm=/[#\?]/g,Nm=/[#\?@]/g,Am=/#/g;function km(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function Dm(n){n.a||(n.a=new sm,n.b=0,n.c&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var o=t[n].substring(0,r);i=t[n].substring(r+1)}else o=t[n];e(o,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(n.c,function(t,e){n.add(decodeURIComponent(t.replace(/\+/g," ")),e)}))}function Rm(t,e){Dm(t),e=xm(t,e),hm(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,um(t.a,e))}function Om(t,e){return Dm(t),e=xm(t,e),hm(t.a.b,e)}function Pm(t,e,n){Rm(t,e),0<n.length&&(t.c=null,t.a.set(xm(t,e),ap(n)),t.b+=n.length)}function Mm(t){var e=new km;return e.c=t.c,t.a&&(e.a=new sm(t.a),e.b=t.b),e}function xm(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function Lm(t){this.a=t,this.b=this.h=null,this.g=!1,this.i=null,this.c=-1,this.l=this.f=null}function Fm(t){var e=t.a.F.a;if(null!=e)Od(4),e?(Od(10),Iy(t.a,t,!1)):(Od(11),Iy(t.a,t,!0));else{t.b=new Qd(t,void 0,void 0),t.b.h=t.h,e=Dy(e=t.a,e.Y()?t.f:null,t.i),Od(4),bm(e,"TYPE","xmlhttp");var n=t.a.j,r=t.a.I;n&&r&&vm(e,n,r),Xd(t.b,e,!1,t.f)}}function Um(){this.a=this.b=null}function Vm(){this.a=new sm}function qm(t){var e=typeof t;return"object"==e&&t||"function"==e?"o"+(t[zf]||(t[zf]=++Yf)):e.charAt(0)+t}function Bm(t,e){this.b=t,this.a=e}function jm(t){this.g=t||Wm,t=Vf.PerformanceNavigationTiming?0<(t=Vf.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(Vf.ka&&Vf.ka.Da&&Vf.ka.Da()&&Vf.ka.Da().yb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new Vm),this.b=null,this.c=[]}(Lf=km.prototype).add=function(t,e){Dm(this),this.c=null,t=xm(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},Lf.forEach=function(n,r){Dm(this),this.a.forEach(function(t,e){ip(t,function(t){n.call(r,t,e,this)},this)},this)},Lf.K=function(){Dm(this);for(var t=this.a.C(),e=this.a.K(),n=[],r=0;r<e.length;r++)for(var i=t[r],o=0;o<i.length;o++)n.push(e[r]);return n},Lf.C=function(t){Dm(this);var e=[];if(qf(t))Om(this,t)&&(e=op(e,this.a.get(xm(this,t))));else{t=this.a.C();for(var n=0;n<t.length;n++)e=op(e,t[n])}return e},Lf.set=function(t,e){return Dm(this),this.c=null,Om(this,t=xm(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},Lf.get=function(t,e){return t&&0<(t=this.C(t)).length?String(t[0]):e},Lf.toString=function(){if(this.c)return this.c;if(!this.a)return"";for(var t=[],e=this.a.K(),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r));r=this.C(r);for(var o=0;o<r.length;o++){var a=i;""!==r[o]&&(a+="="+encodeURIComponent(String(r[o]))),t.push(a)}}return this.c=t.join("&")},ep(function(){},function(){}),(Lf=Lm.prototype).M=null,Lf.$=function(t){return this.a.$(t)},Lf.abort=function(){this.b&&(this.b.cancel(),this.b=null),this.c=-1},Lf.Ca=function(){return!1},Lf.Fa=function(t,e){if(this.c=t.o,0==this.M){if(!this.a.o&&(t=t.a)){var n=py(t,"X-Client-Wire-Protocol");this.l=n||null,this.a.j&&(t=py(t,"X-HTTP-Session-Id"))&&(this.a.I=t)}if(e){try{var r=this.a.ja.a.parse(e)}catch(t){return(e=this.a).m=this.c,void Ay(e,2)}this.f=r[0]}else(e=this.a).m=this.c,Ay(e,2)}else 1==this.M&&(this.g?Od(6):"11111"==e?(Od(5),this.g=!0,(!Tp||10<=Number(Rp))&&(this.c=200,this.b.cancel(),Od(11),Iy(this.a,this,!0))):(Od(7),this.g=!1))},Lf.na=function(){if(this.c=this.b.o,this.b.b)0==this.M?(this.M=1,Fm(this)):1==this.M&&(this.g?(Od(11),Iy(this.a,this,!0)):(Od(10),Iy(this.a,this,!1)));else{0==this.M?Od(8):1==this.M&&Od(9);var t=this.a;t.m=this.c,Ay(t,2)}},Lf.Y=function(){return this.a.Y()},Lf.ma=function(){return this.a.ma()},Vm.prototype.add=function(t){this.a.set(qm(t),t)},Vm.prototype.C=function(){return this.a.C()};var Wm=10;function Km(t,e){!t.a&&(hp(e,"spdy")||hp(e,"quic")||hp(e,"h2"))&&(t.f=t.g,t.a=new Vm,t.b&&(zm(t,t.b),t.b=null))}function Qm(t){return!!t.b||!!t.a&&t.a.a.c>=t.f}function Hm(t){return t.b?1:t.a?t.a.a.c:0}function Gm(t,e){return t=t.b?t.b==e:!!t.a&&(e=qm(e),hm(t.a.a.b,e))}function zm(t,e){t.a?t.a.add(e):t.b=e}function Ym(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=qm(e),n=hm(t.a.a.b,n)),n&&um(t.a.a,qm(e)))}function Xm(t){if(null!=t.b)return t.c.concat(t.b.j);if(null==t.a||0==t.a.a.c)return ap(t.c);var e=t.c;return ip(t.a.C(),function(t){e=e.concat(t.j)}),e}function Jm(){}function $m(){this.a=new Jm}function Zm(t,r,e){var i=e||"";try{am(t,function(t,e){var n=t;Gf(t)&&(n=sd(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function ty(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}jm.prototype.cancel=function(){this.c=Xm(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(ip(this.a.C(),function(t){t.cancel()}),function(t){t.b={},t.a.length=0,t.c=0}(this.a.a))},Jm.prototype.stringify=function(t){return Vf.JSON.stringify(t,void 0)},Jm.prototype.parse=function(t){return Vf.JSON.parse(t,void 0)};var ey=Vf.JSON.parse;function ny(t){od.call(this),this.headers=new sm,this.H=t||null,this.b=!1,this.s=this.a=null,this.A="",this.h=0,this.f="",this.g=this.w=this.l=this.v=!1,this.o=0,this.m=null,this.I=ry,this.D=this.F=!1}ep(ny,od);var ry="",iy=/^https?$/i,oy=["POST","PUT"];function ay(t){return"content-type"==t.toLowerCase()}function sy(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,uy(t),hy(t)}function uy(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function cy(t){if(t.b&&void 0!==Uf&&(!t.s[1]||4!=fy(t)||2!=t.T()))if(t.l&&4==fy(t))wd(t.Ea,0,t);else if(t.dispatchEvent("readystatechange"),4==fy(t)){t.b=!1;try{var e,n=t.T();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var o=String(t.A).match(lm)[1]||null;if(!o&&Vf.self&&Vf.self.location){var a=Vf.self.location.protocol;o=a.substr(0,a.length-1)}i=!iy.test(o?o.toLowerCase():"")}e=i}if(e)t.dispatchEvent("complete"),t.dispatchEvent("success");else{t.h=6;try{var s=2<fy(t)?t.a.statusText:""}catch(t){s=""}t.f=s+" ["+t.T()+"]",uy(t)}}finally{hy(t)}}}function hy(t,e){if(t.a){ly(t);var n=t.a,r=t.s[0]?Wf:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function ly(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(Vf.clearTimeout(t.m),t.m=null)}function fy(t){return t.a?t.a.readyState:0}function py(t,e){return t.a?t.a.getResponseHeader(e):null}function dy(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}if(r)return t;if(n=function(t){var n="";return dp(t,function(t,e){n+=e,n+=":",n+=t,n+="\r\n"}),n}(n),qf(t)){if(e=encodeURIComponent(String(e)),e+=n=null!=n?"="+encodeURIComponent(String(n)):""){if((n=t.indexOf("#"))<0&&(n=t.length),(r=t.indexOf("?"))<0||n<r){r=n;var i=""}else i=t.substring(r+1,n);n=(t=[t.substr(0,r),i,t.substr(n)])[1],t[1]=e?n?n+"&"+e:e:n,t=t[0]+(t[1]?"?"+t[1]:"")+t[2]}return t}return vm(t,e,n),t}function my(t){this.f=[],this.F=new Um,this.ga=this.pa=this.B=this.ha=this.a=this.I=this.j=this.V=this.g=this.J=this.i=null,this.Qa=this.P=0,this.Oa=!!jf("internalChannelParams.failFast",t),this.ia=this.w=this.s=this.l=this.h=this.c=null,this.oa=!0,this.m=this.ra=this.O=-1,this.S=this.v=this.A=0,this.Na=jf("internalChannelParams.baseRetryDelayMs",t)||5e3,this.Ra=jf("internalChannelParams.retryDelaySeedMs",t)||1e4,this.Pa=jf("internalChannelParams.forwardChannelMaxRetries",t)||2,this.qa=jf("internalChannelParams.forwardChannelRequestTimeoutMs",t)||2e4,this.Ka=t&&t.zb||void 0,this.D=void 0,this.R=t&&t.supportsCrossDomainXhr||!1,this.H="",this.b=new jm(t&&t.concurrentRequestLimit),this.ja=new $m,this.o=!t||void 0===t.backgroundChannelTest||t.backgroundChannelTest,(this.W=t&&t.fastHandshake||!1)&&!this.o&&(this.o=!0),t&&t.forceLongPolling&&(this.oa=!1),this.fa=void 0}function yy(t){if(gy(t),3==t.u){var e=t.P++,n=pm(t.B);vm(n,"SID",t.H),vm(n,"RID",e),vm(n,"TYPE","terminate"),_y(t,n),(e=new Qd(t,e,void 0)).F=2,e.f=wm(pm(n)),n=!1,Vf.navigator&&Vf.navigator.sendBeacon&&(n=Vf.navigator.sendBeacon(e.f.toString(),"")),!n&&Vf.Image&&((new Image).src=e.f,n=!0),n||(e.a=e.g.$(null),e.a.ca(e.f)),e.v=tp(),tm(e)}ky(t)}function gy(t){t.w&&(t.w.abort(),t.w=null),t.a&&(t.a.cancel(),t.a=null),t.l&&(Vf.clearTimeout(t.l),t.l=null),Cy(t),t.b.cancel(),t.h&&(Bf(t.h)&&Vf.clearTimeout(t.h),t.h=null)}function vy(t,e){t.f.push(new Bm(t.Qa++,e)),3==t.u&&by(t)}function by(t){Qm(t.b)||t.h||(t.h=!0,dd(t.Ha,t),t.A=0)}function wy(t,e){var n;n=e?e.W:t.P++;var r=pm(t.B);vm(r,"SID",t.H),vm(r,"RID",n),vm(r,"AID",t.O),_y(t,r),t.g&&t.i&&dy(r,t.g,t.i),n=new Qd(t,n,t.A+1),null===t.g&&(n.h=t.i),e&&(t.f=e.j.concat(t.f)),e=Ty(t,n,1e3),n.setTimeout(Math.round(.5*t.qa)+Math.round(.5*t.qa*Math.random())),zm(t.b,n),Yd(n,r,e)}function _y(t,n){t.c&&am({},function(t,e){vm(n,e,t)})}function Ty(t,e,n){n=Math.min(t.f.length,n);var r=t.c?$f(t.c.Sa,t.c,t):null;t:for(var i=t.f,o=-1;;){var a=["count="+n];-1==o?0<n?(o=i[0].b,a.push("ofs="+o)):o=0:a.push("ofs="+o);for(var s=!0,u=0;u<n;u++){var c=i[u].b,h=i[u].a;if((c-=o)<0)o=Math.max(0,i[u].b-100),s=!1;else try{Zm(h,a,"req"+c+"_")}catch(t){r&&r(h)}}if(s){r=a.join("&");break t}}return t=t.f.splice(0,n),e.j=t,r}function Ey(t){t.a||t.l||(t.S=1,dd(t.Ga,t),t.v=0)}function Sy(t){return!(t.a||t.l||3<=t.v)&&(t.S++,t.l=Md($f(t.Ga,t),Ny(t,t.v)),t.v++,!0)}function Iy(t,e,n){var r=e.l;r&&Km(t.b,r),t.ia=t.oa&&n,t.m=e.c,t.B=Dy(t,null,t.ha),by(t)}function Cy(t){null!=t.s&&(Vf.clearTimeout(t.s),t.s=null)}function Ny(t,e){var n=t.Na+Math.floor(Math.random()*t.Ra);return t.ma()||(n*=2),n*e}function Ay(t,e){if(2==e){var n=null;t.c&&(n=null);var r=$f(t.eb,t);n||(n=new fm("//www.google.com/images/cleardot.gif"),Vf.location&&"http"==Vf.location.protocol||dm(n,"https"),wm(n)),function(t,e){var n=new Nd;if(Vf.Image){var r=new Image;r.onload=Zf(ty,n,r,"TestLoadImage: loaded",!0,e),r.onerror=Zf(ty,n,r,"TestLoadImage: error",!1,e),r.onabort=Zf(ty,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=Zf(ty,n,r,"TestLoadImage: timeout",!1,e),Vf.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=t}else e(!1)}(n.toString(),r)}else Od(2);t.u=0,t.c&&t.c.ta(e),ky(t),gy(t)}function ky(t){t.u=0,t.m=-1,t.c&&(0==Xm(t.b).length&&0==t.f.length||(t.b.c.length=0,ap(t.f),t.f.length=0),t.c.sa())}function Dy(t,e,n){var r=function(t){return t instanceof fm?pm(t):new fm(t,void 0)}(n);if(""!=r.b)e&&mm(r,e+"."+r.b),ym(r,r.i);else{var i,o=Vf.location;i=e?e+"."+o.hostname:o.hostname,r=function(t,e,n,r){var i=new fm(null,void 0);return t&&dm(i,t),e&&mm(i,e),n&&ym(i,n),r&&(i.a=r),i}(o.protocol,i,+o.port,n)}return t.V&&dp(t.V,function(t,e){vm(r,e,t)}),e=t.j,n=t.I,e&&n&&vm(r,e,n),vm(r,"VER",t.wa),_y(t,r),r}function Ry(){}function Oy(){if(Tp&&!(10<=Number(Rp)))throw Error("Environmental error: no available transport.")}function Py(t,e){od.call(this),this.a=new my(e),this.g=t,this.m=e&&e.testUrl?e.testUrl:function(t){for(var e=t,n=1;n<arguments.length;n++){var r,i=arguments[n];if(0==i.lastIndexOf("/",0))e=i;else(r=""==e)||(r=0<=(r=e.length-1)&&e.indexOf("/",r)==r),e+=r?i:"/"+i}return e}(this.g,"test"),this.b=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.a.i=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.xa&&(t?t["X-WebChannel-Client-Profile"]=e.xa:t={"X-WebChannel-Client-Profile":e.xa}),this.a.J=t,(t=e&&e.httpHeadersOverwriteParam)&&!sp(t)&&(this.a.g=t),this.l=e&&e.supportsCrossDomainXhr||!1,this.h=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!sp(e)&&(this.a.j=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new Ly(this)}function My(t){jd.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.c=t)?(t=this.c,this.data=null!==e&&t in e?e[t]:void 0):this.data=e}else this.data=t}function xy(){Wd.call(this),this.status=1}function Ly(t){this.a=t}(Lf=ny.prototype).ca=function(t,e,n,r){if(this.a)throw Error("[goog.net.XhrIo] Object is active with another request="+this.A+"; newUri="+t);e=e?e.toUpperCase():"GET",this.A=t,this.f="",this.h=0,this.v=!1,this.b=!0,this.a=new XMLHttpRequest,this.s=this.H?Ud(this.H):Ud(qd),this.a.onreadystatechange=$f(this.Ea,this);try{this.w=!0,this.a.open(e,String(t),!0),this.w=!1}catch(t){return void sy(this,t)}t=n||"";var i=new sm(this.headers);r&&am(r,function(t,e){i.set(e,t)}),r=function(t){t:{for(var e=ay,n=t.length,r=qf(t)?t.split(""):t,i=0;i<n;i++)if(i in r&&e.call(void 0,r[i],i,t)){e=i;break t}e=-1}return e<0?null:qf(t)?t.charAt(e):t[e]}(i.K()),n=Vf.FormData&&t instanceof Vf.FormData,0<=rp(oy,e)&&!r&&!n&&i.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),i.forEach(function(t,e){this.a.setRequestHeader(e,t)},this),this.I&&(this.a.responseType=this.I),"withCredentials"in this.a&&this.a.withCredentials!==this.F&&(this.a.withCredentials=this.F);try{ly(this),0<this.o&&((this.D=function(t){return Tp&&Pp(9)&&Bf(t.timeout)&&void 0!==t.ontimeout}(this.a))?(this.a.timeout=this.o,this.a.ontimeout=$f(this.Ba,this)):this.m=wd(this.Ba,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){sy(this,t)}},Lf.Ba=function(){void 0!==Uf&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,this.dispatchEvent("timeout"),this.abort(8))},Lf.abort=function(t){this.a&&this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1,this.h=t||7,this.dispatchEvent("complete"),this.dispatchEvent("abort"),hy(this))},Lf.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),hy(this,!0)),ny.N.G.call(this)},Lf.Ea=function(){this.j||(this.w||this.l||this.g?cy(this):this.Za())},Lf.Za=function(){cy(this)},Lf.T=function(){try{return 2<fy(this)?this.a.status:-1}catch(t){return-1}},Lf.aa=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},Lf.Ua=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),ey(e)}},Lf.ya=function(){return this.h},Lf.Xa=function(){return qf(this.f)?this.f:String(this.f)},(Lf=my.prototype).wa=8,Lf.u=1,Lf.Ca=function(){return 0==this.u},Lf.Ha=function(t){if(this.h)if(this.h=null,1==this.u){if(!t){this.P=Math.floor(1e5*Math.random()),t=this.P++;var e,n=new Qd(this,t,void 0),r=this.i;if(this.J&&(r?gp(r=mp(r),this.J):r=this.J),null===this.g&&(n.h=r),this.W)t:{for(var i=e=0;i<this.f.length;i++){var o=this.f[i];if(void 0===(o="__data__"in o.a&&qf(o=o.a.__data__)?o.length:void 0))break;if(4096<(e+=o)){e=i;break t}if(4096===e||i===this.f.length-1){e=i+1;break t}}e=1e3}else e=1e3;e=Ty(this,n,e),vm(i=pm(this.B),"RID",t),vm(i,"CVER",22),this.o&&this.j&&vm(i,"X-HTTP-Session-Id",this.j),_y(this,i),this.g&&r&&dy(i,this.g,r),zm(this.b,n),this.W?(vm(i,"$req",e),vm(i,"SID","null"),n.S=!0,Yd(n,i,null)):Yd(n,i,e),this.u=2}}else 3==this.u&&(t?wy(this,t):0==this.f.length||Qm(this.b)||wy(this))},Lf.Ga=function(){this.l=null,this.a=new Qd(this,"rpc",this.S),null===this.g&&(this.a.h=this.i),this.a.J=0;var t=pm(this.pa);vm(t,"RID","rpc"),vm(t,"SID",this.H),vm(t,"CI",this.ia?"0":"1"),vm(t,"AID",this.O),_y(this,t),vm(t,"TYPE","xmlhttp"),this.g&&this.i&&dy(t,this.g,this.i),this.D&&this.a.setTimeout(this.D),Xd(this.a,t,!0,this.ga)},Lf.Fa=function(t,e){if(0!=this.u&&(this.a==t||Gm(this.b,t)))if(this.m=t.o,!t.s&&Gm(this.b,t)&&3==this.u){try{var n=this.ja.a.parse(e)}catch(t){n=null}if(Qf(n)&&3==n.length){if(0==(e=n)[0]){t:if(!this.l){if(this.a){if(!(this.a.v+3e3<t.v))break t;Cy(this),this.a.cancel(),this.a=null}Sy(this),Od(18)}}else this.ra=e[1],0<this.ra-this.O&&e[2]<37500&&this.ia&&0==this.v&&!this.s&&(this.s=Md($f(this.Ya,this),6e3));if(Hm(this.b)<=1&&this.fa){try{this.fa()}catch(t){}this.fa=void 0}}else Ay(this,11)}else if(!t.s&&this.a!=t||Cy(this),!sp(e))for(e=n=this.ja.a.parse(e),n=0;n<e.length;n++){var r=e[n];if(this.O=r[0],r=r[1],2==this.u)if("c"==r[0]){this.H=r[1],this.ga=r[2];var i=r[3];null!=i&&(this.wa=i),null!=(r=r[5])&&Bf(r)&&0<r&&(this.D=1.5*r),this.o&&(r=t.a)&&((i=py(r,"X-Client-Wire-Protocol"))&&Km(this.b,i),this.j&&(r=py(r,"X-HTTP-Session-Id")))&&(this.I=r,vm(this.B,this.j,r)),this.u=3,this.c&&this.c.va(),r=t,this.pa=Dy(this,this.Y()?this.ga:null,this.ha),r.s?(Ym(this.b,r),(i=this.D)&&r.setTimeout(i),r.i&&(nm(r),tm(r)),this.a=r):Ey(this),0<this.f.length&&by(this)}else"stop"!=r[0]&&"close"!=r[0]||Ay(this,7);else 3==this.u&&("stop"==r[0]||"close"==r[0]?"stop"==r[0]?Ay(this,7):yy(this):"noop"!=r[0]&&this.c&&this.c.ua(r),this.v=0)}},Lf.Ya=function(){null!=this.s&&(this.s=null,this.a.cancel(),this.a=null,Sy(this),Od(19))},Lf.na=function(t){var e=null;if(this.a==t){Cy(this),this.a=null;var n=2}else{if(!Gm(this.b,t))return;e=t.j,Ym(this.b,t),n=1}if(this.m=t.o,0!=this.u)if(t.b)1==n?(e=tp()-t.v,Ad.dispatchEvent(new Pd(Ad,t.l?t.l.length:0,e,this.A)),by(this)):Ey(this);else{var r=t.c;if(3==r||0==r&&0<this.m||!(1==n&&function(t,e){return!(Hm(t.b)>=t.b.f-(t.h?1:0))&&(t.h?(t.f=e.j.concat(t.f),!0):!(1==t.u||2==t.u||t.A>=(t.Oa?0:t.Pa))&&(t.h=Md($f(t.Ha,t,e),Ny(t,t.A)),t.A++,!0))}(this,t)||2==n&&Sy(this)))switch(e&&0<e.length&&(t=this.b,t.c=t.c.concat(e)),r){case 1:Ay(this,5);break;case 4:Ay(this,10);break;case 3:Ay(this,6);break;default:Ay(this,2)}}},Lf.eb=function(t){Od(t?2:1)},Lf.$=function(t){if(t&&!this.R)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new ny(this.Ka)).F=this.R,t},Lf.ma=function(){return!!this.c&&!0},Lf.Y=function(){return this.R},(Lf=Ry.prototype).va=function(){},Lf.ua=function(){},Lf.ta=function(){},Lf.sa=function(){},Lf.Sa=function(){},Oy.prototype.a=function(t,e){return new Py(t,e)},ep(Py,od),(Lf=Py.prototype).addEventListener=function(t,e,n,r){Py.N.addEventListener.call(this,t,e,n,r)},Lf.removeEventListener=function(t,e,n,r){Py.N.removeEventListener.call(this,t,e,n,r)},Lf.Va=function(){this.a.c=this.f,this.l&&(this.a.R=!0);var t=this.a,e=this.m,n=this.g,r=this.b||void 0;Od(0),t.ha=n,t.V=r||{},t.o&&(t.F.b=[],t.F.a=!1),t.w=new Lm(t),null===t.g&&(t.w.h=t.i),n=e,t.g&&t.i&&(n=dy(e,t.g,t.i)),(t=t.w).i=n,e=Dy(t.a,null,t.i),Od(3),null!=(n=t.a.F.b)?(t.f=n[0],t.M=1,Fm(t)):(bm(e,"MODE","init"),!t.a.o&&t.a.j&&bm(e,"X-HTTP-Session-Id",t.a.j),t.b=new Qd(t,void 0,void 0),t.b.h=t.h,Xd(t.b,e,!1,null),t.M=0)},Lf.close=function(){yy(this.a)},Lf.Wa=function(t){if(qf(t)){var e={};e.__data__=t,vy(this.a,e)}else this.h?((e={}).__data__=sd(t),vy(this.a,e)):vy(this.a,t)},Lf.G=function(){this.a.c=null,delete this.f,yy(this.a),delete this.a,Py.N.G.call(this)},ep(My,jd),ep(xy,Wd),ep(Ly,Ry),Ly.prototype.va=function(){this.a.dispatchEvent("a")},Ly.prototype.ua=function(t){this.a.dispatchEvent(new My(t))},Ly.prototype.ta=function(t){this.a.dispatchEvent(new xy(t))},Ly.prototype.sa=function(){this.a.dispatchEvent("b")};var Fy=Zf(function(t,e){function n(){}n.prototype=t.prototype;var r=new n;return t.apply(r,Array.prototype.slice.call(arguments,1)),r},Oy);Oy.prototype.createWebChannel=Oy.prototype.a,Py.prototype.send=Py.prototype.Wa,Py.prototype.open=Py.prototype.Va,Py.prototype.close=Py.prototype.close,xd.NO_ERROR=0,xd.TIMEOUT=8,xd.HTTP_ERROR=6,Ld.COMPLETE="complete",(Vd.EventType=Bd).OPEN="a",Bd.CLOSE="b",Bd.ERROR="c",Bd.MESSAGE="d",od.prototype.listen=od.prototype.za,ny.prototype.listenOnce=ny.prototype.Aa,ny.prototype.getLastError=ny.prototype.Xa,ny.prototype.getLastErrorCode=ny.prototype.ya,ny.prototype.getStatus=ny.prototype.T,ny.prototype.getResponseJson=ny.prototype.Ua,ny.prototype.getResponseText=ny.prototype.aa,ny.prototype.send=ny.prototype.ca;var Uy,Vy,qy={createWebChannelTransport:Fy,ErrorCode:xd,EventType:Ld,WebChannel:Vd,XhrIo:ny},By=qy.createWebChannelTransport,jy=qy.ErrorCode,Wy=qy.EventType,Ky=qy.WebChannel,Qy=qy.XhrIo,Hy=fl.SDK_VERSION,Gy=new bs("@firebase/firestore");function zy(){return Gy.logLevel===ls.DEBUG?Uy.DEBUG:Gy.logLevel===ls.SILENT?Uy.SILENT:Uy.ERROR}function Yy(t){switch(t){case Uy.DEBUG:Gy.logLevel=ls.DEBUG;break;case Uy.ERROR:Gy.logLevel=ls.ERROR;break;case Uy.SILENT:Gy.logLevel=ls.SILENT;break;default:Gy.error("Firestore ("+Hy+"): Invalid value passed to `setLogLevel`")}}function Xy(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(Gy.logLevel<=ls.DEBUG){var i=n.map($y);Gy.debug.apply(Gy,_a(["Firestore ("+Hy+") ["+t+"]: "+e],i))}}function Jy(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(Gy.logLevel<=ls.ERROR){var r=e.map($y);Gy.error.apply(Gy,_a(["Firestore ("+Hy+"): "+t],r))}}function $y(e){if("string"==typeof e)return e;var t=eg.getPlatform();try{return t.formatJSON(e)}catch(t){return e}}function Zy(t){var e="FIRESTORE ("+Hy+") INTERNAL ASSERTION FAILED: "+t;throw Jy(e),new Error(e)}function tg(t,e){t||Zy(e)}(Vy=Uy=Uy||{})[Vy.DEBUG=0]="DEBUG",Vy[Vy.ERROR=1]="ERROR",Vy[Vy.SILENT=2]="SILENT";var eg=(ng.setPlatform=function(t){ng.platform&&Zy("Platform already defined"),ng.platform=t},ng.getPlatform=function(){return ng.platform||Zy("Platform not set"),ng.platform},ng);function ng(){}function rg(){return eg.getPlatform().emptyByteString}var ig,og={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"},ag=(da(sg,ig=Error),sg);function sg(t,e){var n=ig.call(this,e)||this;return n.code=t,n.message=e,n.name="FirebaseError",n.toString=function(){return n.name+": [code="+n.code+"]: "+n.message},n}function ug(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new ag(og.INVALID_ARGUMENT,t)}for(var r in n.prototype=t.prototype,t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n}function cg(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function hg(t,e){return void 0!==t?t:e}function lg(t,e){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=Number(n);isNaN(r)||e(r,t[n])}}function fg(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function pg(t){for(var e in tg(null!=t&&"object"==typeof t,"isEmpty() expects object parameter."),t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function dg(t,e){if(0!==e.length)throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Og(e.length,"argument")+".")}function mg(t,e,n){if(e.length!==n)throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires "+Og(n,"argument")+", but was called with "+Og(e.length,"argument")+".")}function yg(t,e,n){if(e.length<n)throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Og(n,"argument")+", but was called with "+Og(e.length,"argument")+".")}function gg(t,e,n,r){if(e.length<n||e.length>r)throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Og(e.length,"argument")+".")}function vg(t,e,n,r){Sg(t,e,Rg(n)+" argument",r)}function bg(t,e,n,r){void 0!==r&&vg(t,e,n,r)}function wg(t,e,n,r){Sg(t,e,n+" option",r)}function _g(t,e,n,r){void 0!==r&&wg(t,e,n,r)}function Tg(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+Cg(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be "+n+", but the value at index "+o+" was: "+Cg(r[o]))}(t,e,n,r,i)}function Eg(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){for(var o=[],a=0,s=i;a<s.length;a++){var u=s[a];if(u===r)return;o.push(Cg(u))}var c=Cg(r);throw new ag(og.INVALID_ARGUMENT,"Invalid value "+c+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+o.join(", "))}(t,0,n,r,i)}function Sg(t,e,n,r){if(!("object"===e?Ig(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=Cg(r);throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function Ig(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function Cg(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return 20<t.length&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"!=typeof t)return"function"==typeof t?"a function":Zy("Unknown wrong type: "+typeof t);if(t instanceof Array)return"an array";var e=function(t){if(t.constructor){var e=/function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());if(e&&1<e.length)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}function Ng(t,e,n){if(void 0===n)throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+Rg(e)+" argument, but it was undefined.")}function Ag(n,t,r){fg(t,function(t,e){if(r.indexOf(t)<0)throw new ag(og.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function kg(t,e,n,r){var i=Cg(r);return new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires its "+Rg(n)+" argument to be a "+e+", but it was: "+i)}function Dg(t,e,n){if(n<=0)throw new ag(og.INVALID_ARGUMENT,'Function "'+t+'()" requires its '+Rg(e)+" argument to be a positive number, but it was: "+n+".")}function Rg(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function Og(t,e){return t+" "+e+(1===t?"":"s")}var Pg=(Mg.newId=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",n=0;n<20;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return tg(20===e.length,"Invalid auto ID: "+e),e},Mg);function Mg(){}function xg(t,e){return t<e?-1:e<t?1:0}function Lg(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!t[n].isEqual(e[n]))return!1;return!0}function Fg(t){return t+"\0"}function Ug(){if("undefined"==typeof Uint8Array)throw new ag(og.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Vg(){if(!eg.getPlatform().base64Available)throw new ag(og.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var qg=(Bg.fromBase64String=function(t){mg("Blob.fromBase64String",arguments,1),vg("Blob.fromBase64String","string",1,t),Vg();try{return new Bg(eg.getPlatform().atob(t))}catch(t){throw new ag(og.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},Bg.fromUint8Array=function(t){if(mg("Blob.fromUint8Array",arguments,1),Ug(),!(t instanceof Uint8Array))throw kg("Blob.fromUint8Array","Uint8Array",1,t);return new Bg(Array.prototype.map.call(t,function(t){return String.fromCharCode(t)}).join(""))},Bg.prototype.toBase64=function(){return mg("Blob.toBase64",arguments,0),Vg(),eg.getPlatform().btoa(this._binaryString)},Bg.prototype.toUint8Array=function(){mg("Blob.toUint8Array",arguments,0),Ug();for(var t=new Uint8Array(this._binaryString.length),e=0;e<this._binaryString.length;e++)t[e]=this._binaryString.charCodeAt(e);return t},Bg.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},Bg.prototype.isEqual=function(t){return this._binaryString===t._binaryString},Bg.prototype._compareTo=function(t){return xg(this._binaryString,t._binaryString)},Bg);function Bg(t){Vg(),this._binaryString=t}var jg=ug(qg,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),Wg=function(t,e,n,r,i){this.databaseId=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i},Kg="(default)",Qg=(Object.defineProperty(Hg.prototype,"isDefaultDatabase",{get:function(){return this.database===Kg},enumerable:!0,configurable:!0}),Hg.prototype.isEqual=function(t){return t instanceof Hg&&t.projectId===this.projectId&&t.database===this.database},Hg.prototype.compareTo=function(t){return xg(this.projectId,t.projectId)||xg(this.database,t.database)},Hg);function Hg(t,e){this.projectId=t,this.database=e||Kg}var Gg=(zg.prototype.setPreviousValue=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},zg.prototype.next=function(){var t=++this.previousValue;return this.writeNewSequenceNumber&&this.writeNewSequenceNumber(t),t},zg.INVALID=-1,zg);function zg(t,e){var n=this;this.previousValue=t,e&&(e.sequenceNumberHandler=function(t){return n.setPreviousValue(t)},this.writeNewSequenceNumber=function(t){return e.writeSequenceNumber(t)})}var Yg="__name__",Xg=(Object.defineProperty(Jg.prototype,"length",{get:function(){return this.len},enumerable:!0,configurable:!0}),Jg.prototype.isEqual=function(t){return 0===Jg.comparator(this,t)},Jg.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof Jg?t.forEach(function(t){e.push(t)}):e.push(t),this.construct(e)},Jg.prototype.limit=function(){return this.offset+this.length},Jg.prototype.popFirst=function(t){return t=void 0===t?1:t,tg(this.length>=t,"Can't call popFirst() with less segments"),this.construct(this.segments,this.offset+t,this.length-t)},Jg.prototype.popLast=function(){return tg(!this.isEmpty(),"Can't call popLast() on empty path"),this.construct(this.segments,this.offset,this.length-1)},Jg.prototype.firstSegment=function(){return tg(!this.isEmpty(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},Jg.prototype.lastSegment=function(){return this.get(this.length-1)},Jg.prototype.get=function(t){return tg(t<this.length,"Index out of range"),this.segments[this.offset+t]},Jg.prototype.isEmpty=function(){return 0===this.length},Jg.prototype.isPrefixOf=function(t){if(t.length<this.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},Jg.prototype.isImmediateParentOf=function(t){if(this.length+1!==t.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},Jg.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},Jg.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},Jg.comparator=function(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){var i=t.get(r),o=e.get(r);if(i<o)return-1;if(o<i)return 1}return t.length<e.length?-1:t.length>e.length?1:0},Jg);function Jg(t,e,n){void 0===e?e=0:e>t.length&&Zy("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&Zy("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.len=n}var $g,Zg=(da(tv,$g=Xg),tv.prototype.construct=function(t,e,n){return new tv(t,e,n)},tv.prototype.canonicalString=function(){return this.toArray().join("/")},tv.prototype.toString=function(){return this.canonicalString()},tv.fromString=function(t){if(0<=t.indexOf("//"))throw new ag(og.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new tv(t.split("/").filter(function(t){return 0<t.length}))},tv.EMPTY_PATH=new tv([]),tv);function tv(){return null!==$g&&$g.apply(this,arguments)||this}var ev,nv=/^[_a-zA-Z][_a-zA-Z0-9]*$/,rv=(da(iv,ev=Xg),iv.prototype.construct=function(t,e,n){return new iv(t,e,n)},iv.isValidIdentifier=function(t){return nv.test(t)},iv.prototype.canonicalString=function(){return this.toArray().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),iv.isValidIdentifier(t)||(t="`"+t+"`"),t}).join(".")},iv.prototype.toString=function(){return this.canonicalString()},iv.prototype.isKeyField=function(){return 1===this.length&&this.get(0)===Yg},iv.keyField=function(){return new iv([Yg])},iv.fromServerFormat=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new ag(og.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");e.push(n),n=""},o=!1;r<t.length;){var a=t[r];if("\\"===a){if(r+1===t.length)throw new ag(og.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var s=t[r+1];if("\\"!==s&&"."!==s&&"`"!==s)throw new ag(og.INVALID_ARGUMENT,"Path has invalid escape sequence: "+t);n+=s,r+=2}else"`"===a?o=!o:"."!==a||o?n+=a:i(),r++}if(i(),o)throw new ag(og.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new iv(e)},iv.EMPTY_PATH=new iv([]),iv);function iv(){return null!==ev&&ev.apply(this,arguments)||this}var ov=(av.prototype.hasCollectionId=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},av.prototype.isEqual=function(t){return null!==t&&0===Zg.comparator(this.path,t.path)},av.prototype.toString=function(){return this.path.toString()},av.comparator=function(t,e){return Zg.comparator(t.path,e.path)},av.isDocumentKey=function(t){return t.length%2==0},av.fromSegments=function(t){return new av(new Zg(t.slice()))},av.fromPathString=function(t){return new av(Zg.fromString(t))},av.EMPTY=new av(new Zg([])),av);function av(t){this.path=t,tg(av.isDocumentKey(t),"Invalid DocumentKey with an odd number of segments: "+t.toArray().join("/"))}var sv,uv,cv=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})};(uv=sv=sv||{}).All="all",uv.ListenStreamIdle="listen_stream_idle",uv.ListenStreamConnectionBackoff="listen_stream_connection_backoff",uv.WriteStreamIdle="write_stream_idle",uv.WriteStreamConnectionBackoff="write_stream_connection_backoff",uv.OnlineStateTimeout="online_state_timeout",uv.ClientMetadataRefresh="client_metadata_refresh",uv.LruGarbageCollection="lru_garbage_collection",uv.RetryTransaction="retry_transaction";var hv=(lv.createAndSchedule=function(t,e,n,r,i){var o=new lv(t,e,Date.now()+n,r,i);return o.start(n),o},lv.prototype.start=function(t){var e=this;this.timerHandle=setTimeout(function(){return e.handleDelayElapsed()},t)},lv.prototype.skipDelay=function(){return this.handleDelayElapsed()},lv.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new ag(og.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},lv.prototype.handleDelayElapsed=function(){var e=this;this.asyncQueue.enqueueAndForget(function(){return null!==e.timerHandle?(e.clearTimeout(),e.op().then(function(t){return e.deferred.resolve(t)})):Promise.resolve()})},lv.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},lv);function lv(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new cv,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.catch=this.deferred.promise.catch.bind(this.deferred.promise),this.deferred.promise.catch(function(t){})}var fv=(Object.defineProperty(pv.prototype,"isShuttingDown",{get:function(){return this._isShuttingDown},enumerable:!0,configurable:!0}),pv.prototype.enqueueAndForget=function(t){this.enqueue(t)},pv.prototype.enqueueAndForgetEvenAfterShutdown=function(t){this.verifyNotFailed(),this.enqueueInternal(t)},pv.prototype.enqueueEvenAfterShutdown=function(t){return this.verifyNotFailed(),this.enqueueInternal(t)},pv.prototype.enqueueAndInitiateShutdown=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.verifyNotFailed(),this._isShuttingDown?[3,2]:(this._isShuttingDown=!0,[4,this.enqueueEvenAfterShutdown(e)]);case 1:t.sent(),t.label=2;case 2:return[2]}})})},pv.prototype.enqueue=function(t){return this.verifyNotFailed(),this._isShuttingDown?new Promise(function(t){}):this.enqueueInternal(t)},pv.prototype.enqueueInternal=function(t){var n=this,e=this.tail.then(function(){return n.operationInProgress=!0,t().catch(function(t){n.failure=t,n.operationInProgress=!1;var e=t.stack||t.message||"";throw Jy("INTERNAL UNHANDLED ERROR: ",e),e.indexOf("Firestore Test Simulated Error")<0&&setTimeout(function(){throw t},0),t}).then(function(t){return n.operationInProgress=!1,t})});return this.tail=e},pv.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.verifyNotFailed(),tg(0<=e,"Attempted to schedule an operation with a negative delay of "+e),-1<this.timerIdsToSkip.indexOf(t)&&(e=0);var i=hv.createAndSchedule(this,t,e,n,function(t){return r.removeDelayedOperation(t)});return this.delayedOperations.push(i),i},pv.prototype.verifyNotFailed=function(){this.failure&&Zy("AsyncQueue is already failed: "+(this.failure.stack||this.failure.message))},pv.prototype.verifyOperationInProgress=function(){tg(this.operationInProgress,"verifyOpInProgress() called when no op in progress on this queue.")},pv.prototype.drain=function(){return this.enqueueEvenAfterShutdown(function(){return Promise.resolve()})},pv.prototype.containsDelayedOperation=function(t){for(var e=0,n=this.delayedOperations;e<n.length;e++)if(n[e].timerId===t)return!0;return!1},pv.prototype.runDelayedOperationsEarly=function(r){var i=this;return this.drain().then(function(){tg(r===sv.All||i.containsDelayedOperation(r),"Attempted to drain to missing operation "+r),i.delayedOperations.sort(function(t,e){return t.targetTimeMs-e.targetTimeMs});for(var t=0,e=i.delayedOperations;t<e.length;t++){var n=e[t];if(n.skipDelay(),r!==sv.All&&n.timerId===r)break}return i.drain()})},pv.prototype.skipDelaysForTimerId=function(t){this.timerIdsToSkip.push(t)},pv.prototype.removeDelayedOperation=function(t){var e=this.delayedOperations.indexOf(t);tg(0<=e,"Delayed operation not found."),this.delayedOperations.splice(e,1)},pv);function pv(){this.tail=Promise.resolve(),this._isShuttingDown=!1,this.delayedOperations=[],this.failure=null,this.operationInProgress=!1,this.timerIdsToSkip=[]}var dv="",mv="",yv="",gv="";function vv(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=wv(e)),e=bv(t.get(n),e);return wv(e)}function bv(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+=dv+yv;break;case dv:n+=dv+gv;break;default:n+=o}}return n}function wv(t){return t+dv+mv}function _v(t){var e=t.length;if(tg(2<=e,"Invalid path "+t),2===e)return tg(t.charAt(0)===dv&&t.charAt(1)===mv,"Non-empty path "+t+" had length 2"),Zg.EMPTY_PATH;for(var n=e-2,r=[],i="",o=0;o<e;){var a=t.indexOf(dv,o);switch((a<0||n<a)&&Zy('Invalid encoded resource path: "'+t+'"'),t.charAt(a+1)){case mv:var s=t.substring(o,a),u=void 0;0===i.length?u=s:(u=i+=s,i=""),r.push(u);break;case yv:i+=t.substring(o,a),i+="\0";break;case gv:i+=t.substring(o,a+1);break;default:Zy('Invalid encoded resource path: "'+t+'"')}o=a+2}return new Zg(r)}var Tv=(Ev.now=function(){return Ev.fromMillis(Date.now())},Ev.fromDate=function(t){return Ev.fromMillis(t.getTime())},Ev.fromMillis=function(t){var e=Math.floor(t/1e3);return new Ev(e,1e6*(t-1e3*e))},Ev.prototype.toDate=function(){return new Date(this.toMillis())},Ev.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},Ev.prototype._compareTo=function(t){return this.seconds===t.seconds?xg(this.nanoseconds,t.nanoseconds):xg(this.seconds,t.seconds)},Ev.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},Ev.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},Ev);function Ev(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new ag(og.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new ag(og.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new ag(og.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new ag(og.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}var Sv=(Iv.fromMicroseconds=function(t){var e=Math.floor(t/1e6);return new Iv(new Tv(e,t%1e6*1e3))},Iv.fromTimestamp=function(t){return new Iv(t)},Iv.forDeletedDoc=function(){return Iv.MIN},Iv.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},Iv.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},Iv.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},Iv.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},Iv.prototype.toTimestamp=function(){return this.timestamp},Iv.MIN=new Iv(new Tv(0,0)),Iv);function Iv(t){this.timestamp=t}var Cv=(Nv.prototype.insert=function(t,e){return new Nv(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,Dv.BLACK,null,null))},Nv.prototype.remove=function(t){return new Nv(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Dv.BLACK,null,null))},Nv.prototype.get=function(t){for(var e=this.root;!e.isEmpty();){var n=this.comparator(t,e.key);if(0===n)return e.value;n<0?e=e.left:0<n&&(e=e.right)}return null},Nv.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.isEmpty();){var r=this.comparator(t,n.key);if(0===r)return e+n.left.size;n=r<0?n.left:(e+=n.left.size+1,n.right)}return-1},Nv.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(Nv.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),Nv.prototype.minKey=function(){return this.root.minKey()},Nv.prototype.maxKey=function(){return this.root.maxKey()},Nv.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},Nv.prototype.forEach=function(n){this.inorderTraversal(function(t,e){return n(t,e),!1})},Nv.prototype.toString=function(){var n=[];return this.inorderTraversal(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},Nv.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},Nv.prototype.getIterator=function(){return new Av(this.root,null,this.comparator,!1)},Nv.prototype.getIteratorFrom=function(t){return new Av(this.root,t,this.comparator,!1)},Nv.prototype.getReverseIterator=function(){return new Av(this.root,null,this.comparator,!0)},Nv.prototype.getReverseIteratorFrom=function(t){return new Av(this.root,t,this.comparator,!0)},Nv);function Nv(t,e){this.comparator=t,this.root=e||Dv.EMPTY}var Av=(kv.prototype.getNext=function(){tg(0<this.nodeStack.length,"getNext() called on iterator when hasNext() is false.");var 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},kv.prototype.hasNext=function(){return 0<this.nodeStack.length},kv.prototype.peek=function(){if(0===this.nodeStack.length)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},kv);function kv(t,e,n,r){this.isReverse=r,this.nodeStack=[];for(var i=1;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}var Dv=(Rv.prototype.copy=function(t,e,n,r,i){return new Rv(null!=t?t:this.key,null!=e?e:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)},Rv.prototype.isEmpty=function(){return!1},Rv.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},Rv.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},Rv.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},Rv.prototype.minKey=function(){return this.min().key},Rv.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},Rv.prototype.insert=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n))).fixUp()},Rv.prototype.removeMin=function(){if(this.left.isEmpty())return Rv.EMPTY;var t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),(t=t.copy(null,null,null,t.left.removeMin(),null)).fixUp()},Rv.prototype.remove=function(t,e){var n,r=this;if(e(t,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(t,e),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===e(t,r.key)){if(r.right.isEmpty())return Rv.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(t,e))}return r.fixUp()},Rv.prototype.isRed=function(){return this.color},Rv.prototype.fixUp=function(){var 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},Rv.prototype.moveRedLeft=function(){var t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t},Rv.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},Rv.prototype.rotateLeft=function(){var t=this.copy(null,null,Rv.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},Rv.prototype.rotateRight=function(){var t=this.copy(null,null,Rv.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},Rv.prototype.colorFlip=function(){var 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)},Rv.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},Rv.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw Zy("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed())throw Zy("Right child of ("+this.key+","+this.value+") is red");var t=this.left.check();if(t!==this.right.check())throw Zy("Black depths differ");return t+(this.isRed()?0:1)},Rv.EMPTY=null,Rv.RED=!0,Rv.BLACK=!1,Rv);function Rv(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:Rv.RED,this.left=null!=r?r:Rv.EMPTY,this.right=null!=i?i:Rv.EMPTY,this.size=this.left.size+1+this.right.size}var Ov=(Object.defineProperty(Pv.prototype,"key",{get:function(){throw Zy("LLRBEmptyNode has no key.")},enumerable:!0,configurable:!0}),Object.defineProperty(Pv.prototype,"value",{get:function(){throw Zy("LLRBEmptyNode has no value.")},enumerable:!0,configurable:!0}),Object.defineProperty(Pv.prototype,"color",{get:function(){throw Zy("LLRBEmptyNode has no color.")},enumerable:!0,configurable:!0}),Object.defineProperty(Pv.prototype,"left",{get:function(){throw Zy("LLRBEmptyNode has no left child.")},enumerable:!0,configurable:!0}),Object.defineProperty(Pv.prototype,"right",{get:function(){throw Zy("LLRBEmptyNode has no right child.")},enumerable:!0,configurable:!0}),Pv.prototype.copy=function(t,e,n,r,i){return this},Pv.prototype.insert=function(t,e,n){return new Dv(t,e)},Pv.prototype.remove=function(t,e){return this},Pv.prototype.isEmpty=function(){return!0},Pv.prototype.inorderTraversal=function(t){return!1},Pv.prototype.reverseTraversal=function(t){return!1},Pv.prototype.minKey=function(){return null},Pv.prototype.maxKey=function(){return null},Pv.prototype.isRed=function(){return!1},Pv.prototype.checkMaxDepth=function(){return!0},Pv.prototype.check=function(){return 0},Pv);function Pv(){this.size=0}Dv.EMPTY=new Ov;var Mv=(xv.fromMapKeys=function(t){var e=new xv(t.comparator);return t.forEach(function(t){e=e.add(t)}),e},xv.prototype.has=function(t){return null!==this.data.get(t)},xv.prototype.first=function(){return this.data.minKey()},xv.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(xv.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),xv.prototype.indexOf=function(t){return this.data.indexOf(t)},xv.prototype.forEach=function(n){this.data.inorderTraversal(function(t,e){return n(t),!1})},xv.prototype.forEachInRange=function(t,e){for(var n=this.data.getIteratorFrom(t[0]);n.hasNext();){var r=n.getNext();if(0<=this.comparator(r.key,t[1]))return;e(r.key)}},xv.prototype.forEachWhile=function(t,e){var n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return},xv.prototype.firstAfterOrEqual=function(t){var e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null},xv.prototype.getIterator=function(){return new Lv(this.data.getIterator())},xv.prototype.getIteratorFrom=function(t){return new Lv(this.data.getIteratorFrom(t))},xv.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},xv.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},xv.prototype.isEmpty=function(){return this.data.isEmpty()},xv.prototype.unionWith=function(t){var e=this;return t.forEach(function(t){e=e.add(t)}),e},xv.prototype.isEqual=function(t){if(!(t instanceof xv))return!1;if(this.size!==t.size)return!1;for(var e=this.data.getIterator(),n=t.data.getIterator();e.hasNext();){var r=e.getNext().key,i=n.getNext().key;if(0!==this.comparator(r,i))return!1}return!0},xv.prototype.toArray=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},xv.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},xv.prototype.copy=function(t){var e=new xv(this.comparator);return e.data=t,e},xv);function xv(t){this.comparator=t,this.data=new Cv(this.comparator)}var Lv=(Fv.prototype.getNext=function(){return this.iter.getNext().key},Fv.prototype.hasNext=function(){return this.iter.hasNext()},Fv);function Fv(t){this.iter=t}var Uv=new Cv(ov.comparator);function Vv(){return Uv}function qv(){return Vv()}var Bv=new Cv(ov.comparator);function jv(){return Bv}var Wv=new Cv(ov.comparator);function Kv(){return Wv}var Qv=new Mv(ov.comparator);function Hv(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Qv,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Gv=new Mv(xg);function zv(){return Gv}var Yv=(Xv.prototype.applyToRemoteDocument=function(t,e,n){e&&tg(e.key.isEqual(t),"applyToRemoteDocument: key "+t+" should match maybeDoc key\n        "+e.key);var r=n.mutationResults;tg(r.length===this.mutations.length,"Mismatch between mutations length\n      ("+this.mutations.length+") and mutation results length\n      ("+r.length+").");for(var i=0;i<this.mutations.length;i++){var o=this.mutations[i];if(o.key.isEqual(t)){var a=r[i];e=o.applyToRemoteDocument(e,a)}}return e},Xv.prototype.applyToLocalView=function(t,e){e&&tg(e.key.isEqual(t),"applyToLocalDocument: key "+t+" should match maybeDoc key\n        "+e.key);for(var n=0,r=this.baseMutations;n<r.length;n++)(s=r[n]).key.isEqual(t)&&(e=s.applyToLocalView(e,e,this.localWriteTime));for(var i=e,o=0,a=this.mutations;o<a.length;o++){var s;(s=a[o]).key.isEqual(t)&&(e=s.applyToLocalView(e,i,this.localWriteTime))}return e},Xv.prototype.applyToLocalDocumentSet=function(n){var r=this,i=n;return this.mutations.forEach(function(t){var e=r.applyToLocalView(t.key,n.get(t.key));e&&(i=i.insert(t.key,e))}),i},Xv.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},Hv())},Xv.prototype.isEqual=function(t){return this.batchId===t.batchId&&Lg(this.mutations,t.mutations)&&Lg(this.baseMutations,t.baseMutations)},Xv);function Xv(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,tg(0<(this.mutations=r).length,"Cannot create an empty mutation batch")}var Jv=($v.from=function(t,e,n,r){tg(t.mutations.length===n.length,"Mutations sent "+t.mutations.length+" must equal results received "+n.length);for(var i=Kv(),o=t.mutations,a=0;a<o.length;a++)i=i.insert(o[a].key,n[a].version);return new $v(t,e,n,r,i)},$v);function $v(t,e,n,r,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.streamToken=r,this.docVersions=i}var Zv=(tb.prototype.catch=function(t){return this.next(void 0,t)},tb.prototype.next=function(r,i){var o=this;return this.callbackAttached&&Zy("Called next() or catch() twice for PersistencePromise"),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(i,this.error):this.wrapSuccess(r,this.result):new tb(function(e,n){o.nextCallback=function(t){o.wrapSuccess(r,t).next(e,n)},o.catchCallback=function(t){o.wrapFailure(i,t).next(e,n)}})},tb.prototype.toPromise=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},tb.prototype.wrapUserFunction=function(t){try{var e=t();return e instanceof tb?e:tb.resolve(e)}catch(t){return tb.reject(t)}},tb.prototype.wrapSuccess=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):tb.resolve(e)},tb.prototype.wrapFailure=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):tb.reject(e)},tb.resolve=function(n){return new tb(function(t,e){t(n)})},tb.reject=function(n){return new tb(function(t,e){e(n)})},tb.waitFor=function(t){return new tb(function(e,n){var r=0,i=0,o=!1;t.forEach(function(t){++r,t.next(function(){++i,o&&i===r&&e()},function(t){return n(t)})}),o=!0,i===r&&e()})},tb.or=function(t){for(var n=tb.resolve(!1),e=function(e){n=n.next(function(t){return t?tb.resolve(t):e()})},r=0,i=t;r<i.length;r++)e(i[r]);return n},tb.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.waitFor(i)},tb);function tb(t){var e=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t(function(t){e.isDone=!0,e.result=t,e.nextCallback&&e.nextCallback(t)},function(t){e.isDone=!0,e.error=t,e.catchCallback&&e.catchCallback(t)})}var eb="SimpleDb",nb=(rb.openOrCreate=function(o,t,a){return tg(rb.isAvailable(),"IndexedDB not supported in current environment."),Xy(eb,"Opening database:",o),new Zv(function(n,r){var i=window.indexedDB.open(o,t);i.onsuccess=function(t){var e=t.target.result;n(new rb(e))},i.onblocked=function(){r(new ag(og.FAILED_PRECONDITION,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(t){var e=t.target.error;"VersionError"===e.name?r(new ag(og.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):r(e)},i.onupgradeneeded=function(t){Xy(eb,'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;a.createOrUpgrade(e,i.transaction,t.oldVersion,__).next(function(){Xy(eb,"Database upgrade to version "+__+" complete")})}}).toPromise()},rb.delete=function(t){return Xy(eb,"Removing database:",t),hb(window.indexedDB.deleteDatabase(t)).toPromise()},rb.isAvailable=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(rb.isMockPersistence())return!0;if(void 0===window.navigator)return!1;var t=Oa(),e=rb.getIOSVersion(t),n=0<e&&e<10,r=rb.getAndroidVersion(t),i=0<r&&r<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||i)},rb.isMockPersistence=function(){var t;return"undefined"!=typeof process&&"YES"===(null===(t=process.env)||void 0===t?void 0:t.USE_MOCK_PERSISTENCE)},rb.getStore=function(t,e){return t.store(e)},rb.getIOSVersion=function(t){var e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)},rb.getAndroidVersion=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},rb.prototype.setVersionChangeListener=function(e){this.db.onversionchange=function(t){return e(t)}},rb.prototype.runTransaction=function(r,c,h){return ya(this,void 0,void 0,function(){var o,a,s,e,u,n;return ga(this,function(t){switch(t.label){case 0:o=r.startsWith("readonly"),a=r.endsWith("idempotent"),s=0,e=function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:++s,e=ab.open(u.db,o?"readonly":"readwrite",c),t.label=1;case 1:return t.trys.push([1,3,,4]),(n=h(e).catch(function(t){return e.abort(t),Zv.reject(t)}).toPromise()).catch(function(){}),[4,e.completionPromise];case 2:return t.sent(),[2,{value:n}];case 3:return r=t.sent(),i=a&&"FirebaseError"!==r.name&&s<3,Xy(eb,"Transaction failed with error: %s. Retrying: %s.",r.message,i),i?[3,4]:[2,{value:Promise.reject(r)}];case 4:return[2]}})},u=this,t.label=1;case 1:return[5,e()];case 2:return"object"==typeof(n=t.sent())?[2,n.value]:[3,1];case 3:return[2]}})})},rb.prototype.close=function(){this.db.close()},rb);function rb(t){this.db=t,12.2===rb.getIOSVersion(Oa())&&Jy("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}var ib=(Object.defineProperty(ob.prototype,"isDone",{get:function(){return this.shouldStop},enumerable:!0,configurable:!0}),Object.defineProperty(ob.prototype,"skipToKey",{get:function(){return this.nextKey},enumerable:!0,configurable:!0}),Object.defineProperty(ob.prototype,"cursor",{set:function(t){this.dbCursor=t},enumerable:!0,configurable:!0}),ob.prototype.done=function(){this.shouldStop=!0},ob.prototype.skip=function(t){this.nextKey=t},ob.prototype.delete=function(){return hb(this.dbCursor.delete())},ob);function ob(t){this.dbCursor=t,this.shouldStop=!1,this.nextKey=null}var ab=(sb.open=function(t,e,n){return new sb(t.transaction(n,e))},Object.defineProperty(sb.prototype,"completionPromise",{get:function(){return this.completionDeferred.promise},enumerable:!0,configurable:!0}),sb.prototype.abort=function(t){t&&this.completionDeferred.reject(t),this.aborted||(Xy(eb,"Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},sb.prototype.store=function(t){var e=this.transaction.objectStore(t);return tg(!!e,"Object store not part of transaction: "+t),new ub(e)},sb);function sb(t){var n=this;this.transaction=t,this.aborted=!1,this.completionDeferred=new cv,this.transaction.oncomplete=function(){n.completionDeferred.resolve()},this.transaction.onabort=function(){t.error?n.completionDeferred.reject(t.error):n.completionDeferred.resolve()},this.transaction.onerror=function(t){var e=fb(t.target.error);n.completionDeferred.reject(e)}}var ub=(cb.prototype.put=function(t,e){return hb(void 0!==e?(Xy(eb,"PUT",this.store.name,t,e),this.store.put(e,t)):(Xy(eb,"PUT",this.store.name,"<auto-key>",t),this.store.put(t)))},cb.prototype.add=function(t){return Xy(eb,"ADD",this.store.name,t,t),hb(this.store.add(t))},cb.prototype.get=function(e){var n=this;return hb(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Xy(eb,"GET",n.store.name,e,t),t})},cb.prototype.delete=function(t){return Xy(eb,"DELETE",this.store.name,t),hb(this.store.delete(t))},cb.prototype.count=function(){return Xy(eb,"COUNT",this.store.name),hb(this.store.count())},cb.prototype.loadAll=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.iterateCursor(n,function(t,e){r.push(e)}).next(function(){return r})},cb.prototype.deleteAll=function(t,e){Xy(eb,"DELETE ALL",this.store.name);var n=this.options(t,e);n.keysOnly=!1;var r=this.cursor(n);return this.iterateCursor(r,function(t,e,n){return n.delete()})},cb.prototype.iterate=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.iterateCursor(r,e)},cb.prototype.iterateSerial=function(i){var t=this.cursor({});return new Zv(function(n,r){t.onerror=function(t){var e=fb(t.target.error);r(e)},t.onsuccess=function(t){var e=t.target.result;e?i(e.primaryKey,e.value).next(function(t){t?e.continue():n()}):n()}})},cb.prototype.iterateCursor=function(t,a){var s=[];return new Zv(function(o,e){t.onerror=function(t){e(t.target.error)},t.onsuccess=function(t){var e=t.target.result;if(e){var n=new ib(e),r=a(e.primaryKey,e.value,n);if(r instanceof Zv){var i=r.catch(function(t){return n.done(),Zv.reject(t)});s.push(i)}n.isDone?o():null===n.skipToKey?e.continue():e.continue(n.skipToKey)}else o()}}).next(function(){return Zv.waitFor(s)})},cb.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(tg(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},cb.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.keysOnly?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},cb);function cb(t){this.store=t}function hb(t){return new Zv(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=fb(t.target.error);r(e)}})}var lb=!1;function fb(t){var e=nb.getIOSVersion(Oa());if(12.2<=e&&e<13){var n="An internal error was encountered in the Indexed Database server";if(0<=t.message.indexOf(n)){var r=new ag("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return lb||(lb=!0,setTimeout(function(){throw r},0)),r}}return t}var pb=(db.forUser=function(t,e,n,r){return tg(""!==t.uid,"UserID must not be an empty string."),new db(t.isAuthenticated()?t.uid:"",e,n,r)},db.prototype.checkEmpty=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return vb(t).iterate({index:k_.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},db.prototype.acknowledgeBatch=function(e,t,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=gb(n),wb(e).put(t)})},db.prototype.getLastStreamToken=function(t){return this.getMutationQueueMetadata(t).next(function(t){return t.lastStreamToken})},db.prototype.setLastStreamToken=function(e,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=gb(n),wb(e).put(t)})},db.prototype.addMutationBatch=function(c,h,l,f){var p=this,d=bb(c),m=vb(c);return m.add({}).next(function(t){tg("number"==typeof t,"Auto-generated key is not a number");for(var e=new Yv(t,h,l,f),n=p.serializer.toDbMutationBatch(p.userId,e),r=[],i=new Mv(function(t,e){return xg(t.canonicalString(),e.canonicalString())}),o=0,a=f;o<a.length;o++){var s=a[o],u=R_.key(p.userId,s.key.path,t);i=i.add(s.key.path.popLast()),r.push(m.put(n)),r.push(d.put(u,R_.PLACEHOLDER))}return i.forEach(function(t){r.push(p.indexManager.addToCollectionParentIndex(c,t))}),c.addOnCommittedListener(function(){p.documentKeysByBatchId[t]=e.keys()}),Zv.waitFor(r).next(function(){return e})})},db.prototype.lookupMutationBatch=function(t,e){var n=this;return vb(t).get(e).next(function(t){return t?(tg(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),n.serializer.fromDbMutationBatch(t)):null})},db.prototype.lookupMutationKeys=function(t,n){var r=this;return this.documentKeysByBatchId[n]?Zv.resolve(this.documentKeysByBatchId[n]):this.lookupMutationBatch(t,n).next(function(t){if(t){var e=t.keys();return r.documentKeysByBatchId[n]=e}return null})},db.prototype.getNextMutationBatchAfterBatchId=function(t,e){var r=this,i=e+1,n=IDBKeyRange.lowerBound([this.userId,i]),o=null;return vb(t).iterate({index:k_.userMutationsIndex,range:n},function(t,e,n){e.userId===r.userId&&(tg(e.batchId>=i,"Should have found mutation after "+i),o=r.serializer.fromDbMutationBatch(e)),n.done()}).next(function(){return o})},db.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return vb(t).iterate({index:k_.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},db.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return vb(t).loadAll(k_.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.fromDbMutationBatch(t)})})},db.prototype.getAllMutationBatchesAffectingDocumentKey=function(s,u){var c=this,t=R_.prefixForPath(this.userId,u.path),e=IDBKeyRange.lowerBound(t),h=[];return bb(s).iterate({range:e},function(e,t,n){var r=e[0],i=e[1],o=e[2],a=_v(i);if(r===c.userId&&u.path.isEqual(a))return vb(s).get(o).next(function(t){if(!t)throw Zy("Dangling document-mutation reference found: "+e+" which points to "+o);tg(t.userId===c.userId,"Unexpected user '"+t.userId+"' for mutation batch "+o),h.push(c.serializer.fromDbMutationBatch(t))});n.done()}).next(function(){return h})},db.prototype.getAllMutationBatchesAffectingDocumentKeys=function(r,t){var u=this,c=new Mv(xg),i=[];return t.forEach(function(s){var t=R_.prefixForPath(u.userId,s.path),e=IDBKeyRange.lowerBound(t),n=bb(r).iterate({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=_v(i);r===u.userId&&s.path.isEqual(a)?c=c.add(o):n.done()});i.push(n)}),Zv.waitFor(i).next(function(){return u.lookupMutationBatches(r,c)})},db.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var s=this;tg(!e.isDocumentQuery(),"Document queries shouldn't go down this path"),tg(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var u=e.path,c=u.length+1,n=R_.prefixForPath(this.userId,u),r=IDBKeyRange.lowerBound(n),h=new Mv(xg);return bb(t).iterate({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=_v(i);r===s.userId&&u.isPrefixOf(a)?a.length===c&&(h=h.add(o)):n.done()}).next(function(){return s.lookupMutationBatches(t,h)})},db.prototype.lookupMutationBatches=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(vb(t).get(e).next(function(t){if(null===t)throw Zy("Dangling document-mutation reference found, which points to "+e);tg(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.fromDbMutationBatch(t))}))}),Zv.waitFor(i).next(function(){return r})},db.prototype.removeMutationBatch=function(e,n){var r=this;return yb(e.simpleDbTransaction,this.userId,n).next(function(t){return e.addOnCommittedListener(function(){r.removeCachedMutationKeys(n.batchId)}),Zv.forEach(t,function(t){return r.referenceDelegate.removeMutationReference(e,t)})})},db.prototype.removeCachedMutationKeys=function(t){delete this.documentKeysByBatchId[t]},db.prototype.performConsistencyCheck=function(n){var o=this;return this.checkEmpty(n).next(function(t){if(!t)return Zv.resolve();var e=IDBKeyRange.lowerBound(R_.prefixForUser(o.userId)),i=[];return bb(n).iterate({range:e},function(t,e,n){if(t[0]===o.userId){var r=_v(t[1]);i.push(r)}else n.done()}).next(function(){tg(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.canonicalString()}))})})},db.prototype.containsKey=function(t,e){return mb(t,this.userId,e)},db.prototype.getMutationQueueMetadata=function(t){var e=this;return wb(t).get(this.userId).next(function(t){return t||new N_(e.userId,-1,"")})},db);function db(t,e,n,r){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=r,this.documentKeysByBatchId={}}function mb(t,o,e){var n=R_.prefixForPath(o,e.path),a=n[1],r=IDBKeyRange.lowerBound(n),s=!1;return bb(t).iterate({range:r,keysOnly:!0},function(t,e,n){var r=t[0],i=t[1];t[2];r===o&&i===a&&(s=!0),n.done()}).next(function(){return s})}function yb(t,e,n){var r=t.store(k_.store),i=t.store(R_.store),o=[],a=IDBKeyRange.only(n.batchId),s=0,u=r.iterate({range:a},function(t,e,n){return s++,n.delete()});o.push(u.next(function(){tg(1===s,"Dangling document-mutation reference found: Missing batch "+n.batchId)}));for(var c=[],h=0,l=n.mutations;h<l.length;h++){var f=l[h],p=R_.key(e,f.key.path,n.batchId);o.push(i.delete(p)),c.push(f.key)}return Zv.waitFor(o).next(function(){return c})}function gb(t){return t instanceof Uint8Array?(tg(nb.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence."),t.toString()):t}function vb(t){return ST.getStore(t,k_.store)}function bb(t){return ST.getStore(t,R_.store)}function wb(t){return ST.getStore(t,N_.store)}var _b,Tb;(Tb=_b=_b||{})[Tb.QueryCache=0]="QueryCache",Tb[Tb.SyncEngine=1]="SyncEngine";var Eb=(Sb.prototype.next=function(){var t=this.nextId;return this.nextId+=2,t},Sb.prototype.after=function(t){return this.seek(t+2),this.next()},Sb.prototype.seek=function(t){tg((1&t)===this.generatorId,"Cannot supply target ID from different generator ID"),this.nextId=t},Sb.forTargetCache=function(){return new Sb(_b.QueryCache,2)},Sb.forSyncEngine=function(){return new Sb(_b.SyncEngine)},Sb);function Sb(t,e){tg((1&(this.generatorId=t))===t,"Generator ID "+t+" contains more than 1 reserved bits"),this.seek(void 0!==e?e:this.generatorId)}var Ib=(Cb.prototype.allocateTargetId=function(e){var n=this;return this.retrieveMetadata(e).next(function(t){return t.highestTargetId=n.targetIdGenerator.after(t.highestTargetId),n.saveMetadata(e,t).next(function(){return t.highestTargetId})})},Cb.prototype.getLastRemoteSnapshotVersion=function(t){return this.retrieveMetadata(t).next(function(t){return Sv.fromTimestamp(new Tv(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},Cb.prototype.getHighestSequenceNumber=function(t){return kb(t.simpleDbTransaction)},Cb.prototype.setTargetsMetadata=function(e,n,r){var i=this;return this.retrieveMetadata(e).next(function(t){return t.highestListenSequenceNumber=n,r&&(t.lastRemoteSnapshotVersion=r.toTimestamp()),n>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=n),i.saveMetadata(e,t)})},Cb.prototype.addTargetData=function(e,n){var r=this;return this.saveTargetData(e,n).next(function(){return r.retrieveMetadata(e).next(function(t){return t.targetCount+=1,r.updateMetadataFromTargetData(n,t),r.saveMetadata(e,t)})})},Cb.prototype.updateTargetData=function(t,e){return this.saveTargetData(t,e)},Cb.prototype.removeTargetData=function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return Nb(e).delete(t.targetId)}).next(function(){return n.retrieveMetadata(e)}).next(function(t){return tg(0<t.targetCount,"Removing from an empty target cache"),t.targetCount-=1,n.saveMetadata(e,t)})},Cb.prototype.removeTargets=function(r,i,o){var a=this,s=0,u=[];return Nb(r).iterate(function(t,e){var n=a.serializer.fromDbTarget(e);n.sequenceNumber<=i&&null===o.get(n.targetId)&&(s++,u.push(a.removeTargetData(r,n)))}).next(function(){return Zv.waitFor(u)}).next(function(){return s})},Cb.prototype.forEachTarget=function(t,r){var i=this;return Nb(t).iterate(function(t,e){var n=i.serializer.fromDbTarget(e);r(n)})},Cb.prototype.retrieveMetadata=function(t){return Ab(t.simpleDbTransaction)},Cb.prototype.saveMetadata=function(t,e){return function(t){return ST.getStore(t,W_.store)}(t).put(W_.key,e)},Cb.prototype.saveTargetData=function(t,e){return Nb(t).put(this.serializer.toDbTarget(e))},Cb.prototype.updateMetadataFromTargetData=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},Cb.prototype.getTargetCount=function(t){return this.retrieveMetadata(t).next(function(t){return t.targetCount})},Cb.prototype.getTargetData=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),a=null;return Nb(t).iterate({range:n,index:V_.queryTargetsIndexName},function(t,e,n){var r=o.serializer.fromDbTarget(e);i.isEqual(r.target)&&(a=r,n.done())}).next(function(){return a})},Cb.prototype.addMatchingKeys=function(n,t,r){var i=this,o=[],a=Db(n);return t.forEach(function(t){var e=vv(t.path);o.push(a.put(new B_(r,e))),o.push(i.referenceDelegate.addReference(n,t))}),Zv.waitFor(o)},Cb.prototype.removeMatchingKeys=function(n,t,r){var i=this,o=Db(n);return Zv.forEach(t,function(t){var e=vv(t.path);return Zv.waitFor([o.delete([r,e]),i.referenceDelegate.removeReference(n,t)])})},Cb.prototype.removeMatchingKeysForTargetId=function(t,e){var n=Db(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},Cb.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Db(t),o=Hv();return r.iterate({range:n,keysOnly:!0},function(t,e,n){var r=_v(t[1]),i=new ov(r);o=o.add(i)}).next(function(){return o})},Cb.prototype.containsKey=function(t,e){var n=vv(e.path),r=IDBKeyRange.bound([n],[Fg(n)],!1,!0),i=0;return Db(t).iterate({index:B_.documentTargetsIndex,keysOnly:!0,range:r},function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())}).next(function(){return 0<i})},Cb.prototype.getTargetDataForTarget=function(t,e){var n=this;return Nb(t).get(e).next(function(t){return t?n.serializer.fromDbTarget(t):null})},Cb);function Cb(t,e){this.referenceDelegate=t,this.serializer=e,this.targetIdGenerator=Eb.forTargetCache()}function Nb(t){return ST.getStore(t,V_.store)}function Ab(t){return nb.getStore(t,W_.store).get(W_.key).next(function(t){return tg(null!==t,"Missing metadata row."),t})}function kb(t){return Ab(t).next(function(t){return t.highestListenSequenceNumber})}function Db(t){return ST.getStore(t,B_.store)}var Rb=(Ob.fromSet=function(t){return new Ob(t)},Ob.fromArray=function(t){var e=new Mv(rv.comparator);return t.forEach(function(t){return e=e.add(t)}),new Ob(e)},Ob.prototype.covers=function(e){var n=!1;return this.fields.forEach(function(t){t.isPrefixOf(e)&&(n=!0)}),n},Ob.prototype.isEqual=function(t){return this.fields.isEqual(t.fields)},Ob);function Ob(t){this.fields=t}var Pb=(Mb.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},Mb);function Mb(t,e){this.field=t,this.transform=e}var xb,Lb,Fb=function(t,e){this.version=t,this.transformResults=e};(Lb=xb=xb||{})[Lb.Set=0]="Set",Lb[Lb.Patch=1]="Patch",Lb[Lb.Transform=2]="Transform",Lb[Lb.Delete=3]="Delete";var Ub=(Vb.exists=function(t){return new Vb(void 0,t)},Vb.updateTime=function(t){return new Vb(t)},Object.defineProperty(Vb.prototype,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),Vb.prototype.isValidFor=function(t){return void 0!==this.updateTime?t instanceof Jw&&t.version.isEqual(this.updateTime):void 0!==this.exists?this.exists===t instanceof Jw:(tg(this.isNone,"Precondition should be empty"),!0)},Vb.prototype.isEqual=function(t){return function(t,e){return null!=t?!(!e||!t.isEqual(e)):t===e}(this.updateTime,t.updateTime)&&this.exists===t.exists},Vb.NONE=new Vb,Vb);function Vb(t,e){this.updateTime=t,this.exists=e,tg(void 0===t||void 0===e,'Precondition can specify "exists" or "updateTime" but not both')}var qb=(Bb.prototype.verifyKeyMatches=function(t){null!=t&&tg(t.key.isEqual(this.key),"Can only apply a mutation to a document with the same key")},Bb.getPostMutationVersion=function(t){return t instanceof Jw?t.version:Sv.MIN},Bb);function Bb(){}var jb,Wb=(da(Kb,jb=qb),Kb.prototype.applyToRemoteDocument=function(t,e){this.verifyKeyMatches(t),tg(null==e.transformResults,"Transform results received by SetMutation.");var n=e.version;return new Jw(this.key,n,{hasCommittedMutations:!0},this.value)},Kb.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=qb.getPostMutationVersion(t);return new Jw(this.key,r,{hasLocalMutations:!0},this.value)},Kb.prototype.extractBaseValue=function(t){return null},Kb.prototype.isEqual=function(t){return t instanceof Kb&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.precondition.isEqual(t.precondition)},Kb);function Kb(t,e,n){var r=jb.call(this)||this;return r.key=t,r.value=e,r.precondition=n,r.type=xb.Set,r}var Qb,Hb=(da(Gb,Qb=qb),Gb.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),tg(null==e.transformResults,"Transform results received by PatchMutation."),!this.precondition.isValidFor(t))return new r_(this.key,e.version);var n=this.patchDocument(t);return new Jw(this.key,e.version,{hasCommittedMutations:!0},n)},Gb.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=qb.getPostMutationVersion(t),i=this.patchDocument(t);return new Jw(this.key,r,{hasLocalMutations:!0},i)},Gb.prototype.extractBaseValue=function(t){return null},Gb.prototype.isEqual=function(t){return t instanceof Gb&&this.key.isEqual(t.key)&&this.fieldMask.isEqual(t.fieldMask)&&this.precondition.isEqual(t.precondition)},Gb.prototype.patchDocument=function(t){var e;return e=t instanceof Jw?t.data():Ww.EMPTY,this.patchObject(e)},Gb.prototype.patchObject=function(n){var r=this;return this.fieldMask.fields.forEach(function(t){if(!t.isEmpty()){var e=r.data.field(t);n=null!==e?n.set(t,e):n.delete(t)}}),n},Gb);function Gb(t,e,n,r){var i=Qb.call(this)||this;return i.key=t,i.data=e,i.fieldMask=n,i.precondition=r,i.type=xb.Patch,i}var zb,Yb=(da(Xb,zb=qb),Xb.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),tg(null!=e.transformResults,"Transform results missing for TransformMutation."),!this.precondition.isValidFor(t))return new r_(this.key,e.version);var n=this.requireDocument(t),r=this.serverTransformResults(t,e.transformResults),i=e.version,o=this.transformObject(n.data(),r);return new Jw(this.key,i,{hasCommittedMutations:!0},o)},Xb.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=this.requireDocument(t),i=this.localTransformResults(n,t,e),o=this.transformObject(r.data(),i);return new Jw(this.key,r.version,{hasLocalMutations:!0},o)},Xb.prototype.extractBaseValue=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof Jw?t.field(i.field):void 0,a=i.transform.computeBaseValue(o||null);null!=a&&(e=null==e?Ww.EMPTY.set(i.field,a):e.set(i.field,a))}return e},Xb.prototype.isEqual=function(t){return t instanceof Xb&&this.key.isEqual(t.key)&&Lg(this.fieldTransforms,t.fieldTransforms)&&this.precondition.isEqual(t.precondition)},Xb.prototype.requireDocument=function(t){return tg(t instanceof Jw,"Unknown MaybeDocument type "+t),tg(t.key.isEqual(this.key),"Can only transform a document with the same key"),t},Xb.prototype.serverTransformResults=function(t,e){var n=[];tg(this.fieldTransforms.length===e.length,"server transform result count ("+e.length+") should match field transform count ("+this.fieldTransforms.length+")");for(var r=0;r<e.length;r++){var i=this.fieldTransforms[r],o=i.transform,a=null;t instanceof Jw&&(a=t.field(i.field)),n.push(o.applyToRemoteDocument(a,e[r]))}return n},Xb.prototype.localTransformResults=function(t,e,n){for(var r=[],i=0,o=this.fieldTransforms;i<o.length;i++){var a=o[i],s=a.transform,u=null;e instanceof Jw&&(u=e.field(a.field)),null===u&&n instanceof Jw&&(u=n.field(a.field)),r.push(s.applyToLocalView(u,t))}return r},Xb.prototype.transformObject=function(t,e){tg(e.length===this.fieldTransforms.length,"TransformResults length mismatch.");for(var n=0;n<this.fieldTransforms.length;n++){var r=this.fieldTransforms[n].field;t=t.set(r,e[n])}return t},Xb);function Xb(t,e){var n=zb.call(this)||this;return n.key=t,n.fieldTransforms=e,n.type=xb.Transform,n.precondition=Ub.exists(!0),n}var Jb,$b,Zb,tw,ew,nw=(da(rw,Jb=qb),rw.prototype.applyToRemoteDocument=function(t,e){return this.verifyKeyMatches(t),tg(null==e.transformResults,"Transform results received by DeleteMutation."),new t_(this.key,e.version,{hasCommittedMutations:!0})},rw.prototype.applyToLocalView=function(t,e,n){return this.verifyKeyMatches(t),this.precondition.isValidFor(t)?(t&&tg(t.key.isEqual(this.key),"Can only apply mutation to document with same key"),new t_(this.key,Sv.forDeletedDoc())):t},rw.prototype.extractBaseValue=function(t){return null},rw.prototype.isEqual=function(t){return t instanceof rw&&this.key.isEqual(t.key)&&this.precondition.isEqual(t.precondition)},rw);function rw(t,e){var n=Jb.call(this)||this;return n.key=t,n.precondition=e,n.type=xb.Delete,n}(Zb=$b=$b||{})[Zb.NullValue=0]="NullValue",Zb[Zb.BooleanValue=1]="BooleanValue",Zb[Zb.NumberValue=2]="NumberValue",Zb[Zb.TimestampValue=3]="TimestampValue",Zb[Zb.StringValue=4]="StringValue",Zb[Zb.BlobValue=5]="BlobValue",Zb[Zb.RefValue=6]="RefValue",Zb[Zb.GeoPointValue=7]="GeoPointValue",Zb[Zb.ArrayValue=8]="ArrayValue",Zb[Zb.ObjectValue=9]="ObjectValue",(ew=tw=tw||{})[ew.Default=0]="Default",ew[ew.Estimate=1]="Estimate",ew[ew.Previous=2]="Previous";var iw=(ow.fromSnapshotOptions=function(t,e){switch(t.serverTimestamps){case"estimate":return new ow(tw.Estimate,e);case"previous":return new ow(tw.Previous,e);case"none":case void 0:return new ow(tw.Default,e);default:return Zy("fromSnapshotOptions() called with invalid options.")}},ow);function ow(t,e){this.serverTimestampBehavior=t,this.timestampsInSnapshots=e}var aw=(sw.prototype.toString=function(){var t=this.value();return null===t?"null":t.toString()},sw.prototype.defaultCompareTo=function(t){return tg(this.typeOrder!==t.typeOrder,"Default compareTo should not be used for values of same type."),xg(this.typeOrder,t.typeOrder)},sw);function sw(){}var uw,cw=(da(hw,uw=aw),hw.prototype.value=function(t){return null},hw.prototype.isEqual=function(t){return t instanceof hw},hw.prototype.compareTo=function(t){return t instanceof hw?0:this.defaultCompareTo(t)},hw.INSTANCE=new hw,hw);function hw(){var t=uw.call(this)||this;return t.typeOrder=$b.NullValue,t.internalValue=null,t}var lw,fw=(da(pw,lw=aw),pw.prototype.value=function(t){return this.internalValue},pw.prototype.isEqual=function(t){return t instanceof pw&&this.internalValue===t.internalValue},pw.prototype.compareTo=function(t){return t instanceof pw?xg(this,t):this.defaultCompareTo(t)},pw.of=function(t){return t?pw.TRUE:pw.FALSE},pw.TRUE=new pw(!0),pw.FALSE=new pw(!1),pw);function pw(t){var e=lw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.BooleanValue,e}var dw,mw=(da(yw,dw=aw),yw.prototype.value=function(t){return this.internalValue},yw.prototype.compareTo=function(t){return t instanceof yw?function(t,e){return t<e?-1:e<t?1:t===e?0:isNaN(t)?isNaN(e)?0:-1:1}(this.internalValue,t.internalValue):this.defaultCompareTo(t)},yw);function yw(t){var e=dw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.NumberValue,e}function gw(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}var vw,bw=(da(ww,vw=mw),ww.prototype.isEqual=function(t){return t instanceof ww&&gw(this.internalValue,t.internalValue)},ww);function ww(){return null!==vw&&vw.apply(this,arguments)||this}var _w,Tw=(da(Ew,_w=mw),Ew.prototype.isEqual=function(t){return t instanceof Ew&&gw(this.internalValue,t.internalValue)},Ew.NAN=new Ew(NaN),Ew.POSITIVE_INFINITY=new Ew(1/0),Ew.NEGATIVE_INFINITY=new Ew(-1/0),Ew);function Ew(){return null!==_w&&_w.apply(this,arguments)||this}var Sw,Iw=(da(Cw,Sw=aw),Cw.prototype.value=function(t){return this.internalValue},Cw.prototype.isEqual=function(t){return t instanceof Cw&&this.internalValue===t.internalValue},Cw.prototype.compareTo=function(t){return t instanceof Cw?xg(this.internalValue,t.internalValue):this.defaultCompareTo(t)},Cw);function Cw(t){var e=Sw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.StringValue,e}var Nw,Aw=(da(kw,Nw=aw),kw.prototype.value=function(t){return!t||t.timestampsInSnapshots?this.internalValue:this.internalValue.toDate()},kw.prototype.isEqual=function(t){return t instanceof kw&&this.internalValue.isEqual(t.internalValue)},kw.prototype.compareTo=function(t){return t instanceof kw?this.internalValue._compareTo(t.internalValue):t instanceof Rw?-1:this.defaultCompareTo(t)},kw);function kw(t){var e=Nw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.TimestampValue,e}var Dw,Rw=(da(Ow,Dw=aw),Ow.prototype.value=function(t){return t&&t.serverTimestampBehavior===tw.Estimate?new Aw(this.localWriteTime).value(t):t&&t.serverTimestampBehavior===tw.Previous&&this.previousValue?this.previousValue.value(t):null},Ow.prototype.isEqual=function(t){return t instanceof Ow&&this.localWriteTime.isEqual(t.localWriteTime)},Ow.prototype.compareTo=function(t){return t instanceof Ow?this.localWriteTime._compareTo(t.localWriteTime):t instanceof Aw?1:this.defaultCompareTo(t)},Ow.prototype.toString=function(){return"<ServerTimestamp localTime="+this.localWriteTime.toString()+">"},Ow);function Ow(t,e){var n=Dw.call(this)||this;return n.localWriteTime=t,n.previousValue=e,n.typeOrder=$b.TimestampValue,n}var Pw,Mw=(da(xw,Pw=aw),xw.prototype.value=function(t){return this.internalValue},xw.prototype.isEqual=function(t){return t instanceof xw&&this.internalValue.isEqual(t.internalValue)},xw.prototype.compareTo=function(t){return t instanceof xw?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},xw);function xw(t){var e=Pw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.BlobValue,e}var Lw,Fw=(da(Uw,Lw=aw),Uw.prototype.value=function(t){return this.key},Uw.prototype.isEqual=function(t){return t instanceof Uw&&this.key.isEqual(t.key)&&this.databaseId.isEqual(t.databaseId)},Uw.prototype.compareTo=function(t){if(t instanceof Uw){var e=this.databaseId.compareTo(t.databaseId);return 0!==e?e:ov.comparator(this.key,t.key)}return this.defaultCompareTo(t)},Uw);function Uw(t,e){var n=Lw.call(this)||this;return n.databaseId=t,n.key=e,n.typeOrder=$b.RefValue,n}var Vw,qw=(da(Bw,Vw=aw),Bw.prototype.value=function(t){return this.internalValue},Bw.prototype.isEqual=function(t){return t instanceof Bw&&this.internalValue.isEqual(t.internalValue)},Bw.prototype.compareTo=function(t){return t instanceof Bw?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},Bw);function Bw(t){var e=Vw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.GeoPointValue,e}var jw,Ww=(da(Kw,jw=aw),Kw.prototype.value=function(n){var r={};return this.internalValue.inorderTraversal(function(t,e){r[t]=e.value(n)}),r},Kw.prototype.forEach=function(t){this.internalValue.inorderTraversal(t)},Kw.prototype.isEqual=function(t){if(t instanceof Kw){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext();if(r.key!==i.key||!r.value.isEqual(i.value))return!1}return!e.hasNext()&&!n.hasNext()}return!1},Kw.prototype.compareTo=function(t){if(t instanceof Kw){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext(),o=xg(r.key,i.key)||r.value.compareTo(i.value);if(o)return o}return xg(e.hasNext(),n.hasNext())}return this.defaultCompareTo(t)},Kw.prototype.set=function(t,e){if(tg(!t.isEmpty(),"Cannot set field for empty path on ObjectValue"),1===t.length)return this.setChild(t.firstSegment(),e);var n=this.child(t.firstSegment());n instanceof Kw||(n=Kw.EMPTY);var r=n.set(t.popFirst(),e);return this.setChild(t.firstSegment(),r)},Kw.prototype.delete=function(t){if(tg(!t.isEmpty(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new Kw(this.internalValue.remove(t.firstSegment()));var e=this.child(t.firstSegment());if(e instanceof Kw){var n=e.delete(t.popFirst());return new Kw(this.internalValue.insert(t.firstSegment(),n))}return this},Kw.prototype.contains=function(t){return null!==this.field(t)},Kw.prototype.field=function(t){tg(!t.isEmpty(),"Can't get field of empty path");var e=this;return t.forEach(function(t){e=e instanceof Kw?e.internalValue.get(t):null}),e},Kw.prototype.fieldMask=function(){var i=new Mv(rv.comparator);return this.internalValue.forEach(function(t,e){var n=new rv([t]);if(e instanceof Kw){var r=e.fieldMask().fields;r.isEmpty()?i=i.add(n):r.forEach(function(t){i=i.add(n.child(t))})}else i=i.add(n)}),Rb.fromSet(i)},Kw.prototype.toString=function(){return this.internalValue.toString()},Kw.prototype.child=function(t){return this.internalValue.get(t)||void 0},Kw.prototype.setChild=function(t,e){return new Kw(this.internalValue.insert(t,e))},Kw.EMPTY=new Kw(new Cv(xg)),Kw);function Kw(t){var e=jw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.ObjectValue,e}var Qw,Hw=(da(Gw,Qw=aw),Gw.prototype.value=function(e){return this.internalValue.map(function(t){return t.value(e)})},Gw.prototype.contains=function(t){for(var e=0,n=this.internalValue;e<n.length;e++)if(n[e].isEqual(t))return!0;return!1},Gw.prototype.forEach=function(t){this.internalValue.forEach(t)},Gw.prototype.isEqual=function(t){if(t instanceof Gw){if(this.internalValue.length!==t.internalValue.length)return!1;for(var e=0;e<this.internalValue.length;e++)if(!this.internalValue[e].isEqual(t.internalValue[e]))return!1;return!0}return!1},Gw.prototype.compareTo=function(t){if(t instanceof Gw){for(var e=Math.min(this.internalValue.length,t.internalValue.length),n=0;n<e;n++){var r=this.internalValue[n].compareTo(t.internalValue[n]);if(r)return r}return xg(this.internalValue.length,t.internalValue.length)}return this.defaultCompareTo(t)},Gw.prototype.toString=function(){return"["+this.internalValue.map(function(t){return t.toString()}).join(",")+"]"},Gw);function Gw(t){var e=Qw.call(this)||this;return e.internalValue=t,e.typeOrder=$b.ArrayValue,e}var zw=(Yw.compareByKey=function(t,e){return ov.comparator(t.key,e.key)},Yw);function Yw(t,e){this.key=t,this.version=e}var Xw,Jw=(da($w,Xw=zw),$w.prototype.field=function(t){if(this.objectValue)return this.objectValue.field(t);this.fieldValueCache||(this.fieldValueCache=new Map);var e=t.canonicalString(),n=this.fieldValueCache.get(e);if(void 0===n){var r=this.getProtoField(t);n=void 0===r?null:this.converter(r),this.fieldValueCache.set(e,n)}return n},$w.prototype.data=function(){var n=this;if(!this.objectValue){var r=Ww.EMPTY;fg(this.proto.fields||{},function(t,e){r=r.set(new rv([t]),n.converter(e))}),this.objectValue=r,this.fieldValueCache=void 0}return this.objectValue},$w.prototype.value=function(){return this.data().value()},$w.prototype.isEqual=function(t){return t instanceof $w&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.hasLocalMutations===t.hasLocalMutations&&this.hasCommittedMutations===t.hasCommittedMutations&&this.data().isEqual(t.data())},$w.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.data().toString()+", {hasLocalMutations: "+this.hasLocalMutations+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty($w.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!0,configurable:!0}),$w.prototype.getProtoField=function(t){tg(void 0!==this.proto,"Can only call getProtoField() when proto is defined");for(var e=this.proto.fields?this.proto.fields[t.firstSegment()]:void 0,n=1;n<t.length;++n){if(!e||!e.mapValue||!e.mapValue.fields)return;e=e.mapValue.fields[t.get(n)]}return e},$w.compareByField=function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?r.compareTo(i):Zy("Trying to compare documents on fields that don't exist")},$w);function $w(t,e,n,r,i,o){var a=Xw.call(this,t,e)||this;return a.objectValue=r,a.proto=i,a.converter=o,tg(void 0!==a.objectValue||void 0!==a.proto&&void 0!==a.converter,"If objectValue is not defined, proto and converter need to be set."),a.hasLocalMutations=!!n.hasLocalMutations,a.hasCommittedMutations=!!n.hasCommittedMutations,a}var Zw,t_=(da(e_,Zw=zw),e_.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(e_.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),e_.prototype.isEqual=function(t){return t instanceof e_&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e_);function e_(t,e,n){var r=Zw.call(this,t,e)||this;return r.hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}var n_,r_=(da(i_,n_=zw),i_.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(i_.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),i_.prototype.isEqual=function(t){return t instanceof i_&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},i_);function i_(){return null!==n_&&n_.apply(this,arguments)||this}var o_=(a_.prototype.get=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],a=o[0],s=o[1];if(a.isEqual(t))return s}},a_.prototype.has=function(t){return void 0!==this.get(t)},a_.prototype.set=function(t,e){var n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(r[i][0].isEqual(t))return void(r[i]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]},a_.prototype.delete=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(n[r][0].isEqual(t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1},a_.prototype.forEach=function(s){fg(this.inner,function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n],o=i[0],a=i[1];s(o,a)}})},a_.prototype.isEmpty=function(){return pg(this.inner)},a_);function a_(t){this.mapKeyFn=t,this.inner={}}var s_=(Object.defineProperty(u_.prototype,"readTime",{get:function(){return tg(void 0!==this._readTime,"Read time is not set. All removeEntry() calls must include a readTime if `trackRemovals` is used."),this._readTime},set:function(t){tg(void 0===this._readTime||this._readTime.isEqual(t),"All changes in a RemoteDocumentChangeBuffer must have the same read time"),this._readTime=t},enumerable:!0,configurable:!0}),u_.prototype.addEntry=function(t,e){this.assertNotApplied(),this.readTime=e,this.changes.set(t.key,t)},u_.prototype.removeEntry=function(t,e){this.assertNotApplied(),e&&(this.readTime=e),this.changes.set(t,null)},u_.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?Zv.resolve(n):this.getFromCache(t,e)},u_.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},u_.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},u_.prototype.assertNotApplied=function(){tg(!this.changesApplied,"Changes have already been applied.")},u_);function u_(){this.changes=new o_(function(t){return t.toString()}),this.changesApplied=!1}var c_,h_=(l_.prototype.addEntry=function(t,e,n){return d_(t).put(m_(e),n)},l_.prototype.removeEntry=function(t,e){var n=d_(t),r=m_(e);return n.delete(r)},l_.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.setMetadata(e,t)})},l_.prototype.getEntry=function(t,e){var n=this;return d_(t).get(m_(e)).next(function(t){return n.maybeDecodeDocument(t)})},l_.prototype.getSizedEntry=function(t,e){var n=this;return d_(t).get(m_(e)).next(function(t){var e=n.maybeDecodeDocument(t);return e?{maybeDocument:e,size:y_(t)}:null})},l_.prototype.getEntries=function(t,e){var r=this,i=qv();return this.forEachDbEntry(t,e,function(t,e){var n=r.maybeDecodeDocument(e);i=i.insert(t,n)}).next(function(){return i})},l_.prototype.getSizedEntries=function(t,e){var r=this,i=qv(),o=new Cv(ov.comparator);return this.forEachDbEntry(t,e,function(t,e){var n=r.maybeDecodeDocument(e);o=n?(i=i.insert(t,n),o.insert(t,y_(e))):(i=i.insert(t,null),o.insert(t,0))}).next(function(){return{maybeDocuments:i,sizeMap:o}})},l_.prototype.forEachDbEntry=function(t,e,i){if(e.isEmpty())return Zv.resolve();var n=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),o=e.getIterator(),a=o.getNext();return d_(t).iterate({range:n},function(t,e,n){for(var r=ov.fromSegments(t);a&&ov.comparator(a,r)<0;)i(a,null),a=o.getNext();a&&a.isEqual(r)&&(i(a,e),a=o.hasNext()?o.getNext():null),a?n.skip(a.path.toArray()):n.done()}).next(function(){for(;a;)i(a,null),a=o.hasNext()?o.getNext():null})},l_.prototype.getDocumentsMatchingQuery=function(t,i,e){var o=this;tg(!i.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var a=jv(),s=i.path.length+1,n={};if(e.isEqual(Sv.MIN)){var r=i.path.toArray();n.range=IDBKeyRange.lowerBound(r)}else{var u=i.path.toArray(),c=this.serializer.toDbTimestampKey(e);n.range=IDBKeyRange.lowerBound([u,c],!0),n.index=x_.collectionReadTimeIndex}return d_(t).iterate(n,function(t,e,n){if(t.length===s){var r=o.serializer.fromDbRemoteDocument(e);i.path.isPrefixOf(r.key.path)?r instanceof Jw&&i.matches(r)&&(a=a.insert(r.key,r)):n.done()}}).next(function(){return a})},l_.prototype.getNewDocumentChanges=function(t,e){var r=this,i=Vv(),o=this.serializer.toDbTimestampKey(e),n=d_(t),a=IDBKeyRange.lowerBound(o,!0);return n.iterate({index:x_.readTimeIndex,range:a},function(t,e){var n=r.serializer.fromDbRemoteDocument(e);i=i.insert(n.key,n),o=e.readTime}).next(function(){return{changedDocs:i,readTime:r.serializer.fromDbTimestampKey(o)}})},l_.prototype.getLastDocumentChange=function(t){var r,i=this,e=d_(t),o=Sv.MIN;return e.iterate({index:x_.readTimeIndex,reverse:!0},function(t,e,n){r=i.serializer.fromDbRemoteDocument(e),e.readTime&&(o=i.serializer.fromDbTimestampKey(e.readTime)),n.done()}).next(function(){return{changedDoc:r,readTime:o}})},l_.prototype.newChangeBuffer=function(t){return new l_.RemoteDocumentChangeBuffer(this,!!t&&t.trackRemovals)},l_.prototype.getSize=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},l_.prototype.getMetadata=function(t){return p_(t).get(F_.key).next(function(t){return tg(!!t,"Missing document cache metadata"),t})},l_.prototype.setMetadata=function(t,e){return p_(t).put(F_.key,e)},l_.prototype.maybeDecodeDocument=function(t){if(t){var e=this.serializer.fromDbRemoteDocument(t);return e instanceof t_&&e.version.isEqual(Sv.forDeletedDoc())?null:e}return null},l_.RemoteDocumentChangeBuffer=(da(f_,c_=s_),f_.prototype.applyChanges=function(a){var s=this,u=[],c=0,h=new Mv(function(t,e){return xg(t.canonicalString(),e.canonicalString())});return this.changes.forEach(function(t,e){var n=s.documentSizes.get(t);if(tg(void 0!==n,"Cannot modify a document that wasn't read (for "+t+")"),e){tg(!s.readTime.isEqual(Sv.MIN),"Cannot add a document with a read time of zero");var r=s.documentCache.serializer.toDbRemoteDocument(e,s.readTime);h=h.add(t.path.popLast());var i=y_(r);c+=i-n,u.push(s.documentCache.addEntry(a,t,r))}else if(c-=n,s.trackRemovals){var o=s.documentCache.serializer.toDbRemoteDocument(new t_(t,Sv.forDeletedDoc()),s.readTime);u.push(s.documentCache.addEntry(a,t,o))}else u.push(s.documentCache.removeEntry(a,t))}),h.forEach(function(t){u.push(s.documentCache.indexManager.addToCollectionParentIndex(a,t))}),u.push(this.documentCache.updateMetadata(a,c)),Zv.waitFor(u)},f_.prototype.getFromCache=function(t,e){var n=this;return this.documentCache.getSizedEntry(t,e).next(function(t){return null===t?(n.documentSizes.set(e,0),null):(n.documentSizes.set(e,t.size),t.maybeDocument)})},f_.prototype.getAllFromCache=function(t,e){var n=this;return this.documentCache.getSizedEntries(t,e).next(function(t){var e=t.maybeDocuments;return t.sizeMap.forEach(function(t,e){n.documentSizes.set(t,e)}),e})},f_),l_);function l_(t,e){this.serializer=t,this.indexManager=e}function f_(t,e){var n=c_.call(this)||this;return n.documentCache=t,n.trackRemovals=e,n.documentSizes=new o_(function(t){return t.toString()}),n}function p_(t){return ST.getStore(t,F_.store)}function d_(t){return ST.getStore(t,x_.store)}function m_(t){return t.path.toArray()}function y_(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Zy("Unknown remote document type");e=t.noDocument}return JSON.stringify(e).length}var g_=(v_.prototype.addToCollectionParentIndex=function(t,e){return this.collectionParentIndex.add(e),Zv.resolve()},v_.prototype.getCollectionParents=function(t,e){return Zv.resolve(this.collectionParentIndex.getEntries(e))},v_);function v_(){this.collectionParentIndex=new b_}var b_=(w_.prototype.add=function(t){tg(t.length%2==1,"Expected a collection path.");var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new Mv(Zg.comparator),i=!r.has(n);return this.index[e]=r.add(n),i},w_.prototype.has=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)},w_.prototype.getEntries=function(t){return(this.index[t]||new Mv(Zg.comparator)).toArray()},w_);function w_(){this.index={}}var __=9,T_=(E_.prototype.createOrUpgrade=function(t,e,n,r){var i=this;tg(n<r&&0<=n&&r<=__,"Unexpected schema upgrade from v"+n+" to v{toVersion}.");var o=new ab(e);n<1&&1<=r&&(function(t){t.createObjectStore(I_.store)}(t),function(t){t.createObjectStore(N_.store,{keyPath:N_.keyPath}),t.createObjectStore(k_.store,{keyPath:k_.keyPath,autoIncrement:!0}).createIndex(k_.userMutationsIndex,k_.userMutationsKeyPath,{unique:!0}),t.createObjectStore(R_.store)}(t),G_(t),function(t){t.createObjectStore(x_.store)}(t));var a=Zv.resolve();return n<3&&3<=r&&(0!==n&&(function(t){t.deleteObjectStore(B_.store),t.deleteObjectStore(V_.store),t.deleteObjectStore(W_.store)}(t),G_(t)),a=a.next(function(){return function(t){var e=t.store(W_.store),n=new W_(0,0,Sv.MIN.toTimestamp(),0);return e.put(W_.key,n)}(o)})),n<4&&4<=r&&(0!==n&&(a=a.next(function(){return function(r,i){return i.store(k_.store).loadAll().next(function(t){r.deleteObjectStore(k_.store),r.createObjectStore(k_.store,{keyPath:k_.keyPath,autoIncrement:!0}).createIndex(k_.userMutationsIndex,k_.userMutationsKeyPath,{unique:!0});var e=i.store(k_.store),n=t.map(function(t){return e.put(t)});return Zv.waitFor(n)})}(t,o)})),a=a.next(function(){!function(t){t.createObjectStore(z_.store,{keyPath:z_.keyPath})}(t)})),n<5&&5<=r&&(a=a.next(function(){return i.removeAcknowledgedMutations(o)})),n<6&&6<=r&&(a=a.next(function(){return function(t){t.createObjectStore(F_.store)}(t),i.addDocumentGlobal(o)})),n<7&&7<=r&&(a=a.next(function(){return i.ensureSequenceNumbers(o)})),n<8&&8<=r&&(a=a.next(function(){return i.createCollectionParentIndex(t,o)})),n<9&&9<=r&&(a=a.next(function(){!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){var e=t.objectStore(x_.store);e.createIndex(x_.readTimeIndex,x_.readTimeIndexPath,{unique:!1}),e.createIndex(x_.collectionReadTimeIndex,x_.collectionReadTimeIndexPath,{unique:!1})}(e)})),a},E_.prototype.addDocumentGlobal=function(e){var n=0;return e.store(x_.store).iterate(function(t,e){n+=y_(e)}).next(function(){var t=new F_(n);return e.store(F_.store).put(F_.key,t)})},E_.prototype.removeAcknowledgedMutations=function(r){var i=this,t=r.store(N_.store),e=r.store(k_.store);return t.loadAll().next(function(t){return Zv.forEach(t,function(n){var t=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return e.loadAll(k_.userMutationsIndex,t).next(function(t){return Zv.forEach(t,function(t){tg(t.userId===n.userId,"Cannot process batch "+t.batchId+" from unexpected user");var e=i.serializer.fromDbMutationBatch(t);return yb(r,n.userId,e).next(function(){})})})})})},E_.prototype.ensureSequenceNumbers=function(t){var a=t.store(B_.store),e=t.store(x_.store);return kb(t).next(function(i){var o=[];return e.iterate(function(t,e){var n=new Zg(t),r=function(t){return[0,vv(t)]}(n);o.push(a.get(r).next(function(t){return t?Zv.resolve():function(t){return a.put(new B_(0,vv(t),i))}(n)}))}).next(function(){return Zv.waitFor(o)})})},E_.prototype.createCollectionParentIndex=function(t,e){function i(t){if(o.add(t)){var e=t.lastSegment(),n=t.popLast();return r.put({collectionId:e,parent:vv(n)})}}t.createObjectStore(Q_.store,{keyPath:Q_.keyPath});var r=e.store(Q_.store),o=new b_;return e.store(x_.store).iterate({keysOnly:!0},function(t,e){var n=new Zg(t);return i(n.popLast())}).next(function(){return e.store(R_.store).iterate({keysOnly:!0},function(t,e){t[0];var n=t[1],r=(t[2],_v(n));return i(r.popLast())})})},E_);function E_(t){this.serializer=t}var S_=function(t,e){this.seconds=t,this.nanoseconds=e},I_=(C_.store="owner",C_.key="owner",C_);function C_(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}var N_=(A_.store="mutationQueues",A_.keyPath="userId",A_);function A_(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}var k_=(D_.store="mutations",D_.keyPath="batchId",D_.userMutationsIndex="userMutationsIndex",D_.userMutationsKeyPath=["userId","batchId"],D_);function D_(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}var R_=(O_.prefixForUser=function(t){return[t]},O_.prefixForPath=function(t,e){return[t,vv(e)]},O_.key=function(t,e,n){return[t,vv(e),n]},O_.store="documentMutations",O_.PLACEHOLDER=new O_,O_);function O_(){}var P_=function(t,e){this.path=t,this.readTime=e},M_=function(t,e){this.path=t,this.version=e},x_=(L_.store="remoteDocuments",L_.readTimeIndex="readTimeIndex",L_.readTimeIndexPath="readTime",L_.collectionReadTimeIndex="collectionReadTimeIndex",L_.collectionReadTimeIndexPath=["parentPath","readTime"],L_);function L_(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o}var F_=(U_.store="remoteDocumentGlobal",U_.key="remoteDocumentGlobalKey",U_);function U_(t){this.byteSize=t}var V_=(q_.store="targets",q_.keyPath="targetId",q_.queryTargetsIndexName="queryTargetsIndex",q_.queryTargetsKeyPath=["canonicalId","targetId"],q_);function q_(t,e,n,r,i,o,a){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=a}var B_=(j_.store="targetDocuments",j_.keyPath=["targetId","path"],j_.documentTargetsIndex="documentTargetsIndex",j_.documentTargetsKeyPath=["path","targetId"],j_);function j_(t,e,n){this.targetId=t,this.path=e,tg(0===t==(void 0!==(this.sequenceNumber=n)),"A target-document row must either have targetId == 0 and a defined sequence number, or a non-zero targetId and no sequence number")}var W_=(K_.key="targetGlobalKey",K_.store="targetGlobal",K_);function K_(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}var Q_=(H_.store="collectionParents",H_.keyPath=["collectionId","parent"],H_);function H_(t,e){this.collectionId=t,this.parent=e}function G_(t){t.createObjectStore(B_.store,{keyPath:B_.keyPath}).createIndex(B_.documentTargetsIndex,B_.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(V_.store,{keyPath:V_.keyPath}).createIndex(V_.queryTargetsIndexName,V_.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(W_.store)}var z_=(Y_.store="clientMetadata",Y_.keyPath="clientId",Y_);function Y_(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}var X_,J_,$_=_a(_a(_a([N_.store,k_.store,R_.store,x_.store,V_.store,I_.store,W_.store,B_.store],[z_.store]),[F_.store]),[Q_.store]),Z_=(tT.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(tg(e.length%2==1,"Expected a collection path."),this.collectionParentsCache.has(e))return Zv.resolve();var r=e.lastSegment(),i=e.popLast();t.addOnCommittedListener(function(){n.collectionParentsCache.add(e)});var o={collectionId:r,parent:vv(i)};return eT(t).put(o)},tT.prototype.getCollectionParents=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[Fg(i),""],!1,!0);return eT(t).loadAll(e).next(function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if(r.collectionId!==i)break;o.push(_v(r.parent))}return o})},tT);function tT(){this.collectionParentsCache=new b_}function eT(t){return ST.getStore(t,Q_.store)}(J_=X_=X_||{})[J_.Listen=0]="Listen",J_[J_.ExistenceFilterMismatch=1]="ExistenceFilterMismatch",J_[J_.LimboResolution=2]="LimboResolution";var nT=(rT.prototype.withSequenceNumber=function(t){return new rT(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},rT.prototype.withResumeToken=function(t,e){return new rT(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},rT.prototype.withLastLimboFreeSnapshotVersion=function(t){return new rT(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)},rT.prototype.isEqual=function(t){return this.targetId===t.targetId&&this.purpose===t.purpose&&this.sequenceNumber===t.sequenceNumber&&this.snapshotVersion.isEqual(t.snapshotVersion)&&this.lastLimboFreeSnapshotVersion.isEqual(t.lastLimboFreeSnapshotVersion)&&this.resumeToken===t.resumeToken&&this.target.isEqual(t.target)},rT);function rT(t,e,n,r,i,o,a){void 0===i&&(i=Sv.MIN),void 0===o&&(o=Sv.MIN),void 0===a&&(a=rg()),this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a}var iT=(oT.prototype.fromDbRemoteDocument=function(t){if(t.document)return this.remoteSerializer.fromDocument(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=ov.fromSegments(t.noDocument.path),n=this.fromDbTimestamp(t.noDocument.readTime);return new t_(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}return t.unknownDocument?(e=ov.fromSegments(t.unknownDocument.path),n=this.fromDbTimestamp(t.unknownDocument.version),new r_(e,n)):Zy("Unexpected DbRemoteDocument")},oT.prototype.toDbRemoteDocument=function(t,e){var n=this.toDbTimestampKey(e),r=t.key.path.popLast().toArray();if(t instanceof Jw){var i=t.proto?t.proto:this.remoteSerializer.toDocument(t),o=t.hasCommittedMutations;return new x_(null,null,i,o,n,r)}if(t instanceof t_){var a=t.key.path.toArray(),s=this.toDbTimestamp(t.version);return o=t.hasCommittedMutations,new x_(null,new P_(a,s),null,o,n,r)}if(t instanceof r_){a=t.key.path.toArray();var u=this.toDbTimestamp(t.version);return new x_(new M_(a,u),null,null,!0,n,r)}return Zy("Unexpected MaybeDocument")},oT.prototype.toDbTimestampKey=function(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]},oT.prototype.fromDbTimestampKey=function(t){var e=new Tv(t[0],t[1]);return Sv.fromTimestamp(e)},oT.prototype.toDbTimestamp=function(t){var e=t.toTimestamp();return new S_(e.seconds,e.nanoseconds)},oT.prototype.fromDbTimestamp=function(t){var e=new Tv(t.seconds,t.nanoseconds);return Sv.fromTimestamp(e)},oT.prototype.toDbMutationBatch=function(t,e){var n=this,r=e.baseMutations.map(function(t){return n.remoteSerializer.toMutation(t)}),i=e.mutations.map(function(t){return n.remoteSerializer.toMutation(t)});return new k_(t,e.batchId,e.localWriteTime.toMillis(),r,i)},oT.prototype.fromDbMutationBatch=function(t){var e=this,n=(t.baseMutations||[]).map(function(t){return e.remoteSerializer.fromMutation(t)}),r=t.mutations.map(function(t){return e.remoteSerializer.fromMutation(t)}),i=Tv.fromMillis(t.localWriteTimeMs);return new Yv(t.batchId,i,n,r)},oT.prototype.toDbResourcePaths=function(t){var e=[];return t.forEach(function(t){e.push(vv(t.path))}),e},oT.prototype.fromDbResourcePaths=function(t){for(var e=Hv(),n=0,r=t;n<r.length;n++){var i=r[n];e=e.add(new ov(_v(i)))}return e},oT.prototype.fromDbTarget=function(t){var e,n=this.fromDbTimestamp(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.fromDbTimestamp(t.lastLimboFreeSnapshotVersion):Sv.MIN,i=t.resumeToken;return e=function(t){return void 0!==t.documents}(t.query)?this.remoteSerializer.fromDocumentsTarget(t.query):this.remoteSerializer.fromQueryTarget(t.query),new nT(e,t.targetId,X_.Listen,t.lastListenSequenceNumber,n,r,i)},oT.prototype.toDbTarget=function(t){tg(X_.Listen===t.purpose,"Only queries with purpose "+X_.Listen+" may be stored, got "+t.purpose);var e,n,r=this.toDbTimestamp(t.snapshotVersion),i=this.toDbTimestamp(t.lastLimboFreeSnapshotVersion);return e=t.target.isDocumentQuery()?this.remoteSerializer.toDocumentsTarget(t.target):this.remoteSerializer.toQueryTarget(t.target),n=t.resumeToken instanceof Uint8Array?(tg(nb.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence ."),t.resumeToken.toString()):t.resumeToken,new V_(t.targetId,t.target.canonicalId(),r,n,t.sequenceNumber,i,e)},oT);function oT(t){this.remoteSerializer=t}function aT(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],a=xg(n,i);return 0===a?xg(r,o):a}var sT=(uT.prototype.nextIndex=function(){return++this.previousIndex},uT.prototype.addElement=function(t){var e=[t,this.nextIndex()];if(this.buffer.size<this.maxElements)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();aT(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(uT.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),uT);function uT(t){this.maxElements=t,this.buffer=new Mv(aT),this.previousIndex=0}var cT={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},hT=(lT.withCacheSize=function(t){return new lT(t,lT.DEFAULT_COLLECTION_PERCENTILE,lT.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},lT.COLLECTION_DISABLED=-1,lT.MINIMUM_CACHE_SIZE_BYTES=1048576,lT.DEFAULT=new lT(lT.DEFAULT_CACHE_SIZE_BYTES=41943040,lT.DEFAULT_COLLECTION_PERCENTILE=10,lT.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3),lT.DISABLED=new lT(lT.COLLECTION_DISABLED,0,0),lT);function lT(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}var fT=(pT.prototype.start=function(){tg(null===this.gcTask,"Cannot start an already started LruScheduler"),this.garbageCollector.params.cacheSizeCollectionThreshold!==hT.COLLECTION_DISABLED&&this.scheduleGC()},pT.prototype.stop=function(){this.gcTask&&(this.gcTask.cancel(),this.gcTask=null)},Object.defineProperty(pT.prototype,"started",{get:function(){return null!==this.gcTask},enumerable:!0,configurable:!0}),pT.prototype.scheduleGC=function(){var t=this;tg(null===this.gcTask,"Cannot schedule GC while a task is pending");var e=this.hasRun?3e5:6e4;Xy("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.gcTask=this.asyncQueue.enqueueAfterDelay(sv.LruGarbageCollection,e,function(){return t.gcTask=null,t.hasRun=!0,t.localStore.collectGarbage(t.garbageCollector).then(function(){return t.scheduleGC()}).catch(CT)})},pT);function pT(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.hasRun=!1,this.gcTask=null}var dT=(mT.prototype.calculateTargetCount=function(t,e){return this.delegate.getSequenceNumberCount(t).next(function(t){return Math.floor(e/100*t)})},mT.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return Zv.resolve(Gg.INVALID);var r=new sT(e);return this.delegate.forEachTarget(t,function(t){return r.addElement(t.sequenceNumber)}).next(function(){return n.delegate.forEachOrphanedDocumentSequenceNumber(t,function(t){return r.addElement(t)})}).next(function(){return r.maxValue})},mT.prototype.removeTargets=function(t,e,n){return this.delegate.removeTargets(t,e,n)},mT.prototype.removeOrphanedDocuments=function(t,e){return this.delegate.removeOrphanedDocuments(t,e)},mT.prototype.collect=function(e,n){var r=this;return this.params.cacheSizeCollectionThreshold===hT.COLLECTION_DISABLED?(Xy("LruGarbageCollector","Garbage collection skipped; disabled"),Zv.resolve(cT)):this.getCacheSize(e).next(function(t){return t<r.params.cacheSizeCollectionThreshold?(Xy("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.params.cacheSizeCollectionThreshold),cT):r.runGarbageCollection(e,n)})},mT.prototype.getCacheSize=function(t){return this.delegate.getCacheSize(t)},mT.prototype.runGarbageCollection=function(e,n){var r,i,o,a,s,u,c,h=this,l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(function(t){return i=t>h.params.maximumSequenceNumbersToCollect?(Xy("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+t),h.params.maximumSequenceNumbersToCollect):t,a=Date.now(),h.nthSequenceNumber(e,i)}).next(function(t){return r=t,s=Date.now(),h.removeTargets(e,r,n)}).next(function(t){return o=t,u=Date.now(),h.removeOrphanedDocuments(e,r)}).next(function(t){return c=Date.now(),zy()<=Uy.DEBUG&&Xy("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(a-l)+"ms\n\tDetermined least recently used "+i+" in "+(s-a)+"ms\n\tRemoved "+o+" targets in "+(u-s)+"ms\n\tRemoved "+t+" documents in "+(c-u)+"ms\nTotal Duration: "+(c-l)+"ms"),Zv.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:t})})},mT);function mT(t,e){this.delegate=t,this.params=e}var yT=(gT.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},gT.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},gT);function gT(){this.onCommittedListeners=[]}var vT,bT="IndexedDbPersistence",wT="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",_T="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",TT=(da(ET,vT=yT),ET);function ET(t,e){var n=vT.call(this)||this;return n.simpleDbTransaction=t,n.currentSequenceNumber=e,n}var ST=(IT.getStore=function(t,e){if(t instanceof TT)return nb.getStore(t.simpleDbTransaction,e);throw Zy("IndexedDbPersistence must use instances of IndexedDbTransaction")},IT.createIndexedDbPersistence=function(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:if(!IT.isAvailable())throw new ag(og.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");return[4,(e=new IT(n.allowTabSynchronization,n.persistenceKey,n.clientId,n.platform,n.lruParams,n.queue,n.serializer,n.sequenceNumberSyncer)).start()];case 1:return t.sent(),[2,e]}})})},IT.prototype.start=function(){var e=this;return tg(!this.started,"IndexedDbPersistence double-started!"),tg(null!==this.window,"Expected 'window' to be defined"),nb.openOrCreate(this.dbName,__,new T_(this.serializer)).then(function(t){return e.simpleDb=t,e.updateClientMetadataAndTryBecomePrimary()}).then(function(){return e.attachVisibilityHandler(),e.attachWindowUnloadHook(),e.scheduleClientMetadataAndPrimaryLeaseRefreshes(),e.simpleDb.runTransaction("readonly-idempotent",[W_.store],function(t){return kb(t)})}).then(function(t){e.listenSequence=new Gg(t,e.sequenceNumberSyncer)}).then(function(){e._started=!0}).catch(function(t){return e.simpleDb&&e.simpleDb.close(),Promise.reject(t)})},IT.prototype.setPrimaryStateListener=function(n){var t=this;return this.primaryStateListener=function(e){return ya(t,void 0,void 0,function(){return ga(this,function(t){return this.started?[2,n(e)]:[2]})})},n(this.isPrimary)},IT.prototype.setDatabaseDeletedListener=function(n){var t=this;this.simpleDb.setVersionChangeListener(function(e){return ya(t,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return null!==e.newVersion?[3,2]:[4,n()];case 1:t.sent(),t.label=2;case 2:return[2]}})})})},IT.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.queue.enqueueAndForget(function(){return ya(e,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.started?[4,this.updateClientMetadataAndTryBecomePrimary()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})}))},IT.prototype.updateClientMetadataAndTryBecomePrimary=function(){var n=this;return this.simpleDb.runTransaction("readwrite-idempotent",$_,function(e){return AT(e).put(new z_(n.clientId,Date.now(),n.networkEnabled,n.inForeground)).next(function(){if(n.isPrimary)return n.verifyPrimaryLease(e).next(function(t){t||(n.isPrimary=!1,n.queue.enqueueAndForget(function(){return n.primaryStateListener(!1)}))})}).next(function(){return n.canActAsPrimary(e)}).next(function(t){return n.isPrimary&&!t?n.releasePrimaryLeaseIfHeld(e).next(function(){return!1}):!!t&&n.acquireOrExtendPrimaryLease(e).next(function(){return!0})})}).catch(function(t){if(!n.allowTabSynchronization)throw t;return Xy(bT,"Releasing owner lease after error during lease refresh",t),!1}).then(function(t){n.isPrimary!==t&&n.queue.enqueueAndForget(function(){return n.primaryStateListener(t)}),n.isPrimary=t})},IT.prototype.verifyPrimaryLease=function(t){var e=this;return NT(t).get(I_.key).next(function(t){return Zv.resolve(e.isLocalClient(t))})},IT.prototype.removeClientMetadata=function(t){return AT(t).delete(this.clientId)},IT.prototype.maybeGarbageCollectMultiClientState=function(){return ya(this,void 0,void 0,function(){var i=this;return ga(this,function(t){switch(t.label){case 0:return!this.isPrimary||this.isWithinAge(this.lastGarbageCollectionTime,18e5)?[3,2]:(this.lastGarbageCollectionTime=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary-idempotent",function(t){var r=IT.getStore(t,z_.store);return r.loadAll().next(function(t){var e=i.filterActiveClients(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return Zv.forEach(n,function(t){return r.delete(t.clientId)}).next(function(){return n})})})]);case 1:t.sent().forEach(function(t){i.window.localStorage.removeItem(i.zombiedClientLocalStorageKey(t.clientId))}),t.label=2;case 2:return[2]}})})},IT.prototype.scheduleClientMetadataAndPrimaryLeaseRefreshes=function(){var t=this;this.clientMetadataRefresher=this.queue.enqueueAfterDelay(sv.ClientMetadataRefresh,4e3,function(){return t.updateClientMetadataAndTryBecomePrimary().then(function(){return t.maybeGarbageCollectMultiClientState()}).then(function(){return t.scheduleClientMetadataAndPrimaryLeaseRefreshes()})})},IT.prototype.isLocalClient=function(t){return!!t&&t.ownerId===this.clientId},IT.prototype.canActAsPrimary=function(e){var i=this;return NT(e).get(I_.key).next(function(t){if(null!==t&&i.isWithinAge(t.leaseTimestampMs,5e3)&&!i.isClientZombied(t.ownerId)){if(i.isLocalClient(t)&&i.networkEnabled)return!0;if(!i.isLocalClient(t)){if(!t.allowTabSynchronization)throw new ag(og.FAILED_PRECONDITION,_T);return!1}}return!(!i.networkEnabled||!i.inForeground)||AT(e).loadAll().next(function(t){return void 0===i.filterActiveClients(t,5e3).find(function(t){if(i.clientId!==t.clientId){var e=!i.networkEnabled&&t.networkEnabled,n=!i.inForeground&&t.inForeground,r=i.networkEnabled===t.networkEnabled;if(e||n&&r)return!0}return!1})})}).next(function(t){return i.isPrimary!==t&&Xy(bT,"Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},IT.prototype.shutdown=function(){return ya(this,void 0,void 0,function(){var e=this;return ga(this,function(t){switch(t.label){case 0:return this._started=!1,this.markClientZombied(),this.clientMetadataRefresher&&(this.clientMetadataRefresher.cancel(),this.clientMetadataRefresher=null),this.detachVisibilityHandler(),this.detachWindowUnloadHook(),[4,this.simpleDb.runTransaction("readwrite-idempotent",[I_.store,z_.store],function(t){return e.releasePrimaryLeaseIfHeld(t).next(function(){return e.removeClientMetadata(t)})})];case 1:return t.sent(),this.simpleDb.close(),this.removeClientZombiedEntry(),[2]}})})},IT.prototype.filterActiveClients=function(t,e){var n=this;return t.filter(function(t){return n.isWithinAge(t.updateTimeMs,e)&&!n.isClientZombied(t.clientId)})},IT.prototype.getActiveClients=function(){var e=this;return this.simpleDb.runTransaction("readonly-idempotent",[z_.store],function(t){return AT(t).loadAll().next(function(t){return e.filterActiveClients(t,18e5).map(function(t){return t.clientId})})})},IT.clearPersistence=function(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return IT.isAvailable()?(e=n+IT.MAIN_DATABASE,[4,nb.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(IT.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),IT.prototype.getMutationQueue=function(t){return tg(this.started,"Cannot initialize MutationQueue before persistence is started."),pb.forUser(t,this.serializer,this.indexManager,this.referenceDelegate)},IT.prototype.getTargetCache=function(){return tg(this.started,"Cannot initialize TargetCache before persistence is started."),this.targetCache},IT.prototype.getRemoteDocumentCache=function(){return tg(this.started,"Cannot initialize RemoteDocumentCache before persistence is started."),this.remoteDocumentCache},IT.prototype.getIndexManager=function(){return tg(this.started,"Cannot initialize IndexManager before persistence is started."),this.indexManager},IT.prototype.runTransaction=function(n,t,r){var i=this;Xy(bT,"Starting transaction:",n);var o,e=t.endsWith("idempotent"),a=t.startsWith("readonly")?e?"readonly-idempotent":"readonly":e?"readwrite-idempotent":"readwrite";return this.simpleDb.runTransaction(a,$_,function(e){return o=new TT(e,i.listenSequence.next()),"readwrite-primary"===t||"readwrite-primary-idempotent"===t?i.verifyPrimaryLease(e).next(function(t){return!!t||i.canActAsPrimary(e)}).next(function(t){if(!t)throw Jy("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.queue.enqueueAndForget(function(){return i.primaryStateListener(!1)}),new ag(og.FAILED_PRECONDITION,wT);return r(o)}).next(function(t){return i.acquireOrExtendPrimaryLease(e).next(function(){return t})}):i.verifyAllowTabSynchronization(e).next(function(){return r(o)})}).then(function(t){return o.raiseOnCommittedEvent(),t})},IT.prototype.verifyAllowTabSynchronization=function(t){var e=this;return NT(t).get(I_.key).next(function(t){if(null!==t&&e.isWithinAge(t.leaseTimestampMs,5e3)&&!e.isClientZombied(t.ownerId)&&!e.isLocalClient(t)&&!t.allowTabSynchronization)throw new ag(og.FAILED_PRECONDITION,_T)})},IT.prototype.acquireOrExtendPrimaryLease=function(t){var e=new I_(this.clientId,this.allowTabSynchronization,Date.now());return NT(t).put(I_.key,e)},IT.isAvailable=function(){return nb.isAvailable()},IT.buildStoragePrefix=function(t){var e=t.databaseId.projectId;return t.databaseId.isDefaultDatabase||(e+="."+t.databaseId.database),"firestore/"+t.persistenceKey+"/"+e+"/"},IT.prototype.releasePrimaryLeaseIfHeld=function(t){var e=this,n=NT(t);return n.get(I_.key).next(function(t){return e.isLocalClient(t)?(Xy(bT,"Releasing primary lease."),n.delete(I_.key)):Zv.resolve()})},IT.prototype.isWithinAge=function(t,e){var n=Date.now();return!(t<n-e||n<t&&(Jy("Detected an update time that is in the future: "+t+" > "+n),1))},IT.prototype.attachVisibilityHandler=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.documentVisibilityHandler=function(){t.queue.enqueueAndForget(function(){return t.inForeground="visible"===t.document.visibilityState,t.updateClientMetadataAndTryBecomePrimary()})},this.document.addEventListener("visibilitychange",this.documentVisibilityHandler),this.inForeground="visible"===this.document.visibilityState)},IT.prototype.detachVisibilityHandler=function(){this.documentVisibilityHandler&&(tg(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this.documentVisibilityHandler),this.documentVisibilityHandler=null)},IT.prototype.attachWindowUnloadHook=function(){var t=this;"function"==typeof this.window.addEventListener&&(this.windowUnloadHandler=function(){t.markClientZombied(),t.queue.enqueueAndForget(function(){return t.shutdown()})},this.window.addEventListener("unload",this.windowUnloadHandler))},IT.prototype.detachWindowUnloadHook=function(){this.windowUnloadHandler&&(tg("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.windowUnloadHandler),this.windowUnloadHandler=null)},IT.prototype.isClientZombied=function(t){try{var e=null!==this.webStorage.getItem(this.zombiedClientLocalStorageKey(t));return Xy(bT,"Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return Jy(bT,"Failed to get zombied client id.",t),!1}},IT.prototype.markClientZombied=function(){try{this.webStorage.setItem(this.zombiedClientLocalStorageKey(this.clientId),String(Date.now()))}catch(t){Jy("Failed to set zombie client id.",t)}},IT.prototype.removeClientZombiedEntry=function(){try{this.webStorage.removeItem(this.zombiedClientLocalStorageKey(this.clientId))}catch(t){}},IT.prototype.zombiedClientLocalStorageKey=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},IT.MAIN_DATABASE="main",IT);function IT(t,e,n,r,i,o,a,s){if(this.allowTabSynchronization=t,this.persistenceKey=e,this.clientId=n,this.queue=o,this.sequenceNumberSyncer=s,this._started=!1,this.isPrimary=!1,this.networkEnabled=!0,this.windowUnloadHandler=null,this.inForeground=!1,this.documentVisibilityHandler=null,this.clientMetadataRefresher=null,this.lastGarbageCollectionTime=Number.NEGATIVE_INFINITY,this.primaryStateListener=function(t){return Promise.resolve()},this.referenceDelegate=new kT(this,i),this.dbName=e+IT.MAIN_DATABASE,this.serializer=new iT(a),this.document=r.document,this.targetCache=new Ib(this.referenceDelegate,this.serializer),this.indexManager=new Z_,this.remoteDocumentCache=new h_(this.serializer,this.indexManager),!r.window||!r.window.localStorage)throw new ag(og.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.webStorage=this.window.localStorage}function CT(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){if(!function(t){return t.code===og.FAILED_PRECONDITION&&t.message===wT}(e))throw e;return Xy(bT,"Unexpectedly lost primary lease"),[2]})})}function NT(t){return t.store(I_.store)}function AT(t){return t.store(z_.store)}var kT=(DT.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocmentCount(t);return this.db.getTargetCache().getTargetCount(t).next(function(e){return n.next(function(t){return e+t})})},DT.prototype.orphanedDocmentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},DT.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},DT.prototype.forEachOrphanedDocumentSequenceNumber=function(t,n){return this.forEachOrphanedDocument(t,function(t,e){return n(e)})},DT.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},DT.prototype.addReference=function(t,e){return RT(t,e)},DT.prototype.removeReference=function(t,e){return RT(t,e)},DT.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},DT.prototype.removeMutationReference=function(t,e){return RT(t,e)},DT.prototype.isPinned=function(t,e){return this.inMemoryPins.containsKey(e)?Zv.resolve(!0):function(e,n){var r=!1;return wb(e).iterateSerial(function(t){return mb(e,t,n).next(function(t){return t&&(r=!0),Zv.resolve(!t)})}).next(function(){return r})}(t,e)},DT.prototype.removeOrphanedDocuments=function(r,i){var o=this,a=this.db.getRemoteDocumentCache().newChangeBuffer(),s=[],u=0;return this.forEachOrphanedDocument(r,function(e,t){if(t<=i){var n=o.isPinned(r,e).next(function(t){if(!t)return u++,a.getEntry(r,e).next(function(){return a.removeEntry(e),Db(r).delete(function(t){return[0,vv(t.path)]}(e))})});s.push(n)}}).next(function(){return Zv.waitFor(s)}).next(function(){return a.apply(r)}).next(function(){return u})},DT.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)},DT.prototype.updateLimboDocument=function(t,e){return RT(t,e)},DT.prototype.forEachOrphanedDocument=function(t,o){var a,e=Db(t),s=Gg.INVALID;return e.iterate({index:B_.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(s!==Gg.INVALID&&o(new ov(_v(a)),s),s=i,a=r):s=Gg.INVALID}).next(function(){s!==Gg.INVALID&&o(new ov(_v(a)),s)})},DT.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},DT);function DT(t,e){this.db=t,this.inMemoryPins=null,this.garbageCollector=new dT(this,e)}function RT(t,e){return Db(t).put(function(t,e){return new B_(0,vv(t.path),e)}(e,t.currentSequenceNumber))}var OT=Number,PT=OT.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),MT=OT.MAX_SAFE_INTEGER||Math.pow(2,53)-1,xT=OT.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function LT(t){return null==t}function FT(t){return xT(t)&&t<=MT&&PT<=t}var UT,VT,qT=(BT.prototype.canonicalId=function(){if(null===this.memoizedCanonicalId){var t=this.path.canonicalString();null!==this.collectionGroup&&(t+="|cg:"+this.collectionGroup),t+="|f:";for(var e=0,n=this.filters;e<n.length;e++)t+=n[e].canonicalId(),t+=",";t+="|ob:";for(var r=0,i=this.orderBy;r<i.length;r++)t+=i[r].canonicalId(),t+=",";LT(this.limit)||(t+="|l:",t+=this.limit),this.startAt&&(t+="|lb:",t+=this.startAt.canonicalId()),this.endAt&&(t+="|ub:",t+=this.endAt.canonicalId()),this.memoizedCanonicalId=t}return this.memoizedCanonicalId},BT.prototype.toString=function(){var t=this.path.canonicalString();return null!==this.collectionGroup&&(t+=" collectionGroup="+this.collectionGroup),0<this.filters.length&&(t+=", filters: ["+this.filters.join(", ")+"]"),LT(this.limit)||(t+=", limit: "+this.limit),0<this.orderBy.length&&(t+=", orderBy: ["+this.orderBy.join(", ")+"]"),this.startAt&&(t+=", startAt: "+this.startAt.canonicalId()),this.endAt&&(t+=", endAt: "+this.endAt.canonicalId()),"Target("+t+")"},BT.prototype.isEqual=function(t){if(this.limit!==t.limit)return!1;if(this.orderBy.length!==t.orderBy.length)return!1;for(var e=0;e<this.orderBy.length;e++)if(!this.orderBy[e].isEqual(t.orderBy[e]))return!1;if(this.filters.length!==t.filters.length)return!1;for(e=0;e<this.filters.length;e++)if(!this.filters[e].isEqual(t.filters[e]))return!1;return this.collectionGroup===t.collectionGroup&&!!this.path.isEqual(t.path)&&!(null!==this.startAt?!this.startAt.isEqual(t.startAt):null!==t.startAt)&&(null!==this.endAt?this.endAt.isEqual(t.endAt):null===t.endAt)},BT.prototype.isDocumentQuery=function(){return ov.isDocumentKey(this.path)&&null===this.collectionGroup&&0===this.filters.length},BT);function BT(t,e,n,r,i,o,a){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===a&&(a=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=a,this.memoizedCanonicalId=null}(VT=UT=UT||{}).First="F",VT.Last="L";var jT=(WT.atPath=function(t){return new WT(t)},Object.defineProperty(WT.prototype,"orderBy",{get:function(){if(null===this.memoizedOrderBy){var t=this.getInequalityFilterField(),e=this.getFirstOrderByField();if(null!==t&&null===e)t.isKeyField()?this.memoizedOrderBy=[gE]:this.memoizedOrderBy=[new mE(t),gE];else{tg(null===t||null!==e&&t.isEqual(e),"First orderBy should match inequality field.");for(var n=!(this.memoizedOrderBy=[]),r=0,i=this.explicitOrderBy;r<i.length;r++){var o=i[r];this.memoizedOrderBy.push(o),o.field.isKeyField()&&(n=!0)}if(!n){var a=0<this.explicitOrderBy.length?this.explicitOrderBy[this.explicitOrderBy.length-1].dir:lE.ASCENDING;this.memoizedOrderBy.push(a===lE.ASCENDING?gE:vE)}}}return this.memoizedOrderBy},enumerable:!0,configurable:!0}),WT.prototype.addFilter=function(t){tg(null==this.getInequalityFilterField()||!(t instanceof zT)||!t.isInequality()||t.field.isEqual(this.getInequalityFilterField()),"Query must only have one inequality field."),tg(!this.isDocumentQuery(),"No filtering allowed for document query");var e=this.filters.concat([t]);return new WT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),e,this.limit,this.limitType,this.startAt,this.endAt)},WT.prototype.addOrderBy=function(t){tg(!this.startAt&&!this.endAt,"Bounds must be set after orderBy");var e=this.explicitOrderBy.concat([t]);return new WT(this.path,this.collectionGroup,e,this.filters.slice(),this.limit,this.limitType,this.startAt,this.endAt)},WT.prototype.withLimitToFirst=function(t){return new WT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),t,UT.First,this.startAt,this.endAt)},WT.prototype.withLimitToLast=function(t){return new WT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),t,UT.Last,this.startAt,this.endAt)},WT.prototype.withStartAt=function(t){return new WT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,t,this.endAt)},WT.prototype.withEndAt=function(t){return new WT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,this.startAt,t)},WT.prototype.asCollectionQueryAtPath=function(t){return new WT(t,null,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.limitType,this.startAt,this.endAt)},WT.prototype.matchesAllDocuments=function(){return 0===this.filters.length&&null===this.limit&&null==this.startAt&&null==this.endAt&&(0===this.explicitOrderBy.length||1===this.explicitOrderBy.length&&this.explicitOrderBy[0].field.isKeyField())},WT.prototype.canonicalId=function(){return this.toTarget().canonicalId()+"|lt:"+this.limitType},WT.prototype.toString=function(){return"Query(target="+this.toTarget().toString()+"; limitType="+this.limitType+")"},WT.prototype.isEqual=function(t){return this.toTarget().isEqual(t.toTarget())&&this.limitType===t.limitType},WT.prototype.docComparator=function(t,e){for(var n=!1,r=0,i=this.orderBy;r<i.length;r++){var o=i[r],a=o.compare(t,e);if(0!==a)return a;n=n||o.field.isKeyField()}return tg(n,"orderBy used that doesn't compare on key field"),0},WT.prototype.matches=function(t){return this.matchesPathAndCollectionGroup(t)&&this.matchesOrderBy(t)&&this.matchesFilters(t)&&this.matchesBounds(t)},WT.prototype.hasLimitToFirst=function(){return!LT(this.limit)&&this.limitType===UT.First},WT.prototype.hasLimitToLast=function(){return!LT(this.limit)&&this.limitType===UT.Last},WT.prototype.getFirstOrderByField=function(){return 0<this.explicitOrderBy.length?this.explicitOrderBy[0].field:null},WT.prototype.getInequalityFilterField=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof zT&&n.isInequality())return n.field}return null},WT.prototype.findFilterOperator=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof zT&&0<=t.indexOf(r.op))return r.op}return null},WT.prototype.isDocumentQuery=function(){return this.toTarget().isDocumentQuery()},WT.prototype.isCollectionGroupQuery=function(){return null!==this.collectionGroup},WT.prototype.toTarget=function(){if(!this.memoizedTarget)if(this.limitType===UT.First)this.memoizedTarget=new qT(this.path,this.collectionGroup,this.orderBy,this.filters,this.limit,this.startAt,this.endAt);else{for(var t=[],e=0,n=this.orderBy;e<n.length;e++){var r=n[e],i=r.dir===lE.DESCENDING?lE.ASCENDING:lE.DESCENDING;t.push(new mE(r.field,i))}var o=this.endAt?new pE(this.endAt.position,!this.endAt.before):null,a=this.startAt?new pE(this.startAt.position,!this.startAt.before):null;this.memoizedTarget=new qT(this.path,this.collectionGroup,t,this.filters,this.limit,o,a)}return this.memoizedTarget},WT.prototype.matchesPathAndCollectionGroup=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.hasCollectionId(this.collectionGroup)&&this.path.isPrefixOf(e):ov.isDocumentKey(this.path)?this.path.isEqual(e):this.path.isImmediateParentOf(e)},WT.prototype.matchesOrderBy=function(t){for(var e=0,n=this.explicitOrderBy;e<n.length;e++){var r=n[e];if(!r.field.isKeyField()&&null===t.field(r.field))return!1}return!0},WT.prototype.matchesFilters=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},WT.prototype.matchesBounds=function(t){return!(this.startAt&&!this.startAt.sortsBeforeDocument(this.orderBy,t)||this.endAt&&this.endAt.sortsBeforeDocument(this.orderBy,t))},WT.prototype.assertValidBound=function(t){tg(t.position.length<=this.orderBy.length,"Bound is longer than orderBy")},WT);function WT(t,e,n,r,i,o,a,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=UT.First),void 0===a&&(a=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=a,this.endAt=s,this.memoizedOrderBy=null,this.memoizedTarget=null,this.startAt&&this.assertValidBound(this.startAt),this.endAt&&this.assertValidBound(this.endAt)}function KT(){}var QT=(HT.fromString=function(t){switch(t){case"<":return HT.LESS_THAN;case"<=":return HT.LESS_THAN_OR_EQUAL;case"==":return HT.EQUAL;case">=":return HT.GREATER_THAN_OR_EQUAL;case">":return HT.GREATER_THAN;case"array-contains":return HT.ARRAY_CONTAINS;case"in":return HT.IN;case"array-contains-any":return HT.ARRAY_CONTAINS_ANY;default:return Zy("Unknown FieldFilter operator: "+t)}},HT.prototype.toString=function(){return this.name},HT.prototype.isEqual=function(t){return this.name===t.name},HT.LESS_THAN=new HT("<"),HT.LESS_THAN_OR_EQUAL=new HT("<="),HT.EQUAL=new HT("=="),HT.GREATER_THAN=new HT(">"),HT.GREATER_THAN_OR_EQUAL=new HT(">="),HT.ARRAY_CONTAINS=new HT("array-contains"),HT.IN=new HT("in"),HT.ARRAY_CONTAINS_ANY=new HT("array-contains-any"),HT);function HT(t){this.name=t}var GT,zT=(da(YT,GT=KT),YT.create=function(t,e,n){if(t.isKeyField())return e===QT.IN?(tg(n instanceof Hw,"Comparing on key with IN, but filter value not an ArrayValue"),tg(n.internalValue.every(function(t){return t instanceof Fw}),"Comparing on key with IN, but an array value was not a RefValue"),new tE(t,n)):(tg(n instanceof Fw,"Comparing on key, but filter value not a RefValue"),tg(e!==QT.ARRAY_CONTAINS&&e!==QT.ARRAY_CONTAINS_ANY,"'"+e.toString()+"' queries don't make sense on document keys."),new JT(t,e,n));if(n.isEqual(cw.INSTANCE)){if(e!==QT.EQUAL)throw new ag(og.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new YT(t,e,n)}if(n.isEqual(Tw.NAN)){if(e!==QT.EQUAL)throw new ag(og.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new YT(t,e,n)}return e===QT.ARRAY_CONTAINS?new rE(t,n):e===QT.IN?(tg(n instanceof Hw,"IN filter has invalid value: "+n.toString()),new aE(t,n)):e===QT.ARRAY_CONTAINS_ANY?(tg(n instanceof Hw,"ARRAY_CONTAINS_ANY filter has invalid value: "+n.toString()),new cE(t,n)):new YT(t,e,n)},YT.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.typeOrder===e.typeOrder&&this.matchesComparison(e.compareTo(this.value))},YT.prototype.matchesComparison=function(t){switch(this.op){case QT.LESS_THAN:return t<0;case QT.LESS_THAN_OR_EQUAL:return t<=0;case QT.EQUAL:return 0===t;case QT.GREATER_THAN:return 0<t;case QT.GREATER_THAN_OR_EQUAL:return 0<=t;default:return Zy("Unknown FieldFilter operator: "+this.op)}},YT.prototype.isInequality=function(){return 0<=[QT.LESS_THAN,QT.LESS_THAN_OR_EQUAL,QT.GREATER_THAN,QT.GREATER_THAN_OR_EQUAL].indexOf(this.op)},YT.prototype.canonicalId=function(){return this.field.canonicalString()+this.op.toString()+this.value.toString()},YT.prototype.isEqual=function(t){return t instanceof YT&&this.op.isEqual(t.op)&&this.field.isEqual(t.field)&&this.value.isEqual(t.value)},YT.prototype.toString=function(){return this.field.canonicalString()+" "+this.op+" "+this.value.value()},YT);function YT(t,e,n){var r=GT.call(this)||this;return r.field=t,r.op=e,r.value=n,r}var XT,JT=(da($T,XT=zT),$T.prototype.matches=function(t){var e=this.value,n=ov.comparator(t.key,e.key);return this.matchesComparison(n)},$T);function $T(){return null!==XT&&XT.apply(this,arguments)||this}var ZT,tE=(da(eE,ZT=zT),eE.prototype.matches=function(e){return this.value.internalValue.some(function(t){return e.key.isEqual(t.key)})},eE);function eE(t,e){var n=ZT.call(this,t,QT.IN,e)||this;return n.value=e,n}var nE,rE=(da(iE,nE=zT),iE.prototype.matches=function(t){var e=t.field(this.field);return e instanceof Hw&&e.contains(this.value)},iE);function iE(t,e){return nE.call(this,t,QT.ARRAY_CONTAINS,e)||this}var oE,aE=(da(sE,oE=zT),sE.prototype.matches=function(t){var e=this.value,n=t.field(this.field);return null!==n&&e.contains(n)},sE);function sE(t,e){var n=oE.call(this,t,QT.IN,e)||this;return n.value=e,n}var uE,cE=(da(hE,uE=zT),hE.prototype.matches=function(t){var e=this,n=t.field(this.field);return n instanceof Hw&&n.internalValue.some(function(t){return e.value.contains(t)})},hE);function hE(t,e){var n=uE.call(this,t,QT.ARRAY_CONTAINS_ANY,e)||this;return n.value=e,n}var lE=(fE.prototype.toString=function(){return this.name},fE.ASCENDING=new fE("asc"),fE.DESCENDING=new fE("desc"),fE);function fE(t){this.name=t}var pE=(dE.prototype.canonicalId=function(){for(var t=this.before?"b:":"a:",e=0,n=this.position;e<n.length;e++)t+=n[e].toString();return t},dE.prototype.sortsBeforeDocument=function(t,e){tg(this.position.length<=t.length,"Bound has more components than query's orderBy");for(var n=0,r=0;r<this.position.length;r++){var i=t[r],o=this.position[r];if(i.field.isKeyField())tg(o instanceof Fw,"Bound has a non-key value where the key path is being used."),n=ov.comparator(o.key,e.key);else{var a=e.field(i.field);tg(null!==a,"Field should exist since document matched the orderBy already."),n=o.compareTo(a)}if(i.dir===lE.DESCENDING&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},dE.prototype.isEqual=function(t){if(null===t)return!1;if(this.before!==t.before||this.position.length!==t.position.length)return!1;for(var e=0;e<this.position.length;e++){var n=this.position[e],r=t.position[e];if(!n.isEqual(r))return!1}return!0},dE);function dE(t,e){this.position=t,this.before=e}var mE=(yE.prototype.compare=function(t,e){var n=this.isKeyOrderBy?Jw.compareByKey(t,e):Jw.compareByField(this.field,t,e);switch(this.dir){case lE.ASCENDING:return n;case lE.DESCENDING:return-1*n;default:return Zy("Unknown direction: "+this.dir)}},yE.prototype.canonicalId=function(){return this.field.canonicalString()+this.dir.toString()},yE.prototype.toString=function(){return this.field.canonicalString()+" ("+this.dir+")"},yE.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},yE);function yE(t,e){this.field=t,void 0===e&&(e=lE.ASCENDING),this.dir=e,this.isKeyOrderBy=t.isKeyField()}var gE=new mE(rv.keyField(),lE.ASCENDING),vE=new mE(rv.keyField(),lE.DESCENDING),bE=(wE.prototype.setLocalDocumentsView=function(t){this.localDocumentsView=t},wE.prototype.getDocumentsMatchingQuery=function(e,r,i,o){var a=this;return tg(void 0!==this.localDocumentsView,"setLocalDocumentsView() not called"),r.matchesAllDocuments()?this.executeFullCollectionScan(e,r):i.isEqual(Sv.MIN)?this.executeFullCollectionScan(e,r):this.localDocumentsView.getDocuments(e,o).next(function(t){var n=a.applyQuery(r,t);return(r.hasLimitToFirst()||r.hasLimitToLast())&&a.needsRefill(r.limitType,n,o,i)?a.executeFullCollectionScan(e,r):(zy()<=Uy.DEBUG&&Xy("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),r.toString()),a.localDocumentsView.getDocumentsMatchingQuery(e,r,i).next(function(e){return n.forEach(function(t){e=e.insert(t.key,t)}),e}))})},wE.prototype.applyQuery=function(n,t){var r=new Mv(function(t,e){return n.docComparator(t,e)});return t.forEach(function(t,e){e instanceof Jw&&n.matches(e)&&(r=r.add(e))}),r},wE.prototype.needsRefill=function(t,e,n,r){if(n.size!==e.size)return!0;var i=t===UT.First?e.last():e.first();return!!i&&(i.hasPendingWrites||0<i.version.compareTo(r))},wE.prototype.executeFullCollectionScan=function(t,e){return zy()<=Uy.DEBUG&&Xy("IndexFreeQueryEngine","Using full collection scan to execute query: %s",e.toString()),this.localDocumentsView.getDocumentsMatchingQuery(t,e,Sv.MIN)},wE);function wE(){}var _E=(TE.prototype.getDocument=function(e,n){var r=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKey(e,n).next(function(t){return r.getDocumentInternal(e,n,t)})},TE.prototype.getDocumentInternal=function(t,r,i){return this.remoteDocumentCache.getEntry(t,r).next(function(t){for(var e=0,n=i;e<n.length;e++)t=n[e].applyToLocalView(r,t);return t})},TE.prototype.applyLocalMutationsToDocuments=function(t,e,i){var o=qv();return e.forEach(function(t,e){for(var n=0,r=i;n<r.length;n++)e=r[n].applyToLocalView(t,e);o=o.insert(t,e)}),o},TE.prototype.getDocuments=function(e,t){var n=this;return this.remoteDocumentCache.getEntries(e,t).next(function(t){return n.getLocalViewOfDocuments(e,t)})},TE.prototype.getLocalViewOfDocuments=function(r,i){var o=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(r,i).next(function(t){var e=o.applyLocalMutationsToDocuments(r,i,t),n=Vv();return e.forEach(function(t,e){e=e||new t_(t,Sv.forDeletedDoc()),n=n.insert(t,e)}),n})},TE.prototype.getDocumentsMatchingQuery=function(t,e,n){return e.isDocumentQuery()?this.getDocumentsMatchingDocumentQuery(t,e.path):e.isCollectionGroupQuery()?this.getDocumentsMatchingCollectionGroupQuery(t,e,n):this.getDocumentsMatchingCollectionQuery(t,e,n)},TE.prototype.getDocumentsMatchingDocumentQuery=function(t,e){return this.getDocument(t,new ov(e)).next(function(t){var e=jv();return t instanceof Jw&&(e=e.insert(t.key,t)),e})},TE.prototype.getDocumentsMatchingCollectionGroupQuery=function(n,r,i){var o=this;tg(r.path.isEmpty(),"Currently we only support collection group queries at the root.");var a=r.collectionGroup,s=jv();return this.indexManager.getCollectionParents(n,a).next(function(t){return Zv.forEach(t,function(t){var e=r.asCollectionQueryAtPath(t.child(a));return o.getDocumentsMatchingCollectionQuery(n,e,i).next(function(t){t.forEach(function(t,e){s=s.insert(t,e)})})}).next(function(){return s})})},TE.prototype.getDocumentsMatchingCollectionQuery=function(e,n,t){var h,l,r=this;return this.remoteDocumentCache.getDocumentsMatchingQuery(e,n,t).next(function(t){return h=t,r.mutationQueue.getAllMutationBatchesAffectingQuery(e,n)}).next(function(t){return l=t,r.addMissingBaseDocuments(e,l,h).next(function(t){h=t;for(var e=0,n=l;e<n.length;e++)for(var r=n[e],i=0,o=r.mutations;i<o.length;i++){var a=o[i],s=a.key,u=h.get(s),c=a.applyToLocalView(u,u,r.localWriteTime);h=c instanceof Jw?h.insert(s,c):h.remove(s)}})}).next(function(){return h.forEach(function(t,e){n.matches(e)||(h=h.remove(t))}),h})},TE.prototype.addMissingBaseDocuments=function(t,e,n){for(var r=Hv(),i=0,o=e;i<o.length;i++)for(var a=0,s=o[i].mutations;a<s.length;a++){var u=s[a];u instanceof Hb&&null===n.get(u.key)&&(r=r.add(u.key))}var c=n;return this.remoteDocumentCache.getEntries(t,r).next(function(t){return t.forEach(function(t,e){null!==e&&e instanceof Jw&&(c=c.insert(t,e))}),c})},TE);function TE(t,e,n){this.remoteDocumentCache=t,this.mutationQueue=e,this.indexManager=n}var EE=(SE.prototype.isEmpty=function(){return this.refsByKey.isEmpty()},SE.prototype.addReference=function(t,e){var n=new IE(t,e);this.refsByKey=this.refsByKey.add(n),this.refsByTarget=this.refsByTarget.add(n)},SE.prototype.addReferences=function(t,e){var n=this;t.forEach(function(t){return n.addReference(t,e)})},SE.prototype.removeReference=function(t,e){this.removeRef(new IE(t,e))},SE.prototype.removeReferences=function(t,e){var n=this;t.forEach(function(t){return n.removeReference(t,e)})},SE.prototype.removeReferencesForId=function(t){var e=this,n=ov.EMPTY,r=new IE(n,t),i=new IE(n,t+1),o=[];return this.refsByTarget.forEachInRange([r,i],function(t){e.removeRef(t),o.push(t.key)}),o},SE.prototype.removeAllReferences=function(){var e=this;this.refsByKey.forEach(function(t){return e.removeRef(t)})},SE.prototype.removeRef=function(t){this.refsByKey=this.refsByKey.delete(t),this.refsByTarget=this.refsByTarget.delete(t)},SE.prototype.referencesForId=function(t){var e=ov.EMPTY,n=new IE(e,t),r=new IE(e,t+1),i=Hv();return this.refsByTarget.forEachInRange([n,r],function(t){i=i.add(t.key)}),i},SE.prototype.containsKey=function(t){var e=new IE(t,0),n=this.refsByKey.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},SE);function SE(){this.refsByKey=new Mv(IE.compareByKey),this.refsByTarget=new Mv(IE.compareByTargetId)}var IE=(CE.compareByKey=function(t,e){return ov.comparator(t.key,e.key)||xg(t.targetOrBatchId,e.targetOrBatchId)},CE.compareByTargetId=function(t,e){return xg(t.targetOrBatchId,e.targetOrBatchId)||ov.comparator(t.key,e.key)},CE);function CE(t,e){this.key=t,this.targetOrBatchId=e}var NE=(AE.prototype.start=function(){return this.synchronizeLastDocumentChangeReadTime()},AE.prototype.handleUserChange=function(i){return ya(this,void 0,void 0,function(){var e,y,n,r=this;return ga(this,function(t){switch(t.label){case 0:return e=this.mutationQueue,y=this.localDocuments,[4,this.persistence.runTransaction("Handle user change","readonly-idempotent",function(d){var m;return r.mutationQueue.getAllMutationBatches(d).next(function(t){return m=t,e=r.persistence.getMutationQueue(i),y=new _E(r.remoteDocuments,e,r.persistence.getIndexManager()),e.getAllMutationBatches(d)}).next(function(t){for(var e=[],n=[],r=Hv(),i=0,o=m;i<o.length;i++){var a=o[i];e.push(a.batchId);for(var s=0,u=a.mutations;s<u.length;s++){var c=u[s];r=r.add(c.key)}}for(var h=0,l=t;h<l.length;h++){a=l[h],n.push(a.batchId);for(var f=0,p=a.mutations;f<p.length;f++)c=p[f],r=r.add(c.key)}return y.getDocuments(d,r).next(function(t){return{affectedDocuments:t,removedBatchIds:e,addedBatchIds:n}})})})];case 1:return n=t.sent(),this.mutationQueue=e,this.localDocuments=y,this.queryEngine.setLocalDocumentsView(this.localDocuments),[2,n]}})})},AE.prototype.localWrite=function(s){var u,c=this,h=Tv.now(),t=s.reduce(function(t,e){return t.add(e.key)},Hv());return this.persistence.runTransaction("Locally write mutations","readwrite-idempotent",function(a){return c.localDocuments.getDocuments(a,t).next(function(t){u=t;for(var e=[],n=0,r=s;n<r.length;n++){var i=r[n],o=i.extractBaseValue(u.get(i.key));null!=o&&e.push(new Hb(i.key,o,o.fieldMask(),Ub.exists(!0)))}return c.mutationQueue.addMutationBatch(a,h,e,s)})}).then(function(t){var e=t.applyToLocalDocumentSet(u);return{batchId:t.batchId,changes:e}})},AE.prototype.lookupMutationDocuments=function(t){var n=this;return this.persistence.runTransaction("Lookup mutation documents","readonly-idempotent",function(e){return n.mutationQueue.lookupMutationKeys(e,t).next(function(t){return t?n.localDocuments.getDocuments(e,t):Zv.resolve(null)})})},AE.prototype.acknowledgeBatch=function(r){var i=this;return this.persistence.runTransaction("Acknowledge batch","readwrite-primary-idempotent",function(t){var e=r.batch.keys(),n=i.remoteDocuments.newChangeBuffer({trackRemovals:!0});return i.mutationQueue.acknowledgeBatch(t,r.batch,r.streamToken).next(function(){return i.applyWriteToRemoteDocuments(t,r,n)}).next(function(){return n.apply(t)}).next(function(){return i.mutationQueue.performConsistencyCheck(t)}).next(function(){return i.localDocuments.getDocuments(t,e)})})},AE.prototype.rejectBatch=function(t){var r=this;return this.persistence.runTransaction("Reject batch","readwrite-primary-idempotent",function(e){var n;return r.mutationQueue.lookupMutationBatch(e,t).next(function(t){return tg(null!==t,"Attempt to reject nonexistent batch!"),n=t.keys(),r.mutationQueue.removeMutationBatch(e,t)}).next(function(){return r.mutationQueue.performConsistencyCheck(e)}).next(function(){return r.localDocuments.getDocuments(e,n)})})},AE.prototype.getHighestUnacknowledgedBatchId=function(){var e=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly-idempotent",function(t){return e.mutationQueue.getHighestUnacknowledgedBatchId(t)})},AE.prototype.getLastStreamToken=function(){var e=this;return this.persistence.runTransaction("Get last stream token","readonly-idempotent",function(t){return e.mutationQueue.getLastStreamToken(t)})},AE.prototype.setLastStreamToken=function(e){var n=this;return this.persistence.runTransaction("Set last stream token","readwrite-primary-idempotent",function(t){return n.mutationQueue.setLastStreamToken(t,e)})},AE.prototype.getLastRemoteSnapshotVersion=function(){var e=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly-idempotent",function(t){return e.targetCache.getLastRemoteSnapshotVersion(t)})},AE.prototype.applyRemoteEvent=function(u){var c=this,h=u.snapshotVersion,l=this.targetDataByTarget;return this.persistence.runTransaction("Apply remote event","readwrite-primary-idempotent",function(o){var i=c.remoteDocuments.newChangeBuffer({trackRemovals:!0});l=c.targetDataByTarget;var a=[];lg(u.targetChanges,function(t,e){var n=l.get(t);if(n){a.push(c.targetCache.removeMatchingKeys(o,e.removedDocuments,t).next(function(){return c.targetCache.addMatchingKeys(o,e.addedDocuments,t)}));var r=e.resumeToken;if(0<r.length){var i=n.withResumeToken(r,h).withSequenceNumber(o.currentSequenceNumber);l=l.insert(t,i),AE.shouldPersistTargetData(n,i,e)&&a.push(c.targetCache.updateTargetData(o,i))}}});var s=Vv(),n=Hv();if(u.documentUpdates.forEach(function(t,e){n=n.add(t)}),a.push(i.getEntries(o,n).next(function(r){u.documentUpdates.forEach(function(t,e){var n=r.get(t);e instanceof t_&&e.version.isEqual(Sv.MIN)?(i.removeEntry(t,h),s=s.insert(t,e)):null==n||0<e.version.compareTo(n.version)||0===e.version.compareTo(n.version)&&n.hasPendingWrites?(tg(!Sv.MIN.isEqual(h),"Cannot add a document when the remote version is zero"),i.addEntry(e,h),s=s.insert(t,e)):Xy("LocalStore","Ignoring outdated watch update for ",t,". Current version:",n.version," Watch version:",e.version),u.resolvedLimboDocuments.has(t)&&a.push(c.persistence.referenceDelegate.updateLimboDocument(o,t))})})),!h.isEqual(Sv.MIN)){var t=c.targetCache.getLastRemoteSnapshotVersion(o).next(function(t){return tg(0<=h.compareTo(t),"Watch stream reverted to previous snapshot?? "+h+" < "+t),c.targetCache.setTargetsMetadata(o,o.currentSequenceNumber,h)});a.push(t)}return Zv.waitFor(a).next(function(){return i.apply(o)}).next(function(){return c.localDocuments.getLocalViewOfDocuments(o,s)})}).then(function(t){return c.targetDataByTarget=l,t})},AE.shouldPersistTargetData=function(t,e,n){return tg(0<e.resumeToken.length,"Attempted to persist target data with no resume token"),0===t.resumeToken.length||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=this.RESUME_TOKEN_MAX_AGE_MICROS||0<n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size},AE.prototype.notifyLocalViewChanges=function(t){for(var n=this,e=0,r=t;e<r.length;e++){var i=r[e],o=i.targetId;if(this.localViewReferences.addReferences(i.addedKeys,o),this.localViewReferences.removeReferences(i.removedKeys,o),!i.fromCache){var a=this.targetDataByTarget.get(o);tg(null!==a,"Can't set limbo-free snapshot version for unknown target: "+o);var s=a.snapshotVersion,u=a.withLastLimboFreeSnapshotVersion(s);this.targetDataByTarget=this.targetDataByTarget.insert(o,u)}}return this.persistence.runTransaction("notifyLocalViewChanges","readwrite-idempotent",function(e){return Zv.forEach(t,function(t){return Zv.forEach(t.removedKeys,function(t){return n.persistence.referenceDelegate.removeReference(e,t)})})})},AE.prototype.nextMutationBatch=function(e){var n=this;return this.persistence.runTransaction("Get next mutation batch","readonly-idempotent",function(t){return void 0===e&&(e=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(t,e)})},AE.prototype.readDocument=function(e){var n=this;return this.persistence.runTransaction("read document","readonly-idempotent",function(t){return n.localDocuments.getDocument(t,e)})},AE.prototype.allocateTarget=function(r){var i=this;return this.persistence.runTransaction("Allocate target","readwrite-idempotent",function(e){var n;return i.targetCache.getTargetData(e,r).next(function(t){return t?(n=t,Zv.resolve(n)):i.targetCache.allocateTargetId(e).next(function(t){return n=new nT(r,t,X_.Listen,e.currentSequenceNumber),i.targetCache.addTargetData(e,n).next(function(){return n})})})}).then(function(t){return null===i.targetDataByTarget.get(t.targetId)&&(i.targetDataByTarget=i.targetDataByTarget.insert(t.targetId,t),i.targetIdByTarget.set(r,t.targetId)),t})},AE.prototype.getTargetData=function(t,e){var n=this.targetIdByTarget.get(e);return void 0!==n?Zv.resolve(this.targetDataByTarget.get(n)):this.targetCache.getTargetData(t,e)},AE.prototype.releaseTarget=function(n,r){var i=this,o=this.targetDataByTarget.get(n);tg(null!==o,"Tried to release nonexistent target: "+n);var t=r?"readwrite-idempotent":"readwrite-primary-idempotent";return this.persistence.runTransaction("Release target",t,function(e){var t=i.localViewReferences.removeReferencesForId(n);return r?Zv.resolve():Zv.forEach(t,function(t){return i.persistence.referenceDelegate.removeReference(e,t)}).next(function(){i.persistence.referenceDelegate.removeTarget(e,o)})}).then(function(){i.targetDataByTarget=i.targetDataByTarget.remove(n),i.targetIdByTarget.delete(o.target)})},AE.prototype.executeQuery=function(t,n){var r=this,i=Sv.MIN,o=Hv();return this.persistence.runTransaction("Execute query","readonly-idempotent",function(e){return r.getTargetData(e,t.toTarget()).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.targetCache.getMatchingKeysForTargetId(e,t.targetId).next(function(t){o=t})}).next(function(){return r.queryEngine.getDocumentsMatchingQuery(e,t,n?i:Sv.MIN,n?o:Hv())}).next(function(t){return{documents:t,remoteKeys:o}})})},AE.prototype.remoteDocumentKeys=function(e){var n=this;return this.persistence.runTransaction("Remote document keys","readonly-idempotent",function(t){return n.targetCache.getMatchingKeysForTargetId(t,e)})},AE.prototype.getActiveClients=function(){return this.persistence.getActiveClients()},AE.prototype.removeCachedMutationBatchMetadata=function(t){this.mutationQueue.removeCachedMutationKeys(t)},AE.prototype.setNetworkEnabled=function(t){this.persistence.setNetworkEnabled(t)},AE.prototype.applyWriteToRemoteDocuments=function(t,i,o){var e=this,a=i.batch,n=a.keys(),s=Zv.resolve();return n.forEach(function(r){s=s.next(function(){return o.getEntry(t,r)}).next(function(t){var e=t,n=i.docVersions.get(r);tg(null!==n,"ackVersions should contain every doc in the write."),(!e||e.version.compareTo(n)<0)&&((e=a.applyToRemoteDocument(r,e,i))?o.addEntry(e,i.commitVersion):tg(!t,"Mutation batch "+a+" applied to document "+t+" resulted in null"))})}),s.next(function(){return e.mutationQueue.removeMutationBatch(t,a)})},AE.prototype.collectGarbage=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary-idempotent",function(t){return e.collect(t,n.targetDataByTarget)})},AE.prototype.getTarget=function(e){var n=this,t=this.targetDataByTarget.get(e);return t?Promise.resolve(t.target):this.persistence.runTransaction("Get target data","readonly-idempotent",function(t){return n.targetCache.getTargetDataForTarget(t,e).next(function(t){return t?t.target:null})})},AE.prototype.getNewDocumentChanges=function(){var r=this;return this.persistence.runTransaction("Get new document changes","readonly-idempotent",function(t){return r.remoteDocuments.getNewDocumentChanges(t,r.lastDocumentChangeReadTime)}).then(function(t){var e=t.changedDocs,n=t.readTime;return r.lastDocumentChangeReadTime=n,e})},AE.prototype.synchronizeLastDocumentChangeReadTime=function(){return ya(this,void 0,void 0,function(){var e,n=this;return ga(this,function(t){return this.remoteDocuments instanceof h_?(e=this.remoteDocuments,[2,this.persistence.runTransaction("Synchronize last document change read time","readonly-idempotent",function(t){return e.getLastDocumentChange(t)}).then(function(t){var e=t.readTime;n.lastDocumentChangeReadTime=e})]):[2]})})},AE.RESUME_TOKEN_MAX_AGE_MICROS=3e8,AE);function AE(t,e,n){this.persistence=t,this.queryEngine=e,this.localViewReferences=new EE,this.targetDataByTarget=new Cv(xg),this.targetIdByTarget=new o_(function(t){return t.canonicalId()}),this.lastDocumentChangeReadTime=Sv.MIN,tg(t.started,"LocalStore was passed an unstarted persistence implementation"),this.persistence.referenceDelegate.setInMemoryPins(this.localViewReferences),this.mutationQueue=t.getMutationQueue(n),this.remoteDocuments=t.getRemoteDocumentCache(),this.targetCache=t.getTargetCache(),this.localDocuments=new _E(this.remoteDocuments,this.mutationQueue,this.persistence.getIndexManager()),this.queryEngine.setLocalDocumentsView(this.localDocuments)}var kE=(DE.prototype.checkEmpty=function(t){return Zv.resolve(0===this.mutationQueue.length)},DE.prototype.acknowledgeBatch=function(t,e,n){var r=e.batchId,i=this.indexOfExistingBatchId(r,"acknowledged");tg(0===i,"Can only acknowledge the first batch in the mutation queue");var o=this.mutationQueue[i];return tg(r===o.batchId,"Queue ordering failure: expected batch "+r+", got batch "+o.batchId),this.lastStreamToken=n,Zv.resolve()},DE.prototype.getLastStreamToken=function(t){return Zv.resolve(this.lastStreamToken)},DE.prototype.setLastStreamToken=function(t,e){return this.lastStreamToken=e,Zv.resolve()},DE.prototype.addMutationBatch=function(t,e,n,r){tg(0!==r.length,"Mutation batches should not be empty");var i=this.nextBatchId;this.nextBatchId++,0<this.mutationQueue.length&&tg(this.mutationQueue[this.mutationQueue.length-1].batchId<i,"Mutation batchIDs must be monotonically increasing order");var o=new Yv(i,e,n,r);this.mutationQueue.push(o);for(var a=0,s=r;a<s.length;a++){var u=s[a];this.batchesByDocumentKey=this.batchesByDocumentKey.add(new IE(u.key,i)),this.indexManager.addToCollectionParentIndex(t,u.key.path.popLast())}return Zv.resolve(o)},DE.prototype.lookupMutationBatch=function(t,e){return Zv.resolve(this.findMutationBatch(e))},DE.prototype.lookupMutationKeys=function(t,e){var n=this.findMutationBatch(e);return tg(null!=n,"Failed to find local mutation batch."),Zv.resolve(n.keys())},DE.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=e+1,r=this.indexOfBatchId(n),i=r<0?0:r;return Zv.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)},DE.prototype.getHighestUnacknowledgedBatchId=function(){return Zv.resolve(0===this.mutationQueue.length?-1:this.nextBatchId-1)},DE.prototype.getAllMutationBatches=function(t){return Zv.resolve(this.mutationQueue.slice())},DE.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,e=new IE(n,0),i=new IE(n,Number.POSITIVE_INFINITY),o=[];return this.batchesByDocumentKey.forEachInRange([e,i],function(t){tg(n.isEqual(t.key),"Should only iterate over a single key's batches");var e=r.findMutationBatch(t.targetOrBatchId);tg(null!==e,"Batches in the index must exist in the main table"),o.push(e)}),Zv.resolve(o)},DE.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var r=this,i=new Mv(xg);return e.forEach(function(e){var t=new IE(e,0),n=new IE(e,Number.POSITIVE_INFINITY);r.batchesByDocumentKey.forEachInRange([t,n],function(t){tg(e.isEqual(t.key),"For each key, should only iterate over a single key's batches"),i=i.add(t.targetOrBatchId)})}),Zv.resolve(this.findMutationBatches(i))},DE.prototype.getAllMutationBatchesAffectingQuery=function(t,e){tg(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;ov.isDocumentKey(i)||(i=i.child(""));var o=new IE(new ov(i),0),a=new Mv(xg);return this.batchesByDocumentKey.forEachWhile(function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(a=a.add(t.targetOrBatchId)),!0)},o),Zv.resolve(this.findMutationBatches(a))},DE.prototype.findMutationBatches=function(t){var n=this,r=[];return t.forEach(function(t){var e=n.findMutationBatch(t);null!==e&&r.push(e)}),r},DE.prototype.removeMutationBatch=function(n,r){var i=this;tg(0===this.indexOfExistingBatchId(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.mutationQueue.shift();var o=this.batchesByDocumentKey;return Zv.forEach(r.mutations,function(t){var e=new IE(t.key,r.batchId);return o=o.delete(e),i.referenceDelegate.removeMutationReference(n,t.key)}).next(function(){i.batchesByDocumentKey=o})},DE.prototype.removeCachedMutationKeys=function(t){},DE.prototype.containsKey=function(t,e){var n=new IE(e,0),r=this.batchesByDocumentKey.firstAfterOrEqual(n);return Zv.resolve(e.isEqual(r&&r.key))},DE.prototype.performConsistencyCheck=function(t){return 0===this.mutationQueue.length&&tg(this.batchesByDocumentKey.isEmpty(),"Document leak -- detected dangling mutation references when queue is empty."),Zv.resolve()},DE.prototype.indexOfExistingBatchId=function(t,e){var n=this.indexOfBatchId(t);return tg(0<=n&&n<this.mutationQueue.length,"Batches must exist to be "+e),n},DE.prototype.indexOfBatchId=function(t){return 0===this.mutationQueue.length?0:t-this.mutationQueue[0].batchId},DE.prototype.findMutationBatch=function(t){var e=this.indexOfBatchId(t);if(e<0||e>=this.mutationQueue.length)return null;var n=this.mutationQueue[e];return tg(n.batchId===t,"If found batch must match"),n},DE);function DE(t,e){this.indexManager=t,this.referenceDelegate=e,this.mutationQueue=[],this.nextBatchId=1,this.lastStreamToken=rg(),this.batchesByDocumentKey=new Mv(IE.compareByKey)}var RE,OE=(PE.prototype.addEntry=function(t,e,n){tg(!n.isEqual(Sv.MIN),"Cannot add a document with a read time of zero");var r=e.key,i=this.docs.get(r),o=i?i.size:0,a=this.sizer(e);return this.docs=this.docs.insert(r,{maybeDocument:e,size:a,readTime:n}),this.size+=a-o,this.indexManager.addToCollectionParentIndex(t,r.path.popLast())},PE.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},PE.prototype.getEntry=function(t,e){var n=this.docs.get(e);return Zv.resolve(n?n.maybeDocument:null)},PE.prototype.getEntries=function(t,e){var n=this,r=qv();return e.forEach(function(t){var e=n.docs.get(t);r=r.insert(t,e?e.maybeDocument:null)}),Zv.resolve(r)},PE.prototype.getDocumentsMatchingQuery=function(t,e,n){tg(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");for(var r=jv(),i=new ov(e.path.child("")),o=this.docs.getIteratorFrom(i);o.hasNext();){var a=o.getNext(),s=a.key,u=a.value,c=u.maybeDocument,h=u.readTime;if(!e.path.isPrefixOf(s.path))break;h.compareTo(n)<=0||c instanceof Jw&&e.matches(c)&&(r=r.insert(c.key,c))}return Zv.resolve(r)},PE.prototype.forEachDocumentKey=function(t,e){return Zv.forEach(this.docs,function(t){return e(t)})},PE.prototype.getNewDocumentChanges=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},PE.prototype.newChangeBuffer=function(t){return new PE.RemoteDocumentChangeBuffer(this)},PE.prototype.getSize=function(t){return Zv.resolve(this.size)},PE.RemoteDocumentChangeBuffer=(da(ME,RE=s_),ME.prototype.applyChanges=function(n){var r=this,i=[];return this.changes.forEach(function(t,e){e?i.push(r.documentCache.addEntry(n,e,r.readTime)):r.documentCache.removeEntry(t)}),Zv.waitFor(i)},ME.prototype.getFromCache=function(t,e){return this.documentCache.getEntry(t,e)},ME.prototype.getAllFromCache=function(t,e){return this.documentCache.getEntries(t,e)},ME),PE);function PE(t,e){this.indexManager=t,this.sizer=e,this.docs=new Cv(ov.comparator),this.size=0}function ME(t){var e=RE.call(this)||this;return e.documentCache=t,e}var xE=(LE.prototype.forEachTarget=function(t,n){return this.targets.forEach(function(t,e){return n(e)}),Zv.resolve()},LE.prototype.getLastRemoteSnapshotVersion=function(t){return Zv.resolve(this.lastRemoteSnapshotVersion)},LE.prototype.getHighestSequenceNumber=function(t){return Zv.resolve(this.highestSequenceNumber)},LE.prototype.allocateTargetId=function(t){var e=this.targetIdGenerator.after(this.highestTargetId);return this.highestTargetId=e,Zv.resolve(e)},LE.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.highestSequenceNumber&&(this.highestSequenceNumber=e),Zv.resolve()},LE.prototype.saveTargetData=function(t){this.targets.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.highestSequenceNumber&&(this.highestSequenceNumber=t.sequenceNumber)},LE.prototype.addTargetData=function(t,e){return tg(!this.targets.has(e.target),"Adding a target that already exists"),this.saveTargetData(e),this.targetCount+=1,Zv.resolve()},LE.prototype.updateTargetData=function(t,e){return tg(this.targets.has(e.target),"Updating a non-existent target"),this.saveTargetData(e),Zv.resolve()},LE.prototype.removeTargetData=function(t,e){return tg(0<this.targetCount,"Removing a target from an empty cache"),tg(this.targets.has(e.target),"Removing a non-existent target from the cache"),this.targets.delete(e.target),this.references.removeReferencesForId(e.targetId),this.targetCount-=1,Zv.resolve()},LE.prototype.removeTargets=function(n,r,i){var o=this,a=0,s=[];return this.targets.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.targets.delete(t),s.push(o.removeMatchingKeysForTargetId(n,e.targetId)),a++)}),Zv.waitFor(s).next(function(){return a})},LE.prototype.getTargetCount=function(t){return Zv.resolve(this.targetCount)},LE.prototype.getTargetData=function(t,e){var n=this.targets.get(e)||null;return Zv.resolve(n)},LE.prototype.getTargetDataForTarget=function(t,e){return Zy("Not yet implemented.")},LE.prototype.addMatchingKeys=function(e,t,n){this.references.addReferences(t,n);var r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(function(t){i.push(r.addReference(e,t))}),Zv.waitFor(i)},LE.prototype.removeMatchingKeys=function(e,t,n){this.references.removeReferences(t,n);var r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(function(t){i.push(r.removeReference(e,t))}),Zv.waitFor(i)},LE.prototype.removeMatchingKeysForTargetId=function(t,e){return this.references.removeReferencesForId(e),Zv.resolve()},LE.prototype.getMatchingKeysForTargetId=function(t,e){var n=this.references.referencesForId(e);return Zv.resolve(n)},LE.prototype.containsKey=function(t,e){return Zv.resolve(this.references.containsKey(e))},LE);function LE(t){this.persistence=t,this.targets=new o_(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=Sv.MIN,this.highestTargetId=0,this.highestSequenceNumber=0,this.references=new EE,this.targetCount=0,this.targetIdGenerator=Eb.forTargetCache()}var FE=(UE.createLruPersistence=function(t,e,n){return new UE(t,function(t){return new KE(t,new iT(e),n)})},UE.createEagerPersistence=function(t){return new UE(t,function(t){return new jE(t)})},UE.prototype.shutdown=function(){return this._started=!1,Promise.resolve()},Object.defineProperty(UE.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),UE.prototype.getActiveClients=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return[2,[this.clientId]]})})},UE.prototype.setPrimaryStateListener=function(t){return t(!0)},UE.prototype.setDatabaseDeletedListener=function(){},UE.prototype.setNetworkEnabled=function(t){},UE.prototype.getIndexManager=function(){return this.indexManager},UE.prototype.getMutationQueue=function(t){var e=this.mutationQueues[t.toKey()];return e||(e=new kE(this.indexManager,this.referenceDelegate),this.mutationQueues[t.toKey()]=e),e},UE.prototype.getTargetCache=function(){return this.targetCache},UE.prototype.getRemoteDocumentCache=function(){return this.remoteDocumentCache},UE.prototype.runTransaction=function(t,e,n){var r=this;Xy("MemoryPersistence","Starting transaction:",t);var i=new qE(this.listenSequence.next());return this.referenceDelegate.onTransactionStarted(),n(i).next(function(t){return r.referenceDelegate.onTransactionCommitted(i).next(function(){return t})}).toPromise().then(function(t){return i.raiseOnCommittedEvent(),t})},UE.prototype.mutationQueuesContainKey=function(e,n){return Zv.or(function(t){var n=[];return fg(t,function(t,e){return n.push(e)}),n}(this.mutationQueues).map(function(t){return function(){return t.containsKey(e,n)}}))},UE);function UE(t,e){var n=this;this.clientId=t,this.mutationQueues={},this.listenSequence=new Gg(0),this._started=!1,this._started=!0,this.referenceDelegate=e(this),this.targetCache=new xE(this);this.indexManager=new g_,this.remoteDocumentCache=new OE(this.indexManager,function(t){return n.referenceDelegate.documentSize(t)})}var VE,qE=(da(BE,VE=yT),BE);function BE(t){var e=VE.call(this)||this;return e.currentSequenceNumber=t,e}var jE=(Object.defineProperty(WE.prototype,"orphanedDocuments",{get:function(){if(this._orphanedDocuments)return this._orphanedDocuments;throw Zy("orphanedDocuments is only valid during a transaction.")},enumerable:!0,configurable:!0}),WE.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},WE.prototype.addReference=function(t,e){return this.orphanedDocuments.delete(e),Zv.resolve()},WE.prototype.removeReference=function(t,e){return this.orphanedDocuments.add(e),Zv.resolve()},WE.prototype.removeMutationReference=function(t,e){return this.orphanedDocuments.add(e),Zv.resolve()},WE.prototype.removeTarget=function(t,e){var n=this,r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next(function(t){t.forEach(function(t){return n.orphanedDocuments.add(t)})}).next(function(){return r.removeTargetData(t,e)})},WE.prototype.onTransactionStarted=function(){this._orphanedDocuments=new Set},WE.prototype.onTransactionCommitted=function(t){var n=this,r=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Zv.forEach(this.orphanedDocuments,function(e){return n.isReferenced(t,e).next(function(t){t||r.removeEntry(e)})}).next(function(){return n._orphanedDocuments=null,r.apply(t)})},WE.prototype.updateLimboDocument=function(t,e){var n=this;return this.isReferenced(t,e).next(function(t){t?n.orphanedDocuments.delete(e):n.orphanedDocuments.add(e)})},WE.prototype.documentSize=function(t){return 0},WE.prototype.isReferenced=function(t,e){var n=this;return Zv.or([function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.mutationQueuesContainKey(t,e)},function(){return Zv.resolve(n.inMemoryPins.containsKey(e))}])},WE);function WE(t){this.persistence=t,this.inMemoryPins=null,this._orphanedDocuments=null}var KE=(QE.prototype.onTransactionStarted=function(){},QE.prototype.onTransactionCommitted=function(t){return Zv.resolve()},QE.prototype.forEachTarget=function(t,e){return this.persistence.getTargetCache().forEachTarget(t,e)},QE.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocumentCount(t);return this.persistence.getTargetCache().getTargetCount(t).next(function(e){return n.next(function(t){return e+t})})},QE.prototype.orphanedDocumentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},QE.prototype.forEachOrphanedDocumentSequenceNumber=function(n,r){var i=this;return Zv.forEach(this.orphanedSequenceNumbers,function(t,e){return i.isPinned(n,t,e).next(function(t){return t?Zv.resolve():r(e)})})},QE.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},QE.prototype.removeTargets=function(t,e,n){return this.persistence.getTargetCache().removeTargets(t,e,n)},QE.prototype.removeOrphanedDocuments=function(t,n){var r=this,i=0,e=this.persistence.getRemoteDocumentCache(),o=e.newChangeBuffer();return e.forEachDocumentKey(t,function(e){return r.isPinned(t,e,n).next(function(t){t||(i++,o.removeEntry(e))})}).next(function(){return o.apply(t)}).next(function(){return i})},QE.prototype.removeMutationReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Zv.resolve()},QE.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(t,n)},QE.prototype.addReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Zv.resolve()},QE.prototype.removeReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Zv.resolve()},QE.prototype.updateLimboDocument=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Zv.resolve()},QE.prototype.documentSize=function(t){var e,n=this.serializer.toDbRemoteDocument(t,t.version);if(n.document)e=n.document;else if(n.unknownDocument)e=n.unknownDocument;else{if(!n.noDocument)throw Zy("Unknown remote document type");e=n.noDocument}return JSON.stringify(e).length},QE.prototype.isPinned=function(t,e,n){var r=this;return Zv.or([function(){return r.persistence.mutationQueuesContainKey(t,e)},function(){return Zv.resolve(r.inMemoryPins.containsKey(e))},function(){return r.persistence.getTargetCache().containsKey(t,e)},function(){var t=r.orphanedSequenceNumbers.get(e);return Zv.resolve(void 0!==t&&n<t)}])},QE.prototype.getCacheSize=function(t){return this.persistence.getRemoteDocumentCache().getSize(t)},QE);function QE(t,e,n){this.persistence=t,this.serializer=e,this.inMemoryPins=null,this.orphanedSequenceNumbers=new o_(function(t){return vv(t.path)}),this.garbageCollector=new dT(this,n)}var HE=(GE.prototype.reset=function(){this.currentBaseMs=0},GE.prototype.resetToMax=function(){this.currentBaseMs=this.maxDelayMs},GE.prototype.backoffAndRun=function(t){var e=this;this.cancel();var n=Math.floor(this.currentBaseMs+this.jitterDelayMs()),r=Math.max(0,Date.now()-this.lastAttemptTime),i=Math.max(0,n-r);0<this.currentBaseMs&&Xy("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.currentBaseMs+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.timerPromise=this.queue.enqueueAfterDelay(this.timerId,i,function(){return e.lastAttemptTime=Date.now(),t()}),this.currentBaseMs*=this.backoffFactor,this.currentBaseMs<this.initialDelayMs&&(this.currentBaseMs=this.initialDelayMs),this.currentBaseMs>this.maxDelayMs&&(this.currentBaseMs=this.maxDelayMs)},GE.prototype.cancel=function(){null!==this.timerPromise&&(this.timerPromise.cancel(),this.timerPromise=null)},GE.prototype.jitterDelayMs=function(){return(Math.random()-.5)*this.currentBaseMs},GE);function GE(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.queue=t,this.timerId=e,this.initialDelayMs=n,this.backoffFactor=r,this.maxDelayMs=i,this.currentBaseMs=0,this.timerPromise=null,this.lastAttemptTime=Date.now(),this.reset()}var zE,YE,XE="PersistentStream";(YE=zE=zE||{})[YE.Initial=0]="Initial",YE[YE.Starting=1]="Starting",YE[YE.Open=2]="Open",YE[YE.Error=3]="Error",YE[YE.Backoff=4]="Backoff";var JE=($E.prototype.isStarted=function(){return this.state===zE.Starting||this.state===zE.Open||this.state===zE.Backoff},$E.prototype.isOpen=function(){return this.state===zE.Open},$E.prototype.start=function(){this.state!==zE.Error?(tg(this.state===zE.Initial,"Already started"),this.auth()):this.performBackoff()},$E.prototype.stop=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.isStarted()?[4,this.close(zE.Initial)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},$E.prototype.inhibitBackoff=function(){tg(!this.isStarted(),"Can only inhibit backoff in a stopped state"),this.state=zE.Initial,this.backoff.reset()},$E.prototype.markIdle=function(){var t=this;this.isOpen()&&null===this.idleTimer&&(this.idleTimer=this.queue.enqueueAfterDelay(this.idleTimerId,6e4,function(){return t.handleIdleCloseTimer()}))},$E.prototype.sendRequest=function(t){this.cancelIdleCheck(),this.stream.send(t)},$E.prototype.handleIdleCloseTimer=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return this.isOpen()?[2,this.close(zE.Initial)]:[2]})})},$E.prototype.cancelIdleCheck=function(){this.idleTimer&&(this.idleTimer.cancel(),this.idleTimer=null)},$E.prototype.close=function(e,n){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return tg(this.isStarted(),"Only started streams should be closed."),tg(e===zE.Error||LT(n),"Can't provide an error when not in an error state."),this.cancelIdleCheck(),this.backoff.cancel(),this.closeCount++,e!==zE.Error?this.backoff.reset():n&&n.code===og.RESOURCE_EXHAUSTED?(Jy(n.toString()),Jy("Using maximum backoff delay to prevent overloading the backend."),this.backoff.resetToMax()):n&&n.code===og.UNAUTHENTICATED&&this.credentialsProvider.invalidateToken(),null!==this.stream&&(this.tearDown(),this.stream.close(),this.stream=null),this.state=e,[4,this.listener.onClose(n)];case 1:return t.sent(),[2]}})})},$E.prototype.tearDown=function(){},$E.prototype.auth=function(){var n=this;tg(this.state===zE.Initial,"Must be in initial state to auth"),this.state=zE.Starting;var t=this.getCloseGuardedDispatcher(this.closeCount),e=this.closeCount;this.credentialsProvider.getToken().then(function(t){n.closeCount===e&&n.startStream(t)},function(e){t(function(){var t=new ag(og.UNKNOWN,"Fetching auth token failed: "+e.message);return n.handleStreamClose(t)})})},$E.prototype.startStream=function(t){var e=this;tg(this.state===zE.Starting,"Trying to start stream in a non-starting state");var n=this.getCloseGuardedDispatcher(this.closeCount);this.stream=this.startRpc(t),this.stream.onOpen(function(){n(function(){return tg(e.state===zE.Starting,"Expected stream to be in state Starting, but was "+e.state),e.state=zE.Open,e.listener.onOpen()})}),this.stream.onClose(function(t){n(function(){return e.handleStreamClose(t)})}),this.stream.onMessage(function(t){n(function(){return e.onMessage(t)})})},$E.prototype.performBackoff=function(){var t=this;tg(this.state===zE.Error,"Should only perform backoff when in Error state"),this.state=zE.Backoff,this.backoff.backoffAndRun(function(){return ya(t,void 0,void 0,function(){return ga(this,function(t){return tg(this.state===zE.Backoff,"Backoff elapsed but state is now: "+this.state),this.state=zE.Initial,this.start(),tg(this.isStarted(),"PersistentStream should have started"),[2]})})})},$E.prototype.handleStreamClose=function(t){return tg(this.isStarted(),"Can't handle server close on non-started stream"),Xy(XE,"close with error: "+t),this.stream=null,this.close(zE.Error,t)},$E.prototype.getCloseGuardedDispatcher=function(e){var n=this;return function(t){n.queue.enqueueAndForget(function(){return n.closeCount===e?t():(Xy(XE,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},$E);function $E(t,e,n,r,i,o){this.queue=t,this.idleTimerId=n,this.connection=r,this.credentialsProvider=i,this.listener=o,this.state=zE.Initial,this.closeCount=0,this.idleTimer=null,this.stream=null,this.backoff=new HE(t,e)}var ZE,tS=(da(eS,ZE=JE),eS.prototype.startRpc=function(t){return this.connection.openStream("Listen",t)},eS.prototype.onMessage=function(t){this.backoff.reset();var e=this.serializer.fromWatchChange(t),n=this.serializer.versionFromListenResponse(t);return this.listener.onWatchChange(e,n)},eS.prototype.watch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.addTarget=this.serializer.toTarget(t);var n=this.serializer.toListenRequestLabels(t);n&&(e.labels=n),this.sendRequest(e)},eS.prototype.unwatch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.removeTarget=t,this.sendRequest(e)},eS);function eS(t,e,n,r,i){var o=ZE.call(this,t,sv.ListenStreamConnectionBackoff,sv.ListenStreamIdle,e,n,i)||this;return o.serializer=r,o}var nS,rS=(da(iS,nS=JE),Object.defineProperty(iS.prototype,"handshakeComplete",{get:function(){return this.handshakeComplete_},enumerable:!0,configurable:!0}),iS.prototype.start=function(){this.handshakeComplete_=!1,nS.prototype.start.call(this)},iS.prototype.tearDown=function(){this.handshakeComplete_&&this.writeMutations([])},iS.prototype.startRpc=function(t){return this.connection.openStream("Write",t)},iS.prototype.onMessage=function(t){if(tg(!!t.streamToken,"Got a write response without a stream token"),this.lastStreamToken=t.streamToken,this.handshakeComplete_){this.backoff.reset();var e=this.serializer.fromWriteResults(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.onMutationResult(n,e)}return tg(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.handshakeComplete_=!0,this.listener.onHandshakeComplete()},iS.prototype.writeHandshake=function(){tg(this.isOpen(),"Writing handshake requires an opened stream"),tg(!this.handshakeComplete_,"Handshake already completed");var t={};t.database=this.serializer.encodedDatabaseId,this.sendRequest(t)},iS.prototype.writeMutations=function(t){var e=this;tg(this.isOpen(),"Writing mutations requires an opened stream"),tg(this.handshakeComplete_,"Handshake must be complete before writing mutations"),tg(0<this.lastStreamToken.length,"Trying to write mutation without a token");var n={streamToken:this.lastStreamToken,writes:t.map(function(t){return e.serializer.toMutation(t)})};this.sendRequest(n)},iS);function iS(t,e,n,r,i){var o=nS.call(this,t,sv.WriteStreamConnectionBackoff,sv.WriteStreamIdle,e,n,i)||this;return o.serializer=r,o.handshakeComplete_=!1,o.lastStreamToken=rg(),o}var oS=(aS.prototype.newPersistentWriteStream=function(t){return new rS(this.queue,this.connection,this.credentials,this.serializer,t)},aS.prototype.newPersistentWatchStream=function(t){return new tS(this.queue,this.connection,this.credentials,this.serializer,t)},aS.prototype.commit=function(t){var e=this,n={database:this.serializer.encodedDatabaseId,writes:t.map(function(t){return e.serializer.toMutation(t)})};return this.invokeRPC("Commit",n).then(function(t){return e.serializer.fromWriteResults(t.writeResults,t.commitTime)})},aS.prototype.lookup=function(e){var i=this,t={database:this.serializer.encodedDatabaseId,documents:e.map(function(t){return i.serializer.toName(t)})};return this.invokeStreamingRPC("BatchGetDocuments",t).then(function(t){var n=Vv();t.forEach(function(t){var e=i.serializer.fromMaybeDocument(t);n=n.insert(e.key,e)});var r=[];return e.forEach(function(t){var e=n.get(t);tg(!!e,"Missing entity in write response for "+t),r.push(e)}),r})},aS.prototype.invokeRPC=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.connection.invokeRPC(e,n,t)}).catch(function(t){throw t.code===og.UNAUTHENTICATED&&r.credentials.invalidateToken(),t})},aS.prototype.invokeStreamingRPC=function(e,n){var r=this;return this.credentials.getToken().then(function(t){return r.connection.invokeStreamingRPC(e,n,t)}).catch(function(t){throw t.code===og.UNAUTHENTICATED&&r.credentials.invalidateToken(),t})},aS);function aS(t,e,n,r){this.queue=t,this.connection=e,this.credentials=n,this.serializer=r}var sS,uS,cS,hS,lS=(fS.prototype.lookup=function(r){return ya(this,void 0,void 0,function(){var e,n=this;return ga(this,function(t){switch(t.label){case 0:if(this.ensureCommitNotCalled(),0<this.mutations.length)throw new ag(og.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,this.datastore.lookup(r)];case 1:return(e=t.sent()).forEach(function(t){t instanceof t_||t instanceof Jw?n.recordVersion(t):Zy("Document in a transaction was a "+t.constructor.name)}),[2,e]}})})},fS.prototype.set=function(t,e){this.write(e.toMutations(t,this.precondition(t))),this.writtenDocs.add(t)},fS.prototype.update=function(t,e){try{this.write(e.toMutations(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t)},fS.prototype.delete=function(t){this.write([new nw(t,this.precondition(t))]),this.writtenDocs.add(t)},fS.prototype.commit=function(){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;if(e=this.readVersions,this.mutations.forEach(function(t){e=e.remove(t.key)}),!e.isEmpty())throw new ag(og.INVALID_ARGUMENT,"Every document read in a transaction must also be written.");return[4,this.datastore.commit(this.mutations)];case 1:return t.sent(),this.committed=!0,[2]}})})},fS.prototype.recordVersion=function(t){var e;if(t instanceof Jw)e=t.version;else{if(!(t instanceof t_))throw Zy("Document in a transaction was a "+t.constructor.name);e=Sv.forDeletedDoc()}var n=this.readVersions.get(t.key);if(null!==n){if(!e.isEqual(n))throw new ag(og.ABORTED,"Document version changed between two reads.")}else this.readVersions=this.readVersions.insert(t.key,e)},fS.prototype.precondition=function(t){var e=this.readVersions.get(t);return!this.writtenDocs.has(t)&&e?Ub.updateTime(e):Ub.NONE},fS.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t);if(this.writtenDocs.has(t)||!e)return Ub.exists(!0);if(e.isEqual(Sv.forDeletedDoc()))throw new ag(og.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ub.updateTime(e)},fS.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations=this.mutations.concat(t)},fS.prototype.ensureCommitNotCalled=function(){tg(!this.committed,"A transaction object cannot be used after its update callback has been invoked.")},fS);function fS(t){this.datastore=t,this.readVersions=Kv(),this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}(uS=sS=sS||{})[uS.Unknown=0]="Unknown",uS[uS.Online=1]="Online",uS[uS.Offline=2]="Offline",(hS=cS=cS||{})[hS.RemoteStore=0]="RemoteStore",hS[hS.SharedClientState=1]="SharedClientState";var pS,dS,mS=(yS.prototype.handleWatchStreamStart=function(){var t=this;0===this.watchStreamFailures&&(this.setAndBroadcast(sS.Unknown),tg(null===this.onlineStateTimer,"onlineStateTimer shouldn't be started yet"),this.onlineStateTimer=this.asyncQueue.enqueueAfterDelay(sv.OnlineStateTimeout,1e4,function(){return t.onlineStateTimer=null,tg(t.state===sS.Unknown,"Timer should be canceled if we transitioned to a different state."),t.logClientOfflineWarningIfNecessary("Backend didn't respond within 10 seconds."),t.setAndBroadcast(sS.Offline),Promise.resolve()}))},yS.prototype.handleWatchStreamFailure=function(t){this.state===sS.Online?(this.setAndBroadcast(sS.Unknown),tg(0===this.watchStreamFailures,"watchStreamFailures must be 0"),tg(null===this.onlineStateTimer,"onlineStateTimer must be null")):(this.watchStreamFailures++,1<=this.watchStreamFailures&&(this.clearOnlineStateTimer(),this.logClientOfflineWarningIfNecessary("Connection failed 1 times. Most recent error: "+t.toString()),this.setAndBroadcast(sS.Offline)))},yS.prototype.set=function(t){this.clearOnlineStateTimer(),this.watchStreamFailures=0,t===sS.Online&&(this.shouldWarnClientIsOffline=!1),this.setAndBroadcast(t)},yS.prototype.setAndBroadcast=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},yS.prototype.logClientOfflineWarningIfNecessary=function(t){var e="Could not reach Cloud Firestore backend. "+t+"\nThis 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.shouldWarnClientIsOffline?(Jy(e),this.shouldWarnClientIsOffline=!1):Xy("OnlineStateTracker",e)},yS.prototype.clearOnlineStateTimer=function(){null!==this.onlineStateTimer&&(this.onlineStateTimer.cancel(),this.onlineStateTimer=null)},yS);function yS(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state=sS.Unknown,this.watchStreamFailures=0,this.onlineStateTimer=null,this.shouldWarnClientIsOffline=!0}function gS(t){switch(t){case og.OK:return Zy("Treated status OK as error");case og.CANCELLED:case og.UNKNOWN:case og.DEADLINE_EXCEEDED:case og.RESOURCE_EXHAUSTED:case og.INTERNAL:case og.UNAVAILABLE:case og.UNAUTHENTICATED:return!1;case og.INVALID_ARGUMENT:case og.NOT_FOUND:case og.ALREADY_EXISTS:case og.PERMISSION_DENIED:case og.FAILED_PRECONDITION:case og.ABORTED:case og.OUT_OF_RANGE:case og.UNIMPLEMENTED:case og.DATA_LOSS:return!0;default:return Zy("Unknown status code: "+t)}}function vS(t){if(void 0===t)return Jy("GRPC error has no .code"),og.UNKNOWN;switch(t){case pS.OK:return og.OK;case pS.CANCELLED:return og.CANCELLED;case pS.UNKNOWN:return og.UNKNOWN;case pS.DEADLINE_EXCEEDED:return og.DEADLINE_EXCEEDED;case pS.RESOURCE_EXHAUSTED:return og.RESOURCE_EXHAUSTED;case pS.INTERNAL:return og.INTERNAL;case pS.UNAVAILABLE:return og.UNAVAILABLE;case pS.UNAUTHENTICATED:return og.UNAUTHENTICATED;case pS.INVALID_ARGUMENT:return og.INVALID_ARGUMENT;case pS.NOT_FOUND:return og.NOT_FOUND;case pS.ALREADY_EXISTS:return og.ALREADY_EXISTS;case pS.PERMISSION_DENIED:return og.PERMISSION_DENIED;case pS.FAILED_PRECONDITION:return og.FAILED_PRECONDITION;case pS.ABORTED:return og.ABORTED;case pS.OUT_OF_RANGE:return og.OUT_OF_RANGE;case pS.UNIMPLEMENTED:return og.UNIMPLEMENTED;case pS.DATA_LOSS:return og.DATA_LOSS;default:return Zy("Unknown status code: "+t)}}(dS=pS=pS||{})[dS.OK=0]="OK",dS[dS.CANCELLED=1]="CANCELLED",dS[dS.UNKNOWN=2]="UNKNOWN",dS[dS.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",dS[dS.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",dS[dS.NOT_FOUND=5]="NOT_FOUND",dS[dS.ALREADY_EXISTS=6]="ALREADY_EXISTS",dS[dS.PERMISSION_DENIED=7]="PERMISSION_DENIED",dS[dS.UNAUTHENTICATED=16]="UNAUTHENTICATED",dS[dS.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",dS[dS.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",dS[dS.ABORTED=10]="ABORTED",dS[dS.OUT_OF_RANGE=11]="OUT_OF_RANGE",dS[dS.UNIMPLEMENTED=12]="UNIMPLEMENTED",dS[dS.INTERNAL=13]="INTERNAL",dS[dS.UNAVAILABLE=14]="UNAVAILABLE",dS[dS.DATA_LOSS=15]="DATA_LOSS";var bS,wS,_S,TS,ES=(SS.emptySet=function(t){return new SS(t.comparator)},SS.prototype.has=function(t){return null!=this.keyedMap.get(t)},SS.prototype.get=function(t){return this.keyedMap.get(t)},SS.prototype.first=function(){return this.sortedSet.minKey()},SS.prototype.last=function(){return this.sortedSet.maxKey()},SS.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},SS.prototype.indexOf=function(t){var e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1},Object.defineProperty(SS.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!0,configurable:!0}),SS.prototype.forEach=function(n){this.sortedSet.inorderTraversal(function(t,e){return n(t),!1})},SS.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},SS.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this},SS.prototype.isEqual=function(t){if(!(t instanceof SS))return!1;if(this.size!==t.size)return!1;for(var e=this.sortedSet.getIterator(),n=t.sortedSet.getIterator();e.hasNext();){var r=e.getNext().key,i=n.getNext().key;if(!r.isEqual(i))return!1}return!0},SS.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"},SS.prototype.copy=function(t,e){var n=new SS;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n},SS);function SS(n){this.comparator=n?function(t,e){return n(t,e)||ov.comparator(t.key,e.key)}:function(t,e){return ov.comparator(t.key,e.key)},this.keyedMap=jv(),this.sortedSet=new Cv(this.comparator)}(wS=bS=bS||{})[wS.Added=0]="Added",wS[wS.Removed=1]="Removed",wS[wS.Modified=2]="Modified",wS[wS.Metadata=3]="Metadata",(TS=_S=_S||{})[TS.Local=0]="Local",TS[TS.Synced=1]="Synced";var IS=(CS.prototype.track=function(t){var e=t.doc.key,n=this.changeMap.get(e);n?t.type!==bS.Added&&n.type===bS.Metadata?this.changeMap=this.changeMap.insert(e,t):t.type===bS.Metadata&&n.type!==bS.Removed?this.changeMap=this.changeMap.insert(e,{type:n.type,doc:t.doc}):t.type===bS.Modified&&n.type===bS.Modified?this.changeMap=this.changeMap.insert(e,{type:bS.Modified,doc:t.doc}):t.type===bS.Modified&&n.type===bS.Added?this.changeMap=this.changeMap.insert(e,{type:bS.Added,doc:t.doc}):t.type===bS.Removed&&n.type===bS.Added?this.changeMap=this.changeMap.remove(e):t.type===bS.Removed&&n.type===bS.Modified?this.changeMap=this.changeMap.insert(e,{type:bS.Removed,doc:n.doc}):t.type===bS.Added&&n.type===bS.Removed?this.changeMap=this.changeMap.insert(e,{type:bS.Modified,doc:t.doc}):Zy("unsupported combination of changes: "+JSON.stringify(t)+" after "+JSON.stringify(n)):this.changeMap=this.changeMap.insert(e,t)},CS.prototype.getChanges=function(){var n=[];return this.changeMap.inorderTraversal(function(t,e){n.push(e)}),n},CS);function CS(){this.changeMap=new Cv(ov.comparator)}var NS=(AS.fromInitialDocuments=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:bS.Added,doc:t})}),new AS(t,e,ES.emptySet(e),i,n,r,!0,!1)},Object.defineProperty(AS.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!0,configurable:!0}),AS.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&this.query.isEqual(t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))return!1;var e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(e[r].type!==n[r].type||!e[r].doc.isEqual(n[r].doc))return!1;return!0},AS);function AS(t,e,n,r,i,o,a,s){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=a,this.excludesMetadataChanges=s}var kS=(DS.createSynthesizedRemoteEventForCurrentChange=function(t,e){var n,r=((n={})[t]=RS.createSynthesizedTargetChangeForCurrentChange(t,e),n);return new DS(Sv.MIN,r,zv(),Vv(),Hv())},DS);function DS(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}var RS=(OS.createSynthesizedTargetChangeForCurrentChange=function(t,e){return new OS(rg(),e,Hv(),Hv(),Hv())},OS);function OS(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}var PS,MS,xS=function(t,e,n,r){this.updatedTargetIds=t,this.removedTargetIds=e,this.key=n,this.newDoc=r},LS=function(t,e){this.targetId=t,this.existenceFilter=e};(MS=PS=PS||{})[MS.NoChange=0]="NoChange",MS[MS.Added=1]="Added",MS[MS.Removed=2]="Removed",MS[MS.Current=3]="Current",MS[MS.Reset=4]="Reset";var FS=function(t,e,n,r){void 0===n&&(n=rg()),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},US=(Object.defineProperty(VS.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(VS.prototype,"resumeToken",{get:function(){return this._resumeToken},enumerable:!0,configurable:!0}),Object.defineProperty(VS.prototype,"isPending",{get:function(){return 0!==this.pendingResponses},enumerable:!0,configurable:!0}),Object.defineProperty(VS.prototype,"hasPendingChanges",{get:function(){return this._hasPendingChanges},enumerable:!0,configurable:!0}),VS.prototype.updateResumeToken=function(t){0<t.length&&(this._hasPendingChanges=!0,this._resumeToken=t)},VS.prototype.toTargetChange=function(){var n=Hv(),r=Hv(),i=Hv();return this.documentChanges.forEach(function(t,e){switch(e){case bS.Added:n=n.add(t);break;case bS.Modified:r=r.add(t);break;case bS.Removed:i=i.add(t);break;default:Zy("Encountered invalid change type: "+e)}}),new RS(this._resumeToken,this._current,n,r,i)},VS.prototype.clearPendingChanges=function(){this._hasPendingChanges=!1,this.documentChanges=WS()},VS.prototype.addDocumentChange=function(t,e){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.insert(t,e)},VS.prototype.removeDocumentChange=function(t){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.remove(t)},VS.prototype.recordPendingTargetRequest=function(){this.pendingResponses+=1},VS.prototype.recordTargetResponse=function(){this.pendingResponses-=1},VS.prototype.markCurrent=function(){this._hasPendingChanges=!0,this._current=!0},VS);function VS(){this.pendingResponses=0,this.documentChanges=WS(),this._resumeToken=rg(),this._current=!1,this._hasPendingChanges=!0}var qS=(BS.prototype.handleDocumentChange=function(t){for(var e=0,n=t.updatedTargetIds;e<n.length;e++){var r=n[e];t.newDoc instanceof Jw?this.addDocumentToTarget(r,t.newDoc):t.newDoc instanceof t_&&this.removeDocumentFromTarget(r,t.key,t.newDoc)}for(var i=0,o=t.removedTargetIds;i<o.length;i++)r=o[i],this.removeDocumentFromTarget(r,t.key,t.newDoc)},BS.prototype.handleTargetChange=function(n){var r=this;this.forEachTarget(n,function(t){var e=r.ensureTargetState(t);switch(n.state){case PS.NoChange:r.isActiveTarget(t)&&e.updateResumeToken(n.resumeToken);break;case PS.Added:e.recordTargetResponse(),e.isPending||e.clearPendingChanges(),e.updateResumeToken(n.resumeToken);break;case PS.Removed:e.recordTargetResponse(),e.isPending||r.removeTarget(t),tg(!n.cause,"WatchChangeAggregator does not handle errored targets");break;case PS.Current:r.isActiveTarget(t)&&(e.markCurrent(),e.updateResumeToken(n.resumeToken));break;case PS.Reset:r.isActiveTarget(t)&&(r.resetTarget(t),e.updateResumeToken(n.resumeToken));break;default:Zy("Unknown target watch change state: "+n.state)}})},BS.prototype.forEachTarget=function(t,e){0<t.targetIds.length?t.targetIds.forEach(e):lg(this.targetStates,e)},BS.prototype.handleExistenceFilter=function(t){var e=t.targetId,n=t.existenceFilter.count,r=this.targetDataForActiveTarget(e);if(r){var i=r.target;if(i.isDocumentQuery())if(0===n){var o=new ov(i.path);this.removeDocumentFromTarget(e,o,new t_(o,Sv.forDeletedDoc()))}else tg(1===n,"Single document existence filter with count: "+n);else this.getCurrentDocumentCountForTarget(e)!==n&&(this.resetTarget(e),this.pendingTargetResets=this.pendingTargetResets.add(e))}},BS.prototype.createRemoteEvent=function(i){var o=this,a={};lg(this.targetStates,function(t,e){var n=o.targetDataForActiveTarget(t);if(n){if(e.current&&n.target.isDocumentQuery()){var r=new ov(n.target.path);null!==o.pendingDocumentUpdates.get(r)||o.targetContainsDocument(t,r)||o.removeDocumentFromTarget(t,r,new t_(r,i))}e.hasPendingChanges&&(a[t]=e.toTargetChange(),e.clearPendingChanges())}});var r=Hv();this.pendingDocumentTargetMapping.forEach(function(t,e){var n=!0;e.forEachWhile(function(t){var e=o.targetDataForActiveTarget(t);return!e||e.purpose===X_.LimboResolution||(n=!1)}),n&&(r=r.add(t))});var t=new kS(i,a,this.pendingTargetResets,this.pendingDocumentUpdates,r);return this.pendingDocumentUpdates=Vv(),this.pendingDocumentTargetMapping=jS(),this.pendingTargetResets=new Mv(xg),t},BS.prototype.addDocumentToTarget=function(t,e){if(this.isActiveTarget(t)){var n=this.targetContainsDocument(t,e.key)?bS.Modified:bS.Added;this.ensureTargetState(t).addDocumentChange(e.key,n),this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(e.key,e),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(e.key,this.ensureDocumentTargetMapping(e.key).add(t))}},BS.prototype.removeDocumentFromTarget=function(t,e,n){if(this.isActiveTarget(t)){var r=this.ensureTargetState(t);this.targetContainsDocument(t,e)?r.addDocumentChange(e,bS.Removed):r.removeDocumentChange(e),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(e,this.ensureDocumentTargetMapping(e).delete(t)),n&&(this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(e,n))}},BS.prototype.removeTarget=function(t){delete this.targetStates[t]},BS.prototype.getCurrentDocumentCountForTarget=function(t){var e=this.ensureTargetState(t).toTargetChange();return this.metadataProvider.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},BS.prototype.recordPendingTargetRequest=function(t){this.ensureTargetState(t).recordPendingTargetRequest()},BS.prototype.ensureTargetState=function(t){return this.targetStates[t]||(this.targetStates[t]=new US),this.targetStates[t]},BS.prototype.ensureDocumentTargetMapping=function(t){var e=this.pendingDocumentTargetMapping.get(t);return e||(e=new Mv(xg),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(t,e)),e},BS.prototype.isActiveTarget=function(t){var e=null!==this.targetDataForActiveTarget(t);return e||Xy("WatchChangeAggregator","Detected inactive target",t),e},BS.prototype.targetDataForActiveTarget=function(t){var e=this.targetStates[t];return e&&e.isPending?null:this.metadataProvider.getTargetDataForTarget(t)},BS.prototype.resetTarget=function(e){var n=this;tg(!this.targetStates[e].isPending,"Should only reset active targets"),this.targetStates[e]=new US,this.metadataProvider.getRemoteKeysForTarget(e).forEach(function(t){n.removeDocumentFromTarget(e,t,null)})},BS.prototype.targetContainsDocument=function(t,e){return this.metadataProvider.getRemoteKeysForTarget(t).has(e)},BS);function BS(t){this.metadataProvider=t,this.targetStates={},this.pendingDocumentUpdates=Vv(),this.pendingDocumentTargetMapping=jS(),this.pendingTargetResets=new Mv(xg)}function jS(){return new Cv(ov.comparator)}function WS(){return new Cv(ov.comparator)}var KS="RemoteStore",QS=(HS.prototype.start=function(){return this.enableNetwork()},HS.prototype.enableNetwork=function(){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return this.networkEnabled=!0,this.canUseNetwork()?(e=this.writeStream,[4,this.localStore.getLastStreamToken()]):[3,3];case 1:return e.lastStreamToken=t.sent(),this.shouldStartWatchStream()?this.startWatchStream():this.onlineStateTracker.set(sS.Unknown),[4,this.fillWritePipeline()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},HS.prototype.disableNetwork=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(sS.Offline),[2]}})})},HS.prototype.disableNetworkInternal=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return[4,this.writeStream.stop()];case 1:return t.sent(),[4,this.watchStream.stop()];case 2:return t.sent(),0<this.writePipeline.length&&(Xy(KS,"Stopping write stream with "+this.writePipeline.length+" pending writes"),this.writePipeline=[]),this.cleanUpWatchStreamState(),[2]}})})},HS.prototype.shutdown=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return Xy(KS,"RemoteStore shutting down."),this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.connectivityMonitor.shutdown(),this.onlineStateTracker.set(sS.Unknown),[2]}})})},HS.prototype.listen=function(t){cg(this.listenTargets,t.targetId)||(this.listenTargets[t.targetId]=t,this.shouldStartWatchStream()?this.startWatchStream():this.watchStream.isOpen()&&this.sendWatchRequest(t))},HS.prototype.unlisten=function(t){tg(cg(this.listenTargets,t),"unlisten called on target no currently watched: "+t),delete this.listenTargets[t],this.watchStream.isOpen()&&this.sendUnwatchRequest(t),pg(this.listenTargets)&&(this.watchStream.isOpen()?this.watchStream.markIdle():this.canUseNetwork()&&this.onlineStateTracker.set(sS.Unknown))},HS.prototype.getTargetDataForTarget=function(t){return this.listenTargets[t]||null},HS.prototype.getRemoteKeysForTarget=function(t){return this.syncEngine.getRemoteKeysForTarget(t)},HS.prototype.sendWatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t.targetId),this.watchStream.watch(t)},HS.prototype.sendUnwatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t),this.watchStream.unwatch(t)},HS.prototype.startWatchStream=function(){tg(this.shouldStartWatchStream(),"startWatchStream() called when shouldStartWatchStream() is false."),this.watchChangeAggregator=new qS(this),this.watchStream.start(),this.onlineStateTracker.handleWatchStreamStart()},HS.prototype.shouldStartWatchStream=function(){return this.canUseNetwork()&&!this.watchStream.isStarted()&&!pg(this.listenTargets)},HS.prototype.canUseNetwork=function(){return this.isPrimary&&this.networkEnabled},HS.prototype.cleanUpWatchStreamState=function(){this.watchChangeAggregator=null},HS.prototype.onWatchStreamOpen=function(){return ya(this,void 0,void 0,function(){var n=this;return ga(this,function(t){return lg(this.listenTargets,function(t,e){n.sendWatchRequest(e)}),[2]})})},HS.prototype.onWatchStreamClose=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){return void 0===e&&tg(!this.shouldStartWatchStream(),"Watch stream was stopped gracefully while still needed."),this.cleanUpWatchStreamState(),this.shouldStartWatchStream()?(this.onlineStateTracker.handleWatchStreamFailure(e),this.startWatchStream()):this.onlineStateTracker.set(sS.Unknown),[2]})})},HS.prototype.onWatchStreamChange=function(n,r){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return this.onlineStateTracker.set(sS.Online),n instanceof FS&&n.state===PS.Removed&&n.cause?[2,this.handleTargetError(n)]:(n instanceof xS?this.watchChangeAggregator.handleDocumentChange(n):n instanceof LS?this.watchChangeAggregator.handleExistenceFilter(n):(tg(n instanceof FS,"Expected watchChange to be an instance of WatchTargetChange"),this.watchChangeAggregator.handleTargetChange(n)),r.isEqual(Sv.MIN)?[3,3]:[4,this.localStore.getLastRemoteSnapshotVersion()]);case 1:return e=t.sent(),0<=r.compareTo(e)?[4,this.raiseWatchSnapshot(r)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}})})},HS.prototype.raiseWatchSnapshot=function(r){var i=this;tg(!r.isEqual(Sv.MIN),"Can't raise event for unknown SnapshotVersion");var t=this.watchChangeAggregator.createRemoteEvent(r);return lg(t.targetChanges,function(t,e){if(0<e.resumeToken.length){var n=i.listenTargets[t];n&&(i.listenTargets[t]=n.withResumeToken(e.resumeToken,r))}}),t.targetMismatches.forEach(function(t){var e=i.listenTargets[t];if(e){i.listenTargets[t]=e.withResumeToken(rg(),e.snapshotVersion),i.sendUnwatchRequest(t);var n=new nT(e.target,t,X_.ExistenceFilterMismatch,e.sequenceNumber);i.sendWatchRequest(n)}}),this.syncEngine.applyRemoteEvent(t)},HS.prototype.handleTargetError=function(t){var n=this;tg(!!t.cause,"Handling target error without a cause");var r=t.cause,i=Promise.resolve();return t.targetIds.forEach(function(e){i=i.then(function(){return ya(n,void 0,void 0,function(){return ga(this,function(t){return cg(this.listenTargets,e)?(delete this.listenTargets[e],this.watchChangeAggregator.removeTarget(e),[2,this.syncEngine.rejectListen(e,r)]):[2]})})})}),i},HS.prototype.fillWritePipeline=function(){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return this.canAddToWritePipeline()?(e=0<this.writePipeline.length?this.writePipeline[this.writePipeline.length-1].batchId:-1,[4,this.localStore.nextMutationBatch(e)]):[3,4];case 1:return null!==(n=t.sent())?[3,2]:(0===this.writePipeline.length&&this.writeStream.markIdle(),[3,4]);case 2:return this.addToWritePipeline(n),[4,this.fillWritePipeline()];case 3:t.sent(),t.label=4;case 4:return this.shouldStartWriteStream()&&this.startWriteStream(),[2]}})})},HS.prototype.canAddToWritePipeline=function(){return this.canUseNetwork()&&this.writePipeline.length<10},HS.prototype.outstandingWrites=function(){return this.writePipeline.length},HS.prototype.addToWritePipeline=function(t){tg(this.canAddToWritePipeline(),"addToWritePipeline called when pipeline is full"),this.writePipeline.push(t),this.writeStream.isOpen()&&this.writeStream.handshakeComplete&&this.writeStream.writeMutations(t.mutations)},HS.prototype.shouldStartWriteStream=function(){return this.canUseNetwork()&&!this.writeStream.isStarted()&&0<this.writePipeline.length},HS.prototype.startWriteStream=function(){tg(this.shouldStartWriteStream(),"startWriteStream() called when shouldStartWriteStream() is false."),this.writeStream.start()},HS.prototype.onWriteStreamOpen=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return this.writeStream.writeHandshake(),[2]})})},HS.prototype.onWriteHandshakeComplete=function(){var r=this;return this.localStore.setLastStreamToken(this.writeStream.lastStreamToken).then(function(){for(var t=0,e=r.writePipeline;t<e.length;t++){var n=e[t];r.writeStream.writeMutations(n.mutations)}}).catch(CT)},HS.prototype.onMutationResult=function(t,e){var n=this;tg(0<this.writePipeline.length,"Got result for empty write pipeline");var r=this.writePipeline.shift(),i=Jv.from(r,t,e,this.writeStream.lastStreamToken);return this.syncEngine.applySuccessfulWrite(i).then(function(){return n.fillWritePipeline()})},HS.prototype.onWriteStreamClose=function(n){return ya(this,void 0,void 0,function(){var e=this;return ga(this,function(t){return void 0===n&&tg(!this.shouldStartWriteStream(),"Write stream was stopped gracefully while still needed."),n&&0<this.writePipeline.length?[2,(this.writeStream.handshakeComplete?this.handleWriteError(n):this.handleHandshakeError(n)).then(function(){e.shouldStartWriteStream()&&e.startWriteStream()})]:[2]})})},HS.prototype.handleHandshakeError=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){return gS(e.code)?(Xy(KS,"RemoteStore error before completed handshake; resetting stream token: ",this.writeStream.lastStreamToken),this.writeStream.lastStreamToken=rg(),[2,this.localStore.setLastStreamToken(rg()).catch(CT)]):[2]})})},HS.prototype.handleWriteError=function(r){return ya(this,void 0,void 0,function(){var e,n=this;return ga(this,function(t){return function(t){return gS(t)&&t!==og.ABORTED}(r.code)?(e=this.writePipeline.shift(),this.writeStream.inhibitBackoff(),[2,this.syncEngine.rejectFailedWrite(e.batchId,r).then(function(){return n.fillWritePipeline()})]):[2]})})},HS.prototype.createTransaction=function(){return new lS(this.datastore)},HS.prototype.restartNetwork=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(sS.Unknown),[4,this.enableNetwork()];case 2:return t.sent(),[2]}})})},HS.prototype.handleCredentialChange=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.canUseNetwork()?(Xy(KS,"RemoteStore restarting streams for new credential"),[4,this.restartNetwork()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},HS.prototype.applyPrimaryState=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return(this.isPrimary=e)&&this.networkEnabled?[4,this.enableNetwork()]:[3,2];case 1:return t.sent(),[3,4];case 2:return e?[3,4]:[4,this.disableNetworkInternal()];case 3:t.sent(),this.onlineStateTracker.set(sS.Unknown),t.label=4;case 4:return[2]}})})},HS);function HS(t,e,n,r,i){var o=this;this.localStore=t,this.datastore=e,this.writePipeline=[],this.listenTargets={},this.watchChangeAggregator=null,this.networkEnabled=!1,this.isPrimary=!1,this.connectivityMonitor=i,this.connectivityMonitor.addCallback(function(t){n.enqueueAndForget(function(){return ya(o,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.canUseNetwork()?(Xy(KS,"Restarting streams for network reachability change."),[4,this.restartNetwork()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.onlineStateTracker=new mS(n,r),this.watchStream=this.datastore.newPersistentWatchStream({onOpen:this.onWatchStreamOpen.bind(this),onClose:this.onWatchStreamClose.bind(this),onWatchChange:this.onWatchStreamChange.bind(this)}),this.writeStream=this.datastore.newPersistentWriteStream({onOpen:this.onWriteStreamOpen.bind(this),onClose:this.onWriteStreamClose.bind(this),onHandshakeComplete:this.onWriteHandshakeComplete.bind(this),onMutationResult:this.onMutationResult.bind(this)})}var GS=(Object.defineProperty(zS.prototype,"latitude",{get:function(){return this._lat},enumerable:!0,configurable:!0}),Object.defineProperty(zS.prototype,"longitude",{get:function(){return this._long},enumerable:!0,configurable:!0}),zS.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},zS.prototype._compareTo=function(t){return xg(this._lat,t._lat)||xg(this._long,t._long)},zS);function zS(t,e){if(mg("GeoPoint",arguments,2),vg("GeoPoint","number",1,t),vg("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new ag(og.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new ag(og.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}var YS=(XS.prototype.applyToLocalView=function(t,e){return new Rw(e,t)},XS.prototype.applyToRemoteDocument=function(t,e){return e},XS.prototype.computeBaseValue=function(t){return null},XS.prototype.isEqual=function(t){return t instanceof XS},XS.instance=new XS,XS);function XS(){}var JS=($S.prototype.applyToLocalView=function(t,e){return this.apply(t)},$S.prototype.applyToRemoteDocument=function(t,e){return this.apply(t)},$S.prototype.apply=function(t){for(var n=rI(t),e=function(e){n.find(function(t){return t.isEqual(e)})||n.push(e)},r=0,i=this.elements;r<i.length;r++)e(i[r]);return new Hw(n)},$S.prototype.computeBaseValue=function(t){return null},$S.prototype.isEqual=function(t){return t instanceof $S&&Lg(t.elements,this.elements)},$S);function $S(t){this.elements=t}var ZS=(tI.prototype.applyToLocalView=function(t,e){return this.apply(t)},tI.prototype.applyToRemoteDocument=function(t,e){return this.apply(t)},tI.prototype.apply=function(t){for(var n=rI(t),e=function(e){n=n.filter(function(t){return!t.isEqual(e)})},r=0,i=this.elements;r<i.length;r++)e(i[r]);return new Hw(n)},tI.prototype.computeBaseValue=function(t){return null},tI.prototype.isEqual=function(t){return t instanceof tI&&Lg(t.elements,this.elements)},tI);function tI(t){this.elements=t}var eI=(nI.prototype.applyToLocalView=function(t,e){var n=this.computeBaseValue(t);if(n instanceof bw&&this.operand instanceof bw){var r=n.internalValue+this.operand.internalValue;return new bw(r)}return r=n.internalValue+this.operand.internalValue,new Tw(r)},nI.prototype.applyToRemoteDocument=function(t,e){return tg(null!==e,"Didn't receive transformResult for NUMERIC_ADD transform"),e},nI.prototype.computeBaseValue=function(t){return t instanceof mw?t:new bw(0)},nI.prototype.isEqual=function(t){return t instanceof nI&&this.operand.isEqual(t.operand)},nI);function nI(t){this.operand=t}function rI(t){return t instanceof Hw?t.internalValue.slice():[]}var iI=(oI.prototype.isEqual=function(t){return t&&t.count===this.count},oI);function oI(t){this.count=t}var aI,sI,uI=((aI={})[lE.ASCENDING.name]="ASCENDING",aI[lE.DESCENDING.name]="DESCENDING",aI),cI=((sI={})[QT.LESS_THAN.name]="LESS_THAN",sI[QT.LESS_THAN_OR_EQUAL.name]="LESS_THAN_OR_EQUAL",sI[QT.GREATER_THAN.name]="GREATER_THAN",sI[QT.GREATER_THAN_OR_EQUAL.name]="GREATER_THAN_OR_EQUAL",sI[QT.EQUAL.name]="EQUAL",sI[QT.ARRAY_CONTAINS.name]="ARRAY_CONTAINS",sI[QT.IN.name]="IN",sI[QT.ARRAY_CONTAINS_ANY.name]="ARRAY_CONTAINS_ANY",sI),hI=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function lI(t,e){tg(!LT(t),e+" is missing")}function fI(t){return"number"==typeof t?t:"string"==typeof t?Number(t):Zy("can't parse "+t)}var pI=(dI.prototype.emptyByteString=function(){return this.options.useProto3Json?"":new Uint8Array(0)},dI.prototype.unsafeCastProtoByteString=function(t){return t},dI.prototype.fromRpcStatus=function(t){var e=void 0===t.code?og.UNKNOWN:vS(t.code);return new ag(e,t.message||"")},dI.prototype.toInt32Value=function(t){return this.options.useProto3Json||LT(t)?t:{value:t}},dI.prototype.fromInt32Value=function(t){var e;return LT(e="object"==typeof t?t.value:t)?null:e},dI.prototype.toTimestamp=function(t){return this.options.useProto3Json?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}},dI.prototype.fromTimestamp=function(t){if("string"==typeof t)return this.fromIso8601String(t);tg(!!t,"Cannot deserialize null or undefined timestamp.");var e=fI(t.seconds||"0"),n=t.nanos||0;return new Tv(e,n)},dI.prototype.fromIso8601String=function(t){var e=0,n=hI.exec(t);if(tg(!!n,"invalid timestamp: "+t),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t),o=Math.floor(i.getTime()/1e3);return new Tv(o,e)},dI.prototype.toBytes=function(t){return this.options.useProto3Json?t.toBase64():this.unsafeCastProtoByteString(t.toUint8Array())},dI.prototype.fromBlob=function(t){return"string"==typeof t?(tg(this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),qg.fromBase64String(t)):(tg(!this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),qg.fromUint8Array(t))},dI.prototype.toVersion=function(t){return this.toTimestamp(t.toTimestamp())},dI.prototype.fromVersion=function(t){return tg(!!t,"Trying to deserialize version that isn't set"),Sv.fromTimestamp(this.fromTimestamp(t))},dI.prototype.toResourceName=function(t,e){return this.fullyQualifiedPrefixPath(t).child("documents").child(e).canonicalString()},dI.prototype.fromResourceName=function(t){var e=Zg.fromString(t);return tg(this.isValidResourceName(e),"Tried to deserialize invalid key "+e.toString()),e},dI.prototype.toName=function(t){return this.toResourceName(this.databaseId,t.path)},dI.prototype.fromName=function(t){var e=this.fromResourceName(t);return tg(e.get(1)===this.databaseId.projectId,"Tried to deserialize key from different project: "+e.get(1)+" vs "+this.databaseId.projectId),tg(!e.get(3)&&!this.databaseId.database||e.get(3)===this.databaseId.database,"Tried to deserialize key from different database: "+e.get(3)+" vs "+this.databaseId.database),new ov(this.extractLocalPathFromResourceName(e))},dI.prototype.toQueryPath=function(t){return this.toResourceName(this.databaseId,t)},dI.prototype.fromQueryPath=function(t){var e=this.fromResourceName(t);return 4===e.length?Zg.EMPTY_PATH:this.extractLocalPathFromResourceName(e)},Object.defineProperty(dI.prototype,"encodedDatabaseId",{get:function(){return new Zg(["projects",this.databaseId.projectId,"databases",this.databaseId.database]).canonicalString()},enumerable:!0,configurable:!0}),dI.prototype.fullyQualifiedPrefixPath=function(t){return new Zg(["projects",t.projectId,"databases",t.database])},dI.prototype.extractLocalPathFromResourceName=function(t){return tg(4<t.length&&"documents"===t.get(4),"tried to deserialize invalid key "+t.toString()),t.popFirst(5)},dI.prototype.isValidResourceName=function(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)},dI.prototype.toValue=function(t){if(t instanceof cw)return{nullValue:"NULL_VALUE"};if(t instanceof fw)return{booleanValue:t.value()};if(t instanceof bw)return{integerValue:""+t.value()};if(t instanceof Tw){var e=t.value();if(this.options.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:t.value()}}return t instanceof Iw?{stringValue:t.value()}:t instanceof Ww?{mapValue:this.toMapValue(t)}:t instanceof Hw?{arrayValue:this.toArrayValue(t)}:t instanceof Aw?{timestampValue:this.toTimestamp(t.internalValue)}:t instanceof qw?{geoPointValue:{latitude:t.value().latitude,longitude:t.value().longitude}}:t instanceof Mw?{bytesValue:this.toBytes(t.value())}:t instanceof Fw?{referenceValue:this.toResourceName(t.databaseId,t.key.path)}:Zy("Unknown FieldValue "+JSON.stringify(t))},dI.prototype.fromValue=function(t){var e=this;if("nullValue"in t)return cw.INSTANCE;if("booleanValue"in t)return fw.of(t.booleanValue);if("integerValue"in t)return new bw(fI(t.integerValue));if("doubleValue"in t){if(this.options.useProto3Json){if("NaN"===t.doubleValue)return Tw.NAN;if("Infinity"===t.doubleValue)return Tw.POSITIVE_INFINITY;if("-Infinity"===t.doubleValue)return Tw.NEGATIVE_INFINITY}return new Tw(t.doubleValue)}if("stringValue"in t)return new Iw(t.stringValue);if("mapValue"in t)return this.fromFields(t.mapValue.fields||{});if("arrayValue"in t){lI(t.arrayValue,"arrayValue");var n=t.arrayValue.values||[];return new Hw(n.map(function(t){return e.fromValue(t)}))}if("timestampValue"in t)return lI(t.timestampValue,"timestampValue"),new Aw(this.fromTimestamp(t.timestampValue));if("geoPointValue"in t){lI(t.geoPointValue,"geoPointValue");var r=t.geoPointValue.latitude||0,i=t.geoPointValue.longitude||0;return new qw(new GS(r,i))}if("bytesValue"in t){lI(t.bytesValue,"bytesValue");var o=this.fromBlob(t.bytesValue);return new Mw(o)}if("referenceValue"in t){lI(t.referenceValue,"referenceValue");var a=this.fromResourceName(t.referenceValue),s=new Qg(a.get(1),a.get(3)),u=new ov(this.extractLocalPathFromResourceName(a));return new Fw(s,u)}return Zy("Unknown Value proto "+JSON.stringify(t))},dI.prototype.toMutationDocument=function(t,e){return{name:this.toName(t),fields:this.toFields(e)}},dI.prototype.toDocument=function(t){return tg(!t.hasLocalMutations,"Can't serialize documents with mutations."),{name:this.toName(t.key),fields:this.toFields(t.data()),updateTime:this.toTimestamp(t.version.toTimestamp())}},dI.prototype.fromDocument=function(t,e){var n=this,r=this.fromName(t.name),i=this.fromVersion(t.updateTime);return new Jw(r,i,{hasCommittedMutations:!!e},void 0,t,function(t){return n.fromValue(t)})},dI.prototype.toFields=function(t){var n=this,r={};return t.forEach(function(t,e){r[t]=n.toValue(e)}),r},dI.prototype.fromFields=function(t){var n=this,e=t,r=Ww.EMPTY;return fg(e,function(t,e){r=r.set(new rv([t]),n.fromValue(e))}),r},dI.prototype.toMapValue=function(t){return{fields:this.toFields(t)}},dI.prototype.toArrayValue=function(t){var e=this,n=[];return t.forEach(function(t){n.push(e.toValue(t))}),{values:n}},dI.prototype.fromFound=function(t){var e=this;tg(!!t.found,"Tried to deserialize a found document from a missing document."),lI(t.found.name,"doc.found.name"),lI(t.found.updateTime,"doc.found.updateTime");var n=this.fromName(t.found.name),r=this.fromVersion(t.found.updateTime);return new Jw(n,r,{},void 0,t.found,function(t){return e.fromValue(t)})},dI.prototype.fromMissing=function(t){tg(!!t.missing,"Tried to deserialize a missing document from a found document."),tg(!!t.readTime,"Tried to deserialize a missing document without a read time.");var e=this.fromName(t.missing),n=this.fromVersion(t.readTime);return new t_(e,n)},dI.prototype.fromMaybeDocument=function(t){return"found"in t?this.fromFound(t):"missing"in t?this.fromMissing(t):Zy("invalid batch get response: "+JSON.stringify(t))},dI.prototype.toWatchTargetChangeState=function(t){switch(t){case PS.Added:return"ADD";case PS.Current:return"CURRENT";case PS.NoChange:return"NO_CHANGE";case PS.Removed:return"REMOVE";case PS.Reset:return"RESET";default:return Zy("Unknown WatchTargetChangeState: "+t)}},dI.prototype.toTestWatchChange=function(t){if(t instanceof LS)return{filter:{count:t.existenceFilter.count,targetId:t.targetId}};if(t instanceof xS){if(t.newDoc instanceof Jw){var e=t.newDoc;return{documentChange:{document:{name:this.toName(e.key),fields:this.toFields(e.data()),updateTime:this.toVersion(e.version)},targetIds:t.updatedTargetIds,removedTargetIds:t.removedTargetIds}}}if(t.newDoc instanceof t_)return e=t.newDoc,{documentDelete:{document:this.toName(e.key),readTime:this.toVersion(e.version),removedTargetIds:t.removedTargetIds}};if(null===t.newDoc)return{documentRemove:{document:this.toName(t.key),removedTargetIds:t.removedTargetIds}}}if(t instanceof FS){var n=void 0;return t.cause&&(n={code:function(t){if(void 0===t)return pS.OK;switch(t){case og.OK:return pS.OK;case og.CANCELLED:return pS.CANCELLED;case og.UNKNOWN:return pS.UNKNOWN;case og.DEADLINE_EXCEEDED:return pS.DEADLINE_EXCEEDED;case og.RESOURCE_EXHAUSTED:return pS.RESOURCE_EXHAUSTED;case og.INTERNAL:return pS.INTERNAL;case og.UNAVAILABLE:return pS.UNAVAILABLE;case og.UNAUTHENTICATED:return pS.UNAUTHENTICATED;case og.INVALID_ARGUMENT:return pS.INVALID_ARGUMENT;case og.NOT_FOUND:return pS.NOT_FOUND;case og.ALREADY_EXISTS:return pS.ALREADY_EXISTS;case og.PERMISSION_DENIED:return pS.PERMISSION_DENIED;case og.FAILED_PRECONDITION:return pS.FAILED_PRECONDITION;case og.ABORTED:return pS.ABORTED;case og.OUT_OF_RANGE:return pS.OUT_OF_RANGE;case og.UNIMPLEMENTED:return pS.UNIMPLEMENTED;case og.DATA_LOSS:return pS.DATA_LOSS;default:return Zy("Unknown status code: "+t)}}(t.cause.code),message:t.cause.message}),{targetChange:{targetChangeType:this.toWatchTargetChangeState(t.state),targetIds:t.targetIds,resumeToken:this.unsafeCastProtoByteString(t.resumeToken),cause:n}}}return Zy("Unrecognized watch change: "+JSON.stringify(t))},dI.prototype.fromWatchChange=function(t){var e,n=this;if("targetChange"in t){lI(t.targetChange,"targetChange");var r=this.fromWatchTargetChangeState(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],o=t.targetChange.resumeToken||this.emptyByteString(),a=t.targetChange.cause,s=a&&this.fromRpcStatus(a);e=new FS(r,i,o,s||null)}else if("documentChange"in t){lI(t.documentChange,"documentChange");var u=t.documentChange;lI(u.document,"documentChange.name"),lI(u.document.name,"documentChange.document.name"),lI(u.document.updateTime,"documentChange.document.updateTime");var c=this.fromName(u.document.name),h=this.fromVersion(u.document.updateTime),l=new Jw(c,h,{},void 0,u.document,function(t){return n.fromValue(t)}),f=u.targetIds||[],p=u.removedTargetIds||[];e=new xS(f,p,l.key,l)}else if("documentDelete"in t){lI(t.documentDelete,"documentDelete");var d=t.documentDelete;lI(d.document,"documentDelete.document"),c=this.fromName(d.document),h=d.readTime?this.fromVersion(d.readTime):Sv.forDeletedDoc(),l=new t_(c,h),p=d.removedTargetIds||[],e=new xS([],p,l.key,l)}else if("documentRemove"in t){lI(t.documentRemove,"documentRemove");var m=t.documentRemove;lI(m.document,"documentRemove"),c=this.fromName(m.document),p=m.removedTargetIds||[],e=new xS([],p,c,null)}else{if(!("filter"in t))return Zy("Unknown change type "+JSON.stringify(t));lI(t.filter,"filter");var y=t.filter;lI(y.targetId,"filter.targetId");var g=y.count||0,v=new iI(g),b=y.targetId;e=new LS(b,v)}return e},dI.prototype.fromWatchTargetChangeState=function(t){return"NO_CHANGE"===t?PS.NoChange:"ADD"===t?PS.Added:"REMOVE"===t?PS.Removed:"CURRENT"===t?PS.Current:"RESET"===t?PS.Reset:Zy("Got unexpected TargetChange.state: "+t)},dI.prototype.versionFromListenResponse=function(t){if(!("targetChange"in t))return Sv.MIN;var e=t.targetChange;return e.targetIds&&e.targetIds.length?Sv.MIN:e.readTime?this.fromVersion(e.readTime):Sv.MIN},dI.prototype.toMutation=function(t){var e,n=this;if(t instanceof Wb)e={update:this.toMutationDocument(t.key,t.value)};else if(t instanceof nw)e={delete:this.toName(t.key)};else if(t instanceof Hb)e={update:this.toMutationDocument(t.key,t.data),updateMask:this.toDocumentMask(t.fieldMask)};else{if(!(t instanceof Yb))return Zy("Unknown mutation type "+t.type);e={transform:{document:this.toName(t.key),fieldTransforms:t.fieldTransforms.map(function(t){return n.toFieldTransform(t)})}}}return t.precondition.isNone||(e.currentDocument=this.toPrecondition(t.precondition)),e},dI.prototype.fromMutation=function(t){var e=this,n=t.currentDocument?this.fromPrecondition(t.currentDocument):Ub.NONE;if(t.update){lI(t.update.name,"name");var r=this.fromName(t.update.name),i=this.fromFields(t.update.fields||{});if(t.updateMask){var o=this.fromDocumentMask(t.updateMask);return new Hb(r,i,o,n)}return new Wb(r,i,n)}if(t.delete)return r=this.fromName(t.delete),new nw(r,n);if(t.transform){r=this.fromName(t.transform.document);var a=t.transform.fieldTransforms.map(function(t){return e.fromFieldTransform(t)});return tg(!0===n.exists,'Transforms only support precondition "exists == true"'),new Yb(r,a)}return Zy("unknown mutation proto: "+JSON.stringify(t))},dI.prototype.toPrecondition=function(t){return tg(!t.isNone,"Can't serialize an empty precondition"),void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:Zy("Unknown precondition")},dI.prototype.fromPrecondition=function(t){return void 0!==t.updateTime?Ub.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?Ub.exists(t.exists):Ub.NONE},dI.prototype.fromWriteResult=function(t,e){var n=this,r=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);r.isEqual(Sv.MIN)&&(r=this.fromVersion(e));var i=null;return t.transformResults&&0<t.transformResults.length&&(i=t.transformResults.map(function(t){return n.fromValue(t)})),new Fb(r,i)},dI.prototype.fromWriteResults=function(t,e){var n=this;return t&&0<t.length?(tg(void 0!==e,"Received a write result without a commit time"),t.map(function(t){return n.fromWriteResult(t,e)})):[]},dI.prototype.toFieldTransform=function(t){var e=this,n=t.transform;if(n instanceof YS)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof JS)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements.map(function(t){return e.toValue(t)})}};if(n instanceof ZS)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements.map(function(t){return e.toValue(t)})}};if(n instanceof eI)return{fieldPath:t.field.canonicalString(),increment:this.toValue(n.operand)};throw Zy("Unknown transform: "+t.transform)},dI.prototype.fromFieldTransform=function(t){var e=this,n=null;if("setToServerValue"in t)tg("REQUEST_TIME"===t.setToServerValue,"Unknown server value transform proto: "+JSON.stringify(t)),n=YS.instance;else if("appendMissingElements"in t){var r=t.appendMissingElements.values||[];n=new JS(r.map(function(t){return e.fromValue(t)}))}else if("removeAllFromArray"in t)r=t.removeAllFromArray.values||[],n=new ZS(r.map(function(t){return e.fromValue(t)}));else if("increment"in t){var i=this.fromValue(t.increment);tg(i instanceof mw,"NUMERIC_ADD transform requires a NumberValue"),n=new eI(i)}else Zy("Unknown transform proto: "+JSON.stringify(t));var o=rv.fromServerFormat(t.fieldPath);return new Pb(o,n)},dI.prototype.toDocumentsTarget=function(t){return{documents:[this.toQueryPath(t.path)]}},dI.prototype.fromDocumentsTarget=function(t){var e=t.documents.length;tg(1===e,"DocumentsTarget contained other than 1 document: "+e);var n=t.documents[0];return jT.atPath(this.fromQueryPath(n)).toTarget()},dI.prototype.toQueryTarget=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(tg(n.length%2==0,"Collection Group queries should be within a document path or root."),e.parent=this.toQueryPath(n),e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(tg(n.length%2!=0,"Document queries with filters are not supported."),e.parent=this.toQueryPath(n.popLast()),e.structuredQuery.from=[{collectionId:n.lastSegment()}]);var r=this.toFilter(t.filters);r&&(e.structuredQuery.where=r);var i=this.toOrder(t.orderBy);i&&(e.structuredQuery.orderBy=i);var o=this.toInt32Value(t.limit);return null!==o&&(e.structuredQuery.limit=o),t.startAt&&(e.structuredQuery.startAt=this.toCursor(t.startAt)),t.endAt&&(e.structuredQuery.endAt=this.toCursor(t.endAt)),e},dI.prototype.fromQueryTarget=function(t){var e=this.fromQueryPath(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(0<r){tg(1===r,"StructuredQuery.from with more than one collection is not supported.");var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var a=[];n.where&&(a=this.fromFilter(n.where));var s=[];n.orderBy&&(s=this.fromOrder(n.orderBy));var u=null;n.limit&&(u=this.fromInt32Value(n.limit));var c=null;n.startAt&&(c=this.fromCursor(n.startAt));var h=null;return n.endAt&&(h=this.fromCursor(n.endAt)),new jT(e,i,s,a,u,UT.First,c,h).toTarget()},dI.prototype.toListenRequestLabels=function(t){var e=this.toLabel(t.purpose);return null==e?null:{"goog-listen-tags":e}},dI.prototype.toLabel=function(t){switch(t){case X_.Listen:return null;case X_.ExistenceFilterMismatch:return"existence-filter-mismatch";case X_.LimboResolution:return"limbo-document";default:return Zy("Unrecognized query purpose: "+t)}},dI.prototype.toTarget=function(t){var e,n=t.target;return(e=n.isDocumentQuery()?{documents:this.toDocumentsTarget(n)}:{query:this.toQueryTarget(n)}).targetId=t.targetId,0<t.resumeToken.length&&(e.resumeToken=this.unsafeCastProtoByteString(t.resumeToken)),e},dI.prototype.toFilter=function(t){var e=this;if(0!==t.length){var n=t.map(function(t){return t instanceof zT?e.toUnaryOrFieldFilter(t):Zy("Unrecognized filter: "+JSON.stringify(t))});return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},dI.prototype.fromFilter=function(t){var e=this;return t?void 0!==t.unaryFilter?[this.fromUnaryFilter(t)]:void 0!==t.fieldFilter?[this.fromFieldFilter(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map(function(t){return e.fromFilter(t)}).reduce(function(t,e){return t.concat(e)}):Zy("Unknown filter: "+JSON.stringify(t)):[]},dI.prototype.toOrder=function(t){var e=this;if(0!==t.length)return t.map(function(t){return e.toPropertyOrder(t)})},dI.prototype.fromOrder=function(t){var e=this;return t.map(function(t){return e.fromPropertyOrder(t)})},dI.prototype.toCursor=function(t){var e=this;return{before:t.before,values:t.position.map(function(t){return e.toValue(t)})}},dI.prototype.fromCursor=function(t){var e=this,n=!!t.before,r=t.values.map(function(t){return e.fromValue(t)});return new pE(r,n)},dI.prototype.toDirection=function(t){return uI[t.name]},dI.prototype.fromDirection=function(t){switch(t){case"ASCENDING":return lE.ASCENDING;case"DESCENDING":return lE.DESCENDING;default:return}},dI.prototype.toOperatorName=function(t){return cI[t.name]},dI.prototype.fromOperatorName=function(t){switch(t){case"EQUAL":return QT.EQUAL;case"GREATER_THAN":return QT.GREATER_THAN;case"GREATER_THAN_OR_EQUAL":return QT.GREATER_THAN_OR_EQUAL;case"LESS_THAN":return QT.LESS_THAN;case"LESS_THAN_OR_EQUAL":return QT.LESS_THAN_OR_EQUAL;case"ARRAY_CONTAINS":return QT.ARRAY_CONTAINS;case"IN":return QT.IN;case"ARRAY_CONTAINS_ANY":return QT.ARRAY_CONTAINS_ANY;case"OPERATOR_UNSPECIFIED":return Zy("Unspecified operator");default:return Zy("Unknown operator")}},dI.prototype.toFieldPathReference=function(t){return{fieldPath:t.canonicalString()}},dI.prototype.fromFieldPathReference=function(t){return rv.fromServerFormat(t.fieldPath)},dI.prototype.toPropertyOrder=function(t){return{field:this.toFieldPathReference(t.field),direction:this.toDirection(t.dir)}},dI.prototype.fromPropertyOrder=function(t){return new mE(this.fromFieldPathReference(t.field),this.fromDirection(t.direction))},dI.prototype.fromFieldFilter=function(t){return zT.create(this.fromFieldPathReference(t.fieldFilter.field),this.fromOperatorName(t.fieldFilter.op),this.fromValue(t.fieldFilter.value))},dI.prototype.toUnaryOrFieldFilter=function(t){if(t.op===QT.EQUAL){if(t.value.isEqual(Tw.NAN))return{unaryFilter:{field:this.toFieldPathReference(t.field),op:"IS_NAN"}};if(t.value.isEqual(cw.INSTANCE))return{unaryFilter:{field:this.toFieldPathReference(t.field),op:"IS_NULL"}}}return{fieldFilter:{field:this.toFieldPathReference(t.field),op:this.toOperatorName(t.op),value:this.toValue(t.value)}}},dI.prototype.fromUnaryFilter=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.fromFieldPathReference(t.unaryFilter.field);return zT.create(e,QT.EQUAL,Tw.NAN);case"IS_NULL":var n=this.fromFieldPathReference(t.unaryFilter.field);return zT.create(n,QT.EQUAL,cw.INSTANCE);case"OPERATOR_UNSPECIFIED":return Zy("Unspecified filter");default:return Zy("Unknown filter")}},dI.prototype.toDocumentMask=function(t){var e=[];return t.fields.forEach(function(t){return e.push(t.canonicalString())}),{fieldPaths:e}},dI.prototype.fromDocumentMask=function(t){var e=(t.fieldPaths||[]).map(function(t){return rv.fromServerFormat(t)});return Rb.fromArray(e)},dI);function dI(t,e){this.databaseId=t,this.options=e}var mI=function(){this.viewSnap=null,this.targetId=0,this.listeners=[]},yI=(gI.prototype.listen=function(t){var e=t.query,n=!1,r=this.queries.get(e);return r||(n=!0,r=new mI,this.queries.set(e,r)),r.listeners.push(t),tg(!t.applyOnlineStateChange(this.onlineState),"applyOnlineStateChange() shouldn't raise an event for brand-new listeners."),!r.viewSnap||t.onViewSnapshot(r.viewSnap)&&this.raiseSnapshotsInSyncEvent(),n?this.syncEngine.listen(e).then(function(t){return r.targetId=t}):Promise.resolve(r.targetId)},gI.prototype.unlisten=function(o){return ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){return e=o.query,n=!1,(r=this.queries.get(e))&&0<=(i=r.listeners.indexOf(o))&&(r.listeners.splice(i,1),n=0===r.listeners.length),n?(this.queries.delete(e),[2,this.syncEngine.unlisten(e)]):[2]})})},gI.prototype.onWatchChange=function(t){for(var e=!1,n=0,r=t;n<r.length;n++){var i=r[n],o=i.query,a=this.queries.get(o);if(a){for(var s=0,u=a.listeners;s<u.length;s++)u[s].onViewSnapshot(i)&&(e=!0);a.viewSnap=i}}e&&this.raiseSnapshotsInSyncEvent()},gI.prototype.onWatchError=function(t,e){var n=this.queries.get(t);if(n)for(var r=0,i=n.listeners;r<i.length;r++)i[r].onError(e);this.queries.delete(t)},gI.prototype.onOnlineStateChange=function(i){this.onlineState=i;var o=!1;this.queries.forEach(function(t,e){for(var n=0,r=e.listeners;n<r.length;n++)r[n].applyOnlineStateChange(i)&&(o=!0)}),o&&this.raiseSnapshotsInSyncEvent()},gI.prototype.addSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.add(t),t.next()},gI.prototype.removeSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.delete(t)},gI.prototype.raiseSnapshotsInSyncEvent=function(){this.snapshotsInSyncListeners.forEach(function(t){t.next()})},gI);function gI(t){this.syncEngine=t,this.queries=new o_(function(t){return t.canonicalId()}),this.onlineState=sS.Unknown,this.snapshotsInSyncListeners=new Set,this.syncEngine.subscribe(this)}var vI=(bI.prototype.onViewSnapshot=function(t){if(tg(0<t.docChanges.length||t.syncStateChanged,"We got a new snapshot with no changes?"),!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];i.type!==bS.Metadata&&e.push(i)}t=new NS(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}var o=!1;return this.raisedInitialEvent?this.shouldRaiseEvent(t)&&(this.queryObserver.next(t),o=!0):this.shouldRaiseInitialEvent(t,this.onlineState)&&(this.raiseInitialEvent(t),o=!0),this.snap=t,o},bI.prototype.onError=function(t){this.queryObserver.error(t)},bI.prototype.applyOnlineStateChange=function(t){this.onlineState=t;var e=!1;return this.snap&&!this.raisedInitialEvent&&this.shouldRaiseInitialEvent(this.snap,t)&&(this.raiseInitialEvent(this.snap),e=!0),e},bI.prototype.shouldRaiseInitialEvent=function(t,e){if(tg(!this.raisedInitialEvent,"Determining whether to raise first event but already had first event"),!t.fromCache)return!0;var n=e!==sS.Offline;return this.options.waitForSyncWhenOnline&&n?(tg(t.fromCache,"Waiting for sync, but snapshot is not from cache"),!1):!t.docs.isEmpty()||e===sS.Offline},bI.prototype.shouldRaiseEvent=function(t){if(0<t.docChanges.length)return!0;var e=this.snap&&this.snap.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges},bI.prototype.raiseInitialEvent=function(t){tg(!this.raisedInitialEvent,"Trying to raise initial events for second time"),t=NS.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.raisedInitialEvent=!0,this.queryObserver.next(t)},bI);function bI(t,e,n){this.query=t,this.queryObserver=e,this.raisedInitialEvent=!1,this.snap=null,this.onlineState=sS.Unknown,this.options=n||{}}var wI=(_I.fromSnapshot=function(t,e){for(var n=Hv(),r=Hv(),i=0,o=e.docChanges;i<o.length;i++){var a=o[i];switch(a.type){case bS.Added:n=n.add(a.doc.key);break;case bS.Removed:r=r.add(a.doc.key)}}return new _I(t,e.fromCache,n,r)},_I);function _I(t,e,n,r){this.targetId=t,this.fromCache=e,this.addedKeys=n,this.removedKeys=r}var TI=function(t){this.key=t},EI=function(t){this.key=t},SI=(Object.defineProperty(II.prototype,"syncedDocuments",{get:function(){return this._syncedDocuments},enumerable:!0,configurable:!0}),II.prototype.computeDocChanges=function(t,e){var s=this,u=e?e.changeSet:new IS,c=e?e.documentSet:this.documentSet,h=e?e.mutatedKeys:this.mutatedKeys,l=c,f=!1,p=this.query.hasLimitToFirst()&&c.size===this.query.limit?c.last():null,d=this.query.hasLimitToLast()&&c.size===this.query.limit?c.first():null;if(t.inorderTraversal(function(t,e){var n=c.get(t),r=e instanceof Jw?e:null;r&&(tg(t.isEqual(r.key),"Mismatching keys found in document changes: "+t+" != "+r.key),r=s.query.matches(r)?r:null);var i=!!n&&s.mutatedKeys.has(n.key),o=!!r&&(r.hasLocalMutations||s.mutatedKeys.has(r.key)&&r.hasCommittedMutations),a=!1;n&&r?n.data().isEqual(r.data())?i!==o&&(u.track({type:bS.Metadata,doc:r}),a=!0):s.shouldWaitForSyncedDocument(n,r)||(u.track({type:bS.Modified,doc:r}),a=!0,(p&&0<s.query.docComparator(r,p)||d&&s.query.docComparator(r,d)<0)&&(f=!0)):!n&&r?(u.track({type:bS.Added,doc:r}),a=!0):n&&!r&&(u.track({type:bS.Removed,doc:n}),a=!0,(p||d)&&(f=!0)),a&&(h=r?(l=l.add(r),o?h.add(t):h.delete(t)):(l=l.delete(t),h.delete(t)))}),this.query.hasLimitToFirst()||this.query.hasLimitToLast())for(;l.size>this.query.limit;){var n=this.query.hasLimitToFirst()?l.last():l.first();l=l.delete(n.key),h=h.delete(n.key),u.track({type:bS.Removed,doc:n})}return tg(!f||!e,"View was refilled using docs that themselves needed refilling."),{documentSet:l,changeSet:u,needsRefill:f,mutatedKeys:h}},II.prototype.shouldWaitForSyncedDocument=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},II.prototype.applyChanges=function(t,e,n){var r=this;tg(!t.needsRefill,"Cannot apply changes that need a refill");var i=this.documentSet;this.documentSet=t.documentSet,this.mutatedKeys=t.mutatedKeys;var o=t.changeSet.getChanges();o.sort(function(t,e){return function(t,e){function n(t){switch(t){case bS.Added:return 1;case bS.Modified:case bS.Metadata:return 2;case bS.Removed:return 0;default:return Zy("Unknown ChangeType: "+t)}}return n(t)-n(e)}(t.type,e.type)||r.query.docComparator(t.doc,e.doc)}),this.applyTargetChange(n);var a=e?this.updateLimboDocuments():[],s=0===this.limboDocuments.size&&this.current?_S.Synced:_S.Local,u=s!==this.syncState;return this.syncState=s,0!==o.length||u?{snapshot:new NS(this.query,t.documentSet,i,o,t.mutatedKeys,s===_S.Local,u,!1),limboChanges:a}:{limboChanges:a}},II.prototype.applyOnlineStateChange=function(t){return this.current&&t===sS.Offline?(this.current=!1,this.applyChanges({documentSet:this.documentSet,changeSet:new IS,mutatedKeys:this.mutatedKeys,needsRefill:!1},!1)):{limboChanges:[]}},II.prototype.shouldBeInLimbo=function(t){return!this._syncedDocuments.has(t)&&!!this.documentSet.has(t)&&!this.documentSet.get(t).hasLocalMutations},II.prototype.applyTargetChange=function(t){var e=this;t&&(t.addedDocuments.forEach(function(t){return e._syncedDocuments=e._syncedDocuments.add(t)}),t.modifiedDocuments.forEach(function(t){return tg(e._syncedDocuments.has(t),"Modified document "+t+" not found in view.")}),t.removedDocuments.forEach(function(t){return e._syncedDocuments=e._syncedDocuments.delete(t)}),this.current=t.current)},II.prototype.updateLimboDocuments=function(){var e=this;if(!this.current)return[];var n=this.limboDocuments;this.limboDocuments=Hv(),this.documentSet.forEach(function(t){e.shouldBeInLimbo(t.key)&&(e.limboDocuments=e.limboDocuments.add(t.key))});var r=[];return n.forEach(function(t){e.limboDocuments.has(t)||r.push(new EI(t))}),this.limboDocuments.forEach(function(t){n.has(t)||r.push(new TI(t))}),r},II.prototype.synchronizeWithPersistedState=function(t){this._syncedDocuments=t.remoteKeys,this.limboDocuments=Hv();var e=this.computeDocChanges(t.documents);return this.applyChanges(e,!0)},II.prototype.computeInitialSnapshot=function(){return NS.fromInitialDocuments(this.query,this.documentSet,this.mutatedKeys,this.syncState===_S.Local)},II);function II(t,e){this.query=t,this._syncedDocuments=e,this.syncState=null,this.current=!1,this.limboDocuments=Hv(),this.mutatedKeys=Hv(),this.documentSet=new ES(t.docComparator.bind(t))}var CI=(NI.prototype.run=function(){this.runWithBackOff()},NI.prototype.runWithBackOff=function(){var t=this;this.backoff.backoffAndRun(function(){return ya(t,void 0,void 0,function(){var e,n,r=this;return ga(this,function(t){return e=this.remoteStore.createTransaction(),(n=this.tryRunUpdateFunction(e))&&n.then(function(t){r.asyncQueue.enqueueAndForget(function(){return e.commit().then(function(){r.deferred.resolve(t)}).catch(function(t){r.handleTransactionError(t)})})}).catch(function(t){r.handleTransactionError(t)}),[2]})})})},NI.prototype.tryRunUpdateFunction=function(t){try{var e=this.updateFunction(t);return!LT(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}},NI.prototype.handleTransactionError=function(t){var e=this;0<this.retries&&this.isRetryableTransactionError(t)?(this.retries-=1,this.asyncQueue.enqueueAndForget(function(){return e.runWithBackOff(),Promise.resolve()})):this.deferred.reject(t)},NI.prototype.isRetryableTransactionError=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!gS(e)},NI);function NI(t,e,n,r){this.asyncQueue=t,this.remoteStore=e,this.updateFunction=n,this.deferred=r,this.retries=5,this.backoff=new HE(this.asyncQueue,sv.RetryTransaction)}var AI="SyncEngine",kI=function(t,e,n){this.query=t,this.targetId=e,this.view=n},DI=function(t){this.key=t,this.receivedDocument=!1},RI=(Object.defineProperty(OI.prototype,"isPrimaryClient",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),OI.prototype.subscribe=function(t){tg(null!==t,"SyncEngine listener cannot be null"),tg(null===this.syncEngineListener,"SyncEngine already has a subscriber."),this.syncEngineListener=t},OI.prototype.listen=function(a){return ya(this,void 0,void 0,function(){var e,n,r,i,o;return ga(this,function(t){switch(t.label){case 0:return this.assertSubscribed("listen()"),(r=this.queryViewsByQuery.get(a))?(e=r.targetId,this.sharedClientState.addLocalQueryTarget(e),n=r.view.computeInitialSnapshot(),[3,4]):[3,1];case 1:return[4,this.localStore.allocateTarget(a.toTarget())];case 2:return i=t.sent(),o=this.sharedClientState.addLocalQueryTarget(i.targetId),e=i.targetId,[4,this.initializeViewAndComputeSnapshot(a,e,"current"===o)];case 3:n=t.sent(),this.isPrimary&&this.remoteStore.listen(i),t.label=4;case 4:return this.syncEngineListener.onWatchChange([n]),[2,e]}})})},OI.prototype.initializeViewAndComputeSnapshot=function(s,u,c){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){switch(t.label){case 0:return[4,this.localStore.executeQuery(s,!0)];case 1:return e=t.sent(),n=new SI(s,e.remoteKeys),r=n.computeDocChanges(e.documents),i=RS.createSynthesizedTargetChangeForCurrentChange(u,c&&this.onlineState!==sS.Offline),tg(0===(o=n.applyChanges(r,!0===this.isPrimary,i)).limboChanges.length,"View returned limbo docs before target ack from the server."),tg(!!o.snapshot,"applyChanges for new view should always return a snapshot"),a=new kI(s,u,n),this.queryViewsByQuery.set(s,a),this.queriesByTarget[u]||(this.queriesByTarget[u]=[]),this.queriesByTarget[u].push(s),[2,o.snapshot]}})})},OI.prototype.synchronizeViewAndComputeSnapshot=function(r){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,this.localStore.executeQuery(r.query,!0)];case 1:return e=t.sent(),n=r.view.synchronizeWithPersistedState(e),this.isPrimary&&this.updateTrackedLimbos(r.targetId,n.limboChanges),[2,n]}})})},OI.prototype.unlisten=function(i){return ya(this,void 0,void 0,function(){var e,n,r=this;return ga(this,function(t){switch(t.label){case 0:return this.assertSubscribed("unlisten()"),tg(!!(e=this.queryViewsByQuery.get(i)),"Trying to unlisten on query not found:"+i),1<(n=this.queriesByTarget[e.targetId]).length?(this.queriesByTarget[e.targetId]=n.filter(function(t){return!t.isEqual(i)}),this.queryViewsByQuery.delete(i),[2]):this.isPrimary?(this.sharedClientState.removeLocalQueryTarget(e.targetId),this.sharedClientState.isActiveQueryTarget(e.targetId)?[3,2]:[4,this.localStore.releaseTarget(e.targetId,!1).then(function(){r.sharedClientState.clearQueryState(e.targetId),r.remoteStore.unlisten(e.targetId),r.removeAndCleanupTarget(e.targetId)}).catch(CT)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return this.removeAndCleanupTarget(e.targetId),[4,this.localStore.releaseTarget(e.targetId,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})},OI.prototype.write=function(n,r){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return this.assertSubscribed("write()"),[4,this.localStore.localWrite(n)];case 1:return e=t.sent(),this.sharedClientState.addPendingMutation(e.batchId),this.addMutationCallback(e.batchId,r),[4,this.emitNewSnapsAndNotifyLocalStore(e.changes)];case 2:return t.sent(),[4,this.remoteStore.fillWritePipeline()];case 3:return t.sent(),[2]}})})},OI.prototype.runTransaction=function(t,e,n){new CI(t,this.remoteStore,e,n).run()},OI.prototype.applyRemoteEvent=function(n){return ya(this,void 0,void 0,function(){var e,r=this;return ga(this,function(t){switch(t.label){case 0:this.assertSubscribed("applyRemoteEvent()"),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.localStore.applyRemoteEvent(n)];case 2:return e=t.sent(),fg(n.targetChanges,function(t,e){var n=r.limboResolutionsByTarget[Number(t)];n&&(tg(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,"Limbo resolution for single document contains multiple changes."),0<e.addedDocuments.size?n.receivedDocument=!0:0<e.modifiedDocuments.size?tg(n.receivedDocument,"Received change for limbo target document without add."):0<e.removedDocuments.size&&(tg(n.receivedDocument,"Received remove for limbo target document without add."),n.receivedDocument=!1))}),[4,this.emitNewSnapsAndNotifyLocalStore(e,n)];case 3:return t.sent(),[3,6];case 4:return[4,CT(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},OI.prototype.applyOnlineStateChange=function(r,t){if(this.isPrimary&&t===cS.RemoteStore||!this.isPrimary&&t===cS.SharedClientState){this.assertSubscribed("applyOnlineStateChange()");var i=[];this.queryViewsByQuery.forEach(function(t,e){var n=e.view.applyOnlineStateChange(r);tg(0===n.limboChanges.length,"OnlineState should not affect limbo documents."),n.snapshot&&i.push(n.snapshot)}),this.syncEngineListener.onOnlineStateChange(r),this.syncEngineListener.onWatchChange(i),this.onlineState=r,this.isPrimary&&this.sharedClientState.setOnlineState(r)}},OI.prototype.rejectListen=function(s,u){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a=this;return ga(this,function(t){switch(t.label){case 0:return this.assertSubscribed("rejectListens()"),this.sharedClientState.updateQueryState(s,"rejected",u),e=this.limboResolutionsByTarget[s],(n=e&&e.key)?(this.limboTargetsByKey=this.limboTargetsByKey.remove(n),delete this.limboResolutionsByTarget[s],r=(r=new Cv(ov.comparator)).insert(n,new t_(n,Sv.forDeletedDoc())),i=Hv().add(n),o=new kS(Sv.MIN,{},new Mv(xg),r,i),[2,this.applyRemoteEvent(o)]):[3,1];case 1:return[4,this.localStore.releaseTarget(s,!1).then(function(){return a.removeAndCleanupTarget(s,u)}).catch(CT)];case 2:t.sent(),t.label=3;case 3:return[2]}})})},OI.prototype.applyBatchState=function(n,r,i){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return this.assertSubscribed("applyBatchState()"),[4,this.localStore.lookupMutationDocuments(n)];case 1:return null===(e=t.sent())?(Xy(AI,"Cannot apply mutation batch with id: "+n),[2]):"pending"!==r?[3,3]:[4,this.remoteStore.fillWritePipeline()];case 2:return t.sent(),[3,4];case 3:"acknowledged"===r||"rejected"===r?(this.processUserCallback(n,i||null),this.localStore.removeCachedMutationBatchMetadata(n)):Zy("Unknown batchState: "+r),t.label=4;case 4:return[4,this.emitNewSnapsAndNotifyLocalStore(e)];case 5:return t.sent(),[2]}})})},OI.prototype.applySuccessfulWrite=function(r){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:this.assertSubscribed("applySuccessfulWrite()"),e=r.batch.batchId,this.processUserCallback(e,null),this.triggerPendingWritesCallbacks(e),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.localStore.acknowledgeBatch(r)];case 2:return n=t.sent(),this.sharedClientState.updateMutationState(e,"acknowledged"),[4,this.emitNewSnapsAndNotifyLocalStore(n)];case 3:return t.sent(),[3,6];case 4:return[4,CT(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},OI.prototype.rejectFailedWrite=function(n,r){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:this.assertSubscribed("rejectFailedWrite()"),this.processUserCallback(n,r),this.triggerPendingWritesCallbacks(n),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this.localStore.rejectBatch(n)];case 2:return e=t.sent(),this.sharedClientState.updateMutationState(n,"rejected",r),[4,this.emitNewSnapsAndNotifyLocalStore(e)];case 3:return t.sent(),[3,6];case 4:return[4,CT(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},OI.prototype.registerPendingWritesCallback=function(r){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return this.remoteStore.canUseNetwork()||Xy(AI,"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),[4,this.localStore.getHighestUnacknowledgedBatchId()];case 1:return-1===(e=t.sent())?r.resolve():((n=this.pendingWritesCallbacks.get(e)||[]).push(r),this.pendingWritesCallbacks.set(e,n)),[2]}})})},OI.prototype.triggerPendingWritesCallbacks=function(t){(this.pendingWritesCallbacks.get(t)||[]).forEach(function(t){t.resolve()}),this.pendingWritesCallbacks.delete(t)},OI.prototype.rejectOutstandingPendingWritesCallbacks=function(e){this.pendingWritesCallbacks.forEach(function(t){t.forEach(function(t){t.reject(new ag(og.CANCELLED,e))})}),this.pendingWritesCallbacks.clear()},OI.prototype.addMutationCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];n=(n=n||new Cv(xg)).insert(t,e),this.mutationUserCallbacks[this.currentUser.toKey()]=n},OI.prototype.processUserCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];if(n){var r=n.get(t);r&&(tg(t===n.minKey(),"Mutation callbacks processed out-of-order?"),e?r.reject(e):r.resolve(),n=n.remove(t)),this.mutationUserCallbacks[this.currentUser.toKey()]=n}},OI.prototype.removeAndCleanupTarget=function(t,e){var n=this;void 0===e&&(e=null),this.sharedClientState.removeLocalQueryTarget(t),tg(this.queriesByTarget[t]&&0!==this.queriesByTarget[t].length,"There are no queries mapped to target id "+t);for(var r=0,i=this.queriesByTarget[t];r<i.length;r++){var o=i[r];this.queryViewsByQuery.delete(o),e&&this.syncEngineListener.onWatchError(o,e)}if(delete this.queriesByTarget[t],this.isPrimary){var a=this.limboDocumentRefs.referencesForId(t);this.limboDocumentRefs.removeReferencesForId(t),a.forEach(function(t){n.limboDocumentRefs.containsKey(t)||n.removeLimboTarget(t)})}},OI.prototype.removeLimboTarget=function(t){var e=this.limboTargetsByKey.get(t);null!==e&&(this.remoteStore.unlisten(e),this.limboTargetsByKey=this.limboTargetsByKey.remove(t),delete this.limboResolutionsByTarget[e])},OI.prototype.updateTrackedLimbos=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof TI?(this.limboDocumentRefs.addReference(i.key,t),this.trackLimboChange(i)):i instanceof EI?(Xy(AI,"Document no longer in limbo: "+i.key),this.limboDocumentRefs.removeReference(i.key,t),this.limboDocumentRefs.containsKey(i.key)||this.removeLimboTarget(i.key)):Zy("Unknown limbo change: "+JSON.stringify(i))}},OI.prototype.trackLimboChange=function(t){var e=t.key;if(!this.limboTargetsByKey.get(e)){Xy(AI,"New document in limbo: "+e);var n=this.limboTargetIdGenerator.next(),r=jT.atPath(e.path);this.limboResolutionsByTarget[n]=new DI(e),this.remoteStore.listen(new nT(r.toTarget(),n,X_.LimboResolution,Gg.INVALID)),this.limboTargetsByKey=this.limboTargetsByKey.insert(e,n)}},OI.prototype.currentLimboDocs=function(){return this.limboTargetsByKey},OI.prototype.emitNewSnapsAndNotifyLocalStore=function(r,u){return ya(this,void 0,void 0,function(){var o,a,e,s=this;return ga(this,function(t){switch(t.label){case 0:return o=[],a=[],e=[],this.queryViewsByQuery.forEach(function(t,i){e.push(Promise.resolve().then(function(){var n=i.view.computeDocChanges(r);return n.needsRefill?s.localStore.executeQuery(i.query,!1).then(function(t){var e=t.documents;return i.view.computeDocChanges(e,n)}):n}).then(function(t){var e=u&&u.targetChanges[i.targetId],n=i.view.applyChanges(t,!0===s.isPrimary,e);if(s.updateTrackedLimbos(i.targetId,n.limboChanges),n.snapshot){s.isPrimary&&s.sharedClientState.updateQueryState(i.targetId,n.snapshot.fromCache?"not-current":"current"),o.push(n.snapshot);var r=wI.fromSnapshot(i.targetId,n.snapshot);a.push(r)}}))}),[4,Promise.all(e)];case 1:return t.sent(),this.syncEngineListener.onWatchChange(o),[4,this.localStore.notifyLocalViewChanges(a)];case 2:return t.sent(),[2]}})})},OI.prototype.assertSubscribed=function(t){tg(null!==this.syncEngineListener,"Trying to call "+t+" before calling subscribe().")},OI.prototype.handleCredentialChange=function(r){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return e=!this.currentUser.isEqual(r),this.currentUser=r,e?(this.rejectOutstandingPendingWritesCallbacks("'waitForPendingWrites' promise is rejected due to a user change."),[4,this.localStore.handleUserChange(r)]):[3,3];case 1:return n=t.sent(),this.sharedClientState.handleUserChange(r,n.removedBatchIds,n.addedBatchIds),[4,this.emitNewSnapsAndNotifyLocalStore(n.affectedDocuments)];case 2:t.sent(),t.label=3;case 3:return[4,this.remoteStore.handleCredentialChange()];case 4:return t.sent(),[2]}})})},OI.prototype.applyPrimaryState=function(c){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u=this;return ga(this,function(t){switch(t.label){case 0:return!0!==c||!0===this.isPrimary?[3,3]:(this.isPrimary=!0,[4,this.remoteStore.applyPrimaryState(!0)]);case 1:return t.sent(),e=this.sharedClientState.getAllActiveQueryTargets(),[4,this.synchronizeQueryViewsAndRaiseSnapshots(e.toArray())];case 2:for(n=t.sent(),r=0,i=n;r<i.length;r++)o=i[r],this.remoteStore.listen(o);return[3,7];case 3:return!1!==c||!1===this.isPrimary?[3,7]:(this.isPrimary=!1,a=[],s=Promise.resolve(),lg(this.queriesByTarget,function(t,e){u.sharedClientState.isLocalQueryTarget(t)?a.push(t):s=s.then(function(){return u.removeAndCleanupTarget(t),u.localStore.releaseTarget(t,!0)}),u.remoteStore.unlisten(t)}),[4,s]);case 4:return t.sent(),[4,this.synchronizeQueryViewsAndRaiseSnapshots(a)];case 5:return t.sent(),this.resetLimboDocuments(),[4,this.remoteStore.applyPrimaryState(!1)];case 6:t.sent(),t.label=7;case 7:return[2]}})})},OI.prototype.resetLimboDocuments=function(){var e=this;lg(this.limboResolutionsByTarget,function(t){e.remoteStore.unlisten(t)}),this.limboDocumentRefs.removeAllReferences(),this.limboResolutionsByTarget=[],this.limboTargetsByKey=new Cv(ov.comparator)},OI.prototype.synchronizeQueryViewsAndRaiseSnapshots=function(d){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f,p;return ga(this,function(t){switch(t.label){case 0:e=[],n=[],r=0,i=d,t.label=1;case 1:return r<i.length?(o=i[r],a=void 0,(s=this.queriesByTarget[o])&&0!==s.length?[4,this.localStore.releaseTarget(o,!0)]:[3,8]):[3,14];case 2:return t.sent(),[4,this.localStore.allocateTarget(s[0].toTarget())];case 3:a=t.sent(),u=0,c=s,t.label=4;case 4:return u<c.length?(h=c[u],tg(!!(l=this.queryViewsByQuery.get(h)),"No query view found for "+h),[4,this.synchronizeViewAndComputeSnapshot(l)]):[3,7];case 5:(f=t.sent()).snapshot&&n.push(f.snapshot),t.label=6;case 6:return u++,[3,4];case 7:return[3,12];case 8:return tg(!0===this.isPrimary,"A secondary tab should never have an active target without an active query."),[4,this.localStore.getTarget(o)];case 9:return tg(!!(p=t.sent()),"Target for id "+o+" not found"),[4,this.localStore.allocateTarget(p)];case 10:return a=t.sent(),[4,this.initializeViewAndComputeSnapshot(this.synthesizeTargetToQuery(p),o,!1)];case 11:t.sent(),t.label=12;case 12:e.push(a),t.label=13;case 13:return r++,[3,1];case 14:return this.syncEngineListener.onWatchChange(n),[2,e]}})})},OI.prototype.synthesizeTargetToQuery=function(t){return new jT(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,UT.First,t.startAt,t.endAt)},OI.prototype.getActiveClients=function(){return this.localStore.getActiveClients()},OI.prototype.applyTargetState=function(r,i,o){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:if(this.isPrimary)return Xy(AI,"Ignoring unexpected query state notification."),[2];if(!this.queriesByTarget[r])return[3,7];switch(i){case"current":case"not-current":return[3,1];case"rejected":return[3,4]}return[3,6];case 1:return[4,this.localStore.getNewDocumentChanges()];case 2:return e=t.sent(),n=kS.createSynthesizedRemoteEventForCurrentChange(r,"current"===i),[4,this.emitNewSnapsAndNotifyLocalStore(e,n)];case 3:return t.sent(),[3,7];case 4:return[4,this.localStore.releaseTarget(r,!0)];case 5:return t.sent(),this.removeAndCleanupTarget(r,o),[3,7];case 6:Zy("Unexpected target state: "+i),t.label=7;case 7:return[2]}})})},OI.prototype.applyActiveTargetsChange=function(l,f){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h=this;return ga(this,function(t){switch(t.label){case 0:if(!this.isPrimary)return[2];e=0,n=l,t.label=1;case 1:return e<n.length?(c=n[e],tg(!this.queriesByTarget[c],"Trying to add an already active target"),[4,this.localStore.getTarget(c)]):[3,6];case 2:return tg(!!(r=t.sent()),"Query data for active target "+c+" not found"),[4,this.localStore.allocateTarget(r)];case 3:return i=t.sent(),[4,this.initializeViewAndComputeSnapshot(this.synthesizeTargetToQuery(r),i.targetId,!1)];case 4:t.sent(),this.remoteStore.listen(i),t.label=5;case 5:return e++,[3,1];case 6:o=function(e){return ga(this,function(t){switch(t.label){case 0:return a.queriesByTarget[e]?[4,a.localStore.releaseTarget(e,!1).then(function(){h.remoteStore.unlisten(e),h.removeAndCleanupTarget(e)}).catch(CT)]:[2,"continue"];case 1:return t.sent(),[2]}})},a=this,s=0,u=f,t.label=7;case 7:return s<u.length?(c=u[s],[5,o(c)]):[3,10];case 8:t.sent(),t.label=9;case 9:return s++,[3,7];case 10:return[2]}})})},OI.prototype.enableNetwork=function(){return this.localStore.setNetworkEnabled(!0),this.remoteStore.enableNetwork()},OI.prototype.disableNetwork=function(){return this.localStore.setNetworkEnabled(!1),this.remoteStore.disableNetwork()},OI.prototype.getRemoteKeysForTarget=function(t){var e=this.limboResolutionsByTarget[t];if(e&&e.receivedDocument)return Hv().add(e.key);var n=Hv(),r=this.queriesByTarget[t];if(!r)return n;for(var i=0,o=r;i<o.length;i++){var a=o[i],s=this.queryViewsByQuery.get(a);tg(!!s,"No query view found for "+a),n=n.unionWith(s.view.syncedDocuments)}return n},OI);function OI(t,e,n,r){this.localStore=t,this.remoteStore=e,this.sharedClientState=n,this.currentUser=r,this.syncEngineListener=null,this.queryViewsByQuery=new o_(function(t){return t.canonicalId()}),this.queriesByTarget={},this.limboTargetsByKey=new Cv(ov.comparator),this.limboResolutionsByTarget={},this.limboDocumentRefs=new EE,this.mutationUserCallbacks={},this.pendingWritesCallbacks=new Map,this.limboTargetIdGenerator=Eb.forSyncEngine(),this.isPrimary=void 0,this.onlineState=sS.Unknown}var PI=(MI.prototype.isAuthenticated=function(){return null!=this.uid},MI.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},MI.prototype.isEqual=function(t){return t.uid===this.uid},MI.UNAUTHENTICATED=new MI(null),MI.GOOGLE_CREDENTIALS=new MI("google-credentials-uid"),MI.FIRST_PARTY=new MI("first-party-uid"),MI);function MI(t){this.uid=t}var xI="SharedClientState",LI="firestore_clients",FI="firestore_mutations",UI="firestore_targets",VI=(qI.fromWebStorageEntry=function(t,e,n){var r=JSON.parse(n),i="object"==typeof r&&-1!==["pending","acknowledged","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error),o=void 0;return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(o=new ag(r.error.code,r.error.message)),i?new qI(t,e,r.state,o):(Jy(xI,"Failed to parse mutation state for ID '"+e+"': "+n),null)},qI.prototype.toWebStorageJSON=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},qI);function qI(t,e,n,r){this.user=t,this.batchId=e,this.state=n,tg(void 0!==(this.error=r)==("rejected"===n),"MutationMetadata must contain an error iff state is 'rejected'")}var BI=(jI.fromWebStorageEntry=function(t,e){var n=JSON.parse(e),r="object"==typeof n&&-1!==["not-current","current","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error),i=void 0;return r&&n.error&&(r="string"==typeof n.error.message&&"string"==typeof n.error.code)&&(i=new ag(n.error.code,n.error.message)),r?new jI(t,n.state,i):(Jy(xI,"Failed to parse target state for ID '"+t+"': "+e),null)},jI.prototype.toWebStorageJSON=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},jI);function jI(t,e,n){this.targetId=t,this.state=e,tg(void 0!==(this.error=n)==("rejected"===e),"QueryTargetMetadata must contain an error iff state is 'rejected'")}var WI=(KI.fromWebStorageEntry=function(t,e){for(var n=JSON.parse(e),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=zv(),o=0;r&&o<n.activeTargetIds.length;++o)r=FT(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return r?new KI(t,i):(Jy(xI,"Failed to parse client data for instance '"+t+"': "+e),null)},KI);function KI(t,e){this.clientId=t,this.activeTargetIds=e}var QI=(HI.fromWebStorageEntry=function(t){var e=JSON.parse(t);return"object"==typeof e&&e.onlineState in sS&&"string"==typeof e.clientId?new HI(e.clientId,sS[e.onlineState]):(Jy(xI,"Failed to parse online state: "+t),null)},HI);function HI(t,e){this.clientId=t,this.onlineState=e}var GI=(zI.prototype.addQueryTarget=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},zI.prototype.removeQueryTarget=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},zI.prototype.toWebStorageJSON=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},zI);function zI(){this.activeTargetIds=zv()}var YI=(XI.isAvailable=function(t){return!(!t.window||null==t.window.localStorage)},XI.prototype.start=function(){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f=this;return ga(this,function(t){switch(t.label){case 0:return tg(!this.started,"WebStorageSharedClientState already started"),tg(null!==this.syncEngine,"syncEngine property must be set before calling start()"),tg(null!==this.onlineStateHandler,"onlineStateHandler property must be set before calling start()"),[4,this.syncEngine.getActiveClients()];case 1:for(e=t.sent(),n=0,r=e;n<r.length;n++)(i=r[n])!==this.localClientId&&(o=this.getItem(this.toWebStorageClientStateKey(i)))&&(a=WI.fromWebStorageEntry(i,o))&&(this.activeClients[a.clientId]=a);for(this.persistClientState(),(s=this.storage.getItem(this.onlineStateKey))&&(u=this.fromWebStorageOnlineState(s))&&this.handleOnlineStateEvent(u),c=0,h=this.earlyEvents;c<h.length;c++)l=h[c],this.handleWebStorageEvent(l);return this.earlyEvents=[],this.platform.window.addEventListener("unload",function(){return f.shutdown()}),this.started=!0,[2]}})})},XI.prototype.writeSequenceNumber=function(t){this.setItem(this.sequenceNumberKey,JSON.stringify(t))},XI.prototype.getAllActiveQueryTargets=function(){var n=zv();return fg(this.activeClients,function(t,e){n=n.unionWith(e.activeTargetIds)}),n},XI.prototype.isActiveQueryTarget=function(t){for(var e in this.activeClients)if(this.activeClients.hasOwnProperty(e)&&this.activeClients[e].activeTargetIds.has(t))return!0;return!1},XI.prototype.addPendingMutation=function(t){this.persistMutationState(t,"pending")},XI.prototype.updateMutationState=function(t,e,n){this.persistMutationState(t,e,n),this.removeMutationState(t)},XI.prototype.addLocalQueryTarget=function(t){var e="not-current";if(this.isActiveQueryTarget(t)){var n=this.storage.getItem(this.toWebStorageQueryTargetMetadataKey(t));if(n){var r=BI.fromWebStorageEntry(t,n);r&&(e=r.state)}}return this.localClientState.addQueryTarget(t),this.persistClientState(),e},XI.prototype.removeLocalQueryTarget=function(t){this.localClientState.removeQueryTarget(t),this.persistClientState()},XI.prototype.isLocalQueryTarget=function(t){return this.localClientState.activeTargetIds.has(t)},XI.prototype.clearQueryState=function(t){this.removeItem(this.toWebStorageQueryTargetMetadataKey(t))},XI.prototype.updateQueryState=function(t,e,n){this.persistQueryTargetState(t,e,n)},XI.prototype.handleUserChange=function(t,e,n){var r=this;e.forEach(function(t){r.removeMutationState(t)}),this.currentUser=t,n.forEach(function(t){r.addPendingMutation(t)})},XI.prototype.setOnlineState=function(t){this.persistOnlineState(t)},XI.prototype.shutdown=function(){this.started&&(this.platform.window.removeEventListener("storage",this.storageListener),this.removeItem(this.localClientStorageKey),this.started=!1)},XI.prototype.getItem=function(t){var e=this.storage.getItem(t);return Xy(xI,"READ",t,e),e},XI.prototype.setItem=function(t,e){Xy(xI,"SET",t,e),this.storage.setItem(t,e)},XI.prototype.removeItem=function(t){Xy(xI,"REMOVE",t),this.storage.removeItem(t)},XI.prototype.handleWebStorageEvent=function(s){var t=this;if(s.storageArea===this.storage){if(Xy(xI,"EVENT",s.key,s.newValue),s.key===this.localClientStorageKey)return void Jy("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.queue.enqueueAndForget(function(){return ya(t,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){if(!this.started)return this.earlyEvents.push(s),[2];if(null===s.key)return[2];if(this.clientStateKeyRe.test(s.key)){if(null==s.newValue)return n=this.fromWebStorageClientStateKey(s.key),[2,this.handleClientStateEvent(n,null)];if(e=this.fromWebStorageClientState(s.key,s.newValue))return[2,this.handleClientStateEvent(e.clientId,e)]}else if(this.mutationBatchKeyRe.test(s.key)){if(null!==s.newValue&&(r=this.fromWebStorageMutationMetadata(s.key,s.newValue)))return[2,this.handleMutationBatchEvent(r)]}else if(this.queryTargetKeyRe.test(s.key)){if(null!==s.newValue&&(i=this.fromWebStorageQueryTargetMetadata(s.key,s.newValue)))return[2,this.handleQueryTargetEvent(i)]}else if(s.key===this.onlineStateKey){if(null!==s.newValue&&(o=this.fromWebStorageOnlineState(s.newValue)))return[2,this.handleOnlineStateEvent(o)]}else s.key===this.sequenceNumberKey&&(tg(!!this.sequenceNumberHandler,"Missing sequenceNumberHandler"),(a=function(t){var e=Gg.INVALID;if(null!=t)try{var n=JSON.parse(t);tg("number"==typeof n,"Found non-numeric sequence number"),e=n}catch(t){Jy(xI,"Failed to read sequence number from WebStorage",t)}return e}(s.newValue))!==Gg.INVALID&&this.sequenceNumberHandler(a));return[2]})})})}},Object.defineProperty(XI.prototype,"localClientState",{get:function(){return this.activeClients[this.localClientId]},enumerable:!0,configurable:!0}),XI.prototype.persistClientState=function(){this.setItem(this.localClientStorageKey,this.localClientState.toWebStorageJSON())},XI.prototype.persistMutationState=function(t,e,n){var r=new VI(this.currentUser,t,e,n),i=this.toWebStorageMutationBatchKey(t);this.setItem(i,r.toWebStorageJSON())},XI.prototype.removeMutationState=function(t){var e=this.toWebStorageMutationBatchKey(t);this.removeItem(e)},XI.prototype.persistOnlineState=function(t){var e={clientId:this.localClientId,onlineState:sS[t]};this.storage.setItem(this.onlineStateKey,JSON.stringify(e))},XI.prototype.persistQueryTargetState=function(t,e,n){var r=this.toWebStorageQueryTargetMetadataKey(t),i=new BI(t,e,n);this.setItem(r,i.toWebStorageJSON())},XI.prototype.toWebStorageClientStateKey=function(t){return tg(-1===t.indexOf("_"),"Client key cannot contain '_', but was '"+t+"'"),LI+"_"+this.persistenceKey+"_"+t},XI.prototype.toWebStorageQueryTargetMetadataKey=function(t){return UI+"_"+this.persistenceKey+"_"+t},XI.prototype.toWebStorageMutationBatchKey=function(t){var e=FI+"_"+this.persistenceKey+"_"+t;return this.currentUser.isAuthenticated()&&(e+="_"+this.currentUser.uid),e},XI.prototype.fromWebStorageClientStateKey=function(t){var e=this.clientStateKeyRe.exec(t);return e?e[1]:null},XI.prototype.fromWebStorageClientState=function(t,e){var n=this.fromWebStorageClientStateKey(t);return tg(null!==n,"Cannot parse client state key '"+t+"'"),WI.fromWebStorageEntry(n,e)},XI.prototype.fromWebStorageMutationMetadata=function(t,e){var n=this.mutationBatchKeyRe.exec(t);tg(null!==n,"Cannot parse mutation batch key '"+t+"'");var r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return VI.fromWebStorageEntry(new PI(i),r,e)},XI.prototype.fromWebStorageQueryTargetMetadata=function(t,e){var n=this.queryTargetKeyRe.exec(t);tg(null!==n,"Cannot parse query target key '"+t+"'");var r=Number(n[1]);return BI.fromWebStorageEntry(r,e)},XI.prototype.fromWebStorageOnlineState=function(t){return QI.fromWebStorageEntry(t)},XI.prototype.handleMutationBatchEvent=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){return e.user.uid!==this.currentUser.uid?(Xy(xI,"Ignoring mutation for non-active user "+e.user.uid),[2]):[2,this.syncEngine.applyBatchState(e.batchId,e.state,e.error)]})})},XI.prototype.handleQueryTargetEvent=function(t){return this.syncEngine.applyTargetState(t.targetId,t.state,t.error)},XI.prototype.handleClientStateEvent=function(t,e){var n=this,r=this.getAllActiveQueryTargets();e?this.activeClients[t]=e:delete this.activeClients[t];var i=this.getAllActiveQueryTargets(),o=[],a=[];return i.forEach(function(e){return ya(n,void 0,void 0,function(){return ga(this,function(t){return r.has(e)||o.push(e),[2]})})}),r.forEach(function(e){return ya(n,void 0,void 0,function(){return ga(this,function(t){return i.has(e)||a.push(e),[2]})})}),this.syncEngine.applyActiveTargetsChange(o,a)},XI.prototype.handleOnlineStateEvent=function(t){this.activeClients[t.clientId]&&this.onlineStateHandler(t.onlineState)},XI);function XI(t,e,n,r,i){if(this.queue=t,this.platform=e,this.persistenceKey=n,this.localClientId=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.activeClients={},this.storageListener=this.handleWebStorageEvent.bind(this),this.started=!1,this.earlyEvents=[],!XI.isAvailable(this.platform))throw new ag(og.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=i,this.localClientStorageKey=this.toWebStorageClientStateKey(this.localClientId),this.sequenceNumberKey="firestore_sequence_number_"+n,this.activeClients[this.localClientId]=new GI,this.clientStateKeyRe=new RegExp("^"+LI+"_"+o+"_([^_]*)$"),this.mutationBatchKeyRe=new RegExp("^"+FI+"_"+o+"_(\\d+)(?:_(.*))?$"),this.queryTargetKeyRe=new RegExp("^"+UI+"_"+o+"_(\\d+)$"),this.onlineStateKey="firestore_online_state_"+n,this.platform.window.addEventListener("storage",this.storageListener)}var JI=($I.prototype.addPendingMutation=function(t){},$I.prototype.updateMutationState=function(t,e,n){},$I.prototype.addLocalQueryTarget=function(t){return this.localState.addQueryTarget(t),this.queryState[t]||"not-current"},$I.prototype.updateQueryState=function(t,e,n){this.queryState[t]=e},$I.prototype.removeLocalQueryTarget=function(t){this.localState.removeQueryTarget(t)},$I.prototype.isLocalQueryTarget=function(t){return this.localState.activeTargetIds.has(t)},$I.prototype.clearQueryState=function(t){delete this.queryState[t]},$I.prototype.getAllActiveQueryTargets=function(){return this.localState.activeTargetIds},$I.prototype.isActiveQueryTarget=function(t){return this.localState.activeTargetIds.has(t)},$I.prototype.start=function(){return this.localState=new GI,Promise.resolve()},$I.prototype.handleUserChange=function(t,e,n){},$I.prototype.setOnlineState=function(t){},$I.prototype.shutdown=function(){},$I.prototype.writeSequenceNumber=function(t){},$I);function $I(){this.localState=new GI,this.queryState={},this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null}var ZI="FirestoreClient",tC=(eC.prototype.lruParams=function(){return hT.withCacheSize(this.cacheSizeBytes)},eC);function eC(t,e){this.cacheSizeBytes=t,this.synchronizeTabs=e}var nC=function(){},rC=(iC.prototype.start=function(t){var n=this;this.verifyNotTerminated();var r=new cv,i=new cv,o=!1;return this.credentials.setChangeListener(function(e){o?n.asyncQueue.enqueueAndForget(function(){return n.handleCredentialChange(e)}):(o=!0,n.initializePersistence(t,i,e).then(function(t){return n.initializeRest(e,t)}).then(r.resolve,r.reject))}),this.asyncQueue.enqueueAndForget(function(){return r.promise}),i.promise},iC.prototype.enableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return t.syncEngine.enableNetwork()})},iC.prototype.initializePersistence=function(t,e,n){var r=this;return t instanceof tC?this.startIndexedDbPersistence(n,t).then(function(t){return e.resolve(),t}).catch(function(t){if(e.reject(t),!r.canFallback(t))throw t;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+t),r.startMemoryPersistence()}):(e.resolve(),this.startMemoryPersistence())},iC.prototype.canFallback=function(t){return t instanceof ag?t.code===og.FAILED_PRECONDITION||t.code===og.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},iC.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new ag(og.FAILED_PRECONDITION,"The client has already been terminated.")},iC.prototype.startIndexedDbPersistence=function(r,i){var t=this,o=ST.buildStoragePrefix(this.databaseInfo),a=new pI(this.databaseInfo.databaseId,{useProto3Json:!0});return Promise.resolve().then(function(){return ya(t,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:if(i.synchronizeTabs&&!YI.isAvailable(this.platform))throw new ag(og.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");return e=i.lruParams(),this.sharedClientState=i.synchronizeTabs?new YI(this.asyncQueue,this.platform,o,this.clientId,r):new JI,[4,ST.createIndexedDbPersistence({allowTabSynchronization:i.synchronizeTabs,persistenceKey:o,clientId:this.clientId,platform:this.platform,queue:this.asyncQueue,serializer:a,lruParams:e,sequenceNumberSyncer:this.sharedClientState})];case 1:return n=t.sent(),[2,(this.persistence=n).referenceDelegate.garbageCollector]}})})})},iC.prototype.startMemoryPersistence=function(){return this.persistence=FE.createEagerPersistence(this.clientId),this.sharedClientState=new JI,Promise.resolve(null)},iC.prototype.initializeRest=function(c,h){var t=this;return Xy(ZI,"Initializing. user=",c.uid),this.platform.loadConnection(this.databaseInfo).then(function(u){return ya(t,void 0,void 0,function(){var e,n,r,i,o,a,s=this;return ga(this,function(t){switch(t.label){case 0:return e=new bE,this.localStore=new NE(this.persistence,e,c),[4,this.localStore.start()];case 1:return t.sent(),h&&(this.lruScheduler=new fT(h,this.asyncQueue,this.localStore)),n=this.platform.newConnectivityMonitor(),r=this.platform.newSerializer(this.databaseInfo.databaseId),i=new oS(this.asyncQueue,u,this.credentials,r),o=function(t){return s.syncEngine.applyOnlineStateChange(t,cS.RemoteStore)},a=function(t){return s.syncEngine.applyOnlineStateChange(t,cS.SharedClientState)},this.remoteStore=new QS(this.localStore,i,this.asyncQueue,o,n),this.syncEngine=new RI(this.localStore,this.remoteStore,this.sharedClientState,c),this.sharedClientState.onlineStateHandler=a,this.remoteStore.syncEngine=this.syncEngine,this.sharedClientState.syncEngine=this.syncEngine,this.eventMgr=new yI(this.syncEngine),[4,this.sharedClientState.start()];case 2:return t.sent(),[4,this.remoteStore.start()];case 3:return t.sent(),[4,this.persistence.setPrimaryStateListener(function(e){return ya(s,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return[4,this.syncEngine.applyPrimaryState(e)];case 1:return t.sent(),this.lruScheduler&&(e&&!this.lruScheduler.started?this.lruScheduler.start():e||this.lruScheduler.stop()),[2]}})})})];case 4:return t.sent(),[4,this.persistence.setDatabaseDeletedListener(function(){return ya(s,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}})})})];case 5:return t.sent(),[2]}})})})},iC.prototype.handleCredentialChange=function(t){return this.asyncQueue.verifyOperationInProgress(),Xy(ZI,"Credential Changed. Current user: "+t.uid),this.syncEngine.handleCredentialChange(t)},iC.prototype.disableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return t.syncEngine.disableNetwork()})},iC.prototype.terminate=function(){var t=this;return this.asyncQueue.enqueueAndInitiateShutdown(function(){return ya(t,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.lruScheduler&&this.lruScheduler.stop(),[4,this.remoteStore.shutdown()];case 1:return t.sent(),[4,this.sharedClientState.shutdown()];case 2:return t.sent(),[4,this.persistence.shutdown()];case 3:return t.sent(),this.credentials.removeChangeListener(),[2]}})})})},iC.prototype.waitForPendingWrites=function(){var t=this;this.verifyNotTerminated();var e=new cv;return this.asyncQueue.enqueueAndForget(function(){return t.syncEngine.registerPendingWritesCallback(e)}),e.promise},iC.prototype.listen=function(t,e,n){var r=this;this.verifyNotTerminated();var i=new vI(t,e,n);return this.asyncQueue.enqueueAndForget(function(){return r.eventMgr.listen(i)}),i},iC.prototype.unlisten=function(t){var e=this;this.clientTerminated||this.asyncQueue.enqueueAndForget(function(){return e.eventMgr.unlisten(t)})},iC.prototype.getDocumentFromLocalCache=function(t){var e=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return e.localStore.readDocument(t)}).then(function(t){if(t instanceof Jw)return t;if(t instanceof t_)return null;throw new ag(og.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")})},iC.prototype.getDocumentsFromLocalCache=function(i){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return ya(t,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return[4,this.localStore.executeQuery(i,!0)];case 1:return e=t.sent(),n=new SI(i,e.remoteKeys),r=n.computeDocChanges(e.documents),[2,n.applyChanges(r,!1).snapshot]}})})})},iC.prototype.write=function(t){var e=this;this.verifyNotTerminated();var n=new cv;return this.asyncQueue.enqueueAndForget(function(){return e.syncEngine.write(t,n)}),n.promise},iC.prototype.databaseId=function(){return this.databaseInfo.databaseId},iC.prototype.addSnapshotsInSyncListener=function(t){var e=this;this.verifyNotTerminated(),this.asyncQueue.enqueueAndForget(function(){return e.eventMgr.addSnapshotsInSyncListener(t),Promise.resolve()})},iC.prototype.removeSnapshotsInSyncListener=function(t){this.clientTerminated||this.eventMgr.removeSnapshotsInSyncListener(t)},Object.defineProperty(iC.prototype,"clientTerminated",{get:function(){return this.asyncQueue.isShuttingDown},enumerable:!0,configurable:!0}),iC.prototype.transaction=function(t){var e=this;this.verifyNotTerminated();var n=new cv;return this.asyncQueue.enqueueAndForget(function(){return e.syncEngine.runTransaction(e.asyncQueue,t,n),Promise.resolve()}),n.promise},iC);function iC(t,e,n,r){this.platform=t,this.databaseInfo=e,this.credentials=n,this.asyncQueue=r,this.clientId=Pg.newId()}var oC=(aC.prototype.next=function(t){this.scheduleEvent(this.observer.next,t)},aC.prototype.error=function(t){this.scheduleEvent(this.observer.error,t)},aC.prototype.mute=function(){this.muted=!0},aC.prototype.scheduleEvent=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},aC);function aC(t){this.observer=t,this.muted=!1}var sC=(uC.documentId=function(){return uC._DOCUMENT_ID},uC.prototype.isEqual=function(t){if(!(t instanceof uC))throw kg("isEqual","FieldPath",1,t);return this._internalPath.isEqual(t._internalPath)},uC._DOCUMENT_ID=new uC(rv.keyField().canonicalString()),uC);function uC(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];!function(t,e,n,r){if(!(e instanceof Array)||e.length<r)throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" argument to be an array with at least "+Og(r,"element")+".")}("FieldPath",t,"fieldNames",1);for(var n=0;n<t.length;++n)if(vg("FieldPath","string",n,t[n]),0===t[n].length)throw new ag(og.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new rv(t)}var cC=new RegExp("[~\\*/\\[\\]]");var hC=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t},lC=(fC.prototype.getToken=function(){return Promise.resolve(null)},fC.prototype.invalidateToken=function(){},fC.prototype.setChangeListener=function(t){tg(!this.changeListener,"Can only call setChangeListener() once."),(this.changeListener=t)(PI.UNAUTHENTICATED)},fC.prototype.removeChangeListener=function(){tg(null!==this.changeListener,"removeChangeListener() when no listener registered"),this.changeListener=null},fC);function fC(){this.changeListener=null}var pC=(dC.prototype.getToken=function(){var e=this;tg(null!=this.tokenListener,"getToken cannot be called after listener removed.");var n=this.tokenCounter,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(function(t){if(e.tokenCounter!==n)throw new ag(og.ABORTED,"getToken aborted due to token change.");return t?(tg("string"==typeof t.accessToken,"Invalid tokenData returned from getToken():"+t),new hC(t.accessToken,e.currentUser)):null}):Promise.resolve(null)},dC.prototype.invalidateToken=function(){this.forceRefresh=!0},dC.prototype.setChangeListener=function(t){tg(!this.changeListener,"Can only call setChangeListener() once."),this.changeListener=t,this.receivedInitialUser&&t(this.currentUser)},dC.prototype.removeChangeListener=function(){tg(null!=this.tokenListener,"removeChangeListener() called twice"),tg(null!==this.changeListener,"removeChangeListener() called when no listener registered"),this.auth&&this.auth.removeAuthTokenListener(this.tokenListener),this.tokenListener=null,this.changeListener=null},dC.prototype.getUser=function(){var t=this.auth&&this.auth.getUid();return tg(null===t||"string"==typeof t,"Received invalid UID: "+t),new PI(t)},dC);function dC(t){var e=this;this.tokenListener=null,this.currentUser=PI.UNAUTHENTICATED,this.receivedInitialUser=!1,this.tokenCounter=0,this.changeListener=null,this.forceRefresh=!1,this.tokenListener=function(){e.tokenCounter++,e.currentUser=e.getUser(),e.receivedInitialUser=!0,e.changeListener&&e.changeListener(e.currentUser)},this.tokenCounter=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.tokenListener):(this.tokenListener(null),t.get().then(function(t){e.auth=t,e.tokenListener&&e.auth.addAuthTokenListener(e.tokenListener)},function(){}))}var mC=(Object.defineProperty(yC.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.sessionIndex},e=this.gapi.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),t},enumerable:!0,configurable:!0}),yC);function yC(t,e){this.gapi=t,this.sessionIndex=e,this.type="FirstParty",this.user=PI.FIRST_PARTY}var gC=(vC.prototype.getToken=function(){return Promise.resolve(new mC(this.gapi,this.sessionIndex))},vC.prototype.setChangeListener=function(t){t(PI.FIRST_PARTY)},vC.prototype.removeChangeListener=function(){},vC.prototype.invalidateToken=function(){},vC);function vC(t,e){this.gapi=t,this.sessionIndex=e}function bC(t){return function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=t,r=0,i=e;r<i.length;r++){var o=i[r];if(o in n&&"function"==typeof n[o])return!0}return!1}(t,["next","error","complete"])}var wC=(_C.delete=function(){return dg("FieldValue.delete",arguments),EC.instance},_C.serverTimestamp=function(){return dg("FieldValue.serverTimestamp",arguments),CC.instance},_C.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return yg("FieldValue.arrayUnion",arguments,1),new kC(t)},_C.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return yg("FieldValue.arrayRemove",arguments,1),new OC(t)},_C.increment=function(t){return vg("FieldValue.increment","number",1,t),mg("FieldValue.increment",arguments,1),new xC(t)},_C.prototype.isEqual=function(t){return this===t},_C);function _C(t){this._methodName=t}var TC,EC=(da(SC,TC=wC),SC.instance=new SC,SC);function SC(){return TC.call(this,"FieldValue.delete")||this}var IC,CC=(da(NC,IC=wC),NC.instance=new NC,NC);function NC(){return IC.call(this,"FieldValue.serverTimestamp")||this}var AC,kC=(da(DC,AC=wC),DC);function DC(t){var e=AC.call(this,"FieldValue.arrayUnion")||this;return e._elements=t,e}var RC,OC=(da(PC,RC=wC),PC);function PC(t){var e=RC.call(this,"FieldValue.arrayRemove")||this;return e._elements=t,e}var MC,xC=(da(LC,MC=wC),LC);function LC(t){var e=MC.call(this,"FieldValue.increment")||this;return e._operand=t,e}var FC=ug(wC,"Use FieldValue.<field>() instead."),UC=/^__.*__$/,VC=(qC.prototype.toMutations=function(t,e){var n=[];return null!==this.fieldMask?n.push(new Hb(t,this.data,this.fieldMask,e)):n.push(new Wb(t,this.data,e)),0<this.fieldTransforms.length&&n.push(new Yb(t,this.fieldTransforms)),n},qC);function qC(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}var BC,jC,WC=(KC.prototype.toMutations=function(t,e){var n=[new Hb(t,this.data,this.fieldMask,e)];return 0<this.fieldTransforms.length&&n.push(new Yb(t,this.fieldTransforms)),n},KC);function KC(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}function QC(t){switch(t){case BC.Set:case BC.MergeSet:case BC.Update:return!0;case BC.Argument:case BC.ArrayArgument:return!1;default:throw Zy("Unexpected case for UserDataSource: "+t)}}(jC=BC=BC||{})[jC.Set=0]="Set",jC[jC.Update=1]="Update",jC[jC.MergeSet=2]="MergeSet",jC[jC.Argument=3]="Argument",jC[jC.ArrayArgument=4]="ArrayArgument";var HC=(GC.prototype.childContextForField=function(t){var e=null==this.path?null:this.path.child(t),n=new GC(this.dataSource,this.methodName,e,!1,this.fieldTransforms,this.fieldMask);return n.validatePathSegment(t),n},GC.prototype.childContextForFieldPath=function(t){var e=null==this.path?null:this.path.child(t),n=new GC(this.dataSource,this.methodName,e,!1,this.fieldTransforms,this.fieldMask);return n.validatePath(),n},GC.prototype.childContextForArray=function(t){return new GC(this.dataSource,this.methodName,null,!0,this.fieldTransforms,this.fieldMask)},GC.prototype.createError=function(t){var e=null===this.path||this.path.isEmpty()?"":" (found in field "+this.path.toString()+")";return new ag(og.INVALID_ARGUMENT,"Function "+this.methodName+"() called with invalid data. "+t+e)},GC.prototype.contains=function(e){return void 0!==this.fieldMask.find(function(t){return e.isPrefixOf(t)})||void 0!==this.fieldTransforms.find(function(t){return e.isPrefixOf(t.field)})},GC.prototype.validatePath=function(){if(null!==this.path)for(var t=0;t<this.path.length;t++)this.validatePathSegment(this.path.get(t))},GC.prototype.validatePathSegment=function(t){if(0===t.length)throw this.createError("Document fields must not be empty");if(QC(this.dataSource)&&UC.test(t))throw this.createError('Document fields cannot begin and end with "__"')},GC);function GC(t,e,n,r,i,o){this.dataSource=t,this.methodName=e,this.path=n,this.arrayElement=r,void 0===i&&this.validatePath(),this.arrayElement=void 0!==r&&r,this.fieldTransforms=i||[],this.fieldMask=o||[]}var zC=function(t,e){this.databaseId=t,this.key=e},YC=(XC.prototype.parseSetData=function(t,e){var n=new HC(BC.Set,t,rv.EMPTY_PATH);$C("Data must be an object, but it was:",n,e);var r=this.parseData(e,n);return new VC(r,null,n.fieldTransforms)},XC.prototype.parseMergeData=function(t,e,n){var r=new HC(BC.MergeSet,t,rv.EMPTY_PATH);$C("Data must be an object, but it was:",r,e);var i,o,a=this.parseData(e,r);if(n){for(var s=new Mv(rv.comparator),u=0,c=n;u<c.length;u++){var h=c[u],l=void 0;if(h instanceof sC)l=h._internalPath;else{if("string"!=typeof h)throw Zy("Expected stringOrFieldPath to be a string or a FieldPath");l=tN(t,h)}if(!r.contains(l))throw new ag(og.INVALID_ARGUMENT,"Field '"+l+"' is specified in your field mask but missing from your input data.");s=s.add(l)}i=Rb.fromSet(s),o=r.fieldTransforms.filter(function(t){return i.covers(t.field)})}else i=Rb.fromArray(r.fieldMask),o=r.fieldTransforms;return new VC(a,i,o)},XC.prototype.parseUpdateData=function(o,t){var a=this,s=new HC(BC.Update,o,rv.EMPTY_PATH);$C("Data must be an object, but it was:",s,t);var u=new Mv(rv.comparator),c=Ww.EMPTY;fg(t,function(t,e){var n=tN(o,t),r=s.childContextForFieldPath(n);if((e=a.runPreConverter(e,r))instanceof EC)u=u.add(n);else{var i=a.parseData(e,r);null!=i&&(u=u.add(n),c=c.set(n,i))}});var e=Rb.fromSet(u);return new WC(c,e,s.fieldTransforms)},XC.prototype.parseUpdateVarargs=function(t,e,n,r){var i=new HC(BC.Update,t,rv.EMPTY_PATH),o=[ZC(t,e)],a=[n];if(r.length%2!=0)throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var s=0;s<r.length;s+=2)o.push(ZC(t,r[s])),a.push(r[s+1]);var u=new Mv(rv.comparator),c=Ww.EMPTY;for(s=0;s<o.length;++s){var h=o[s],l=i.childContextForFieldPath(h),f=this.runPreConverter(a[s],l);if(f instanceof EC)u=u.add(h);else{var p=this.parseData(f,l);null!=p&&(u=u.add(h),c=c.set(h,p))}}var d=Rb.fromSet(u);return new WC(c,d,i.fieldTransforms)},XC.prototype.parseQueryValue=function(t,e,n){void 0===n&&(n=!1);var r=new HC(n?BC.ArrayArgument:BC.Argument,t,rv.EMPTY_PATH),i=this.parseData(e,r);return tg(null!=i,"Parsed data should not be null."),tg(0===r.fieldTransforms.length,"Field transforms should have been disallowed."),i},XC.prototype.runPreConverter=function(t,e){try{return this.preConverter(t)}catch(t){var n=eN(t);throw e.createError(n)}},XC.prototype.parseData=function(t,e){if(JC(t=this.runPreConverter(t,e)))return $C("Unsupported field value:",e,t),this.parseObject(t,e);if(t instanceof wC)return this.parseSentinelFieldValue(t,e),null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.arrayElement&&e.dataSource!==BC.ArrayArgument)throw e.createError("Nested arrays are not supported");return this.parseArray(t,e)}return this.parseScalarValue(t,e)},XC.prototype.parseObject=function(t,r){var i=this,o=new Cv(xg);return pg(t)?r.path&&0<r.path.length&&r.fieldMask.push(r.path):fg(t,function(t,e){var n=i.parseData(e,r.childContextForField(t));null!=n&&(o=o.insert(t,n))}),new Ww(o)},XC.prototype.parseArray=function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var a=o[i],s=this.parseData(a,e.childContextForArray(r));null==s&&(s=cw.INSTANCE),n.push(s),r++}return new Hw(n)},XC.prototype.parseSentinelFieldValue=function(t,e){if(!QC(e.dataSource))throw e.createError(t._methodName+"() can only be used with update() and set()");if(null===e.path)throw e.createError(t._methodName+"() is not currently supported inside arrays");if(t instanceof EC){if(e.dataSource!==BC.MergeSet)throw e.dataSource===BC.Update?(tg(0<e.path.length,"FieldValue.delete() at the top level should have already been handled."),e.createError("FieldValue.delete() can only appear at the top level of your update data")):e.createError("FieldValue.delete() cannot be used with set() unless you pass {merge:true}");e.fieldMask.push(e.path)}else if(t instanceof CC)e.fieldTransforms.push(new Pb(e.path,YS.instance));else if(t instanceof kC){var n=this.parseArrayTransformElements(t._methodName,t._elements),r=new JS(n);e.fieldTransforms.push(new Pb(e.path,r))}else if(t instanceof OC){n=this.parseArrayTransformElements(t._methodName,t._elements);var i=new ZS(n);e.fieldTransforms.push(new Pb(e.path,i))}else if(t instanceof xC){var o=this.parseQueryValue("FieldValue.increment",t._operand),a=new eI(o);e.fieldTransforms.push(new Pb(e.path,a))}else Zy("Unknown FieldValue type: "+t)},XC.prototype.parseScalarValue=function(t,e){if(null===t)return cw.INSTANCE;if("number"==typeof t)return FT(t)?new bw(t):new Tw(t);if("boolean"==typeof t)return fw.of(t);if("string"==typeof t)return new Iw(t);if(t instanceof Date)return new Aw(Tv.fromDate(t));if(t instanceof Tv)return new Aw(new Tv(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)));if(t instanceof GS)return new qw(t);if(t instanceof qg)return new Mw(t);if(t instanceof zC)return new Fw(t.databaseId,t.key);throw e.createError("Unsupported field value: "+Cg(t))},XC.prototype.parseArrayTransformElements=function(r,t){var i=this;return t.map(function(t,e){var n=new HC(BC.Argument,r,rv.EMPTY_PATH);return i.parseData(t,n.childContextForArray(e))})},XC);function XC(t){this.preConverter=t}function JC(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof Tv||t instanceof GS||t instanceof qg||t instanceof zC||t instanceof wC)}function $C(t,e,n){if(!JC(n)||!Ig(n)){var r=Cg(n);throw"an object"===r?e.createError(t+" a custom object"):e.createError(t+" "+r)}}function ZC(t,e){if(e instanceof sC)return e._internalPath;if("string"==typeof e)return tN(t,e);throw new ag(og.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function tN(e,t){try{return function(e){if(0<=e.search(cC))throw new ag(og.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(sC.bind.apply(sC,_a([void 0],e.split("."))))}catch(t){throw new ag(og.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(t)._internalPath}catch(t){var n=eN(t);throw new ag(og.INVALID_ARGUMENT,"Function "+e+"() called with invalid data. "+n)}}function eN(t){return t instanceof Error?t.message:t.toString()}var nN=hT.COLLECTION_DISABLED,rN=(iN.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.timestampsInSnapshots===t.timestampsInSnapshots&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.forceLongPolling===t.forceLongPolling},iN);function iN(t){if(void 0===t.host){if(void 0!==t.ssl)throw new ag(og.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else wg("settings","non-empty string","host",t.host),this.host=t.host,_g("settings","boolean","ssl",t.ssl),this.ssl=hg(t.ssl,!0);if(Ag("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),_g("settings","object","credentials",t.credentials),this.credentials=t.credentials,_g("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?Jy("\n  The timestampsInSnapshots setting now defaults to true and you no\n  longer need to explicitly set it. In a future release, the setting\n  will be removed entirely and so it is recommended that you remove it\n  from your firestore.settings() call now."):!1===t.timestampsInSnapshots&&Jy("\n  The timestampsInSnapshots setting will soon be removed. YOU MUST UPDATE\n  YOUR CODE.\n\n  To hide this warning, stop using the timestampsInSnapshots setting in your\n  firestore.settings({ ... }) call.\n\n  Once you remove the setting, Timestamps stored in Cloud Firestore will be\n  read back as Firebase Timestamp objects instead of as system Date objects.\n  So you will also need to update code expecting a Date to instead expect a\n  Timestamp. For example:\n\n  // Old:\n  const date = snapshot.get('created_at');\n  // New:\n  const timestamp = snapshot.get('created_at'); const date =\n  timestamp.toDate();\n\n  Please audit all existing usages of Date when you enable the new\n  behavior."),this.timestampsInSnapshots=hg(t.timestampsInSnapshots,!0),_g("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=hT.DEFAULT_CACHE_SIZE_BYTES;else{if(t.cacheSizeBytes!==nN&&t.cacheSizeBytes<hT.MINIMUM_CACHE_SIZE_BYTES)throw new ag(og.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+hT.MINIMUM_CACHE_SIZE_BYTES);this.cacheSizeBytes=t.cacheSizeBytes}_g("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0!==t.experimentalForceLongPolling&&t.experimentalForceLongPolling}var oN=(aN.prototype.settings=function(t){if(mg("Firestore.settings",arguments,1),vg("Firestore.settings","object",1,t),cg(t,"persistence"))throw new ag(og.INVALID_ARGUMENT,'"persistence" is now specified with a separate call to firestore.enablePersistence().');var e=new rN(t);if(this._firestoreClient&&!this._settings.isEqual(e))throw new ag(og.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only call settings() before calling any other methods on a Firestore object.");void 0!==(this._settings=e).credentials&&(this._credentials=function(t){if(!t)return new lC;switch(t.type){case"gapi":var e=t.client;return tg(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty),"unexpected gapi interface"),new gC(e,t.sessionIndex||"0");case"provider":return t.client;default:throw new ag(og.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},aN.prototype.enableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.enableNetwork()},aN.prototype.disableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.disableNetwork()},aN.prototype.enablePersistence=function(t){if(this._firestoreClient)throw new ag(og.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only call enablePersistence() before calling any other methods on a Firestore object.");var e=!1;return t&&(void 0!==t.experimentalTabSynchronization&&Jy("The 'experimentalTabSynchronization' setting has been renamed to 'synchronizeTabs'. In a future release, the setting will be removed and it is recommended that you update your firestore.enablePersistence() call to use 'synchronizeTabs'."),e=hg(void 0!==t.synchronizeTabs?t.synchronizeTabs:t.experimentalTabSynchronization,!1)),this.configureClient(new tC(this._settings.cacheSizeBytes,e))},aN.prototype.clearPersistence=function(){var t=this,n=ST.buildStoragePrefix(this.makeDatabaseInfo()),r=new cv;return this._queue.enqueueAndForgetEvenAfterShutdown(function(){return ya(t,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:if(t.trys.push([0,2,,3]),void 0!==this._firestoreClient&&!this._firestoreClient.clientTerminated)throw new ag(og.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return[4,ST.clearPersistence(n)];case 1:return t.sent(),r.resolve(),[3,3];case 2:return e=t.sent(),r.reject(e),[3,3];case 3:return[2]}})})}),r.promise},aN.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(aN.prototype,"_isTerminated",{get:function(){return this.ensureClientConfigured(),this._firestoreClient.clientTerminated},enumerable:!0,configurable:!0}),aN.prototype.waitForPendingWrites=function(){return this.ensureClientConfigured(),this._firestoreClient.waitForPendingWrites()},aN.prototype.onSnapshotsInSync=function(t){if(this.ensureClientConfigured(),bC(t))return this.onSnapshotsInSyncInternal(t);vg("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.onSnapshotsInSyncInternal(e)},aN.prototype.onSnapshotsInSyncInternal=function(t){var e=this,n=new oC({next:function(){t.next&&t.next()},error:function(t){throw Zy("Uncaught Error in onSnapshotsInSync")}});return this._firestoreClient.addSnapshotsInSyncListener(n),function(){n.mute(),e._firestoreClient.removeSnapshotsInSyncListener(n)}},aN.prototype.ensureClientConfigured=function(){return this._firestoreClient||this.configureClient(new nC),this._firestoreClient},aN.prototype.makeDatabaseInfo=function(){return new Wg(this._databaseId,this._persistenceKey,this._settings.host,this._settings.ssl,this._settings.forceLongPolling)},aN.prototype.configureClient=function(t){tg(!!this._settings.host,"FirestoreSettings.host is not set"),tg(!this._firestoreClient,"configureClient() called multiple times");var e=this.makeDatabaseInfo();return this._firestoreClient=new rC(eg.getPlatform(),e,this._credentials,this._queue),this._firestoreClient.start(t)},aN.prototype.createDataConverter=function(r){return new YC(function(t){if(t instanceof lN){var e=r,n=t.firestore._databaseId;if(!n.isEqual(e))throw new ag(og.INVALID_ARGUMENT,"Document reference is for database "+n.projectId+"/"+n.database+" but should be for database "+e.projectId+"/"+e.database);return new zC(r,t._key)}return t})},aN.databaseIdFromApp=function(t){var e=t.options;if(!cg(e,"projectId"))throw new ag(og.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var n=e.projectId;if(!n||"string"!=typeof n)throw new ag(og.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new Qg(n)},Object.defineProperty(aN.prototype,"app",{get:function(){if(!this._firebaseApp)throw new ag(og.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._firebaseApp},enumerable:!0,configurable:!0}),aN.prototype.collection=function(t){return mg("Firestore.collection",arguments,1),vg("Firestore.collection","non-empty string",1,t),this.ensureClientConfigured(),new IN(Zg.fromString(t),this)},aN.prototype.doc=function(t){return mg("Firestore.doc",arguments,1),vg("Firestore.doc","non-empty string",1,t),this.ensureClientConfigured(),lN.forPath(Zg.fromString(t),this)},aN.prototype.collectionGroup=function(t){if(mg("Firestore.collectionGroup",arguments,1),vg("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new ag(og.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.ensureClientConfigured(),new wN(new jT(Zg.EMPTY_PATH,t),this)},aN.prototype.runTransaction=function(e){var n=this;return mg("Firestore.runTransaction",arguments,1),vg("Firestore.runTransaction","function",1,e),this.ensureClientConfigured().transaction(function(t){return e(new sN(n,t))})},aN.prototype.batch=function(){return this.ensureClientConfigured(),new cN(this)},Object.defineProperty(aN,"logLevel",{get:function(){switch(zy()){case Uy.DEBUG:return"debug";case Uy.ERROR:return"error";case Uy.SILENT:return"silent";default:return Zy("Unknown log level: "+zy())}},enumerable:!0,configurable:!0}),aN.setLogLevel=function(t){switch(mg("Firestore.setLogLevel",arguments,1),vg("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":Yy(Uy.DEBUG);break;case"error":Yy(Uy.ERROR);break;case"silent":Yy(Uy.SILENT);break;default:throw new ag(og.INVALID_ARGUMENT,"Invalid log level: "+t)}},aN.prototype._areTimestampsInSnapshotsEnabled=function(){return this._settings.timestampsInSnapshots},aN);function aN(t,e){var n=this;if(this._firebaseApp=null,this._queue=new fv,this.INTERNAL={delete:function(){return ya(n,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.ensureClientConfigured(),[4,this._firestoreClient.terminate()];case 1:return t.sent(),[2]}})})}},"object"==typeof t.options){var r=t;this._firebaseApp=r,this._databaseId=aN.databaseIdFromApp(r),this._persistenceKey=r.name,this._credentials=new pC(e)}else{var i=t;if(!i.projectId)throw new ag(og.INVALID_ARGUMENT,"Must provide projectId");this._databaseId=new Qg(i.projectId,i.database),this._persistenceKey="[DEFAULT]",this._credentials=new lC}this._settings=new rN({}),this._dataConverter=this.createDataConverter(this._databaseId)}var sN=(uN.prototype.get=function(t){var n=this;mg("Transaction.get",arguments,1);var r=DN("Transaction.get",t,this._firestore);return this._transaction.lookup([r._key]).then(function(t){if(!t||1!==t.length)return Zy("Mismatch in docs returned from document lookup.");var e=t[0];if(e instanceof t_)return new mN(n._firestore,r._key,null,!1,!1,r._converter);if(e instanceof Jw)return new mN(n._firestore,r._key,e,!1,!1,r._converter);throw Zy("BatchGetDocumentsRequest returned unexpected document type: "+e.constructor.name)})},uN.prototype.set=function(t,e,n){gg("Transaction.set",arguments,2,3);var r=DN("Transaction.set",t,this._firestore);n=NN("Transaction.set",n);var i=RN(r._converter,e,"Transaction.set"),o=i[0],a=i[1],s=n.merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(a,o,n.mergeFields):this._firestore._dataConverter.parseSetData(a,o);return this._transaction.set(r._key,s),this},uN.prototype.update=function(t,e,n){for(var r,i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return i="string"==typeof e||e instanceof sC?(yg("Transaction.update",arguments,3),r=DN("Transaction.update",t,this._firestore),this._firestore._dataConverter.parseUpdateVarargs("Transaction.update",e,n,o)):(mg("Transaction.update",arguments,2),r=DN("Transaction.update",t,this._firestore),this._firestore._dataConverter.parseUpdateData("Transaction.update",e)),this._transaction.update(r._key,i),this},uN.prototype.delete=function(t){mg("Transaction.delete",arguments,1);var e=DN("Transaction.delete",t,this._firestore);return this._transaction.delete(e._key),this},uN);function uN(t,e){this._firestore=t,this._transaction=e}var cN=(hN.prototype.set=function(t,e,n){gg("WriteBatch.set",arguments,2,3),this.verifyNotCommitted();var r=DN("WriteBatch.set",t,this._firestore);n=NN("WriteBatch.set",n);var i=RN(r._converter,e,"WriteBatch.set"),o=i[0],a=i[1],s=n.merge||n.mergeFields?this._firestore._dataConverter.parseMergeData(a,o,n.mergeFields):this._firestore._dataConverter.parseSetData(a,o);return this._mutations=this._mutations.concat(s.toMutations(r._key,Ub.NONE)),this},hN.prototype.update=function(t,e,n){for(var r,i,o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return this.verifyNotCommitted(),i="string"==typeof e||e instanceof sC?(yg("WriteBatch.update",arguments,3),r=DN("WriteBatch.update",t,this._firestore),this._firestore._dataConverter.parseUpdateVarargs("WriteBatch.update",e,n,o)):(mg("WriteBatch.update",arguments,2),r=DN("WriteBatch.update",t,this._firestore),this._firestore._dataConverter.parseUpdateData("WriteBatch.update",e)),this._mutations=this._mutations.concat(i.toMutations(r._key,Ub.exists(!0))),this},hN.prototype.delete=function(t){mg("WriteBatch.delete",arguments,1),this.verifyNotCommitted();var e=DN("WriteBatch.delete",t,this._firestore);return this._mutations=this._mutations.concat(new nw(e._key,Ub.NONE)),this},hN.prototype.commit=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return this.verifyNotCommitted(),this._committed=!0,0<this._mutations.length?[2,this._firestore.ensureClientConfigured().write(this._mutations)]:[2]})})},hN.prototype.verifyNotCommitted=function(){if(this._committed)throw new ag(og.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},hN);function hN(t){this._firestore=t,this._mutations=[],this._committed=!1}var lN=(fN.forPath=function(t,e,n){if(t.length%2!=0)throw new ag(og.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.canonicalString()+" has "+t.length);return new fN(new ov(t),e,n)},Object.defineProperty(fN.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(fN.prototype,"parent",{get:function(){return new IN(this._key.path.popLast(),this.firestore,this._converter)},enumerable:!0,configurable:!0}),Object.defineProperty(fN.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!0,configurable:!0}),fN.prototype.collection=function(t){if(mg("DocumentReference.collection",arguments,1),vg("DocumentReference.collection","non-empty string",1,t),!t)throw new ag(og.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=Zg.fromString(t);return new IN(this._key.path.child(e),this.firestore)},fN.prototype.isEqual=function(t){if(!(t instanceof fN))throw kg("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this._key.isEqual(t._key)&&this._converter===t._converter},fN.prototype.set=function(t,e){gg("DocumentReference.set",arguments,1,2),e=NN("DocumentReference.set",e);var n=RN(this._converter,t,"DocumentReference.set"),r=n[0],i=n[1],o=e.merge||e.mergeFields?this.firestore._dataConverter.parseMergeData(i,r,e.mergeFields):this.firestore._dataConverter.parseSetData(i,r);return this._firestoreClient.write(o.toMutations(this._key,Ub.NONE))},fN.prototype.update=function(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return n="string"==typeof t||t instanceof sC?(yg("DocumentReference.update",arguments,2),this.firestore._dataConverter.parseUpdateVarargs("DocumentReference.update",t,e,r)):(mg("DocumentReference.update",arguments,1),this.firestore._dataConverter.parseUpdateData("DocumentReference.update",t)),this._firestoreClient.write(n.toMutations(this._key,Ub.exists(!0)))},fN.prototype.delete=function(){return mg("DocumentReference.delete",arguments,0),this._firestoreClient.write([new nw(this._key,Ub.NONE)])},fN.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];gg("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||bC(t[i])||(Ag("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),_g("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return n=bC(t[i])?t[i]:(vg("DocumentReference.onSnapshot","function",i,t[i]),bg("DocumentReference.onSnapshot","function",i+1,t[i+1]),bg("DocumentReference.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.onSnapshotInternal(o,n)},fN.prototype.onSnapshotInternal=function(t,n){var r=this,e=function(t){console.error("Uncaught Error in onSnapshot:",t)};n.error&&(e=n.error.bind(n));var i=new oC({next:function(t){if(n.next){tg(t.docs.size<=1,"Too many documents returned on a document query");var e=t.docs.get(r._key);n.next(new mN(r.firestore,r._key,e,t.fromCache,t.hasPendingWrites,r._converter))}},error:e}),o=this._firestoreClient.listen(jT.atPath(this._key.path),i,t);return function(){i.mute(),r._firestoreClient.unlisten(o)}},fN.prototype.get=function(n){var r=this;return gg("DocumentReference.get",arguments,0,1),kN("DocumentReference.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.ensureClientConfigured().getDocumentFromLocalCache(r._key).then(function(t){e(new mN(r.firestore,r._key,t,!0,t instanceof Jw&&t.hasLocalMutations,r._converter))},t):r.getViaSnapshotListener(e,t,n)})},fN.prototype.getViaSnapshotListener=function(e,n,r){var i=this.onSnapshotInternal({includeMetadataChanges:!0,waitForSyncWhenOnline:!0},{next:function(t){i(),!t.exists&&t.metadata.fromCache?n(new ag(og.UNAVAILABLE,"Failed to get document because the client is offline.")):t.exists&&t.metadata.fromCache&&r&&"server"===r.source?n(new ag(og.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.)')):e(t)},error:n})},fN.prototype.withConverter=function(t){return new fN(this._key,this.firestore,t)},fN);function fN(t,e,n){this._key=t,this.firestore=e,this._converter=n,this._firestoreClient=this.firestore.ensureClientConfigured()}var pN=(dN.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},dN);function dN(t,e){this.hasPendingWrites=t,this.fromCache=e}var mN=(yN.prototype.data=function(t){if(gg("DocumentSnapshot.data",arguments,0,1),t=AN("DocumentSnapshot.data",t),this._document){if(this._converter){var e=new vN(this._firestore,this._key,this._document,this._fromCache,this._hasPendingWrites);return this._converter.fromFirestore(e,t)}return this.toJSObject(this._document.data(),iw.fromSnapshotOptions(t,this._firestore._areTimestampsInSnapshotsEnabled()))}},yN.prototype.get=function(t,e){if(gg("DocumentSnapshot.get",arguments,1,2),e=AN("DocumentSnapshot.get",e),this._document){var n=this._document.data().field(ZC("DocumentSnapshot.get",t));if(null!==n)return this.toJSValue(n,iw.fromSnapshotOptions(e,this._firestore._areTimestampsInSnapshotsEnabled()))}},Object.defineProperty(yN.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(yN.prototype,"ref",{get:function(){return new lN(this._key,this._firestore,this._converter)},enumerable:!0,configurable:!0}),Object.defineProperty(yN.prototype,"exists",{get:function(){return null!==this._document},enumerable:!0,configurable:!0}),Object.defineProperty(yN.prototype,"metadata",{get:function(){return new pN(this._hasPendingWrites,this._fromCache)},enumerable:!0,configurable:!0}),yN.prototype.isEqual=function(t){if(!(t instanceof yN))throw kg("isEqual","DocumentSnapshot",1,t);return this._firestore===t._firestore&&this._fromCache===t._fromCache&&this._key.isEqual(t._key)&&(null===this._document?null===t._document:this._document.isEqual(t._document))&&this._converter===t._converter},yN.prototype.toJSObject=function(t,n){var r=this,i={};return t.forEach(function(t,e){i[t]=r.toJSValue(e,n)}),i},yN.prototype.toJSValue=function(t,e){if(t instanceof Ww)return this.toJSObject(t,e);if(t instanceof Hw)return this.toJSArray(t,e);if(t instanceof Fw){var n=t.value(e),r=this._firestore.ensureClientConfigured().databaseId();return t.databaseId.isEqual(r)||Jy("Document "+this._key.path+" contains a document reference within a different database ("+t.databaseId.projectId+"/"+t.databaseId.database+") which is not supported. It will be treated as a reference in the current database ("+r.projectId+"/"+r.database+") instead."),new lN(n,this._firestore,this._converter)}return t.value(e)},yN.prototype.toJSArray=function(t,e){var n=this;return t.internalValue.map(function(t){return n.toJSValue(t,e)})},yN);function yN(t,e,n,r,i,o){this._firestore=t,this._key=e,this._document=n,this._fromCache=r,this._hasPendingWrites=i,this._converter=o}var gN,vN=(da(bN,gN=mN),bN.prototype.data=function(t){var e=gN.prototype.data.call(this,t);return tg(void 0!==e,"Document in a QueryDocumentSnapshot should exist"),e},bN);function bN(){return null!==gN&&gN.apply(this,arguments)||this}var wN=(_N.prototype.where=function(t,e,n){var r;mg("Query.where",arguments,3),Ng("Query.where",3,n),function(t,e,n,r){if(!e.some(function(t){return t===r}))throw new ag(og.INVALID_ARGUMENT,"Invalid value "+Cg(r)+" provided to function "+t+"() for its "+Rg(n)+" argument. Acceptable values: "+e.join(", "))}("Query.where",["<","<=","==",">=",">","array-contains","in","array-contains-any"],2,e);var i=ZC("Query.where",t),o=QT.fromString(e);if(i.isKeyField()){if(o===QT.ARRAY_CONTAINS||o===QT.ARRAY_CONTAINS_ANY)throw new ag(og.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o.toString()+"' queries on FieldPath.documentId().");if(o===QT.IN){this.validateDisjunctiveFilterElements(n,o);for(var a=[],s=0,u=n;s<u.length;s++){var c=u[s];a.push(this.parseDocumentIdValue(c))}r=new Hw(a)}else r=this.parseDocumentIdValue(n)}else o!==QT.IN&&o!==QT.ARRAY_CONTAINS_ANY||this.validateDisjunctiveFilterElements(n,o),r=this.firestore._dataConverter.parseQueryValue("Query.where",n,o===QT.IN);var h=zT.create(i,o,r);return this.validateNewFilter(h),new _N(this._query.addFilter(h),this.firestore,this._converter)},_N.prototype.orderBy=function(t,e){var n;if(gg("Query.orderBy",arguments,1,2),bg("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n=lE.ASCENDING;else{if("desc"!==e)throw new ag(og.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n=lE.DESCENDING}if(null!==this._query.startAt)throw new ag(og.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this._query.endAt)throw new ag(og.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=ZC("Query.orderBy",t),i=new mE(r,n);return this.validateNewOrderBy(i),new _N(this._query.addOrderBy(i),this.firestore,this._converter)},_N.prototype.limit=function(t){return mg("Query.limit",arguments,1),vg("Query.limit","number",1,t),Dg("Query.limit",1,t),new _N(this._query.withLimitToFirst(t),this.firestore,this._converter)},_N.prototype.limitToLast=function(t){return mg("Query.limitToLast",arguments,1),vg("Query.limitToLast","number",1,t),Dg("Query.limitToLast",1,t),new _N(this._query.withLimitToLast(t),this.firestore,this._converter)},_N.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];yg("Query.startAt",arguments,1);var r=this.boundFromDocOrFields("Query.startAt",t,e,!0);return new _N(this._query.withStartAt(r),this.firestore,this._converter)},_N.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];yg("Query.startAfter",arguments,1);var r=this.boundFromDocOrFields("Query.startAfter",t,e,!1);return new _N(this._query.withStartAt(r),this.firestore,this._converter)},_N.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];yg("Query.endBefore",arguments,1);var r=this.boundFromDocOrFields("Query.endBefore",t,e,!0);return new _N(this._query.withEndAt(r),this.firestore,this._converter)},_N.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];yg("Query.endAt",arguments,1);var r=this.boundFromDocOrFields("Query.endAt",t,e,!1);return new _N(this._query.withEndAt(r),this.firestore,this._converter)},_N.prototype.isEqual=function(t){if(!(t instanceof _N))throw kg("isEqual","Query",1,t);return this.firestore===t.firestore&&this._query.isEqual(t._query)},_N.prototype.withConverter=function(t){return new _N(this._query,this.firestore,t)},_N.prototype.boundFromDocOrFields=function(t,e,n,r){if(Ng(t,1,e),e instanceof mN){if(0<n.length)throw new ag(og.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new ag(og.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+t+"().");return this.boundFromDocument(t,i._document,r)}var o=[e].concat(n);return this.boundFromFields(t,o,r)},_N.prototype.boundFromDocument=function(t,e,n){for(var r=[],i=0,o=this._query.orderBy;i<o.length;i++){var a=o[i];if(a.field.isKeyField())r.push(new Fw(this.firestore._databaseId,e.key));else{var s=e.field(a.field);if(s instanceof Rw)throw new ag(og.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+a.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===s){var u=a.field.canonicalString();throw new ag(og.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+u+"' (used as the orderBy) does not exist.")}r.push(s)}}return new pE(r,n)},_N.prototype.boundFromFields=function(t,e,n){var r=this._query.explicitOrderBy;if(e.length>r.length)throw new ag(og.INVALID_ARGUMENT,"Too many arguments provided to "+t+"(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses");for(var i=[],o=0;o<e.length;o++){var a=e[o];if(r[o].field.isKeyField()){if("string"!=typeof a)throw new ag(og.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+t+"(), but got a "+typeof a);if(!this._query.isCollectionGroupQuery()&&-1!==a.indexOf("/"))throw new ag(og.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+t+"() must be a plain document ID, but '"+a+"' contains a slash.");var s=this._query.path.child(Zg.fromString(a));if(!ov.isDocumentKey(s))throw new ag(og.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+t+"() must result in a valid document path, but '"+s+"' is not because it contains an odd number of segments.");var u=new ov(s);i.push(new Fw(this.firestore._databaseId,u))}else{var c=this.firestore._dataConverter.parseQueryValue(t,a);i.push(c)}}return new pE(i,n)},_N.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];gg("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||bC(t[i])||(Ag("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),_g("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),n=bC(t[i])?t[i]:(vg("Query.onSnapshot","function",i,t[i]),bg("Query.onSnapshot","function",i+1,t[i+1]),bg("Query.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.validateHasExplicitOrderByForLimitToLast(this._query),this.onSnapshotInternal(r,n)},_N.prototype.onSnapshotInternal=function(t,e){var n=this,r=function(t){console.error("Uncaught Error in onSnapshot:",t)};e.error&&(r=e.error.bind(e));var i=new oC({next:function(t){e.next&&e.next(new TN(n.firestore,n._query,t,n._converter))},error:r}),o=this.firestore.ensureClientConfigured(),a=o.listen(this._query,i,t);return function(){i.mute(),o.unlisten(a)}},_N.prototype.validateHasExplicitOrderByForLimitToLast=function(t){if(t.hasLimitToLast()&&0===t.explicitOrderBy.length)throw new ag(og.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},_N.prototype.get=function(n){var r=this;return gg("Query.get",arguments,0,1),kN("Query.get",n),this.validateHasExplicitOrderByForLimitToLast(this._query),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.ensureClientConfigured().getDocumentsFromLocalCache(r._query).then(function(t){e(new TN(r.firestore,r._query,t,r._converter))},t):r.getViaSnapshotListener(e,t,n)})},_N.prototype.getViaSnapshotListener=function(e,n,r){var i=this.onSnapshotInternal({includeMetadataChanges:!0,waitForSyncWhenOnline:!0},{next:function(t){i(),t.metadata.fromCache&&r&&"server"===r.source?n(new ag(og.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.)')):e(t)},error:n})},_N.prototype.parseDocumentIdValue=function(t){if("string"==typeof t){if(""===t)throw new ag(og.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!this._query.isCollectionGroupQuery()&&-1!==t.indexOf("/"))throw new ag(og.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+t+"' contains a '/' character.");var e=this._query.path.child(Zg.fromString(t));if(!ov.isDocumentKey(e))throw new ag(og.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+e+"' is not because it has an odd number of segments ("+e.length+").");return new Fw(this.firestore._databaseId,new ov(e))}if(t instanceof lN){var n=t;return new Fw(this.firestore._databaseId,n._key)}throw new ag(og.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Cg(t)+".")},_N.prototype.validateDisjunctiveFilterElements=function(t,e){if(!Array.isArray(t)||0===t.length)throw new ag(og.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new ag(og.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(0<=t.indexOf(null))throw new ag(og.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'null' in the value array.");if(0<t.filter(function(t){return Number.isNaN(t)}).length)throw new ag(og.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},_N.prototype.validateNewFilter=function(t){if(t instanceof zT){var e=[QT.ARRAY_CONTAINS,QT.ARRAY_CONTAINS_ANY],n=[QT.IN,QT.ARRAY_CONTAINS_ANY],r=0<=e.indexOf(t.op),i=0<=n.indexOf(t.op);if(t.isInequality()){var o=this._query.getInequalityFilterField();if(null!==o&&!o.isEqual(t.field))throw new ag(og.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '"+o.toString()+"' and '"+t.field.toString()+"'");var a=this._query.getFirstOrderByField();null!==a&&this.validateOrderByAndInequalityMatch(t.field,a)}else if(i||r){var s=null;if(i&&(s=this._query.findFilterOperator(n)),null===s&&r&&(s=this._query.findFilterOperator(e)),null!=s)throw s===t.op?new ag(og.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new ag(og.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+s.toString()+"' filters.")}}},_N.prototype.validateNewOrderBy=function(t){if(null===this._query.getFirstOrderByField()){var e=this._query.getInequalityFilterField();null!==e&&this.validateOrderByAndInequalityMatch(e,t.field)}},_N.prototype.validateOrderByAndInequalityMatch=function(t,e){if(!e.isEqual(t))throw new ag(og.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '"+t.toString()+"' and so you must also use '"+t.toString()+"' as your first Query.orderBy(), but your first Query.orderBy() is on field '"+e.toString()+"' instead.")},_N);function _N(t,e,n){this._query=t,this.firestore=e,this._converter=n}var TN=(Object.defineProperty(EN.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(EN.prototype,"empty",{get:function(){return this._snapshot.docs.isEmpty()},enumerable:!0,configurable:!0}),Object.defineProperty(EN.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!0,configurable:!0}),EN.prototype.forEach=function(e,n){var r=this;gg("QuerySnapshot.forEach",arguments,1,2),vg("QuerySnapshot.forEach","function",1,e),this._snapshot.docs.forEach(function(t){e.call(n,r.convertToDocumentImpl(t))})},Object.defineProperty(EN.prototype,"query",{get:function(){return new wN(this._originalQuery,this._firestore,this._converter)},enumerable:!0,configurable:!0}),EN.prototype.docChanges=function(t){t&&(Ag("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),_g("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this._snapshot.excludesMetadataChanges)throw new ag(og.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(i,e,o,a){if(o.oldDocs.isEmpty()){var n,r=0;return o.docChanges.map(function(t){var e=new vN(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key),a);return tg(t.type===bS.Added,"Invalid event type for first snapshot"),tg(!n||o.query.docComparator(n,t.doc)<0,"Got added events in wrong order"),n=t.doc,{type:"added",doc:e,oldIndex:-1,newIndex:r++}})}var s=o.oldDocs;return o.docChanges.filter(function(t){return e||t.type!==bS.Metadata}).map(function(t){var e=new vN(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key),a),n=-1,r=-1;return t.type!==bS.Added&&(tg(0<=(n=s.indexOf(t.doc.key)),"Index for document not found"),s=s.delete(t.doc.key)),t.type!==bS.Removed&&(r=(s=s.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case bS.Added:return"added";case bS.Modified:case bS.Metadata:return"modified";case bS.Removed:return"removed";default:return Zy("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this._firestore,e,this._snapshot,this._converter),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},EN.prototype.isEqual=function(t){if(!(t instanceof EN))throw kg("isEqual","QuerySnapshot",1,t);return this._firestore===t._firestore&&this._originalQuery.isEqual(t._originalQuery)&&this._snapshot.isEqual(t._snapshot)&&this._converter===t._converter},EN.prototype.convertToDocumentImpl=function(t){return new vN(this._firestore,t.key,t,this.metadata.fromCache,this._snapshot.mutatedKeys.has(t.key),this._converter)},EN);function EN(t,e,n,r){this._firestore=t,this._originalQuery=e,this._snapshot=n,this._converter=r,this._cachedChanges=null,this._cachedChangesIncludeMetadataChanges=null,this.metadata=new pN(n.hasPendingWrites,n.fromCache)}_a(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach(function(t){try{Object.defineProperty(TN.prototype.docChanges,t,{get:function(){return function(){throw new ag(og.INVALID_ARGUMENT,'QuerySnapshot.docChanges has been changed from a property into a method, so usages like "querySnapshot.docChanges" should become "querySnapshot.docChanges()"')}()}})}catch(t){}});var SN,IN=(da(CN,SN=wN),Object.defineProperty(CN.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(CN.prototype,"parent",{get:function(){var t=this._query.path.popLast();return t.isEmpty()?null:new lN(new ov(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(CN.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!0,configurable:!0}),CN.prototype.doc=function(t){if(gg("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=Pg.newId()),vg("CollectionReference.doc","non-empty string",1,t),""===t)throw new ag(og.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Zg.fromString(t);return lN.forPath(this._query.path.child(e),this.firestore,this._converter)},CN.prototype.add=function(t){mg("CollectionReference.add",arguments,1),vg("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then(function(){return e})},CN.prototype.withConverter=function(t){return new CN(this._path,this.firestore,t)},CN);function CN(t,e,n){var r=SN.call(this,jT.atPath(t),e,n)||this;if((r._path=t).length%2!=1)throw new ag(og.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.canonicalString()+" has "+t.length);return r}function NN(t,e){if(void 0===e)return{merge:!1};if(Ag(t,e,["merge","mergeFields"]),_g(t,"boolean","merge",e.merge),Tg(t,"mergeFields","a string or a FieldPath",e.mergeFields,function(t){return"string"==typeof t||t instanceof sC}),void 0!==e.mergeFields&&void 0!==e.merge)throw new ag(og.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function AN(t,e){return void 0===e?{}:(Ag(t,e,["serverTimestamps"]),Eg(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function kN(t,e){bg(t,"object",1,e),e&&(Ag(t,e,["source"]),Eg(t,0,"source",e.source,["default","server","cache"]))}function DN(t,e,n){if(e instanceof lN){if(e.firestore!==n)throw new ag(og.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw kg(t,"DocumentReference",1,e)}function RN(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}var ON=ug(oN,"Use firebase.firestore() instead."),PN=ug(sN,"Use firebase.firestore().runTransaction() instead."),MN=ug(cN,"Use firebase.firestore().batch() instead."),xN=ug(lN,"Use firebase.firestore().doc() instead."),LN=ug(mN),FN=ug(vN),UN=ug(wN),VN=ug(TN),qN=ug(IN,"Use firebase.firestore().collection() instead."),BN={Firestore:ON,GeoPoint:GS,Timestamp:Tv,Blob:jg,Transaction:PN,WriteBatch:MN,DocumentReference:xN,DocumentSnapshot:LN,Query:UN,QueryDocumentSnapshot:FN,QuerySnapshot:VN,CollectionReference:qN,FieldPath:sC,FieldValue:FC,setLogLevel:oN.setLogLevel,CACHE_SIZE_UNLIMITED:nN};function jN(t){t.INTERNAL.registerComponent(new as("firestore",function(t){var e=t.getProvider("app").getImmediate();return new oN(e,t.getProvider("auth-internal"))},"PUBLIC").setServiceProps(function(t){tg(t&&"object"==typeof t,"shallowCopy() expects object parameter.");var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}(BN)))}var WN=(KN.prototype.addCallback=function(t){},KN.prototype.shutdown=function(){},KN);function KN(){}var QN="ConnectivityMonitor",HN=(GN.prototype.addCallback=function(t){this.callbacks.push(t)},GN.prototype.shutdown=function(){window.removeEventListener("online",this.networkAvailableListener),window.removeEventListener("offline",this.networkUnavailableListener)},GN.prototype.configureNetworkMonitoring=function(){window.addEventListener("online",this.networkAvailableListener),window.addEventListener("offline",this.networkUnavailableListener)},GN.prototype.onNetworkAvailable=function(){Xy(QN,"Network connectivity changed: AVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++)(0,e[t])(0)},GN.prototype.onNetworkUnavailable=function(){Xy(QN,"Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++)(0,e[t])(1)},GN.isAvailable=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},GN);function GN(){var t=this;this.networkAvailableListener=function(){return t.onNetworkAvailable()},this.networkUnavailableListener=function(){return t.onNetworkUnavailable()},this.callbacks=[],this.configureNetworkMonitoring()}var zN=(YN.prototype.onOpen=function(t){tg(!this.wrappedOnOpen,"Called onOpen on stream twice!"),this.wrappedOnOpen=t},YN.prototype.onClose=function(t){tg(!this.wrappedOnClose,"Called onClose on stream twice!"),this.wrappedOnClose=t},YN.prototype.onMessage=function(t){tg(!this.wrappedOnMessage,"Called onMessage on stream twice!"),this.wrappedOnMessage=t},YN.prototype.close=function(){this.closeFn()},YN.prototype.send=function(t){this.sendFn(t)},YN.prototype.callOnOpen=function(){tg(void 0!==this.wrappedOnOpen,"Cannot call onOpen because no callback was set"),this.wrappedOnOpen()},YN.prototype.callOnClose=function(t){tg(void 0!==this.wrappedOnClose,"Cannot call onClose because no callback was set"),this.wrappedOnClose(t)},YN.prototype.callOnMessage=function(t){tg(void 0!==this.wrappedOnMessage,"Cannot call onMessage because no callback was set"),this.wrappedOnMessage(t)},YN);function YN(t){this.sendFn=t.sendFn,this.closeFn=t.closeFn}var XN="Connection",JN={BatchGetDocuments:"batchGet",Commit:"commit"},$N="gl-js/ fire/"+Hy,ZN=(tA.prototype.modifyHeadersForRequest=function(t,e){if(e)for(var n in e.authHeaders)e.authHeaders.hasOwnProperty(n)&&(t[n]=e.authHeaders[n]);t["X-Goog-Api-Client"]=$N},tA.prototype.invokeRPC=function(s,r,u){var c=this,h=this.makeUrl(s);return new Promise(function(i,o){var a=new Qy;a.listenOnce(Wy.COMPLETE,function(){try{switch(a.getLastErrorCode()){case jy.NO_ERROR:var t=a.getResponseJson();Xy(XN,"XHR received:",JSON.stringify(t)),i(t);break;case jy.TIMEOUT:Xy(XN,'RPC "'+s+'" timed out'),o(new ag(og.DEADLINE_EXCEEDED,"Request time out"));break;case jy.HTTP_ERROR:var e=a.getStatus();if(Xy(XN,'RPC "'+s+'" failed with status:',e,"response text:",a.getResponseText()),0<e){var n=a.getResponseJson().error;if(n&&n.status&&n.message){var r=function(t){var e=t.toLowerCase().replace("_","-");return 0<=Object.values(og).indexOf(e)?e:og.UNKNOWN}(n.status);o(new ag(r,n.message))}else o(new ag(og.UNKNOWN,"Server responded with status "+a.getStatus()))}else Xy(XN,'RPC "'+s+'" failed'),o(new ag(og.UNAVAILABLE,"Connection failed."));break;default:Zy('RPC "'+s+'" failed with unanticipated webchannel error '+a.getLastErrorCode()+": "+a.getLastError()+", giving up.")}}finally{Xy(XN,'RPC "'+s+'" completed.')}});var t=ma({},r);delete t.database;var e=JSON.stringify(t);Xy(XN,"XHR sending: ",h+" "+e);var n={"Content-Type":"text/plain"};c.modifyHeadersForRequest(n,u),a.send(h,"POST",e,n,15)})},tA.prototype.invokeStreamingRPC=function(t,e,n){return this.invokeRPC(t,e,n)},tA.prototype.openStream=function(t,e){var n=[this.baseUrl,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=By(),i={backgroundChannelTest:!0,httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.modifyHeadersForRequest(i.initMessageHeaders,e),Ma()||(i.httpHeadersOverwriteParam="$httpHeaders");var o=n.join("");function a(t,e){u.listen(t,function(t){try{e(t)}catch(t){setTimeout(function(){throw t},0)}})}Xy(XN,"Creating WebChannel: "+o+" "+i);var u=r.createWebChannel(o,i),s=!1,c=!1,h=new zN({sendFn:function(t){c?Xy(XN,"Not sending because WebChannel is closed:",t):(s||(Xy(XN,"Opening WebChannel transport."),u.open(),s=!0),Xy(XN,"WebChannel sending:",t),u.send(t))},closeFn:function(){return u.close()}});return a(Ky.EventType.OPEN,function(){c||Xy(XN,"WebChannel transport opened.")}),a(Ky.EventType.CLOSE,function(){c||(c=!0,Xy(XN,"WebChannel transport closed"),h.callOnClose())}),a(Ky.EventType.ERROR,function(t){c||(c=!0,Xy(XN,"WebChannel transport errored:",t),h.callOnClose(new ag(og.UNAVAILABLE,"The operation could not be completed")))}),a(Ky.EventType.MESSAGE,function(t){var e;if(!c){var n=t.data[0];tg(!!n,"Got a webchannel message without data.");var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){Xy(XN,"WebChannel received error:",i);var o=i.status,a=function(t){var e=pS[t];if(void 0!==e)return vS(e)}(o),s=i.message;void 0===a&&(a=og.INTERNAL,s="Unknown error status: "+o+" with message "+i.message),c=!0,h.callOnClose(new ag(a,s)),u.close()}else Xy(XN,"WebChannel received:",n),h.callOnMessage(n)}}),setTimeout(function(){h.callOnOpen()},0),h},tA.prototype.makeUrl=function(t){var e=JN[t];return tg(void 0!==e,"Unknown REST mapping for: "+t),this.baseUrl+"/v1/projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents:"+e},tA);function tA(t){this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.baseUrl=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}var eA=(Object.defineProperty(nA.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(nA.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),nA.prototype.loadConnection=function(t){return Promise.resolve(new ZN(t))},nA.prototype.newConnectivityMonitor=function(){return HN.isAvailable()?new HN:new WN},nA.prototype.newSerializer=function(t){return new pI(t,{useProto3Json:!0})},nA.prototype.formatJSON=function(t){return JSON.stringify(t)},nA.prototype.atob=function(t){return atob(t)},nA.prototype.btoa=function(t){return btoa(t)},nA);function nA(){this.emptyByteString="",this.base64Available="undefined"!=typeof atob}eg.setPlatform(new eA);var rA;jN(rA=fl),rA.registerVersion("@firebase/firestore","1.9.0");var iA,oA={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"},aA=(da(sA,iA=Error),sA);function sA(t,e,n){var r=iA.call(this,e)||this;return Object.setPrototypeOf(r,sA.prototype),r.code=t,r.details=n,r}function uA(t,e,n){var r=function(t){if(200<=t&&t<300)return"ok";switch(t){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}(t),i=r,o=void 0;try{var a=e&&e.error;if(a){var s=a.status;if("string"==typeof s){if(!oA[s])return new aA("internal","internal");r=oA[s],i=s}var u=a.message;"string"==typeof u&&(i=u),void 0!==(o=a.details)&&(o=n.decode(o))}}catch(t){}return"ok"===r?null:new aA(r,i,o)}var cA=(hA.prototype.getAuthToken=function(){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:if(!this.auth)return[2,void 0];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.auth.getToken()];case 2:return(e=t.sent())?[2,e.accessToken]:[2,void 0];case 3:return t.sent(),[2,void 0];case 4:return[2]}})})},hA.prototype.getInstanceIdToken=function(){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.messaging?[4,this.messaging.getToken()]:[2,void 0];case 1:return(e=t.sent())?[2,e]:[2,void 0];case 2:return t.sent(),[2,void 0];case 3:return[2]}})})},hA.prototype.getContext=function(){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,this.getAuthToken()];case 1:return e=t.sent(),[4,this.getInstanceIdToken()];case 2:return n=t.sent(),[2,{authToken:e,instanceIdToken:n}]}})})},hA);function hA(t,e){var n=this;this.auth=null,this.messaging=null,this.auth=t.getImmediate({optional:!0}),this.messaging=e.getImmediate({optional:!0}),this.auth||t.get().then(function(t){return n.auth=t},function(){}),this.messaging||e.get().then(function(t){return n.messaging=t},function(){})}function lA(t,e){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]=e(t[r]));return n}var fA=(pA.prototype.encode=function(t){var e=this;if(null==t)return null;if(t instanceof Number&&(t=t.valueOf()),"number"==typeof t&&isFinite(t))return t;if(!0===t||!1===t)return t;if("[object String]"===Object.prototype.toString.call(t))return t;if(Array.isArray(t))return t.map(function(t){return e.encode(t)});if("function"==typeof t||"object"==typeof t)return lA(t,function(t){return e.encode(t)});throw new Error("Data cannot be encoded in JSON: "+t)},pA.prototype.decode=function(t){var e=this;if(null==t)return t;if(t["@type"])switch(t["@type"]){case"type.googleapis.com/google.protobuf.Int64Value":case"type.googleapis.com/google.protobuf.UInt64Value":var n=Number(t.value);if(isNaN(n))throw new Error("Data cannot be decoded from JSON: "+t);return n;default:throw new Error("Data cannot be decoded from JSON: "+t)}return Array.isArray(t)?t.map(function(t){return e.decode(t)}):"function"==typeof t||"object"==typeof t?lA(t,function(t){return e.decode(t)}):t},pA);function pA(){}var dA=(Object.defineProperty(mA.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),mA.prototype._url=function(t){var e=this.app_.options.projectId,n=this.region_;return null===this.emulatorOrigin?"https://"+n+"-"+e+".cloudfunctions.net/"+t:this.emulatorOrigin+"/"+e+"/"+n+"/"+t},mA.prototype.useFunctionsEmulator=function(t){this.emulatorOrigin=t},mA.prototype.httpsCallable=function(e,n){var r=this;return function(t){return r.call(e,t,n||{})}},mA.prototype.postJSON=function(r,i,o){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:o.append("Content-Type","application/json"),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch(r,{method:"POST",body:JSON.stringify(i),headers:o})];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,{status:0,json:null}];case 4:n=null,t.label=5;case 5:return t.trys.push([5,7,,8]),[4,e.json()];case 6:return n=t.sent(),[3,8];case 7:return t.sent(),[3,8];case 8:return[2,{status:e.status,json:n}]}})})},mA.prototype.call=function(c,h,l){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u;return ga(this,function(t){switch(t.label){case 0:return e=this._url(c),h=this.serializer.encode(h),n={data:h},r=new Headers,[4,this.contextProvider.getContext()];case 1:return(i=t.sent()).authToken&&r.append("Authorization","Bearer "+i.authToken),i.instanceIdToken&&r.append("Firebase-Instance-ID-Token",i.instanceIdToken),o=l.timeout||7e4,[4,Promise.race([this.postJSON(e,n,r),function(n){return new Promise(function(t,e){setTimeout(function(){e(new aA("deadline-exceeded","deadline-exceeded"))},n)})}(o),this.cancelAllRequests])];case 2:if(!(a=t.sent()))throw new aA("cancelled","Firebase Functions instance was deleted.");if(s=uA(a.status,a.json,this.serializer))throw s;if(!a.json)throw new aA("internal","Response is not valid JSON object.");if(void 0===(u=a.json.data)&&(u=a.json.result),void 0===u)throw new aA("internal","Response is missing data field.");return[2,{data:this.serializer.decode(u)}]}})})},mA);function mA(t,e,n,r){var i=this;void 0===r&&(r="us-central1"),this.app_=t,this.region_=r,this.serializer=new fA,this.emulatorOrigin=null,this.INTERNAL={delete:function(){return i.deleteService()}},this.contextProvider=new cA(e,n),this.cancelAllRequests=new Promise(function(t){i.deleteService=function(){return t()}})}function yA(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal"),i=t.getProvider("messaging");return new dA(n,r,i,e)}var gA;function vA(n){return new Promise(function(t,e){n.onsuccess=function(){t(n.result)},n.onerror=function(){e(n.error)}})}function bA(n,r,i){var o,t=new Promise(function(t,e){vA(o=n[r].apply(n,i)).then(t,e)});return t.request=o,t}function wA(t,n,e){e.forEach(function(e){Object.defineProperty(t.prototype,e,{get:function(){return this[n][e]},set:function(t){this[n][e]=t}})})}function _A(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return bA(this[n],t,arguments)})})}function TA(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return this[n][t].apply(this[n],arguments)})})}function EA(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return function(t,e,n){var r=bA(t,e,n);return r.then(function(t){if(t)return new IA(t,r.request)})}(this[n],t,arguments)})})}function SA(t){this._index=t}function IA(t,e){this._cursor=t,this._request=e}function CA(t){this._store=t}function NA(n){this._tx=n,this.complete=new Promise(function(t,e){n.oncomplete=function(){t()},n.onerror=function(){e(n.error)},n.onabort=function(){e(n.error)}})}function AA(t,e,n){this._db=t,this.oldVersion=e,this.transaction=new NA(n)}function kA(t){this._db=t}gA={Functions:dA},fl.INTERNAL.registerComponent(new as("functions",yA,"PUBLIC").setServiceProps(gA).setMultipleInstances(!0)),fl.registerVersion("@firebase/functions","0.4.28"),wA(SA,"_index",["name","keyPath","multiEntry","unique"]),_A(SA,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),EA(SA,"_index",IDBIndex,["openCursor","openKeyCursor"]),wA(IA,"_cursor",["direction","key","primaryKey","value"]),_A(IA,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(IA.prototype[n]=function(){var e=this,t=arguments;return Promise.resolve().then(function(){return e._cursor[n].apply(e._cursor,t),vA(e._request).then(function(t){if(t)return new IA(t,e._request)})})})}),CA.prototype.createIndex=function(){return new SA(this._store.createIndex.apply(this._store,arguments))},CA.prototype.index=function(){return new SA(this._store.index.apply(this._store,arguments))},wA(CA,"_store",["name","keyPath","indexNames","autoIncrement"]),_A(CA,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),EA(CA,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),TA(CA,"_store",IDBObjectStore,["deleteIndex"]),NA.prototype.objectStore=function(){return new CA(this._tx.objectStore.apply(this._tx,arguments))},wA(NA,"_tx",["objectStoreNames","mode"]),TA(NA,"_tx",IDBTransaction,["abort"]),AA.prototype.createObjectStore=function(){return new CA(this._db.createObjectStore.apply(this._db,arguments))},wA(AA,"_db",["name","version","objectStoreNames"]),TA(AA,"_db",IDBDatabase,["deleteObjectStore","close"]),kA.prototype.transaction=function(){return new NA(this._db.transaction.apply(this._db,arguments))},wA(kA,"_db",["name","version","objectStoreNames"]),TA(kA,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(i){[CA,SA].forEach(function(t){i in t.prototype&&(t.prototype[i.replace("open","iterate")]=function(){var t=function(t){return Array.prototype.slice.call(t)}(arguments),e=t[t.length-1],n=this._store||this._index,r=n[i].apply(n,t.slice(0,-1));r.onsuccess=function(){e(r.result)}})})}),[SA,CA].forEach(function(t){t.prototype.getAll||(t.prototype.getAll=function(t,n){var r=this,i=[];return new Promise(function(e){r.iterateCursor(t,function(t){t?(i.push(t.value),void 0===n||i.length!=n?t.continue():e(i)):e(i)})})})});var DA,RA=1e4,OA="w:0.3.8",PA="FIS_v2",MA="https://firebaseinstallations.googleapis.com/v1",xA=36e5,LA=((DA={})["missing-app-config-values"]='Missing App configuration value: "{$valueName}"',DA["not-registered"]="Firebase Installation is not registered.",DA["installation-not-found"]="Firebase Installation not found.",DA["request-failed"]='{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',DA["app-offline"]="Could not process request. Application offline.",DA["delete-pending-registration"]="Can't delete installation while there is a pending registration request.",DA),FA=new Va("installations","Installations",LA);function UA(t){return t instanceof Fa&&t.code.includes("request-failed")}function VA(t){var e=t.projectId;return MA+"/projects/"+e+"/installations"}function qA(t){return{token:t.token,requestStatus:2,expiresIn:function(t){return Number(t.replace("s","000"))}(t.expiresIn),creationTime:Date.now()}}function BA(r,i){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,i.json()];case 1:return e=t.sent(),n=e.error,[2,FA.create("request-failed",{requestName:r,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})]}})})}function jA(t){var e=t.apiKey;return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function WA(t,e){var n=e.refreshToken,r=jA(t);return r.append("Authorization",function(t){return PA+" "+t}(n)),r}function KA(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return[4,n()];case 1:return 500<=(e=t.sent()).status&&e.status<600?[2,n()]:[2,e]}})})}function QA(e){return new Promise(function(t){setTimeout(t,e)})}var HA=/^[cdef][\w-]{21}$/,GA="";function zA(){try{var t=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(t),t[0]=112+t[0]%16;var e=function(t){return function(t){return btoa(String.fromCharCode.apply(String,wa(t))).replace(/\+/g,"-").replace(/\//g,"_")}(t).substr(0,22)}(t);return HA.test(e)?e:GA}catch(t){return GA}}var YA,XA,JA="firebase-installations-database",$A=1,ZA="firebase-installations-store",tk=null;function ek(){return tk=tk||function(t,e,n){var r=bA(indexedDB,"open",[t,e]),i=r.request;return i&&(i.onupgradeneeded=function(t){n&&n(new AA(i.result,t.oldVersion,i.transaction))}),r.then(function(t){return new kA(t)})}(JA,$A,function(t){switch(t.oldVersion){case 0:t.createObjectStore(ZA)}})}function nk(i,o){return ya(this,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return e=ok(i),[4,ek()];case 1:return n=t.sent(),[4,(r=n.transaction(ZA,"readwrite")).objectStore(ZA).put(o,e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2,o]}})})}function rk(i){return ya(this,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return e=ok(i),[4,ek()];case 1:return n=t.sent(),[4,(r=n.transaction(ZA,"readwrite")).objectStore(ZA).delete(e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2]}})})}function ik(s,u){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){switch(t.label){case 0:return e=ok(s),[4,ek()];case 1:return n=t.sent(),r=n.transaction(ZA,"readwrite"),[4,(i=r.objectStore(ZA)).get(e)];case 2:return o=t.sent(),void 0!==(a=u(o))?[3,4]:[4,i.delete(e)];case 3:return t.sent(),[3,6];case 4:return[4,i.put(a,e)];case 5:t.sent(),t.label=6;case 6:return[4,r.complete];case 7:return t.sent(),[2,a]}})})}function ok(t){return t.appName+"!"+t.appId}function ak(i){return ya(this,void 0,void 0,function(){var r,e,n;return ga(this,function(t){switch(t.label){case 0:return[4,ik(i,function(t){var e=function(t){return uk(t||{fid:zA(),registrationStatus:0})}(t),n=function(t,e){{if(0!==e.registrationStatus)return 1===e.registrationStatus?{installationEntry:e,registrationPromise:function(o){return ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:return[4,sk(o)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.registrationStatus?[3,5]:[4,QA(100)];case 3:return t.sent(),[4,sk(o)];case 4:return e=t.sent(),[3,2];case 5:return 0!==e.registrationStatus?[3,7]:[4,ak(o)];case 6:return n=t.sent(),r=n.installationEntry,(i=n.registrationPromise)?[2,i]:[2,r];case 7:return[2,e]}})})}(t)}:{installationEntry:e};if(!navigator.onLine){var n=Promise.reject(FA.create("app-offline"));return{installationEntry:e,registrationPromise:n}}var r={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},i=function(r,i){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,7]),[4,function(s,t){var u=t.fid;return ya(this,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){switch(t.label){case 0:return e=VA(s),n=jA(s),r={fid:u,authVersion:PA,appId:s.appId,sdkVersion:OA},i={method:"POST",headers:n,body:JSON.stringify(r)},[4,KA(function(){return fetch(e,i)})];case 1:return(o=t.sent()).ok?[4,o.json()]:[3,3];case 2:return a=t.sent(),[2,{fid:a.fid||u,registrationStatus:2,refreshToken:a.refreshToken,authToken:qA(a.authToken)}];case 3:return[4,BA("Create Installation",o)];case 4:throw t.sent()}})})}(r,i)];case 1:return e=t.sent(),[2,nk(r,e)];case 2:return UA(n=t.sent())&&409===n.serverCode?[4,rk(r)]:[3,4];case 3:return t.sent(),[3,6];case 4:return[4,nk(r,{fid:i.fid,registrationStatus:0})];case 5:t.sent(),t.label=6;case 6:throw n;case 7:return[2]}})})}(t,r);return{installationEntry:r,registrationPromise:i}}}(i,e);return r=n.registrationPromise,n.installationEntry})];case 1:return(e=t.sent()).fid!==GA?[3,3]:(n={},[4,r]);case 2:return[2,(n.installationEntry=t.sent(),n)];case 3:return[2,{installationEntry:e,registrationPromise:r}]}})})}function sk(t){return ik(t,function(t){if(!t)throw FA.create("installation-not-found");return uk(t)})}function uk(t){return function(t){return 1===t.registrationStatus&&t.registrationTime+RA<Date.now()}(t)?{fid:t.fid,registrationStatus:0}:t}function ck(t,u){var c=t.appConfig,h=t.platformLoggerProvider;return ya(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return ga(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return VA(t)+"/"+n+"/authTokens:generate"}(c,u),n=WA(c,u),(r=h.getImmediate({optional:!0}))&&n.append("x-firebase-client",r.getPlatformInfoString()),i={installation:{sdkVersion:OA}},o={method:"POST",headers:n,body:JSON.stringify(i)},[4,KA(function(){return fetch(e,o)})];case 1:return(a=t.sent()).ok?[4,a.json()]:[3,3];case 2:return s=t.sent(),[2,qA(s)];case 3:return[4,BA("Generate Auth Token",a)];case 4:throw t.sent()}})})}function hk(i,o){return void 0===o&&(o=!1),ya(this,void 0,void 0,function(){var r,e,n;return ga(this,function(t){switch(t.label){case 0:return[4,ik(i.appConfig,function(t){if(!fk(t))throw FA.create("not-registered");var e=t.authToken;if(!o&&function(t){return 2===t.requestStatus&&!function(t){var e=Date.now();return e<t.creationTime||t.creationTime+t.expiresIn<e+xA}(t)}(e))return t;if(1===e.requestStatus)return r=function(r,i){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,lk(r.appConfig)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.authToken.requestStatus?[3,5]:[4,QA(100)];case 3:return t.sent(),[4,lk(r.appConfig)];case 4:return e=t.sent(),[3,2];case 5:return 0===(n=e.authToken).requestStatus?[2,hk(r,i)]:[2,n]}})})}(i,o),t;if(!navigator.onLine)throw FA.create("app-offline");var n=function(t){var e={requestStatus:1,requestTime:Date.now()};return ma(ma({},t),{authToken:e})}(t);return r=function(i,o){return ya(this,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,8]),[4,ck(i,o)];case 1:return e=t.sent(),r=ma(ma({},o),{authToken:e}),[4,nk(i.appConfig,r)];case 2:return t.sent(),[2,e];case 3:return!UA(n=t.sent())||401!==n.serverCode&&404!==n.serverCode?[3,5]:[4,rk(i.appConfig)];case 4:return t.sent(),[3,7];case 5:return r=ma(ma({},o),{authToken:{requestStatus:0}}),[4,nk(i.appConfig,r)];case 6:t.sent(),t.label=7;case 7:throw n;case 8:return[2]}})})}(i,n),n})];case 1:return e=t.sent(),r?[4,r]:[3,3];case 2:return n=t.sent(),[3,4];case 3:n=e.authToken,t.label=4;case 4:return[2,n]}})})}function lk(t){return ik(t,function(t){if(!fk(t))throw FA.create("not-registered");return function(t){return 1===t.requestStatus&&t.requestTime+RA<Date.now()}(t.authToken)?ma(ma({},t),{authToken:{requestStatus:0}}):t})}function fk(t){return void 0!==t&&2===t.registrationStatus}function pk(e,n){return void 0===n&&(n=!1),ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return[4,function(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return[4,ak(n)];case 1:return(e=t.sent().registrationPromise)?[4,e]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}})})}(e.appConfig)];case 1:return t.sent(),[4,hk(e,n)];case 2:return[2,t.sent().token]}})})}function dk(o,a){return ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return VA(t)+"/"+n}(o,a),n=WA(o,a),r={method:"DELETE",headers:n},[4,KA(function(){return fetch(e,r)})];case 1:return(i=t.sent()).ok?[3,3]:[4,BA("Delete Installation",i)];case 2:throw t.sent();case 3:return[2]}})})}function mk(t){return FA.create("missing-app-config-values",{valueName:t})}(YA=fl).INTERNAL.registerComponent(new as("installations",function(t){var e=t.getProvider("app").getImmediate(),n={appConfig:function(t){var e,n;if(!t||!t.options)throw mk("App Configuration");if(!t.name)throw mk("App Name");try{for(var r=va(["projectId","apiKey","appId"]),i=r.next();!i.done;i=r.next()){var o=i.value;if(!t.options[o])throw mk(o)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e),platformLoggerProvider:t.getProvider("platform-logger")};return{app:e,getId:function(){return function(i){return ya(this,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return[4,ak(i.appConfig)];case 1:return e=t.sent(),n=e.installationEntry,(r=e.registrationPromise)?r.catch(console.error):hk(i).catch(console.error),[2,n.fid]}})})}(n)},getToken:function(t){return pk(n,t)},delete:function(){return function(r){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,ik(e=r.appConfig,function(t){if(!t||0!==t.registrationStatus)return t})];case 1:if(!(n=t.sent()))return[3,6];if(1!==n.registrationStatus)return[3,2];throw FA.create("delete-pending-registration");case 2:if(2!==n.registrationStatus)return[3,6];if(navigator.onLine)return[3,3];throw FA.create("app-offline");case 3:return[4,dk(e,n)];case 4:return t.sent(),[4,rk(e)];case 5:t.sent(),t.label=6;case 6:return[2]}})})}(n)}}},"PUBLIC")),YA.registerVersion("@firebase/installations","0.3.8");var yk,gk,vk=((XA={})["only-available-in-window"]="This method is available in a Window context.",XA["only-available-in-sw"]="This method is available in a service worker context.",XA["should-be-overriden"]="This method should be overriden by extended classes.",XA["bad-sender-id"]="Please ensure that 'messagingSenderId' is set correctly in the options passed into firebase.initializeApp().",XA["permission-default"]="The required permissions were not granted and dismissed instead.",XA["permission-blocked"]="The required permissions were not granted and blocked instead.",XA["unsupported-browser"]="This browser doesn't support the API's required to use the firebase SDK.",XA["notifications-blocked"]="Notifications have been blocked.",XA["failed-serviceworker-registration"]="We are unable to register the default service worker. {$browserErrorMessage}",XA["sw-registration-expected"]="A service worker registration was the expected input.",XA["get-subscription-failed"]="There was an error when trying to get any existing Push Subscriptions.",XA["invalid-saved-token"]="Unable to access details of the saved token.",XA["sw-reg-redundant"]="The service worker being used for push was made redundant.",XA["token-subscribe-failed"]="A problem occured while subscribing the user to FCM: {$errorInfo}",XA["token-subscribe-no-token"]="FCM returned no token when subscribing the user to push.",XA["token-unsubscribe-failed"]="A problem occured while unsubscribing the user from FCM: {$errorInfo}",XA["token-update-failed"]="A problem occured while updating the user from FCM: {$errorInfo}",XA["token-update-no-token"]="FCM returned no token when updating the user to push.",XA["use-sw-before-get-token"]="The useServiceWorker() method may only be called once and must be called before calling getToken() to ensure your service worker is used.",XA["invalid-delete-token"]="You must pass a valid token into deleteToken(), i.e. the token from getToken().",XA["delete-token-not-found"]="The deletion attempt for token could not be performed as the token was not found.",XA["delete-scope-not-found"]="The deletion attempt for service worker scope could not be performed as the scope was not found.",XA["bg-handler-function-expected"]="The input to setBackgroundMessageHandler() must be a function.",XA["no-window-client-to-msg"]="An attempt was made to message a non-existant window client.",XA["unable-to-resubscribe"]="There was an error while re-subscribing the FCM token for push messaging. Will have to resubscribe the user on next visit. {$errorInfo}",XA["no-fcm-token-for-resubscribe"]="Could not find an FCM token and as a result, unable to resubscribe. Will have to resubscribe the user on next visit.",XA["failed-to-delete-token"]="Unable to delete the currently saved token.",XA["no-sw-in-reg"]="Even though the service worker registration was successful, there was a problem accessing the service worker itself.",XA["bad-scope"]="The service worker scope must be a string with at least one character.",XA["bad-vapid-key"]="The public VAPID key is not a Uint8Array with 65 bytes.",XA["bad-subscription"]="The subscription must be a valid PushSubscription.",XA["bad-token"]="The FCM Token used for storage / lookup was not a valid token string.",XA["failed-delete-vapid-key"]="The VAPID key could not be deleted.",XA["invalid-public-vapid-key"]="The public VAPID key must be a string.",XA["use-public-key-before-get-token"]="The usePublicVapidKey() method may only be called once and must be called before calling getToken() to ensure your VAPID key is used.",XA["public-vapid-key-decryption-failed"]="The public VAPID key did not equal 65 bytes when decrypted.",XA),bk=new Va("messaging","Messaging",vk),wk=new Uint8Array([4,51,148,247,223,161,235,177,220,3,162,94,21,113,219,72,211,46,237,237,178,52,219,183,71,58,12,143,196,204,225,111,60,140,132,223,171,182,102,62,242,12,212,139,254,227,249,118,47,20,28,99,8,106,111,45,177,26,149,176,206,55,192,156,110]),_k="google.c.a.c_id";function Tk(t,e){if(null==t||null==e)return!1;if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(var n=new DataView(t),r=new DataView(e),i=0;i<t.byteLength;i++)if(n.getUint8(i)!==r.getUint8(i))return!1;return!0}function Ek(t){return function(t){var e=new Uint8Array(t);return btoa(String.fromCharCode.apply(String,wa(e)))}(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(gk=yk=yk||{}).PUSH_MSG_RECEIVED="push-msg-received",gk.NOTIFICATION_CLICKED="notification-clicked";var Sk=(Ik.prototype.getToken=function(s,u,c){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){switch(t.label){case 0:return[4,Nk(s)];case 1:e=t.sent(),n=Ak(u,c),r={method:"POST",headers:e,body:JSON.stringify(n)},t.label=2;case 2:return t.trys.push([2,5,,6]),[4,fetch(Ck(s.app),r)];case 3:return[4,t.sent().json()];case 4:return i=t.sent(),[3,6];case 5:throw o=t.sent(),bk.create("token-subscribe-failed",{errorInfo:o});case 6:if(i.error)throw a=i.error.message,bk.create("token-subscribe-failed",{errorInfo:a});if(!i.token)throw bk.create("token-subscribe-no-token");return[2,i.token]}})})},Ik.prototype.updateToken=function(s,u,c,h){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){switch(t.label){case 0:return[4,Nk(u)];case 1:e=t.sent(),n=Ak(c,h),r={method:"PATCH",headers:e,body:JSON.stringify(n)},t.label=2;case 2:return t.trys.push([2,5,,6]),[4,fetch(Ck(u.app)+"/"+s.fcmToken,r)];case 3:return[4,t.sent().json()];case 4:return i=t.sent(),[3,6];case 5:throw o=t.sent(),bk.create("token-update-failed",{errorInfo:o});case 6:if(i.error)throw a=i.error.message,bk.create("token-update-failed",{errorInfo:a});if(!i.token)throw bk.create("token-update-no-token");return[2,i.token]}})})},Ik.prototype.deleteToken=function(a,s){return ya(this,void 0,void 0,function(){var e,n,r,i,o;return ga(this,function(t){switch(t.label){case 0:return[4,Nk(a)];case 1:e=t.sent(),n={method:"DELETE",headers:e},t.label=2;case 2:return t.trys.push([2,5,,6]),[4,fetch(Ck(a.app)+"/"+s.fcmToken,n)];case 3:return[4,t.sent().json()];case 4:if((r=t.sent()).error)throw i=r.error.message,bk.create("token-unsubscribe-failed",{errorInfo:i});return[3,6];case 5:throw o=t.sent(),bk.create("token-unsubscribe-failed",{errorInfo:o});case 6:return[2]}})})},Ik);function Ik(){}function Ck(t){return"https://fcmregistrations.googleapis.com/v1/projects/"+t.options.projectId+"/registrations"}function Nk(t){var n=t.app,r=t.installations;return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return[4,r.getToken()];case 1:return e=t.sent(),[2,new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n.options.apiKey,"x-goog-firebase-installations-auth":"FIS "+e})]}})})}function Ak(t,e){var n=Ek(t.getKey("p256dh")),r=Ek(t.getKey("auth")),i={web:{endpoint:t.endpoint,p256dh:n,auth:r}};return Tk(e.buffer,wk.buffer)||(i.web.applicationPubKey=Ek(e)),i}function kk(t){for(var e=(t+"=".repeat((4-t.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),n=atob(e),r=new Uint8Array(n.length),i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}var Dk="undefined",Rk="fcm_token_object_Store";function Ok(e){var n=indexedDB.open(Dk);n.onerror=function(t){},n.onsuccess=function(t){!function(n,r){if(n.objectStoreNames.contains(Rk)){var t=n.transaction(Rk).objectStore(Rk),i=new Sk,o=t.openCursor();o.onerror=function(t){console.warn("Unable to cleanup old IDB.",t)},o.onsuccess=function(){var t=o.result;if(t){var e=t.value;i.deleteToken(r,e),t.continue()}else n.close(),indexedDB.deleteDatabase(Dk)}}}(n.result,e)}}var Pk=(Mk.prototype.get=function(e){return this.createTransaction(function(t){return t.get(e)})},Mk.prototype.getIndex=function(e,n){return this.createTransaction(function(t){return t.index(e).get(n)})},Mk.prototype.put=function(e){return this.createTransaction(function(t){return t.put(e)},"readwrite")},Mk.prototype.delete=function(e){return this.createTransaction(function(t){return t.delete(e)},"readwrite")},Mk.prototype.closeDatabase=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return this.dbPromise?[4,this.dbPromise]:[3,2];case 1:t.sent().close(),this.dbPromise=null,t.label=2;case 2:return[2]}})})},Mk.prototype.createTransaction=function(o,a){return void 0===a&&(a="readonly"),ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:return[4,this.getDb()];case 1:return e=t.sent(),n=e.transaction(this.objectStoreName,a),r=n.objectStore(this.objectStoreName),[4,function(n){return new Promise(function(t,e){n.onsuccess=function(){t(n.result)},n.onerror=function(){e(n.error)}})}(o(r))];case 2:return i=t.sent(),[2,new Promise(function(t,e){n.oncomplete=function(){t(i)},n.onerror=function(){e(n.error)}})]}})})},Mk.prototype.getDb=function(){var r=this;return this.dbPromise||(this.dbPromise=new Promise(function(t,e){var n=indexedDB.open(r.dbName,r.dbVersion);n.onsuccess=function(){t(n.result)},n.onerror=function(){r.dbPromise=null,e(n.error)},n.onupgradeneeded=function(t){return r.onDbUpgrade(n,t)}})),this.dbPromise},Mk);function Mk(){this.dbPromise=null}var xk,Lk=(da(Fk,xk=Pk),Fk.prototype.onDbUpgrade=function(t,e){var n=t.result;switch(e.oldVersion){case 0:(i=n.createObjectStore(this.objectStoreName,{keyPath:"swScope"})).createIndex("fcmSenderId","fcmSenderId",{unique:!1}),i.createIndex("fcmToken","fcmToken",{unique:!0});case 1:Ok(this.services);case 2:var r=(i=t.transaction.objectStore(this.objectStoreName)).openCursor();r.onsuccess=function(){var t=r.result;if(t){var e=t.value,n=ma({},e);e.createTime||(n.createTime=Date.now()),"string"==typeof e.vapidKey&&(n.vapidKey=kk(e.vapidKey)),"string"==typeof e.auth&&(n.auth=kk(e.auth).buffer),"string"==typeof e.auth&&(n.p256dh=kk(e.p256dh).buffer),"string"==typeof e.fcmPushSet&&delete n.fcmPushSet,t.update(n),t.continue()}};break;case 3:var i,o=(i=t.transaction.objectStore(this.objectStoreName)).openCursor();o.onsuccess=function(){var t=o.result;if(t){var e=t.value,n=ma({},e);"string"==typeof e.fcmPushSet&&delete n.fcmPushSet,t.update(n),t.continue()}}}},Fk.prototype.getTokenDetailsFromToken=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){if(!e)throw bk.create("bad-token");return Uk({fcmToken:e}),[2,this.getIndex("fcmToken",e)]})})},Fk.prototype.getTokenDetailsFromSWScope=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){if(!e)throw bk.create("bad-scope");return Uk({swScope:e}),[2,this.get(e)]})})},Fk.prototype.saveTokenDetails=function(e){return ya(this,void 0,void 0,function(){return ga(this,function(t){if(!e.swScope)throw bk.create("bad-scope");if(!e.vapidKey)throw bk.create("bad-vapid-key");if(!e.endpoint||!e.auth||!e.p256dh)throw bk.create("bad-subscription");if(!e.fcmSenderId)throw bk.create("bad-sender-id");if(!e.fcmToken)throw bk.create("bad-token");return Uk(e),[2,this.put(e)]})})},Fk.prototype.deleteToken=function(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return"string"!=typeof n||0===n.length?[2,Promise.reject(bk.create("invalid-delete-token"))]:[4,this.getTokenDetailsFromToken(n)];case 1:if(!(e=t.sent()))throw bk.create("delete-token-not-found");return[4,this.delete(e.swScope)];case 2:return t.sent(),[2,e]}})})},Fk);function Fk(t){var e=xk.call(this)||this;return e.services=t,e.dbName="fcm_token_details_db",e.dbVersion=4,e.objectStoreName="fcm_token_object_Store",e}function Uk(t){if(t.fcmToken&&("string"!=typeof t.fcmToken||0===t.fcmToken.length))throw bk.create("bad-token");if(t.swScope&&("string"!=typeof t.swScope||0===t.swScope.length))throw bk.create("bad-scope");if(t.vapidKey&&(!(t.vapidKey instanceof Uint8Array)||65!==t.vapidKey.length))throw bk.create("bad-vapid-key");if(t.endpoint&&("string"!=typeof t.endpoint||0===t.endpoint.length))throw bk.create("bad-subscription");if(t.auth&&!(t.auth instanceof ArrayBuffer))throw bk.create("bad-subscription");if(t.p256dh&&!(t.p256dh instanceof ArrayBuffer))throw bk.create("bad-subscription");if(t.fcmSenderId&&("string"!=typeof t.fcmSenderId||0===t.fcmSenderId.length))throw bk.create("bad-sender-id")}var Vk,qk=(da(Bk,Vk=Pk),Bk.prototype.onDbUpgrade=function(t){t.result.createObjectStore(this.objectStoreName,{keyPath:"swScope"})},Bk.prototype.getVapidFromSWScope=function(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:if("string"!=typeof n||0===n.length)throw bk.create("bad-scope");return[4,this.get(n)];case 1:return[2,(e=t.sent())?e.vapidKey:void 0]}})})},Bk.prototype.saveVapidDetails=function(n,r){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){if("string"!=typeof n||0===n.length)throw bk.create("bad-scope");if(null===r||65!==r.length)throw bk.create("bad-vapid-key");return e={swScope:n,vapidKey:r},[2,this.put(e)]})})},Bk.prototype.deleteVapidDetails=function(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return[4,this.getVapidFromSWScope(n)];case 1:if(!(e=t.sent()))throw bk.create("delete-scope-not-found");return[4,this.delete(n)];case 2:return t.sent(),[2,e]}})})},Bk);function Bk(){var t=null!==Vk&&Vk.apply(this,arguments)||this;return t.dbName="fcm_vapid_details_db",t.dbVersion=1,t.objectStoreName="fcm_vapid_object_Store",t}var jk=(Wk.prototype.getToken=function(){return ya(this,void 0,void 0,function(){var e,n,r,i,o;return ga(this,function(t){switch(t.label){case 0:return"default"!==(e=this.getNotificationPermission())?[3,2]:[4,this.requestNotificationPermission()];case 1:e=t.sent(),t.label=2;case 2:if("granted"!==e)throw bk.create("notifications-blocked");return[4,this.getSWRegistration_()];case 3:return n=t.sent(),[4,this.getPublicVapidKey_()];case 4:return r=t.sent(),[4,this.getPushSubscription(n,r)];case 5:return i=t.sent(),[4,this.tokenDetailsModel.getTokenDetailsFromSWScope(n.scope)];case 6:return(o=t.sent())?[2,this.manageExistingToken(n,i,r,o)]:[2,this.getNewToken(n,i,r)]}})})},Wk.prototype.manageExistingToken=function(e,n,r,i){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return function(t,e,n){if(!n.vapidKey||!Tk(e.buffer,n.vapidKey.buffer))return!1;var r=t.endpoint===n.endpoint,i=Tk(t.getKey("auth"),n.auth),o=Tk(t.getKey("p256dh"),n.p256dh);return r&&i&&o}(n,r,i)?Date.now()<i.createTime+6048e5?[2,i.fcmToken]:[2,this.updateToken(e,n,r,i)]:[3,1];case 1:return[4,this.deleteTokenFromDB(i.fcmToken)];case 2:return t.sent(),[2,this.getNewToken(e,n,r)];case 3:return[2]}})})},Wk.prototype.updateToken=function(i,o,a,s){return ya(this,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,6]),[4,this.subscriptionManager.updateToken(s,this.services,o,a)];case 1:return e=t.sent(),n={swScope:i.scope,vapidKey:a,fcmSenderId:this.services.app.options.messagingSenderId,fcmToken:e,createTime:Date.now(),endpoint:o.endpoint,auth:o.getKey("auth"),p256dh:o.getKey("p256dh")},[4,this.tokenDetailsModel.saveTokenDetails(n)];case 2:return t.sent(),[4,this.vapidDetailsModel.saveVapidDetails(i.scope,a)];case 3:return t.sent(),[2,e];case 4:return r=t.sent(),[4,this.deleteToken(s.fcmToken)];case 5:throw t.sent(),r;case 6:return[2]}})})},Wk.prototype.getNewToken=function(r,i,o){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,this.subscriptionManager.getToken(this.services,i,o)];case 1:return e=t.sent(),n={swScope:r.scope,vapidKey:o,fcmSenderId:this.app.options.messagingSenderId,fcmToken:e,createTime:Date.now(),endpoint:i.endpoint,auth:i.getKey("auth"),p256dh:i.getKey("p256dh")},[4,this.tokenDetailsModel.saveTokenDetails(n)];case 2:return t.sent(),[4,this.vapidDetailsModel.saveVapidDetails(r.scope,o)];case 3:return t.sent(),[2,e]}})})},Wk.prototype.deleteToken=function(r){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,this.deleteTokenFromDB(r)];case 1:return t.sent(),[4,this.getSWRegistration_()];case 2:return(e=t.sent())?[4,e.pushManager.getSubscription()]:[3,4];case 3:if(n=t.sent())return[2,n.unsubscribe()];t.label=4;case 4:return[2,!0]}})})},Wk.prototype.deleteTokenFromDB=function(r){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,this.tokenDetailsModel.deleteToken(r)];case 1:e=t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,this.subscriptionManager.deleteToken(this.services,e)];case 3:return t.sent(),[3,5];case 4:return n=t.sent(),console.error(n),[3,5];case 5:return[2]}})})},Wk.prototype.getPushSubscription=function(n,r){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return[4,n.pushManager.getSubscription()];case 1:return(e=t.sent())?[2,e]:[2,n.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r})]}})})},Wk.prototype.requestPermission=function(){throw bk.create("only-available-in-window")},Wk.prototype.useServiceWorker=function(t){throw bk.create("only-available-in-window")},Wk.prototype.usePublicVapidKey=function(t){throw bk.create("only-available-in-window")},Wk.prototype.onMessage=function(t,e,n){throw bk.create("only-available-in-window")},Wk.prototype.onTokenRefresh=function(t,e,n){throw bk.create("only-available-in-window")},Wk.prototype.setBackgroundMessageHandler=function(t){throw bk.create("only-available-in-sw")},Wk.prototype.delete=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return[4,Promise.all([this.tokenDetailsModel.closeDatabase(),this.vapidDetailsModel.closeDatabase()])];case 1:return t.sent(),[2]}})})},Wk.prototype.getNotificationPermission=function(){return Notification.permission},Wk.prototype.requestNotificationPermission=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return Notification.requestPermission?[2,Notification.requestPermission()]:[2,Notification.permission]})})},Wk.prototype.getTokenDetailsModel=function(){return this.tokenDetailsModel},Wk.prototype.getVapidDetailsModel=function(){return this.vapidDetailsModel},Wk.prototype.getSubscriptionManager=function(){return this.subscriptionManager},Wk);function Wk(t){var e=this;this.services=t,this.vapidDetailsModel=new qk,this.subscriptionManager=new Sk;var n=t.app;if(!(this.app=n).options.messagingSenderId||"string"!=typeof n.options.messagingSenderId)throw bk.create("bad-sender-id");this.INTERNAL={delete:function(){return e.delete()}},this.tokenDetailsModel=new Lk(t)}var Kk,Qk="FCM_MSG",Hk=(da(Gk,Kk=jk),Gk.prototype.onPush=function(t){t.waitUntil(this.onPush_(t))},Gk.prototype.onSubChange=function(t){t.waitUntil(this.onSubChange_(t))},Gk.prototype.onNotificationClick=function(t){t.waitUntil(this.onNotificationClick_(t))},Gk.prototype.onPush_=function(s){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){switch(t.label){case 0:if(!s.data)return[2];try{e=s.data.json()}catch(t){return[2]}return[4,this.hasVisibleClients_()];case 1:return t.sent()?[2,this.sendMessageToWindowClients_(e)]:(n=this.getNotificationData_(e))?(r=n.title||"",[4,this.getSWRegistration_()]):[3,3];case 2:return i=t.sent(),o=n.actions,a=Notification.maxActions,o&&a&&o.length>a&&console.warn("This browser only supports "+a+" actions.The remaining actions will not be displayed."),[2,i.showNotification(r,n)];case 3:return this.bgMessageHandler?[4,this.bgMessageHandler(e)]:[3,5];case 4:return t.sent(),[2];case 5:return[2]}})})},Gk.prototype.onSubChange_=function(t){return ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.getSWRegistration_()];case 1:return e=t.sent(),[3,3];case 2:throw n=t.sent(),bk.create("unable-to-resubscribe",{errorInfo:n});case 3:return t.trys.push([3,5,,8]),[4,e.pushManager.getSubscription()];case 4:return t.sent(),[3,8];case 5:return r=t.sent(),[4,this.getTokenDetailsModel().getTokenDetailsFromSWScope(e.scope)];case 6:if(!(i=t.sent()))throw r;return[4,this.deleteToken(i.fcmToken)];case 7:throw t.sent(),r;case 8:return[2]}})})},Gk.prototype.onNotificationClick_=function(o){return ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:if(!(o.notification&&o.notification.data&&o.notification.data[Qk]))return[2];if(o.action)return[2];if(o.stopImmediatePropagation(),o.notification.close(),!(e=o.notification.data[Qk]).notification)return[2];if(!(n=e.fcmOptions&&e.fcmOptions.link||e.notification.click_action)){if(!(e.data&&_k in e.data))return[2];n=self.location.origin}return[4,this.getWindowClient_(n)];case 1:return(r=t.sent())?[3,4]:[4,self.clients.openWindow(n)];case 2:return r=t.sent(),[4,function(e){return new Promise(function(t){setTimeout(t,e)})}(3e3)];case 3:return t.sent(),[3,6];case 4:return[4,r.focus()];case 5:r=t.sent(),t.label=6;case 6:return r?(delete e.notification,delete e.fcmOptions,i=Yk(yk.NOTIFICATION_CLICKED,e),[2,this.attemptToMessageClient_(r,i)]):[2]}})})},Gk.prototype.getNotificationData_=function(t){var e;if(t&&"object"==typeof t.notification){var n=ma({},t.notification);return n.data=ma(ma({},t.notification.data),((e={})[Qk]=t,e)),n}},Gk.prototype.setBackgroundMessageHandler=function(t){if(!t||"function"!=typeof t)throw bk.create("bg-handler-function-expected");this.bgMessageHandler=t},Gk.prototype.getWindowClient_=function(o){return ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:return e=new URL(o,self.location.href).href,[4,zk()];case 1:for(n=t.sent(),r=null,i=0;i<n.length;i++)if(new URL(n[i].url,self.location.href).href===e){r=n[i];break}return[2,r]}})})},Gk.prototype.attemptToMessageClient_=function(e,n){return ya(this,void 0,void 0,function(){return ga(this,function(t){if(!e)throw bk.create("no-window-client-to-msg");return e.postMessage(n),[2]})})},Gk.prototype.hasVisibleClients_=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return[4,zk()];case 1:return[2,t.sent().some(function(t){return"visible"===t.visibilityState&&!t.url.startsWith("chrome-extension://")})]}})})},Gk.prototype.sendMessageToWindowClients_=function(i){return ya(this,void 0,void 0,function(){var e,n,r=this;return ga(this,function(t){switch(t.label){case 0:return[4,zk()];case 1:return e=t.sent(),n=Yk(yk.PUSH_MSG_RECEIVED,i),[4,Promise.all(e.map(function(t){return r.attemptToMessageClient_(t,n)}))];case 2:return t.sent(),[2]}})})},Gk.prototype.getSWRegistration_=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return[2,self.registration]})})},Gk.prototype.getPublicVapidKey_=function(){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,this.getSWRegistration_()];case 1:if(!(e=t.sent()))throw bk.create("sw-registration-expected");return[4,this.getVapidDetailsModel().getVapidFromSWScope(e.scope)];case 2:return null==(n=t.sent())?[2,wk]:[2,n]}})})},Gk);function Gk(t){var e=Kk.call(this,t)||this;return e.bgMessageHandler=null,self.addEventListener("push",function(t){e.onPush(t)}),self.addEventListener("pushsubscriptionchange",function(t){e.onSubChange(t)}),self.addEventListener("notificationclick",function(t){e.onNotificationClick(t)}),e}function zk(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function Yk(t,e){return{firebaseMessagingType:t,firebaseMessagingData:e}}var Xk,Jk=(da($k,Xk=jk),$k.prototype.requestPermission=function(){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return"granted"===Notification.permission?[2]:[4,Notification.requestPermission()];case 1:if("granted"===(e=t.sent()))return[2];throw"denied"===e?bk.create("permission-blocked"):bk.create("permission-default")}})})},$k.prototype.useServiceWorker=function(t){if(!(t instanceof ServiceWorkerRegistration))throw bk.create("sw-registration-expected");if(null!=this.registrationToUse)throw bk.create("use-sw-before-get-token");this.registrationToUse=t},$k.prototype.usePublicVapidKey=function(t){if("string"!=typeof t)throw bk.create("invalid-public-vapid-key");if(null!=this.publicVapidKeyToUse)throw bk.create("use-public-key-before-get-token");var e=kk(t);if(65!==e.length)throw bk.create("public-vapid-key-decryption-failed");this.publicVapidKeyToUse=e},$k.prototype.onMessage=function(t,e,n){return"function"==typeof t?this.onMessageInternal(t,e,n):this.onMessageInternal(t)},$k.prototype.onTokenRefresh=function(t,e,n){return"function"==typeof t?this.onTokenRefreshInternal(t,e,n):this.onTokenRefreshInternal(t)},$k.prototype.waitForRegistrationToActivate_=function(r){var i=r.installing||r.waiting||r.active;return new Promise(function(t,e){if(i)if("activated"!==i.state)if("redundant"!==i.state){var n=function(){if("activated"===i.state)t(r);else{if("redundant"!==i.state)return;e(bk.create("sw-reg-redundant"))}i.removeEventListener("statechange",n)};i.addEventListener("statechange",n)}else e(bk.create("sw-reg-redundant"));else t(r);else e(bk.create("no-sw-in-reg"))})},$k.prototype.getSWRegistration_=function(){var e=this;return this.registrationToUse?this.waitForRegistrationToActivate_(this.registrationToUse):(this.registrationToUse=null,navigator.serviceWorker.register("/firebase-messaging-sw.js",{scope:"/firebase-cloud-messaging-push-scope"}).catch(function(t){throw bk.create("failed-serviceworker-registration",{browserErrorMessage:t.message})}).then(function(t){return e.waitForRegistrationToActivate_(t).then(function(){return(e.registrationToUse=t).update(),t})}))},$k.prototype.getPublicVapidKey_=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){return this.publicVapidKeyToUse?[2,this.publicVapidKeyToUse]:[2,wk]})})},$k.prototype.setupSWMessageListener_=function(){var t=this;navigator.serviceWorker.addEventListener("message",function(a){return ya(t,void 0,void 0,function(){var e,n,r,i,o;return ga(this,function(t){switch(t.label){case 0:return a.data&&a.data.firebaseMessagingType&&a.data.firebaseMessagingData?(e=a.data,n=e.firebaseMessagingType,r=e.firebaseMessagingData,this.messageObserver&&this.messageObserver.next(r),(i=r.data)&&_k in i&&"1"===i["google.c.a.e"]?(o=function(t){switch(t){case yk.NOTIFICATION_CLICKED:return"notification_open";case yk.PUSH_MSG_RECEIVED:return"notification_foreground";default:throw new Error}}(n),[4,this.services.analyticsProvider.get()]):[3,2]):[2];case 1:t.sent().logEvent(o,{message_name:i["google.c.a.c_l"],message_id:i[_k],message_time:i["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)}),t.label=2;case 2:return[2]}})})},!1)},$k);function $k(t){var e=Xk.call(this,t)||this;return e.registrationToUse=null,e.publicVapidKeyToUse=null,e.messageObserver=null,e.tokenRefreshObserver=null,e.onMessageInternal=Ja(function(t){e.messageObserver=t}),e.onTokenRefreshInternal=Ja(function(t){e.tokenRefreshObserver=t}),e.setupSWMessageListener_(),e}var Zk,tD;function eD(){return self&&"ServiceWorkerGlobalScope"in self?"PushManager"in self&&"Notification"in self&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey"):navigator.cookieEnabled&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window&&"fetch"in window&&ServiceWorkerRegistration.prototype.hasOwnProperty("showNotification")&&PushSubscription.prototype.hasOwnProperty("getKey")}tD={isSupported:eD},(Zk=fl).INTERNAL.registerComponent(new as("messaging",function(t){var e={app:t.getProvider("app").getImmediate(),installations:t.getProvider("installations").getImmediate(),analyticsProvider:t.getProvider("analytics-internal")};if(!eD())throw bk.create("unsupported-browser");return self&&"ServiceWorkerGlobalScope"in self?new Hk(e):new Jk(e)},"PUBLIC").setServiceProps(tD)),Zk.registerVersion("@firebase/messaging","0.6.0");var nD="firebasestorage.googleapis.com",rD="storageBucket",iD=(oD.prototype.codeProp=function(){return this.code},oD.prototype.codeEquals=function(t){return sD(t)===this.codeProp()},oD.prototype.serverResponseProp=function(){return this.serverResponse_},oD.prototype.setServerResponseProp=function(t){this.serverResponse_=t},Object.defineProperty(oD.prototype,"name",{get:function(){return this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(oD.prototype,"code",{get:function(){return this.code_},enumerable:!0,configurable:!0}),Object.defineProperty(oD.prototype,"message",{get:function(){return this.message_},enumerable:!0,configurable:!0}),Object.defineProperty(oD.prototype,"serverResponse",{get:function(){return this.serverResponse_},enumerable:!0,configurable:!0}),oD);function oD(t,e){this.code_=sD(t),this.message_="Firebase Storage: "+e,this.serverResponse_=null,this.name_="FirebaseError"}var aD={UNKNOWN:"unknown",OBJECT_NOT_FOUND:"object-not-found",BUCKET_NOT_FOUND:"bucket-not-found",PROJECT_NOT_FOUND:"project-not-found",QUOTA_EXCEEDED:"quota-exceeded",UNAUTHENTICATED:"unauthenticated",UNAUTHORIZED:"unauthorized",RETRY_LIMIT_EXCEEDED:"retry-limit-exceeded",INVALID_CHECKSUM:"invalid-checksum",CANCELED:"canceled",INVALID_EVENT_NAME:"invalid-event-name",INVALID_URL:"invalid-url",INVALID_DEFAULT_BUCKET:"invalid-default-bucket",NO_DEFAULT_BUCKET:"no-default-bucket",CANNOT_SLICE_BLOB:"cannot-slice-blob",SERVER_FILE_WRONG_SIZE:"server-file-wrong-size",NO_DOWNLOAD_URL:"no-download-url",INVALID_ARGUMENT:"invalid-argument",INVALID_ARGUMENT_COUNT:"invalid-argument-count",APP_DELETED:"app-deleted",INVALID_ROOT_OPERATION:"invalid-root-operation",INVALID_FORMAT:"invalid-format",INTERNAL_ERROR:"internal-error"};function sD(t){return"storage/"+t}function uD(){return new iD(aD.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function cD(){return new iD(aD.CANCELED,"User canceled the upload/download.")}function hD(){return new iD(aD.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function lD(t,e,n){return new iD(aD.INVALID_ARGUMENT,"Invalid argument in `"+e+"` at index "+t+": "+n)}function fD(){return new iD(aD.APP_DELETED,"The Firebase app was deleted.")}function pD(t,e){return new iD(aD.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function dD(t){throw new iD(aD.INTERNAL_ERROR,"Internal error: "+t)}var mD={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};function yD(t){switch(t){case mD.RAW:case mD.BASE64:case mD.BASE64URL:case mD.DATA_URL:return;default:throw"Expected one of the event types: ["+mD.RAW+", "+mD.BASE64+", "+mD.BASE64URL+", "+mD.DATA_URL+"]."}}var gD=function(t,e){this.data=t,this.contentType=e||null};function vD(t,e){switch(t){case mD.RAW:return new gD(bD(e));case mD.BASE64:case mD.BASE64URL:return new gD(wD(t,e));case mD.DATA_URL:return new gD(function(t){var e=new _D(t);return e.base64?wD(mD.BASE64,e.rest):function(t){var e;try{e=decodeURIComponent(t)}catch(t){throw pD(mD.DATA_URL,"Malformed data URL.")}return bD(e)}(e.rest)}(e),function(t){return new _D(t).contentType}(e))}throw uD()}function bD(t){for(var e=[],n=0;n<t.length;n++){var r=t.charCodeAt(n);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|63&r);else if(55296==(64512&r))if(n<t.length-1&&56320==(64512&t.charCodeAt(n+1)))r=65536|(1023&r)<<10|1023&t.charCodeAt(++n),e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r);else e.push(239,191,189);else 56320==(64512&r)?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|63&r)}return new Uint8Array(e)}function wD(e,t){switch(e){case mD.BASE64:var n=-1!==t.indexOf("-"),r=-1!==t.indexOf("_");if(n||r)throw pD(e,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case mD.BASE64URL:var i=-1!==t.indexOf("+"),o=-1!==t.indexOf("/");if(i||o)throw pD(e,"Invalid character '"+(i?"+":"/")+"' found: is it base64 encoded?");t=t.replace(/-/g,"+").replace(/_/g,"/")}var a;try{a=atob(t)}catch(t){throw pD(e,"Invalid character found")}for(var s=new Uint8Array(a.length),u=0;u<a.length;u++)s[u]=a.charCodeAt(u);return s}var _D=function(t){this.base64=!1,this.contentType=null;var e=t.match(/^data:([^,]+)?,/);if(null===e)throw pD(mD.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");var n=e[1]||null;null!=n&&(this.base64=function(t,e){return t.length>=e.length&&t.substring(t.length-e.length)===e}(n,";base64"),this.contentType=this.base64?n.substring(0,n.length-";base64".length):n),this.rest=t.substring(t.indexOf(",")+1)};var TD,ED,SD={STATE_CHANGED:"state_changed"},ID="running",CD="pausing",ND="paused",AD="success",kD="canceling",DD="canceled",RD="error",OD={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function PD(t){switch(t){case ID:case CD:case kD:return OD.RUNNING;case ND:return OD.PAUSED;case AD:return OD.SUCCESS;case DD:return OD.CANCELED;case RD:default:return OD.ERROR}}function MD(t){return null!=t}function xD(t){return void 0!==t}function LD(t){return"function"==typeof t}function FD(t){return"object"==typeof t}function UD(t){return"string"==typeof t||t instanceof String}function VD(t){return"number"==typeof t||t instanceof Number}function qD(t){return BD()&&t instanceof Blob}function BD(){return"undefined"!=typeof Blob}(ED=TD=TD||{})[ED.NO_ERROR=0]="NO_ERROR",ED[ED.NETWORK_ERROR=1]="NETWORK_ERROR",ED[ED.ABORT=2]="ABORT";var jD=(WD.prototype.send=function(t,e,n,r){if(this.sent_)throw dD("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(e,t,!0),MD(r))for(var i in r)r.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,r[i].toString());return MD(n)?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_},WD.prototype.getErrorCode=function(){if(!this.sent_)throw dD("cannot .getErrorCode() before sending");return this.errorCode_},WD.prototype.getStatus=function(){if(!this.sent_)throw dD("cannot .getStatus() before sending");try{return this.xhr_.status}catch(t){return-1}},WD.prototype.getResponseText=function(){if(!this.sent_)throw dD("cannot .getResponseText() before sending");return this.xhr_.responseText},WD.prototype.abort=function(){this.xhr_.abort()},WD.prototype.getResponseHeader=function(t){return this.xhr_.getResponseHeader(t)},WD.prototype.addUploadProgressListener=function(t){MD(this.xhr_.upload)&&this.xhr_.upload.addEventListener("progress",t)},WD.prototype.removeUploadProgressListener=function(t){MD(this.xhr_.upload)&&this.xhr_.upload.removeEventListener("progress",t)},WD);function WD(){var e=this;this.sent_=!1,this.xhr_=new XMLHttpRequest,this.errorCode_=TD.NO_ERROR,this.sendPromise_=new Promise(function(t){e.xhr_.addEventListener("abort",function(){e.errorCode_=TD.ABORT,t(e)}),e.xhr_.addEventListener("error",function(){e.errorCode_=TD.NETWORK_ERROR,t(e)}),e.xhr_.addEventListener("load",function(){t(e)})})}var KD=(QD.prototype.createXhrIo=function(){return new jD},QD);function QD(){}function HD(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:void 0;if(void 0!==n){for(var r=new n,i=0;i<t.length;i++)r.append(t[i]);return r.getBlob()}if(BD())return new Blob(t);throw Error("This browser doesn't seem to support creating Blobs")}var GD=(zD.prototype.size=function(){return this.size_},zD.prototype.type=function(){return this.type_},zD.prototype.slice=function(t,e){if(qD(this.data_)){var n=function(t,e,n){return t.webkitSlice?t.webkitSlice(e,n):t.mozSlice?t.mozSlice(e,n):t.slice?t.slice(e,n):null}(this.data_,t,e);return null===n?null:new zD(n)}return new zD(new Uint8Array(this.data_.buffer,t,e-t),!0)},zD.getBlob=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(BD()){var n=t.map(function(t){return t instanceof zD?t.data_:t});return new zD(HD.apply(null,n))}var r=t.map(function(t){return UD(t)?vD(mD.RAW,t).data:t.data_}),i=0;r.forEach(function(t){i+=t.byteLength});var o=new Uint8Array(i),a=0;return r.forEach(function(t){for(var e=0;e<t.length;e++)o[a++]=t[e]}),new zD(o,!0)},zD.prototype.uploadData=function(){return this.data_},zD);function zD(t,e){var n=0,r="";qD(t)?(n=(this.data_=t).size,r=t.type):t instanceof ArrayBuffer?(e?this.data_=new Uint8Array(t):(this.data_=new Uint8Array(t.byteLength),this.data_.set(new Uint8Array(t))),n=this.data_.length):t instanceof Uint8Array&&(e?this.data_=t:(this.data_=new Uint8Array(t.length),this.data_.set(t)),n=t.length),this.size_=n,this.type_=r}var YD=(Object.defineProperty(XD.prototype,"path",{get:function(){return this.path_},enumerable:!0,configurable:!0}),Object.defineProperty(XD.prototype,"isRoot",{get:function(){return 0===this.path.length},enumerable:!0,configurable:!0}),XD.prototype.fullServerUrl=function(){var t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o/"+t(this.path)},XD.prototype.bucketOnlyServerUrl=function(){return"/b/"+encodeURIComponent(this.bucket)+"/o"},XD.makeFromBucketSpec=function(e){var t;try{t=XD.makeFromUrl(e)}catch(t){return new XD(e,"")}if(""===t.path)return t;throw function(t){return new iD(aD.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}(e)},XD.makeFromUrl=function(t){for(var e=null,n="([A-Za-z0-9.\\-_]+)",r=new RegExp("^gs://"+n+"(/(.*))?$","i"),i=nD.replace(/[.]/g,"\\."),o=[{regex:r,indices:{bucket:1,path:3},postModify:function(t){"/"===t.path.charAt(t.path.length-1)&&(t.path_=t.path_.slice(0,-1))}},{regex:new RegExp("^https?://"+i+"/v[A-Za-z0-9_]+/b/"+n+"/o(/([^?#]*).*)?$","i"),indices:{bucket:1,path:3},postModify:function(t){t.path_=decodeURIComponent(t.path)}}],a=0;a<o.length;a++){var s=o[a],u=s.regex.exec(t);if(u){var c=u[s.indices.bucket],h=u[s.indices.path];e=new XD(c,h=h||""),s.postModify(e);break}}if(null==e)throw function(t){return new iD(aD.INVALID_URL,"Invalid URL '"+t+"'.")}(t);return e},XD);function XD(t,e){this.bucket=t,this.path_=e}function JD(t){var e;try{e=JSON.parse(t)}catch(t){return null}return function(t){return FD(t)&&!Array.isArray(t)}(e)?e:null}function $D(t){var e=t.lastIndexOf("/",t.length-2);return-1===e?t:t.slice(e+1)}function ZD(t){return"https://"+nD+"/v0"+t}function tR(t){var e=encodeURIComponent,n="?";for(var r in t){if(t.hasOwnProperty(r))n=n+(e(r)+"="+e(t[r]))+"&"}return n=n.slice(0,-1)}function eR(t,e){return e}var nR=function(t,e,n,r){this.server=t,this.local=e||t,this.writable=!!n,this.xform=r||eR},rR=null;function iR(){if(rR)return rR;var t=[];t.push(new nR("bucket")),t.push(new nR("generation")),t.push(new nR("metageneration")),t.push(new nR("name","fullPath",!0));var e=new nR("name");e.xform=function(t,e){return function(t){return!UD(t)||t.length<2?t:$D(t)}(e)},t.push(e);var n=new nR("size");return n.xform=function(t,e){return MD(e)?Number(e):e},t.push(n),t.push(new nR("timeCreated")),t.push(new nR("updated")),t.push(new nR("md5Hash",null,!0)),t.push(new nR("cacheControl",null,!0)),t.push(new nR("contentDisposition",null,!0)),t.push(new nR("contentEncoding",null,!0)),t.push(new nR("contentLanguage",null,!0)),t.push(new nR("contentType",null,!0)),t.push(new nR("metadata","customMetadata",!0)),rR=t}function oR(r,i){Object.defineProperty(r,"ref",{get:function(){var t=r.bucket,e=r.fullPath,n=new YD(t,e);return i.makeStorageReference(n)}})}function aR(t,e,n){var r=JD(e);return null===r?null:function(t,e,n){for(var r={type:"file"},i=n.length,o=0;o<i;o++){var a=n[o];r[a.local]=a.xform(r,e[a.server])}return oR(r,t),r}(t,r,n)}function sR(t,e){for(var n={},r=e.length,i=0;i<r;i++){var o=e[i];o.writable&&(n[o.server]=t[o.local])}return JSON.stringify(n)}function uR(t){if(!FD(t)||!t)throw"Expected Metadata object.";for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];if("customMetadata"===e){if(!FD(n))throw"Expected object for 'customMetadata' mapping."}else if(FD(r=n)&&null!==r)throw"Mapping for '"+e+"' cannot be an object."}var r}var cR="maxResults",hR=1e3,lR="pageToken",fR="prefixes",pR="items";function dR(t,e){var n={prefixes:[],items:[],nextPageToken:e.nextPageToken},r=t.bucket();if(null===r)throw new iD(aD.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+rD+"' property when initializing the app?");if(e[fR])for(var i=0,o=e[fR];i<o.length;i++){var a=o[i].replace(/\/$/,""),s=t.makeStorageReference(new YD(r,a));n.prefixes.push(s)}if(e[pR])for(var u=0,c=e[pR];u<c.length;u++){var h=c[u];s=t.makeStorageReference(new YD(r,h.name));n.items.push(s)}return n}function mR(t){if(!FD(t)||!t)throw"Expected ListOptions object.";for(var e in t)if(e===cR){if(!VD(n=t[cR])||!Number.isInteger(n)||t[cR]<=0)throw"Expected maxResults to be a positive number.";if(1e3<t[cR])throw"Expected maxResults to be less than or equal to "+hR+"."}else{if(e!==lR)throw"Unknown option: "+e;if(t[lR]&&!UD(t[lR]))throw"Expected pageToken to be string."}var n}var yR=function(t,e,n,r){this.url=t,this.method=e,this.handler=n,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]};function gR(t){if(!t)throw uD()}function vR(r,i){return function(t,e){var n=aR(r,e,i);return gR(null!==n),n}}function bR(r){return function(t,e){var n=function(t,e){var n=JD(e);return null===n?null:dR(t,n)}(r,e);return gR(null!==n),n}}function wR(r,i){return function(t,e){var n=aR(r,e,i);return gR(null!==n),function(r,t){var e=JD(t);if(null===e)return null;if(!UD(e.downloadTokens))return null;var n=e.downloadTokens;if(0===n.length)return null;var i=encodeURIComponent;return n.split(",").map(function(t){var e=r.bucket,n=r.fullPath;return ZD("/b/"+i(e)+"/o/"+i(n))+tR({alt:"media",token:t})})[0]}(n,e)}}function _R(r){return function(t,e){var n;return(n=401===t.getStatus()?new iD(aD.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===t.getStatus()?function(t){return new iD(aD.QUOTA_EXCEEDED,"Quota for bucket '"+t+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}(r.bucket):403===t.getStatus()?function(t){return new iD(aD.UNAUTHORIZED,"User does not have permission to access '"+t+"'.")}(r.path):e).setServerResponseProp(e.serverResponseProp()),n}}function TR(r){var i=_R(r);return function(t,e){var n=i(t,e);return 404===t.getStatus()&&(n=function(t){return new iD(aD.OBJECT_NOT_FOUND,"Object '"+t+"' does not exist.")}(r.path)),n.setServerResponseProp(e.serverResponseProp()),n}}function ER(t,e,n){var r=ZD(e.fullServerUrl()),i=t.maxOperationRetryTime(),o=new yR(r,"GET",vR(t,n),i);return o.errorHandler=TR(e),o}function SR(t,e,n){var r=Object.assign({},n);return r.fullPath=t.path,r.size=e.size(),r.contentType||(r.contentType=function(t,e){return t&&t.contentType||e&&e.type()||"application/octet-stream"}(null,e)),r}function IR(t,e,n,r,i){var o=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};var s=function(){for(var t="",e=0;e<2;e++)t+=Math.random().toString().slice(2);return t}();a["Content-Type"]="multipart/related; boundary="+s;var u=SR(e,r,i),c="--"+s+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+sR(u,n)+"\r\n--"+s+"\r\nContent-Type: "+u.contentType+"\r\n\r\n",h="\r\n--"+s+"--",l=GD.getBlob(c,r,h);if(null===l)throw hD();var f={name:u.fullPath},p=ZD(o),d=t.maxUploadRetryTime(),m=new yR(p,"POST",vR(t,n),d);return m.urlParams=f,m.headers=a,m.body=l.uploadData(),m.errorHandler=_R(e),m}var CR=function(t,e,n,r){this.current=t,this.total=e,this.finalized=!!n,this.metadata=r||null};function NR(t,e){var n=null;try{n=t.getResponseHeader("X-Goog-Upload-Status")}catch(t){gR(!1)}return gR(!!n&&-1!==(e||["active"]).indexOf(n)),n}function AR(t,e,n,r,i){var o=e.bucketOnlyServerUrl(),a=SR(e,r,i),s={name:a.fullPath},u=ZD(o),c={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":r.size(),"X-Goog-Upload-Header-Content-Type":a.contentType,"Content-Type":"application/json; charset=utf-8"},h=sR(a,n),l=t.maxUploadRetryTime();var f=new yR(u,"POST",function(t){var e;NR(t);try{e=t.getResponseHeader("X-Goog-Upload-URL")}catch(t){gR(!1)}return gR(UD(e)),e},l);return f.urlParams=s,f.headers=c,f.body=h,f.errorHandler=_R(e),f}function kR(t,e,n,i){var r=t.maxUploadRetryTime(),o=new yR(n,"POST",function(t){var e=NR(t,["active","final"]),n=null;try{n=t.getResponseHeader("X-Goog-Upload-Size-Received")}catch(t){gR(!1)}n||gR(!1);var r=Number(n);return gR(!isNaN(r)),new CR(r,i.size(),"final"===e)},r);return o.headers={"X-Goog-Upload-Command":"query"},o.errorHandler=_R(e),o}function DR(t,a,e,s,n,u,r,i){var c=new CR(0,0);if(r?(c.current=r.current,c.total=r.total):(c.current=0,c.total=s.size()),s.size()!==c.total)throw new iD(aD.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.");var o=c.total-c.current,h=o;0<n&&(h=Math.min(h,n));var l=c.current,f=l+h,p={"X-Goog-Upload-Command":h===o?"upload, finalize":"upload","X-Goog-Upload-Offset":c.current},d=s.slice(l,f);if(null===d)throw hD();var m=a.maxUploadRetryTime(),y=new yR(e,"POST",function(t,e){var n,r=NR(t,["active","final"]),i=c.current+h,o=s.size();return n="final"===r?vR(a,u)(t,e):null,new CR(i,o,"final"===r,n)},m);return y.headers=p,y.body=d.uploadData(),y.progressCallback=i||null,y.errorHandler=_R(t),y}var RR=function(t,e,n){if(LD(t)||MD(e)||MD(n))this.next=t,this.error=e||null,this.complete=n||null;else{var r=t;this.next=r.next||null,this.error=r.error||null,this.complete=r.complete||null}},OR=function(t,e,n,r,i,o){this.bytesTransferred=t,this.totalBytes=e,this.state=n,this.metadata=r,this.task=i,this.ref=o};function PR(e,t,n){for(var r=t.length,i=t.length,o=0;o<t.length;o++)if(t[o].optional){r=o;break}if(!(r<=n.length&&n.length<=i))throw function(t,e,n,r){var i,o;return o=t===e?1===(i=t)?"argument":"arguments":(i="between "+t+" and "+e,"arguments"),new iD(aD.INVALID_ARGUMENT_COUNT,"Invalid argument count in `"+n+"`: Expected "+i+" "+o+", received "+r+".")}(r,i,e,n.length);for(o=0;o<n.length;o++)try{t[o].validator(n[o])}catch(t){throw t instanceof Error?lD(o,e,t.message):lD(o,e,t)}}var MR=function(e,t){var n=this;this.validator=function(t){n.optional&&!xD(t)||e(t)},this.optional=!!t};function xR(t,e){function n(t){if(!UD(t))throw"Expected string."}var r;return r=t?function(e,n){return function(t){e(t),n(t)}}(n,t):n,new MR(r,e)}function LR(){return new MR(function(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer||BD()&&t instanceof Blob))throw"Expected Blob or File."})}function FR(t){return new MR(uR,t)}function UR(){return new MR(function(t){if(!(VD(t)&&0<=t))throw"Expected a number 0 or greater."})}function VR(e,t){return new MR(function(t){if(!(null===t||MD(t)&&t instanceof Object))throw"Expected an Object.";null!=e&&e(t)},t)}function qR(t){return new MR(function(t){if(!(null===t||LD(t)))throw"Expected a Function."},t)}function BR(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Promise.resolve().then(function(){return n.apply(void 0,t)})}}var jR=(WR.prototype.makeProgressCallback_=function(){var e=this,n=this.transferred_;return function(t){return e.updateProgress_(n+t)}},WR.prototype.shouldDoResumable_=function(t){return 262144<t.size()},WR.prototype.start_=function(){this.state_===ID&&null===this.request_&&(this.resumable_?null===this.uploadUrl_?this.createResumable_():this.needToFetchStatus_?this.fetchStatus_():this.needToFetchMetadata_?this.fetchMetadata_():this.continueUpload_():this.oneShotUpload_())},WR.prototype.resolveToken_=function(e){var n=this;this.authWrapper_.getAuthToken().then(function(t){switch(n.state_){case ID:e(t);break;case kD:n.transition_(DD);break;case CD:n.transition_(ND)}})},WR.prototype.createResumable_=function(){var r=this;this.resolveToken_(function(t){var e=AR(r.authWrapper_,r.location_,r.mappings_,r.blob_,r.metadata_),n=r.authWrapper_.makeRequest(e,t);(r.request_=n).getPromise().then(function(t){r.request_=null,r.uploadUrl_=t,r.needToFetchStatus_=!1,r.completeTransitions_()},r.errorHandler_)})},WR.prototype.fetchStatus_=function(){var r=this,i=this.uploadUrl_;this.resolveToken_(function(t){var e=kR(r.authWrapper_,r.location_,i,r.blob_),n=r.authWrapper_.makeRequest(e,t);(r.request_=n).getPromise().then(function(t){t=t,r.request_=null,r.updateProgress_(t.current),r.needToFetchStatus_=!1,t.finalized&&(r.needToFetchMetadata_=!0),r.completeTransitions_()},r.errorHandler_)})},WR.prototype.continueUpload_=function(){var r=this,i=262144*this.chunkMultiplier_,o=new CR(this.transferred_,this.blob_.size()),a=this.uploadUrl_;this.resolveToken_(function(t){var e;try{e=DR(r.location_,r.authWrapper_,a,r.blob_,i,r.mappings_,o,r.makeProgressCallback_())}catch(t){return r.error_=t,void r.transition_(RD)}var n=r.authWrapper_.makeRequest(e,t);(r.request_=n).getPromise().then(function(t){r.increaseMultiplier_(),r.request_=null,r.updateProgress_(t.current),t.finalized?(r.metadata_=t.metadata,r.transition_(AD)):r.completeTransitions_()},r.errorHandler_)})},WR.prototype.increaseMultiplier_=function(){262144*this.chunkMultiplier_<33554432&&(this.chunkMultiplier_*=2)},WR.prototype.fetchMetadata_=function(){var r=this;this.resolveToken_(function(t){var e=ER(r.authWrapper_,r.location_,r.mappings_),n=r.authWrapper_.makeRequest(e,t);(r.request_=n).getPromise().then(function(t){r.request_=null,r.metadata_=t,r.transition_(AD)},r.metadataErrorHandler_)})},WR.prototype.oneShotUpload_=function(){var r=this;this.resolveToken_(function(t){var e=IR(r.authWrapper_,r.location_,r.mappings_,r.blob_,r.metadata_),n=r.authWrapper_.makeRequest(e,t);(r.request_=n).getPromise().then(function(t){r.request_=null,r.metadata_=t,r.updateProgress_(r.blob_.size()),r.transition_(AD)},r.errorHandler_)})},WR.prototype.updateProgress_=function(t){var e=this.transferred_;this.transferred_=t,this.transferred_!==e&&this.notifyObservers_()},WR.prototype.transition_=function(t){if(this.state_!==t)switch(t){case kD:case CD:this.state_=t,null!==this.request_&&this.request_.cancel();break;case ID:var e=this.state_===ND;this.state_=t,e&&(this.notifyObservers_(),this.start_());break;case ND:this.state_=t,this.notifyObservers_();break;case DD:this.error_=cD(),this.state_=t,this.notifyObservers_();break;case RD:case AD:this.state_=t,this.notifyObservers_()}},WR.prototype.completeTransitions_=function(){switch(this.state_){case CD:this.transition_(ND);break;case kD:this.transition_(DD);break;case ID:this.start_()}},Object.defineProperty(WR.prototype,"snapshot",{get:function(){var t=PD(this.state_);return new OR(this.transferred_,this.blob_.size(),t,this.metadata_,this,this.ref_)},enumerable:!0,configurable:!0}),WR.prototype.on=function(t,e,n,o){var r="Expected a function or an Object with one of `next`, `error`, `complete` properties.",i=qR(!0).validator,a=VR(null,!0).validator;function s(t){try{return void i(t)}catch(t){}try{if(a(t),!(xD(t.next)||xD(t.error)||xD(t.complete)))throw"";return}catch(t){throw r}}PR("on",[xR(function(){if(t!==SD.STATE_CHANGED)throw"Expected one of the event types: ["+SD.STATE_CHANGED+"]."}),VR(s,!0),qR(!0),qR(!0)],arguments);var u=this;function c(i){return function(t,e,n){null!==i&&PR("on",i,arguments);var r=new RR(t,e,o);return u.addObserver_(r),function(){u.removeObserver_(r)}}}var h=[VR(function(t){if(null===t)throw r;s(t)}),qR(!0),qR(!0)];return xD(e)||xD(n)||xD(o)?c(null)(e,n,o):c(h)},WR.prototype.then=function(t,e){return this.promise_.then(t,e)},WR.prototype.catch=function(t){return this.then(null,t)},WR.prototype.addObserver_=function(t){this.observers_.push(t),this.notifyObserver_(t)},WR.prototype.removeObserver_=function(t){var e=this.observers_.indexOf(t);-1!==e&&this.observers_.splice(e,1)},WR.prototype.notifyObservers_=function(){var e=this;this.finishPromise_(),this.observers_.slice().forEach(function(t){e.notifyObserver_(t)})},WR.prototype.finishPromise_=function(){if(null!==this.resolve_){var t=!0;switch(PD(this.state_)){case OD.SUCCESS:BR(this.resolve_.bind(null,this.snapshot))();break;case OD.CANCELED:case OD.ERROR:BR(this.reject_.bind(null,this.error_))();break;default:t=!1}t&&(this.resolve_=null,this.reject_=null)}},WR.prototype.notifyObserver_=function(t){switch(PD(this.state_)){case OD.RUNNING:case OD.PAUSED:t.next&&BR(t.next.bind(t,this.snapshot))();break;case OD.SUCCESS:t.complete&&BR(t.complete.bind(t))();break;case OD.CANCELED:case OD.ERROR:t.error&&BR(t.error.bind(t,this.error_))();break;default:t.error&&BR(t.error.bind(t,this.error_))()}},WR.prototype.resume=function(){PR("resume",[],arguments);var t=this.state_===ND||this.state_===CD;return t&&this.transition_(ID),t},WR.prototype.pause=function(){PR("pause",[],arguments);var t=this.state_===ID;return t&&this.transition_(CD),t},WR.prototype.cancel=function(){PR("cancel",[],arguments);var t=this.state_===ID||this.state_===CD;return t&&this.transition_(kD),t},WR);function WR(t,e,n,r,i,o){var a=this;void 0===o&&(o=null),this.transferred_=0,this.needToFetchStatus_=!1,this.needToFetchMetadata_=!1,this.observers_=[],this.error_=null,this.uploadUrl_=null,this.request_=null,this.chunkMultiplier_=1,this.resolve_=null,this.reject_=null,this.ref_=t,this.authWrapper_=e,this.location_=n,this.blob_=i,this.metadata_=o,this.mappings_=r,this.resumable_=this.shouldDoResumable_(this.blob_),this.state_=ID,this.errorHandler_=function(t){a.request_=null,a.chunkMultiplier_=1,t.codeEquals(aD.CANCELED)?(a.needToFetchStatus_=!0,a.completeTransitions_()):(a.error_=t,a.transition_(RD))},this.metadataErrorHandler_=function(t){a.request_=null,t.codeEquals(aD.CANCELED)?a.completeTransitions_():(a.error_=t,a.transition_(RD))},this.promise_=new Promise(function(t,e){a.resolve_=t,a.reject_=e,a.start_()}),this.promise_.then(null,function(){})}var KR=(QR.prototype.toString=function(){return PR("toString",[],arguments),"gs://"+this.location.bucket+"/"+this.location.path},QR.prototype.newRef=function(t,e){return new QR(t,e)},QR.prototype.mappings=function(){return iR()},QR.prototype.child=function(t){PR("child",[xR()],arguments);var e=function(t,e){var n=e.split("/").filter(function(t){return 0<t.length}).join("/");return 0===t.length?n:t+"/"+n}(this.location.path,t),n=new YD(this.location.bucket,e);return this.newRef(this.authWrapper,n)},Object.defineProperty(QR.prototype,"parent",{get:function(){var t=function(t){if(0===t.length)return null;var e=t.lastIndexOf("/");return-1===e?"":t.slice(0,e)}(this.location.path);if(null===t)return null;var e=new YD(this.location.bucket,t);return this.newRef(this.authWrapper,e)},enumerable:!0,configurable:!0}),Object.defineProperty(QR.prototype,"root",{get:function(){var t=new YD(this.location.bucket,"");return this.newRef(this.authWrapper,t)},enumerable:!0,configurable:!0}),Object.defineProperty(QR.prototype,"bucket",{get:function(){return this.location.bucket},enumerable:!0,configurable:!0}),Object.defineProperty(QR.prototype,"fullPath",{get:function(){return this.location.path},enumerable:!0,configurable:!0}),Object.defineProperty(QR.prototype,"name",{get:function(){return $D(this.location.path)},enumerable:!0,configurable:!0}),Object.defineProperty(QR.prototype,"storage",{get:function(){return this.authWrapper.service()},enumerable:!0,configurable:!0}),QR.prototype.put=function(t,e){return void 0===e&&(e=null),PR("put",[LR(),FR(!0)],arguments),this.throwIfRoot_("put"),new jR(this,this.authWrapper,this.location,this.mappings(),new GD(t),e)},QR.prototype.putString=function(t,e,n){void 0===e&&(e=mD.RAW),PR("putString",[xR(),xR(yD,!0),FR(!0)],arguments),this.throwIfRoot_("putString");var r=vD(e,t),i=Object.assign({},n);return!MD(i.contentType)&&MD(r.contentType)&&(i.contentType=r.contentType),new jR(this,this.authWrapper,this.location,this.mappings(),new GD(r.data,!0),i)},QR.prototype.delete=function(){var n=this;return PR("delete",[],arguments),this.throwIfRoot_("delete"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e){var n=ZD(e.fullServerUrl()),r=t.maxOperationRetryTime(),i=new yR(n,"DELETE",function(t,e){},r);return i.successCodes=[200,204],i.errorHandler=TR(e),i}(n.authWrapper,n.location);return n.authWrapper.makeRequest(e,t).getPromise()})},QR.prototype.listAll=function(){PR("listAll",[],arguments);var t={prefixes:[],items:[]};return this.listAllHelper(t).then(function(){return t})},QR.prototype.listAllHelper=function(o,a){return ya(this,void 0,void 0,function(){var e,n,r,i;return ga(this,function(t){switch(t.label){case 0:return e={pageToken:a},[4,this.list(e)];case 1:return n=t.sent(),(r=o.prefixes).push.apply(r,n.prefixes),(i=o.items).push.apply(i,n.items),null==n.nextPageToken?[3,3]:[4,this.listAllHelper(o,n.nextPageToken)];case 2:t.sent(),t.label=3;case 3:return[2]}})})},QR.prototype.list=function(r){PR("list",[function(t){return new MR(mR,t)}(!0)],arguments);var i=this;return this.authWrapper.getAuthToken().then(function(t){var e=r||{},n=function(t,e,n,r,i){var o={};e.isRoot?o.prefix="":o.prefix=e.path+"/",n&&0<n.length&&(o.delimiter=n),r&&(o.pageToken=r),i&&(o.maxResults=i);var a=ZD(e.bucketOnlyServerUrl()),s=t.maxOperationRetryTime(),u=new yR(a,"GET",bR(t),s);return u.urlParams=o,u.errorHandler=_R(e),u}(i.authWrapper,i.location,"/",e.pageToken,e.maxResults);return i.authWrapper.makeRequest(n,t).getPromise()})},QR.prototype.getMetadata=function(){var n=this;return PR("getMetadata",[],arguments),this.throwIfRoot_("getMetadata"),this.authWrapper.getAuthToken().then(function(t){var e=ER(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(e,t).getPromise()})},QR.prototype.updateMetadata=function(n){var r=this;return PR("updateMetadata",[FR()],arguments),this.throwIfRoot_("updateMetadata"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e,n,r){var i=ZD(e.fullServerUrl()),o=sR(n,r),a=t.maxOperationRetryTime(),s=new yR(i,"PATCH",vR(t,r),a);return s.headers={"Content-Type":"application/json; charset=utf-8"},s.body=o,s.errorHandler=TR(e),s}(r.authWrapper,r.location,n,r.mappings());return r.authWrapper.makeRequest(e,t).getPromise()})},QR.prototype.getDownloadURL=function(){var n=this;return PR("getDownloadURL",[],arguments),this.throwIfRoot_("getDownloadURL"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e,n){var r=ZD(e.fullServerUrl()),i=t.maxOperationRetryTime(),o=new yR(r,"GET",wR(t,n),i);return o.errorHandler=TR(e),o}(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(e,t).getPromise().then(function(t){if(null===t)throw new iD(aD.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return t})})},QR.prototype.throwIfRoot_=function(t){if(""===this.location.path)throw function(t){return new iD(aD.INVALID_ROOT_OPERATION,"The operation '"+t+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}(t)},QR);function QR(t,e){this.authWrapper=t,this.location=e instanceof YD?e:YD.makeFromUrl(e)}var HR=(GR.prototype.getPromise=function(){return this.promise_},GR.prototype.cancel=function(t){},GR);function GR(t){this.promise_=Promise.reject(t)}var zR=(YR.prototype.addRequest=function(t){var e=this,n=this.id;this.id++,this.map.set(n,t),t.getPromise().then(function(){return e.map.delete(n)},function(){return e.map.delete(n)})},YR.prototype.clear=function(){this.map.forEach(function(t){t&&t.cancel(!0)}),this.map.clear()},YR);function YR(){this.map=new Map,this.id=-9007199254740991}var XR=(JR.extractBucket_=function(t){var e=t[rD]||null;return null==e?null:YD.makeFromBucketSpec(e).bucket},JR.prototype.getAuthToken=function(){var t=this.authProvider_.getImmediate({optional:!0});return t?t.getToken().then(function(t){return null!==t?t.accessToken:null},function(){return null}):Promise.resolve(null)},JR.prototype.bucket=function(){if(this.deleted_)throw fD();return this.bucket_},JR.prototype.service=function(){return this.service_},JR.prototype.makeStorageReference=function(t){return this.storageRefMaker_(this,t)},JR.prototype.makeRequest=function(t,e){if(this.deleted_)return new HR(fD());var n=this.requestMaker_(t,e,this.pool_);return this.requestMap_.addRequest(n),n},JR.prototype.deleteApp=function(){this.deleted_=!0,this.app_=null,this.requestMap_.clear()},JR.prototype.maxUploadRetryTime=function(){return this.maxUploadRetryTime_},JR.prototype.setMaxUploadRetryTime=function(t){this.maxUploadRetryTime_=t},JR.prototype.maxOperationRetryTime=function(){return this.maxOperationRetryTime_},JR.prototype.setMaxOperationRetryTime=function(t){this.maxOperationRetryTime_=t},JR);function JR(t,e,n,r,i,o){if(this.bucket_=null,this.deleted_=!1,this.app_=t,null!==this.app_){var a=this.app_.options;MD(a)&&(this.bucket_=JR.extractBucket_(a))}this.authProvider_=e,this.storageRefMaker_=n,this.requestMaker_=r,this.pool_=o,this.service_=i,this.maxOperationRetryTime_=12e4,this.maxUploadRetryTime_=6e5,this.requestMap_=new zR}var $R=(ZR.prototype.start_=function(){var s=this;function t(t,e){var n,r=s.resolve_,i=s.reject_,o=e.xhr;if(e.wasSuccessCode)try{var a=s.callback_(o,o.getResponseText());xD(a)?r(a):r()}catch(t){i(t)}else null!==o?((n=uD()).setServerResponseProp(o.getResponseText()),s.errorCallback_?i(s.errorCallback_(o,n)):i(n)):e.canceled?i(n=s.appDelete_?fD():cD()):i(n=new iD(aD.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again."))}this.canceled_?t(0,new tO(!1,null,!0)):this.backoffId_=function(e,n,t){var r=1,i=null,o=!1,a=0;function s(){return 2===a}var u=!1;function c(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];u||(u=!0,n.apply(null,t))}function h(t){i=setTimeout(function(){i=null,e(l,s())},t)}function l(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];u||(t?c.call.apply(c,_a([null,t],e)):s()||o?c.call.apply(c,_a([null,t],e)):(r<64&&(r*=2),h(1===a?(a=2,0):1e3*(r+Math.random()))))}var f=!1;function p(t){f||(f=!0,u||(null!==i?(t||(a=2),clearTimeout(i),h(0)):t||(a=1)))}return h(0),setTimeout(function(){p(o=!0)},t),p}(function(o,t){if(t)o(!1,new tO(!1,null,!0));else{var e=s.pool_.createXhrIo();s.pendingXhr_=e,null!==s.progressCallback_&&e.addUploadProgressListener(a),e.send(s.url_,s.method_,s.body_,s.headers_).then(function(t){null!==s.progressCallback_&&t.removeUploadProgressListener(a),s.pendingXhr_=null;var e=(t=t).getErrorCode()===TD.NO_ERROR,n=t.getStatus();if(e&&!s.isRetryStatusCode_(n)){var r=-1!==s.successCodes_.indexOf(n);o(!0,new tO(r,t))}else{var i=t.getErrorCode()===TD.ABORT;o(!1,new tO(!1,null,i))}})}function a(t){var e=t.loaded,n=t.lengthComputable?t.total:-1;null!==s.progressCallback_&&s.progressCallback_(e,n)}},t,this.timeout_)},ZR.prototype.getPromise=function(){return this.promise_},ZR.prototype.cancel=function(t){this.canceled_=!0,this.appDelete_=t||!1,null!==this.backoffId_&&function(t){t(!1)}(this.backoffId_),null!==this.pendingXhr_&&this.pendingXhr_.abort()},ZR.prototype.isRetryStatusCode_=function(t){var e=500<=t&&t<600,n=-1!==[408,429].indexOf(t),r=-1!==this.additionalRetryCodes_.indexOf(t);return e||n||r},ZR);function ZR(t,e,n,r,i,o,a,s,u,c,h){var l=this;this.pendingXhr_=null,this.backoffId_=null,this.resolve_=null,this.reject_=null,this.canceled_=!1,this.appDelete_=!1,this.url_=t,this.method_=e,this.headers_=n,this.body_=r,this.successCodes_=i.slice(),this.additionalRetryCodes_=o.slice(),this.callback_=a,this.errorCallback_=s,this.progressCallback_=c,this.timeout_=u,this.pool_=h,this.promise_=new Promise(function(t,e){l.resolve_=t,l.reject_=e,l.start_()})}var tO=function(t,e,n){this.wasSuccessCode=t,this.xhr=e,this.canceled=!!n};function eO(t,e,n){var r=tR(t.urlParams),i=t.url+r,o=Object.assign({},t.headers);return function(t,e){null!==e&&0<e.length&&(t.Authorization="Firebase "+e)}(o,e),function(t){var e=void 0!==fl?fl.SDK_VERSION:"AppManager";t["X-Firebase-Storage-Version"]="webjs/"+e}(o),new $R(i,t.method,o,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,n)}var nO=(rO.prototype.ref=function(t){if(PR("ref",[xR(function(t){if("string"!=typeof t)throw"Path is not a string.";if(/^[A-Za-z]+:\/\//.test(t))throw"Expected child path but got a URL, use refFromURL instead."},!0)],arguments),null==this.bucket_)throw new Error("No Storage Bucket defined in Firebase Options.");var e=new KR(this.authWrapper_,this.bucket_);return null!=t?e.child(t):e},rO.prototype.refFromURL=function(t){return PR("refFromURL",[xR(function(t){if("string"!=typeof t)throw"Path is not a string.";if(!/^[A-Za-z]+:\/\//.test(t))throw"Expected full URL but got a child path, use ref instead.";try{YD.makeFromUrl(t)}catch(t){throw"Expected valid full URL but got an invalid one."}},!1)],arguments),new KR(this.authWrapper_,t)},Object.defineProperty(rO.prototype,"maxUploadRetryTime",{get:function(){return this.authWrapper_.maxUploadRetryTime()},enumerable:!0,configurable:!0}),rO.prototype.setMaxUploadRetryTime=function(t){PR("setMaxUploadRetryTime",[UR()],arguments),this.authWrapper_.setMaxUploadRetryTime(t)},rO.prototype.setMaxOperationRetryTime=function(t){PR("setMaxOperationRetryTime",[UR()],arguments),this.authWrapper_.setMaxOperationRetryTime(t)},Object.defineProperty(rO.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),Object.defineProperty(rO.prototype,"INTERNAL",{get:function(){return this.internals_},enumerable:!0,configurable:!0}),rO);function rO(t,e,n,r){if(this.bucket_=null,this.authWrapper_=new XR(t,e,function(t,e){return new KR(t,e)},eO,this,n),this.app_=t,null!=r)this.bucket_=YD.makeFromBucketSpec(r);else{var i=this.authWrapper_.bucket();null!=i&&(this.bucket_=new YD(i,""))}this.internals_=new iO(this)}var iO=(oO.prototype.delete=function(){return this.service_.authWrapper_.deleteApp(),Promise.resolve()},oO);function oO(t){this.service_=t}var aO,sO;function uO(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("auth-internal");return new nO(n,r,new KD,e)}sO={TaskState:OD,TaskEvent:SD,StringFormat:mD,Storage:nO,Reference:KR},(aO=fl).INTERNAL.registerComponent(new as("storage",uO,"PUBLIC").setServiceProps(sO).setMultipleInstances(!0)),aO.registerVersion("@firebase/storage","0.3.22");var cO,hO,lO,fO,pO="0.2.28",dO="FB-PERF-TRACE-MEASURE",mO="@firebase/performance/config",yO="@firebase/performance/configexpire",gO="Performance",vO=((cO={})["trace started"]="Trace {$traceName} was started before.",cO["trace stopped"]="Trace {$traceName} is not running.",cO["no window"]="Window is not available.",cO["no app id"]="App id is not available.",cO["no project id"]="Project id is not available.",cO["no api key"]="Api key is not available.",cO["invalid cc log"]="Attempted to queue invalid cc event",cO["FB not default"]="Performance can only start when Firebase app instance is the default one.",cO["RC response not ok"]="RC response is not ok",cO["invalid attribute name"]="Attribute name {$attributeName} is invalid.",cO["invalid attribute value"]="Attribute value {$attributeValue} is invalid.",cO["invalide custom metric name"]="Custom metric name {$customMetricName} is invalid",cO),bO=new Va("performance",gO,vO),wO=(_O.prototype.getUrl=function(){return this.windowLocation.href.split("?")[0]},_O.prototype.mark=function(t){this.performance&&this.performance.mark&&this.performance.mark(t)},_O.prototype.measure=function(t,e,n){this.performance&&this.performance.measure&&this.performance.measure(t,e,n)},_O.prototype.getEntriesByType=function(t){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(t):[]},_O.prototype.getEntriesByName=function(t){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(t):[]},_O.prototype.getTimeOrigin=function(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)},_O.prototype.requiredApisAvailable=function(){return!!(fetch&&Promise&&this.navigator&&this.navigator.cookieEnabled)},_O.prototype.setupObserver=function(t,i){this.PerformanceObserver&&new this.PerformanceObserver(function(t){for(var e=0,n=t.getEntries();e<n.length;e++){var r=n[e];i(r)}}).observe({entryTypes:[t]})},_O.getInstance=function(){return void 0===hO&&(hO=new _O(lO)),hO},_O);function _O(t){if(!(this.window=t))throw bO.create("no window");this.performance=t.performance,this.PerformanceObserver=t.PerformanceObserver,this.windowLocation=t.location,this.navigator=t.navigator,this.document=t.document,this.navigator&&this.navigator.cookieEnabled&&(this.localStorage=t.localStorage),t.perfMetrics&&t.perfMetrics.onFirstInputDelay&&(this.onFirstInputDelay=t.perfMetrics.onFirstInputDelay)}var TO,EO,SO,IO=(CO.prototype.getAppId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.appId;if(!t)throw bO.create("no app id");return t},CO.prototype.getProjectId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.projectId;if(!t)throw bO.create("no project id");return t},CO.prototype.getApiKey=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.apiKey;if(!t)throw bO.create("no api key");return t},CO.getInstance=function(){return void 0===fO&&(fO=new CO),fO},CO);function CO(){this.instrumentationEnabled=!0,this.dataCollectionEnabled=!0,this.loggingEnabled=!1,this.tracesSamplingRate=1,this.networkRequestsSamplingRate=1,this.logEndPointUrl="https://firebaselogging.googleapis.com/v0cc/log?format=json_proto",this.logSource=462,this.logTraceAfterSampling=!1,this.logNetworkAfterSampling=!1,this.configTimeToLive=12}function NO(){return TO}(SO=EO=EO||{})[SO.UNKNOWN=0]="UNKNOWN",SO[SO.VISIBLE=1]="VISIBLE",SO[SO.HIDDEN=2]="HIDDEN";var AO=["firebase_","google_","ga_"],kO=new RegExp("^[a-zA-Z]\\w*$");function DO(){switch(wO.getInstance().document.visibilityState){case"visible":return EO.VISIBLE;case"hidden":return EO.HIDDEN;default:return EO.UNKNOWN}}var RO=new bs(gO);RO.logLevel=ls.INFO;var OO="0.0.1",PO={loggingEnabled:!0},MO="FIREBASE_INSTALLATIONS_AUTH";function xO(t){var e=function(){var t=wO.getInstance().localStorage;if(!t)return;var e=t.getItem(yO);if(!e||!function(t){return Number(t)>Date.now()}(e))return;var n=t.getItem(mO);if(!n)return;try{return JSON.parse(n)}catch(t){return}}();return e?(FO(e),Promise.resolve()):function(r){return function(){var t=IO.getInstance().installationsService.getToken();return t.then(function(t){}),t}().then(function(t){var e="https://firebaseremoteconfig.googleapis.com/v1/projects/"+IO.getInstance().getProjectId()+"/namespaces/fireperf:fetch?key="+IO.getInstance().getApiKey(),n=new Request(e,{method:"POST",headers:{Authorization:MO+" "+t},body:JSON.stringify({app_instance_id:r,app_instance_id_token:t,app_id:IO.getInstance().getAppId(),app_version:pO,sdk_version:OO})});return fetch(n).then(function(t){if(t.ok)return t.json();throw bO.create("RC response not ok")})}).catch(function(){RO.info(LO)})}(t).then(function(t){return FO(t)}).then(function(t){return function(t){var e=wO.getInstance().localStorage;if(!t||!e)return;e.setItem(mO,JSON.stringify(t)),e.setItem(yO,String(Date.now()+60*IO.getInstance().configTimeToLive*60*1e3))}(t)},function(){})}var LO="Could not fetch config, will use default configs";function FO(t){if(!t)return t;var e=IO.getInstance(),n=t.entries||{};return void 0!==n.fpr_enabled?e.loggingEnabled="true"===String(n.fpr_enabled):e.loggingEnabled=PO.loggingEnabled,n.fpr_log_source&&(e.logSource=Number(n.fpr_log_source)),n.fpr_log_endpoint_url&&(e.logEndPointUrl=n.fpr_log_endpoint_url),void 0!==n.fpr_vc_network_request_sampling_rate&&(e.networkRequestsSamplingRate=Number(n.fpr_vc_network_request_sampling_rate)),void 0!==n.fpr_vc_trace_sampling_rate&&(e.tracesSamplingRate=Number(n.fpr_vc_trace_sampling_rate)),e.logTraceAfterSampling=UO(e.tracesSamplingRate),e.logNetworkAfterSampling=UO(e.networkRequestsSamplingRate),t}function UO(t){return Math.random()<=t}var VO,qO=1;function BO(){return qO=2,VO=VO||function(){var n=wO.getInstance().document;return new Promise(function(t){if(n&&"complete"!==n.readyState){var e=function(){"complete"===n.readyState&&(n.removeEventListener("readystatechange",e),t())};n.addEventListener("readystatechange",e)}else t()})}().then(function(){return function(){var t=IO.getInstance().installationsService.getId();return t.then(function(t){TO=t}),t}()}).then(function(t){return xO(t)}).then(function(){return jO()},function(){return jO()})}function jO(){qO=3}var WO,KO=1e4,QO=3,HO=QO,GO=[];function zO(i){return function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];!function(t){if(!t.eventTime||!t.message)throw bO.create("invalid cc log");GO=_a(GO,[t])}({message:i.apply(void 0,n),eventTime:Date.now()})}}function YO(){if(WO)return WO;var t=zO($O);return(WO=new bs("@firebase/performance/cc")).logHandler=t,WO}function XO(t){var e=IO.getInstance();!e.instrumentationEnabled&&t.isAuto||(e.dataCollectionEnabled||t.isAuto)&&wO.getInstance().requiredApisAvailable()&&(t.isAuto&&DO()!==EO.VISIBLE||e.loggingEnabled&&e.logTraceAfterSampling&&(3===qO?JO(t):BO().then(function(){return JO(t)},function(){return JO(t)})))}function JO(t){NO()&&setTimeout(function(){return YO().log(t,1)},0)}function $O(t,e){return 0===e?function(t){var e={url:t.url,http_method:t.httpMethod||0,http_response_code:200,response_payload_bytes:t.responsePayloadBytes,client_start_time_us:t.startTimeUs,time_to_response_initiated_us:t.timeToResponseInitiatedUs,time_to_response_completed_us:t.timeToResponseCompletedUs},n={application_info:ZO(),network_request_metric:e};return JSON.stringify(n)}(t):function(t){var e={name:t.name,is_auto:t.isAuto,client_start_time_us:t.startTimeUs,duration_us:t.durationUs};0!==Object.keys(t.counters).length&&(e.counters=tP(t.counters));var n=t.getAttributes();0!==Object.keys(n).length&&(e.custom_attributes=tP(n));var r={application_info:ZO(),trace_metric:e};return JSON.stringify(r)}(t)}function ZO(){return{google_app_id:IO.getInstance().getAppId(),app_instance_id:NO(),web_app_info:{sdk_version:pO,page_url:wO.getInstance().getUrl(),service_worker_status:function(){var t=wO.getInstance().navigator;return"serviceWorker"in t?t.serviceWorker.controller?2:3:1}(),visibility_state:DO(),effective_connection_type:function(){var t=wO.getInstance().navigator.connection;switch(t&&t.effectiveType){case"slow-2g":return 1;case"2g":return 2;case"3g":return 3;case"4g":return 4;default:return 0}}()},application_process_state:0}}function tP(e){return Object.keys(e).map(function(t){return{key:t,value:e[t]}})}!function r(t){setTimeout(function(){if(0!==HO){if(!GO.length)return r(KO);var t=_a(GO);GO=[];var e=t.map(function(t){return{source_extension_json:t.message,event_time_ms:String(t.eventTime)}}),n={request_time_ms:String(Date.now()),client_info:{client_type:1,js_client_info:{}},log_source:IO.getInstance().logSource,log_event:e};fetch(IO.getInstance().logEndPointUrl,{method:"POST",body:JSON.stringify(n)}).then(function(t){return t.ok||RO.info("Call to Firebase backend failed."),t.json()}).then(function(t){var e=Number(t.next_request_wait_millis),n=isNaN(e)?KO:Math.max(KO,e);HO=QO,r(n)}).catch(function(){GO=_a(t,GO),HO--,RO.info("Tries left: "+HO+"."),r(KO)})}},t)}(5500);var eP=["_fp","_fcp","_fid"];var nP=(rP.prototype.start=function(){if(1!==this.state)throw bO.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2},rP.prototype.stop=function(){if(2!==this.state)throw bO.create("trace stopped",{traceName:this.name});this.state=3,this.api.mark(this.traceStopMark),this.api.measure(this.traceMeasure,this.traceStartMark,this.traceStopMark),this.calculateTraceMetrics(),XO(this)},rP.prototype.record=function(t,e,n){if(this.durationUs=Math.floor(1e3*e),this.startTimeUs=Math.floor(1e3*t),n&&n.attributes&&(this.customAttributes=ma({},n.attributes)),n&&n.metrics)for(var r=0,i=Object.keys(n.metrics);r<i.length;r++){var o=i[r];isNaN(Number(n.metrics[o]))||(this.counters[o]=Number(Math.floor(n.metrics[o])))}XO(this)},rP.prototype.incrementMetric=function(t,e){void 0===e&&(e=1),void 0===this.counters[t]&&this.putMetric(t,0),this.counters[t]+=e},rP.prototype.putMetric=function(t,e){if(!function(t,e){return!(0===t.length||100<t.length)&&(e&&e.startsWith("_wt_")&&-1<eP.indexOf(t)||!t.startsWith("_"))}(t,this.name))throw bO.create("invalide custom metric name",{customMetricName:t});this.counters[t]=e},rP.prototype.getMetric=function(t){return this.counters[t]||0},rP.prototype.putAttribute=function(t,e){var n=function(e){return!(0===e.length||40<e.length||AO.some(function(t){return e.startsWith(t)})||!e.match(kO))}(t),r=function(t){return 0!==t.length&&t.length<=100}(e);if(n&&r)this.customAttributes[t]=e;else{if(!n)throw bO.create("invalid attribute name",{attributeName:t});if(!r)throw bO.create("invalid attribute value",{attributeValue:e})}},rP.prototype.getAttribute=function(t){return this.customAttributes[t]},rP.prototype.removeAttribute=function(t){void 0!==this.customAttributes[t]&&delete this.customAttributes[t]},rP.prototype.getAttributes=function(){return ma({},this.customAttributes)},rP.prototype.setStartTime=function(t){this.startTimeUs=t},rP.prototype.setDuration=function(t){this.durationUs=t},rP.prototype.calculateTraceMetrics=function(){var t=this.api.getEntriesByName(this.traceMeasure),e=t&&t[0];e&&(this.durationUs=Math.floor(1e3*e.duration),this.startTimeUs=Math.floor(1e3*(e.startTime+this.api.getTimeOrigin())))},rP.createOobTrace=function(t,e,n){var r=wO.getInstance().getUrl();if(r){var i=new rP("_wt_"+r,!0),o=Math.floor(1e3*wO.getInstance().getTimeOrigin());if(i.setStartTime(o),t&&t[0]&&(i.setDuration(Math.floor(1e3*t[0].duration)),i.putMetric("domInteractive",Math.floor(1e3*t[0].domInteractive)),i.putMetric("domContentLoadedEventEnd",Math.floor(1e3*t[0].domContentLoadedEventEnd)),i.putMetric("loadEventEnd",Math.floor(1e3*t[0].loadEventEnd))),e){var a=e.find(function(t){return"first-paint"===t.name});a&&a.startTime&&i.putMetric("_fp",Math.floor(1e3*a.startTime));var s=e.find(function(t){return"first-contentful-paint"===t.name});s&&s.startTime&&i.putMetric("_fcp",Math.floor(1e3*s.startTime)),n&&i.putMetric("_fid",Math.floor(1e3*n))}XO(i)}},rP.createUserTimingTrace=function(t){XO(new rP(t,!1,t))},rP);function rP(t,e,n){void 0===e&&(e=!1),this.name=t,this.isAuto=e,this.state=1,this.customAttributes={},this.counters={},this.api=wO.getInstance(),this.randomId=Math.floor(1e6*Math.random()),this.isAuto||(this.traceStartMark="FB-PERF-TRACE-START-"+this.randomId+"-"+this.name,this.traceStopMark="FB-PERF-TRACE-STOP-"+this.randomId+"-"+this.name,this.traceMeasure=n||dO+"-"+this.randomId+"-"+this.name,n&&this.calculateTraceMetrics())}function iP(t){var e=t;if(e&&void 0!==e.responseStart){var n=wO.getInstance().getTimeOrigin(),r=Math.floor(1e3*(e.startTime+n)),i=e.responseStart?Math.floor(1e3*(e.responseStart-e.startTime)):void 0,o=Math.floor(1e3*(e.responseEnd-e.startTime));!function(t){var e=IO.getInstance();e.instrumentationEnabled&&t.url!==e.logEndPointUrl.split("?")[0]&&e.loggingEnabled&&e.logNetworkAfterSampling&&setTimeout(function(){return YO().log(t,0)},0)}({url:e.name&&e.name.split("?")[0],responsePayloadBytes:e.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:o})}}var oP=5e3;function aP(){NO()&&(setTimeout(function(){return function(){var t=wO.getInstance(),e=t.getEntriesByType("navigation"),n=t.getEntriesByType("paint");if(t.onFirstInputDelay){var r=setTimeout(function(){nP.createOobTrace(e,n),r=void 0},oP);t.onFirstInputDelay(function(t){r&&(clearTimeout(r),nP.createOobTrace(e,n,t))})}else nP.createOobTrace(e,n)}()},0),setTimeout(function(){return function(){for(var t=wO.getInstance(),e=t.getEntriesByType("resource"),n=0,r=e;n<r.length;n++){iP(r[n])}t.setupObserver("resource",iP)}()},0),setTimeout(function(){return function(){for(var t=wO.getInstance(),e=t.getEntriesByType("measure"),n=0,r=e;n<r.length;n++){sP(r[n])}t.setupObserver("measure",sP)}()},0))}function sP(t){var e=t.name;e.substring(0,dO.length)!==dO&&nP.createUserTimingTrace(e)}var uP=(cP.prototype.trace=function(t){return new nP(t)},Object.defineProperty(cP.prototype,"instrumentationEnabled",{get:function(){return IO.getInstance().instrumentationEnabled},set:function(t){IO.getInstance().instrumentationEnabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(cP.prototype,"dataCollectionEnabled",{get:function(){return IO.getInstance().dataCollectionEnabled},set:function(t){IO.getInstance().dataCollectionEnabled=t},enumerable:!0,configurable:!0}),cP);function cP(t){this.app=t,wO.getInstance().requiredApisAvailable()?BO().then(aP,aP):RO.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.")}var hP;function lP(t,e){if("[DEFAULT]"!==t.name)throw bO.create("FB not default");if("undefined"==typeof window)throw bO.create("no window");return function(t){lO=t}(window),IO.getInstance().firebaseAppInstance=t,IO.getInstance().installationsService=e,new uP(t)}(hP=fl).INTERNAL.registerComponent(new as("performance",function(t){var e=t.getProvider("app").getImmediate(),n=t.getProvider("installations").getImmediate();return lP(e,n)},"PUBLIC")),hP.registerVersion("@firebase/performance","0.2.28");var fP,pP,dP,mP,yP,gP="measurementId",vP="firebase_id",bP="origin",wP="https://www.googletagmanager.com/gtag/js";function _P(t,n,e){var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];window[n].push(arguments)};return window[e]&&"function"==typeof window[e]&&(r=window[e]),window[e]=function(f,p){return function(t,e,n){if(t===fP.EVENT){var r=[];if(n&&n.send_to){var i=n.send_to;Array.isArray(i)||(i=[i]);for(var o=0,a=i;o<a.length;o++){var s=a[o],u=p[s];if(!u){r=[];break}r.push(u)}}if(0===r.length)for(var c=0,h=Object.values(p);c<h.length;c++){var l=h[c];r.push(l)}Promise.all(r).then(function(){return f(fP.EVENT,e,n||{})}).catch(function(t){return console.error(t)})}else if(t===fP.CONFIG){(p[e]||Promise.resolve()).then(function(){f(fP.CONFIG,e,n)}).catch(function(t){return console.error(t)})}else f(fP.SET,e)}}(r,t),{gtagCore:r,wrappedGtag:window[e]}}(pP=fP=fP||{}).EVENT="event",pP.SET="set",pP.CONFIG="config",(mP=dP=dP||{}).ADD_PAYMENT_INFO="add_payment_info",mP.ADD_TO_CART="add_to_cart",mP.ADD_TO_WISHLIST="add_to_wishlist",mP.BEGIN_CHECKOUT="begin_checkout",mP.CHECKOUT_PROGRESS="checkout_progress",mP.EXCEPTION="exception",mP.GENERATE_LEAD="generate_lead",mP.LOGIN="login",mP.PAGE_VIEW="page_view",mP.PURCHASE="purchase",mP.REFUND="refund",mP.REMOVE_FROM_CART="remove_from_cart",mP.SCREEN_VIEW="screen_view",mP.SEARCH="search",mP.SELECT_CONTENT="select_content",mP.SET_CHECKOUT_OPTION="set_checkout_option",mP.SHARE="share",mP.SIGN_UP="sign_up",mP.TIMING_COMPLETE="timing_complete",mP.VIEW_ITEM="view_item",mP.VIEW_ITEM_LIST="view_item_list",mP.VIEW_PROMOTION="view_promotion",mP.VIEW_SEARCH_RESULTS="view_search_results";var TP,EP,SP=((yP={})["no-ga-id"]='"'+gP+'" field is empty in Firebase config. Firebase Analytics requires this field to contain a valid measurement ID.',yP["already-exists"]="A Firebase Analytics instance with the measurement ID ${id}  already exists. Only one Firebase Analytics instance can be created for each measurement ID.",yP["already-initialized"]="Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.",yP["interop-component-reg-failed"]="Firebase Analytics Interop Component failed to instantiate",yP),IP=new Va("analytics","Analytics",SP),CP={},NP="dataLayer",AP="gtag",kP=!1;function DP(t){if(kP)throw IP.create("already-initialized");t.dataLayerName&&(NP=t.dataLayerName),t.gtagName&&(AP=t.gtagName)}function RP(t,e){var r=t.options[gP];if(!r)throw IP.create("no-ga-id");if(null!=CP[r])throw IP.create("already-exists",{id:r});if(!kP){!function(){for(var t=window.document.getElementsByTagName("script"),e=0,n=Object.values(t);e<n.length;e++){var r=n[e];if(r.src&&r.src.includes(wP))return r}return null}()&&function(t){var e=document.createElement("script");e.src=wP+"?l="+t,e.async=!0,document.head.appendChild(e)}(NP),function(t){var e=[];Array.isArray(window[t])?e=window[t]:window[t]=e}(NP);var n=_P(CP,NP,AP),i=n.wrappedGtag,o=n.gtagCore;EP=i,TP=o,kP=!0}return CP[r]=function(r,i,o){return ya(this,void 0,void 0,function(){var e,n;return ga(this,function(t){switch(t.label){case 0:return[4,i.getId()];case 1:return e=t.sent(),o("js",new Date),o(fP.CONFIG,r.options[gP],((n={})[vP]=e,n[bP]="firebase",n.update=!0,n)),[2]}})})}(t,e,TP),{app:t,logEvent:function(t,e,n){return function(t,e,n,r,i){var o=r||{};i&&i.global||(o=ma(ma({},r),{send_to:e})),t(fP.EVENT,n,o||{})}(EP,r,t,e,n)},setCurrentScreen:function(t,e){return function(t,e,n,r){r&&r.global?t(fP.SET,{screen_name:n}):t(fP.CONFIG,e,{update:!0,screen_name:n})}(EP,r,t,e)},setUserId:function(t,e){return function(t,e,n,r){r&&r.global?t(fP.SET,{user_id:n}):t(fP.CONFIG,e,{update:!0,user_id:n})}(EP,r,t,e)},setUserProperties:function(t,e){return function(t,e,n,r){if(r&&r.global){for(var i={},o=0,a=Object.keys(n);o<a.length;o++){var s=a[o];i["user_properties."+s]=n[s]}t(fP.SET,i)}else t(fP.CONFIG,e,{update:!0,user_properties:n})}(EP,r,t,e)},setAnalyticsCollectionEnabled:function(t){return function(t,e){window["ga-disable-"+t]=!e}(r,t)}}}var OP,PP="analytics";(OP=fl).INTERNAL.registerComponent(new as(PP,function(t){return RP(t.getProvider("app").getImmediate(),t.getProvider("installations").getImmediate())},"PUBLIC").setServiceProps({settings:DP,EventName:dP})),OP.INTERNAL.registerComponent(new as("analytics-internal",function(t){try{return{logEvent:t.getProvider(PP).getImmediate().logEvent}}catch(t){throw IP.create("interop-component-reg-failed",{reason:t})}},"PRIVATE")),OP.registerVersion("@firebase/analytics","0.2.9");var MP,xP=(LP.prototype.isCachedDataFresh=function(t,e){if(!e)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;var n=Date.now()-e,r=n<=t;return this.logger.debug("Config fetch cache check. Cache age millis: "+n+". Cache max age millis (minimumFetchIntervalMillis setting): "+t+". Is cache hit: "+r+"."),r},LP.prototype.fetch=function(a){return ya(this,void 0,void 0,function(){var e,n,r,i,o;return ga(this,function(t){switch(t.label){case 0:return[4,Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()])];case 1:return e=t.sent(),n=e[0],(r=e[1])&&this.isCachedDataFresh(a.cacheMaxAgeMillis,n)?[2,r]:(a.eTag=r&&r.eTag,[4,this.client.fetch(a)]);case 2:return i=t.sent(),o=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())],200===i.status&&o.push(this.storage.setLastSuccessfulFetchResponse(i)),[4,Promise.all(o)];case 3:return t.sent(),[2,i]}})})},LP);function LP(t,e,n,r){this.client=t,this.storage=e,this.storageCache=n,this.logger=r}var FP=((MP={})["registration-window"]="Undefined window object. This SDK only supports usage in a browser environment.",MP["registration-project-id"]="Undefined project identifier. Check Firebase app initialization.",MP["registration-api-key"]="Undefined API key. Check Firebase app initialization.",MP["registration-app-id"]="Undefined app identifier. Check Firebase app initialization.",MP["storage-open"]="Error thrown when opening storage. Original error: {$originalErrorMessage}.",MP["storage-get"]="Error thrown when reading from storage. Original error: {$originalErrorMessage}.",MP["storage-set"]="Error thrown when writing to storage. Original error: {$originalErrorMessage}.",MP["storage-delete"]="Error thrown when deleting from storage. Original error: {$originalErrorMessage}.",MP["fetch-client-network"]="Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.",MP["fetch-timeout"]='The config fetch request timed out.  Configure timeout using "fetchTimeoutMillis" SDK setting.',MP["fetch-throttle"]='The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',MP["fetch-client-parse"]="Fetch client could not parse response. Original error: {$originalErrorMessage}.",MP["fetch-status"]="Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.",MP),UP=new Va("remoteconfig","Remote Config",FP);var VP=(qP.prototype.fetch=function(w){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f,p,d,m,y,g,v,b;return ga(this,function(t){switch(t.label){case 0:return[4,Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()])];case 1:e=t.sent(),n=e[0],r=e[1],i=window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com",o=i+"/v1/projects/"+this.projectId+"/namespaces/"+this.namespace+":fetch?key="+this.apiKey,a={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":w.eTag||"*"},s={sdk_version:this.sdkVersion,app_instance_id:n,app_instance_id_token:r,app_id:this.appId,language_code:function(t){return void 0===t&&(t=navigator),t.languages&&t.languages[0]||t.language}()},u={method:"POST",headers:a,body:JSON.stringify(s)},c=fetch(o,u),h=new Promise(function(t,e){w.signal.addEventListener(function(){var t=new Error("The operation was aborted.");t.name="AbortError",e(t)})}),t.label=2;case 2:return t.trys.push([2,5,,6]),[4,Promise.race([c,h])];case 3:return t.sent(),[4,c];case 4:return l=t.sent(),[3,6];case 5:throw f=t.sent(),p="fetch-client-network","AbortError"===f.name&&(p="fetch-timeout"),UP.create(p,{originalErrorMessage:f.message});case 6:if(d=l.status,m=l.headers.get("ETag")||void 0,200!==l.status)return[3,11];v=void 0,t.label=7;case 7:return t.trys.push([7,9,,10]),[4,l.json()];case 8:return v=t.sent(),[3,10];case 9:throw b=t.sent(),UP.create("fetch-client-parse",{originalErrorMessage:b.message});case 10:y=v.entries,g=v.state,t.label=11;case 11:if("INSTANCE_STATE_UNSPECIFIED"===g?d=500:"NO_CHANGE"===g?d=304:"NO_TEMPLATE"!==g&&"EMPTY_CONFIG"!==g||(y={}),304!==d&&200!==d)throw UP.create("fetch-status",{httpStatus:d});return[2,{status:d,eTag:m,config:y}]}})})},qP);function qP(t,e,n,r,i,o){this.firebaseInstallations=t,this.sdkVersion=e,this.namespace=n,this.projectId=r,this.apiKey=i,this.appId=o}var BP=(jP.prototype.addEventListener=function(t){this.listeners.push(t)},jP.prototype.abort=function(){this.listeners.forEach(function(t){return t()})},jP);function jP(){this.listeners=[]}var WP=["1","true","t","yes","y","on"],KP=(QP.prototype.asString=function(){return this._value},QP.prototype.asBoolean=function(){return"static"!==this._source&&0<=WP.indexOf(this._value.toLowerCase())},QP.prototype.asNumber=function(){if("static"===this._source)return 0;var t=Number(this._value);return isNaN(t)&&(t=0),t},QP.prototype.getSource=function(){return this._source},QP);function QP(t,e){void 0===e&&(e=""),this._source=t,this._value=e}var HP=(GP.prototype.setLogLevel=function(t){switch(t){case"debug":this._logger.logLevel=ls.DEBUG;break;case"silent":this._logger.logLevel=ls.SILENT;break;default:this._logger.logLevel=ls.ERROR}},Object.defineProperty(GP.prototype,"fetchTimeMillis",{get:function(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1},enumerable:!0,configurable:!0}),Object.defineProperty(GP.prototype,"lastFetchStatus",{get:function(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"},enumerable:!0,configurable:!0}),GP.prototype.activate=function(){return ya(this,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return[4,Promise.all([this._storage.getLastSuccessfulFetchResponse(),this._storage.getActiveConfigEtag()])];case 1:return e=t.sent(),n=e[0],r=e[1],n&&n.config&&n.eTag&&n.eTag!==r?[4,Promise.all([this._storageCache.setActiveConfig(n.config),this._storage.setActiveConfigEtag(n.eTag)])]:[2,!1];case 2:return t.sent(),[2,!0]}})})},GP.prototype.ensureInitialized=function(){var t=this;return this._initializePromise||(this._initializePromise=this._storageCache.loadFromStorage().then(function(){t._isInitializationComplete=!0})),this._initializePromise},GP.prototype.fetch=function(){return ya(this,void 0,void 0,function(){var e,n,r,i=this;return ga(this,function(t){switch(t.label){case 0:e=new BP,setTimeout(function(){return ya(i,void 0,void 0,function(){return ga(this,function(t){return e.abort(),[2]})})},this.settings.fetchTimeoutMillis),t.label=1;case 1:return t.trys.push([1,4,,6]),[4,this._client.fetch({cacheMaxAgeMillis:this.settings.minimumFetchIntervalMillis,signal:e})];case 2:return t.sent(),[4,this._storageCache.setLastFetchStatus("success")];case 3:return t.sent(),[3,6];case 4:return n=t.sent(),r=function(t,e){return t instanceof Fa&&-1!==t.code.indexOf(e)}(n,"fetch-throttle")?"throttle":"failure",[4,this._storageCache.setLastFetchStatus(r)];case 5:throw t.sent(),n;case 6:return[2]}})})},GP.prototype.fetchAndActivate=function(){return ya(this,void 0,void 0,function(){return ga(this,function(t){switch(t.label){case 0:return[4,this.fetch()];case 1:return t.sent(),[2,this.activate()]}})})},GP.prototype.getAll=function(){var n=this;return function(t,e){return void 0===t&&(t={}),void 0===e&&(e={}),Object.keys(ma(ma({},t),e))}(this._storageCache.getActiveConfig(),this.defaultConfig).reduce(function(t,e){return t[e]=n.getValue(e),t},{})},GP.prototype.getBoolean=function(t){return this.getValue(t).asBoolean()},GP.prototype.getNumber=function(t){return this.getValue(t).asNumber()},GP.prototype.getString=function(t){return this.getValue(t).asString()},GP.prototype.getValue=function(t){this._isInitializationComplete||this._logger.debug('A value was requested for key "'+t+'" before SDK initialization completed. Await on ensureInitialized if the intent was to get a previously activated value.');var e=this._storageCache.getActiveConfig();return e&&void 0!==e[t]?new KP("remote",e[t]):this.defaultConfig&&void 0!==this.defaultConfig[t]?new KP("default",String(this.defaultConfig[t])):(this._logger.debug('Returning static value for key "'+t+'". Define a default or remote value if this is unintentional.'),new KP("static"))},GP);function GP(t,e,n,r,i){this.app=t,this._client=e,this._storageCache=n,this._storage=r,this._logger=i,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}function zP(t,e){var n=t.target.error||void 0;return UP.create(e,{originalErrorMessage:n&&n.message})}var YP="app_namespace_store",XP="firebase_remote_config",JP=1;var $P=(ZP.prototype.getLastFetchStatus=function(){return this.get("last_fetch_status")},ZP.prototype.setLastFetchStatus=function(t){return this.set("last_fetch_status",t)},ZP.prototype.getLastSuccessfulFetchTimestampMillis=function(){return this.get("last_successful_fetch_timestamp_millis")},ZP.prototype.setLastSuccessfulFetchTimestampMillis=function(t){return this.set("last_successful_fetch_timestamp_millis",t)},ZP.prototype.getLastSuccessfulFetchResponse=function(){return this.get("last_successful_fetch_response")},ZP.prototype.setLastSuccessfulFetchResponse=function(t){return this.set("last_successful_fetch_response",t)},ZP.prototype.getActiveConfig=function(){return this.get("active_config")},ZP.prototype.setActiveConfig=function(t){return this.set("active_config",t)},ZP.prototype.getActiveConfigEtag=function(){return this.get("active_config_etag")},ZP.prototype.setActiveConfigEtag=function(t){return this.set("active_config_etag",t)},ZP.prototype.getThrottleMetadata=function(){return this.get("throttle_metadata")},ZP.prototype.setThrottleMetadata=function(t){return this.set("throttle_metadata",t)},ZP.prototype.deleteThrottleMetadata=function(){return this.delete("throttle_metadata")},ZP.prototype.get=function(s){return ya(this,void 0,void 0,function(){var o,a=this;return ga(this,function(t){switch(t.label){case 0:return[4,this.openDbPromise];case 1:return o=t.sent(),[2,new Promise(function(n,e){var t=o.transaction([YP],"readonly").objectStore(YP),r=a.createCompositeKey(s);try{var i=t.get(r);i.onerror=function(t){e(zP(t,"storage-get"))},i.onsuccess=function(t){var e=t.target.result;n(e?e.value:void 0)}}catch(t){e(UP.create("storage-get",{originalErrorMessage:t&&t.message}))}})]}})})},ZP.prototype.set=function(s,u){return ya(this,void 0,void 0,function(){var o,a=this;return ga(this,function(t){switch(t.label){case 0:return[4,this.openDbPromise];case 1:return o=t.sent(),[2,new Promise(function(t,e){var n=o.transaction([YP],"readwrite").objectStore(YP),r=a.createCompositeKey(s);try{var i=n.put({compositeKey:r,value:u});i.onerror=function(t){e(zP(t,"storage-set"))},i.onsuccess=function(){t()}}catch(t){e(UP.create("storage-set",{originalErrorMessage:t&&t.message}))}})]}})})},ZP.prototype.delete=function(s){return ya(this,void 0,void 0,function(){var o,a=this;return ga(this,function(t){switch(t.label){case 0:return[4,this.openDbPromise];case 1:return o=t.sent(),[2,new Promise(function(t,e){var n=o.transaction([YP],"readwrite").objectStore(YP),r=a.createCompositeKey(s);try{var i=n.delete(r);i.onerror=function(t){e(zP(t,"storage-delete"))},i.onsuccess=function(){t()}}catch(t){e(UP.create("storage-delete",{originalErrorMessage:t&&t.message}))}})]}})})},ZP.prototype.createCompositeKey=function(t){return[this.appId,this.appName,this.namespace,t].join()},ZP);function ZP(t,e,n,r){void 0===r&&(r=new Promise(function(e,n){var t=indexedDB.open(XP,JP);t.onerror=function(t){n(zP(t,"storage-open"))},t.onsuccess=function(t){e(t.target.result)},t.onupgradeneeded=function(t){var e=t.target.result;switch(t.oldVersion){case 0:e.createObjectStore(YP,{keyPath:"compositeKey"})}}})),this.appId=t,this.appName=e,this.namespace=n,this.openDbPromise=r}var tM=(eM.prototype.getLastFetchStatus=function(){return this.lastFetchStatus},eM.prototype.getLastSuccessfulFetchTimestampMillis=function(){return this.lastSuccessfulFetchTimestampMillis},eM.prototype.getActiveConfig=function(){return this.activeConfig},eM.prototype.loadFromStorage=function(){return ya(this,void 0,void 0,function(){var e,n,r,i,o,a;return ga(this,function(t){switch(t.label){case 0:return e=this.storage.getLastFetchStatus(),n=this.storage.getLastSuccessfulFetchTimestampMillis(),r=this.storage.getActiveConfig(),[4,e];case 1:return(i=t.sent())&&(this.lastFetchStatus=i),[4,n];case 2:return(o=t.sent())&&(this.lastSuccessfulFetchTimestampMillis=o),[4,r];case 3:return(a=t.sent())&&(this.activeConfig=a),[2]}})})},eM.prototype.setLastFetchStatus=function(t){return this.lastFetchStatus=t,this.storage.setLastFetchStatus(t)},eM.prototype.setLastSuccessfulFetchTimestampMillis=function(t){return this.lastSuccessfulFetchTimestampMillis=t,this.storage.setLastSuccessfulFetchTimestampMillis(t)},eM.prototype.setActiveConfig=function(t){return this.activeConfig=t,this.storage.setActiveConfig(t)},eM);function eM(t){this.storage=t}var nM=(rM.prototype.fetch=function(n){return ya(this,void 0,void 0,function(){var e;return ga(this,function(t){switch(t.label){case 0:return[4,this.storage.getThrottleMetadata()];case 1:return e=t.sent()||{backoffCount:0,throttleEndTimeMillis:Date.now()},[2,this.attemptFetch(n,e)]}})})},rM.prototype.attemptFetch=function(i,t){var o=t.throttleEndTimeMillis,a=t.backoffCount;return ya(this,void 0,void 0,function(){var e,n,r;return ga(this,function(t){switch(t.label){case 0:return[4,function(i,o){return new Promise(function(t,e){var n=Math.max(o-Date.now(),0),r=setTimeout(t,n);i.addEventListener(function(){clearTimeout(r),e(UP.create("fetch-throttle",{throttleEndTimeMillis:o}))})})}(i.signal,o)];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,5,,7]),[4,this.client.fetch(i)];case 3:return e=t.sent(),[4,this.storage.deleteThrottleMetadata()];case 4:return t.sent(),[2,e];case 5:if(!function(t){if(!(t instanceof Fa))return!1;var e=Number(t.httpStatus);return 429===e||500===e||503===e||504===e}(n=t.sent()))throw n;return r={throttleEndTimeMillis:Date.now()+function(t){var e=1e3*Math.pow(2,t),n=Math.round(.5*e*(Math.random()-.5)*2);return Math.min(144e5,e+n)}(a),backoffCount:a+1},[4,this.storage.setThrottleMetadata(r)];case 6:return t.sent(),[2,this.attemptFetch(i,r)];case 7:return[2]}})})},rM);function rM(t,e){this.client=t,this.storage=e}var iM,oM="@firebase/remote-config";return(iM=fl).INTERNAL.registerComponent(new as("remoteConfig",function(t,e){var n=t.getProvider("app").getImmediate(),r=t.getProvider("installations").getImmediate();if("undefined"==typeof window)throw UP.create("registration-window");var i=n.options,o=i.projectId,a=i.apiKey,s=i.appId;if(!o)throw UP.create("registration-project-id");if(!a)throw UP.create("registration-api-key");if(!s)throw UP.create("registration-app-id");e=e||"firebase";var u=new $P(s,n.name,e),c=new tM(u),h=new bs(oM);h.logLevel=ls.ERROR;var l=new VP(r,iM.SDK_VERSION,e,o,a,s),f=new nM(l,u),p=new xP(f,u,c,h),d=new HP(n,p,c,u,h);return d.ensureInitialized(),d},"PUBLIC").setMultipleInstances(!0)),iM.registerVersion(oM,"0.1.9"),console.warn("\nIt looks like you're using the development build of the Firebase JS SDK.\nWhen deploying Firebase apps to production, it is advisable to only import\nthe individual SDK components you intend to use.\n\nFor the CDN builds, these are available in the following manner\n(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):\n\nhttps://www.gstatic.com/firebasejs/5.0.0/firebase-<PACKAGE>.js\n"),fl.registerVersion("firebase","7.6.0","cdn"),fl});
  //# sourceMappingURL=firebase.js.map
  