UNPKG

891 kBJavaScriptView Raw
1!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(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var h=[301,302,303,307,308];E.redirect=function(t,e){if(-1===h.indexOf(e))throw new RangeError("Invalid status code");return new E(null,{status:e,headers:{location:t}})},t.Headers=d,t.Request=w,t.Response=E,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 E(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 y(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function m(n){return new Promise(function(t,e){n.onload=function(){t(n.result)},n.onerror=function(){e(n.error)}})}function v(t){var e=new FileReader,n=m(e);return e.readAsArrayBuffer(t),n}function g(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=g(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=g(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=y(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?y(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t=y(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,n=m(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 E(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 m(t){try{return!!t()}catch(t){return!0}}function v(t){return"object"==typeof t?null!==t:"function"==typeof t}function i(t){return y?p.createElement(t):{}}function d(t){if(!v(t))throw TypeError(String(t)+" is not an object");return t}function o(t,e){if(!v(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!v(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}function g(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}function h(e,n){try{T(b,e,n)}catch(t){b[e]=n}return n}function c(t,e){return N.call(t,e)}function s(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++R+O).toString(36)}function r(t){return P[t]||(P[t]=s(t))}var a,u,l,b=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||Function("return this")(),f=!m(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),p=b.document,y=v(p)&&v(p.createElement),w=!f&&!m(function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}),_=Object.defineProperty,E={f:f?_:function(t,e,n){if(d(t),e=o(e,!0),d(n),w)try{return _(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}},T=f?function(t,e,n){return E.f(t,e,g(1,n))}:function(t,e,n){return t[e]=n,t},S="__core-js_shared__",I=b[S]||h(S,{}),C=e(function(t){(t.exports=function(t,e){return I[t]||(I[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.3.3",mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),N={}.hasOwnProperty,A=C("native-function-to-string",Function.toString),k=b.WeakMap,D="function"==typeof k&&/native code/.test(A.call(k)),R=0,O=Math.random(),P=C("keys"),M={},x=b.WeakMap;if(D){var L=new x,F=L.get,U=L.has,q=L.set;a=function(t,e){return q.call(L,t,e),e},u=function(t){return F.call(L,t)||{}},l=function(t){return U.call(L,t)}}else{var V=r("state");M[V]=!0,a=function(t,e){return T(t,V,e),e},u=function(t){return c(t,V)?t[V]:{}},l=function(t){return c(t,V)}}function B(t){return H.call(t).slice(8,-1)}function j(t){return Y[t]||(Y[t]=G&&z[t]||(G?z:s)("Symbol."+t))}function W(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),X))?n:J?B(e):"Object"==(r=B(e))&&"function"==typeof e.callee?"Arguments":r}var K={set:a,get:u,has:l,enforce:function(t){return l(t)?u(t):a(t,{})},getterFor:function(n){return function(t){var e;if(!v(t)||(e=u(t)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return e}}},Q=e(function(t){var e=K.get,s=K.enforce,u=String(A).split("toString");C("inspectSource",function(t){return A.call(t)}),(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")||T(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(t,e,n)):o?t[e]=n:h(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||A.call(this)})}),H={}.toString,G=!!Object.getOwnPropertySymbols&&!m(function(){return!String(Symbol())}),z=b.Symbol,Y=C("wks"),X=j("toStringTag"),J="Arguments"==B(function(){return arguments}()),$={};$[j("toStringTag")]="z";var Z="[object z]"!==String($)?function(){return"[object "+W(this)+"]"}:$.toString,tt=Object.prototype;Z!==tt.toString&&Q(tt,"toString",Z,{unsafe:!0});function et(t){return isNaN(t=+t)?0:(0<t?gt:vt)(t)}function nt(t){if(null==t)throw TypeError("Can't call method on "+t);return t}function rt(s){return function(t,e){var n,r,i=String(nt(t)),o=et(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 it(t){return St(nt(t))}function ot(t){return"function"==typeof t?t:void 0}function at(t,e){return arguments.length<2?ot(Nt[t])||ot(b[t]):Nt[t]&&Nt[t][e]||b[t]&&b[t][e]}function st(t){return 0<t?At(et(t),9007199254740991):0}function ut(s){return function(t,e,n){var r,i=it(t),o=st(i.length),a=function(t,e){var n=et(t);return n<0?kt(n+e,0):Dt(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 ct(t,e){var n,r=it(t),i=0,o=[];for(n in r)!c(M,n)&&c(r,n)&&o.push(n);for(;e.length>i;)c(r,n=e[i++])&&(~Rt(o,n)||o.push(n));return o}function ht(t,e){for(var n=Lt(e),r=E.f,i=Ct.f,o=0;o<n.length;o++){var a=n[o];c(t,a)||r(t,a,i(e,a))}}function lt(t,e){var n=qt[Ut(t)];return n==Bt||n!=Vt&&("function"==typeof e?m(e):!!e)}function ft(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=Wt(n,r))&&a.value:n[r],!jt(u?r:s+(c?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;ht(o,i)}(t.sham||i&&i.sham)&&T(o,"sham",!0),Q(n,r,o,t)}}function pt(t){return Object(nt(t))}var dt,yt,mt,vt=Math.ceil,gt=Math.floor,bt={codeAt:rt(!1),charAt:rt(!0)},wt={}.propertyIsEnumerable,_t=Object.getOwnPropertyDescriptor,Et={f:_t&&!wt.call({1:2},1)?function(t){var e=_t(this,t);return!!e&&e.enumerable}:wt},Tt="".split,St=m(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==B(t)?Tt.call(t,""):Object(t)}:Object,It=Object.getOwnPropertyDescriptor,Ct={f:f?It:function(t,e){if(t=it(t),e=o(e,!0),w)try{return It(t,e)}catch(t){}if(c(t,e))return g(!Et.f.call(t,e),t[e])}},Nt=b,At=Math.min,kt=Math.max,Dt=Math.min,Rt={includes:ut(!0),indexOf:ut(!1)}.indexOf,Ot=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pt=Ot.concat("length","prototype"),Mt={f:Object.getOwnPropertyNames||function(t){return ct(t,Pt)}},xt={f:Object.getOwnPropertySymbols},Lt=at("Reflect","ownKeys")||function(t){var e=Mt.f(d(t)),n=xt.f;return n?e.concat(n(t)):e},Ft=/#|\.prototype\./,Ut=lt.normalize=function(t){return String(t).replace(Ft,".").toLowerCase()},qt=lt.data={},Vt=lt.NATIVE="N",Bt=lt.POLYFILL="P",jt=lt,Wt=Ct.f,Kt=!m(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Qt=r("IE_PROTO"),Ht=Object.prototype,Gt=Kt?Object.getPrototypeOf:function(t){return t=pt(t),c(t,Qt)?t[Qt]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Ht:null},zt=j("iterator"),Yt=!1;[].keys&&("next"in(mt=[].keys())?(yt=Gt(Gt(mt)))!==Object.prototype&&(dt=yt):Yt=!0),null==dt&&(dt={}),c(dt,zt)||T(dt,zt,function(){return this});function Xt(){}var Jt={IteratorPrototype:dt,BUGGY_SAFARI_ITERATORS:Yt},$t=Object.keys||function(t){return ct(t,Ot)},Zt=f?Object.defineProperties:function(t,e){d(t);for(var n,r=$t(e),i=r.length,o=0;o<i;)E.f(t,n=r[o++],e[n]);return t},te=at("document","documentElement"),ee=r("IE_PROTO"),ne="prototype",re=function(){var t,e=i("iframe"),n=Ot.length,r="script";for(e.style.display="none",te.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write("<script>document.F=Object</"+r+">"),t.close(),re=t.F;n--;)delete re[ne][Ot[n]];return re()},ie=Object.create||function(t,e){var n;return null!==t?(Xt[ne]=d(t),n=new Xt,Xt[ne]=null,n[ee]=t):n=re(),void 0===e?n:Zt(n,e)};M[ee]=!0;function oe(t,e,n){t&&!c(t=n?t:t.prototype,he)&&ce(t,he,{configurable:!0,value:e})}function ae(){return this}function se(){return this}function ue(t,e,n,r,i,o,a){function s(t){if(t===i&&y)return y;if(!ye&&t in p)return p[t];switch(t){case"keys":case ve:case ge:return function(){return new n(this,t)}}return function(){return new n(this)}}!function(t,e,n){var r=e+" Iterator";t.prototype=ie(fe,{next:g(1,n)}),oe(t,r,!1),le[r]=ae}(n,e,r);var u,c,h,l=e+" Iterator",f=!1,p=t.prototype,d=p[me]||p["@@iterator"]||i&&p[i],y=!ye&&d||s(i),m="Array"==e&&p.entries||d;if(m&&(u=Gt(m.call(new t)),de!==Object.prototype&&u.next&&(Gt(u)!==de&&(pe?pe(u,de):"function"!=typeof u[me]&&T(u,me,se)),oe(u,l,!0))),i==ve&&d&&d.name!==ve&&(f=!0,y=function(){return d.call(this)}),p[me]!==y&&T(p,me,y),le[e]=y,i)if(c={values:s(ve),keys:o?y:s("keys"),entries:s(ge)},a)for(h in c)!ye&&!f&&h in p||Q(p,h,c[h]);else ft({target:e,proto:!0,forced:ye||f},c);return c}var ce=E.f,he=j("toStringTag"),le={},fe=Jt.IteratorPrototype,pe=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(!v(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),de=Jt.IteratorPrototype,ye=Jt.BUGGY_SAFARI_ITERATORS,me=j("iterator"),ve="values",ge="entries",be=bt.charAt,we="String Iterator",_e=K.set,Ee=K.getterFor(we);ue(String,"String",function(t){_e(this,{type:we,string:String(t),index:0})},function(){var t,e=Ee(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=be(n,r),e.index+=t.length,{value:t,done:!1})});var Te={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},Se=j("unscopables"),Ie=Array.prototype;null==Ie[Se]&&T(Ie,Se,ie(null));function Ce(t){Ie[Se][t]=!0}var Ne="Array Iterator",Ae=K.set,ke=K.getterFor(Ne),De=ue(Array,"Array",function(t,e){Ae(this,{type:Ne,target:it(t),index:0,kind:e})},function(){var t=ke(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");le.Arguments=le.Array,Ce("keys"),Ce("values"),Ce("entries");var Re=j("iterator"),Oe=j("toStringTag"),Pe=De.values;for(var Me in Te){var xe=b[Me],Le=xe&&xe.prototype;if(Le){if(Le[Re]!==Pe)try{T(Le,Re,Pe)}catch(bs){Le[Re]=Pe}if(Le[Oe]||T(Le,Oe,Me),Te[Me])for(var Fe in De)if(Le[Fe]!==De[Fe])try{T(Le,Fe,De[Fe])}catch(bs){Le[Fe]=De[Fe]}}}function Ue(t,e,n){for(var r in e)Q(t,r,e[r],n);return t}function qe(t){var e=at(t),n=E.f;f&&e&&!e[Ge]&&n(e,Ge,{configurable:!0,get:function(){return this}})}function Ve(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}function Be(t,e,n){if(!(t instanceof e))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return t}function je(t){return void 0!==t&&(le.Array===t||Ye[ze]===t)}function We(r,i,t){if(Ve(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 Ke(t){if(null!=t)return t[Xe]||t["@@iterator"]||le[W(t)]}function Qe(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 He=b.Promise,Ge=j("species"),ze=j("iterator"),Ye=Array.prototype,Xe=j("iterator"),Je=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=We(e,n,r?2:1);if(i)o=t;else{if("function"!=typeof(a=Ke(t)))throw TypeError("Target is not iterable");if(je(a)){for(s=0,u=st(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=Qe(o,f,l.value,r))&&c&&c instanceof p)return c;return new p(!1)}).stop=function(t){return new p(!0,t)}}),$e=j("iterator"),Ze=!1;try{var tn=0,en={next:function(){return{done:!!tn++}},return:function(){Ze=!0}};en[$e]=function(){return this},Array.from(en,function(){throw 2})}catch(bs){}function nn(t,e){if(!e&&!Ze)return!1;var n=!1;try{var r={};r[$e]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}function rn(t,e){var n,r=d(t).constructor;return void 0===r||null==(n=d(r)[fn])?e:Ve(n)}function on(t){if(_n.hasOwnProperty(t)){var e=_n[t];delete _n[t],e()}}function an(t){return function(){on(t)}}function sn(t){on(t.data)}function un(t){b.postMessage(t+"",dn.protocol+"//"+dn.host)}var cn,hn,ln,fn=j("species"),pn=at("navigator","userAgent")||"",dn=b.location,yn=b.setImmediate,mn=b.clearImmediate,vn=b.process,gn=b.MessageChannel,bn=b.Dispatch,wn=0,_n={},En="onreadystatechange";yn&&mn||(yn=function(t){for(var e=[],n=1;n<arguments.length;)e.push(arguments[n++]);return _n[++wn]=function(){("function"==typeof t?t:Function(t)).apply(void 0,e)},cn(wn),wn},mn=function(t){delete _n[t]},"process"==B(vn)?cn=function(t){vn.nextTick(an(t))}:bn&&bn.now?cn=function(t){bn.now(an(t))}:gn&&!/(iphone|ipod|ipad).*applewebkit/i.test(pn)?(ln=(hn=new gn).port2,hn.port1.onmessage=sn,cn=We(ln.postMessage,ln,1)):!b.addEventListener||"function"!=typeof postMessage||b.importScripts||m(un)?cn=En in i("script")?function(t){te.appendChild(i("script"))[En]=function(){te.removeChild(this),on(t)}}:function(t){setTimeout(an(t),0)}:(cn=un,b.addEventListener("message",sn,!1)));var Tn,Sn,In,Cn,Nn,An,kn,Dn,Rn={set:yn,clear:mn},On=Ct.f,Pn=Rn.set,Mn=b.MutationObserver||b.WebKitMutationObserver,xn=b.process,Ln=b.Promise,Fn="process"==B(xn),Un=On(b,"queueMicrotask"),qn=Un&&Un.value;qn||(Tn=function(){var t,e;for(Fn&&(t=xn.domain)&&t.exit();Sn;){e=Sn.fn,Sn=Sn.next;try{e()}catch(t){throw Sn?Cn():In=void 0,t}}In=void 0,t&&t.enter()},Cn=Fn?function(){xn.nextTick(Tn)}:Mn&&!/(iphone|ipod|ipad).*applewebkit/i.test(pn)?(Nn=!0,An=document.createTextNode(""),new Mn(Tn).observe(An,{characterData:!0}),function(){An.data=Nn=!Nn}):Ln&&Ln.resolve?(kn=Ln.resolve(void 0),Dn=kn.then,function(){Dn.call(kn,Tn)}):function(){Pn.call(b,Tn)});function Vn(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=Ve(n),this.reject=Ve(r)}function Bn(t,e){if(d(t),v(e)&&e.constructor===t)return e;var n=Zn.f(t);return(0,n.resolve)(e),n.promise}function jn(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}function Wn(t){var e;return!(!v(t)||"function"!=typeof(e=t.then))&&e}function Kn(l,f,p){if(!f.notified){f.notified=!0;var d=f.reactions;$n(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&&Er(l,f),f.rejection=1),!0===s?r=t:(h&&h.enter(),r=s(t),h&&(h.exit(),o=!0)),r===a.promise?c(sr("Promise-chain cycle")):(i=Wn(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&&wr(l,f)})}}function Qn(t,e,n){var r,i;mr?((r=ur.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===vr&&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 Hn(e,n,r,i){return function(t){e(n,r,t,i)}}function Gn(t,e,n,r){e.done||(e.done=!0,r&&(e=r),e.value=n,e.state=2,Kn(t,e,!0))}var zn,Yn,Xn,Jn,$n=qn||function(t){var e={fn:t,next:void 0};In&&(In.next=e),Sn||(Sn=e,Cn()),In=e},Zn={f:function(t){return new Vn(t)}},tr=Rn.set,er=j("species"),nr="Promise",rr=K.get,ir=K.set,or=K.getterFor(nr),ar=He,sr=b.TypeError,ur=b.document,cr=b.process,hr=b.fetch,lr=cr&&cr.versions,fr=lr&&lr.v8||"",pr=Zn.f,dr=pr,yr="process"==B(cr),mr=!!(ur&&ur.createEvent&&b.dispatchEvent),vr="unhandledrejection",gr=jt(nr,function(){function e(){}var t=ar.resolve(1),n=(t.constructor={})[er]=function(t){t(e,e)};return!((yr||"function"==typeof PromiseRejectionEvent)&&t.then(e)instanceof n&&0!==fr.indexOf("6.6")&&-1===pn.indexOf("Chrome/66"))}),br=gr||!nn(function(t){ar.all(t).catch(function(){})}),wr=function(n,r){tr.call(b,function(){var t,e=r.value;if(_r(r)&&(t=jn(function(){yr?cr.emit("unhandledRejection",e,n):Qn(vr,n,e)}),r.rejection=yr||_r(r)?2:1,t.error))throw t.value})},_r=function(t){return 1!==t.rejection&&!t.parent},Er=function(t,e){tr.call(b,function(){yr?cr.emit("rejectionHandled",t):Qn("rejectionhandled",t,e.value)})},Tr=function(n,r,t,e){if(!r.done){r.done=!0,e&&(r=e);try{if(n===t)throw sr("Promise can't be resolved itself");var i=Wn(t);i?$n(function(){var e={done:!1};try{i.call(t,Hn(Tr,n,e,r),Hn(Gn,n,e,r))}catch(t){Gn(n,e,t,r)}}):(r.value=t,r.state=1,Kn(n,r,!1))}catch(t){Gn(n,{done:!1},t,r)}}};gr&&(ar=function(t){Be(this,ar,nr),Ve(t),zn.call(this);var e=rr(this);try{t(Hn(Tr,this,e),Hn(Gn,this,e))}catch(t){Gn(this,e,t)}},(zn=function(t){ir(this,{type:nr,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=Ue(ar.prototype,{then:function(t,e){var n=or(this),r=pr(rn(this,ar));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=yr?cr.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&Kn(this,n,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),Yn=function(){var t=new zn,e=rr(t);this.promise=t,this.resolve=Hn(Tr,t,e),this.reject=Hn(Gn,t,e)},Zn.f=pr=function(t){return t===ar||t===Xn?new Yn(t):dr(t)},"function"==typeof He&&(Jn=He.prototype.then,Q(He.prototype,"then",function(t,e){var n=this;return new ar(function(t,e){Jn.call(n,t,e)}).then(t,e)},{unsafe:!0}),"function"==typeof hr&&ft({global:!0,enumerable:!0,forced:!0},{fetch:function(t){return Bn(ar,hr.apply(b,arguments))}}))),ft({global:!0,wrap:!0,forced:gr},{Promise:ar}),oe(ar,nr,!1),qe(nr),Xn=Nt[nr],ft({target:nr,stat:!0,forced:gr},{reject:function(t){var e=pr(this);return e.reject.call(void 0,t),e.promise}}),ft({target:nr,stat:!0,forced:gr},{resolve:function(t){return Bn(this,t)}}),ft({target:nr,stat:!0,forced:br},{all:function(t){var s=this,e=pr(s),u=e.resolve,c=e.reject,n=jn(function(){var r=Ve(s.resolve),i=[],o=0,a=1;Je(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=pr(n),i=r.reject,e=jn(function(){var e=Ve(n.resolve);Je(t,function(t){e.call(n,t).then(r.resolve,i)})});return e.error&&i(e.value),r.promise}}),ft({target:"Promise",stat:!0},{allSettled:function(t){var s=this,e=Zn.f(s),u=e.resolve,n=e.reject,r=jn(function(){var r=Ve(s.resolve),i=[],o=0,a=1;Je(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}}),ft({target:"Promise",proto:!0,real:!0},{finally:function(e){var n=rn(this,at("Promise")),t="function"==typeof e;return this.then(t?function(t){return Bn(n,e()).then(function(){return t})}:e,t?function(t){return Bn(n,e()).then(function(){throw t})}:e)}}),"function"!=typeof He||He.prototype.finally||Q(He.prototype,"finally",at("Promise").prototype.finally);Nt.Promise;var Sr=K.set,Ir=K.getterFor("AggregateError"),Cr=function(t,e){var n=this;if(!(n instanceof Cr))return new Cr(t,e);pe&&(n=pe(new Error(e),Gt(n)));var r=[];return Je(t,r.push,r),f?Sr(n,{errors:r,type:"AggregateError"}):n.errors=r,void 0!==e&&T(n,"message",String(e)),n};Cr.prototype=ie(Error.prototype,{constructor:g(5,Cr),message:g(5,""),name:g(5,"AggregateError"),toString:g(5,function(){var t=d(this).name;t=void 0===t?"AggregateError":String(t);var e=this.message;return t+": "+(e=void 0===e?"":String(e))})}),f&&E.f(Cr.prototype,"errors",{get:function(){return Ir(this).errors},configurable:!0}),ft({global:!0},{AggregateError:Cr}),ft({target:"Promise",stat:!0},{try:function(t){var e=Zn.f(this),n=jn(t);return(n.error?e.reject:e.resolve)(n.value),e.promise}});var Nr="No one promise resolved";ft({target:"Promise",stat:!0},{any:function(t){var u=this,e=Zn.f(u),c=e.resolve,h=e.reject,n=jn(function(){var r=Ve(u.resolve),i=[],o=0,a=1,s=!1;Je(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(at("AggregateError"))(i,Nr)))})}),--a||h(new(at("AggregateError"))(i,Nr))});return n.error&&h(n.value),e.promise}});function Ar(t,e){var n;return Dr(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!Dr(n.prototype)?v(n)&&null===(n=n[Rr])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)}function kr(p){var d=1==p,y=2==p,m=3==p,v=4==p,g=6==p,b=5==p||g;return function(t,e,n,r){for(var i,o,a=pt(t),s=St(a),u=We(e,n,3),c=st(s.length),h=0,l=r||Ar,f=d?l(t,c):y?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:Or.call(f,i)}else if(v)return!1;return g?-1:m||v?v:f}}var Dr=Array.isArray||function(t){return"Array"==B(t)},Rr=j("species"),Or=[].push,Pr={forEach:kr(0),map:kr(1),filter:kr(2),some:kr(3),every:kr(4),find:kr(5),findIndex:kr(6)},Mr=Pr.find,xr="find",Lr=!0;xr in[]&&Array(1)[xr](function(){Lr=!1}),ft({target:"Array",proto:!0,forced:Lr},{find:function(t,e){return Mr(this,t,1<arguments.length?e:void 0)}}),Ce(xr);function Fr(t,e,n){return We(Ur,b[t].prototype[e],n)}var Ur=Function.call,qr=(Fr("Array","find"),Pr.findIndex),Vr="findIndex",Br=!0;Vr in[]&&Array(1)[Vr](function(){Br=!1}),ft({target:"Array",proto:!0,forced:Br},{findIndex:function(t,e){return qr(this,t,1<arguments.length?e:void 0)}}),Ce(Vr);function jr(t,e,n){var r=o(e);r in t?E.f(t,r,g(0,n)):t[r]=n}Fr("Array","findIndex");var Wr=!nn(function(t){Array.from(t)});ft({target:"Array",stat:!0,forced:Wr},{from:function(t,e,n){var r,i,o,a,s,u=pt(t),c="function"==typeof this?this:Array,h=arguments.length,l=1<h?e:void 0,f=void 0!==l,p=0,d=Ke(u);if(f&&(l=We(l,2<h?n:void 0,2)),null==d||c==Array&&je(d))for(i=new c(r=st(u.length));p<r;p++)jr(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++)jr(i,p,f?Qe(a,l,[o.value,p],!0):o.value);return i.length=p,i}});Nt.Array.from;var Kr,Qr,Hr,Gr=Pr.some;ft({target:"Array",proto:!0,forced:(Kr="some",Hr=[][Kr],!Hr||!m(function(){Hr.call(null,Qr||function(){throw 1},1)}))},{some:function(t,e){return Gr(this,t,1<arguments.length?e:void 0)}});Fr("Array","some");function zr(t){return v(t)&&c(hi,W(t))}var Yr,Xr=E.f,Jr=b.DataView,$r=Jr&&Jr.prototype,Zr=b.Int8Array,ti=Zr&&Zr.prototype,ei=b.Uint8ClampedArray,ni=ei&&ei.prototype,ri=Zr&&Gt(Zr),ii=ti&&Gt(ti),oi=Object.prototype,ai=(oi.isPrototypeOf,j("toStringTag")),si=s("TYPED_ARRAY_TAG"),ui=!(!b.ArrayBuffer||!Jr),ci=ui&&!!pe&&"Opera"!==W(b.opera),hi={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8};for(Yr in hi)b[Yr]||(ci=!1);if((!ci||"function"!=typeof ri||ri===Function.prototype)&&(ri=function(){throw TypeError("Incorrect invocation")},ci))for(Yr in hi)b[Yr]&&pe(b[Yr],ri);if((!ci||!ii||ii===oi)&&(ii=ri.prototype,ci))for(Yr in hi)b[Yr]&&pe(b[Yr].prototype,ii);if(ci&&Gt(ni)!==ii&&pe(ni,ii),f&&!c(ii,ai))for(Yr in!0,Xr(ii,ai,{get:function(){return v(this)?this[si]:void 0}}),hi)b[Yr]&&T(b[Yr],si,Yr);ui&&pe&&Gt($r)!==oi&&pe($r,oi);function li(){return mi.call(bi(this))}var fi=function(t){if(zr(t))return t;throw TypeError("Target is not a typed array")},pi=function(t,e,n){if(f){if(n)for(var r in hi){var i=b[r];i&&c(i.prototype,t)&&delete i.prototype[t]}ii[t]&&!n||Q(ii,t,n?e:ci&&ti[t]||e)}},di=j("iterator"),yi=b.Uint8Array,mi=De.values,vi=De.keys,gi=De.entries,bi=fi,wi=pi,_i=yi&&yi.prototype[di],Ei=!!_i&&("values"==_i.name||null==_i.name);wi("entries",function(){return gi.call(bi(this))}),wi("keys",function(){return vi.call(bi(this))}),wi("values",li,!Ei),wi(di,li,!Ei);var Ti=Object.assign,Si=!Ti||m(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t}),7!=Ti({},t)[n]||$t(Ti({},e)).join("")!=r})?function(t,e){for(var n=pt(t),r=arguments.length,i=1,o=xt.f,a=Et.f;i<r;)for(var s,u=St(arguments[i++]),c=o?$t(u).concat(o(u)):$t(u),h=c.length,l=0;l<h;)s=c[l++],f&&!a.call(u,s)||(n[s]=u[s]);return n}:Ti;ft({target:"Object",stat:!0,forced:Object.assign!==Si},{assign:Si});Nt.Object.assign;function Ii(s){return function(t){for(var e,n=it(t),r=$t(n),i=r.length,o=0,a=[];o<i;)e=r[o++],f&&!Ci.call(n,e)||a.push(s?[e,n[e]]:n[e]);return a}}var Ci=Et.f,Ni={entries:Ii(!0),values:Ii(!1)},Ai=Ni.entries;ft({target:"Object",stat:!0},{entries:function(t){return Ai(t)}});Nt.Object.entries;var ki=Ni.values;ft({target:"Object",stat:!0},{values:function(t){return ki(t)}});Nt.Object.values;function Di(t){if(function(t){var e;return v(t)&&(void 0!==(e=t[Oi])?!!e:"RegExp"==B(t))}(t))throw TypeError("The method doesn't accept regular expressions");return t}function Ri(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Pi]=!1,"/./"[e](n)}catch(t){}}return!1}var Oi=j("match"),Pi=j("match");ft({target:"String",proto:!0,forced:!Ri("includes")},{includes:function(t,e){return!!~String(nt(this)).indexOf(Di(t),1<arguments.length?e:void 0)}});Fr("String","includes");var Mi="".startsWith,xi=Math.min;ft({target:"String",proto:!0,forced:!Ri("startsWith")},{startsWith:function(t,e){var n=String(nt(this));Di(t);var r=st(xi(1<arguments.length?e:void 0,n.length)),i=String(t);return Mi?Mi.call(n,i,r):n.slice(r,r+i.length)===i}});Fr("String","startsWith");ft({target:"String",proto:!0},{repeat:"".repeat||function(t){var e=String(nt(this)),n="",r=et(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}});Fr("String","repeat");function Li(t){if(!v(t))return!1;var e=t[qi];return void 0!==e?!!e:Dr(t)}var Fi,Ui=j("species"),qi=j("isConcatSpreadable"),Vi=9007199254740991,Bi="Maximum allowed index exceeded",ji=!m(function(){var t=[];return t[qi]=!1,t.concat()[0]!==t}),Wi=(Fi="concat",!m(function(){var t=[];return(t.constructor={})[Ui]=function(){return{foo:1}},1!==t[Fi](Boolean).foo}));ft({target:"Array",proto:!0,forced:!ji||!Wi},{concat:function(t){var e,n,r,i,o,a=pt(this),s=Ar(a,0),u=0;for(e=-1,r=arguments.length;e<r;e++)if(Li(o=-1===e?a:arguments[e])){if(i=st(o.length),Vi<u+i)throw TypeError(Bi);for(n=0;n<i;n++,u++)n in o&&jr(s,u,o[n])}else{if(Vi<=u)throw TypeError(Bi);jr(s,u++,o)}return s.length=u,s}});function Ki(t){var e=Nt.Symbol||(Nt.Symbol={});c(e,t)||to(e,t,{value:Zi.f(t)})}function Qi(t,e){var n=vo[t]=ie(co[io]);return ao(n,{type:ro,tag:t,description:e}),f||(n.description=e),n}function Hi(e,t){d(e);var n=it(t),r=$t(n).concat(Ao(n));return eo(r,function(t){f&&!No.call(n,t)||Co(e,t,n[t])}),e}function Gi(t,e){var n=it(t),r=o(e,!0);if(n!==uo||!c(vo,r)||c(go,r)){var i=fo(n,r);return!i||!c(vo,r)||c(n,no)&&n[no][r]||(i.enumerable=!0),i}}function zi(t){var e=yo(it(t)),n=[];return eo(e,function(t){c(vo,t)||c(M,t)||n.push(t)}),n}var Yi=Mt.f,Xi={}.toString,Ji="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],$i={f:function(t){return Ji&&"[object Window]"==Xi.call(t)?function(t){try{return Yi(t)}catch(t){return Ji.slice()}}(t):Yi(it(t))}},Zi={f:j},to=E.f,eo=Pr.forEach,no=r("hidden"),ro="Symbol",io="prototype",oo=j("toPrimitive"),ao=K.set,so=K.getterFor(ro),uo=Object[io],co=b.Symbol,ho=b.JSON,lo=ho&&ho.stringify,fo=Ct.f,po=E.f,yo=$i.f,mo=Et.f,vo=C("symbols"),go=C("op-symbols"),bo=C("string-to-symbol-registry"),wo=C("symbol-to-string-registry"),_o=C("wks"),Eo=b.QObject,To=!Eo||!Eo[io]||!Eo[io].findChild,So=f&&m(function(){return 7!=ie(po({},"a",{get:function(){return po(this,"a",{value:7}).a}})).a})?function(t,e,n){var r=fo(uo,e);r&&delete uo[e],po(t,e,n),r&&t!==uo&&po(uo,e,r)}:po,Io=G&&"symbol"==typeof co.iterator?function(t){return"symbol"==typeof t}:function(t){return Object(t)instanceof co},Co=function(t,e,n){t===uo&&Co(go,e,n),d(t);var r=o(e,!0);return d(n),c(vo,r)?(n.enumerable?(c(t,no)&&t[no][r]&&(t[no][r]=!1),n=ie(n,{enumerable:g(0,!1)})):(c(t,no)||po(t,no,g(1,{})),t[no][r]=!0),So(t,r,n)):po(t,r,n)},No=function(t){var e=o(t,!0),n=mo.call(this,e);return!(this===uo&&c(vo,e)&&!c(go,e))&&(!(n||!c(this,e)||!c(vo,e)||c(this,no)&&this[no][e])||n)},Ao=function(t){var e=t===uo,n=yo(e?go:it(t)),r=[];return eo(n,function(t){!c(vo,t)||e&&!c(uo,t)||r.push(vo[t])}),r};G||(Q((co=function(t){if(this instanceof co)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===uo&&r.call(go,t),c(this,no)&&c(this[no],n)&&(this[no][n]=!1),So(this,n,g(1,t))};return f&&To&&So(uo,n,{configurable:!0,set:r}),Qi(n,e)})[io],"toString",function(){return so(this).tag}),Et.f=No,E.f=Co,Ct.f=Gi,Mt.f=$i.f=zi,xt.f=Ao,f&&(po(co[io],"description",{configurable:!0,get:function(){return so(this).description}}),Q(uo,"propertyIsEnumerable",No,{unsafe:!0})),Zi.f=function(t){return Qi(j(t),t)}),ft({global:!0,wrap:!0,forced:!G,sham:!G},{Symbol:co}),eo($t(_o),function(t){Ki(t)}),ft({target:ro,stat:!0,forced:!G},{for:function(t){var e=String(t);if(c(bo,e))return bo[e];var n=co(e);return bo[e]=n,wo[n]=e,n},keyFor:function(t){if(!Io(t))throw TypeError(t+" is not a symbol");if(c(wo,t))return wo[t]},useSetter:function(){To=!0},useSimple:function(){To=!1}}),ft({target:"Object",stat:!0,forced:!G,sham:!f},{create:function(t,e){return void 0===e?ie(t):Hi(ie(t),e)},defineProperty:Co,defineProperties:Hi,getOwnPropertyDescriptor:Gi}),ft({target:"Object",stat:!0,forced:!G},{getOwnPropertyNames:zi,getOwnPropertySymbols:Ao}),ft({target:"Object",stat:!0,forced:m(function(){xt.f(1)})},{getOwnPropertySymbols:function(t){return xt.f(pt(t))}}),ho&&ft({target:"JSON",stat:!0,forced:!G||m(function(){var t=co();return"[null]"!=lo([t])||"{}"!=lo({a:t})||"{}"!=lo(Object(t))})},{stringify:function(t){for(var e,n,r=[t],i=1;i<arguments.length;)r.push(arguments[i++]);if(n=e=r[1],(v(e)||void 0!==t)&&!Io(t))return Dr(e)||(e=function(t,e){if("function"==typeof n&&(e=n.call(this,t,e)),!Io(e))return e}),r[1]=e,lo.apply(ho,r)}}),co[io][oo]||T(co[io],oo,co[io].valueOf),oe(co,ro),M[no]=!0,Ki("asyncIterator");var ko=E.f,Do=b.Symbol;if(!(!f||"function"!=typeof Do||"description"in Do.prototype&&void 0===Do().description)){var Ro={},Oo=function(t){var e=arguments.length<1||void 0===t?void 0:String(t),n=this instanceof Oo?new Do(e):void 0===e?Do():Do(e);return""===e&&(Ro[n]=!0),n};ht(Oo,Do);var Po=Oo.prototype=Do.prototype;Po.constructor=Oo;var Mo=Po.toString,xo="Symbol(test)"==String(Do("test")),Lo=/^Symbol\((.*)\)[^)]+$/;ko(Po,"description",{configurable:!0,get:function(){var t=v(this)?this.valueOf():this,e=Mo.call(t);if(c(Ro,t))return"";var n=xo?e.slice(7,-1):e.replace(Lo,"$1");return""===n?void 0:n}}),ft({global:!0,forced:!0},{Symbol:Oo})}Ki("hasInstance"),Ki("isConcatSpreadable"),Ki("iterator"),Ki("match"),Ki("matchAll"),Ki("replace"),Ki("search"),Ki("species"),Ki("split"),Ki("toPrimitive"),Ki("toStringTag"),Ki("unscopables"),oe(Math,"Math",!0),oe(b.JSON,"JSON",!0);Nt.Symbol;Ki("asyncDispose"),Ki("dispose"),Ki("observable"),Ki("patternMatch"),Ki("replaceAll");Zi.f("iterator");function Fo(r,t,e,i,o){function n(t){var n=s[t];Q(s,t,"add"==t?function(t){return n.call(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!v(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return o&&!v(t)?void 0:n.call(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!v(t))&&n.call(this,0===t?0:t)}:function(t,e){return n.call(this,0===t?0:t,e),this})}var a=b[r],s=a&&a.prototype,u=a,c=i?"set":"add",h={};if(jt(r,"function"!=typeof a||!(o||s.forEach&&!m(function(){(new a).entries().next()}))))u=e.getConstructor(t,r,i,c),Vo.REQUIRED=!0;else if(jt(r,!0)){var l=new u,f=l[c](o?{}:-0,1)!=l,p=m(function(){l.has(1)}),d=nn(function(t){new a(t)}),y=!o&&m(function(){for(var t=new a,e=5;e--;)t[c](e,e);return!t.has(-0)});d||(((u=t(function(t,e){Be(t,u,r);var n=function(t,e,n){var r,i;return pe&&"function"==typeof(r=e.constructor)&&r!==n&&v(i=r.prototype)&&i!==n.prototype&&pe(t,i),t}(new a,t,u);return null!=e&&Je(e,n[c],n,i),n})).prototype=s).constructor=u),(p||y)&&(n("delete"),n("has"),i&&n("get")),(y||f)&&n(c),o&&s.clear&&delete s.clear}return h[r]=u,ft({global:!0,forced:u!=a},h),oe(u,r),o||e.setStrong(u,r,i),u}function Uo(t,e,n){var r,i,o,a,s=arguments.length,u=1<s?e:void 0;return Ve(this),(r=void 0!==u)&&Ve(u),null==t?new this:(i=[],r?(o=0,a=We(u,2<s?n:void 0,2),Je(t,function(t){i.push(a(t,o++))})):Je(t,i.push,i),new this(i))}var qo=!m(function(){return Object.isExtensible(Object.preventExtensions({}))}),Vo=e(function(t){function n(t){e(t,r,{value:{objectID:"O"+ ++i,weakData:{}}})}var e=E.f,r=s("meta"),i=0,o=Object.isExtensible||function(){return!0},a=t.exports={REQUIRED:!1,fastKey:function(t,e){if(!v(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 qo&&a.REQUIRED&&o(t)&&!c(t,r)&&n(t),t}};M[r]=!0}),Bo=(Vo.REQUIRED,Vo.fastKey,Vo.getWeakData,Vo.onFreeze,E.f),jo=Vo.fastKey,Wo=K.set,Ko=K.getterFor,Qo={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=jo(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){Be(t,a,n),Wo(t,{type:n,index:ie(null),first:void 0,last:void 0,size:0}),f||(t.size=0),null!=e&&Je(e,t[i],t,r)}),s=Ko(n),u=function(t,e){var n,r=s(t),i=jo(e);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==e)return n};return Ue(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=We(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)}}),Ue(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&&Bo(a.prototype,"size",{get:function(){return s(this).size}}),a},setStrong:function(t,e,n){var r=e+" Iterator",i=Ko(e),o=Ko(r);ue(t,e,function(t,e){Wo(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),qe(e)}};Fo("Map",function(e){return function(t){return e(this,arguments.length?t:void 0)}},Qo,!0),Nt.Map;ft({target:"Map",stat:!0},{from:Uo});function Ho(){for(var t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return new this(e)}ft({target:"Map",stat:!0},{of:Ho});function Go(){for(var t,e=d(this),n=Ve(e.delete),r=!0,i=0,o=arguments.length;i<o;i++)t=n.call(e,arguments[i]),r=r&&t;return!!r}ft({target:"Map",proto:!0,real:!0,forced:!1},{deleteAll:function(){return Go.apply(this,arguments)}});function zo(t){return Map.prototype.entries.call(t)}ft({target:"Map",proto:!0,real:!0,forced:!1},{every:function(t,e){var n=d(this),r=zo(n),i=We(t,1<arguments.length?e:void 0,3);return!Je(r,function(t,e){if(!i(e,t,n))return Je.stop()},void 0,!0,!0).stopped}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{filter:function(t,e){var n=d(this),r=zo(n),i=We(t,1<arguments.length?e:void 0,3),o=new(rn(n,at("Map"))),a=Ve(o.set);return Je(r,function(t,e){i(e,t,n)&&a.call(o,t,e)},void 0,!0,!0),o}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{find:function(t,e){var n=d(this),r=zo(n),i=We(t,1<arguments.length?e:void 0,3);return Je(r,function(t,e){if(i(e,t,n))return Je.stop(e)},void 0,!0,!0).result}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{findKey:function(t,e){var n=d(this),r=zo(n),i=We(t,1<arguments.length?e:void 0,3);return Je(r,function(t,e){if(i(e,t,n))return Je.stop(t)},void 0,!0,!0).result}}),ft({target:"Map",stat:!0},{groupBy:function(t,n){var r=new this;Ve(n);var i=Ve(r.has),o=Ve(r.get),a=Ve(r.set);return Je(t,function(t){var e=n(t);i.call(r,e)?o.call(r,e).push(t):a.call(r,e,[t])}),r}});ft({target:"Map",proto:!0,real:!0,forced:!1},{includes:function(n){return Je(zo(d(this)),function(t,e){if(function(t,e){return t===e||t!=t&&e!=e}(e,n))return Je.stop()},void 0,!0,!0).stopped}}),ft({target:"Map",stat:!0},{keyBy:function(t,e){var n=new this;Ve(e);var r=Ve(n.set);return Je(t,function(t){r.call(n,e(t),t)}),n}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{keyOf:function(n){return Je(zo(d(this)),function(t,e){if(e===n)return Je.stop(t)},void 0,!0,!0).result}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{mapKeys:function(t,e){var n=d(this),r=zo(n),i=We(t,1<arguments.length?e:void 0,3),o=new(rn(n,at("Map"))),a=Ve(o.set);return Je(r,function(t,e){a.call(o,i(e,t,n),e)},void 0,!0,!0),o}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{mapValues:function(t,e){var n=d(this),r=zo(n),i=We(t,1<arguments.length?e:void 0,3),o=new(rn(n,at("Map"))),a=Ve(o.set);return Je(r,function(t,e){a.call(o,t,i(e,t,n))},void 0,!0,!0),o}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{merge:function(t){for(var e=d(this),n=Ve(e.set),r=0;r<arguments.length;)Je(arguments[r++],n,e,!0);return e}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{reduce:function(n,t){var r=d(this),e=zo(r),i=arguments.length<2,o=i?void 0:t;if(Ve(n),Je(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}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{some:function(t,e){var n=d(this),r=zo(n),i=We(t,1<arguments.length?e:void 0,3);return Je(r,function(t,e){if(i(e,t,n))return Je.stop()},void 0,!0,!0).stopped}}),ft({target:"Map",proto:!0,real:!0,forced:!1},{update:function(t,e,n){var r=d(this),i=arguments.length;Ve(e);var o=r.has(t);if(!o&&i<3)throw TypeError("Updating absent value");var a=o?r.get(t):Ve(2<i?n:void 0)(t,r);return r.set(t,e(a,t,r)),r}});function Yo(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}ft({target:"Map",proto:!0,real:!0,forced:!1},{updateOrInsert:Yo}),ft({target:"Map",proto:!0,real:!0,forced:!1},{upsert:Yo});Fo("Set",function(e){return function(t){return e(this,arguments.length?t:void 0)}},Qo),Nt.Set;ft({target:"Set",stat:!0},{from:Uo}),ft({target:"Set",stat:!0},{of:Ho});ft({target:"Set",proto:!0,real:!0,forced:!1},{addAll:function(){return function(){for(var t=d(this),e=Ve(t.add),n=0,r=arguments.length;n<r;n++)e.call(t,arguments[n]);return t}.apply(this,arguments)}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{deleteAll:function(){return Go.apply(this,arguments)}});function Xo(t){return Set.prototype.values.call(t)}ft({target:"Set",proto:!0,real:!0,forced:!1},{every:function(t,e){var n=d(this),r=Xo(n),i=We(t,1<arguments.length?e:void 0,3);return!Je(r,function(t){if(!i(t,t,n))return Je.stop()},void 0,!1,!0).stopped}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{difference:function(t){var e=d(this),n=new(rn(e,at("Set")))(e),r=Ve(n.delete);return Je(t,function(t){r.call(n,t)}),n}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{filter:function(t,e){var n=d(this),r=Xo(n),i=We(t,1<arguments.length?e:void 0,3),o=new(rn(n,at("Set"))),a=Ve(o.add);return Je(r,function(t){i(t,t,n)&&a.call(o,t)},void 0,!1,!0),o}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{find:function(t,e){var n=d(this),r=Xo(n),i=We(t,1<arguments.length?e:void 0,3);return Je(r,function(t){if(i(t,t,n))return Je.stop(t)},void 0,!1,!0).result}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{intersection:function(t){var e=d(this),n=new(rn(e,at("Set"))),r=Ve(e.has),i=Ve(n.add);return Je(t,function(t){r.call(e,t)&&i.call(n,t)}),n}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{isDisjointFrom:function(t){var e=d(this),n=Ve(e.has);return!Je(t,function(t){if(!0===n.call(e,t))return Je.stop()}).stopped}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{isSubsetOf:function(t){var e=function(t){var e=Ke(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(at("Set"))(t),r=Ve(n.has)),!Je(e,function(t){if(!1===r.call(n,t))return Je.stop()},void 0,!1,!0).stopped}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{isSupersetOf:function(t){var e=d(this),n=Ve(e.has);return!Je(t,function(t){if(!1===n.call(e,t))return Je.stop()}).stopped}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{join:function(t){var e=d(this),n=Xo(e),r=void 0===t?",":String(t),i=[];return Je(n,i.push,i,!1,!0),i.join(r)}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{map:function(t,e){var n=d(this),r=Xo(n),i=We(t,1<arguments.length?e:void 0,3),o=new(rn(n,at("Set"))),a=Ve(o.add);return Je(r,function(t){a.call(o,i(t,t,n))},void 0,!1,!0),o}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{reduce:function(e,t){var n=d(this),r=Xo(n),i=arguments.length<2,o=i?void 0:t;if(Ve(e),Je(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}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{some:function(t,e){var n=d(this),r=Xo(n),i=We(t,1<arguments.length?e:void 0,3);return Je(r,function(t){if(i(t,t,n))return Je.stop()},void 0,!1,!0).stopped}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{symmetricDifference:function(t){var e=d(this),n=new(rn(e,at("Set")))(e),r=Ve(n.delete),i=Ve(n.add);return Je(t,function(t){r.call(n,t)||i.call(n,t)}),n}}),ft({target:"Set",proto:!0,real:!0,forced:!1},{union:function(t){var e=d(this),n=new(rn(e,at("Set")))(e);return Je(t,Ve(n.add),n),n}});var Jo=Math.floor;ft({target:"Number",stat:!0},{isInteger:function(t){return!v(t)&&isFinite(t)&&Jo(t)===t}});Nt.Number.isInteger;var $o=function(t,e){return($o=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 Zo(t,e){function n(){this.constructor=t}$o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var ta=function(){return(ta=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 ea(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 na(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 ra(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 ia(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 oa(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(ia(arguments[e]));return t}function aa(){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 sa(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 ua(t){try{return fa.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null}var ca={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},ha=function(t,e){if(!t)throw la(e)},la=function(t){return new Error("Firebase Database ("+ca.SDK_VERSION+") INTERNAL ASSERT FAILED: "+t)},fa={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(sa(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 pa(t){return da(void 0,t)}function da(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]=da(t[n],e[n]));return t}var ya=(ma.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))}},ma);function ma(){var n=this;this.reject=function(){},this.resolve=function(){},this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})}function va(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function ga(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(va())}function ba(){return"object"==typeof navigator&&"ReactNative"===navigator.product}function wa(){return!0===ca.NODE_ADMIN}var _a,Ea=(Zo(Ta,_a=Error),Ta);function Ta(t,e){var n=_a.call(this,e)||this;return n.code=t,n.name="FirebaseError",Object.setPrototypeOf(n,Ta.prototype),Error.captureStackTrace&&Error.captureStackTrace(n,Sa.prototype.create),n}var Sa=(Ia.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(Ca,function(t,e){var n=r[e];return null!=n?n.toString():"<"+e+"?>"})}(o,r):"Error",s=this.serviceName+": "+a+" ("+i+").",u=new Ea(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},Ia);function Ia(t,e,n){this.service=t,this.serviceName=e,this.errors=n}var Ca=/\{\$([^}]+)}/g;function Na(t){return JSON.parse(t)}function Aa(t){return JSON.stringify(t)}function ka(t){var e={},n={},r={},i="";try{var o=t.split(".");e=Na(ua(o[0])||""),n=Na(ua(o[1])||""),i=o[2],r=n.d||{},delete n.d}catch(t){}return{header:e,claims:n,data:r,signature:i}}function Da(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ra(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function Oa(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Pa(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 Ma=(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 La(t,e){var n=new Fa(t,e);return n.subscribe.bind(n)}var Fa=(Ua.prototype.next=function(e){this.forEachObserver(function(t){t.next(e)})},Ua.prototype.error=function(e){this.forEachObserver(function(t){t.error(e)}),this.close(e)},Ua.prototype.complete=function(){this.forEachObserver(function(t){t.complete()}),this.close()},Ua.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=qa),void 0===r.error&&(r.error=qa),void 0===r.complete&&(r.complete=qa);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},Ua.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))},Ua.prototype.forEachObserver=function(t){if(!this.finalized)for(var e=0;e<this.observers.length;e++)this.sendOne(e,t)},Ua.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)}})},Ua.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}))},Ua);function Ua(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 qa(){}function Va(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 Ba(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 ja(t,e,n,r){if((!r||n)&&"function"!=typeof n)throw new Error(Ba(t,e,r)+"must be a valid function.")}function Wa(t,e,n,r){if((!r||n)&&("object"!=typeof n||null===n))throw new Error(Ba(t,e,r)+"must be a valid context object.")}function Ka(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 Qa,Ha;function Ga(){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}(Ha=Qa=Qa||{})[Ha.DEBUG=0]="DEBUG",Ha[Ha.VERBOSE=1]="VERBOSE",Ha[Ha.INFO=2]="INFO",Ha[Ha.WARN=3]="WARN",Ha[Ha.ERROR=4]="ERROR",Ha[Ha.SILENT=5]="SILENT";function za(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 Qa.DEBUG:case Qa.VERBOSE:console.log.apply(console,Ga(["["+i+"] "+t.name+":"],n));break;case Qa.INFO:console.info.apply(console,Ga(["["+i+"] "+t.name+":"],n));break;case Qa.WARN:console.warn.apply(console,Ga(["["+i+"] "+t.name+":"],n));break;case Qa.ERROR:console.error.apply(console,Ga(["["+i+"] "+t.name+":"],n));break;default:throw new Error("Attempted to log a message with an invalid logType (value: "+e+")")}}}var Ya,Xa=Qa.INFO,Ja=(Object.defineProperty($a.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){if(!(t in Qa))throw new TypeError("Invalid value assigned to `logLevel`");this._logLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty($a.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}),$a.prototype.debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Ga([this,Qa.DEBUG],t))},$a.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Ga([this,Qa.VERBOSE],t))},$a.prototype.info=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Ga([this,Qa.INFO],t))},$a.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Ga([this,Qa.WARN],t))},$a.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logHandler.apply(this,Ga([this,Qa.ERROR],t))},$a);function $a(t){this.name=t,this._logLevel=Xa,this._logHandler=za}var Za=((Ya={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",Ya["bad-app-name"]="Illegal App name: '{$appName}",Ya["duplicate-app"]="Firebase App named '{$appName}' already exists",Ya["app-deleted"]="Firebase App named '{$appName}' already deleted",Ya["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",Ya),ts=new Sa("app","Firebase",Za),es="[DEFAULT]",ns=(Object.defineProperty(rs.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(t){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=t},enumerable:!0,configurable:!0}),Object.defineProperty(rs.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(rs.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!0,configurable:!0}),rs.prototype.delete=function(){var s=this;return new Promise(function(t){s.checkDestroyed_(),t()}).then(function(){s.firebase_.INTERNAL.removeApp(s.name_);for(var t=[],e=0,n=Object.keys(s.services_);e<n.length;e++)for(var r=n[e],i=0,o=Object.keys(s.services_[r]);i<o.length;i++){var a=o[i];t.push(s.services_[r][a])}return Promise.all(t.filter(function(t){return"INTERNAL"in t}).map(function(t){return t.INTERNAL.delete()}))}).then(function(){s.isDeleted_=!0,s.services_={}})},rs.prototype._getService=function(t,e){if(void 0===e&&(e=es),this.checkDestroyed_(),this.services_[t]||(this.services_[t]={}),!this.services_[t][e]){var n=e!==es?e:void 0,r=this.firebase_.INTERNAL.factories[t](this,this.extendApp.bind(this),n);this.services_[t][e]=r}return this.services_[t][e]},rs.prototype._removeServiceInstance=function(t,e){void 0===e&&(e=es),this.services_[t]&&this.services_[t][e]&&delete this.services_[t][e]},rs.prototype.extendApp=function(t){if(da(this,t),t.INTERNAL){if(t.INTERNAL.addAuthTokenListener){for(var e=0,n=this.tokenListeners_;e<n.length;e++){var r=n[e];this.INTERNAL.addAuthTokenListener(r)}this.tokenListeners_=[]}if(t.INTERNAL.analytics){for(var i=0,o=this.analyticsEventRequests_;i<o.length;i++){var a=o[i];this.INTERNAL.analytics.logEvent.apply(void 0,a)}this.analyticsEventRequests_=[]}}},rs.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw ts.create("app-deleted",{appName:this.name_})},rs);function rs(t,e,n){var r=this;this.firebase_=n,this.isDeleted_=!1,this.services_={},this.tokenListeners_=[],this.analyticsEventRequests_=[],this.name_=e.name,this.automaticDataCollectionEnabled_=e.automaticDataCollectionEnabled||!1,this.options_=pa(t);var i=this;this.INTERNAL={getUid:function(){return null},getToken:function(){return Promise.resolve(null)},addAuthTokenListener:function(t){r.tokenListeners_.push(t),setTimeout(function(){return t(null)},0)},removeAuthTokenListener:function(e){r.tokenListeners_=r.tokenListeners_.filter(function(t){return t!==e})},analytics:{logEvent:function(){i.analyticsEventRequests_.push(arguments)}}}}ns.prototype.name&&ns.prototype.options||ns.prototype.delete||console.log("dc");var is="7.2.3",os=new Ja("@firebase/app");function as(a){var o={},s={},u={},c={__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=es);var r=n.name;if("string"!=typeof r||!r)throw ts.create("bad-app-name",{appName:String(r)});if(Da(o,r))throw ts.create("duplicate-app",{appName:r});var i=new a(t,n,c);return f(o[r]=i,"create"),i},app:h,apps:null,SDK_VERSION:is,INTERNAL:{registerService:function(n,t,e,r,i){void 0===i&&(i=!1);if(s[n])return os.debug("There were multiple attempts to register service "+n+"."),c[n];s[n]=t,r&&(u[n]=r,l().forEach(function(t){r("create",t)}));function o(t){if(void 0===t&&(t=h()),"function"!=typeof t[n])throw ts.create("invalid-app-argument",{appName:n});return t[n]()}void 0!==e&&da(o,e);return c[n]=o,a.prototype[n]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._getService.bind(this,n).apply(this,i?t:[])},o},removeApp:function(t){f(o[t],"delete"),delete o[t]},factories:s,useAsService:p}};function h(t){if(!Da(o,t=t||es))throw ts.create("no-app",{appName:t});return o[t]}function l(){return Object.keys(o).map(function(t){return o[t]})}function f(t,e){for(var n=0,r=Object.keys(s);n<r.length;n++){var i=p(t,r[n]);if(null===i)return;u[i]&&u[i](e,t)}}function p(t,e){return"serverAuth"===e?null:e}return c.default=c,Object.defineProperty(c,"apps",{get:l}),h.App=a,c}if("object"==typeof self&&self.self===self&&void 0!==self.firebase){os.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");var ss=self.firebase.SDK_VERSION;ss&&0<=ss.indexOf("LITE")&&os.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 us=function t(){var e=as(ns);return e.INTERNAL=ta(ta({},e.INTERNAL),{createFirebaseNamespace:t,extendNamespace:function(t){da(e,t)},createSubscribe:La,ErrorFactory:Sa,deepExtend:da}),e}(),cs=us.initializeApp;us.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}}()&&os.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 '),cs.apply(void 0,t)};var fl=us;(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.Ja(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.Ja(n(t,r),n(e,i)),o},s.prototype.catch=function(t){return this.then(void 0,t)},s.prototype.Ja=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).Ja(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).Ja(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 y(t){var e=r(t);return"array"==e||"object"==e&&"number"==typeof t.length}function m(t){return"function"==r(t)}function v(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var e="closure_uid_"+(1e9*Math.random()>>>0),g=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 E(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 T=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).fd=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(v(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 q(t,e){return 0<=x(t,e)}function V(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 yt(t,e){return-1!=t.indexOf(e)}function mt(t,e){return t<e?-1:e<t?1:0}function vt(){this.a="",this.b=Et}function gt(t){return t instanceof vt&&t.constructor===vt&&t.b===Et?t.a:(A("expected object of type SafeUrl, got '"+t+"' of type "+r(t)),"type_error:SafeUrl")}vt.prototype.qa=!0,vt.prototype.pa=function(){return this.a.toString()},vt.prototype.toString=function(){return"SafeUrl{"+this.a+"}"};var bt=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;function wt(t){return t instanceof vt?t:(t="object"==typeof t&&t.qa?t.pa():String(t),bt.test(t)||(t="about:invalid#zClosurez"),Tt(t))}var _t,Et={};function Tt(t){var e=new vt;return e.a=t,e}Tt("about:blank");t:{var St=l.navigator;if(St){var It=St.userAgent;if(It){_t=It;break t}}_t=""}function Ct(t){return yt(_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;!m(l.setImmediate)||l.Window&&l.Window.prototype&&!Ct("Edge")&&l.Window.prototype.setImmediate==l.setImmediate?(Rt=Rt||Ft())(t):l.setImmediate(t)}}(),qt||(Ot(),qt=!0),Vt.add(t,e)}Dt("<br>");var qt=!1,Vt=new R;function Bt(){for(var t;n=e=void 0,n=null,(e=Vt).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;qt=!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(E(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],E(t,e,!0),E(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(v(t))try{var i=t.then;if(m(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,m(t)?t:null,m(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.ta=this.ta,this.la=this.la}S(ue,C);var he=0;function le(t){if(!t.ta&&(t.ta=!0,t.xa(),0!=he))t[e]||(t[e]=++g)}function fe(t){return fe[" "](t),t}ce.prototype.ta=!(ue.prototype.name="cancel"),ce.prototype.xa=function(){if(this.la)for(;this.la.length;)this.la.shift()()},fe[" "]=p;var pe,de,ye=Ct("Opera"),me=Ct("Trident")||Ct("MSIE"),ve=Ct("Edge"),ge=ve||me,be=Ct("Gecko")&&!(yt(_t.toLowerCase(),"webkit")&&!Ct("Edge"))&&!(Ct("Trident")||Ct("MSIE"))&&!Ct("Edge"),we=yt(_t.toLowerCase(),"webkit")&&!Ct("Edge");function _e(){var t=l.document;return t?t.documentMode:void 0}t:{var Ee="",Te=(de=_t,be?/rv:([^\);]+)(\)|;)/.exec(de):ve?/Edge\/([\d\.]+)/.exec(de):me?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(de):we?/WebKit\/(\S+)/.exec(de):ye?/(?:Version)[ \/]?(\S+)/.exec(de):void 0);if(Te&&(Ee=Te?Te[1]:""),me){var Se=_e();if(null!=Se&&Se>parseFloat(Ee)){pe=String(Se);break t}}pe=Ee}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=mt(0==o[1].length?0:parseInt(o[1],10),0==a[1].length?0:parseInt(a[1],10))||mt(0==o[2].length,0==a[2].length)||mt(o[2],a[2]),o=o[3],a=a[3]}while(0==t)}return 0<=t})}Ie=l.document&&me?_e():void 0;var Ae=Object.freeze||function(t){return t},ke=!me||9<=Number(Ie),De=me&&!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.Na=i,this.key=++Le,this.ra=this.Ia=!1}function Ue(t){t.ra=!0,t.listener=null,t.proxy=null,t.src=null,t.Na=null}function qe(t){this.src=t,this.a={},this.b=0}function Ve(t,e){var n=e.type;n in t.a&&V(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.ra&&o.listener==e&&o.capture==!!n&&o.Na==r)return i}return-1}qe.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.Ia=!1)):((e=new Fe(e,this.src,o,!!r,i)).Ia=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,v(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=v(i)?!!i.capture:!!i,s=Ze(t);if(s||(t[je]=s=new qe(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,v(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=v(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.ra){var e=t.src;if(e&&e[xe])Ve(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))?(Ve(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.ra&&(o=Je(o,r),i=i&&!1!==o)}return i}function Je(t,e){var n=t.listener,r=t.Na||t.src;return t.Ia&&ze(t),n.call(r,e)}function $e(t,e){if(t.ra)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 qe?t:null}var tn="__closure_events_fn_"+(1e9*Math.random()>>>0);function en(e){return m(e)?e:(e[tn]||(e[tn]=function(t){return e.handleEvent(t)}),e[tn])}function nn(){ce.call(this),this.u=new qe(this),(this.Sb=this).Wa=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.ra&&a.capture==n){var s=a.listener,u=a.Na||a.src;a.Ia&&Ve(t.u,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Mb}function sn(t,e,n){if(m(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(y(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(y(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.Wa;if(n)for(e=[];n;n=n.Wa)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.xa=function(){if(nn.qb.xa.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.Wa=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 yn(t,e){var n;this.b=this.i=this.f="",this.l=null,this.g=this.c="",this.h=!1,t instanceof yn?(this.h=void 0!==e?e:t.h,mn(this,t.f),this.i=t.i,this.b=t.b,vn(this,t.l),this.c=t.c,gn(this,Fn(t.a)),this.g=t.g):t&&(n=String(t).match(dn))?(this.h=!!e,mn(this,n[1]||"",!0),this.i=Tn(n[2]||""),this.b=Tn(n[3]||"",!0),vn(this,n[4]),this.c=Tn(n[5]||"",!0),gn(this,n[6]||"",!0),this.g=Tn(n[7]||"")):(this.h=!!e,this.a=new Rn(null,this.h))}function mn(t,e,n){t.f=n?Tn(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function vn(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 gn(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 yn?new yn(t):new yn(t,void 0)}function En(t,e){var n=new yn(null,void 0);return mn(n,"https"),t&&(n.b=t),e&&(n.c=e),n}function Tn(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)}yn.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("")},yn.prototype.resolve=function(t){var e=new yn(this),n=!!t.f;n?mn(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)vn(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(yt(i,"./")||yt(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?gn(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 qn=!me||9<=Number(Ie);function Vn(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(!qn&&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];!y(o)||v(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(v(t))return"function"==typeof t.item||"string"==typeof t.item;if(m(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=yr();return me&&!!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=gt(wt(t)).toString()),e.location.href=n}function Zn(t){return!!((t=(t||yr()).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=yr().toLowerCase(),r&&(e.target=r,yt(n,"crios/")&&(e.target="_blank")),fr(yr())==hr&&(t=t||"http://localhost",e.scrollbars=!0),n=t||"",(t=e)||(t={}),r=window,e=n instanceof vt?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 vt||e instanceof vt||(e="object"==typeof e&&e.qa?e.pa():String(e),bt.test(e)||(e="about:invalid#zClosurez"),e=Tt(e)),a.href=gt(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=gt(e).toString(),a&&(ge&&yt(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(gt(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||yr(),!("file:"!==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 yt(e,"opera/")||yt(e,"opr/")||yt(e,"opios/")?"Opera":yt(e,"iemobile")?"IEMobile":yt(e,"msie")||yt(e,"trident/")?"IE":yt(e,"edge/")?"Edge":yt(e,"firefox/")?hr:yt(e,"silk/")?"Silk":yt(e,"blackberry")?"Blackberry":yt(e,"webos")?"Webos":!yt(e,"safari/")||yt(e,"chrome/")||yt(e,"crios/")||yt(e,"android")?!yt(e,"chrome/")&&!yt(e,"crios/")||yt(e,"edge/")?yt(e,"android")?"Android":(t=t.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/))&&2==t.length?t[1]:"Other":lr:"Safari"}var pr={Vc:"FirebaseCore-web",Xc:"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=yr()):"Worker"===r&&(r=fr(i=yr())+"-"+r),r+"/JsCore/"+t+"/"+e.join(",")}function yr(){return l.navigator&&l.navigator.userAgent||""}function mr(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 vr(){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 gr(){return(br()||"chrome-extension:"===wr()||or())&&!cr()&&vr()&&!sr()}function br(){return"http:"===wr()||"https:"===wr()}function wr(){return l.location&&l.location.protocol||null}function _r(t){return!Zn(t=t||yr())&&fr(t)!=hr}function Er(t){return void 0===t?null:Qn(t)}function Tr(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||yr())&&!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=yr(),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!(!mr("fireauth.oauthhelper",l)&&!mr("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 qr(t){var e=t;if("object"==typeof t&&null!=t)for(var n in e="length"in t?[]:{},t)Lr(e,n,qr(t[n]));return e}function Vr(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,qr(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 OIDC ID token requires a valid unhashed nonce.","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":"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[mi];var r=n[di];if(n=n[yi],"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",yi+" property must be a non empty string when specified.");this.b=n||null}else{if(void 0!==e)throw new Yr("argument-error",mi+" 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[vi])&&e.length)this.f=e;else if(void 0!==e)throw new Yr("argument-error",vi+" 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",yi="minimumVersion",mi="packageName",vi="bundleId";function gi(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 Ei(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 Ti(t){return(t=Si(t))&&t.sub&&t.iss&&t.aud&&t.exp?new Ei(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}Ei.prototype.R=function(){return this.c},Ei.prototype.g=function(){return this.b};var Ii,Ci={ad:{bb:"https://www.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://securetoken.googleapis.com/v1/token",id:"p"},cd:{bb:"https://staging-www.sandbox.googleapis.com/identitytoolkit/v3/relyingparty/",ib:"https://staging-securetoken.sandbox.googleapis.com/v1/token",id:"s"},dd:{bb:"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]).bb,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={Wc:{Oa:"locale",Da:500,Ca:600,Pa:"facebook.com",hb:ki},Yc:{Oa:null,Da:500,Ca:620,Pa:"github.com",hb:ki},Zc:{Oa:"hl",Da:515,Ca:680,Pa:"google.com",hb:ki},ed:{Oa:"lang",Da:485,Ca:705,Pa:"twitter.com",hb:Ai}};function Ri(t){for(var e in Di)if(Di[e].Pa==t)return Di[e];return null}function Oi(t){var e={};e["facebook.com"]=Fi,e["google.com"]=qi,e["github.com"]=Ui,e["twitter.com"]=Vi;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=Ti(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",qr((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 qi(t){if(Li.call(this,t),"google.com"!=this.providerId)throw Error("Invalid provider ID!")}function Vi(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=Ti(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.cb=(Ri(t)||{}).Oa||null,this.ab=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 v(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 v(t)&&(e=t.accessToken),(new eo).credential({accessToken:e})}function ro(){$i.call(this,"google.com"),this.wa("profile")}function io(t,e){var n=t;return v(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(v(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.Ua&&t.Ta||t.Fa&&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 yo(t){return t.a.Fa&&t.a.ba?{temporaryProof:t.a.Fa,phoneNumber:t.a.ba}:{sessionInfo:t.a.Ua,code:t.a.Ta}}function mo(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 vo(t,e){if(!t)throw new Yr("missing-verification-id");if(!e)throw new Yr("missing-verification-code");return new fo({Ua:t,Ta:e})}function go(t){if(t.temporaryProof&&t.phoneNumber)return new fo({Fa: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 Eo(){this.b=null,this.a=[]}S(Li,xi),S(Fi,Li),S(Ui,Li),S(qi,Li),S(Vi,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.Ea=function(t){return this.zb=H(t),this},S(Ji,Xi),S($i,Xi),$i.prototype.wa=function(t){return q(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=v(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,Ts,{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,vs,{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.Va(yo(this))},fo.prototype.b=function(t,e){var n=yo(this);return n.idToken=e,Ns(t,Is,n)},fo.prototype.f=function(t,e){var n=yo(this);return n.operation="REAUTH",Wi(t=Ns(t,Cs,n),e)},fo.prototype.A=function(){var t={providerId:"phone"};return this.a.Ua&&(t.verificationId=this.a.Ua),this.a.Ta&&(t.verificationCode=this.a.Ta),this.a.Fa&&(t.temporaryProof=this.a.Fa),this.a.ba&&(t.phoneNumber=this.a.ba),t},mo.prototype.Va=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,ys,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(mo,{PROVIDER_ID:"phone"}),Fr(mo,{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 To,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:go(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},To=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),qo=new Fo("WARNING",900),Vo=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(m(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=Vo),!(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.Ma.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.Ma.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.Ma.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.Ma.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.Ma=function(t){var e=this.h;e&&e.log(qo,"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(qo,"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(qo,"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():To.a(),e.w=e.B?ko(e.B):ko(To),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(y(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,!q(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 me&&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.Ga,e)):e.o=sn(e.Ga,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,ga(t)}function ya(t){if(t.a){if(!t.u)throw new ba(t);t.u=!1}}function ma(t,e,n,r){t.g.push([e,n,r]),t.a&&ga(t)}function va(t){return U(t.g,function(t){return m(t[1])})}function ga(e){if(e.h&&e.a&&va(e)){var n=e.h,r=Ea[n];r&&(l.clearTimeout(r.a),delete Ea[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,va(e)||(r=!0)}}e.c=n,t&&(s=_(e.m,e,!0),t=_(e.m,e,!1),n instanceof pa?(ma(n,s,t),n.w=!0):n.then(s,t)),r&&(n=new _a(n),Ea[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).Ga=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.xa=function(){this.a&&(this.c&&(this.c=!1,this.f=!0,this.a.abort(),this.f=!1),ua(this,!0)),Zo.qb.xa.call(this)},t.Lb=function(){this.ta||(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),ya(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 ma(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 Ea[this.a],this.b};var Ea={};function Ta(t){var e,n=document,r=et(t).toString(),i=document.createElement("SCRIPT"),o={Nb:i,Ga: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);ya(a),da(a,!1,t)},5e3),o.Ga=e,i.onload=i.onreadystatechange=function(){i.readyState&&"loaded"!=i.readyState&&"complete"!=i.readyState||(Ia(i,!1,e),ya(a),da(a,!0,null))},i.onerror=function(){Ia(i,!0,e);var t=new Aa(Ca,"Error while loading script "+r);ya(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.Ga)}}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 qa(t,e,n,r,i,o,a){(t=function(){var t=yr();return!((t=fr(t)!=lr?null:(t=t.match(/\sChrome\/(\d+)/i))&&2==t.length?parseInt(t[1],10):null)&&t<30)&&(!me||!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){ma(t,null,e,void 0)}(Ta(nt(Va,{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 Va=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,gs,{})},Da.prototype.rb=function(t,e){return Ns(this,ms,{idToken:t,email:e})},Da.prototype.sb=function(t,e){return Ns(this,vs,{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,ms,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.Va=function(t){return Ns(this,Ss,t)},t.$a=function(t,e){return Ns(this,ds,{oobCode:t,newPassword:e})},t.Ka=function(t){return Ns(this,es,{oobCode:t})},t.Xa=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},ys={endpoint:"sendVerificationCode",V:["phoneNumber","recaptchaToken"],fa:"sessionInfo",F:!0},ms={endpoint:"setAccountInfo",V:["idToken"],D:Wa,T:!0},vs={endpoint:"setAccountInfo",V:["idToken"],D:function(t){if(Wa(t),!t.password)throw new Yr("weak-password")},K:Ka,T:!0},gs={endpoint:"signupNewUser",K:Ka,T:!0,F:!0},bs={endpoint:"verifyAssertion",D:Ga,Qa:za,K:Ya,T:!0,F:!0},ws={endpoint:"verifyAssertion",D:Ga,Qa: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")},Qa:za,K:Ya,T:!0},Es={endpoint:"verifyCustomToken",D:function(t){if(!t.token)throw new Yr("invalid-custom-token")},K:Ka,T:!0,F:!0},Ts={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",T().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){qa(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(Tr(i)),t.a,t.i.get())})}(t,e.endpoint,i,n,e.Yb,e.wb||!1)}).then(function(t){return r=t,e.Qa?e.Qa(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",ADMIN_ONLY_OPERATION:"admin-restricted-operation"},e||{}),e=(e=n.match(/^[^\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=Er(t)),new Yr("internal-error",e)}function Ds(t){this.b=t,this.a=null,this.fb=function(o){return(Ms=Ms||new jt(function(t,e){function n(){Nr(),mr("gapi.load")("gapi.iframes",{callback:t,ontimeout:function(){Nr(),e(Error("Network Error"))},timeout:Os.get()})}if(mr("gapi.iframes.Iframe"))t();else if(mr("gapi.load"))n();else{var r="__iframefcb"+Math.floor(1e6*Math.random()).toString();l[r]=function(){mr("gapi.load")?n():e(Error("Network Error"))},Yt(Ta(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){mr("gapi.iframes.getContext")().open({where:document.body,url:o.b,messageHandlersFilter:mr("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=En(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().Aa()}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 qs(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 Vs(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.fb.then(function(){t.a.register("authEvent",e,mr("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=En(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.ab=n,bn(t,"providerId",this.a.providerId),n=Tr((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.cb&&e.ab&&!n[e.cb]&&(n[e.cb]=e.ab),Q(n)||bn(t,"customParameters",Er(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 Vs(t).then(function(){return function(e,n){return e.fb.then(function(){return new jt(function(t){e.a.send(n.type,n,t,mr("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=yr();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=qs(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=qs(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 Vs(this).then(function(){return t.i.fb}).s(function(){throw t.a=null,new Yr("network-request-failed")})},t.Rb=function(){return!0},t.ya=function(t){this.g.push(t)},t.La=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,Er(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:q(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&&q(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 yu(){var t={};t.Browser=gu,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=Er(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=Er(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 mu,vu,gu={C:hu,Sa:pu},bu={C:hu,Sa:pu},wu={C:Ws,Sa:fu},_u={C:hu,Sa:fu},Eu={$c:"local",NONE:"none",bd:"session"};function Tu(){var t=!(Cr(yr())||!ar()),e=_r(),n=vr();this.m=t,this.h=e,this.l=n,this.a={},t=mu=mu||new yu;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.Sa}catch(t){this.i=new cu}this.u=new cu,this.f=_(this.Pb,this),this.b={}}function Su(){return vu=vu||new Tu}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=Tu.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.Za(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.Za(e))},me&&Ie&&10==Ie&&l.localStorage.getItem(e)!==t.a.newValue&&t.a.newValue!==t.a.oldValue?setTimeout(n,10):n()}}else L(t,_(this.Za,this))},t.Za=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 qu(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 Vu(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&&(qu(t),i=0);else{if(!y(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&&(qu(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;Vu(e,t),t=[];var n=8*e.g;e.c<56?Vu(e,Uu,56-e.c):Vu(e,Uu,e.b-(e.c-56));for(var r=63;56<=r;r--)e.f[r]=255&n,n/=256;for(qu(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.ya(function t(e){return n(e),r.La(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(mr("BuildInfo.packageName",l).toLowerCase()+"://")&&e({url:t}),"function"==typeof r)try{r(t)}catch(t){console.error(t)}},So=So||new Eo,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=mr("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.Ba?this.Ba:this.Ba=(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 mr("universalLinks.subscribe",l))throw Qu("cordova-universal-links-plugin-fix is not installed");if(void 0===mr("BuildInfo.packageName",l))throw Qu("cordova-plugin-buildinfo is not installed");if("function"!=typeof mr("cordova.plugins.browsertab.openUrl",l))throw Qu("cordova-plugin-browsertab is not installed");if("function"!=typeof mr("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=mr("BuildInfo.packageName",l);if("string"!=typeof s)throw new Yr("invalid-cordova-configuration");var u=mr("BuildInfo.displayName",l),c={};if(yr().toLowerCase().match(/iphone|ipad|ipod/))c.ibi=s;else{if(!yr().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=mr("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=mr("cordova.plugins.browsertab.openUrl",l)))throw new Yr("invalid-cordova-configuration");e(h)}else{if("function"!=typeof(e=mr("cordova.InAppBrowser.open",l)))throw new Yr("invalid-cordova-configuration");t=yr(),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=mr("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.ya(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),yr().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.La(s),i.c=null})},t.ya=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.La=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 gc,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.ya(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){q(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.La(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<=T()-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=T())),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.ya(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,vc(t,!1,null,null))}function yc(t){t.g&&!t.i&&vc(t,!1,null,null)}function mc(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 vc(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):mc(t,n):mc(t,{user:null}),t.f=[],t.c=[]}function gc(){}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 mo(t).Va(e,n).then(function(t){return new wc(t,r)})}function Ec(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 Tc(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 T()+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?qa(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),qc(this,e[Oa]),Cc(this.b,e),Lr(this,"refreshToken",this.b.a),jc(this,n||{}),nn.call(this),this.J=!1,this.o&&gr()&&(this.i=fc(this.o,this.l,this.m)),this.O=[],this.h=null,this.w=function(e){return new Tc(function(){return e.G(!0)},function(t){return!(!t||"auth/network-request-failed"!=t.code)},function(){var t=e.b.c-T()-3e5;return 0<t?t:0})}(this),this.W=_(this.Ha,this);var r=this;this.ga=null,this.va=function(t){r.sa(t.g)},this.Z=null,this.P=[],this.ua=function(t){Mc(r,t.c)},this.Y=null}function Pc(t,e){t.Z&&Ge(t.Z,"languageCodeChanged",t.va),(t.Z=e)&&Ke(e,"languageCodeChanged",t.va)}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.ua),(t.Y=e)&&Ke(e,"frameworkChanged",t.ua)}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 qc(t,e){t.ma=e,Lr(t,"_lat",e)}function Vc(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")),qc(t,e[Oa]),zc(t,"refreshToken",t.b.a))}function $c(t,e){return Xc(t).then(function(){if(q(Qc(t),e))return Vc(t).then(function(){throw new Yr("provider-already-linked")})})}function Zc(t,e,n){return Ur({user:t,credential:go(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(!gr())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.Da,o&&o.Ca);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(!gr())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,Vc(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(){V(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-T())/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?(vc(this,!0,null,t.a),Yt()):e.za(n,r)?function(e,t,n){n=n.za(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){vc(e,s,t,null)}).s(function(t){vc(e,s,null,t)})}(this,t,e):Xt(new Yr("invalid-auth-event")):(vc(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,vc(t,!0,null,e))})}(n))})},gc.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.za(n,r)?function(t,e){var n=t.b,r=t.c;e.za(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=vo(this.verificationId,t),this.a(t)},Tc.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)},Tc.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||T()>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.sa=function(t){this.ga=t,Fa(this.a,t)},Oc.prototype.ha=function(){return this.ga},Oc.prototype.Aa=function(){return W(this.P)},Oc.prototype.Ha=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 Vc(t)}).then(Wc)}))},t.dc=function(t){return this.G(t).then(function(t){return new Ec(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&&(qc(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.gb(t)},t.gb=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.eb(t)},t.eb=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.eb,n))}))},t.Bc=function(t,e){var n=this;return ih(this,Yt().then(function(){return _c(Lc(n),t,e,_(n.gb,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))}),Vc(n)}).then(Wc))},t.Qc=function(e){var n=this;return ih(this,Xc(this).then(function(t){return q(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[mo.PROVIDER_ID]||Lr(n,"phoneNumber",null),Vc(n)}):Vc(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.za=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 Vc(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)?{}:gi(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 Eu)Eu[n]!==e&&r.push(Nu(t.b,fh(Eu[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],E(t,a),o);else n(i)})}(r)}ch.prototype.g=function(){var e=this,n=fh("local");mh(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 mh(t,function(){return t.b.set(t.c,e.A(),t.a)})}function dh(t){return mh(t,function(){return Nu(t.b,t.c,t.a)})}function yh(t,e){return mh(t,function(){return t.b.get(t.c,t.a).then(function(t){return t&&e&&(t.authDomain=e),oh(t||{})})})}function mh(t,e){return t.f=t.f.then(e,e),t.f}function vh(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)),Th(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 yh(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){Th(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.ua=_(this.bc,this),this.va=_(this.mc,this),this.Ha=_(this.nc,this),this.a=null,function(e){var n=Ih(e).options.authDomain,r=Ih(e).options.apiKey;n&&gr()&&(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.sa(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.sa(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 gh(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(!gr())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 Eh(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.Aa())}).then(function(t){return Ch(e)&&t.uid==Ch(e).uid?Yc(Ch(e),t):(Th(e,t),Bc(t)),e.aa(t)}).then(function(){Ah(e)})}function Th(t,e){Ch(t)&&(function(t,e){B(t.O,function(t){return t==e})}(Ch(t),t.ub),Ge(Ch(t),"tokenChanged",t.ua),Ge(Ch(t),"userDeleted",t.va),Ge(Ch(t),"userInvalidated",t.Ha),Uc(Ch(t))),e&&(e.O.push(t.ub),Ke(e,"tokenChanged",t.ua),Ke(e,"userDeleted",t.va),Ke(e,"userInvalidated",t.Ha),0<t.o&&Fc(e)),Lr(t,"currentUser",e),e&&(e.sa(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=go(t),r=Oi(t),Eh(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(){V(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 Eu)if(Eu[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(!vr()&&"none"!==t)throw n}}(e),mh(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(vh,nn),S(gh,Oe),S(bh,Oe),(t=vh.prototype).mb=function(t){return t=this.h.mb(t),kh(this,t)},t.sa=function(t){this.Z===t||this.l||(this.Z=t,Fa(this.b,this.Z),this.dispatchEvent(new gh(this.ha())))},t.ha=function(){return this.Z},t.Tc=function(){var t=l.navigator;this.sa(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.Aa=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.za=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=go(t),a=Oi(t),t});return kh(this,t=i.Y.then(function(){return s}).then(function(t){return Eh(i,t)}).then(function(){return Ur({user:Ch(i),credential:o,additionalUserInfo:a,operationType:"signIn"})}))},t.Lc=function(e){if(!gr())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.Da,t&&t.Ca);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(!gr())return Xt(new Yr("operation-not-supported-in-this-environment"));var e=this;return kh(this,wh(this).then(function(){return function(t){return mh(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&&yc(e.a.b),t}).s(function(t){throw e.a&&yc(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-T())/1e3,e=new Oc(e,o),n&&(e.da=n),r&&Mc(e,r),Yc(e,t),e}(t,n,e.w,e.Aa());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)):(Th(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&&yc(t.a.b),Ch(t)?(Th(t,null),dh(t.h).then(function(){Ah(t)})):Yt()});return kh(this,e)},t.Nc=function(){var r=this;return yh(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)&&(Th(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&&q(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(){m(t)?t(Ch(r)):m(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(),m(t)?t(Ch(r)):m(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,Es,{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,Ts,{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.Ra=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.Ra(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||q(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),yc(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 gi(t)}).then(function(t){return r.b.lb(e,t)}).then(function(){}))},t.Uc=function(t){return this.Ka(t).then(function(t){return t.data.email})},t.$a=function(t,e){return kh(this,this.b.$a(t,e).then(function(){}))},t.Ka=function(t){return kh(this,this.b.Ka(t).then(function(t){return new Vr(t)}))},t.Xa=function(t){return kh(this,this.b.Xa(t).then(function(){}))},t.kb=function(e,t){var n=this;return kh(this,Yt().then(function(){return void 0===t||Q(t)?{}:gi(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.Ra,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.Ra(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=Vn(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 qh(){this.b=l.grecaptcha?1/0:0,this.f=null,this.a="__rcb"+Math.floor(1e6*Math.random()).toString()}var Vh=new Y($,"https://www.google.com/recaptcha/api.js?onload=%{onload}&render=explicit&hl=%{hl}"),Bh=new Ar(3e4,6e4);qh.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(Ta(nt(Vh,{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))})},qh.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 qh,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(!Vn(e)||!this.i&&Vn(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=mr(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=mr(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(){V(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().Aa()}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).Ba=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.Ba().then(function(){if(null===n.c){var t=n.u;if(!n.i){var e=Vn(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=Vn(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:v}}function rl(t,e){return{name:t||"",M:"a function",optional:!!e,N:m}}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)&&m(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:E(function(t){return this[t]},n),set:E(function(t,e,n,r){$h(t,[n],[r],!0),this[e]=r},r,n,e[n].Ya),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(vh.prototype,{Xa:{name:"applyActionCode",j:[tl("code")]},Ka:{name:"checkActionCode",j:[tl("code")]},$a:{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:[]},Ra:{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(vh.prototype,{lc:{name:"languageCode",Ya:sl(tl(),il(),"languageCode")},ti:{name:"tenantId",Ya:sl(tl(),il(),"tenantId")}}),(vh.Persistence=Eu).LOCAL="local",vh.Persistence.SESSION="session",vh.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()]},eb:{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()]},gb:{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",Ya: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,{wa:{name:"addScope",j:[tl("scope")]},Ea:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(Zi,"credential",to,[sl(tl(),nl(),"token")]),hl(co,"credentialWithLink",ho,[tl("email"),tl("emailLink")]),ul(eo.prototype,{wa:{name:"addScope",j:[tl("scope")]},Ea:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(eo,"credential",no,[sl(tl(),nl(),"token")]),ul(ro.prototype,{wa:{name:"addScope",j:[tl("scope")]},Ea:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(ro,"credential",io,[sl(tl(),sl(nl(),il()),"idToken"),sl(tl(),il(),"accessToken",!0)]),ul(oo.prototype,{Ea:{name:"setCustomParameters",j:[nl("customOAuthParameters")]}}),hl(oo,"credential",ao,[sl(tl(),nl(),"token"),tl("secret",!0)]),ul($i.prototype,{wa:{name:"addScope",j:[tl("scope")]},credential:{name:"credential",j:[sl(tl(),sl(nl(),il()),"optionsOrIdToken"),sl(tl(),il(),"accessToken",!0)]},Ea:{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(mo,"credential",vo,[tl("verificationId"),tl("verificationCode")]),ul(mo.prototype,{Va:{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.registerService)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:vh,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",mo,[{name:"auth",M:"an instance of Firebase Auth",optional:!0,N:function(t){return!!(t&&t instanceof vh)}}]),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.registerService("auth",function(t,e){return e({INTERNAL:{getUid:_((t=new vh(t)).getUid,t),getToken:_(t.cc,t),addAuthTokenListener:_(t.Wb,t),removeAuthTokenListener:_(t.Ec,t)}}),t},t,function(t,e){if("create"===t)try{e.auth()}catch(t){}}),fl.INTERNAL.extendNamespace({User:Oc})}()}).apply("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var hs=(ls.prototype.set=function(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),Aa(e))},ls.prototype.get=function(t){var e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:Na(e)},ls.prototype.remove=function(t){this.domStorage_.removeItem(this.prefixedName_(t))},ls.prototype.prefixedName_=function(t){return this.prefix_+t},ls.prototype.toString=function(){return this.domStorage_.toString()},ls);function ls(t){this.domStorage_=t,this.prefix_="firebase:"}var fs=(ps.prototype.set=function(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e},ps.prototype.get=function(t){return Da(this.cache_,t)?this.cache_[t]:null},ps.prototype.remove=function(t){delete this.cache_[t]},ps);function ps(){this.cache_={},this.isInMemoryStorage=!0}function ds(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 hs(e)}}catch(t){}return new fs}function ys(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;ha(++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 Ma;n.update(e);var r=n.digest();return fa.encodeByteArray(r)}function ms(t,e){ha(!e||!0===t||!1===t,"Can't turn on custom loggers persistently."),!0===t?(ks.logLevel=Qa.VERBOSE,Ps=ks.log.bind(ks),e&&As.set("logging_enabled",!0)):"function"==typeof t?Ps=t:(Ps=null,As.remove("logging_enabled"))}function vs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!0===Ms&&(Ms=!1,null===Ps&&!0===As.get("logging_enabled")&&ms(!0)),Ps){var n=Os.apply(null,t);Ps(n)}}function gs(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];vs.apply(void 0,oa([n],t))}}function bs(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE INTERNAL ERROR: "+Os.apply(void 0,oa(t));ks.error(n)}function ws(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE FATAL ERROR: "+Os.apply(void 0,oa(t));throw ks.error(n),new Error(n)}function _s(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="FIREBASE WARNING: "+Os.apply(void 0,oa(t));ks.warn(n)}function Es(t){return"number"==typeof t&&(t!=t||t==Number.POSITIVE_INFINITY||t==Number.NEGATIVE_INFINITY)}function Ts(t,e){return t===e?0:t<e?-1:1}function Ss(t,e){if(e&&t in e)return e[t];throw new Error("Missing required key ("+t+") in object: "+Aa(e))}function Is(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 Cs,Ns=ds("localStorage"),As=ds("sessionStorage"),ks=new Ja("@firebase/database"),Ds="FIREBASE_DATABASE_EMULATOR_HOST",Rs=(Cs=1,function(){return Cs++}),Os=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+=Os.apply(null,t[r]):"object"==typeof t[r]?n+=Aa(t[r]):n+=t[r],n+=" ";return n},Ps=null,Ms=!0,xs="[MIN_NAME]",Ls="[MAX_NAME]",Fs=function(t,e){if(t===e)return 0;if(t===xs||e===Ls)return-1;if(e===xs||t===Ls)return 1;var n=Ks(t),r=Ks(e);return null!==n?null!==r?n-r==0?t.length-e.length:n-r:-1:null!==r?1:t<e?-1:1},Us=function(t){if("object"!=typeof t||null===t)return Aa(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+=Aa(e[i]),r+=":",r+=Us(t[e[i]]);return r+="}"};function qs(t,e){for(var n in t)t.hasOwnProperty(n)&&e(n,t[n])}function Vs(t){var e,n,r,i,o,a,s;for(ha(!Es(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 Bs(t){try{t()}catch(e){setTimeout(function(){var t=e.stack||"";throw _s("Exception was thrown by user callback.",t),e},Math.floor(0))}}function js(t,e){var n=setTimeout(t,e);return"object"==typeof n&&n.unref&&n.unref(),n}var Ws=new RegExp("^-?(0*)\\d{1,10}$"),Ks=function(t){if(Ws.test(t)){var e=Number(t);if(-2147483648<=e&&e<=2147483647)return e}return null},Qs=(Object.defineProperty(Hs,"Empty",{get:function(){return new Hs("")},enumerable:!0,configurable:!0}),Hs.prototype.getFront=function(){return this.pieceNum_>=this.pieces_.length?null:this.pieces_[this.pieceNum_]},Hs.prototype.getLength=function(){return this.pieces_.length-this.pieceNum_},Hs.prototype.popFront=function(){var t=this.pieceNum_;return t<this.pieces_.length&&t++,new Hs(this.pieces_,t)},Hs.prototype.getBack=function(){return this.pieceNum_<this.pieces_.length?this.pieces_[this.pieces_.length-1]:null},Hs.prototype.toString=function(){for(var t="",e=this.pieceNum_;e<this.pieces_.length;e++)""!==this.pieces_[e]&&(t+="/"+this.pieces_[e]);return t||"/"},Hs.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||"/"},Hs.prototype.slice=function(t){return void 0===t&&(t=0),this.pieces_.slice(this.pieceNum_+t)},Hs.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 Hs(t,0)},Hs.prototype.child=function(t){for(var e=[],n=this.pieceNum_;n<this.pieces_.length;n++)e.push(this.pieces_[n]);if(t instanceof Hs)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 Hs(e,0)},Hs.prototype.isEmpty=function(){return this.pieceNum_>=this.pieces_.length},Hs.relativePath=function(t,e){var n=t.getFront(),r=e.getFront();if(null===n)return e;if(n===r)return Hs.relativePath(t.popFront(),e.popFront());throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")},Hs.comparePaths=function(t,e){for(var n=t.slice(),r=e.slice(),i=0;i<n.length&&i<r.length;i++){var o=Fs(n[i],r[i]);if(0!==o)return o}return n.length===r.length?0:n.length<r.length?-1:1},Hs.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},Hs.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},Hs);function Hs(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 Gs=(Object.defineProperty(zs,"MAX_PATH_DEPTH",{get:function(){return 32},enumerable:!0,configurable:!0}),Object.defineProperty(zs,"MAX_PATH_LENGTH_BYTES",{get:function(){return 768},enumerable:!0,configurable:!0}),zs.prototype.push=function(t){0<this.parts_.length&&(this.byteLength_+=1),this.parts_.push(t),this.byteLength_+=Ka(t),this.checkValid_()},zs.prototype.pop=function(){var t=this.parts_.pop();this.byteLength_-=Ka(t),0<this.parts_.length&&(this.byteLength_-=1)},zs.prototype.checkValid_=function(){if(this.byteLength_>zs.MAX_PATH_LENGTH_BYTES)throw new Error(this.errorPrefix_+"has a key path longer than "+zs.MAX_PATH_LENGTH_BYTES+" bytes ("+this.byteLength_+").");if(this.parts_.length>zs.MAX_PATH_DEPTH)throw new Error(this.errorPrefix_+"path specified exceeds the maximum depth that can be written ("+zs.MAX_PATH_DEPTH+") or object contains a cycle "+this.toErrorString())},zs.prototype.toErrorString=function(){return 0==this.parts_.length?"":"in property '"+this.parts_.join(".")+"'"},zs);function zs(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_+=Ka(this.parts_[n]);this.checkValid_()}var Ys="firebaseio.com",Xs="websocket",Js="long_polling",$s=(Zs.prototype.needsQueryParam=function(){return this.host!==this.internalHost||this.isCustomHost()||this.includeNamespaceInQueryParams},Zs.prototype.isCacheableHost=function(){return"s-"===this.internalHost.substr(0,2)},Zs.prototype.isDemoHost=function(){return"firebaseio-demo.com"===this.domain},Zs.prototype.isCustomHost=function(){return"firebaseio.com"!==this.domain&&"firebaseio-demo.com"!==this.domain},Zs.prototype.updateHost=function(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&Ns.set("host:"+this.host,this.internalHost))},Zs.prototype.connectionURL=function(t,e){var n;if(ha("string"==typeof t,"typeof type must == string"),ha("object"==typeof e,"typeof params must == object"),t===Xs)n=(this.secure?"wss://":"ws://")+this.internalHost+"/.ws?";else{if(t!==Js)throw new Error("Unknown connection type: "+t);n=(this.secure?"https://":"http://")+this.internalHost+"/.lp?"}this.needsQueryParam()&&(e.ns=this.namespace);var r=[];return qs(e,function(t,e){r.push(t+"="+e)}),n+r.join("&")},Zs.prototype.toString=function(){var t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t},Zs.prototype.toURLString=function(){return(this.secure?"https://":"http://")+this.host},Zs);function Zs(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=Ns.get("host:"+t)||this.host}function tu(t){var e=fu(t),n=e.namespace;"firebase"===e.domain&&ws(e.host+" is no longer supported. Please use <YOUR FIREBASE>.firebaseio.com instead"),n&&"undefined"!=n||"localhost"===e.domain||ws("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:")&&_s("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 $s(e.host,e.secure,n,r,"",n!=e.subdomain),path:new Qs(e.pathString)}}function eu(t){return"string"==typeof t&&0!==t.length&&!pu.test(t)}function nu(t){return"string"==typeof t&&0!==t.length&&!du.test(t)}function ru(t){return null===t||"string"==typeof t||"number"==typeof t&&!Es(t)||t&&"object"==typeof t&&Da(t,".sv")}function iu(t,e,n,r,i){i&&void 0===n||mu(Ba(t,e,i),n,r)}function ou(t,e,n,r,i){if(!i||void 0!==n){var o=Ba(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=[];qs(n,function(t,e){var n=new Qs(t);if(mu(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(!eu(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(Qs.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 au(t,e,n,r){if(!r||void 0!==n){if(Es(n))throw new Error(Ba(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(Ba(t,e,r)+"must be a valid Firebase priority (a string, finite number, server value, or null).")}}function su(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(Ba(t,e,r)+'must be a valid event type = "value", "child_added", "child_removed", "child_changed", or "child_moved".')}}function uu(t,e,n,r){if(!(r&&void 0===n||eu(n)))throw new Error(Ba(t,e,r)+'was an invalid key = "'+n+'". Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')}function cu(t,e,n,r){if(!(r&&void 0===n||nu(n)))throw new Error(Ba(t,e,r)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')}function hu(t,e){if(".info"===e.getFront())throw new Error(t+" failed = Can't modify data under /.info/")}function lu(t,e,n){var r=n.path.toString();if("string"!=typeof n.repoInfo.host||0===n.repoInfo.host.length||!eu(n.repoInfo.namespace)&&"localhost"!==n.repoInfo.host.split(":")[0]||0!==r.length&&!function(t){return t=t&&t.replace(/^\/*\.info(\/|$)/,"/"),nu(t)}(r))throw new Error(Ba(t,e,!1)+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')}var fu=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=ra(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]):_s("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}},pu=/[\[\].#$\/\u0000-\u001F\u007F]/,du=/[\[\].#$\u0000-\u001F\u007F]/,yu=10485760,mu=function(n,t,e){var r=e instanceof Qs?new Gs(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(Es(t))throw new Error(n+"contains "+t.toString()+" "+r.toErrorString());if("string"==typeof t&&t.length>yu/3&&Ka(t)>yu)throw new Error(n+"contains a string greater than "+yu+" utf8 bytes "+r.toErrorString()+" ('"+t.substring(0,50)+"...')");if(t&&"object"==typeof t){var i=!1,o=!1;if(qs(t,function(t,e){if(".value"===t)i=!0;else if(".priority"!==t&&".sv"!==t&&(o=!0,!eu(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),mu(n,e,r),r.pop()}),i&&o)throw new Error(n+' contains ".value" child '+r.toErrorString()+" in addition to actual children.")}},vu=(gu.prototype.cancel=function(t){Va("OnDisconnect.cancel",0,1,arguments.length),ja("OnDisconnect.cancel",1,t,!0);var e=new ya;return this.repo_.onDisconnectCancel(this.path_,e.wrapCallback(t)),e.promise},gu.prototype.remove=function(t){Va("OnDisconnect.remove",0,1,arguments.length),hu("OnDisconnect.remove",this.path_),ja("OnDisconnect.remove",1,t,!0);var e=new ya;return this.repo_.onDisconnectSet(this.path_,null,e.wrapCallback(t)),e.promise},gu.prototype.set=function(t,e){Va("OnDisconnect.set",1,2,arguments.length),hu("OnDisconnect.set",this.path_),iu("OnDisconnect.set",1,t,this.path_,!1),ja("OnDisconnect.set",2,e,!0);var n=new ya;return this.repo_.onDisconnectSet(this.path_,t,n.wrapCallback(e)),n.promise},gu.prototype.setWithPriority=function(t,e,n){Va("OnDisconnect.setWithPriority",2,3,arguments.length),hu("OnDisconnect.setWithPriority",this.path_),iu("OnDisconnect.setWithPriority",1,t,this.path_,!1),au("OnDisconnect.setWithPriority",2,e,!1),ja("OnDisconnect.setWithPriority",3,n,!0);var r=new ya;return this.repo_.onDisconnectSetWithPriority(this.path_,t,e,r.wrapCallback(n)),r.promise},gu.prototype.update=function(t,e){if(Va("OnDisconnect.update",1,2,arguments.length),hu("OnDisconnect.update",this.path_),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,_s("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.")}ou("OnDisconnect.update",1,t,this.path_,!1),ja("OnDisconnect.update",2,e,!0);var i=new ya;return this.repo_.onDisconnectUpdate(this.path_,t,i.wrapCallback(e)),i.promise},gu);function gu(t,e){this.repo_=t,this.path_=e}var bu=(wu.prototype.toJSON=function(){return Va("TransactionResult.toJSON",0,1,arguments.length),{committed:this.committed,snapshot:this.snapshot.toJSON()}},wu);function wu(t,e){this.committed=t,this.snapshot=e}var _u,Eu,Tu,Su=(_u="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Eu=0,Tu=[],function(t){var e,n=t===Eu;Eu=t;var r=new Array(8);for(e=7;0<=e;e--)r[e]=_u.charAt(t%64),t=Math.floor(t/64);ha(0===t,"Cannot push at time == 0");var i=r.join("");if(n){for(e=11;0<=e&&63===Tu[e];e--)Tu[e]=0;Tu[e]++}else for(e=0;e<12;e++)Tu[e]=Math.floor(64*Math.random());for(e=0;e<12;e++)i+=_u.charAt(Tu[e]);return ha(20===i.length,"nextPushId: Length should be 20."),i}),Iu=(Cu.Wrap=function(t,e){return new Cu(t,e)},Cu);function Cu(t,e){this.name=t,this.node=e}var Nu,Au=(ku.prototype.getCompare=function(){return this.compare.bind(this)},ku.prototype.indexedValueChanged=function(t,e){var n=new Iu(xs,t),r=new Iu(xs,e);return 0!==this.compare(n,r)},ku.prototype.minPost=function(){return Iu.MIN},ku);function ku(){}var Du,Ru=(Zo(Ou,Du=Au),Object.defineProperty(Ou,"__EMPTY_NODE",{get:function(){return Nu},set:function(t){Nu=t},enumerable:!0,configurable:!0}),Ou.prototype.compare=function(t,e){return Fs(t.name,e.name)},Ou.prototype.isDefinedOn=function(t){throw la("KeyIndex.isDefinedOn not expected to be called.")},Ou.prototype.indexedValueChanged=function(t,e){return!1},Ou.prototype.minPost=function(){return Iu.MIN},Ou.prototype.maxPost=function(){return new Iu(Ls,Nu)},Ou.prototype.makePost=function(t,e){return ha("string"==typeof t,"KeyIndex indexValue must always be a string."),new Iu(t,Nu)},Ou.prototype.toString=function(){return".key"},Ou);function Ou(){return null!==Du&&Du.apply(this,arguments)||this}var Pu,Mu=new Ru;function xu(t){return"number"==typeof t?"number:"+Vs(t):"string:"+t}function Lu(t){if(t.isLeafNode()){var e=t.val();ha("string"==typeof e||"number"==typeof e||"object"==typeof e&&Da(e,".sv"),"Priority must be a string or number.")}else ha(t===Pu||t.isEmpty(),"priority of unexpected type.");ha(t===Pu||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")}var Fu,Uu,qu,Vu,Bu=(Object.defineProperty(ju,"__childrenNodeConstructor",{get:function(){return Fu},set:function(t){Fu=t},enumerable:!0,configurable:!0}),ju.prototype.isLeafNode=function(){return!0},ju.prototype.getPriority=function(){return this.priorityNode_},ju.prototype.updatePriority=function(t){return new ju(this.value_,t)},ju.prototype.getImmediateChild=function(t){return".priority"===t?this.priorityNode_:ju.__childrenNodeConstructor.EMPTY_NODE},ju.prototype.getChild=function(t){return t.isEmpty()?this:".priority"===t.getFront()?this.priorityNode_:ju.__childrenNodeConstructor.EMPTY_NODE},ju.prototype.hasChild=function(){return!1},ju.prototype.getPredecessorChildName=function(t,e){return null},ju.prototype.updateImmediateChild=function(t,e){return".priority"===t?this.updatePriority(e):e.isEmpty()&&".priority"!==t?this:ju.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,e).updatePriority(this.priorityNode_)},ju.prototype.updateChild=function(t,e){var n=t.getFront();return null===n?e:e.isEmpty()&&".priority"!==n?this:(ha(".priority"!==n||1===t.getLength(),".priority must be the last token in a path"),this.updateImmediateChild(n,ju.__childrenNodeConstructor.EMPTY_NODE.updateChild(t.popFront(),e)))},ju.prototype.isEmpty=function(){return!1},ju.prototype.numChildren=function(){return 0},ju.prototype.forEachChild=function(t,e){return!1},ju.prototype.val=function(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()},ju.prototype.hash=function(){if(null===this.lazyHash_){var t="";this.priorityNode_.isEmpty()||(t+="priority:"+xu(this.priorityNode_.val())+":");var e=typeof this.value_;t+=e+":",t+="number"==e?Vs(this.value_):this.value_,this.lazyHash_=ys(t)}return this.lazyHash_},ju.prototype.getValue=function(){return this.value_},ju.prototype.compareTo=function(t){return t===ju.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof ju.__childrenNodeConstructor?-1:(ha(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))},ju.prototype.compareToLeafNode_=function(t){var e=typeof t.value_,n=typeof this.value_,r=ju.VALUE_TYPE_ORDER.indexOf(e),i=ju.VALUE_TYPE_ORDER.indexOf(n);return ha(0<=r,"Unknown leaf type: "+e),ha(0<=i,"Unknown leaf type: "+n),r===i?"object"==n?0:this.value_<t.value_?-1:this.value_===t.value_?0:1:i-r},ju.prototype.withIndex=function(){return this},ju.prototype.isIndexed=function(){return!0},ju.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},ju.VALUE_TYPE_ORDER=["object","boolean","number","string"],ju);function ju(t,e){void 0===e&&(e=ju.__childrenNodeConstructor.EMPTY_NODE),this.value_=t,this.priorityNode_=e,this.lazyHash_=null,ha(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),Lu(this.priorityNode_)}function Wu(){return null!==Vu&&Vu.apply(this,arguments)||this}var Ku=new(Zo(Wu,Vu=Au),Wu.prototype.compare=function(t,e){var n=t.node.getPriority(),r=e.node.getPriority(),i=n.compareTo(r);return 0===i?Fs(t.name,e.name):i},Wu.prototype.isDefinedOn=function(t){return!t.getPriority().isEmpty()},Wu.prototype.indexedValueChanged=function(t,e){return!t.getPriority().equals(e.getPriority())},Wu.prototype.minPost=function(){return Iu.MIN},Wu.prototype.maxPost=function(){return new Iu(Ls,new Bu("[PRIORITY-POST]",qu))},Wu.prototype.makePost=function(t,e){var n=Uu(t);return new Iu(e,new Bu("[PRIORITY-POST]",n))},Wu.prototype.toString=function(){return".priority"},Wu),Qu=(Hu.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},Hu.prototype.hasNext=function(){return 0<this.nodeStack_.length},Hu.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}},Hu);function Hu(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 Gu=(zu.prototype.copy=function(t,e,n,r,i){return new zu(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)},zu.prototype.count=function(){return this.left.count()+1+this.right.count()},zu.prototype.isEmpty=function(){return!1},zu.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},zu.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},zu.prototype.min_=function(){return this.left.isEmpty()?this:this.left.min_()},zu.prototype.minKey=function(){return this.min_().key},zu.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},zu.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_()},zu.prototype.removeMin_=function(){if(this.left.isEmpty())return Ju.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_()},zu.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 Ju.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_()},zu.prototype.isRed_=function(){return this.color},zu.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},zu.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},zu.prototype.moveRedRight_=function(){var t=this.colorFlip_();return t.left.left.isRed_()&&(t=(t=t.rotateRight_()).colorFlip_()),t},zu.prototype.rotateLeft_=function(){var t=this.copy(null,null,zu.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},zu.prototype.rotateRight_=function(){var t=this.copy(null,null,zu.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},zu.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)},zu.prototype.checkMaxDepth_=function(){var t=this.check_();return Math.pow(2,t)<=this.count()+1},zu.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)},zu.RED=!0,zu.BLACK=!1,zu);function zu(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:zu.RED,this.left=null!=r?r:Ju.EMPTY_NODE,this.right=null!=i?i:Ju.EMPTY_NODE}var Yu=(Xu.prototype.copy=function(t,e,n,r,i){return this},Xu.prototype.insert=function(t,e,n){return new Gu(t,e,null)},Xu.prototype.remove=function(t,e){return this},Xu.prototype.count=function(){return 0},Xu.prototype.isEmpty=function(){return!0},Xu.prototype.inorderTraversal=function(t){return!1},Xu.prototype.reverseTraversal=function(t){return!1},Xu.prototype.minKey=function(){return null},Xu.prototype.maxKey=function(){return null},Xu.prototype.check_=function(){return 0},Xu.prototype.isRed_=function(){return!1},Xu);function Xu(){}var Ju=($u.prototype.insert=function(t,e){return new $u(this.comparator_,this.root_.insert(t,e,this.comparator_).copy(null,null,Gu.BLACK,null,null))},$u.prototype.remove=function(t){return new $u(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,Gu.BLACK,null,null))},$u.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},$u.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?")},$u.prototype.isEmpty=function(){return this.root_.isEmpty()},$u.prototype.count=function(){return this.root_.count()},$u.prototype.minKey=function(){return this.root_.minKey()},$u.prototype.maxKey=function(){return this.root_.maxKey()},$u.prototype.inorderTraversal=function(t){return this.root_.inorderTraversal(t)},$u.prototype.reverseTraversal=function(t){return this.root_.reverseTraversal(t)},$u.prototype.getIterator=function(t){return new Qu(this.root_,null,this.comparator_,!1,t)},$u.prototype.getIteratorFrom=function(t,e){return new Qu(this.root_,t,this.comparator_,!1,e)},$u.prototype.getReverseIteratorFrom=function(t,e){return new Qu(this.root_,t,this.comparator_,!0,e)},$u.prototype.getReverseIterator=function(t){return new Qu(this.root_,null,this.comparator_,!0,t)},$u.EMPTY_NODE=new Yu,$u);function $u(t,e){void 0===e&&(e=$u.EMPTY_NODE),this.comparator_=t,this.root_=e}var Zu=Math.log(2),tc=(ec.prototype.nextBitIsOne=function(){var t=!(this.bits_&1<<this.current_);return this.current_--,t},ec);function ec(t){var e;this.count=(e=t+1,parseInt(Math.log(e)/Zu,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 nc,rc,ic=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 Gu(r,n.node,Gu.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 Gu(r,n.node,Gu.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 Gu(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,Gu.BLACK):(r(a,Gu.BLACK),r(a,Gu.RED))}return n}(new tc(c.length));return new Ju(e||t,n)},oc={},ac=(Object.defineProperty(sc,"Default",{get:function(){return ha(Ku,"ChildrenNode.ts has not been loaded"),nc=nc||new sc({".priority":oc},{".priority":Ku})},enumerable:!0,configurable:!0}),sc.prototype.get=function(t){var e=Ra(this.indexes_,t);if(!e)throw new Error("No index defined for "+t);return e instanceof Ju?e:null},sc.prototype.hasIndex=function(t){return Da(this.indexSet_,t.toString())},sc.prototype.addIndex=function(t,e){ha(t!==Mu,"KeyIndex always exists and isn't meant to be added to the IndexMap.");for(var n,r=[],i=!1,o=e.getIterator(Iu.Wrap),a=o.getNext();a;)i=i||t.isDefinedOn(a.node),r.push(a),a=o.getNext();n=i?ic(r,t.getCompare()):oc;var s=t.toString(),u=ta({},this.indexSet_);u[s]=t;var c=ta({},this.indexes_);return c[s]=n,new sc(c,u)},sc.prototype.addToIndexes=function(u,c){var h=this;return new sc(Pa(this.indexes_,function(t,e){var n=Ra(h.indexSet_,e);if(ha(n,"Missing index implementation for "+e),t===oc){if(n.isDefinedOn(u.node)){for(var r=[],i=c.getIterator(Iu.Wrap),o=i.getNext();o;)o.name!=u.name&&r.push(o),o=i.getNext();return r.push(u),ic(r,n.getCompare())}return oc}var a=c.get(u.name),s=t;return a&&(s=s.remove(new Iu(u.name,a))),s.insert(u,u.node)}),this.indexSet_)},sc.prototype.removeFromIndexes=function(n,r){return new sc(Pa(this.indexes_,function(t){if(t===oc)return t;var e=r.get(n.name);return e?t.remove(new Iu(n.name,e)):t}),this.indexSet_)},sc);function sc(t,e){this.indexes_=t,this.indexSet_=e}function uc(t,e){return Fs(t.name,e.name)}function cc(t,e){return Fs(t,e)}var hc,lc=(Object.defineProperty(fc,"EMPTY_NODE",{get:function(){return rc=rc||new fc(new Ju(cc),null,ac.Default)},enumerable:!0,configurable:!0}),fc.prototype.isLeafNode=function(){return!1},fc.prototype.getPriority=function(){return this.priorityNode_||rc},fc.prototype.updatePriority=function(t){return this.children_.isEmpty()?this:new fc(this.children_,t,this.indexMap_)},fc.prototype.getImmediateChild=function(t){if(".priority"===t)return this.getPriority();var e=this.children_.get(t);return null===e?rc:e},fc.prototype.getChild=function(t){var e=t.getFront();return null===e?this:this.getImmediateChild(e).getChild(t.popFront())},fc.prototype.hasChild=function(t){return null!==this.children_.get(t)},fc.prototype.updateImmediateChild=function(t,e){if(ha(e,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(e);var n,r=new Iu(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 fc(i,n,o)},fc.prototype.updateChild=function(t,e){var n=t.getFront();if(null===n)return e;ha(".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)},fc.prototype.isEmpty=function(){return this.children_.isEmpty()},fc.prototype.numChildren=function(){return this.children_.count()},fc.prototype.val=function(n){if(this.isEmpty())return null;var r={},i=0,o=0,a=!0;if(this.forEachChild(Ku,function(t,e){r[t]=e.val(n),i++,a&&fc.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},fc.prototype.hash=function(){if(null===this.lazyHash_){var r="";this.getPriority().isEmpty()||(r+="priority:"+xu(this.getPriority().val())+":"),this.forEachChild(Ku,function(t,e){var n=e.hash();""!==n&&(r+=":"+t+":"+n)}),this.lazyHash_=""===r?"":ys(r)}return this.lazyHash_},fc.prototype.getPredecessorChildName=function(t,e,n){var r=this.resolveIndex_(n);if(r){var i=r.getPredecessorKey(new Iu(t,e));return i?i.name:null}return this.children_.getPredecessorKey(t)},fc.prototype.getFirstChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.minKey();return n&&n.name}return this.children_.minKey()},fc.prototype.getFirstChild=function(t){var e=this.getFirstChildName(t);return e?new Iu(e,this.children_.get(e)):null},fc.prototype.getLastChildName=function(t){var e=this.resolveIndex_(t);if(e){var n=e.maxKey();return n&&n.name}return this.children_.maxKey()},fc.prototype.getLastChild=function(t){var e=this.getLastChildName(t);return e?new Iu(e,this.children_.get(e)):null},fc.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)},fc.prototype.getIterator=function(t){return this.getIteratorFrom(t.minPost(),t)},fc.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,Iu.Wrap),i=r.peek();null!=i&&e.compare(i,t)<0;)r.getNext(),i=r.peek();return r},fc.prototype.getReverseIterator=function(t){return this.getReverseIteratorFrom(t.maxPost(),t)},fc.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,Iu.Wrap),i=r.peek();null!=i&&0<e.compare(i,t);)r.getNext(),i=r.peek();return r},fc.prototype.compareTo=function(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===dc?-1:0},fc.prototype.withIndex=function(t){if(t===Mu||this.indexMap_.hasIndex(t))return this;var e=this.indexMap_.addIndex(t,this.children_);return new fc(this.children_,this.priorityNode_,e)},fc.prototype.isIndexed=function(t){return t===Mu||this.indexMap_.hasIndex(t)},fc.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(Ku),r=e.getIterator(Ku),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},fc.prototype.resolveIndex_=function(t){return t===Mu?null:this.indexMap_.get(t.toString())},fc.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/,fc);function fc(t,e,n){this.children_=t,this.priorityNode_=e,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&&Lu(this.priorityNode_),this.children_.isEmpty()&&ha(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}function pc(){return hc.call(this,new Ju(cc),lc.EMPTY_NODE,ac.Default)||this}var dc=new(Zo(pc,hc=lc),pc.prototype.compareTo=function(t){return t===this?0:1},pc.prototype.equals=function(t){return t===this},pc.prototype.getPriority=function(){return this},pc.prototype.getImmediateChild=function(t){return lc.EMPTY_NODE},pc.prototype.isEmpty=function(){return!1},pc);Object.defineProperties(Iu,{MIN:{value:new Iu(xs,lc.EMPTY_NODE)},MAX:{value:new Iu(Ls,dc)}}),Ru.__EMPTY_NODE=lc.EMPTY_NODE,Bu.__childrenNodeConstructor=lc,Pu=dc,qu=dc;var yc,mc=!0;function vc(r,t){if(void 0===t&&(t=null),null===r)return lc.EMPTY_NODE;if("object"==typeof r&&".priority"in r&&(t=r[".priority"]),ha(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 Bu(r,vc(t));if(r instanceof Array||!mc){var i=lc.EMPTY_NODE;return qs(r,function(t,e){if(Da(r,t)&&"."!==t.substring(0,1)){var n=vc(e);!n.isLeafNode()&&n.isEmpty()||(i=i.updateImmediateChild(t,n))}}),i.updatePriority(vc(t))}var o=[],a=!1;if(qs(r,function(t,e){if("."!==t.substring(0,1)){var n=vc(e);n.isEmpty()||(a=a||!n.getPriority().isEmpty(),o.push(new Iu(t,n)))}}),0==o.length)return lc.EMPTY_NODE;var e=ic(o,uc,function(t){return t.name},cc);if(a){var n=ic(o,Ku.getCompare());return new lc(e,vc(t),new ac({".priority":n},{".priority":Ku}))}return new lc(e,vc(t),ac.Default)}function gc(){return null!==yc&&yc.apply(this,arguments)||this}Uu=vc;var bc,wc=new(Zo(gc,yc=Au),gc.prototype.compare=function(t,e){var n=t.node.compareTo(e.node);return 0===n?Fs(t.name,e.name):n},gc.prototype.isDefinedOn=function(t){return!0},gc.prototype.indexedValueChanged=function(t,e){return!t.equals(e)},gc.prototype.minPost=function(){return Iu.MIN},gc.prototype.maxPost=function(){return Iu.MAX},gc.prototype.makePost=function(t,e){var n=vc(t);return new Iu(e,n)},gc.prototype.toString=function(){return".value"},gc),_c=(Zo(Ec,bc=Au),Ec.prototype.extractChild=function(t){return t.getChild(this.indexPath_)},Ec.prototype.isDefinedOn=function(t){return!t.getChild(this.indexPath_).isEmpty()},Ec.prototype.compare=function(t,e){var n=this.extractChild(t.node),r=this.extractChild(e.node),i=n.compareTo(r);return 0===i?Fs(t.name,e.name):i},Ec.prototype.makePost=function(t,e){var n=vc(t),r=lc.EMPTY_NODE.updateChild(this.indexPath_,n);return new Iu(e,r)},Ec.prototype.maxPost=function(){var t=lc.EMPTY_NODE.updateChild(this.indexPath_,dc);return new Iu(Ls,t)},Ec.prototype.toString=function(){return this.indexPath_.slice().join("/")},Ec);function Ec(t){var e=bc.call(this)||this;return e.indexPath_=t,ha(!t.isEmpty()&&".priority"!==t.getFront(),"Can't create PathIndex with empty path or .priority key"),e}var Tc=(Sc.prototype.val=function(){return Va("DataSnapshot.val",0,0,arguments.length),this.node_.val()},Sc.prototype.exportVal=function(){return Va("DataSnapshot.exportVal",0,0,arguments.length),this.node_.val(!0)},Sc.prototype.toJSON=function(){return Va("DataSnapshot.toJSON",0,1,arguments.length),this.exportVal()},Sc.prototype.exists=function(){return Va("DataSnapshot.exists",0,0,arguments.length),!this.node_.isEmpty()},Sc.prototype.child=function(t){Va("DataSnapshot.child",0,1,arguments.length),t=String(t),cu("DataSnapshot.child",1,t,!1);var e=new Qs(t),n=this.ref_.child(e);return new Sc(this.node_.getChild(e),n,Ku)},Sc.prototype.hasChild=function(t){Va("DataSnapshot.hasChild",1,1,arguments.length),cu("DataSnapshot.hasChild",1,t,!1);var e=new Qs(t);return!this.node_.getChild(e).isEmpty()},Sc.prototype.getPriority=function(){return Va("DataSnapshot.getPriority",0,0,arguments.length),this.node_.getPriority().val()},Sc.prototype.forEach=function(n){var r=this;return Va("DataSnapshot.forEach",1,1,arguments.length),ja("DataSnapshot.forEach",1,n,!1),!this.node_.isLeafNode()&&!!this.node_.forEachChild(this.index_,function(t,e){return n(new Sc(e,r.ref_.child(t),Ku))})},Sc.prototype.hasChildren=function(){return Va("DataSnapshot.hasChildren",0,0,arguments.length),!this.node_.isLeafNode()&&!this.node_.isEmpty()},Object.defineProperty(Sc.prototype,"key",{get:function(){return this.ref_.getKey()},enumerable:!0,configurable:!0}),Sc.prototype.numChildren=function(){return Va("DataSnapshot.numChildren",0,0,arguments.length),this.node_.numChildren()},Sc.prototype.getRef=function(){return Va("DataSnapshot.ref",0,0,arguments.length),this.ref_},Object.defineProperty(Sc.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),Sc);function Sc(t,e,n){this.node_=t,this.ref_=e,this.index_=n}var Ic=(Cc.prototype.getPath=function(){var t=this.snapshot.getRef();return"value"===this.eventType?t.path:t.getParent().path},Cc.prototype.getEventType=function(){return this.eventType},Cc.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},Cc.prototype.toString=function(){return this.getPath().toString()+":"+this.eventType+":"+Aa(this.snapshot.exportVal())},Cc);function Cc(t,e,n,r){this.eventType=t,this.eventRegistration=e,this.snapshot=n,this.prevName=r}var Nc=(Ac.prototype.getPath=function(){return this.path},Ac.prototype.getEventType=function(){return"cancel"},Ac.prototype.getEventRunner=function(){return this.eventRegistration.getEventRunner(this)},Ac.prototype.toString=function(){return this.path.toString()+":cancel"},Ac);function Ac(t,e,n){this.eventRegistration=t,this.error=e,this.path=n}var kc=(Dc.prototype.respondsTo=function(t){return"value"===t},Dc.prototype.createEvent=function(t,e){var n=e.getQueryParams().getIndex();return new Ic("value",this,new Tc(t.snapshotNode,e.getRef(),n))},Dc.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){ha(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)}},Dc.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new Nc(this,t,e):null},Dc.prototype.matches=function(t){return t instanceof Dc&&(!t.callback_||!this.callback_||t.callback_===this.callback_&&t.context_===this.context_)},Dc.prototype.hasAnyCallback=function(){return null!==this.callback_},Dc);function Dc(t,e,n){this.callback_=t,this.cancelCallback_=e,this.context_=n}var Rc,Oc=(Pc.prototype.respondsTo=function(t){var e="children_added"===t?"child_added":t;return e="children_removed"===e?"child_removed":e,Da(this.callbacks_,e)},Pc.prototype.createCancelEvent=function(t,e){return this.cancelCallback_?new Nc(this,t,e):null},Pc.prototype.createEvent=function(t,e){ha(null!=t.childName,"Child events should have a childName.");var n=e.getRef().child(t.childName),r=e.getQueryParams().getIndex();return new Ic(t.type,this,new Tc(t.snapshotNode,n,r),t.prevName)},Pc.prototype.getEventRunner=function(t){var e=this.context_;if("cancel"===t.getEventType()){ha(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)}},Pc.prototype.matches=function(e){var n=this;if(e instanceof Pc){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},Pc.prototype.hasAnyCallback=function(){return null!==this.callbacks_},Pc);function Pc(t,e,n){this.callbacks_=t,this.cancelCallback_=e,this.context_=n}var Mc=(Object.defineProperty(xc,"__referenceConstructor",{get:function(){return ha(Rc,"Reference.ts has not been loaded"),Rc},set:function(t){Rc=t},enumerable:!0,configurable:!0}),xc.validateQueryEndpoints_=function(t){var e=null,n=null;if(t.hasStart()&&(e=t.getIndexStartValue()),t.hasEnd()&&(n=t.getIndexEndValue()),t.getIndex()===Mu){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()!=xs)throw new Error(r);if("string"!=typeof e)throw new Error(i)}if(t.hasEnd()){if(t.getIndexEndName()!=Ls)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(t.getIndex()===Ku){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(ha(t.getIndex()instanceof _c||t.getIndex()===wc,"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.")},xc.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.")},xc.prototype.validateNoPreviousOrderByCall_=function(t){if(!0===this.orderByCalled_)throw new Error(t+": You can't combine multiple orderBy calls.")},xc.prototype.getQueryParams=function(){return this.queryParams_},xc.prototype.getRef=function(){return Va("Query.ref",0,0,arguments.length),new xc.__referenceConstructor(this.repo,this.path)},xc.prototype.on=function(t,e,n,r){Va("Query.on",2,4,arguments.length),su("Query.on",1,t,!1),ja("Query.on",2,e,!1);var i=xc.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},xc.prototype.onValueEvent=function(t,e,n){var r=new kc(t,e||null,n||null);this.repo.addEventCallbackForQuery(this,r)},xc.prototype.onChildEvent=function(t,e,n){var r=new Oc(t,e,n);this.repo.addEventCallbackForQuery(this,r)},xc.prototype.off=function(t,e,n){Va("Query.off",0,3,arguments.length),su("Query.off",1,t,!0),ja("Query.off",2,e,!0),Wa("Query.off",3,n,!0);var r=null,i=null;"value"===t?r=new kc(e||null,null,n||null):t&&(e&&((i={})[t]=e),r=new Oc(i,null,n||null)),this.repo.removeEventCallbackForQuery(this,r)},xc.prototype.once=function(e,n,t,r){var i=this;Va("Query.once",1,4,arguments.length),su("Query.once",1,e,!1),ja("Query.once",2,n,!0);var o=xc.getCancelAndContextArgs_("Query.once",t,r),a=!0,s=new ya;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},xc.prototype.limitToFirst=function(t){if(Va("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 xc(this.repo,this.path,this.queryParams_.limitToFirst(t),this.orderByCalled_)},xc.prototype.limitToLast=function(t){if(Va("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 xc(this.repo,this.path,this.queryParams_.limitToLast(t),this.orderByCalled_)},xc.prototype.orderByChild=function(t){if(Va("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.');cu("Query.orderByChild",1,t,!1),this.validateNoPreviousOrderByCall_("Query.orderByChild");var e=new Qs(t);if(e.isEmpty())throw new Error("Query.orderByChild: cannot pass in empty path. Use Query.orderByValue() instead.");var n=new _c(e),r=this.queryParams_.orderBy(n);return xc.validateQueryEndpoints_(r),new xc(this.repo,this.path,r,!0)},xc.prototype.orderByKey=function(){Va("Query.orderByKey",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByKey");var t=this.queryParams_.orderBy(Mu);return xc.validateQueryEndpoints_(t),new xc(this.repo,this.path,t,!0)},xc.prototype.orderByPriority=function(){Va("Query.orderByPriority",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByPriority");var t=this.queryParams_.orderBy(Ku);return xc.validateQueryEndpoints_(t),new xc(this.repo,this.path,t,!0)},xc.prototype.orderByValue=function(){Va("Query.orderByValue",0,0,arguments.length),this.validateNoPreviousOrderByCall_("Query.orderByValue");var t=this.queryParams_.orderBy(wc);return xc.validateQueryEndpoints_(t),new xc(this.repo,this.path,t,!0)},xc.prototype.startAt=function(t,e){void 0===t&&(t=null),Va("Query.startAt",0,2,arguments.length),iu("Query.startAt",1,t,this.path,!0),uu("Query.startAt",2,e,!0);var n=this.queryParams_.startAt(t,e);if(xc.validateLimit_(n),xc.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 xc(this.repo,this.path,n,this.orderByCalled_)},xc.prototype.endAt=function(t,e){void 0===t&&(t=null),Va("Query.endAt",0,2,arguments.length),iu("Query.endAt",1,t,this.path,!0),uu("Query.endAt",2,e,!0);var n=this.queryParams_.endAt(t,e);if(xc.validateLimit_(n),xc.validateQueryEndpoints_(n),this.queryParams_.hasEnd())throw new Error("Query.endAt: Ending point was already set (by another call to endAt or equalTo).");return new xc(this.repo,this.path,n,this.orderByCalled_)},xc.prototype.equalTo=function(t,e){if(Va("Query.equalTo",1,2,arguments.length),iu("Query.equalTo",1,t,this.path,!1),uu("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)},xc.prototype.toString=function(){return Va("Query.toString",0,0,arguments.length),this.repo.toString()+this.path.toUrlEncodedString()},xc.prototype.toJSON=function(){return Va("Query.toJSON",0,1,arguments.length),this.toString()},xc.prototype.queryObject=function(){return this.queryParams_.getQueryObject()},xc.prototype.queryIdentifier=function(){var t=this.queryObject(),e=Us(t);return"{}"===e?"default":e},xc.prototype.isEqual=function(t){if(Va("Query.isEqual",1,1,arguments.length),!(t instanceof xc))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},xc.getCancelAndContextArgs_=function(t,e,n){var r={cancel:null,context:null};if(e&&n)r.cancel=e,ja(t,3,r.cancel,!0),r.context=n,Wa(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(Ba(t,3,!0)+" must either be a cancel callback or a context object.");r.cancel=e}return r},Object.defineProperty(xc.prototype,"ref",{get:function(){return this.getRef()},enumerable:!0,configurable:!0}),xc);function xc(t,e,n,r){this.repo=t,this.path=e,this.queryParams_=n,this.orderByCalled_=r}var Lc=(Fc.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},Fc.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 Fc);var r=this.children.get(n);t=t.popFront(),r.remember(t,e)}},Fc.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(Ku,function(t,e){n.remember(new Qs(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},Fc.prototype.forEachTree=function(r,i){null!==this.value?i(r,this.value):this.forEachChild(function(t,e){var n=new Qs(r.toString()+"/"+t);e.forEachTree(n,i)})},Fc.prototype.forEachChild=function(n){this.children.forEach(function(t,e){n(e,t)})},Fc);function Fc(){this.value=null,this.children=new Map}function Uc(t,e){return t&&"object"==typeof t?(ha(".sv"in t,"Unexpected leaf node or priority contents"),e[t[".sv"]]):t}var qc,Vc,Bc=function(t,r){var i,e=t.getPriority().val(),n=Uc(e,r);if(t.isLeafNode()){var o=t,a=Uc(o.getValue(),r);return a!==o.getValue()||n!==o.getPriority().val()?new Bu(a,vc(n)):t}var s=t;return n!==(i=s).getPriority().val()&&(i=i.updatePriority(new Bu(n))),s.forEachChild(Ku,function(t,e){var n=Bc(e,r);n!==e&&(i=i.updateImmediateChild(t,n))}),i};(Vc=qc=qc||{})[Vc.OVERWRITE=0]="OVERWRITE",Vc[Vc.MERGE=1]="MERGE",Vc[Vc.ACK_USER_WRITE=2]="ACK_USER_WRITE",Vc[Vc.LISTEN_COMPLETE=3]="LISTEN_COMPLETE";var jc=(Wc.User=new Wc(!0,!1,null,!1),Wc.Server=new Wc(!1,!0,null,!1),Wc.forServerTaggedQuery=function(t){return new Wc(!1,!0,t,!0)},Wc);function Wc(t,e,n,r){this.fromUser=t,this.fromServer=e,this.queryId=n,this.tagged=r,ha(!r||e,"Tagged queries must be from server.")}var Kc,Qc=(Hc.prototype.operationForChild=function(t){if(this.path.isEmpty()){if(null!=this.affectedTree.value)return ha(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;var e=this.affectedTree.subtree(new Qs(t));return new Hc(Qs.Empty,e,this.revert)}return ha(this.path.getFront()===t,"operationForChild called for unrelated child."),new Hc(this.path.popFront(),this.affectedTree,this.revert)},Hc);function Hc(t,e,n){this.path=t,this.affectedTree=e,this.revert=n,this.type=qc.ACK_USER_WRITE,this.source=jc.User}var Gc=(zc.fromObject=function(t){var n=zc.Empty;return qs(t,function(t,e){n=n.set(new Qs(t),e)}),n},zc.prototype.isEmpty=function(){return null===this.value&&this.children.isEmpty()},zc.prototype.findRootMostMatchingPathAndValue=function(t,e){if(null!=this.value&&e(this.value))return{path:Qs.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 Qs(n).child(i.path),value:i.value}},zc.prototype.findRootMostValueAndPath=function(t){return this.findRootMostMatchingPathAndValue(t,function(){return!0})},zc.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()):zc.Empty},zc.prototype.set=function(t,e){if(t.isEmpty())return new zc(e,this.children);var n=t.getFront(),r=(this.children.get(n)||zc.Empty).set(t.popFront(),e),i=this.children.insert(n,r);return new zc(this.value,i)},zc.prototype.remove=function(t){if(t.isEmpty())return this.children.isEmpty()?zc.Empty:new zc(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()?zc.Empty:new zc(this.value,i)}return this},zc.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},zc.prototype.setTree=function(t,e){if(t.isEmpty())return e;var n=t.getFront(),r=(this.children.get(n)||zc.Empty).setTree(t.popFront(),e),i=void 0;return i=r.isEmpty()?this.children.remove(n):this.children.insert(n,r),new zc(this.value,i)},zc.prototype.fold=function(t){return this.fold_(Qs.Empty,t)},zc.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)},zc.prototype.findOnPath=function(t,e){return this.findOnPath_(t,Qs.Empty,e)},zc.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},zc.prototype.foreachOnPath=function(t,e){return this.foreachOnPath_(t,Qs.Empty,e)},zc.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):zc.Empty},zc.prototype.foreach=function(t){this.foreach_(Qs.Empty,t)},zc.prototype.foreach_=function(n,r){this.children.inorderTraversal(function(t,e){e.foreach_(n.child(t),r)}),this.value&&r(n,this.value)},zc.prototype.foreachChild=function(n){this.children.inorderTraversal(function(t,e){e.value&&n(t,e.value)})},zc.Empty=new zc(null),zc);function zc(t,e){void 0===e&&(e=Kc=Kc||new Ju(Ts)),this.value=t,this.children=e}var Yc=(Xc.prototype.operationForChild=function(t){return this.path.isEmpty()?new Xc(this.source,Qs.Empty):new Xc(this.source,this.path.popFront())},Xc);function Xc(t,e){this.source=t,this.path=e,this.type=qc.LISTEN_COMPLETE}var Jc=($c.prototype.operationForChild=function(t){return this.path.isEmpty()?new $c(this.source,Qs.Empty,this.snap.getImmediateChild(t)):new $c(this.source,this.path.popFront(),this.snap)},$c);function $c(t,e,n){this.source=t,this.path=e,this.snap=n,this.type=qc.OVERWRITE}var Zc=(th.prototype.operationForChild=function(t){if(this.path.isEmpty()){var e=this.children.subtree(new Qs(t));return e.isEmpty()?null:e.value?new Jc(this.source,Qs.Empty,e.value):new th(this.source,Qs.Empty,e)}return ha(this.path.getFront()===t,"Can't get a merge for a child not on the path of the operation"),new th(this.source,this.path.popFront(),this.children)},th.prototype.toString=function(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"},th);function th(t,e,n){this.source=t,this.path=e,this.children=n,this.type=qc.MERGE}var eh=(nh.prototype.isFullyInitialized=function(){return this.fullyInitialized_},nh.prototype.isFiltered=function(){return this.filtered_},nh.prototype.isCompleteForPath=function(t){if(t.isEmpty())return this.isFullyInitialized()&&!this.filtered_;var e=t.getFront();return this.isCompleteForChild(e)},nh.prototype.isCompleteForChild=function(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)},nh.prototype.getNode=function(){return this.node_},nh);function nh(t,e,n){this.node_=t,this.fullyInitialized_=e,this.filtered_=n}var rh=(ih.prototype.updateEventSnap=function(t,e,n){return new ih(new eh(t,e,n),this.serverCache_)},ih.prototype.updateServerSnap=function(t,e,n){return new ih(this.eventCache_,new eh(t,e,n))},ih.prototype.getEventCache=function(){return this.eventCache_},ih.prototype.getCompleteEventSnap=function(){return this.eventCache_.isFullyInitialized()?this.eventCache_.getNode():null},ih.prototype.getServerCache=function(){return this.serverCache_},ih.prototype.getCompleteServerSnap=function(){return this.serverCache_.isFullyInitialized()?this.serverCache_.getNode():null},ih.Empty=new ih(new eh(lc.EMPTY_NODE,!1,!1),new eh(lc.EMPTY_NODE,!1,!1)),ih);function ih(t,e){this.eventCache_=t,this.serverCache_=e}var oh=(ah.valueChange=function(t){return new ah(ah.VALUE,t)},ah.childAddedChange=function(t,e){return new ah(ah.CHILD_ADDED,e,t)},ah.childRemovedChange=function(t,e){return new ah(ah.CHILD_REMOVED,e,t)},ah.childChangedChange=function(t,e,n){return new ah(ah.CHILD_CHANGED,e,t,n)},ah.childMovedChange=function(t,e){return new ah(ah.CHILD_MOVED,e,t)},ah.CHILD_ADDED="child_added",ah.CHILD_REMOVED="child_removed",ah.CHILD_CHANGED="child_changed",ah.CHILD_MOVED="child_moved",ah.VALUE="value",ah);function ah(t,e,n,r,i){this.type=t,this.snapshotNode=e,this.childName=n,this.oldSnap=r,this.prevName=i}var sh=(uh.prototype.updateChild=function(t,e,n,r,i,o){ha(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(oh.childRemovedChange(e,a)):ha(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(oh.childAddedChange(e,n)):o.trackChildChange(oh.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(Ku,function(t,e){n.hasChild(t)||i.trackChildChange(oh.childRemovedChange(t,e))}),n.isLeafNode()||n.forEachChild(Ku,function(t,e){if(r.hasChild(t)){var n=r.getImmediateChild(t);n.equals(e)||i.trackChildChange(oh.childChangedChange(t,e,n))}else i.trackChildChange(oh.childAddedChange(t,e))})),n.withIndex(this.index_)},uh.prototype.updatePriority=function(t,e){return t.isEmpty()?lc.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 ch=(hh.prototype.trackChildChange=function(t){var e=t.type,n=t.childName;ha(e==oh.CHILD_ADDED||e==oh.CHILD_CHANGED||e==oh.CHILD_REMOVED,"Only child changes supported for tracking"),ha(".priority"!==n,"Only non-priority child changes can be tracked.");var r=this.changeMap.get(n);if(r){var i=r.type;if(e==oh.CHILD_ADDED&&i==oh.CHILD_REMOVED)this.changeMap.set(n,oh.childChangedChange(n,t.snapshotNode,r.snapshotNode));else if(e==oh.CHILD_REMOVED&&i==oh.CHILD_ADDED)this.changeMap.delete(n);else if(e==oh.CHILD_REMOVED&&i==oh.CHILD_CHANGED)this.changeMap.set(n,oh.childRemovedChange(n,r.oldSnap));else if(e==oh.CHILD_CHANGED&&i==oh.CHILD_ADDED)this.changeMap.set(n,oh.childAddedChange(n,t.snapshotNode));else{if(e!=oh.CHILD_CHANGED||i!=oh.CHILD_CHANGED)throw la("Illegal combination of changes: "+t+" occurred after "+r);this.changeMap.set(n,oh.childChangedChange(n,t.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,t)},hh.prototype.getChanges=function(){return Array.from(this.changeMap.values())},hh);function hh(){this.changeMap=new Map}function lh(){}var fh=new(lh.prototype.getCompleteChild=function(t){return null},lh.prototype.getChildAfterChild=function(t,e,n){return null},lh),ph=(dh.prototype.getCompleteChild=function(t){var e=this.viewCache_.getEventCache();if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);var n=null!=this.optCompleteServerCache_?new eh(this.optCompleteServerCache_,!0,!1):this.viewCache_.getServerCache();return this.writes_.calcCompleteChild(t,n)},dh.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]},dh);function dh(t,e,n){void 0===n&&(n=null),this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=n}var yh=function(t,e){this.viewCache=t,this.changes=e},mh=(vh.prototype.assertIndexed=function(t){ha(t.getEventCache().getNode().isIndexed(this.filter_.getIndex()),"Event snap not indexed"),ha(t.getServerCache().getNode().isIndexed(this.filter_.getIndex()),"Server snap not indexed")},vh.prototype.applyOperation=function(t,e,n,r){var i,o,a=new ch;if(e.type===qc.OVERWRITE){var s=e;i=s.source.fromUser?this.applyUserOverwrite_(t,s.path,s.snap,n,r,a):(ha(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===qc.MERGE){var u=e;i=u.source.fromUser?this.applyUserMerge_(t,u.path,u.children,n,r,a):(ha(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===qc.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!==qc.LISTEN_COMPLETE)throw la("Unknown operation type: "+e.type);i=this.listenComplete_(t,e.path,n,a)}var h=a.getChanges();return vh.maybeAddValueEvent_(t,i,h),new yh(i,h)},vh.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(oh.valueChange(e.getCompleteEventSnap()))}},vh.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(ha(t.getServerCache().isFullyInitialized(),"If change path is empty, we must have complete server data"),t.getServerCache().isFiltered()){var u=t.getCompleteServerSnap(),c=u instanceof lc?u:lc.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){ha(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 y=e.popFront(),m=void 0;if(o.isCompleteForChild(f)){s=t.getServerCache().getNode();var v=n.calcEventCacheAfterServerOverwrite(e,o.getNode(),s);m=null!=v?o.getNode().getImmediateChild(f).updateChild(y,v):o.getNode().getImmediateChild(f)}else m=n.calcCompleteChild(f,t.getServerCache());a=null!=m?this.filter_.updateChild(o.getNode(),f,m,y,r,i):o.getNode()}}return t.updateEventSnap(a,o.isFullyInitialized()||e.isEmpty(),this.filter_.filtersNodes())},vh.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,fh,null)}var d=t.updateServerSnap(s,u.isFullyInitialized()||e.isEmpty(),c.filtersNodes()),y=new ph(r,d,i);return this.generateEventCacheAfterServerEvent_(d,e,r,y,a)},vh.prototype.applyUserOverwrite_=function(t,e,n,r,i,o){var a,s,u=t.getEventCache(),c=new ph(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):lc.EMPTY_NODE}if(f.equals(p))a=t;else{var y=this.filter_.updateChild(u.getNode(),h,p,l,c,o);a=t.updateEventSnap(y,u.isFullyInitialized(),this.filter_.filtersNodes())}}}return a},vh.cacheHasChild_=function(t,e){return t.getEventCache().isCompleteForChild(e)},vh.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);vh.cacheHasChild_(r,n.getFront())&&(c=u.applyUserOverwrite_(c,n,e,o,a,s))}),t.foreach(function(t,e){var n=i.child(t);vh.cacheHasChild_(r,n.getFront())||(c=u.applyUserOverwrite_(c,n,e,o,a,s))}),c},vh.prototype.applyMerge_=function(n,t){return t.foreach(function(t,e){n=n.updateChild(t,e)}),n},vh.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:Gc.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 Qs(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 Qs(t),i,a,s,u,c)}}),l},vh.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=Gc.Empty;return s.getNode().forEachChild(Mu,function(t,e){u=u.set(new Qs(t),e)}),this.applyServerMerge_(t,r,u,n,i,a,o)}return t}var c=Gc.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)},vh.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,fh,r)},vh.prototype.revertUserWrite_=function(t,e,n,r,i){var o;if(null!=n.shadowingWrite(e))return t;var a=new ph(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();ha(h instanceof lc,"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,lc.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(Qs.Empty),t.updateEventSnap(u,o,this.filter_.filtersNodes())},vh);function vh(t){this.filter_=t}var gh=(bh.prototype.generateEventsForChanges=function(t,e,n){var r=this,i=[],o=[];return t.forEach(function(t){t.type===oh.CHILD_CHANGED&&r.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&&o.push(oh.childMovedChange(t.childName,t.snapshotNode))}),this.generateEventsForType_(i,oh.CHILD_REMOVED,t,n,e),this.generateEventsForType_(i,oh.CHILD_ADDED,t,n,e),this.generateEventsForType_(i,oh.CHILD_MOVED,o,n,e),this.generateEventsForType_(i,oh.CHILD_CHANGED,t,n,e),this.generateEventsForType_(i,oh.VALUE,t,n,e),i},bh.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_))})})},bh.prototype.materializeSingleChange_=function(t,e){return"value"===t.type||"child_removed"===t.type||(t.prevName=e.getPredecessorChildName(t.childName,t.snapshotNode,this.index_)),t},bh.prototype.compareChanges_=function(t,e){if(null==t.childName||null==e.childName)throw la("Should only compare child_ events.");var n=new Iu(t.childName,t.snapshotNode),r=new Iu(e.childName,e.snapshotNode);return this.index_.compare(n,r)},bh);function bh(t){this.query_=t,this.index_=this.query_.getQueryParams().getIndex()}var wh,_h=(Eh.prototype.getQuery=function(){return this.query_},Eh.prototype.getServerCache=function(){return this.viewCache_.getServerCache().getNode()},Eh.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},Eh.prototype.isEmpty=function(){return 0===this.eventRegistrations_.length},Eh.prototype.addEventRegistration=function(t){this.eventRegistrations_.push(t)},Eh.prototype.removeEventRegistration=function(t,n){var r=[];if(n){ha(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},Eh.prototype.applyOperation=function(t,e,n){t.type===qc.MERGE&&null!==t.source.queryId&&(ha(this.viewCache_.getCompleteServerSnap(),"We should always have a full cache before handling merges"),ha(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),ha(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)},Eh.prototype.getInitialEvents=function(t){var e=this.viewCache_.getEventCache(),n=[];return e.getNode().isLeafNode()||e.getNode().forEachChild(Ku,function(t,e){n.push(oh.childAddedChange(t,e))}),e.isFullyInitialized()&&n.push(oh.valueChange(e.getNode())),this.generateEventsForChanges_(n,e.getNode(),t)},Eh.prototype.generateEventsForChanges_=function(t,e,n){var r=n?[n]:this.eventRegistrations_;return this.eventGenerator_.generateEventsForChanges(t,e,r)},Eh);function Eh(t,e){this.query_=t,this.eventRegistrations_=[];var n=this.query_.getQueryParams(),r=new sh(n.getIndex()),i=n.getNodeFilter();this.processor_=new mh(i);var o=e.getServerCache(),a=e.getEventCache(),s=r.updateFullNode(lc.EMPTY_NODE,o.getNode(),null),u=i.updateFullNode(lc.EMPTY_NODE,a.getNode(),null),c=new eh(s,o.isFullyInitialized(),r.filtersNodes()),h=new eh(u,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=new rh(h,c),this.eventGenerator_=new gh(this.query_)}var Th=(Object.defineProperty(Sh,"__referenceConstructor",{get:function(){return ha(wh,"Reference.ts has not been loaded"),wh},set:function(t){ha(!wh,"__referenceConstructor has already been defined"),wh=t},enumerable:!0,configurable:!0}),Sh.prototype.isEmpty=function(){return 0===this.views.size},Sh.prototype.applyOperation=function(t,e,n){var r,i,o=t.source.queryId;if(null!==o){var a=this.views.get(o);return ha(null!=a,"SyncTree gave us an op for an invalid query."),a.applyOperation(t,e,n)}var s=[];try{for(var u=ra(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},Sh.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 lc?n.calcCompleteEventChildren(r):lc.EMPTY_NODE,!1);var c=new rh(new eh(s,u,!1),new eh(r,i,!1));a=new _h(t,c),this.views.set(o,a)}return a.addEventRegistration(e),a.getInitialEvents(e)},Sh.prototype.removeEventRegistration=function(t,e,n){var r,i,o=t.queryIdentifier(),a=[],s=[],u=this.hasCompleteView();if("default"===o)try{for(var c=ra(this.views.entries()),h=c.next();!h.done;h=c.next()){var l=ia(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 Sh.__referenceConstructor(t.repo,t.path)),{removed:a,events:s}},Sh.prototype.getQueryViews=function(){var e,t,n=[];try{for(var r=ra(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},Sh.prototype.getCompleteServerCache=function(t){var e,n,r=null;try{for(var i=ra(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},Sh.prototype.viewForQuery=function(t){if(t.getQueryParams().loadsAllData())return this.getCompleteView();var e=t.queryIdentifier();return this.views.get(e)},Sh.prototype.viewExistsForQuery=function(t){return null!=this.viewForQuery(t)},Sh.prototype.hasCompleteView=function(){return null!=this.getCompleteView()},Sh.prototype.getCompleteView=function(){var e,t;try{for(var n=ra(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},Sh);function Sh(){this.views=new Map}var Ih=(Ch.prototype.addWrite=function(t,e){if(t.isEmpty())return new Ch(new Gc(e));var n=this.writeTree_.findRootMostValueAndPath(t);if(null!=n){var r=n.path,i=n.value,o=Qs.relativePath(r,t);return i=i.updateChild(o,e),new Ch(this.writeTree_.set(r,i))}var a=new Gc(e);return new Ch(this.writeTree_.setTree(t,a))},Ch.prototype.addWrites=function(n,t){var r=this;return qs(t,function(t,e){r=r.addWrite(n.child(t),e)}),r},Ch.prototype.removeWrite=function(t){return t.isEmpty()?Ch.Empty:new Ch(this.writeTree_.setTree(t,Gc.Empty))},Ch.prototype.hasCompleteWrite=function(t){return null!=this.getCompleteNode(t)},Ch.prototype.getCompleteNode=function(t){var e=this.writeTree_.findRootMostValueAndPath(t);return null!=e?this.writeTree_.get(e.path).getChild(Qs.relativePath(e.path,t)):null},Ch.prototype.getCompleteChildren=function(){var n=[],t=this.writeTree_.value;return null!=t?t.isLeafNode()||t.forEachChild(Ku,function(t,e){n.push(new Iu(t,e))}):this.writeTree_.children.inorderTraversal(function(t,e){null!=e.value&&n.push(new Iu(t,e.value))}),n},Ch.prototype.childCompoundWrite=function(t){if(t.isEmpty())return this;var e=this.getCompleteNode(t);return new Ch(null!=e?new Gc(e):this.writeTree_.subtree(t))},Ch.prototype.isEmpty=function(){return this.writeTree_.isEmpty()},Ch.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?(ha(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}(Qs.Empty,this.writeTree_,t)},Ch.Empty=new Ch(new Gc(null)),Ch);function Ch(t){this.writeTree_=t}var Nh=(Ah.prototype.childWrites=function(t){return new kh(t,this)},Ah.prototype.addOverwrite=function(t,e,n,r){ha(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},Ah.prototype.addMerge=function(t,e,n){ha(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},Ah.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},Ah.prototype.removeWrite=function(e){var n=this,t=this.allWrites_.findIndex(function(t){return t.writeId===e});ha(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):qs(r.children,function(t){n.visibleWrites_=n.visibleWrites_.removeWrite(r.path.child(t))}),!0)},Ah.prototype.getCompleteWriteData=function(t){return this.visibleWrites_.getCompleteNode(t)},Ah.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(Qs.Empty)){var o=Ah.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||lc.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(Qs.Empty)){var u=t||lc.EMPTY_NODE;return s.apply(u)}return null},Ah.prototype.calcCompleteEventChildren=function(t,e){var r=lc.EMPTY_NODE,n=this.visibleWrites_.getCompleteNode(t);if(n)return n.isLeafNode()||n.forEachChild(Ku,function(t,e){r=r.updateImmediateChild(t,e)}),r;if(e){var i=this.visibleWrites_.childCompoundWrite(t);return e.forEachChild(Ku,function(t,e){var n=i.childCompoundWrite(new Qs(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},Ah.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n,r){ha(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))},Ah.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},Ah.prototype.shadowingWrite=function(t){return this.visibleWrites_.getCompleteNode(t)},Ah.prototype.calcIndexedSlice=function(t,e,n,r,i,o){var a,s=this.visibleWrites_.childCompoundWrite(t),u=s.getCompleteNode(Qs.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},Ah.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},Ah.prototype.resetTree_=function(){this.visibleWrites_=Ah.layerTree_(this.allWrites_,Ah.DefaultFilter_,Qs.Empty),0<this.allWrites_.length?this.lastWriteId_=this.allWrites_[this.allWrites_.length-1].writeId:this.lastWriteId_=-1},Ah.DefaultFilter_=function(t){return t.visible},Ah.layerTree_=function(t,e,n){for(var r=Ih.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=Qs.relativePath(n,a),r=r.addWrite(s,o.snap)):a.contains(n)&&(s=Qs.relativePath(a,n),r=r.addWrite(Qs.Empty,o.snap.getChild(s)));else{if(!o.children)throw la("WriteRecord should have .snap or .children");if(n.contains(a))s=Qs.relativePath(n,a),r=r.addWrites(s,o.children);else if(a.contains(n))if((s=Qs.relativePath(a,n)).isEmpty())r=r.addWrites(Qs.Empty,o.children);else{var u=Ra(o.children,s.getFront());if(u){var c=u.getChild(s.popFront());r=r.addWrite(Qs.Empty,c)}}}}}return r},Ah);function Ah(){this.visibleWrites_=Ih.Empty,this.allWrites_=[],this.lastWriteId_=-1}var kh=(Dh.prototype.calcCompleteEventCache=function(t,e,n){return this.writeTree_.calcCompleteEventCache(this.treePath_,t,e,n)},Dh.prototype.calcCompleteEventChildren=function(t){return this.writeTree_.calcCompleteEventChildren(this.treePath_,t)},Dh.prototype.calcEventCacheAfterServerOverwrite=function(t,e,n){return this.writeTree_.calcEventCacheAfterServerOverwrite(this.treePath_,t,e,n)},Dh.prototype.shadowingWrite=function(t){return this.writeTree_.shadowingWrite(this.treePath_.child(t))},Dh.prototype.calcIndexedSlice=function(t,e,n,r,i){return this.writeTree_.calcIndexedSlice(this.treePath_,t,e,n,r,i)},Dh.prototype.calcCompleteChild=function(t,e){return this.writeTree_.calcCompleteChild(this.treePath_,t,e)},Dh.prototype.child=function(t){return new Dh(this.treePath_.child(t),this.writeTree_)},Dh);function Dh(t,e){this.treePath_=t,this.writeTree_=e}var Rh=(Oh.prototype.applyUserOverwrite=function(t,e,n,r){return this.pendingWriteTree_.addOverwrite(t,e,n,r),r?this.applyOperationToSyncPoints_(new Jc(jc.User,t,e)):[]},Oh.prototype.applyUserMerge=function(t,e,n){this.pendingWriteTree_.addMerge(t,e,n);var r=Gc.fromObject(e);return this.applyOperationToSyncPoints_(new Zc(jc.User,t,r))},Oh.prototype.ackUserWrite=function(t,e){void 0===e&&(e=!1);var n=this.pendingWriteTree_.getWrite(t);if(this.pendingWriteTree_.removeWrite(t)){var r=Gc.Empty;return null!=n.snap?r=r.set(Qs.Empty,!0):qs(n.children,function(t,e){r=r.set(new Qs(t),e)}),this.applyOperationToSyncPoints_(new Qc(n.path,r,e))}return[]},Oh.prototype.applyServerOverwrite=function(t,e){return this.applyOperationToSyncPoints_(new Jc(jc.Server,t,e))},Oh.prototype.applyServerMerge=function(t,e){var n=Gc.fromObject(e);return this.applyOperationToSyncPoints_(new Zc(jc.Server,t,n))},Oh.prototype.applyListenComplete=function(t){return this.applyOperationToSyncPoints_(new Yc(jc.Server,t))},Oh.prototype.applyTaggedQueryOverwrite=function(t,e,n){var r=this.queryKeyForTag_(n);if(null==r)return[];var i=Oh.parseQueryKey_(r),o=i.path,a=i.queryId,s=Qs.relativePath(o,t),u=new Jc(jc.forServerTaggedQuery(a),s,e);return this.applyTaggedOperation_(o,u)},Oh.prototype.applyTaggedQueryMerge=function(t,e,n){var r=this.queryKeyForTag_(n);if(r){var i=Oh.parseQueryKey_(r),o=i.path,a=i.queryId,s=Qs.relativePath(o,t),u=Gc.fromObject(e),c=new Zc(jc.forServerTaggedQuery(a),s,u);return this.applyTaggedOperation_(o,c)}return[]},Oh.prototype.applyTaggedListenComplete=function(t,e){var n=this.queryKeyForTag_(e);if(n){var r=Oh.parseQueryKey_(n),i=r.path,o=r.queryId,a=Qs.relativePath(i,t),s=new Yc(jc.forServerTaggedQuery(o),a);return this.applyTaggedOperation_(i,s)}return[]},Oh.prototype.addEventRegistration=function(t,e){var r=t.path,i=null,o=!1;this.syncPointTree_.foreachOnPath(r,function(t,e){var n=Qs.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(Qs.Empty)):(a=new Th,this.syncPointTree_=this.syncPointTree_.set(r,a)),null!=i?n=!0:(n=!1,i=lc.EMPTY_NODE,this.syncPointTree_.subtree(r).foreachChild(function(t,e){var n=e.getCompleteServerCache(Qs.Empty);n&&(i=i.updateImmediateChild(t,n))}));var s=a.viewExistsForQuery(t);if(!s&&!t.getQueryParams().loadsAllData()){var u=Oh.makeQueryKey_(t);ha(!this.queryToTagMap.has(u),"View does not exist, but we have a tag");var c=Oh.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},Oh.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],y=d.getQuery(),m=this.createListenerForView_(d);this.listenProvider_.startListening(Oh.queryForListening_(y),this.tagForQuery_(y),m.hashFn,m.onComplete)}}!h&&0<u.length&&!n&&(c?this.listenProvider_.stopListening(Oh.queryForListening_(t),null):u.forEach(function(t){var e=r.queryToTagMap.get(Oh.makeQueryKey_(t));r.listenProvider_.stopListening(Oh.queryForListening_(t),e)})),this.removeTags_(u)}return a},Oh.prototype.calcCompleteEventCache=function(i,t){var e=this.pendingWriteTree_,n=this.syncPointTree_.findOnPath(i,function(t,e){var n=Qs.relativePath(t,i),r=e.getCompleteServerCache(n);if(r)return r});return e.calcCompleteEventCache(i,n,t,!0)},Oh.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()),qs(n,function(t,e){r=r.concat(e)}),r})},Oh.prototype.removeTags_=function(t){for(var e=0;e<t.length;++e){var n=t[e];if(!n.getQueryParams().loadsAllData()){var r=Oh.makeQueryKey_(n),i=this.queryToTagMap.get(r);this.queryToTagMap.delete(r),this.tagToQueryMap.delete(i)}}},Oh.queryForListening_=function(t){return t.getQueryParams().loadsAllData()&&!t.getQueryParams().isDefault()?t.getRef():t},Oh.prototype.setupListener_=function(t,e){var n=t.path,r=this.tagForQuery_(t),i=this.createListenerForView_(e),o=this.listenProvider_.startListening(Oh.queryForListening_(t),r,i.hashFn,i.onComplete),a=this.syncPointTree_.subtree(n);if(r)ha(!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()}))),qs(n,function(t,e){r=r.concat(e)}),r}),u=0;u<s.length;++u){var c=s[u];this.listenProvider_.stopListening(Oh.queryForListening_(c),this.tagForQuery_(c))}return o},Oh.prototype.createListenerForView_=function(t){var n=this,r=t.getQuery(),i=this.tagForQuery_(r);return{hashFn:function(){return(t.getServerCache()||lc.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)}}},Oh.makeQueryKey_=function(t){return t.path.toString()+"$"+t.queryIdentifier()},Oh.parseQueryKey_=function(t){var e=t.indexOf("$");return ha(-1!==e&&e<t.length-1,"Bad queryKey."),{queryId:t.substr(e+1),path:new Qs(t.substr(0,e))}},Oh.prototype.queryKeyForTag_=function(t){return this.tagToQueryMap.get(t)},Oh.prototype.tagForQuery_=function(t){var e=Oh.makeQueryKey_(t);return this.queryToTagMap.get(e)},Oh.getNextQueryTag_=function(){return Oh.nextQueryTag_++},Oh.prototype.applyTaggedOperation_=function(t,e){var n=this.syncPointTree_.get(t);ha(n,"Missing sync point for query tag that we're tracking");var r=this.pendingWriteTree_.childWrites(t);return n.applyOperation(e,r,null)},Oh.prototype.applyOperationToSyncPoints_=function(t){return this.applyOperationHelper_(t,this.syncPointTree_,null,this.pendingWriteTree_.childWrites(Qs.Empty))},Oh.prototype.applyOperationHelper_=function(t,e,n,r){if(t.path.isEmpty())return this.applyOperationDescendantsHelper_(t,e,n,r);var i=e.get(Qs.Empty);null==n&&null!=i&&(n=i.getCompleteServerCache(Qs.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},Oh.prototype.applyOperationDescendantsHelper_=function(o,t,a,s){var u=this,e=t.get(Qs.Empty);null==a&&null!=e&&(a=e.getCompleteServerCache(Qs.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},Oh.nextQueryTag_=1,Oh);function Oh(t){this.listenProvider_=t,this.syncPointTree_=Gc.Empty,this.pendingWriteTree_=new Nh,this.tagToQueryMap=new Map,this.queryToTagMap=new Map}var Ph=(Mh.prototype.getNode=function(t){return this.rootNode_.getChild(t)},Mh.prototype.updateSnapshot=function(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)},Mh);function Mh(){this.rootNode_=lc.EMPTY_NODE}var xh=(Lh.prototype.getToken=function(t){return this.app_.INTERNAL.getToken(t).then(null,function(t){return t&&"auth/token-not-initialized"===t.code?(vs("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t)})},Lh.prototype.addTokenChangeListener=function(t){this.app_.INTERNAL.addAuthTokenListener(t)},Lh.prototype.removeTokenChangeListener=function(t){this.app_.INTERNAL.removeAuthTokenListener(t)},Lh.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/.',_s(t)},Lh);function Lh(t){this.app_=t}var Fh=function(t){this.accessToken=t},Uh=(qh.prototype.getToken=function(t){return Promise.resolve(new Fh("owner"))},qh.prototype.addTokenChangeListener=function(t){},qh.prototype.removeTokenChangeListener=function(t){},qh.prototype.notifyForInvalidToken=function(){_s('Database emulator unexpectedly rejected fake "owner" credentials.')},qh);function qh(t){this.app_=t}var Vh=(Bh.prototype.incrementCounter=function(t,e){void 0===e&&(e=1),Da(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e},Bh.prototype.get=function(){return pa(this.counters_)},Bh);function Bh(){this.counters_={}}var jh=(Wh.getCollection=function(t){var e=t.toString();return this.collections_[e]||(this.collections_[e]=new Vh),this.collections_[e]},Wh.getOrCreateReporter=function(t,e){var n=t.toString();return this.reporters_[n]||(this.reporters_[n]=e()),this.reporters_[n]},Wh.collections_={},Wh.reporters_={},Wh);function Wh(){}var Kh=(Qh.prototype.get=function(){var t=this.collection_.get(),n=ta({},t);return this.last_&&qs(this.last_,function(t,e){n[t]=n[t]-e}),this.last_=t,n},Qh);function Qh(t){this.collection_=t,this.last_=null}var Hh=(Gh.prototype.includeStat=function(t){this.statsToReport_[t]=!0},Gh.prototype.reportStats_=function(){var n=this,t=this.statsListener_.get(),r={},i=!1;qs(t,function(t,e){0<e&&Da(n.statsToReport_,t)&&(r[t]=e,i=!0)}),i&&this.server_.reportStats(r),js(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))},Gh);function Gh(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new Kh(t);var n=1e4+2e4*Math.random();js(this.reportStats_.bind(this),Math.floor(n))}var zh=(Yh.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 Xh(i)),e.add(r)}e&&this.eventLists_.push(e)},Yh.prototype.raiseEventsAtPath=function(e,t){this.queueEvents(t),this.raiseQueuedEventsMatchingPredicate_(function(t){return t.equals(e)})},Yh.prototype.raiseEventsForChangedPath=function(e,t){this.queueEvents(t),this.raiseQueuedEventsMatchingPredicate_(function(t){return t.contains(e)||e.contains(t)})},Yh.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_--},Yh);function Yh(){this.eventLists_=[],this.recursionDepth_=0}var Xh=(Jh.prototype.add=function(t){this.events_.push(t)},Jh.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();Ps&&vs("event: "+e.toString()),Bs(n)}}},Jh.prototype.getPath=function(){return this.path_},Jh);function Jh(t){this.path_=t,this.events_=[]}var $h=(Zh.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=oa(this.listeners_[t]),i=0;i<r.length;i++)r[i].callback.apply(r[i].context,e)},Zh.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)},Zh.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)},Zh.prototype.validateEventType_=function(e){ha(this.allowedEvents_.find(function(t){return t===e}),"Unknown event: "+e)},Zh);function Zh(t){this.allowedEvents_=t,this.listeners_={},ha(Array.isArray(t)&&0<t.length,"Requires a non-empty array")}var tl,el=(Zo(nl,tl=$h),nl.getInstance=function(){return new nl},nl.prototype.getInitialEvent=function(t){return ha("visible"===t,"Unknown event type: "+t),[this.visible_]},nl);function nl(){var e,t,n=tl.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,il=(Zo(ol,rl=$h),ol.getInstance=function(){return new ol},ol.prototype.getInitialEvent=function(t){return ha("online"===t,"Unknown event type: "+t),[this.online_]},ol.prototype.currentlyOnline=function(){return this.online_},ol);function ol(){var t=rl.call(this,["online"])||this;return t.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||ga()||(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 al=(sl.prototype.closeAfter=function(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse<this.currentResponseNum&&(this.onClose(),this.onClose=null)},sl.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]&&Bs(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(););},sl);function sl(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}var ul=(cl.prototype.open=function(t,e){var a=this;this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new al(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 hl(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=ia(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=ia(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(Ys)&&(t.r="f");var e=a.urlFn(t);a.log_("Connecting via long-poll to "+e),a.scriptTagHolder.addTag(e,function(){})}})},cl.prototype.start=function(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)},cl.forceAllow=function(){cl.forceAllow_=!0},cl.forceDisallow=function(){cl.forceDisallow_=!0},cl.isAvailable=function(){return!!cl.forceAllow_||!(cl.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)},cl.prototype.markConnectionHealthy=function(){},cl.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)},cl.prototype.onClosed_=function(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))},cl.prototype.close=function(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())},cl.prototype.send=function(t){var e=Aa(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);for(var n=function(t){var e=sa(t);return fa.encodeByteArray(e,!0)}(e),r=Is(n,1840),i=0;i<r.length;i++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[i]),this.curSegmentNum++},cl.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)},cl.prototype.incrementIncomingBytes_=function(t){var e=Aa(t).length;this.bytesReceived+=e,this.stats_.incrementCounter("bytes_received",e)},cl);function cl(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_=jh.getCollection(e),this.urlFn=function(t){return e.connectionURL(Js,t)}}var hl=(ll.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||vs("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},ll.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())},ll.prototype.startLongPoll=function(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););},ll.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},ll.prototype.enqueueSegment=function(t,e,n){this.pendingSegs.push({seg:t,ts:e,d:n}),this.alive&&this.newRequest_()},ll.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()})},ll.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(){vs("Long-poll script failed to load: "+t),r.sendNewPolls=!1,r.close()},r.myIFrame.doc.body.appendChild(e)}catch(t){}},Math.floor(1))},ll);function ll(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=Rs(),window["pLPCommand"+this.uniqueCallbackIdentifier]=t,window["pRTLPCB"+this.uniqueCallbackIdentifier]=e,this.myIFrame=ll.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){vs("frame writing exception"),t.stack&&vs(t.stack),vs(t)}}var pl="";var dl=null;"undefined"!=typeof MozWebSocket?dl=MozWebSocket:"undefined"!=typeof WebSocket&&(dl=WebSocket);var yl=(ml.connectionURL_=function(t,e,n){var r={v:"5"};return"undefined"!=typeof location&&location.href&&-1!==location.href.indexOf(Ys)&&(r.r="f"),e&&(r.s=e),n&&(r.ls=n),t.connectionURL(Xs,r)},ml.prototype.open=function(t,e){var n=this;this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Ns.set("previous_websocket_failure",!0);try{if(wa()){var r=ca.NODE_ADMIN?"AdminNode":"Node",i={headers:{"User-Agent":"Firebase/5/"+pl+"/"+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 dl(this.connURL,[],i)}else this.mySock=new dl(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_()}},ml.prototype.start=function(){},ml.forceDisallow=function(){ml.forceDisallow_=!0},ml.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!==dl&&!ml.forceDisallow_},ml.previouslyFailed=function(){return Ns.isInMemoryStorage||!0===Ns.get("previous_websocket_failure")},ml.prototype.markConnectionHealthy=function(){Ns.remove("previous_websocket_failure")},ml.prototype.appendFrame_=function(t){if(this.frames.push(t),this.frames.length==this.totalFrames){var e=this.frames.join("");this.frames=null;var n=Na(e);this.onMessage(n)}},ml.prototype.handleNewFrameCount_=function(t){this.totalFrames=t,this.frames=[]},ml.prototype.extractFrameCount_=function(t){if(ha(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},ml.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)}}},ml.prototype.send=function(t){this.resetKeepAlive();var e=Aa(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);var n=Is(e,16384);1<n.length&&this.sendString_(String(n.length));for(var r=0;r<n.length;r++)this.sendString_(n[r])},ml.prototype.shutdown_=function(){this.isClosed_=!0,this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&&(this.mySock.close(),this.mySock=null)},ml.prototype.onClosed_=function(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&&(this.onDisconnect(this.everConnected_),this.onDisconnect=null))},ml.prototype.close=function(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())},ml.prototype.resetKeepAlive=function(){var t=this;clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval(function(){t.mySock&&t.sendString_("0"),t.resetKeepAlive()},Math.floor(45e3))},ml.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)}},ml.responsesRequiredToBeHealthy=2,ml.healthyTimeout=3e4,ml);function ml(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_=jh.getCollection(e),this.connURL=ml.connectionURL_(e,n,r)}var vl=(Object.defineProperty(gl,"ALL_TRANSPORTS",{get:function(){return[ul,yl]},enumerable:!0,configurable:!0}),gl.prototype.initTransports_=function(t){var e,n,r=yl&&yl.isAvailable(),i=r&&!yl.previouslyFailed();if(t.webSocketOnly&&(r||_s("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[yl];else{var o=this.transports_=[];try{for(var a=ra(gl.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}}}},gl.prototype.initialTransport=function(){if(0<this.transports_.length)return this.transports_[0];throw new Error("No transports available")},gl.prototype.upgradeTransport=function(){return 1<this.transports_.length?this.transports_[1]:null},gl);function gl(t){this.initTransports_(t)}var bl=(wl.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_=js(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)))},wl.prototype.nextTransportId_=function(){return"c:"+this.id+":"+this.connectionCount++},wl.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")}},wl.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"))}},wl.prototype.sendRequest=function(t){var e={t:"d",d:t};this.sendData_(e)},wl.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)},wl.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_())}},wl.prototype.onSecondaryMessageReceived_=function(t){var e=Ss("t",t),n=Ss("d",t);if("c"==e)this.onSecondaryControl_(n);else{if("d"!=e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(n)}},wl.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:{}}}))},wl.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()},wl.prototype.onPrimaryMessageReceived_=function(t){var e=Ss("t",t),n=Ss("d",t);"c"==e?this.onControl_(n):"d"==e&&this.onDataMessage_(n)},wl.prototype.onDataMessage_=function(t){this.onPrimaryResponse_(),this.onMessage_(t)},wl.prototype.onPrimaryResponse_=function(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))},wl.prototype.onControl_=function(t){var e=Ss("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?bs("Server Error: "+n):"o"===e?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):bs("Unknown control packet command: "+e)}},wl.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&&_s("Protocol version mismatch detected"),this.tryStartUpgrade_())},wl.prototype.tryStartUpgrade_=function(){var t=this.transportManager_.upgradeTransport();t&&this.startUpgrade_(t)},wl.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),js(function(){e.secondaryConn_&&(e.log_("Timed out trying to upgrade."),e.secondaryConn_.close())},Math.floor(6e4))},wl.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_())},wl.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):js(function(){n.sendPingOnPrimaryIfNecessary_()},Math.floor(5e3))},wl.prototype.sendPingOnPrimaryIfNecessary_=function(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))},wl.prototype.onSecondaryConnectionLost_=function(){var t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()},wl.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()&&(Ns.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()},wl.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()},wl.prototype.sendData_=function(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)},wl.prototype.close=function(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))},wl.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)},wl);function wl(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 vl(e),this.log_("Connection created"),this.start_()}var _l=(El.prototype.put=function(t,e,n,r){},El.prototype.merge=function(t,e,n,r){},El.prototype.refreshAuthToken=function(t){},El.prototype.onDisconnectPut=function(t,e,n){},El.prototype.onDisconnectMerge=function(t,e,n){},El.prototype.onDisconnectCancel=function(t,e){},El.prototype.reportStats=function(t){},El);function El(){}var Tl,Sl=(Zo(Il,Tl=_l),Il.prototype.sendRequest=function(t,e,n){var r=++this.requestNumber_,i={r:r,a:t,b:e};this.log_(Aa(i)),ha(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&&(this.requestCBHash_[r]=n)},Il.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),ha(t.getQueryParams().isDefault()||!t.getQueryParams().loadsAllData(),"listen() called for non-default but complete query"),ha(!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)},Il.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;Il.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))})},Il.warnOnListenWarnings_=function(t,e){if(t&&"object"==typeof t&&Da(t,"w")){var n=Ra(t,"w");if(Array.isArray(n)&&~n.indexOf("no_index")){var r='".indexOn": "'+e.getQueryParams().getIndex().toString()+'"',i=e.path.toString();_s("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.")}}},Il.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)},Il.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)},Il.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))})}},Il.prototype.unlisten=function(t,e){var n=t.path.toString(),r=t.queryIdentifier();this.log_("Unlisten called for "+n+" "+r),ha(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)},Il.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)},Il.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})},Il.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})},Il.prototype.onDisconnectCancel=function(t,e){this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})},Il.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))})},Il.prototype.put=function(t,e,n,r){this.putInternal("p",t,e,n,r)},Il.prototype.merge=function(t,e,n,r){this.putInternal("m",t,e,n,r)},Il.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)},Il.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)})},Il.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)}})}},Il.prototype.onDataMessage_=function(t){if("r"in t){this.log_("from server: "+Aa(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)}},Il.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):bs("Unrecognized action received from server: "+Aa(t)+"\nAre you using the latest client?")},Il.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)},Il.prototype.scheduleConnect_=function(t){var e=this;ha(!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))},Il.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},Il.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())},Il.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)},Il.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+":"+Il.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){ha(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?vs("getToken() completed but was canceled"):(vs("getToken() completed. Creating connection."),o.authToken_=t&&t.accessToken,u=new bl(i,o.repoInfo_,e,n,r,function(t){_s(t+" ("+o.repoInfo_.toString()+")"),o.interrupt("server_kill")},a))}).then(null,function(t){o.log_("Failed to get token: "+t),s||c()})}},Il.prototype.interrupt=function(t){vs("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_())},Il.prototype.resume=function(t){vs("Resuming connection for reason: "+t),delete this.interruptReasons_[t],Oa(this.interruptReasons_)&&(this.reconnectDelay_=1e3,this.realtime_||this.scheduleConnect_(0))},Il.prototype.handleTimestamp_=function(t){var e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})},Il.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_=[])},Il.prototype.onListenRevoked_=function(t,e){var n;n=e?e.map(function(t){return Us(t)}).join("$"):"default";var r=this.removeListen_(t,n);r&&r.onComplete&&r.onComplete("permission_denied")},Il.prototype.removeListen_=function(t,e){var n,r=new Qs(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},Il.prototype.onAuthRevoked_=function(t,e){vs("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()))},Il.prototype.onSecurityDebugPacket_=function(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))},Il.prototype.restoreState_=function(){var e,t,n,r;this.tryAuth();try{for(var i=ra(this.listens.values()),o=i.next();!o.done;o=i.next()){var a=o.value;try{for(var s=(n=void 0,ra(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)}},Il.prototype.sendConnectStats_=function(){var t={};t["sdk.js."+pl.replace(/\./g,"-")]=1,ga()?t["framework.cordova"]=1:ba()&&(t["framework.reactnative"]=1),this.reportStats(t)},Il.prototype.shouldReconnect_=function(){var t=il.getInstance().currentlyOnline();return Oa(this.interruptReasons_)&&t},Il.nextPersistentConnectionId_=0,Il.nextConnectionId_=0,Il);function Il(t,e,n,r,i,o){var a=Tl.call(this)||this;if(a.repoInfo_=t,a.onDataUpdate_=e,a.onConnectStatus_=n,a.onServerInfoUpdate_=r,a.authTokenProvider_=i,a.authOverride_=o,a.id=Il.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&&!wa())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");return a.scheduleConnect_(0),el.getInstance().on("visible",a.onVisible_,a),-1===t.host.indexOf("fblocal")&&il.getInstance().on("online",a.onOnline_,a),a}var Cl,Nl=(Zo(Al,Cl=_l),Al.prototype.reportStats=function(t){throw new Error("Method not implemented.")},Al.getListenId_=function(t,e){return void 0!==e?"tag$"+e:(ha(t.getQueryParams().isDefault(),"should have a tag if it's not a default query."),t.path.toString())},Al.prototype.listen=function(t,e,r,i){var o=this,a=t.path.toString();this.log_("Listen called for "+a+" "+t.queryIdentifier());var s=Al.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),Ra(o.listens_,s)===u&&i(t?401==t?"permission_denied":"rest_error:"+t:"ok",null)})},Al.prototype.unlisten=function(t,e){var n=Al.getListenId_(t,e);delete this.listens_[n]},Al.prototype.refreshAuthToken=function(t){},Al.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=Na(r.responseText)}catch(t){_s("Failed to parse JSON response for "+n+": "+r.responseText)}a(null,t)}else 401!==r.status&&404!==r.status&&_s("Got unsuccessful REST response for "+n+" Status: "+r.status),a(r.status);a=null}},r.open("GET",n,!0),r.send()})},Al);function Al(t,e,n){var r=Cl.call(this)||this;return r.repoInfo_=t,r.onDataUpdate_=e,r.authTokenProvider_=n,r.log_=gs("p:rest:"),r.listens_={},r}var kl="repo_interrupt",Dl=(Rl.prototype.toString=function(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host},Rl.prototype.name=function(){return this.repoInfo_.namespace},Rl.prototype.serverTime=function(){var t=this.infoData_.getNode(new Qs(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t},Rl.prototype.generateServerValues=function(){return function(t){return(t=t||{}).timestamp=t.timestamp||(new Date).getTime(),t}({timestamp:this.serverTime()})},Rl.prototype.onDataUpdate_=function(t,e,n,r){this.dataUpdateCount++;var i=new Qs(t);e=this.interceptServerDataCallback_?this.interceptServerDataCallback_(t,e):e;var o=[];if(r)if(n){var a=Pa(e,function(t){return vc(t)});o=this.serverSyncTree_.applyTaggedQueryMerge(i,a,r)}else{var s=vc(e);o=this.serverSyncTree_.applyTaggedQueryOverwrite(i,s,r)}else if(n){var u=Pa(e,function(t){return vc(t)});o=this.serverSyncTree_.applyServerMerge(i,u)}else{var c=vc(e);o=this.serverSyncTree_.applyServerOverwrite(i,c)}var h=i;0<o.length&&(h=this.rerunTransactions_(i)),this.eventQueue_.raiseEventsForChangedPath(h,o)},Rl.prototype.interceptServerData_=function(t){this.interceptServerDataCallback_=t},Rl.prototype.onConnectStatus_=function(t){this.updateInfo_("connected",t),!1===t&&this.runOnDisconnectEvents_()},Rl.prototype.onServerInfoUpdate_=function(t){var n=this;qs(t,function(t,e){n.updateInfo_(t,e)})},Rl.prototype.updateInfo_=function(t,e){var n=new Qs("/.info/"+t),r=vc(e);this.infoData_.updateSnapshot(n,r);var i=this.infoSyncTree_.applyServerOverwrite(n,r);this.eventQueue_.raiseEventsForChangedPath(n,i)},Rl.prototype.getNextWriteId_=function(){return this.nextWriteId_++},Rl.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=vc(t,e),s=Bc(r,n),u=this.getNextWriteId_(),c=this.serverSyncTree_.applyUserOverwrite(i,s,u,!0);this.eventQueue_.queueEvents(c),this.server_.put(i.toString(),r.val(!0),function(t,e){var n="ok"===t;n||_s("set at "+i+" failed: "+t);var r=a.serverSyncTree_.ackUserWrite(u,!n);a.eventQueue_.raiseEventsForChangedPath(i,r),a.callOnCompleteCallback(o,t,e)});var h=this.abortTransactions_(i);this.rerunTransactions_(h),this.eventQueue_.raiseEventsForChangedPath(h,[])},Rl.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(qs(t,function(t,e){r=!1;var n=vc(e);u[t]=Bc(n,i)}),r)vs("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||_s("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)}),qs(t,function(t){var e=s.abortTransactions_(o.child(t));s.rerunTransactions_(e)}),this.eventQueue_.raiseEventsForChangedPath(o,[])}},Rl.prototype.runOnDisconnectEvents_=function(){var r=this;this.log_("onDisconnectEvents");var t=this.generateServerValues(),e=function(t,n){var r=new Lc;return t.forEachTree(new Qs(""),function(t,e){r.remember(t,Bc(e,n))}),r}(this.onDisconnect_,t),i=[];e.forEachTree(Qs.Empty,function(t,e){i=i.concat(r.serverSyncTree_.applyServerOverwrite(t,e));var n=r.abortTransactions_(t);r.rerunTransactions_(n)}),this.onDisconnect_=new Lc,this.eventQueue_.raiseEventsForChangedPath(Qs.Empty,i)},Rl.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)})},Rl.prototype.onDisconnectSet=function(n,t,r){var i=this,o=vc(t);this.server_.onDisconnectPut(n.toString(),o.val(!0),function(t,e){"ok"===t&&i.onDisconnect_.remember(n,o),i.callOnCompleteCallback(r,t,e)})},Rl.prototype.onDisconnectSetWithPriority=function(n,t,e,r){var i=this,o=vc(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)})},Rl.prototype.onDisconnectUpdate=function(r,n,i){var o=this;if(Oa(n))return vs("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&&qs(n,function(t,e){var n=vc(e);o.onDisconnect_.remember(r.child(t),n)}),o.callOnCompleteCallback(i,t,e)})},Rl.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)},Rl.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)},Rl.prototype.interrupt=function(){this.persistentConnection_&&this.persistentConnection_.interrupt(kl)},Rl.prototype.resume=function(){this.persistentConnection_&&this.persistentConnection_.resume(kl)},Rl.prototype.stats=function(t){if(void 0===t&&(t=!1),"undefined"!=typeof console){var e;e=t?(this.statsListener_||(this.statsListener_=new Kh(this.stats_)),this.statsListener_.get()):this.stats_.get();var i=Object.keys(e).reduce(function(t,e){return Math.max(e.length,t)},0);qs(e,function(t,e){for(var n=t,r=t.length;r<i+2;r++)n+=" ";console.log(n+e)})}},Rl.prototype.statsIncrementCounter=function(t){this.stats_.incrementCounter(t),this.statsReporter_.includeStat(t)},Rl.prototype.log_=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="";this.persistentConnection_&&(n=this.persistentConnection_.id+":"),vs.apply(void 0,oa([n],t))},Rl.prototype.callOnCompleteCallback=function(r,i,o){r&&Bs(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(Rl.prototype,"database",{get:function(){return this.__database||(this.__database=new Xl(this))},enumerable:!0,configurable:!0}),Rl);function Rl(t,e,n){var r,a=this;if(this.repoInfo_=t,this.app=n,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new zh,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=new Lc,this.persistentConnection_=null,r="undefined"!=typeof process&&process.env[Ds]?new Uh(n):new xh(n),this.stats_=jh.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 Nl(this.repoInfo_,this.onDataUpdate_.bind(this),r),setTimeout(this.onConnectStatus_.bind(this,!0),0);else{var i=n.options.databaseAuthVariableOverride;if(null!=i){if("object"!=typeof i)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{Aa(i)}catch(t){throw new Error("Invalid authOverride provided: "+t)}}this.persistentConnection_=new Sl(this.repoInfo_,this.onDataUpdate_.bind(this),this.onConnectStatus_.bind(this),this.onServerInfoUpdate_.bind(this),r,i),this.server_=this.persistentConnection_}r.addTokenChangeListener(function(t){a.server_.refreshAuthToken(t)}),this.statsReporter_=jh.getOrCreateReporter(t,function(){return new Hh(a.stats_,a.server_)}),this.transactions_init_(),this.infoData_=new Ph,this.infoSyncTree_=new Rh({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 Rh({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 Ol=(Pl.prototype.getStartPost=function(){return this.startPost_},Pl.prototype.getEndPost=function(){return this.endPost_},Pl.prototype.matches=function(t){return this.index_.compare(this.getStartPost(),t)<=0&&this.index_.compare(t,this.getEndPost())<=0},Pl.prototype.updateChild=function(t,e,n,r,i,o){return this.matches(new Iu(e,n))||(n=lc.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,n,r,i,o)},Pl.prototype.updateFullNode=function(t,e,n){e.isLeafNode()&&(e=lc.EMPTY_NODE);var r=e.withIndex(this.index_);r=r.updatePriority(lc.EMPTY_NODE);var i=this;return e.forEachChild(Ku,function(t,e){i.matches(new Iu(t,e))||(r=r.updateImmediateChild(t,lc.EMPTY_NODE))}),this.indexedFilter_.updateFullNode(t,r,n)},Pl.prototype.updatePriority=function(t,e){return t},Pl.prototype.filtersNodes=function(){return!0},Pl.prototype.getIndexedFilter=function(){return this.indexedFilter_},Pl.prototype.getIndex=function(){return this.index_},Pl.getStartPost_=function(t){if(t.hasStart()){var e=t.getIndexStartName();return t.getIndex().makePost(t.getIndexStartValue(),e)}return t.getIndex().minPost()},Pl.getEndPost_=function(t){if(t.hasEnd()){var e=t.getIndexEndName();return t.getIndex().makePost(t.getIndexEndValue(),e)}return t.getIndex().maxPost()},Pl);function Pl(t){this.indexedFilter_=new sh(t.getIndex()),this.index_=t.getIndex(),this.startPost_=Pl.getStartPost_(t),this.endPost_=Pl.getEndPost_(t)}var Ml=(xl.prototype.updateChild=function(t,e,n,r,i,o){return this.rangedFilter_.matches(new Iu(e,n))||(n=lc.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)},xl.prototype.updateFullNode=function(t,e,n){var r;if(e.isLeafNode()||e.isEmpty())r=lc.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_<e.numChildren()&&e.isIndexed(this.index_)){r=lc.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(lc.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,lc.EMPTY_NODE)}return this.rangedFilter_.getIndexedFilter().updateFullNode(t,r,n)},xl.prototype.updatePriority=function(t,e){return t},xl.prototype.filtersNodes=function(){return!0},xl.prototype.getIndexedFilter=function(){return this.rangedFilter_.getIndexedFilter()},xl.prototype.getIndex=function(){return this.index_},xl.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;ha(s.numChildren()==this.limit_,"");var u=new Iu(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(oh.childChangedChange(e,n,l)),s.updateImmediateChild(e,n);null!=i&&i.trackChildChange(oh.childRemovedChange(e,l));var d=s.updateImmediateChild(e,lc.EMPTY_NODE);return null!=f&&this.rangedFilter_.matches(f)?(null!=i&&i.trackChildChange(oh.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(oh.childRemovedChange(c.name,c.node)),i.trackChildChange(oh.childAddedChange(e,n))),s.updateImmediateChild(e,n).updateImmediateChild(c.name,lc.EMPTY_NODE)):t},xl);function xl(t){this.rangedFilter_=new Ol(t),this.index_=t.getIndex(),this.limit_=t.getLimit(),this.reverse_=!t.isViewFromLeft()}var Ll=(Fl.prototype.hasStart=function(){return this.startSet_},Fl.prototype.isViewFromLeft=function(){return""===this.viewFrom_?this.startSet_:this.viewFrom_===Fl.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT},Fl.prototype.getIndexStartValue=function(){return ha(this.startSet_,"Only valid if start has been set"),this.indexStartValue_},Fl.prototype.getIndexStartName=function(){return ha(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:xs},Fl.prototype.hasEnd=function(){return this.endSet_},Fl.prototype.getIndexEndValue=function(){return ha(this.endSet_,"Only valid if end has been set"),this.indexEndValue_},Fl.prototype.getIndexEndName=function(){return ha(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Ls},Fl.prototype.hasLimit=function(){return this.limitSet_},Fl.prototype.hasAnchoredLimit=function(){return this.limitSet_&&""!==this.viewFrom_},Fl.prototype.getLimit=function(){return ha(this.limitSet_,"Only valid if limit has been set"),this.limit_},Fl.prototype.getIndex=function(){return this.index_},Fl.prototype.copy_=function(){var t=new Fl;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},Fl.prototype.limit=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_="",e},Fl.prototype.limitToFirst=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_=Fl.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_LEFT,e},Fl.prototype.limitToLast=function(t){var e=this.copy_();return e.limitSet_=!0,e.limit_=t,e.viewFrom_=Fl.WIRE_PROTOCOL_CONSTANTS_.VIEW_FROM_RIGHT,e},Fl.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},Fl.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},Fl.prototype.orderBy=function(t){var e=this.copy_();return e.index_=t,e},Fl.prototype.getQueryObject=function(){var t=Fl.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_!==Ku&&(e[t.INDEX]=this.index_.toString()),e},Fl.prototype.loadsAllData=function(){return!(this.startSet_||this.endSet_||this.limitSet_)},Fl.prototype.isDefault=function(){return this.loadsAllData()&&this.index_==Ku},Fl.prototype.getNodeFilter=function(){return this.loadsAllData()?new sh(this.getIndex()):this.hasLimit()?new Ml(this):new Ol(this)},Fl.prototype.toRestQueryStringParameters=function(){var t,e=Fl.REST_QUERY_CONSTANTS_,n={};return this.isDefault()||(t=this.index_===Ku?e.PRIORITY_INDEX:this.index_===wc?e.VALUE_INDEX:this.index_===Mu?e.KEY_INDEX:(ha(this.index_ instanceof _c,"Unrecognized index type!"),this.index_.toString()),n[e.ORDER_BY]=Aa(t),this.startSet_&&(n[e.START_AT]=Aa(this.indexStartValue_),this.startNameSet_&&(n[e.START_AT]+=","+Aa(this.indexStartName_))),this.endSet_&&(n[e.END_AT]=Aa(this.indexEndValue_),this.endNameSet_&&(n[e.END_AT]+=","+Aa(this.indexEndName_))),this.limitSet_&&(this.isViewFromLeft()?n[e.LIMIT_TO_FIRST]=this.limit_:n[e.LIMIT_TO_LAST]=this.limit_)),n},Fl.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"},Fl.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"},Fl.DEFAULT=new Fl,Fl);function Fl(){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_=Ku}var Ul,ql=(Zo(Vl,Ul=Mc),Vl.prototype.getKey=function(){return Va("Reference.key",0,0,arguments.length),this.path.isEmpty()?null:this.path.getBack()},Vl.prototype.child=function(t){return Va("Reference.child",1,1,arguments.length),"number"==typeof t?t=String(t):t instanceof Qs||(null===this.path.getFront()?function(t,e,n,r){n=n&&n.replace(/^\/*\.info(\/|$)/,"/"),cu(t,e,n,r)}("Reference.child",1,t,!1):cu("Reference.child",1,t,!1)),new Vl(this.repo,this.path.child(t))},Vl.prototype.getParent=function(){Va("Reference.parent",0,0,arguments.length);var t=this.path.parent();return null===t?null:new Vl(this.repo,t)},Vl.prototype.getRoot=function(){Va("Reference.root",0,0,arguments.length);for(var t=this;null!==t.getParent();)t=t.getParent();return t},Vl.prototype.databaseProp=function(){return this.repo.database},Vl.prototype.set=function(t,e){Va("Reference.set",1,2,arguments.length),hu("Reference.set",this.path),iu("Reference.set",1,t,this.path,!1),ja("Reference.set",2,e,!0);var n=new ya;return this.repo.setWithPriority(this.path,t,null,n.wrapCallback(e)),n.promise},Vl.prototype.update=function(t,e){if(Va("Reference.update",1,2,arguments.length),hu("Reference.update",this.path),Array.isArray(t)){for(var n={},r=0;r<t.length;++r)n[""+r]=t[r];t=n,_s("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.")}ou("Reference.update",1,t,this.path,!1),ja("Reference.update",2,e,!0);var i=new ya;return this.repo.update(this.path,t,i.wrapCallback(e)),i.promise},Vl.prototype.setWithPriority=function(t,e,n){if(Va("Reference.setWithPriority",2,3,arguments.length),hu("Reference.setWithPriority",this.path),iu("Reference.setWithPriority",1,t,this.path,!1),au("Reference.setWithPriority",2,e,!1),ja("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 ya;return this.repo.setWithPriority(this.path,t,e,r.wrapCallback(n)),r.promise},Vl.prototype.remove=function(t){return Va("Reference.remove",0,1,arguments.length),hu("Reference.remove",this.path),ja("Reference.remove",1,t,!0),this.set(null,t)},Vl.prototype.transaction=function(t,r,e){if(Va("Reference.transaction",1,3,arguments.length),hu("Reference.transaction",this.path),ja("Reference.transaction",1,t,!1),ja("Reference.transaction",2,r,!0),function(t,e,n,r){if((!r||void 0!==n)&&"boolean"!=typeof n)throw new Error(Ba(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 ya;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 bu(e,n)),"function"==typeof r&&r(t,e,n)},e),i.promise},Vl.prototype.setPriority=function(t,e){Va("Reference.setPriority",1,2,arguments.length),hu("Reference.setPriority",this.path),au("Reference.setPriority",1,t,!1),ja("Reference.setPriority",2,e,!0);var n=new ya;return this.repo.setWithPriority(this.path.child(".priority"),t,null,n.wrapCallback(e)),n.promise},Vl.prototype.push=function(t,e){Va("Reference.push",0,2,arguments.length),hu("Reference.push",this.path),iu("Reference.push",1,t,this.path,!0),ja("Reference.push",2,e,!0);var n,r=this.repo.serverTime(),i=Su(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},Vl.prototype.onDisconnect=function(){return hu("Reference.onDisconnect",this.path),new vu(this.repo,this.path)},Object.defineProperty(Vl.prototype,"database",{get:function(){return this.databaseProp()},enumerable:!0,configurable:!0}),Object.defineProperty(Vl.prototype,"key",{get:function(){return this.getKey()},enumerable:!0,configurable:!0}),Object.defineProperty(Vl.prototype,"parent",{get:function(){return this.getParent()},enumerable:!0,configurable:!0}),Object.defineProperty(Vl.prototype,"root",{get:function(){return this.getRoot()},enumerable:!0,configurable:!0}),Vl);function Vl(t,e){if(!(t instanceof Dl))throw new Error("new Reference() no longer supported - use app.database().");return Ul.call(this,t,e,Ll.DEFAULT,!1)||this}Mc.__referenceConstructor=ql,Th.__referenceConstructor=ql;var Bl,jl,Wl=function(){this.children={},this.childCount=0,this.value=null},Kl=(Ql.prototype.subTree=function(t){for(var e,n=t instanceof Qs?t:new Qs(t),r=this;null!==(e=n.getFront());)r=new Ql(e,r,Ra(r.node_.children,e)||new Wl),n=n.popFront();return r},Ql.prototype.getValue=function(){return this.node_.value},Ql.prototype.setValue=function(t){ha(void 0!==t,"Cannot set value to undefined"),this.node_.value=t,this.updateParents_()},Ql.prototype.clear=function(){this.node_.value=null,this.node_.children={},this.node_.childCount=0,this.updateParents_()},Ql.prototype.hasChildren=function(){return 0<this.node_.childCount},Ql.prototype.isEmpty=function(){return null===this.getValue()&&!this.hasChildren()},Ql.prototype.forEachChild=function(n){var r=this;qs(this.node_.children,function(t,e){n(new Ql(t,r,e))})},Ql.prototype.forEachDescendant=function(e,t,n){t&&!n&&e(this),this.forEachChild(function(t){t.forEachDescendant(e,!0,n)}),t&&n&&e(this)},Ql.prototype.forEachAncestor=function(t,e){for(var n=e?this:this.parent();null!==n;){if(t(n))return!0;n=n.parent()}return!1},Ql.prototype.forEachImmediateDescendantWithValue=function(e){this.forEachChild(function(t){null!==t.getValue()?e(t):t.forEachImmediateDescendantWithValue(e)})},Ql.prototype.path=function(){return new Qs(null===this.parent_?this.name_:this.parent_.path()+"/"+this.name_)},Ql.prototype.name=function(){return this.name_},Ql.prototype.parent=function(){return this.parent_},Ql.prototype.updateParents_=function(){null!==this.parent_&&this.parent_.updateChild_(this.name_,this)},Ql.prototype.updateChild_=function(t,e){var n=e.isEmpty(),r=Da(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_())},Ql);function Ql(t,e,n){void 0===t&&(t=""),void 0===e&&(e=null),void 0===n&&(n=new Wl),this.name_=t,this.parent_=e,this.node_=n}(jl=Bl=Bl||{})[jl.RUN=0]="RUN",jl[jl.SENT=1]="SENT",jl[jl.COMPLETED=2]="COMPLETED",jl[jl.SENT_NEEDS_ABORT=3]="SENT_NEEDS_ABORT",jl[jl.NEEDS_ABORT=4]="NEEDS_ABORT",Dl.MAX_TRANSACTION_RETRIES_=25,Dl.prototype.transactions_init_=function(){this.transactionQueueTree_=new Kl},Dl.prototype.startTransaction=function(t,e,n,r){this.log_("transaction on "+t);function i(){}var o=new ql(this,t);o.on("value",i);var a={path:t,update:e,onComplete:n,status:null,order:Rs(),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 Tc(a.currentInputSnapshot,new ql(this,a.path),Ku);a.onComplete(null,!1,c)}}else{mu("transaction failed: Data returned ",u,a.path),a.status=Bl.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&&Da(u,".priority"))f=Ra(u,".priority"),ha(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)||lc.EMPTY_NODE).getPriority().val();f=f;var p=this.generateServerValues(),d=vc(u,f),y=Bc(d,p);a.currentOutputSnapshotRaw=d,a.currentOutputSnapshotResolved=y,a.currentWriteId=this.getNextWriteId_();var m=this.serverSyncTree_.applyUserOverwrite(t,y,a.currentWriteId,a.applyLocally);this.eventQueue_.raiseEventsForChangedPath(t,m),this.sendReadyTransactions_()}},Dl.prototype.getLatestState_=function(t,e){return this.serverSyncTree_.calcCompleteEventCache(t,e)||lc.EMPTY_NODE},Dl.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);ha(0<n.length,"Sending zero length transaction queue"),n.every(function(t){return t.status===Bl.RUN})&&this.sendTransactionQueue_(t.path(),n)}else t.hasChildren()&&t.forEachChild(function(t){e.sendReadyTransactions_(t)})},Dl.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];ha(o.status===Bl.RUN,"tryToSendTransactionQueue_: items in queue should all be run."),o.status=Bl.SENT,o.retryCount++;var a=Qs.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=Bl.COMPLETED,e=e.concat(c.serverSyncTree_.ackUserWrite(u[r].currentWriteId)),u[r].onComplete){var i=u[r].currentOutputSnapshotResolved,o=new ql(c,u[r].path),a=new Tc(i,o,Ku);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++)Bs(n[r])}else{if("datastale"===t)for(r=0;r<u.length;r++)u[r].status===Bl.SENT_NEEDS_ABORT?u[r].status=Bl.NEEDS_ABORT:u[r].status=Bl.RUN;else{_s("transaction at "+l.toString()+" failed: "+t);for(r=0;r<u.length;r++)u[r].status=Bl.NEEDS_ABORT,u[r].abortReason=t}c.rerunTransactions_(s)}},r)},Dl.prototype.rerunTransactions_=function(t){var e=this.getAncestorTransactionNode_(t),n=e.path(),r=this.buildTransactionQueue_(e);return this.rerunTransactionQueue_(r,n),n},Dl.prototype.rerunTransactionQueue_=function(t,e){if(0!==t.length){for(var n,r=[],i=[],o=t.filter(function(t){return t.status===Bl.RUN}).map(function(t){return t.currentWriteId}),a=0;a<t.length;a++){var s=t[a],u=Qs.relativePath(e,s.path),c=!1,h=void 0;if(ha(null!==u,"rerunTransactionsUnderNode_: relativePath should not be null."),s.status===Bl.NEEDS_ABORT)c=!0,h=s.abortReason,i=i.concat(this.serverSyncTree_.ackUserWrite(s.currentWriteId,!0));else if(s.status===Bl.RUN)if(s.retryCount>=Dl.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){mu("transaction failed: Data returned ",f,s.path);var p=vc(f);"object"==typeof f&&null!=f&&Da(f,".priority")||(p=p.updatePriority(l.getPriority()));var d=s.currentWriteId,y=this.generateServerValues(),m=Bc(p,y);s.currentOutputSnapshotRaw=p,s.currentOutputSnapshotResolved=m,s.currentWriteId=this.getNextWriteId_(),o.splice(o.indexOf(d),1),i=(i=i.concat(this.serverSyncTree_.applyUserOverwrite(s.path,m,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=Bl.COMPLETED,n=t[a].unwatcher,setTimeout(n,Math.floor(0)),t[a].onComplete))if("nodata"===h){var v=new ql(this,t[a].path),g=t[a].currentInputSnapshot,b=new Tc(g,v,Ku);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++)Bs(r[a]);this.sendReadyTransactions_()}},Dl.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},Dl.prototype.buildTransactionQueue_=function(t){var e=[];return this.aggregateTransactionQueuesForNode_(t,e),e.sort(function(t,e){return t.order-e.order}),e},Dl.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)})},Dl.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!==Bl.COMPLETED&&(n[r]=n[i],r++);n.length=r,t.setValue(0<n.length?n:null)}t.forEachChild(function(t){e.pruneCompletedTransactionsBelowNode_(t)})},Dl.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},Dl.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===Bl.SENT_NEEDS_ABORT);else if(e[o].status===Bl.SENT)ha(i===o-1,"All SENT items should be at beginning of queue."),e[i=o].status=Bl.SENT_NEEDS_ABORT,e[o].abortReason="set";else if(ha(e[o].status===Bl.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++)Bs(n[o])}};var Hl,Gl="databaseURL",zl=(Yl.getInstance=function(){return Hl=Hl||new Yl},Yl.prototype.interrupt=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].interrupt()},Yl.prototype.resume=function(){for(var t in this.repos_)for(var e in this.repos_[t])this.repos_[t][e].resume()},Yl.prototype.databaseFromApp=function(t,e){var n=e||t.options[Gl];void 0===n&&ws("Can't determine Firebase Database URL. Be sure to include "+Gl+" option when calling firebase.initializeApp().");var r=tu(n),i=r.repoInfo,o=void 0;return"undefined"!=typeof process&&(o=process.env[Ds]),o&&(n="http://"+o+"?ns="+i.namespace,i=(r=tu(n)).repoInfo),lu("Invalid Firebase Database URL",1,r),r.path.isEmpty()||ws("Database URL must point to the root of a Firebase Database (not including a child path)."),this.createRepo(i,t).database},Yl.prototype.deleteRepo=function(t){var e=Ra(this.repos_,t.app.name);e&&Ra(e,t.repoInfo_.toURLString())===t||ws("Database "+t.app.name+"("+t.repoInfo_+") has already been deleted."),t.interrupt(),delete e[t.repoInfo_.toURLString()]},Yl.prototype.createRepo=function(t,e){var n=Ra(this.repos_,e.name);n||(n={},this.repos_[e.name]=n);var r=Ra(n,t.toURLString());return r&&ws("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),r=new Dl(t,this.useRestClient_,e),n[t.toURLString()]=r},Yl.prototype.forceRestClient=function(t){this.useRestClient_=t},Yl);function Yl(){this.repos_={},this.useRestClient_=!1}var Xl=(Object.defineProperty(Jl.prototype,"app",{get:function(){return this.repo_.app},enumerable:!0,configurable:!0}),Jl.prototype.ref=function(t){return this.checkDeleted_("ref"),Va("database.ref",0,1,arguments.length),t instanceof ql?this.refFromURL(t.toString()):void 0!==t?this.root_.child(t):this.root_},Jl.prototype.refFromURL=function(t){var e="database.refFromURL";this.checkDeleted_(e),Va(e,1,1,arguments.length);var n=tu(t);lu(e,1,n);var r=n.repoInfo;return r.host!==this.repo_.repoInfo_.host&&ws(e+": Host name does not match the current database: (found "+r.host+" but expected "+this.repo_.repoInfo_.host+")"),this.ref(n.path.toString())},Jl.prototype.checkDeleted_=function(t){null===this.repo_&&ws("Cannot call "+t+" on a deleted database.")},Jl.prototype.goOffline=function(){Va("database.goOffline",0,0,arguments.length),this.checkDeleted_("goOffline"),this.repo_.interrupt()},Jl.prototype.goOnline=function(){Va("database.goOnline",0,0,arguments.length),this.checkDeleted_("goOnline"),this.repo_.resume()},Jl.ServerValue={TIMESTAMP:{".sv":"timestamp"}},Jl);function Jl(t){(this.repo_=t)instanceof Dl||ws("Don't call new Database() directly - please use firebase.database()."),this.root_=new ql(t,Qs.Empty),this.INTERNAL=new $l(this)}var $l=(Zl.prototype.delete=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){return this.database.checkDeleted_("delete"),zl.getInstance().deleteRepo(this.database.repo_),this.database.repo_=null,this.database.root_=null,this.database.INTERNAL=null,this.database=null,[2]})})},Zl);function Zl(t){this.database=t}var tf=Object.freeze({__proto__:null,forceLongPolling:function(){yl.forceDisallow(),ul.forceAllow()},forceWebSockets:function(){ul.forceDisallow()},isWebSocketsAvailable:function(){return yl.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)}}),ef=Sl;Sl.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},Sl.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)};var nf,rf,of=bl,af=$s,sf=Object.freeze({__proto__:null,DataConnection:ef,RealTimeConnection:of,hijackHash:function(i){var o=Sl.prototype.put;return Sl.prototype.put=function(t,e,n,r){void 0!==r&&(r=i()),o.call(this,t,e,n,r)},function(){Sl.prototype.put=o}},ConnectionTarget:af,queryIdentifier:function(t){return t.queryIdentifier()},forceRestClient:function(t){zl.getInstance().forceRestClient(t)}}),uf=Xl.ServerValue;nf=(rf=fl).SDK_VERSION,pl=nf,rf.INTERNAL.registerService("database",function(t,e,n){return zl.getInstance().databaseFromApp(t,n)},{Reference:ql,Query:Mc,Database:Xl,DataSnapshot:Tc,enableLogging:ms,INTERNAL:tf,ServerValue:uf,TEST_ACCESS:sf},null,!0);var cf,hf="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},lf=lf||{},ff=hf;function pf(t){return"string"==typeof t}function df(t){return"number"==typeof t}function yf(t,e){t=t.split("."),e=e||ff;for(var n=0;n<t.length;n++)if(null==(e=e[t[n]]))return null;return e}function mf(){}function vf(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 gf(t){return"array"==vf(t)}function bf(t){var e=vf(t);return"array"==e||"object"==e&&"number"==typeof t.length}function wf(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var _f="closure_uid_"+(1e9*Math.random()>>>0),Ef=0;function Tf(t,e,n){return t.call.apply(t.bind,arguments)}function Sf(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 If(t,e,n){return(If=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?Tf:Sf).apply(null,arguments)}function Cf(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 Nf=Date.now||function(){return+new Date};function Af(t,o){function e(){}e.prototype=o.prototype,t.N=o.prototype,t.prototype=new e,(t.prototype.constructor=t).yb=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 kf(){this.j=this.j,this.i=this.i}kf.prototype.j=!1,kf.prototype.la=function(){if(!this.j&&(this.j=!0,this.G(),0))this[_f]||(this[_f]=++Ef)},kf.prototype.G=function(){if(this.i)for(;this.i.length;)this.i.shift()()};var Df=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if(pf(t))return pf(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},Rf=Array.prototype.forEach?function(t,e,n){Array.prototype.forEach.call(t,e,n)}:function(t,e,n){for(var r=t.length,i=pf(t)?t.split(""):t,o=0;o<r;o++)o in i&&e.call(n,i[o],o,t)};function Of(){return Array.prototype.concat.apply([],arguments)}function Pf(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 Mf(t){return/^[\s\xa0]*$/.test(t)}var xf,Lf=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function Ff(t,e){return-1!=t.indexOf(e)}function Uf(t,e){return t<e?-1:e<t?1:0}t:{var qf=ff.navigator;if(qf){var Vf=qf.userAgent;if(Vf){xf=Vf;break t}}xf=""}function Bf(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function jf(t){var e,n={};for(e in t)n[e]=t[e];return n}var Wf="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function Kf(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<Wf.length;i++)e=Wf[i],Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}}function Qf(t){return Qf[" "](t),t}Qf[" "]=mf;var Hf,Gf,zf=Ff(xf,"Opera"),Yf=Ff(xf,"Trident")||Ff(xf,"MSIE"),Xf=Ff(xf,"Edge"),Jf=Xf||Yf,$f=Ff(xf,"Gecko")&&!(Ff(xf.toLowerCase(),"webkit")&&!Ff(xf,"Edge"))&&!(Ff(xf,"Trident")||Ff(xf,"MSIE"))&&!Ff(xf,"Edge"),Zf=Ff(xf.toLowerCase(),"webkit")&&!Ff(xf,"Edge");function tp(){var t=ff.document;return t?t.documentMode:void 0}t:{var ep="",np=(Gf=xf,$f?/rv:([^\);]+)(\)|;)/.exec(Gf):Xf?/Edge\/([\d\.]+)/.exec(Gf):Yf?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Gf):Zf?/WebKit\/(\S+)/.exec(Gf):zf?/(?:Version)[ \/]?(\S+)/.exec(Gf):void 0);if(np&&(ep=np?np[1]:""),Yf){var rp=tp();if(null!=rp&&rp>parseFloat(ep)){Hf=String(rp);break t}}Hf=ep}var ip,op={};function ap(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=Lf(String(Hf)).split("."),n=Lf(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=Uf(0==o[1].length?0:parseInt(o[1],10),0==a[1].length?0:parseInt(a[1],10))||Uf(0==o[2].length,0==a[2].length)||Uf(o[2],a[2]),o=o[3],a=a[3]}while(0==t)}return 0<=t})}var sp=ff.document;ip=sp&&Yf?tp()||("CSS1Compat"==sp.compatMode?parseInt(Hf,10):5):void 0;var up=!Yf||9<=Number(ip),cp=Yf&&!ap("9"),hp=function(){if(!ff.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{ff.addEventListener("test",mf,e),ff.removeEventListener("test",mf,e)}catch(t){}return t}();function lp(t,e){this.type=t,this.a=this.target=e,this.Ja=!0}function fp(t,e){if(lp.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($f){t:{try{Qf(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=pf(t.pointerType)?t.pointerType:pp[t.pointerType]||"",(this.c=t).defaultPrevented&&this.b()}}lp.prototype.b=function(){this.Ja=!1},Af(fp,lp);var pp={2:"touch",3:"pen",4:"mouse"};fp.prototype.b=function(){fp.N.b.call(this);var t=this.c;if(t.preventDefault)t.preventDefault();else if(t.returnValue=!1,cp)try{(t.ctrlKey||112<=t.keyCode&&t.keyCode<=123)&&(t.keyCode=-1)}catch(t){}};var dp="closure_listenable_"+(1e6*Math.random()|0),yp=0;function mp(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=++yp,this.X=this.Z=!1}function vp(t){t.X=!0,t.listener=null,t.proxy=null,t.src=null,t.da=null}function gp(t){this.src=t,this.a={},this.b=0}function bp(t,e){var n=e.type;if(n in t.a){var r,i=t.a[n],o=Df(i,e);(r=0<=o)&&Array.prototype.splice.call(i,o,1),r&&(vp(e),0==t.a[n].length&&(delete t.a[n],t.b--))}}function wp(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}gp.prototype.add=function(t,e,n,r,i){var o=t.toString();(t=this.a[o])||(t=this.a[o]=[],this.b++);var a=wp(t,e,r,i);return-1<a?(e=t[a],n||(e.Z=!1)):((e=new mp(e,this.src,o,!!r,i)).Z=n,t.push(e)),e};var _p="closure_lm_"+(1e6*Math.random()|0),Ep={};function Tp(t,e,n,r,i){if(r&&r.once)return function t(e,n,r,i,o){if(gf(n)){for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);return null}r=Rp(r);return e&&e[dp]?e.Ba(n,r,wf(i)?!!i.capture:!!i,o):Sp(e,n,r,!0,i,o)}(t,e,n,r,i);if(gf(e)){for(var o=0;o<e.length;o++)Tp(t,e[o],n,r,i);return null}return n=Rp(n),t&&t[dp]?t.Aa(e,n,wf(r)?!!r.capture:!!r,i):Sp(t,e,n,!1,r,i)}function Sp(t,e,n,r,i,o){if(!e)throw Error("Invalid event type");var a=wf(i)?!!i.capture:!!i;if(a&&!up)return null;var s=kp(t);if(s||(t[_p]=s=new gp(t)),(n=s.add(e,n,r,a,o)).proxy)return n;if(r=function(){var e=Ap,n=up?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)hp||(i=a),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Cp(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function Ip(t){if(!df(t)&&t&&!t.X){var e=t.src;if(e&&e[dp])bp(e.c,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Cp(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=kp(e))?(bp(n,t),0==n.b&&(n.src=null,e[_p]=null)):vp(t)}}}function Cp(t){return t in Ep?Ep[t]:Ep[t]="on"+t}function Np(t,e){var n=t.listener,r=t.da||t.src;return t.Z&&Ip(t),n.call(r,e)}function Ap(t,e){return!!t.X||(up?Np(t,new fp(e,this)):Np(t,e=new fp(e||yf("window.event"),this)))}function kp(t){return(t=t[_p])instanceof gp?t:null}var Dp="__closure_events_fn_"+(1e9*Math.random()>>>0);function Rp(e){return"function"==vf(e)?e:(e[Dp]||(e[Dp]=function(t){return e.handleEvent(t)}),e[Dp])}function Op(){kf.call(this),this.c=new gp(this),(this.J=this).B=null}function Pp(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&&bp(t.c,a),i=!1!==s.call(u,r)&&i}}return i&&0!=r.Ja}Af(Op,kf),Op.prototype[dp]=!0,(cf=Op.prototype).addEventListener=function(t,e,n,r){Tp(this,t,e,n,r)},cf.removeEventListener=function(t,e,n,r){!function t(e,n,r,i,o){if(gf(n))for(var a=0;a<n.length;a++)t(e,n[a],r,i,o);else i=wf(i)?!!i.capture:!!i,r=Rp(r),e&&e[dp]?(e=e.c,(n=String(n).toString())in e.a&&-1<(r=wp(a=e.a[n],r,i,o))&&(vp(a[r]),Array.prototype.splice.call(a,r,1),0==a.length&&(delete e.a[n],e.b--))):(e=e&&kp(e))&&(n=e.a[n.toString()],e=-1,n&&(e=wp(n,r,i,o)),(r=-1<e?n[e]:null)&&Ip(r))}(this,t,e,n,r)},cf.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(pf(t))t=new lp(t,n);else if(t instanceof lp)t.target=t.target||n;else{var i=t;Kf(t=new lp(r,n),i)}if(i=!0,e)for(var o=e.length-1;0<=o;o--){var a=t.a=e[o];i=Pp(a,r,!0,t)&&i}if(i=Pp(a=t.a=n,r,!0,t)&&i,i=Pp(a,r,!1,t)&&i,e)for(o=0;o<e.length;o++)i=Pp(a=t.a=e[o],r,!1,t)&&i;return i},cf.G=function(){if(Op.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++)vp(n[r]);delete e.a[t],e.b--}}this.B=null},cf.Aa=function(t,e,n,r){return this.c.add(String(t),e,!1,n,r)},cf.Ba=function(t,e,n,r){return this.c.add(String(t),e,!0,n,r)};var Mp=ff.JSON.stringify;function xp(t,e){this.c=t,this.f=e,this.b=0,this.a=null}function Lp(){this.b=this.a=null}xp.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 Fp,Up=new xp(function(){return new qp},function(t){t.reset()});function qp(){this.next=this.b=this.a=null}function Vp(t){ff.setTimeout(function(){throw t},0)}function Bp(t,e){Fp||function(){var t=ff.Promise.resolve(void 0);Fp=function(){t.then(Kp)}}(),jp||(Fp(),jp=!0),Wp.add(t,e)}Lp.prototype.add=function(t,e){var n=Up.get();n.set(t,e),this.b?this.b.next=n:this.a=n,this.b=n},qp.prototype.set=function(t,e){this.a=t,this.b=e,this.next=null};var jp=!(qp.prototype.reset=function(){this.next=this.b=this.a=null}),Wp=new Lp;function Kp(){for(var t;r=n=void 0,r=null,(n=Wp).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){Vp(t)}var e=Up;e.f(t),e.b<100&&(e.b++,t.next=e.a,e.a=t)}var n,r;jp=!1}function Qp(t,e){Op.call(this),this.b=t||1,this.a=e||ff,this.f=If(this.gb,this),this.g=Nf()}function Hp(t){t.ba=!1,t.L&&(t.a.clearTimeout(t.L),t.L=null)}function Gp(t,e,n){if("function"==vf(t))n&&(t=If(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=If(t.handleEvent,t)}return 2147483647<Number(e)?-1:ff.setTimeout(t,e||0)}function zp(t,e,n){kf.call(this),this.f=null!=n?If(t,n):t,this.c=e,this.b=If(this.ab,this),this.a=[]}function Yp(t){t.U=Gp(t.b,t.c),t.f.apply(null,t.a)}function Xp(t){kf.call(this),this.b=t,this.a={}}Af(Qp,Op),(cf=Qp.prototype).ba=!1,cf.L=null,cf.gb=function(){if(this.ba){var t=Nf()-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&&(Hp(this),this.start()))}},cf.start=function(){this.ba=!0,this.L||(this.L=this.a.setTimeout(this.f,this.b),this.g=Nf())},cf.G=function(){Qp.N.G.call(this),Hp(this),delete this.a},Af(zp,kf),(cf=zp.prototype).ea=!1,cf.U=null,cf.Ua=function(t){this.a=arguments,this.U?this.ea=!0:Yp(this)},cf.G=function(){zp.N.G.call(this),this.U&&(ff.clearTimeout(this.U),this.U=null,this.ea=!1,this.a=[])},cf.ab=function(){this.U=null,this.ea&&(this.ea=!1,Yp(this))},Af(Xp,kf);var Jp=[];function $p(t,e,n,r){gf(n)||(n&&(Jp[0]=n.toString()),n=Jp);for(var i=0;i<n.length;i++){var o=Tp(e,n[i],r||t.handleEvent,!1,t.b||t);if(!o)break;t.a[o.key]=o}}function Zp(t){Bf(t.a,function(t,e){this.a.hasOwnProperty(e)&&Ip(t)},t),t.a={}}function td(){}Xp.prototype.G=function(){Xp.N.G.call(this),Zp(this)},Xp.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ed=new Op;function nd(t){lp.call(this,"serverreachability",t)}function rd(t){ed.dispatchEvent(new nd(ed,t))}function id(t){lp.call(this,"statevent",t)}function od(t){ed.dispatchEvent(new id(ed,t))}function ad(t){lp.call(this,"timingevent",t)}function sd(t,e){if("function"!=vf(t))throw Error("Fn must not be null and must be a function");return ff.setTimeout(function(){t()},e)}Af(nd,lp),Af(id,lp),Af(ad,lp);var ud={NO_ERROR:0,hb:1,ob:2,nb:3,kb:4,mb:5,pb:6,Ma:7,TIMEOUT:8,sb:9},cd={jb:"complete",wb:"success",Na:"error",Ma:"abort",ub:"ready",vb:"readystatechange",TIMEOUT:"timeout",qb:"incrementaldata",tb:"progress",lb:"downloadprogress",xb:"uploadprogress"};function hd(){}function ld(t){var e;return(e=t.a)||(e=t.a={}),e}function fd(){}hd.prototype.a=null;var pd,dd={OPEN:"a",ib:"b",Na:"c",rb:"d"};function yd(){lp.call(this,"d")}function md(){lp.call(this,"c")}function vd(){}function gd(t,e,n){this.g=t,this.W=e,this.V=n||1,this.I=new Xp(this),this.O=bd,t=Jf?125:void 0,this.P=new Qp(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}Af(yd,lp),Af(md,lp),Af(vd,hd),pd=new vd;var bd=45e3,wd={},_d={};function Ed(t,e,n){t.F=1,t.f=Gd(Vd(e)),t.l=n,t.H=!0,Sd(t,null)}function Td(t,e,n,r){t.F=1,t.f=Gd(Vd(e)),t.l=null,t.H=n,Sd(t,r)}function Sd(t,e){t.v=Nf(),Nd(t),t.D=Vd(t.f),Hd(t.D,"t",t.V),t.A=0,t.a=t.g.$(t.g.Y()?e:null),0<t.J&&(t.B=new zp(If(t.Ka,t,t.a),t.J)),$p(t.I,t.a,"readystatechange",t.eb),e=t.h?jf(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)),rd(1)}function Id(t,e,n){for(var r=!0;!t.m&&t.A<n.length;){var i=Cd(t,n);if(i==_d){4==e&&(t.c=4,od(14),r=!1);break}if(i==wd){t.c=4,od(15),r=!1;break}Od(t,i)}4==e&&0==n.length&&(t.c=1,od(16),r=!1),t.b=t.b&&r,r||(Rd(t),Dd(t))}function Cd(t,e){var n=t.A,r=e.indexOf("\n",n);return-1==r?_d:(n=Number(e.substring(n,r)),isNaN(n)?wd:(r+=1)+n>e.length?_d:(e=e.substr(r,n),t.A=r+n,e))}function Nd(t){t.R=Nf()+t.O,Ad(t,t.O)}function Ad(t,e){if(null!=t.i)throw Error("WatchDog timer not null");t.i=sd(If(t.bb,t),e)}function kd(t){t.i&&(ff.clearTimeout(t.i),t.i=null)}function Dd(t){t.g.Da()||t.m||t.g.na(t)}function Rd(t){kd(t);var e=t.B;e&&"function"==typeof e.la&&e.la(),t.B=null,Hp(t.P),Zp(t.I),t.a&&(e=t.a,t.a=null,e.abort(),e.la())}function Od(t,e){try{t.g.Ga(t,e),rd(4)}catch(t){}}function Pd(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(bf(t)||pf(t))Rf(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(bf(t)||pf(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(pf(t))return t.split("");if(bf(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 Md(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 Md)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 xd(t,e){Fd(t.b,e)&&(delete t.b[e],t.c--,t.a.length>2*t.c&&Ld(t))}function Ld(t){if(t.c!=t.a.length){for(var e=0,n=0;e<t.a.length;){var r=t.a[e];Fd(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;)Fd(i,r=t.a[e])||(i[t.a[n++]=r]=1),e++;t.a.length=n}}function Fd(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(cf=gd.prototype).setTimeout=function(t){this.O=t},cf.eb=function(t){t=t.target;var e=this.B;e&&3==qy(t)?e.Ua():this.Ka(t)},cf.Ka=function(t){try{if(t==this.a)t:{var e=qy(this.a),n=this.a.ya(),r=this.a.T();if(!(e<3||3==e&&!Jf&&!this.a.aa())){this.m||4!=e||7==n||rd(8==n||r<=0?3:2),kd(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=Vy(this.a,"X-HTTP-Initial-Response");if(a&&!Mf(a)){var s=a;break e}}s=null}if(!s){this.b=!1,this.c=3,od(12),Rd(this),Dd(this);break t}this.s=!0,Od(this,s)}this.H?(Id(this,e,o),Jf&&this.b&&3==e&&($p(this.I,this.P,"tick",this.cb),this.P.start())):Od(this,o),4==e&&Rd(this),this.b&&!this.m&&(4==e?this.g.na(this):(this.b=!1,Nd(this)))}else 400==i&&0<o.indexOf("Unknown SID")?(this.c=3,od(12)):(this.c=0,od(13)),Rd(this),Dd(this)}}}catch(t){}},cf.cb=function(){if(this.a){var t=qy(this.a),e=this.a.aa();this.A<e.length&&(kd(this),Id(this,t,e),this.b&&4!=t&&Nd(this))}},cf.cancel=function(){this.m=!0,Rd(this)},cf.bb=function(){this.i=null;var t=Nf();0<=t-this.R?(2!=this.F&&(rd(3),od(17)),Rd(this),this.c=2,Dd(this)):Ad(this,this.R-t)},(cf=Md.prototype).C=function(){Ld(this);for(var t=[],e=0;e<this.a.length;e++)t.push(this.b[this.a[e]]);return t},cf.K=function(){return Ld(this),this.a.concat()},cf.get=function(t,e){return Fd(this.b,t)?this.b[t]:e},cf.set=function(t,e){Fd(this.b,t)||(this.c++,this.a.push(t)),this.b[t]=e},cf.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 Ud=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function qd(t,e){var n;this.b=this.j=this.f="",this.i=null,this.g=this.a="",this.h=!1,t instanceof qd?(this.h=void 0!==e?e:t.h,Bd(this,t.f),this.j=t.j,jd(this,t.b),Wd(this,t.i),this.a=t.a,Kd(this,sy(t.c)),this.g=t.g):t&&(n=String(t).match(Ud))?(this.h=!!e,Bd(this,n[1]||"",!0),this.j=zd(n[2]||""),jd(this,n[3]||"",!0),Wd(this,n[4]),this.a=zd(n[5]||"",!0),Kd(this,n[6]||"",!0),this.g=zd(n[7]||"")):(this.h=!!e,this.c=new ny(null,this.h))}function Vd(t){return new qd(t)}function Bd(t,e,n){t.f=n?zd(e,!0):e,t.f&&(t.f=t.f.replace(/:$/,""))}function jd(t,e,n){t.b=n?zd(e,!0):e}function Wd(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 Kd(t,e,n){e instanceof ny?(t.c=e,function(t,e){e&&!t.f&&(ry(t),t.c=null,t.a.forEach(function(t,e){var n=e.toLowerCase();e!=n&&(iy(this,e),ay(this,n,t))},t)),t.f=e}(t.c,t.h)):(n||(e=Yd(e,ty)),t.c=new ny(e,t.h))}function Qd(t,e,n){t.c.set(e,n)}function Hd(t,e,n){gf(n)||(n=[String(n)]),ay(t.c,e,n)}function Gd(t){return Qd(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Nf()).toString(36)),t}function zd(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Yd(t,e,n){return pf(t)?(t=encodeURI(t).replace(e,Xd),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Xd(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}qd.prototype.toString=function(){var t=[],e=this.f;e&&t.push(Yd(e,Jd,!0),":");var n=this.b;return!n&&"file"!=e||(t.push("//"),(e=this.j)&&t.push(Yd(e,Jd,!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(Yd(n,"/"==n.charAt(0)?Zd:$d,!0))),(n=this.c.toString())&&t.push("?",n),(n=this.g)&&t.push("#",Yd(n,ey)),t.join("")},qd.prototype.resolve=function(t){var e=Vd(this),n=!!t.f;n?Bd(e,t.f):n=!!t.j,n?e.j=t.j:n=!!t.b,n?jd(e,t.b):n=null!=t.i;var r=t.a;if(n)Wd(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(Ff(i,"./")||Ff(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?Kd(e,sy(t.c)):n=!!t.g,n&&(e.g=t.g),e};var Jd=/[#\/\?@]/g,$d=/[#\?:]/g,Zd=/[#\?]/g,ty=/[#\?@]/g,ey=/#/g;function ny(t,e){this.b=this.a=null,this.c=t||null,this.f=!!e}function ry(n){n.a||(n.a=new Md,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 iy(t,e){ry(t),e=uy(t,e),Fd(t.a.b,e)&&(t.c=null,t.b-=t.a.get(e).length,xd(t.a,e))}function oy(t,e){return ry(t),e=uy(t,e),Fd(t.a.b,e)}function ay(t,e,n){iy(t,e),0<n.length&&(t.c=null,t.a.set(uy(t,e),Pf(n)),t.b+=n.length)}function sy(t){var e=new ny;return e.c=t.c,t.a&&(e.a=new Md(t.a),e.b=t.b),e}function uy(t,e){return e=String(e),t.f&&(e=e.toLowerCase()),e}function cy(t){this.a=t,this.b=this.h=null,this.g=!1,this.i=null,this.c=-1,this.l=this.f=null}function hy(t){var e=t.a.F.a;if(null!=e)od(4),e?(od(10),$y(t.a,t,!1)):(od(11),$y(t.a,t,!0));else{t.b=new gd(t,void 0,void 0),t.b.h=t.h,e=rm(e=t.a,e.Y()?t.f:null,t.i),od(4),Hd(e,"TYPE","xmlhttp");var n=t.a.j,r=t.a.I;n&&r&&Qd(e,n,r),Td(t.b,e,!1,t.f)}}function ly(){this.a=this.b=null}function fy(){this.a=new Md}function py(t){var e=typeof t;return"object"==e&&t||"function"==e?"o"+(t[_f]||(t[_f]=++Ef)):e.charAt(0)+t}function dy(t,e){this.b=t,this.a=e}function yy(t){this.g=t||my,t=ff.PerformanceNavigationTiming?0<(t=ff.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):!!(ff.ka&&ff.ka.Ea&&ff.ka.Ea()&&ff.ka.Ea().zb),this.f=t?this.g:1,this.a=null,1<this.f&&(this.a=new fy),this.b=null,this.c=[]}(cf=ny.prototype).add=function(t,e){ry(this),this.c=null,t=uy(this,t);var n=this.a.get(t);return n||this.a.set(t,n=[]),n.push(e),this.b+=1,this},cf.forEach=function(n,r){ry(this),this.a.forEach(function(t,e){Rf(t,function(t){n.call(r,t,e,this)},this)},this)},cf.K=function(){ry(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},cf.C=function(t){ry(this);var e=[];if(pf(t))oy(this,t)&&(e=Of(e,this.a.get(uy(this,t))));else{t=this.a.C();for(var n=0;n<t.length;n++)e=Of(e,t[n])}return e},cf.set=function(t,e){return ry(this),this.c=null,oy(this,t=uy(this,t))&&(this.b-=this.a.get(t).length),this.a.set(t,[e]),this.b+=1,this},cf.get=function(t,e){return t&&0<(t=this.C(t)).length?String(t[0]):e},cf.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("&")},Af(function(){},function(){}),(cf=cy.prototype).M=null,cf.$=function(t){return this.a.$(t)},cf.abort=function(){this.b&&(this.b.cancel(),this.b=null),this.c=-1},cf.Da=function(){return!1},cf.Ga=function(t,e){if(this.c=t.o,0==this.M){if(!this.a.o&&(t=t.a)){var n=Vy(t,"X-Client-Wire-Protocol");this.l=n||null,this.a.j&&(t=Vy(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 em(e,2)}this.f=r[0]}else(e=this.a).m=this.c,em(e,2)}else 1==this.M&&(this.g?od(6):"11111"==e?(od(5),this.g=!0,(!Yf||10<=Number(ip))&&(this.c=200,this.b.cancel(),od(11),$y(this.a,this,!0))):(od(7),this.g=!1))},cf.na=function(){if(this.c=this.b.o,this.b.b)0==this.M?(this.M=1,hy(this)):1==this.M&&(this.g?(od(11),$y(this.a,this,!0)):(od(10),$y(this.a,this,!1)));else{0==this.M?od(8):1==this.M&&od(9);var t=this.a;t.m=this.c,em(t,2)}},cf.Y=function(){return this.a.Y()},cf.ma=function(){return this.a.ma()},fy.prototype.add=function(t){this.a.set(py(t),t)},fy.prototype.C=function(){return this.a.C()};var my=10;function vy(t,e){!t.a&&(Ff(e,"spdy")||Ff(e,"quic")||Ff(e,"h2"))&&(t.f=t.g,t.a=new fy,t.b&&(_y(t,t.b),t.b=null))}function gy(t){return!!t.b||!!t.a&&t.a.a.c>=t.f}function by(t){return t.b?1:t.a?t.a.a.c:0}function wy(t,e){return t=t.b?t.b==e:!!t.a&&(e=py(e),Fd(t.a.a.b,e))}function _y(t,e){t.a?t.a.add(e):t.b=e}function Ey(t,e){var n;t.b&&t.b==e?t.b=null:((n=t.a)&&(n=py(e),n=Fd(t.a.a.b,n)),n&&xd(t.a.a,py(e)))}function Ty(t){if(null!=t.b)return t.c.concat(t.b.j);if(null==t.a||0==t.a.a.c)return Pf(t.c);var e=t.c;return Rf(t.a.C(),function(t){e=e.concat(t.j)}),e}function Sy(){}function Iy(){this.a=new Sy}function Cy(t,r,e){var i=e||"";try{Pd(t,function(t,e){var n=t;wf(t)&&(n=Mp(t)),r.push(i+e+"="+encodeURIComponent(n))})}catch(t){throw r.push(i+"type="+encodeURIComponent("_badmap")),t}}function Ny(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}yy.prototype.cancel=function(){this.c=Ty(this),this.b?(this.b.cancel(),this.b=null):this.a&&0!=this.a.a.c&&(Rf(this.a.C(),function(t){t.cancel()}),function(t){t.b={},t.a.length=0,t.c=0}(this.a.a))},Sy.prototype.stringify=function(t){return ff.JSON.stringify(t,void 0)},Sy.prototype.parse=function(t){return ff.JSON.parse(t,void 0)};var Ay=ff.JSON.parse;function ky(t){Op.call(this),this.headers=new Md,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=Dy,this.D=this.F=!1}Af(ky,Op);var Dy="",Ry=/^https?$/i,Oy=["POST","PUT"];function Py(t){return"content-type"==t.toLowerCase()}function My(t,e){t.b=!1,t.a&&(t.g=!0,t.a.abort(),t.g=!1),t.f=e,t.h=5,xy(t),Fy(t)}function xy(t){t.v||(t.v=!0,t.dispatchEvent("complete"),t.dispatchEvent("error"))}function Ly(t){if(t.b&&void 0!==lf&&(!t.s[1]||4!=qy(t)||2!=t.T()))if(t.l&&4==qy(t))Gp(t.Fa,0,t);else if(t.dispatchEvent("readystatechange"),4==qy(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(Ud)[1]||null;if(!o&&ff.self&&ff.self.location){var a=ff.self.location.protocol;o=a.substr(0,a.length-1)}i=!Ry.test(o?o.toLowerCase():"")}e=i}e?(t.dispatchEvent("complete"),t.dispatchEvent("success")):(t.h=6,t.f=t.za()+" ["+t.T()+"]",xy(t))}finally{Fy(t)}}}function Fy(t,e){if(t.a){Uy(t);var n=t.a,r=t.s[0]?mf:null;t.a=null,t.s=null,e||t.dispatchEvent("ready");try{n.onreadystatechange=r}catch(t){}}}function Uy(t){t.a&&t.D&&(t.a.ontimeout=null),t.m&&(ff.clearTimeout(t.m),t.m=null)}function qy(t){return t.a?t.a.readyState:0}function Vy(t,e){return t.a?t.a.getResponseHeader(e):null}function By(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 Bf(t,function(t,e){n+=e,n+=":",n+=t,n+="\r\n"}),n}(n),pf(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 Qd(t,e,n),t}function jy(t){this.f=[],this.F=new ly,this.ga=this.pa=this.B=this.ha=this.a=this.I=this.j=this.V=this.g=this.J=this.i=null,this.Ra=this.P=0,this.Pa=!!yf("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.Oa=yf("internalChannelParams.baseRetryDelayMs",t)||5e3,this.Sa=yf("internalChannelParams.retryDelaySeedMs",t)||1e4,this.Qa=yf("internalChannelParams.forwardChannelMaxRetries",t)||2,this.qa=yf("internalChannelParams.forwardChannelRequestTimeoutMs",t)||2e4,this.La=t&&t.Ab||void 0,this.D=void 0,this.R=t&&t.supportsCrossDomainXhr||!1,this.H="",this.b=new yy(t&&t.concurrentRequestLimit),this.ja=new Iy,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 Wy(t){if(Ky(t),3==t.u){var e=t.P++,n=Vd(t.B);Qd(n,"SID",t.H),Qd(n,"RID",e),Qd(n,"TYPE","terminate"),zy(t,n),(e=new gd(t,e,void 0)).F=2,e.f=Gd(Vd(n)),n=!1,ff.navigator&&ff.navigator.sendBeacon&&(n=ff.navigator.sendBeacon(e.f.toString(),"")),!n&&ff.Image&&((new Image).src=e.f,n=!0),n||(e.a=e.g.$(null),e.a.ca(e.f)),e.v=Nf(),Nd(e)}nm(t)}function Ky(t){t.w&&(t.w.abort(),t.w=null),t.a&&(t.a.cancel(),t.a=null),t.l&&(ff.clearTimeout(t.l),t.l=null),Zy(t),t.b.cancel(),t.h&&(df(t.h)&&ff.clearTimeout(t.h),t.h=null)}function Qy(t,e){t.f.push(new dy(t.Ra++,e)),3==t.u&&Hy(t)}function Hy(t){gy(t.b)||t.h||(t.h=!0,Bp(t.Ia,t),t.A=0)}function Gy(t,e){var n;n=e?e.W:t.P++;var r=Vd(t.B);Qd(r,"SID",t.H),Qd(r,"RID",n),Qd(r,"AID",t.O),zy(t,r),t.g&&t.i&&By(r,t.g,t.i),n=new gd(t,n,t.A+1),null===t.g&&(n.h=t.i),e&&(t.f=e.j.concat(t.f)),e=Yy(t,n,1e3),n.setTimeout(Math.round(.5*t.qa)+Math.round(.5*t.qa*Math.random())),_y(t.b,n),Ed(n,r,e)}function zy(t,n){t.c&&Pd({},function(t,e){Qd(n,e,t)})}function Yy(t,e,n){n=Math.min(t.f.length,n);var r=t.c?If(t.c.Ta,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{Cy(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 Xy(t){t.a||t.l||(t.S=1,Bp(t.Ha,t),t.v=0)}function Jy(t){return!(t.a||t.l||3<=t.v)&&(t.S++,t.l=sd(If(t.Ha,t),tm(t,t.v)),t.v++,!0)}function $y(t,e,n){var r=e.l;r&&vy(t.b,r),t.ia=t.oa&&n,t.m=e.c,t.B=rm(t,null,t.ha),Hy(t)}function Zy(t){null!=t.s&&(ff.clearTimeout(t.s),t.s=null)}function tm(t,e){var n=t.Oa+Math.floor(Math.random()*t.Sa);return t.ma()||(n*=2),n*e}function em(t,e){if(2==e){var n=null;t.c&&(n=null);var r=If(t.fb,t);n||(n=new qd("//www.google.com/images/cleardot.gif"),ff.location&&"http"==ff.location.protocol||Bd(n,"https"),Gd(n)),function(t,e){var n=new td;if(ff.Image){var r=new Image;r.onload=Cf(Ny,n,r,"TestLoadImage: loaded",!0,e),r.onerror=Cf(Ny,n,r,"TestLoadImage: error",!1,e),r.onabort=Cf(Ny,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=Cf(Ny,n,r,"TestLoadImage: timeout",!1,e),ff.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),nm(t),Ky(t)}function nm(t){t.u=0,t.m=-1,t.c&&(0==Ty(t.b).length&&0==t.f.length||(t.b.c.length=0,Pf(t.f),t.f.length=0),t.c.sa())}function rm(t,e,n){var r=function(t){return t instanceof qd?Vd(t):new qd(t,void 0)}(n);if(""!=r.b)e&&jd(r,e+"."+r.b),Wd(r,r.i);else{var i,o=ff.location;i=e?e+"."+o.hostname:o.hostname,r=function(t,e,n,r){var i=new qd(null,void 0);return t&&Bd(i,t),e&&jd(i,e),n&&Wd(i,n),r&&(i.a=r),i}(o.protocol,i,+o.port,n)}return t.V&&Bf(t.V,function(t,e){Qd(r,e,t)}),e=t.j,n=t.I,e&&n&&Qd(r,e,n),Qd(r,"VER",t.wa),zy(t,r),r}function im(){}function om(){if(Yf&&!(10<=Number(ip)))throw Error("Environmental error: no available transport.")}function am(t,e){Op.call(this),this.a=new jy(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)&&!Mf(t)&&(this.a.g=t),this.l=e&&e.supportsCrossDomainXhr||!1,this.h=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!Mf(e)&&(this.a.j=e,null!==(t=this.b)&&e in t&&(e in(t=this.b)&&delete t[e])),this.f=new cm(this)}function sm(t){yd.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 um(){md.call(this),this.status=1}function cm(t){this.a=t}(cf=ky.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?ld(this.H):ld(pd),this.a.onreadystatechange=If(this.Fa,this);try{this.w=!0,this.a.open(e,String(t),!0),this.w=!1}catch(t){return void My(this,t)}t=n||"";var i=new Md(this.headers);r&&Pd(r,function(t,e){i.set(e,t)}),r=function(t){t:{for(var e=Py,n=t.length,r=pf(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:pf(t)?t.charAt(e):t[e]}(i.K()),n=ff.FormData&&t instanceof ff.FormData,0<=Df(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{Uy(this),0<this.o&&((this.D=function(t){return Yf&&ap(9)&&df(t.timeout)&&void 0!==t.ontimeout}(this.a))?(this.a.timeout=this.o,this.a.ontimeout=If(this.Ca,this)):this.m=Gp(this.Ca,this.o,this)),this.l=!0,this.a.send(t),this.l=!1}catch(t){My(this,t)}},cf.Ca=function(){void 0!==lf&&this.a&&(this.f="Timed out after "+this.o+"ms, aborting",this.h=8,this.dispatchEvent("timeout"),this.abort(8))},cf.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"),Fy(this))},cf.G=function(){this.a&&(this.b&&(this.b=!1,this.g=!0,this.a.abort(),this.g=!1),Fy(this,!0)),ky.N.G.call(this)},cf.Fa=function(){this.j||(this.w||this.l||this.g?Ly(this):this.$a())},cf.$a=function(){Ly(this)},cf.T=function(){try{return 2<qy(this)?this.a.status:-1}catch(t){return-1}},cf.za=function(){try{return 2<qy(this)?this.a.statusText:""}catch(t){return""}},cf.aa=function(){try{return this.a?this.a.responseText:""}catch(t){return""}},cf.Va=function(t){if(this.a){var e=this.a.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Ay(e)}},cf.ya=function(){return this.h},cf.Ya=function(){return pf(this.f)?this.f:String(this.f)},(cf=jy.prototype).wa=8,cf.u=1,cf.Da=function(){return 0==this.u},cf.Ia=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 gd(this,t,void 0),r=this.i;if(this.J&&(r?Kf(r=jf(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&&pf(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=Yy(this,n,e),Qd(i=Vd(this.B),"RID",t),Qd(i,"CVER",22),this.o&&this.j&&Qd(i,"X-HTTP-Session-Id",this.j),zy(this,i),this.g&&r&&By(i,this.g,r),_y(this.b,n),this.W?(Qd(i,"$req",e),Qd(i,"SID","null"),n.S=!0,Ed(n,i,null)):Ed(n,i,e),this.u=2}}else 3==this.u&&(t?Gy(this,t):0==this.f.length||gy(this.b)||Gy(this))},cf.Ha=function(){this.l=null,this.a=new gd(this,"rpc",this.S),null===this.g&&(this.a.h=this.i),this.a.J=0;var t=Vd(this.pa);Qd(t,"RID","rpc"),Qd(t,"SID",this.H),Qd(t,"CI",this.ia?"0":"1"),Qd(t,"AID",this.O),zy(this,t),Qd(t,"TYPE","xmlhttp"),this.g&&this.i&&By(t,this.g,this.i),this.D&&this.a.setTimeout(this.D),Td(this.a,t,!0,this.ga)},cf.Ga=function(t,e){if(0!=this.u&&(this.a==t||wy(this.b,t)))if(this.m=t.o,!t.s&&wy(this.b,t)&&3==this.u){try{var n=this.ja.a.parse(e)}catch(t){n=null}if(gf(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;Zy(this),this.a.cancel(),this.a=null}Jy(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=sd(If(this.Za,this),6e3));if(by(this.b)<=1&&this.fa){try{this.fa()}catch(t){}this.fa=void 0}}else em(this,11)}else if(!t.s&&this.a!=t||Zy(this),!Mf(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])&&df(r)&&0<r&&(this.D=1.5*r),this.o&&(r=t.a)&&((i=Vy(r,"X-Client-Wire-Protocol"))&&vy(this.b,i),this.j&&(r=Vy(r,"X-HTTP-Session-Id")))&&(this.I=r,Qd(this.B,this.j,r)),this.u=3,this.c&&this.c.va(),r=t,this.pa=rm(this,this.Y()?this.ga:null,this.ha),r.s?(Ey(this.b,r),(i=this.D)&&r.setTimeout(i),r.i&&(kd(r),Nd(r)),this.a=r):Xy(this),0<this.f.length&&Hy(this)}else"stop"!=r[0]&&"close"!=r[0]||em(this,7);else 3==this.u&&("stop"==r[0]||"close"==r[0]?"stop"==r[0]?em(this,7):Wy(this):"noop"!=r[0]&&this.c&&this.c.ua(r),this.v=0)}},cf.Za=function(){null!=this.s&&(this.s=null,this.a.cancel(),this.a=null,Jy(this),od(19))},cf.na=function(t){var e=null;if(this.a==t){Zy(this),this.a=null;var n=2}else{if(!wy(this.b,t))return;e=t.j,Ey(this.b,t),n=1}if(this.m=t.o,0!=this.u)if(t.b)1==n?(e=Nf()-t.v,ed.dispatchEvent(new ad(ed,t.l?t.l.length:0,e,this.A)),Hy(this)):Xy(this);else{var r=t.c;if(3==r||0==r&&0<this.m||!(1==n&&function(t,e){return!(by(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.Pa?0:t.Qa))&&(t.h=sd(If(t.Ia,t,e),tm(t,t.A)),t.A++,!0))}(this,t)||2==n&&Jy(this)))switch(e&&0<e.length&&(t=this.b,t.c=t.c.concat(e)),r){case 1:em(this,5);break;case 4:em(this,10);break;case 3:em(this,6);break;default:em(this,2)}}},cf.fb=function(t){od(t?2:1)},cf.$=function(t){if(t&&!this.R)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new ky(this.La)).F=this.R,t},cf.ma=function(){return!!this.c&&!0},cf.Y=function(){return this.R},(cf=im.prototype).va=function(){},cf.ua=function(){},cf.ta=function(){},cf.sa=function(){},cf.Ta=function(){},om.prototype.a=function(t,e){return new am(t,e)},Af(am,Op),(cf=am.prototype).addEventListener=function(t,e,n,r){am.N.addEventListener.call(this,t,e,n,r)},cf.removeEventListener=function(t,e,n,r){am.N.removeEventListener.call(this,t,e,n,r)},cf.Wa=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 cy(t),null===t.g&&(t.w.h=t.i),n=e,t.g&&t.i&&(n=By(e,t.g,t.i)),(t=t.w).i=n,e=rm(t.a,null,t.i),od(3),null!=(n=t.a.F.b)?(t.f=n[0],t.M=1,hy(t)):(Hd(e,"MODE","init"),!t.a.o&&t.a.j&&Hd(e,"X-HTTP-Session-Id",t.a.j),t.b=new gd(t,void 0,void 0),t.b.h=t.h,Td(t.b,e,!1,null),t.M=0)},cf.close=function(){Wy(this.a)},cf.Xa=function(t){if(pf(t)){var e={};e.__data__=t,Qy(this.a,e)}else this.h?((e={}).__data__=Mp(t),Qy(this.a,e)):Qy(this.a,t)},cf.G=function(){this.a.c=null,delete this.f,Wy(this.a),delete this.a,am.N.G.call(this)},Af(sm,yd),Af(um,md),Af(cm,im),cm.prototype.va=function(){this.a.dispatchEvent("a")},cm.prototype.ua=function(t){this.a.dispatchEvent(new sm(t))},cm.prototype.ta=function(t){this.a.dispatchEvent(new um(t))},cm.prototype.sa=function(){this.a.dispatchEvent("b")};var hm=Cf(function(t,e){function n(){}n.prototype=t.prototype;var r=new n;return t.apply(r,Array.prototype.slice.call(arguments,1)),r},om);om.prototype.createWebChannel=om.prototype.a,am.prototype.send=am.prototype.Xa,am.prototype.open=am.prototype.Wa,am.prototype.close=am.prototype.close,ud.NO_ERROR=0,ud.TIMEOUT=8,ud.HTTP_ERROR=6,cd.COMPLETE="complete",(fd.EventType=dd).OPEN="a",dd.CLOSE="b",dd.ERROR="c",dd.MESSAGE="d",Op.prototype.listen=Op.prototype.Aa,ky.prototype.listenOnce=ky.prototype.Ba,ky.prototype.getLastError=ky.prototype.Ya,ky.prototype.getLastErrorCode=ky.prototype.ya,ky.prototype.getStatus=ky.prototype.T,ky.prototype.getStatusText=ky.prototype.za,ky.prototype.getResponseJson=ky.prototype.Va,ky.prototype.getResponseText=ky.prototype.aa,ky.prototype.send=ky.prototype.ca;var lm,fm,pm={createWebChannelTransport:hm,ErrorCode:ud,EventType:cd,WebChannel:fd,XhrIo:ky},dm=pm.createWebChannelTransport,ym=pm.ErrorCode,mm=pm.EventType,vm=pm.WebChannel,gm=pm.XhrIo,bm=fl.SDK_VERSION,wm=new Ja("@firebase/firestore");function _m(){return wm.logLevel===Qa.DEBUG?lm.DEBUG:wm.logLevel===Qa.SILENT?lm.SILENT:lm.ERROR}function Em(t){switch(t){case lm.DEBUG:wm.logLevel=Qa.DEBUG;break;case lm.ERROR:wm.logLevel=Qa.ERROR;break;case lm.SILENT:wm.logLevel=Qa.SILENT;break;default:wm.error("Firestore ("+bm+"): Invalid value passed to `setLogLevel`")}}function Tm(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];if(wm.logLevel<=Qa.DEBUG){var i=n.map(Im);wm.debug.apply(wm,aa(["Firestore ("+bm+") ["+t+"]: "+e],i))}}function Sm(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(wm.logLevel<=Qa.ERROR){var r=e.map(Im);wm.error.apply(wm,aa(["Firestore ("+bm+"): "+t],r))}}function Im(e){if("string"==typeof e)return e;var t=Am.getPlatform();try{return t.formatJSON(e)}catch(t){return e}}function Cm(t){var e="FIRESTORE ("+bm+") INTERNAL ASSERTION FAILED: "+t;throw Sm(e),new Error(e)}function Nm(t,e){t||Cm(e)}(fm=lm=lm||{})[fm.DEBUG=0]="DEBUG",fm[fm.ERROR=1]="ERROR",fm[fm.SILENT=2]="SILENT";var Am=(km.setPlatform=function(t){km.platform&&Cm("Platform already defined"),km.platform=t},km.getPlatform=function(){return km.platform||Cm("Platform not set"),km.platform},km);function km(){}function Dm(){return Am.getPlatform().emptyByteString}var Rm,Om={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"},Pm=(Zo(Mm,Rm=Error),Mm);function Mm(t,e){var n=Rm.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 xm(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new Pm(Om.INVALID_ARGUMENT,t)}for(var r in n.prototype=t.prototype,t)t.hasOwnProperty(r)&&(n[r]=t[r]);return n}function Lm(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Fm(t,e){return void 0!==t?t:e}function Um(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 qm(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function Vm(t){for(var e in Nm(null!=t&&"object"==typeof t,"isEmpty() expects object parameter."),t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Bm(t,e){if(0!==e.length)throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+iv(e.length,"argument")+".")}function jm(t,e,n){if(e.length!==n)throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires "+iv(n,"argument")+", but was called with "+iv(e.length,"argument")+".")}function Wm(t,e,n){if(e.length<n)throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires at least "+iv(n,"argument")+", but was called with "+iv(e.length,"argument")+".")}function Km(t,e,n,r){if(e.length<n||e.length>r)throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+iv(e.length,"argument")+".")}function Qm(t,e,n,r){Jm(t,e,rv(n)+" argument",r)}function Hm(t,e,n,r){void 0!==r&&Qm(t,e,n,r)}function Gm(t,e,n,r){Jm(t,e,n+" option",r)}function zm(t,e,n,r){void 0!==r&&Gm(t,e,n,r)}function Ym(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+Zm(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be "+n+", but the value at index "+o+" was: "+Zm(r[o]))}(t,e,n,r,i)}function Xm(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(Zm(u))}var c=Zm(r);throw new Pm(Om.INVALID_ARGUMENT,"Invalid value "+c+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+o.join(", "))}(t,0,n,r,i)}function Jm(t,e,n,r){if(!("object"===e?$m(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=Zm(r);throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function $m(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function Zm(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":Cm("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 tv(t,e,n){if(void 0===n)throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+rv(e)+" argument, but it was undefined.")}function ev(n,t,r){qm(t,function(t,e){if(r.indexOf(t)<0)throw new Pm(Om.INVALID_ARGUMENT,"Unknown option '"+t+"' passed to function "+n+"(). Available options: "+r.join(", "))})}function nv(t,e,n,r){var i=Zm(r);return new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires its "+rv(n)+" argument to be a "+e+", but it was: "+i)}function rv(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function iv(t,e){return t+" "+e+(1===t?"":"s")}var ov=(av.newId=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",n=0;n<20;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return Nm(20===e.length,"Invalid auto ID: "+e),e},av);function av(){}function sv(t,e){return t<e?-1:e<t?1:0}function uv(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 cv(t){return t+"\0"}function hv(){if("undefined"==typeof Uint8Array)throw new Pm(Om.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function lv(){if(!Am.getPlatform().base64Available)throw new Pm(Om.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var fv=(pv.fromBase64String=function(t){jm("Blob.fromBase64String",arguments,1),Qm("Blob.fromBase64String","string",1,t),lv();try{return new pv(Am.getPlatform().atob(t))}catch(t){throw new Pm(Om.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},pv.fromUint8Array=function(t){if(jm("Blob.fromUint8Array",arguments,1),hv(),!(t instanceof Uint8Array))throw nv("Blob.fromUint8Array","Uint8Array",1,t);return new pv(Array.prototype.map.call(t,function(t){return String.fromCharCode(t)}).join(""))},pv.prototype.toBase64=function(){return jm("Blob.toBase64",arguments,0),lv(),Am.getPlatform().btoa(this._binaryString)},pv.prototype.toUint8Array=function(){jm("Blob.toUint8Array",arguments,0),hv();for(var t=new Uint8Array(this._binaryString.length),e=0;e<this._binaryString.length;e++)t[e]=this._binaryString.charCodeAt(e);return t},pv.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},pv.prototype.isEqual=function(t){return this._binaryString===t._binaryString},pv.prototype._compareTo=function(t){return sv(this._binaryString,t._binaryString)},pv);function pv(t){lv(),this._binaryString=t}var dv=xm(fv,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),yv=function(t,e,n,r,i){this.databaseId=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i},mv="(default)",vv=(Object.defineProperty(gv.prototype,"isDefaultDatabase",{get:function(){return this.database===mv},enumerable:!0,configurable:!0}),gv.prototype.isEqual=function(t){return t instanceof gv&&t.projectId===this.projectId&&t.database===this.database},gv.prototype.compareTo=function(t){return sv(this.projectId,t.projectId)||sv(this.database,t.database)},gv);function gv(t,e){this.projectId=t,this.database=e||mv}var bv=(wv.prototype.setPreviousValue=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},wv.prototype.next=function(){var t=++this.previousValue;return this.writeNewSequenceNumber&&this.writeNewSequenceNumber(t),t},wv.INVALID=-1,wv);function wv(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 _v="__name__",Ev=(Object.defineProperty(Tv.prototype,"length",{get:function(){return this.len},enumerable:!0,configurable:!0}),Tv.prototype.isEqual=function(t){return 0===Tv.comparator(this,t)},Tv.prototype.child=function(t){var e=this.segments.slice(this.offset,this.limit());return t instanceof Tv?t.forEach(function(t){e.push(t)}):e.push(t),this.construct(e)},Tv.prototype.limit=function(){return this.offset+this.length},Tv.prototype.popFirst=function(t){return t=void 0===t?1:t,Nm(this.length>=t,"Can't call popFirst() with less segments"),this.construct(this.segments,this.offset+t,this.length-t)},Tv.prototype.popLast=function(){return Nm(!this.isEmpty(),"Can't call popLast() on empty path"),this.construct(this.segments,this.offset,this.length-1)},Tv.prototype.firstSegment=function(){return Nm(!this.isEmpty(),"Can't call firstSegment() on empty path"),this.segments[this.offset]},Tv.prototype.lastSegment=function(){return this.get(this.length-1)},Tv.prototype.get=function(t){return Nm(t<this.length,"Index out of range"),this.segments[this.offset+t]},Tv.prototype.isEmpty=function(){return 0===this.length},Tv.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},Tv.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},Tv.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},Tv.prototype.toArray=function(){return this.segments.slice(this.offset,this.limit())},Tv.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},Tv);function Tv(t,e,n){void 0===e?e=0:e>t.length&&Cm("offset "+e+" out of range "+t.length),void 0===n?n=t.length-e:n>t.length-e&&Cm("length "+n+" out of range "+(t.length-e)),this.segments=t,this.offset=e,this.len=n}var Sv,Iv=(Zo(Cv,Sv=Ev),Cv.prototype.construct=function(t,e,n){return new Cv(t,e,n)},Cv.prototype.canonicalString=function(){return this.toArray().join("/")},Cv.prototype.toString=function(){return this.canonicalString()},Cv.fromString=function(t){if(0<=t.indexOf("//"))throw new Pm(Om.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new Cv(t.split("/").filter(function(t){return 0<t.length}))},Cv.EMPTY_PATH=new Cv([]),Cv);function Cv(){return null!==Sv&&Sv.apply(this,arguments)||this}var Nv,Av=/^[_a-zA-Z][_a-zA-Z0-9]*$/,kv=(Zo(Dv,Nv=Ev),Dv.prototype.construct=function(t,e,n){return new Dv(t,e,n)},Dv.isValidIdentifier=function(t){return Av.test(t)},Dv.prototype.canonicalString=function(){return this.toArray().map(function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),Dv.isValidIdentifier(t)||(t="`"+t+"`"),t}).join(".")},Dv.prototype.toString=function(){return this.canonicalString()},Dv.prototype.isKeyField=function(){return 1===this.length&&this.get(0)===_v},Dv.keyField=function(){return new Dv([_v])},Dv.fromServerFormat=function(t){for(var e=[],n="",r=0,i=function(){if(0===n.length)throw new Pm(Om.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 Pm(Om.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var s=t[r+1];if("\\"!==s&&"."!==s&&"`"!==s)throw new Pm(Om.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 Pm(Om.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new Dv(e)},Dv.EMPTY_PATH=new Dv([]),Dv);function Dv(){return null!==Nv&&Nv.apply(this,arguments)||this}var Rv=(Ov.prototype.hasCollectionId=function(t){return 2<=this.path.length&&this.path.get(this.path.length-2)===t},Ov.prototype.isEqual=function(t){return null!==t&&0===Iv.comparator(this.path,t.path)},Ov.prototype.toString=function(){return this.path.toString()},Ov.comparator=function(t,e){return Iv.comparator(t.path,e.path)},Ov.isDocumentKey=function(t){return t.length%2==0},Ov.fromSegments=function(t){return new Ov(new Iv(t.slice()))},Ov.fromPathString=function(t){return new Ov(Iv.fromString(t))},Ov.EMPTY=new Ov(new Iv([])),Ov);function Ov(t){this.path=t,Nm(Ov.isDocumentKey(t),"Invalid DocumentKey with an odd number of segments: "+t.toArray().join("/"))}var Pv,Mv,xv=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})};(Mv=Pv=Pv||{}).All="all",Mv.ListenStreamIdle="listen_stream_idle",Mv.ListenStreamConnectionBackoff="listen_stream_connection_backoff",Mv.WriteStreamIdle="write_stream_idle",Mv.WriteStreamConnectionBackoff="write_stream_connection_backoff",Mv.OnlineStateTimeout="online_state_timeout",Mv.ClientMetadataRefresh="client_metadata_refresh",Mv.LruGarbageCollection="lru_garbage_collection",Mv.RetryTransaction="retry_transaction";var Lv=(Fv.createAndSchedule=function(t,e,n,r,i){var o=new Fv(t,e,Date.now()+n,r,i);return o.start(n),o},Fv.prototype.start=function(t){var e=this;this.timerHandle=setTimeout(function(){return e.handleDelayElapsed()},t)},Fv.prototype.skipDelay=function(){return this.handleDelayElapsed()},Fv.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Pm(Om.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},Fv.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()})},Fv.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},Fv);function Fv(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new xv,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 Uv=(Object.defineProperty(qv.prototype,"isShuttingDown",{get:function(){return this._isShuttingDown},enumerable:!0,configurable:!0}),qv.prototype.enqueueAndForget=function(t){this.enqueue(t)},qv.prototype.enqueueAndForgetEvenAfterShutdown=function(t){this.verifyNotFailed(),this.enqueueInternal(t)},qv.prototype.enqueueEvenAfterShutdown=function(t){return this.verifyNotFailed(),this.enqueueInternal(t)},qv.prototype.enqueueAndInitiateShutdown=function(e){return ea(this,void 0,void 0,function(){return na(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]}})})},qv.prototype.enqueue=function(t){return this.verifyNotFailed(),this._isShuttingDown?new Promise(function(t){}):this.enqueueInternal(t)},qv.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 Sm("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},qv.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.verifyNotFailed(),Nm(0<=e,"Attempted to schedule an operation with a negative delay of "+e),-1<this.timerIdsToSkip.indexOf(t)&&(e=0);var i=Lv.createAndSchedule(this,t,e,n,function(t){return r.removeDelayedOperation(t)});return this.delayedOperations.push(i),i},qv.prototype.verifyNotFailed=function(){this.failure&&Cm("AsyncQueue is already failed: "+(this.failure.stack||this.failure.message))},qv.prototype.verifyOperationInProgress=function(){Nm(this.operationInProgress,"verifyOpInProgress() called when no op in progress on this queue.")},qv.prototype.drain=function(){return this.enqueueEvenAfterShutdown(function(){return Promise.resolve()})},qv.prototype.containsDelayedOperation=function(t){for(var e=0,n=this.delayedOperations;e<n.length;e++)if(n[e].timerId===t)return!0;return!1},qv.prototype.runDelayedOperationsEarly=function(r){var i=this;return this.drain().then(function(){Nm(r===Pv.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!==Pv.All&&n.timerId===r)break}return i.drain()})},qv.prototype.skipDelaysForTimerId=function(t){this.timerIdsToSkip.push(t)},qv.prototype.removeDelayedOperation=function(t){var e=this.delayedOperations.indexOf(t);Nm(0<=e,"Delayed operation not found."),this.delayedOperations.splice(e,1)},qv);function qv(){this.tail=Promise.resolve(),this._isShuttingDown=!1,this.delayedOperations=[],this.failure=null,this.operationInProgress=!1,this.timerIdsToSkip=[]}var Vv="",Bv="",jv="",Wv="";function Kv(t){for(var e="",n=0;n<t.length;n++)0<e.length&&(e=Hv(e)),e=Qv(t.get(n),e);return Hv(e)}function Qv(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+=Vv+jv;break;case Vv:n+=Vv+Wv;break;default:n+=o}}return n}function Hv(t){return t+Vv+Bv}function Gv(t){var e=t.length;if(Nm(2<=e,"Invalid path "+t),2===e)return Nm(t.charAt(0)===Vv&&t.charAt(1)===Bv,"Non-empty path "+t+" had length 2"),Iv.EMPTY_PATH;for(var n=e-2,r=[],i="",o=0;o<e;){var a=t.indexOf(Vv,o);switch((a<0||n<a)&&Cm('Invalid encoded resource path: "'+t+'"'),t.charAt(a+1)){case Bv:var s=t.substring(o,a),u=void 0;0===i.length?u=s:(u=i+=s,i=""),r.push(u);break;case jv:i+=t.substring(o,a),i+="\0";break;case Wv:i+=t.substring(o,a+1);break;default:Cm('Invalid encoded resource path: "'+t+'"')}o=a+2}return new Iv(r)}var zv=(Yv.now=function(){return Yv.fromMillis(Date.now())},Yv.fromDate=function(t){return Yv.fromMillis(t.getTime())},Yv.fromMillis=function(t){var e=Math.floor(t/1e3);return new Yv(e,1e6*(t-1e3*e))},Yv.prototype.toDate=function(){return new Date(this.toMillis())},Yv.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},Yv.prototype._compareTo=function(t){return this.seconds===t.seconds?sv(this.nanoseconds,t.nanoseconds):sv(this.seconds,t.seconds)},Yv.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},Yv.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},Yv);function Yv(t,e){if(this.seconds=t,(this.nanoseconds=e)<0)throw new Pm(Om.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(1e9<=e)throw new Pm(Om.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new Pm(Om.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(253402300800<=t)throw new Pm(Om.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}var Xv=(Jv.fromMicroseconds=function(t){var e=Math.floor(t/1e6);return new Jv(new zv(e,t%1e6*1e3))},Jv.fromTimestamp=function(t){return new Jv(t)},Jv.forDeletedDoc=function(){return Jv.MIN},Jv.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},Jv.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},Jv.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},Jv.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},Jv.prototype.toTimestamp=function(){return this.timestamp},Jv.MIN=new Jv(new zv(0,0)),Jv);function Jv(t){this.timestamp=t}var $v=(Zv.prototype.insert=function(t,e){return new Zv(this.comparator,this.root.insert(t,e,this.comparator).copy(null,null,ng.BLACK,null,null))},Zv.prototype.remove=function(t){return new Zv(this.comparator,this.root.remove(t,this.comparator).copy(null,null,ng.BLACK,null,null))},Zv.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},Zv.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},Zv.prototype.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(Zv.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),Zv.prototype.minKey=function(){return this.root.minKey()},Zv.prototype.maxKey=function(){return this.root.maxKey()},Zv.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},Zv.prototype.forEach=function(n){this.inorderTraversal(function(t,e){return n(t,e),!1})},Zv.prototype.toString=function(){var n=[];return this.inorderTraversal(function(t,e){return n.push(t+":"+e),!1}),"{"+n.join(", ")+"}"},Zv.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},Zv.prototype.getIterator=function(){return new tg(this.root,null,this.comparator,!1)},Zv.prototype.getIteratorFrom=function(t){return new tg(this.root,t,this.comparator,!1)},Zv.prototype.getReverseIterator=function(){return new tg(this.root,null,this.comparator,!0)},Zv.prototype.getReverseIteratorFrom=function(t){return new tg(this.root,t,this.comparator,!0)},Zv);function Zv(t,e){this.comparator=t,this.root=e||ng.EMPTY}var tg=(eg.prototype.getNext=function(){Nm(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},eg.prototype.hasNext=function(){return 0<this.nodeStack.length},eg.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}},eg);function eg(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 ng=(rg.prototype.copy=function(t,e,n,r,i){return new rg(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)},rg.prototype.isEmpty=function(){return!1},rg.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},rg.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},rg.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},rg.prototype.minKey=function(){return this.min().key},rg.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},rg.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()},rg.prototype.removeMin=function(){if(this.left.isEmpty())return rg.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()},rg.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 rg.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()},rg.prototype.isRed=function(){return this.color},rg.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},rg.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},rg.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},rg.prototype.rotateLeft=function(){var t=this.copy(null,null,rg.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)},rg.prototype.rotateRight=function(){var t=this.copy(null,null,rg.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)},rg.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)},rg.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},rg.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw Cm("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed())throw Cm("Right child of ("+this.key+","+this.value+") is red");var t=this.left.check();if(t!==this.right.check())throw Cm("Black depths differ");return t+(this.isRed()?0:1)},rg.EMPTY=null,rg.RED=!0,rg.BLACK=!1,rg);function rg(t,e,n,r,i){this.key=t,this.value=e,this.color=null!=n?n:rg.RED,this.left=null!=r?r:rg.EMPTY,this.right=null!=i?i:rg.EMPTY,this.size=this.left.size+1+this.right.size}var ig=(Object.defineProperty(og.prototype,"key",{get:function(){throw Cm("LLRBEmptyNode has no key.")},enumerable:!0,configurable:!0}),Object.defineProperty(og.prototype,"value",{get:function(){throw Cm("LLRBEmptyNode has no value.")},enumerable:!0,configurable:!0}),Object.defineProperty(og.prototype,"color",{get:function(){throw Cm("LLRBEmptyNode has no color.")},enumerable:!0,configurable:!0}),Object.defineProperty(og.prototype,"left",{get:function(){throw Cm("LLRBEmptyNode has no left child.")},enumerable:!0,configurable:!0}),Object.defineProperty(og.prototype,"right",{get:function(){throw Cm("LLRBEmptyNode has no right child.")},enumerable:!0,configurable:!0}),og.prototype.copy=function(t,e,n,r,i){return this},og.prototype.insert=function(t,e,n){return new ng(t,e)},og.prototype.remove=function(t,e){return this},og.prototype.isEmpty=function(){return!0},og.prototype.inorderTraversal=function(t){return!1},og.prototype.reverseTraversal=function(t){return!1},og.prototype.minKey=function(){return null},og.prototype.maxKey=function(){return null},og.prototype.isRed=function(){return!1},og.prototype.checkMaxDepth=function(){return!0},og.prototype.check=function(){return 0},og);function og(){this.size=0}ng.EMPTY=new ig;var ag=(sg.fromMapKeys=function(t){var e=new sg(t.comparator);return t.forEach(function(t){e=e.add(t)}),e},sg.prototype.has=function(t){return null!==this.data.get(t)},sg.prototype.first=function(){return this.data.minKey()},sg.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(sg.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),sg.prototype.indexOf=function(t){return this.data.indexOf(t)},sg.prototype.forEach=function(n){this.data.inorderTraversal(function(t,e){return n(t),!1})},sg.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)}},sg.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},sg.prototype.firstAfterOrEqual=function(t){var e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null},sg.prototype.getIterator=function(){return new ug(this.data.getIterator())},sg.prototype.getIteratorFrom=function(t){return new ug(this.data.getIteratorFrom(t))},sg.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},sg.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},sg.prototype.isEmpty=function(){return this.data.isEmpty()},sg.prototype.unionWith=function(t){var e=this;return t.forEach(function(t){e=e.add(t)}),e},sg.prototype.isEqual=function(t){if(!(t instanceof sg))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},sg.prototype.toArray=function(){var e=[];return this.forEach(function(t){e.push(t)}),e},sg.prototype.toString=function(){var e=[];return this.forEach(function(t){return e.push(t)}),"SortedSet("+e.toString()+")"},sg.prototype.copy=function(t){var e=new sg(this.comparator);return e.data=t,e},sg);function sg(t){this.comparator=t,this.data=new $v(this.comparator)}var ug=(cg.prototype.getNext=function(){return this.iter.getNext().key},cg.prototype.hasNext=function(){return this.iter.hasNext()},cg);function cg(t){this.iter=t}var hg=new $v(Rv.comparator);function lg(){return hg}function fg(){return lg()}var pg=new $v(Rv.comparator);function dg(){return pg}var yg=new $v(Rv.comparator);function mg(){return yg}var vg=new ag(Rv.comparator);function gg(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=vg,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var bg=new ag(sv);function wg(){return bg}var _g=(Eg.prototype.applyToRemoteDocument=function(t,e,n){e&&Nm(e.key.isEqual(t),"applyToRemoteDocument: key "+t+" should match maybeDoc key\n "+e.key);var r=n.mutationResults;Nm(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},Eg.prototype.applyToLocalView=function(t,e){e&&Nm(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},Eg.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},Eg.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},gg())},Eg.prototype.isEqual=function(t){return this.batchId===t.batchId&&uv(this.mutations,t.mutations)&&uv(this.baseMutations,t.baseMutations)},Eg);function Eg(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,Nm(0<(this.mutations=r).length,"Cannot create an empty mutation batch")}var Tg=(Sg.from=function(t,e,n,r){Nm(t.mutations.length===n.length,"Mutations sent "+t.mutations.length+" must equal results received "+n.length);for(var i=mg(),o=t.mutations,a=0;a<o.length;a++)i=i.insert(o[a].key,n[a].version);return new Sg(t,e,n,r,i)},Sg);function Sg(t,e,n,r,i){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.streamToken=r,this.docVersions=i}var Ig=(Cg.prototype.catch=function(t){return this.next(void 0,t)},Cg.prototype.next=function(r,i){var o=this;return this.callbackAttached&&Cm("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 Cg(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)}})},Cg.prototype.toPromise=function(){var n=this;return new Promise(function(t,e){n.next(t,e)})},Cg.prototype.wrapUserFunction=function(t){try{var e=t();return e instanceof Cg?e:Cg.resolve(e)}catch(t){return Cg.reject(t)}},Cg.prototype.wrapSuccess=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):Cg.resolve(e)},Cg.prototype.wrapFailure=function(t,e){return t?this.wrapUserFunction(function(){return t(e)}):Cg.reject(e)},Cg.resolve=function(n){return new Cg(function(t,e){t(n)})},Cg.reject=function(n){return new Cg(function(t,e){e(n)})},Cg.waitFor=function(t){return new Cg(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()})},Cg.or=function(t){for(var n=Cg.resolve(!1),e=function(e){n=n.next(function(t){return t?Cg.resolve(t):e()})},r=0,i=t;r<i.length;r++)e(i[r]);return n},Cg.forEach=function(t,n){var r=this,i=[];return t.forEach(function(t,e){i.push(n.call(r,t,e))}),this.waitFor(i)},Cg);function Cg(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 Ng="SimpleDb",Ag=(kg.openOrCreate=function(o,t,a){return Nm(kg.isAvailable(),"IndexedDB not supported in current environment."),Tm(Ng,"Opening database:",o),new Ig(function(n,r){var i=window.indexedDB.open(o,t);i.onsuccess=function(t){var e=t.target.result;n(new kg(e))},i.onblocked=function(){r(new Pm(Om.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 Pm(Om.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){Tm(Ng,'Database "'+o+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;a.createOrUpgrade(e,i.transaction,t.oldVersion,Gw).next(function(){Tm(Ng,"Database upgrade to version "+Gw+" complete")})}}).toPromise()},kg.delete=function(t){return Tm(Ng,"Removing database:",t),Lg(window.indexedDB.deleteDatabase(t)).toPromise()},kg.isAvailable=function(){if("undefined"==typeof window||null==window.indexedDB)return!1;if(kg.isMockPersistence())return!0;if(void 0===window.navigator)return!1;var t=va(),e=kg.getIOSVersion(t),n=0<e&&e<10,r=kg.getAndroidVersion(t),i=0<r&&r<4.5;return!(0<t.indexOf("MSIE ")||0<t.indexOf("Trident/")||0<t.indexOf("Edge/")||n||i)},kg.isMockPersistence=function(){return"undefined"!=typeof process&&"YES"===process.env.USE_MOCK_PERSISTENCE},kg.getStore=function(t,e){return t.store(e)},kg.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)},kg.getAndroidVersion=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},kg.prototype.setVersionChangeListener=function(e){this.db.onversionchange=function(t){return e(t)}},kg.prototype.runTransaction=function(r,c,h){return ea(this,void 0,void 0,function(){var o,a,s,e,u,n;return na(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 na(this,function(t){switch(t.label){case 0:++s,e=Og.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),Ig.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,Tm(Ng,"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]}})})},kg.prototype.close=function(){this.db.close()},kg);function kg(t){this.db=t,12.2===kg.getIOSVersion(va())&&Sm("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 Dg=(Object.defineProperty(Rg.prototype,"isDone",{get:function(){return this.shouldStop},enumerable:!0,configurable:!0}),Object.defineProperty(Rg.prototype,"skipToKey",{get:function(){return this.nextKey},enumerable:!0,configurable:!0}),Object.defineProperty(Rg.prototype,"cursor",{set:function(t){this.dbCursor=t},enumerable:!0,configurable:!0}),Rg.prototype.done=function(){this.shouldStop=!0},Rg.prototype.skip=function(t){this.nextKey=t},Rg.prototype.delete=function(){return Lg(this.dbCursor.delete())},Rg);function Rg(t){this.dbCursor=t,this.shouldStop=!1,this.nextKey=null}var Og=(Pg.open=function(t,e,n){return new Pg(t.transaction(n,e))},Object.defineProperty(Pg.prototype,"completionPromise",{get:function(){return this.completionDeferred.promise},enumerable:!0,configurable:!0}),Pg.prototype.abort=function(t){t&&this.completionDeferred.reject(t),this.aborted||(Tm(Ng,"Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},Pg.prototype.store=function(t){var e=this.transaction.objectStore(t);return Nm(!!e,"Object store not part of transaction: "+t),new Mg(e)},Pg);function Pg(t){var n=this;this.transaction=t,this.aborted=!1,this.completionDeferred=new xv,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=Ug(t.target.error);n.completionDeferred.reject(e)}}var Mg=(xg.prototype.put=function(t,e){return Lg(void 0!==e?(Tm(Ng,"PUT",this.store.name,t,e),this.store.put(e,t)):(Tm(Ng,"PUT",this.store.name,"<auto-key>",t),this.store.put(t)))},xg.prototype.add=function(t){return Tm(Ng,"ADD",this.store.name,t,t),Lg(this.store.add(t))},xg.prototype.get=function(e){var n=this;return Lg(this.store.get(e)).next(function(t){return void 0===t&&(t=null),Tm(Ng,"GET",n.store.name,e,t),t})},xg.prototype.delete=function(t){return Tm(Ng,"DELETE",this.store.name,t),Lg(this.store.delete(t))},xg.prototype.count=function(){return Tm(Ng,"COUNT",this.store.name),Lg(this.store.count())},xg.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})},xg.prototype.deleteAll=function(t,e){Tm(Ng,"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()})},xg.prototype.iterate=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.iterateCursor(r,e)},xg.prototype.iterateSerial=function(i){var t=this.cursor({});return new Ig(function(n,r){t.onerror=function(t){var e=Ug(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()}})},xg.prototype.iterateCursor=function(t,a){var s=[];return new Ig(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 Dg(e),r=a(e.primaryKey,e.value,n);if(r instanceof Ig){var i=r.catch(function(t){return n.done(),Ig.reject(t)});s.push(i)}n.isDone?o():null===n.skipToKey?e.continue():e.continue(n.skipToKey)}else o()}}).next(function(){return Ig.waitFor(s)})},xg.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:(Nm(void 0===e,"3rd argument must not be defined if 2nd is a range."),e=t)),{index:n,range:e}},xg.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)},xg);function xg(t){this.store=t}function Lg(t){return new Ig(function(n,r){t.onsuccess=function(t){var e=t.target.result;n(e)},t.onerror=function(t){var e=Ug(t.target.error);r(e)}})}var Fg=!1;function Ug(t){var e=Ag.getIOSVersion(va());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 Pm("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 Fg||(Fg=!0,setTimeout(function(){throw r},0)),r}}return t}var qg=(Vg.forUser=function(t,e,n,r){return Nm(""!==t.uid,"UserID must not be an empty string."),new Vg(t.isAuthenticated()?t.uid:"",e,n,r)},Vg.prototype.checkEmpty=function(t){var r=!0,e=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Kg(t).iterate({index:e_.userMutationsIndex,range:e},function(t,e,n){r=!1,n.done()}).next(function(){return r})},Vg.prototype.acknowledgeBatch=function(e,t,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=Wg(n),Hg(e).put(t)})},Vg.prototype.getLastStreamToken=function(t){return this.getMutationQueueMetadata(t).next(function(t){return t.lastStreamToken})},Vg.prototype.setLastStreamToken=function(e,n){return this.getMutationQueueMetadata(e).next(function(t){return t.lastStreamToken=Wg(n),Hg(e).put(t)})},Vg.prototype.addMutationBatch=function(c,h,l,f){var p=this,d=Qg(c),y=Kg(c);return y.add({}).next(function(t){Nm("number"==typeof t,"Auto-generated key is not a number");for(var e=new _g(t,h,l,f),n=p.serializer.toDbMutationBatch(p.userId,e),r=[],i=new ag(function(t,e){return sv(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(y.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()}),Ig.waitFor(r).next(function(){return e})})},Vg.prototype.lookupMutationBatch=function(t,e){var n=this;return Kg(t).get(e).next(function(t){return t?(Nm(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),n.serializer.fromDbMutationBatch(t)):null})},Vg.prototype.lookupMutationKeys=function(t,n){var r=this;return this.documentKeysByBatchId[n]?Ig.resolve(this.documentKeysByBatchId[n]):this.lookupMutationBatch(t,n).next(function(t){if(t){var e=t.keys();return r.documentKeysByBatchId[n]=e}return null})},Vg.prototype.getNextMutationBatchAfterBatchId=function(t,e){var r=this,i=e+1,n=IDBKeyRange.lowerBound([this.userId,i]),o=null;return Kg(t).iterate({index:e_.userMutationsIndex,range:n},function(t,e,n){e.userId===r.userId&&(Nm(e.batchId>=i,"Should have found mutation after "+i),o=r.serializer.fromDbMutationBatch(e)),n.done()}).next(function(){return o})},Vg.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),r=-1;return Kg(t).iterate({index:e_.userMutationsIndex,range:e,reverse:!0},function(t,e,n){r=e.batchId,n.done()}).next(function(){return r})},Vg.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Kg(t).loadAll(e_.userMutationsIndex,n).next(function(t){return t.map(function(t){return e.serializer.fromDbMutationBatch(t)})})},Vg.prototype.getAllMutationBatchesAffectingDocumentKey=function(s,u){var c=this,t=r_.prefixForPath(this.userId,u.path),e=IDBKeyRange.lowerBound(t),h=[];return Qg(s).iterate({range:e},function(e,t,n){var r=e[0],i=e[1],o=e[2],a=Gv(i);if(r===c.userId&&u.path.isEqual(a))return Kg(s).get(o).next(function(t){if(!t)throw Cm("Dangling document-mutation reference found: "+e+" which points to "+o);Nm(t.userId===c.userId,"Unexpected user '"+t.userId+"' for mutation batch "+o),h.push(c.serializer.fromDbMutationBatch(t))});n.done()}).next(function(){return h})},Vg.prototype.getAllMutationBatchesAffectingDocumentKeys=function(r,t){var u=this,c=new ag(sv),i=[];return t.forEach(function(s){var t=r_.prefixForPath(u.userId,s.path),e=IDBKeyRange.lowerBound(t),n=Qg(r).iterate({range:e},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=Gv(i);r===u.userId&&s.path.isEqual(a)?c=c.add(o):n.done()});i.push(n)}),Ig.waitFor(i).next(function(){return u.lookupMutationBatches(r,c)})},Vg.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var s=this;Nm(!e.isDocumentQuery(),"Document queries shouldn't go down this path"),Nm(!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 ag(sv);return Qg(t).iterate({range:r},function(t,e,n){var r=t[0],i=t[1],o=t[2],a=Gv(i);r===s.userId&&u.isPrefixOf(a)?a.length===c&&(h=h.add(o)):n.done()}).next(function(){return s.lookupMutationBatches(t,h)})},Vg.prototype.lookupMutationBatches=function(t,e){var n=this,r=[],i=[];return e.forEach(function(e){i.push(Kg(t).get(e).next(function(t){if(null===t)throw Cm("Dangling document-mutation reference found, which points to "+e);Nm(t.userId===n.userId,"Unexpected user '"+t.userId+"' for mutation batch "+e),r.push(n.serializer.fromDbMutationBatch(t))}))}),Ig.waitFor(i).next(function(){return r})},Vg.prototype.removeMutationBatch=function(e,n){var r=this;return jg(e.simpleDbTransaction,this.userId,n).next(function(t){return e.addOnCommittedListener(function(){r.removeCachedMutationKeys(n.batchId)}),Ig.forEach(t,function(t){return r.referenceDelegate.removeMutationReference(e,t)})})},Vg.prototype.removeCachedMutationKeys=function(t){delete this.documentKeysByBatchId[t]},Vg.prototype.performConsistencyCheck=function(n){var o=this;return this.checkEmpty(n).next(function(t){if(!t)return Ig.resolve();var e=IDBKeyRange.lowerBound(r_.prefixForUser(o.userId)),i=[];return Qg(n).iterate({range:e},function(t,e,n){if(t[0]===o.userId){var r=Gv(t[1]);i.push(r)}else n.done()}).next(function(){Nm(0===i.length,"Document leak -- detected dangling mutation references when queue is empty. Dangling keys: "+i.map(function(t){return t.canonicalString()}))})})},Vg.prototype.containsKey=function(t,e){return Bg(t,this.userId,e)},Vg.prototype.getMutationQueueMetadata=function(t){var e=this;return Hg(t).get(this.userId).next(function(t){return t||new Zw(e.userId,-1,"")})},Vg);function Vg(t,e,n,r){this.userId=t,this.serializer=e,this.indexManager=n,this.referenceDelegate=r,this.documentKeysByBatchId={}}function Bg(t,o,e){var n=r_.prefixForPath(o,e.path),a=n[1],r=IDBKeyRange.lowerBound(n),s=!1;return Qg(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 jg(t,e,n){var r=t.store(e_.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(){Nm(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 Ig.waitFor(o).next(function(){return c})}function Wg(t){return t instanceof Uint8Array?(Nm(Ag.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence."),t.toString()):t}function Kg(t){return X_.getStore(t,e_.store)}function Qg(t){return X_.getStore(t,r_.store)}function Hg(t){return X_.getStore(t,Zw.store)}var Gg,zg;(zg=Gg=Gg||{})[zg.QueryCache=0]="QueryCache",zg[zg.SyncEngine=1]="SyncEngine";var Yg=(Xg.prototype.next=function(){var t=this.nextId;return this.nextId+=2,t},Xg.prototype.after=function(t){return this.seek(t+2),this.next()},Xg.prototype.seek=function(t){Nm((1&t)===this.generatorId,"Cannot supply target ID from different generator ID"),this.nextId=t},Xg.forQueryCache=function(){return new Xg(Gg.QueryCache,2)},Xg.forSyncEngine=function(){return new Xg(Gg.SyncEngine)},Xg);function Xg(t,e){Nm((1&(this.generatorId=t))===t,"Generator ID "+t+" contains more than 1 reserved bits"),this.seek(void 0!==e?e:this.generatorId)}var Jg=($g.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})})},$g.prototype.getLastRemoteSnapshotVersion=function(t){return this.retrieveMetadata(t).next(function(t){return Xv.fromTimestamp(new zv(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))})},$g.prototype.getHighestSequenceNumber=function(t){return eb(t.simpleDbTransaction)},$g.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)})},$g.prototype.addQueryData=function(e,n){var r=this;return this.saveQueryData(e,n).next(function(){return r.retrieveMetadata(e).next(function(t){return t.targetCount+=1,r.updateMetadataFromQueryData(n,t),r.saveMetadata(e,t)})})},$g.prototype.updateQueryData=function(t,e){return this.saveQueryData(t,e)},$g.prototype.removeQueryData=function(e,t){var n=this;return this.removeMatchingKeysForTargetId(e,t.targetId).next(function(){return Zg(e).delete(t.targetId)}).next(function(){return n.retrieveMetadata(e)}).next(function(t){return Nm(0<t.targetCount,"Removing from an empty query cache"),t.targetCount-=1,n.saveMetadata(e,t)})},$g.prototype.removeTargets=function(r,i,o){var a=this,s=0,u=[];return Zg(r).iterate(function(t,e){var n=a.serializer.fromDbTarget(e);n.sequenceNumber<=i&&null===o.get(n.targetId)&&(s++,u.push(a.removeQueryData(r,n)))}).next(function(){return Ig.waitFor(u)}).next(function(){return s})},$g.prototype.forEachTarget=function(t,r){var i=this;return Zg(t).iterate(function(t,e){var n=i.serializer.fromDbTarget(e);r(n)})},$g.prototype.retrieveMetadata=function(t){return tb(t.simpleDbTransaction)},$g.prototype.saveMetadata=function(t,e){return function(t){return X_.getStore(t,y_.store)}(t).put(y_.key,e)},$g.prototype.saveQueryData=function(t,e){return Zg(t).put(this.serializer.toDbTarget(e))},$g.prototype.updateMetadataFromQueryData=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},$g.prototype.getQueryCount=function(t){return this.retrieveMetadata(t).next(function(t){return t.targetCount})},$g.prototype.getQueryData=function(t,i){var o=this,e=i.canonicalId(),n=IDBKeyRange.bound([e,Number.NEGATIVE_INFINITY],[e,Number.POSITIVE_INFINITY]),a=null;return Zg(t).iterate({range:n,index:l_.queryTargetsIndexName},function(t,e,n){var r=o.serializer.fromDbTarget(e);i.isEqual(r.query)&&(a=r,n.done())}).next(function(){return a})},$g.prototype.addMatchingKeys=function(n,t,r){var i=this,o=[],a=nb(n);return t.forEach(function(t){var e=Kv(t.path);o.push(a.put(new p_(r,e))),o.push(i.referenceDelegate.addReference(n,t))}),Ig.waitFor(o)},$g.prototype.removeMatchingKeys=function(n,t,r){var i=this,o=nb(n);return Ig.forEach(t,function(t){var e=Kv(t.path);return Ig.waitFor([o.delete([r,e]),i.referenceDelegate.removeReference(n,t)])})},$g.prototype.removeMatchingKeysForTargetId=function(t,e){var n=nb(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},$g.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=nb(t),o=gg();return r.iterate({range:n,keysOnly:!0},function(t,e,n){var r=Gv(t[1]),i=new Rv(r);o=o.add(i)}).next(function(){return o})},$g.prototype.containsKey=function(t,e){var n=Kv(e.path),r=IDBKeyRange.bound([n],[cv(n)],!1,!0),i=0;return nb(t).iterate({index:p_.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})},$g.prototype.getQueryDataForTarget=function(t,e){var n=this;return Zg(t).get(e).next(function(t){return t?n.serializer.fromDbTarget(t):null})},$g);function $g(t,e){this.referenceDelegate=t,this.serializer=e,this.targetIdGenerator=Yg.forQueryCache()}function Zg(t){return X_.getStore(t,l_.store)}function tb(t){return Ag.getStore(t,y_.store).get(y_.key).next(function(t){return Nm(null!==t,"Missing metadata row."),t})}function eb(t){return tb(t).next(function(t){return t.highestListenSequenceNumber})}function nb(t){return X_.getStore(t,p_.store)}var rb=(ib.fromSet=function(t){return new ib(t)},ib.fromArray=function(t){var e=new ag(kv.comparator);return t.forEach(function(t){return e=e.add(t)}),new ib(e)},ib.prototype.covers=function(e){var n=!1;return this.fields.forEach(function(t){t.isPrefixOf(e)&&(n=!0)}),n},ib.prototype.isEqual=function(t){return this.fields.isEqual(t.fields)},ib);function ib(t){this.fields=t}var ob=(ab.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},ab);function ab(t,e){this.field=t,this.transform=e}var sb,ub,cb=function(t,e){this.version=t,this.transformResults=e};(ub=sb=sb||{})[ub.Set=0]="Set",ub[ub.Patch=1]="Patch",ub[ub.Transform=2]="Transform",ub[ub.Delete=3]="Delete";var hb=(lb.exists=function(t){return new lb(void 0,t)},lb.updateTime=function(t){return new lb(t)},Object.defineProperty(lb.prototype,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),lb.prototype.isValidFor=function(t){return void 0!==this.updateTime?t instanceof Tw&&t.version.isEqual(this.updateTime):void 0!==this.exists?this.exists===t instanceof Tw:(Nm(this.isNone,"Precondition should be empty"),!0)},lb.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},lb.NONE=new lb,lb);function lb(t,e){this.updateTime=t,this.exists=e,Nm(void 0===t||void 0===e,'Precondition can specify "exists" or "updateTime" but not both')}var fb=(pb.prototype.verifyKeyMatches=function(t){null!=t&&Nm(t.key.isEqual(this.key),"Can only apply a mutation to a document with the same key")},pb.getPostMutationVersion=function(t){return t instanceof Tw?t.version:Xv.MIN},pb);function pb(){}var db,yb=(Zo(mb,db=fb),mb.prototype.applyToRemoteDocument=function(t,e){this.verifyKeyMatches(t),Nm(null==e.transformResults,"Transform results received by SetMutation.");var n=e.version;return new Tw(this.key,n,{hasCommittedMutations:!0},this.value)},mb.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=fb.getPostMutationVersion(t);return new Tw(this.key,r,{hasLocalMutations:!0},this.value)},mb.prototype.extractBaseValue=function(t){return null},mb.prototype.isEqual=function(t){return t instanceof mb&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.precondition.isEqual(t.precondition)},mb);function mb(t,e,n){var r=db.call(this)||this;return r.key=t,r.value=e,r.precondition=n,r.type=sb.Set,r}var vb,gb=(Zo(bb,vb=fb),bb.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),Nm(null==e.transformResults,"Transform results received by PatchMutation."),!this.precondition.isValidFor(t))return new kw(this.key,e.version);var n=this.patchDocument(t);return new Tw(this.key,e.version,{hasCommittedMutations:!0},n)},bb.prototype.applyToLocalView=function(t,e,n){if(this.verifyKeyMatches(t),!this.precondition.isValidFor(t))return t;var r=fb.getPostMutationVersion(t),i=this.patchDocument(t);return new Tw(this.key,r,{hasLocalMutations:!0},i)},bb.prototype.extractBaseValue=function(t){return null},bb.prototype.isEqual=function(t){return t instanceof bb&&this.key.isEqual(t.key)&&this.fieldMask.isEqual(t.fieldMask)&&this.precondition.isEqual(t.precondition)},bb.prototype.patchDocument=function(t){var e;return e=t instanceof Tw?t.data():yw.EMPTY,this.patchObject(e)},bb.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},bb);function bb(t,e,n,r){var i=vb.call(this)||this;return i.key=t,i.data=e,i.fieldMask=n,i.precondition=r,i.type=sb.Patch,i}var wb,_b=(Zo(Eb,wb=fb),Eb.prototype.applyToRemoteDocument=function(t,e){if(this.verifyKeyMatches(t),Nm(null!=e.transformResults,"Transform results missing for TransformMutation."),!this.precondition.isValidFor(t))return new kw(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 Tw(this.key,i,{hasCommittedMutations:!0},o)},Eb.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 Tw(this.key,r.version,{hasLocalMutations:!0},o)},Eb.prototype.extractBaseValue=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof Tw?t.field(i.field):void 0,a=i.transform.computeBaseValue(o||null);null!=a&&(e=null==e?yw.EMPTY.set(i.field,a):e.set(i.field,a))}return e},Eb.prototype.isEqual=function(t){return t instanceof Eb&&this.key.isEqual(t.key)&&uv(this.fieldTransforms,t.fieldTransforms)&&this.precondition.isEqual(t.precondition)},Eb.prototype.requireDocument=function(t){Nm(t instanceof Tw,"Unknown MaybeDocument type "+t);var e=t;return Nm(e.key.isEqual(this.key),"Can only transform a document with the same key"),e},Eb.prototype.serverTransformResults=function(t,e){var n=[];Nm(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 Tw&&(a=t.field(i.field)),n.push(o.applyToRemoteDocument(a,e[r]))}return n},Eb.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 Tw&&(u=e.field(a.field)),null===u&&n instanceof Tw&&(u=n.field(a.field)),r.push(s.applyToLocalView(u,t))}return r},Eb.prototype.transformObject=function(t,e){Nm(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},Eb);function Eb(t,e){var n=wb.call(this)||this;return n.key=t,n.fieldTransforms=e,n.type=sb.Transform,n.precondition=hb.exists(!0),n}var Tb,Sb,Ib,Cb,Nb,Ab=(Zo(kb,Tb=fb),kb.prototype.applyToRemoteDocument=function(t,e){return this.verifyKeyMatches(t),Nm(null==e.transformResults,"Transform results received by DeleteMutation."),new Cw(this.key,e.version,{hasCommittedMutations:!0})},kb.prototype.applyToLocalView=function(t,e,n){return this.verifyKeyMatches(t),this.precondition.isValidFor(t)?(t&&Nm(t.key.isEqual(this.key),"Can only apply mutation to document with same key"),new Cw(this.key,Xv.forDeletedDoc())):t},kb.prototype.extractBaseValue=function(t){return null},kb.prototype.isEqual=function(t){return t instanceof kb&&this.key.isEqual(t.key)&&this.precondition.isEqual(t.precondition)},kb);function kb(t,e){var n=Tb.call(this)||this;return n.key=t,n.precondition=e,n.type=sb.Delete,n}(Ib=Sb=Sb||{})[Ib.NullValue=0]="NullValue",Ib[Ib.BooleanValue=1]="BooleanValue",Ib[Ib.NumberValue=2]="NumberValue",Ib[Ib.TimestampValue=3]="TimestampValue",Ib[Ib.StringValue=4]="StringValue",Ib[Ib.BlobValue=5]="BlobValue",Ib[Ib.RefValue=6]="RefValue",Ib[Ib.GeoPointValue=7]="GeoPointValue",Ib[Ib.ArrayValue=8]="ArrayValue",Ib[Ib.ObjectValue=9]="ObjectValue",(Nb=Cb=Cb||{})[Nb.Default=0]="Default",Nb[Nb.Estimate=1]="Estimate",Nb[Nb.Previous=2]="Previous";var Db=(Rb.fromSnapshotOptions=function(t,e){switch(t.serverTimestamps){case"estimate":return new Rb(Cb.Estimate,e);case"previous":return new Rb(Cb.Previous,e);case"none":case void 0:return new Rb(Cb.Default,e);default:return Cm("fromSnapshotOptions() called with invalid options.")}},Rb);function Rb(t,e){this.serverTimestampBehavior=t,this.timestampsInSnapshots=e}var Ob=(Pb.prototype.toString=function(){var t=this.value();return null===t?"null":t.toString()},Pb.prototype.defaultCompareTo=function(t){return Nm(this.typeOrder!==t.typeOrder,"Default compareTo should not be used for values of same type."),sv(this.typeOrder,t.typeOrder)},Pb);function Pb(){}var Mb,xb=(Zo(Lb,Mb=Ob),Lb.prototype.value=function(t){return null},Lb.prototype.isEqual=function(t){return t instanceof Lb},Lb.prototype.compareTo=function(t){return t instanceof Lb?0:this.defaultCompareTo(t)},Lb.INSTANCE=new Lb,Lb);function Lb(){var t=Mb.call(this)||this;return t.typeOrder=Sb.NullValue,t.internalValue=null,t}var Fb,Ub=(Zo(qb,Fb=Ob),qb.prototype.value=function(t){return this.internalValue},qb.prototype.isEqual=function(t){return t instanceof qb&&this.internalValue===t.internalValue},qb.prototype.compareTo=function(t){return t instanceof qb?sv(this,t):this.defaultCompareTo(t)},qb.of=function(t){return t?qb.TRUE:qb.FALSE},qb.TRUE=new qb(!0),qb.FALSE=new qb(!1),qb);function qb(t){var e=Fb.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.BooleanValue,e}var Vb,Bb=(Zo(jb,Vb=Ob),jb.prototype.value=function(t){return this.internalValue},jb.prototype.compareTo=function(t){return t instanceof jb?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)},jb);function jb(t){var e=Vb.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.NumberValue,e}function Wb(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}var Kb,Qb=(Zo(Hb,Kb=Bb),Hb.prototype.isEqual=function(t){return t instanceof Hb&&Wb(this.internalValue,t.internalValue)},Hb);function Hb(){return null!==Kb&&Kb.apply(this,arguments)||this}var Gb,zb=(Zo(Yb,Gb=Bb),Yb.prototype.isEqual=function(t){return t instanceof Yb&&Wb(this.internalValue,t.internalValue)},Yb.NAN=new Yb(NaN),Yb.POSITIVE_INFINITY=new Yb(1/0),Yb.NEGATIVE_INFINITY=new Yb(-1/0),Yb);function Yb(){return null!==Gb&&Gb.apply(this,arguments)||this}var Xb,Jb=(Zo($b,Xb=Ob),$b.prototype.value=function(t){return this.internalValue},$b.prototype.isEqual=function(t){return t instanceof $b&&this.internalValue===t.internalValue},$b.prototype.compareTo=function(t){return t instanceof $b?sv(this.internalValue,t.internalValue):this.defaultCompareTo(t)},$b);function $b(t){var e=Xb.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.StringValue,e}var Zb,tw=(Zo(ew,Zb=Ob),ew.prototype.value=function(t){return!t||t.timestampsInSnapshots?this.internalValue:this.internalValue.toDate()},ew.prototype.isEqual=function(t){return t instanceof ew&&this.internalValue.isEqual(t.internalValue)},ew.prototype.compareTo=function(t){return t instanceof ew?this.internalValue._compareTo(t.internalValue):t instanceof rw?-1:this.defaultCompareTo(t)},ew);function ew(t){var e=Zb.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.TimestampValue,e}var nw,rw=(Zo(iw,nw=Ob),iw.prototype.value=function(t){return t&&t.serverTimestampBehavior===Cb.Estimate?new tw(this.localWriteTime).value(t):t&&t.serverTimestampBehavior===Cb.Previous&&this.previousValue?this.previousValue.value(t):null},iw.prototype.isEqual=function(t){return t instanceof iw&&this.localWriteTime.isEqual(t.localWriteTime)},iw.prototype.compareTo=function(t){return t instanceof iw?this.localWriteTime._compareTo(t.localWriteTime):t instanceof tw?1:this.defaultCompareTo(t)},iw.prototype.toString=function(){return"<ServerTimestamp localTime="+this.localWriteTime.toString()+">"},iw);function iw(t,e){var n=nw.call(this)||this;return n.localWriteTime=t,n.previousValue=e,n.typeOrder=Sb.TimestampValue,n}var ow,aw=(Zo(sw,ow=Ob),sw.prototype.value=function(t){return this.internalValue},sw.prototype.isEqual=function(t){return t instanceof sw&&this.internalValue.isEqual(t.internalValue)},sw.prototype.compareTo=function(t){return t instanceof sw?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},sw);function sw(t){var e=ow.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.BlobValue,e}var uw,cw=(Zo(hw,uw=Ob),hw.prototype.value=function(t){return this.key},hw.prototype.isEqual=function(t){return t instanceof hw&&this.key.isEqual(t.key)&&this.databaseId.isEqual(t.databaseId)},hw.prototype.compareTo=function(t){if(t instanceof hw){var e=this.databaseId.compareTo(t.databaseId);return 0!==e?e:Rv.comparator(this.key,t.key)}return this.defaultCompareTo(t)},hw);function hw(t,e){var n=uw.call(this)||this;return n.databaseId=t,n.key=e,n.typeOrder=Sb.RefValue,n}var lw,fw=(Zo(pw,lw=Ob),pw.prototype.value=function(t){return this.internalValue},pw.prototype.isEqual=function(t){return t instanceof pw&&this.internalValue.isEqual(t.internalValue)},pw.prototype.compareTo=function(t){return t instanceof pw?this.internalValue._compareTo(t.internalValue):this.defaultCompareTo(t)},pw);function pw(t){var e=lw.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.GeoPointValue,e}var dw,yw=(Zo(mw,dw=Ob),mw.prototype.value=function(n){var r={};return this.internalValue.inorderTraversal(function(t,e){r[t]=e.value(n)}),r},mw.prototype.forEach=function(t){this.internalValue.inorderTraversal(t)},mw.prototype.isEqual=function(t){if(t instanceof mw){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},mw.prototype.compareTo=function(t){if(t instanceof mw){for(var e=this.internalValue.getIterator(),n=t.internalValue.getIterator();e.hasNext()&&n.hasNext();){var r=e.getNext(),i=n.getNext(),o=sv(r.key,i.key)||r.value.compareTo(i.value);if(o)return o}return sv(e.hasNext(),n.hasNext())}return this.defaultCompareTo(t)},mw.prototype.set=function(t,e){if(Nm(!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 mw||(n=mw.EMPTY);var r=n.set(t.popFirst(),e);return this.setChild(t.firstSegment(),r)},mw.prototype.delete=function(t){if(Nm(!t.isEmpty(),"Cannot delete field for empty path on ObjectValue"),1===t.length)return new mw(this.internalValue.remove(t.firstSegment()));var e=this.child(t.firstSegment());if(e instanceof mw){var n=e.delete(t.popFirst());return new mw(this.internalValue.insert(t.firstSegment(),n))}return this},mw.prototype.contains=function(t){return null!==this.field(t)},mw.prototype.field=function(t){Nm(!t.isEmpty(),"Can't get field of empty path");var e=this;return t.forEach(function(t){e=e instanceof mw?e.internalValue.get(t):null}),e},mw.prototype.fieldMask=function(){var i=new ag(kv.comparator);return this.internalValue.forEach(function(t,e){var n=new kv([t]);if(e instanceof mw){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)},mw.prototype.toString=function(){return this.internalValue.toString()},mw.prototype.child=function(t){return this.internalValue.get(t)||void 0},mw.prototype.setChild=function(t,e){return new mw(this.internalValue.insert(t,e))},mw.EMPTY=new mw(new $v(sv)),mw);function mw(t){var e=dw.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.ObjectValue,e}var vw,gw=(Zo(bw,vw=Ob),bw.prototype.value=function(e){return this.internalValue.map(function(t){return t.value(e)})},bw.prototype.contains=function(t){for(var e=0,n=this.internalValue;e<n.length;e++)if(n[e].isEqual(t))return!0;return!1},bw.prototype.forEach=function(t){this.internalValue.forEach(t)},bw.prototype.isEqual=function(t){if(t instanceof bw){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},bw.prototype.compareTo=function(t){if(t instanceof bw){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 sv(this.internalValue.length,t.internalValue.length)}return this.defaultCompareTo(t)},bw.prototype.toString=function(){return"["+this.internalValue.map(function(t){return t.toString()}).join(",")+"]"},bw);function bw(t){var e=vw.call(this)||this;return e.internalValue=t,e.typeOrder=Sb.ArrayValue,e}var ww=(_w.compareByKey=function(t,e){return Rv.comparator(t.key,e.key)},_w);function _w(t,e){this.key=t,this.version=e}var Ew,Tw=(Zo(Sw,Ew=ww),Sw.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},Sw.prototype.data=function(){var n=this;if(!this.objectValue){var r=yw.EMPTY;qm(this.proto.fields||{},function(t,e){r=r.set(new kv([t]),n.converter(e))}),this.objectValue=r,this.fieldValueCache=void 0}return this.objectValue},Sw.prototype.value=function(){return this.data().value()},Sw.prototype.isEqual=function(t){return t instanceof Sw&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.hasLocalMutations===t.hasLocalMutations&&this.hasCommittedMutations===t.hasCommittedMutations&&this.data().isEqual(t.data())},Sw.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.data().toString()+", {hasLocalMutations: "+this.hasLocalMutations+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(Sw.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!0,configurable:!0}),Sw.prototype.getProtoField=function(t){Nm(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},Sw.compareByField=function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?r.compareTo(i):Cm("Trying to compare documents on fields that don't exist")},Sw);function Sw(t,e,n,r,i,o){var a=Ew.call(this,t,e)||this;return a.objectValue=r,a.proto=i,a.converter=o,Nm(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 Iw,Cw=(Zo(Nw,Iw=ww),Nw.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(Nw.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,configurable:!0}),Nw.prototype.isEqual=function(t){return t instanceof Nw&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Nw);function Nw(t,e,n){var r=Iw.call(this,t,e)||this;return r.hasCommittedMutations=!(!n||!n.hasCommittedMutations),r}var Aw,kw=(Zo(Dw,Aw=ww),Dw.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(Dw.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),Dw.prototype.isEqual=function(t){return t instanceof Dw&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},Dw);function Dw(){return null!==Aw&&Aw.apply(this,arguments)||this}var Rw=(Ow.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}},Ow.prototype.has=function(t){return void 0!==this.get(t)},Ow.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]]},Ow.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},Ow.prototype.forEach=function(s){qm(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)}})},Ow.prototype.isEmpty=function(){return Vm(this.inner)},Ow);function Ow(t){this.mapKeyFn=t,this.inner={}}var Pw=(Object.defineProperty(Mw.prototype,"readTime",{get:function(){return Nm(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){Nm(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}),Mw.prototype.addEntry=function(t,e){this.assertNotApplied(),this.readTime=e,this.changes.set(t.key,t)},Mw.prototype.removeEntry=function(t,e){this.assertNotApplied(),e&&(this.readTime=e),this.changes.set(t,null)},Mw.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?Ig.resolve(n):this.getFromCache(t,e)},Mw.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},Mw.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},Mw.prototype.assertNotApplied=function(){Nm(!this.changesApplied,"Changes have already been applied.")},Mw);function Mw(){this.changes=new Rw(function(t){return t.toString()}),this.changesApplied=!1}var xw,Lw=(Fw.prototype.addEntry=function(t,e,n){return Vw(t).put(Bw(e),n)},Fw.prototype.removeEntry=function(t,e){var n=Vw(t),r=Bw(e);return n.delete(r)},Fw.prototype.updateMetadata=function(e,n){var r=this;return this.getMetadata(e).next(function(t){return t.byteSize+=n,r.setMetadata(e,t)})},Fw.prototype.getEntry=function(t,e){var n=this;return Vw(t).get(Bw(e)).next(function(t){return n.maybeDecodeDocument(t)})},Fw.prototype.getSizedEntry=function(t,e){var n=this;return Vw(t).get(Bw(e)).next(function(t){var e=n.maybeDecodeDocument(t);return e?{maybeDocument:e,size:jw(t)}:null})},Fw.prototype.getEntries=function(t,e){var r=this,i=fg();return this.forEachDbEntry(t,e,function(t,e){var n=r.maybeDecodeDocument(e);i=i.insert(t,n)}).next(function(){return i})},Fw.prototype.getSizedEntries=function(t,e){var r=this,i=fg(),o=new $v(Rv.comparator);return this.forEachDbEntry(t,e,function(t,e){var n=r.maybeDecodeDocument(e);o=n?(i=i.insert(t,n),o.insert(t,jw(e))):(i=i.insert(t,null),o.insert(t,0))}).next(function(){return{maybeDocuments:i,sizeMap:o}})},Fw.prototype.forEachDbEntry=function(t,e,i){if(e.isEmpty())return Ig.resolve();var n=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),o=e.getIterator(),a=o.getNext();return Vw(t).iterate({range:n},function(t,e,n){for(var r=Rv.fromSegments(t);a&&Rv.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})},Fw.prototype.getDocumentsMatchingQuery=function(t,i,e){var o=this;Nm(!i.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var a=dg(),s=i.path.length+1,n={};if(e.isEqual(Xv.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=s_.collectionReadTimeIndex}return Vw(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 Tw&&i.matches(r)&&(a=a.insert(r.key,r)):n.done()}}).next(function(){return a})},Fw.prototype.getNewDocumentChanges=function(t,e){var r=this,i=lg(),o=this.serializer.toDbTimestampKey(e),n=Vw(t),a=IDBKeyRange.lowerBound(o,!0);return n.iterate({index:s_.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)}})},Fw.prototype.getLastDocumentChange=function(t){var r,i=this,e=Vw(t),o=Xv.MIN;return e.iterate({index:s_.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}})},Fw.prototype.newChangeBuffer=function(t){return new Fw.RemoteDocumentChangeBuffer(this,!!t&&t.trackRemovals)},Fw.prototype.getSize=function(t){return this.getMetadata(t).next(function(t){return t.byteSize})},Fw.prototype.getMetadata=function(t){return qw(t).get(c_.key).next(function(t){return Nm(!!t,"Missing document cache metadata"),t})},Fw.prototype.setMetadata=function(t,e){return qw(t).put(c_.key,e)},Fw.prototype.maybeDecodeDocument=function(t){if(t){var e=this.serializer.fromDbRemoteDocument(t);return e instanceof Cw&&e.version.isEqual(Xv.forDeletedDoc())?null:e}return null},Fw.RemoteDocumentChangeBuffer=(Zo(Uw,xw=Pw),Uw.prototype.applyChanges=function(a){var s=this,u=[],c=0,h=new ag(function(t,e){return sv(t.canonicalString(),e.canonicalString())});return this.changes.forEach(function(t,e){var n=s.documentSizes.get(t);if(Nm(void 0!==n,"Cannot modify a document that wasn't read (for "+t+")"),e){Nm(!s.readTime.isEqual(Xv.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=jw(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 Cw(t,Xv.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)),Ig.waitFor(u)},Uw.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)})},Uw.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})},Uw),Fw);function Fw(t,e){this.serializer=t,this.indexManager=e}function Uw(t,e){var n=xw.call(this)||this;return n.documentCache=t,n.trackRemovals=e,n.documentSizes=new Rw(function(t){return t.toString()}),n}function qw(t){return X_.getStore(t,c_.store)}function Vw(t){return X_.getStore(t,s_.store)}function Bw(t){return t.path.toArray()}function jw(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw Cm("Unknown remote document type");e=t.noDocument}return JSON.stringify(e).length}var Ww=(Kw.prototype.addToCollectionParentIndex=function(t,e){return this.collectionParentIndex.add(e),Ig.resolve()},Kw.prototype.getCollectionParents=function(t,e){return Ig.resolve(this.collectionParentIndex.getEntries(e))},Kw);function Kw(){this.collectionParentIndex=new Qw}var Qw=(Hw.prototype.add=function(t){Nm(t.length%2==1,"Expected a collection path.");var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new ag(Iv.comparator),i=!r.has(n);return this.index[e]=r.add(n),i},Hw.prototype.has=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)},Hw.prototype.getEntries=function(t){return(this.index[t]||new ag(Iv.comparator)).toArray()},Hw);function Hw(){this.index={}}var Gw=9,zw=(Yw.prototype.createOrUpgrade=function(t,e,n,r){var i=this;Nm(n<r&&0<=n&&r<=Gw,"Unexpected schema upgrade from v"+n+" to v{toVersion}.");var o=new Og(e);n<1&&1<=r&&(function(t){t.createObjectStore(Jw.store)}(t),function(t){t.createObjectStore(Zw.store,{keyPath:Zw.keyPath}),t.createObjectStore(e_.store,{keyPath:e_.keyPath,autoIncrement:!0}).createIndex(e_.userMutationsIndex,e_.userMutationsKeyPath,{unique:!0}),t.createObjectStore(r_.store)}(t),b_(t),function(t){t.createObjectStore(s_.store)}(t));var a=Ig.resolve();return n<3&&3<=r&&(0!==n&&(function(t){t.deleteObjectStore(p_.store),t.deleteObjectStore(l_.store),t.deleteObjectStore(y_.store)}(t),b_(t)),a=a.next(function(){return function(t){var e=t.store(y_.store),n=new y_(0,0,Xv.MIN.toTimestamp(),0);return e.put(y_.key,n)}(o)})),n<4&&4<=r&&(0!==n&&(a=a.next(function(){return function(r,i){return i.store(e_.store).loadAll().next(function(t){r.deleteObjectStore(e_.store),r.createObjectStore(e_.store,{keyPath:e_.keyPath,autoIncrement:!0}).createIndex(e_.userMutationsIndex,e_.userMutationsKeyPath,{unique:!0});var e=i.store(e_.store),n=t.map(function(t){return e.put(t)});return Ig.waitFor(n)})}(t,o)})),a=a.next(function(){!function(t){t.createObjectStore(w_.store,{keyPath:w_.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(c_.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(s_.store);e.createIndex(s_.readTimeIndex,s_.readTimeIndexPath,{unique:!1}),e.createIndex(s_.collectionReadTimeIndex,s_.collectionReadTimeIndexPath,{unique:!1})}(e)})),a},Yw.prototype.addDocumentGlobal=function(e){var n=0;return e.store(s_.store).iterate(function(t,e){n+=jw(e)}).next(function(){var t=new c_(n);return e.store(c_.store).put(c_.key,t)})},Yw.prototype.removeAcknowledgedMutations=function(r){var i=this,t=r.store(Zw.store),e=r.store(e_.store);return t.loadAll().next(function(t){return Ig.forEach(t,function(n){var t=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return e.loadAll(e_.userMutationsIndex,t).next(function(t){return Ig.forEach(t,function(t){Nm(t.userId===n.userId,"Cannot process batch "+t.batchId+" from unexpected user");var e=i.serializer.fromDbMutationBatch(t);return jg(r,n.userId,e).next(function(){})})})})})},Yw.prototype.ensureSequenceNumbers=function(t){var a=t.store(p_.store),e=t.store(s_.store);return eb(t).next(function(i){var o=[];return e.iterate(function(t,e){var n=new Iv(t),r=function(t){return[0,Kv(t)]}(n);o.push(a.get(r).next(function(t){return t?Ig.resolve():function(t){return a.put(new p_(0,Kv(t),i))}(n)}))}).next(function(){return Ig.waitFor(o)})})},Yw.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:Kv(n)})}}t.createObjectStore(v_.store,{keyPath:v_.keyPath});var r=e.store(v_.store),o=new Qw;return e.store(s_.store).iterate({keysOnly:!0},function(t,e){var n=new Iv(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],Gv(n));return i(r.popLast())})})},Yw);function Yw(t){this.serializer=t}var Xw=function(t,e){this.seconds=t,this.nanoseconds=e},Jw=($w.store="owner",$w.key="owner",$w);function $w(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n}var Zw=(t_.store="mutationQueues",t_.keyPath="userId",t_);function t_(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n}var e_=(n_.store="mutations",n_.keyPath="batchId",n_.userMutationsIndex="userMutationsIndex",n_.userMutationsKeyPath=["userId","batchId"],n_);function n_(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i}var r_=(i_.prefixForUser=function(t){return[t]},i_.prefixForPath=function(t,e){return[t,Kv(e)]},i_.key=function(t,e,n){return[t,Kv(e),n]},i_.store="documentMutations",i_.PLACEHOLDER=new i_,i_);function i_(){}var o_=function(t,e){this.path=t,this.readTime=e},a_=function(t,e){this.path=t,this.version=e},s_=(u_.store="remoteDocuments",u_.readTimeIndex="readTimeIndex",u_.readTimeIndexPath="readTime",u_.collectionReadTimeIndex="collectionReadTimeIndex",u_.collectionReadTimeIndexPath=["parentPath","readTime"],u_);function u_(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 c_=(h_.store="remoteDocumentGlobal",h_.key="remoteDocumentGlobalKey",h_);function h_(t){this.byteSize=t}var l_=(f_.store="targets",f_.keyPath="targetId",f_.queryTargetsIndexName="queryTargetsIndex",f_.queryTargetsKeyPath=["canonicalId","targetId"],f_);function f_(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 p_=(d_.store="targetDocuments",d_.keyPath=["targetId","path"],d_.documentTargetsIndex="documentTargetsIndex",d_.documentTargetsKeyPath=["path","targetId"],d_);function d_(t,e,n){this.targetId=t,this.path=e,Nm(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 y_=(m_.key="targetGlobalKey",m_.store="targetGlobal",m_);function m_(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r}var v_=(g_.store="collectionParents",g_.keyPath=["collectionId","parent"],g_);function g_(t,e){this.collectionId=t,this.parent=e}function b_(t){t.createObjectStore(p_.store,{keyPath:p_.keyPath}).createIndex(p_.documentTargetsIndex,p_.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(l_.store,{keyPath:l_.keyPath}).createIndex(l_.queryTargetsIndexName,l_.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(y_.store)}var w_=(__.store="clientMetadata",__.keyPath="clientId",__);function __(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r}var E_,T_,S_=aa(aa(aa([Zw.store,e_.store,r_.store,s_.store,l_.store,Jw.store,y_.store,p_.store],[w_.store]),[c_.store]),[v_.store]),I_=(C_.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(Nm(e.length%2==1,"Expected a collection path."),this.collectionParentsCache.has(e))return Ig.resolve();var r=e.lastSegment(),i=e.popLast();return t.addOnCommittedListener(function(){n.collectionParentsCache.add(e)}),N_(t).put({collectionId:r,parent:Kv(i)})},C_.prototype.getCollectionParents=function(t,i){var o=[],e=IDBKeyRange.bound([i,""],[cv(i),""],!1,!0);return N_(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(Gv(r.parent))}return o})},C_);function C_(){this.collectionParentsCache=new Qw}function N_(t){return X_.getStore(t,v_.store)}(T_=E_=E_||{})[T_.Listen=0]="Listen",T_[T_.ExistenceFilterMismatch=1]="ExistenceFilterMismatch",T_[T_.LimboResolution=2]="LimboResolution";var A_=(k_.prototype.withSequenceNumber=function(t){return new k_(this.query,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},k_.prototype.withResumeToken=function(t,e){return new k_(this.query,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)},k_.prototype.withLastLimboFreeSnapshotVersion=function(t){return new k_(this.query,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)},k_.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.query.isEqual(t.query)},k_);function k_(t,e,n,r,i,o,a){void 0===i&&(i=Xv.MIN),void 0===o&&(o=Xv.MIN),void 0===a&&(a=Dm()),this.query=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a}var D_=(R_.prototype.fromDbRemoteDocument=function(t){if(t.document)return this.remoteSerializer.fromDocument(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=Rv.fromSegments(t.noDocument.path),n=this.fromDbTimestamp(t.noDocument.readTime);return new Cw(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}return t.unknownDocument?(e=Rv.fromSegments(t.unknownDocument.path),n=this.fromDbTimestamp(t.unknownDocument.version),new kw(e,n)):Cm("Unexpected DbRemoteDocument")},R_.prototype.toDbRemoteDocument=function(t,e){var n=this.toDbTimestampKey(e),r=t.key.path.popLast().toArray();if(t instanceof Tw){var i=t.proto?t.proto:this.remoteSerializer.toDocument(t),o=t.hasCommittedMutations;return new s_(null,null,i,o,n,r)}if(t instanceof Cw){var a=t.key.path.toArray(),s=this.toDbTimestamp(t.version);return o=t.hasCommittedMutations,new s_(null,new o_(a,s),null,o,n,r)}if(t instanceof kw){a=t.key.path.toArray();var u=this.toDbTimestamp(t.version);return new s_(new a_(a,u),null,null,!0,n,r)}return Cm("Unexpected MaybeDocument")},R_.prototype.toDbTimestampKey=function(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]},R_.prototype.fromDbTimestampKey=function(t){var e=new zv(t[0],t[1]);return Xv.fromTimestamp(e)},R_.prototype.toDbTimestamp=function(t){var e=t.toTimestamp();return new Xw(e.seconds,e.nanoseconds)},R_.prototype.fromDbTimestamp=function(t){var e=new zv(t.seconds,t.nanoseconds);return Xv.fromTimestamp(e)},R_.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 e_(t,e.batchId,e.localWriteTime.toMillis(),r,i)},R_.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=zv.fromMillis(t.localWriteTimeMs);return new _g(t.batchId,i,n,r)},R_.prototype.toDbResourcePaths=function(t){var e=[];return t.forEach(function(t){e.push(Kv(t.path))}),e},R_.prototype.fromDbResourcePaths=function(t){for(var e=gg(),n=0,r=t;n<r.length;n++){var i=r[n];e=e.add(new Rv(Gv(i)))}return e},R_.prototype.fromDbTarget=function(t){var e,n=this.fromDbTimestamp(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.fromDbTimestamp(t.lastLimboFreeSnapshotVersion):Xv.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 A_(e,t.targetId,E_.Listen,t.lastListenSequenceNumber,n,r,i)},R_.prototype.toDbTarget=function(t){Nm(E_.Listen===t.purpose,"Only queries with purpose "+E_.Listen+" may be stored, got "+t.purpose);var e,n,r=this.toDbTimestamp(t.snapshotVersion),i=this.toDbTimestamp(t.lastLimboFreeSnapshotVersion);return e=t.query.isDocumentQuery()?this.remoteSerializer.toDocumentsTarget(t.query):this.remoteSerializer.toQueryTarget(t.query),n=t.resumeToken instanceof Uint8Array?(Nm(Ag.isMockPersistence(),"Persisting non-string stream tokens is only supported with mock persistence ."),t.resumeToken.toString()):t.resumeToken,new l_(t.targetId,t.query.canonicalId(),r,n,t.sequenceNumber,i,e)},R_);function R_(t){this.remoteSerializer=t}function O_(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],a=sv(n,i);return 0===a?sv(r,o):a}var P_=(M_.prototype.nextIndex=function(){return++this.previousIndex},M_.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();O_(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(M_.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),M_);function M_(t){this.maxElements=t,this.buffer=new ag(O_),this.previousIndex=0}var x_={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},L_=(F_.withCacheSize=function(t){return new F_(t,F_.DEFAULT_COLLECTION_PERCENTILE,F_.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},F_.COLLECTION_DISABLED=-1,F_.MINIMUM_CACHE_SIZE_BYTES=1048576,F_.DEFAULT=new F_(F_.DEFAULT_CACHE_SIZE_BYTES=41943040,F_.DEFAULT_COLLECTION_PERCENTILE=10,F_.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3),F_.DISABLED=new F_(F_.COLLECTION_DISABLED,0,0),F_);function F_(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}var U_=(q_.prototype.start=function(){Nm(null===this.gcTask,"Cannot start an already started LruScheduler"),this.garbageCollector.params.cacheSizeCollectionThreshold!==L_.COLLECTION_DISABLED&&this.scheduleGC()},q_.prototype.stop=function(){this.gcTask&&(this.gcTask.cancel(),this.gcTask=null)},Object.defineProperty(q_.prototype,"started",{get:function(){return null!==this.gcTask},enumerable:!0,configurable:!0}),q_.prototype.scheduleGC=function(){var t=this;Nm(null===this.gcTask,"Cannot schedule GC while a task is pending");var e=this.hasRun?3e5:6e4;Tm("LruGarbageCollector","Garbage collection scheduled in "+e+"ms"),this.gcTask=this.asyncQueue.enqueueAfterDelay(Pv.LruGarbageCollection,e,function(){return t.gcTask=null,t.hasRun=!0,t.localStore.collectGarbage(t.garbageCollector).then(function(){return t.scheduleGC()}).catch($_)})},q_);function q_(t,e,n){this.garbageCollector=t,this.asyncQueue=e,this.localStore=n,this.hasRun=!1,this.gcTask=null}var V_=(B_.prototype.calculateTargetCount=function(t,e){return this.delegate.getSequenceNumberCount(t).next(function(t){return Math.floor(e/100*t)})},B_.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return Ig.resolve(bv.INVALID);var r=new P_(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})},B_.prototype.removeTargets=function(t,e,n){return this.delegate.removeTargets(t,e,n)},B_.prototype.removeOrphanedDocuments=function(t,e){return this.delegate.removeOrphanedDocuments(t,e)},B_.prototype.collect=function(e,n){var r=this;return this.params.cacheSizeCollectionThreshold===L_.COLLECTION_DISABLED?(Tm("LruGarbageCollector","Garbage collection skipped; disabled"),Ig.resolve(x_)):this.getCacheSize(e).next(function(t){return t<r.params.cacheSizeCollectionThreshold?(Tm("LruGarbageCollector","Garbage collection skipped; Cache size "+t+" is lower than threshold "+r.params.cacheSizeCollectionThreshold),x_):r.runGarbageCollection(e,n)})},B_.prototype.getCacheSize=function(t){return this.delegate.getCacheSize(t)},B_.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?(Tm("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(),_m()<=lm.DEBUG&&Tm("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"),Ig.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:o,documentsRemoved:t})})},B_);function B_(t,e){this.delegate=t,this.params=e}var j_=(W_.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},W_.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},W_);function W_(){this.onCommittedListeners=[]}var K_,Q_="IndexedDbPersistence",H_="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",G_="Another tab has exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs.",z_=(Zo(Y_,K_=j_),Y_);function Y_(t,e){var n=K_.call(this)||this;return n.simpleDbTransaction=t,n.currentSequenceNumber=e,n}var X_=(J_.getStore=function(t,e){if(t instanceof z_)return Ag.getStore(t.simpleDbTransaction,e);throw Cm("IndexedDbPersistence must use instances of IndexedDbTransaction")},J_.createIndexedDbPersistence=function(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:if(!J_.isAvailable())throw new Pm(Om.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");return[4,(e=new J_(n.allowTabSynchronization,n.persistenceKey,n.clientId,n.platform,n.lruParams,n.queue,n.serializer,n.sequenceNumberSyncer)).start()];case 1:return t.sent(),[2,e]}})})},J_.prototype.start=function(){var e=this;return Nm(!this.started,"IndexedDbPersistence double-started!"),Nm(null!==this.window,"Expected 'window' to be defined"),Ag.openOrCreate(this.dbName,Gw,new zw(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",[y_.store],function(t){return eb(t)})}).then(function(t){e.listenSequence=new bv(t,e.sequenceNumberSyncer)}).then(function(){e._started=!0}).catch(function(t){return e.simpleDb&&e.simpleDb.close(),Promise.reject(t)})},J_.prototype.setPrimaryStateListener=function(n){var t=this;return this.primaryStateListener=function(e){return ea(t,void 0,void 0,function(){return na(this,function(t){return this.started?[2,n(e)]:[2]})})},n(this.isPrimary)},J_.prototype.setDatabaseDeletedListener=function(n){var t=this;this.simpleDb.setVersionChangeListener(function(e){return ea(t,void 0,void 0,function(){return na(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]}})})})},J_.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.queue.enqueueAndForget(function(){return ea(e,void 0,void 0,function(){return na(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]}})})}))},J_.prototype.updateClientMetadataAndTryBecomePrimary=function(){var n=this;return this.simpleDb.runTransaction("readwrite-idempotent",S_,function(e){return tE(e).put(new w_(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 Tm(Q_,"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})},J_.prototype.verifyPrimaryLease=function(t){var e=this;return Z_(t).get(Jw.key).next(function(t){return Ig.resolve(e.isLocalClient(t))})},J_.prototype.removeClientMetadata=function(t){return tE(t).delete(this.clientId)},J_.prototype.maybeGarbageCollectMultiClientState=function(){return ea(this,void 0,void 0,function(){var i=this;return na(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=J_.getStore(t,w_.store);return r.loadAll().next(function(t){var e=i.filterActiveClients(t,18e5),n=t.filter(function(t){return-1===e.indexOf(t)});return Ig.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]}})})},J_.prototype.scheduleClientMetadataAndPrimaryLeaseRefreshes=function(){var t=this;this.clientMetadataRefresher=this.queue.enqueueAfterDelay(Pv.ClientMetadataRefresh,4e3,function(){return t.updateClientMetadataAndTryBecomePrimary().then(function(){return t.maybeGarbageCollectMultiClientState()}).then(function(){return t.scheduleClientMetadataAndPrimaryLeaseRefreshes()})})},J_.prototype.isLocalClient=function(t){return!!t&&t.ownerId===this.clientId},J_.prototype.canActAsPrimary=function(e){var i=this;return Z_(e).get(Jw.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 Pm(Om.FAILED_PRECONDITION,G_);return!1}}return!(!i.networkEnabled||!i.inForeground)||tE(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&&Tm(Q_,"Client "+(t?"is":"is not")+" eligible for a primary lease."),t})},J_.prototype.shutdown=function(){return ea(this,void 0,void 0,function(){var e=this;return na(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",[Jw.store,w_.store],function(t){return e.releasePrimaryLeaseIfHeld(t).next(function(){return e.removeClientMetadata(t)})})];case 1:return t.sent(),this.simpleDb.close(),this.removeClientZombiedEntry(),[2]}})})},J_.prototype.filterActiveClients=function(t,e){var n=this;return t.filter(function(t){return n.isWithinAge(t.updateTimeMs,e)&&!n.isClientZombied(t.clientId)})},J_.prototype.getActiveClients=function(){var e=this;return this.simpleDb.runTransaction("readonly-idempotent",[w_.store],function(t){return tE(t).loadAll().next(function(t){return e.filterActiveClients(t,18e5).map(function(t){return t.clientId})})})},J_.clearPersistence=function(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return J_.isAvailable()?(e=n+J_.MAIN_DATABASE,[4,Ag.delete(e)]):[2,Promise.resolve()];case 1:return t.sent(),[2]}})})},Object.defineProperty(J_.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),J_.prototype.getMutationQueue=function(t){return Nm(this.started,"Cannot initialize MutationQueue before persistence is started."),qg.forUser(t,this.serializer,this.indexManager,this.referenceDelegate)},J_.prototype.getQueryCache=function(){return Nm(this.started,"Cannot initialize QueryCache before persistence is started."),this.queryCache},J_.prototype.getRemoteDocumentCache=function(){return Nm(this.started,"Cannot initialize RemoteDocumentCache before persistence is started."),this.remoteDocumentCache},J_.prototype.getIndexManager=function(){return Nm(this.started,"Cannot initialize IndexManager before persistence is started."),this.indexManager},J_.prototype.runTransaction=function(n,t,r){var i=this;Tm(Q_,"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,S_,function(e){return o=new z_(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 Sm("Failed to obtain primary lease for action '"+n+"'."),i.isPrimary=!1,i.queue.enqueueAndForget(function(){return i.primaryStateListener(!1)}),new Pm(Om.FAILED_PRECONDITION,H_);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})},J_.prototype.verifyAllowTabSynchronization=function(t){var e=this;return Z_(t).get(Jw.key).next(function(t){if(null!==t&&e.isWithinAge(t.leaseTimestampMs,5e3)&&!e.isClientZombied(t.ownerId)&&!e.isLocalClient(t)&&!t.allowTabSynchronization)throw new Pm(Om.FAILED_PRECONDITION,G_)})},J_.prototype.acquireOrExtendPrimaryLease=function(t){var e=new Jw(this.clientId,this.allowTabSynchronization,Date.now());return Z_(t).put(Jw.key,e)},J_.isAvailable=function(){return Ag.isAvailable()},J_.buildStoragePrefix=function(t){var e=t.databaseId.projectId;return t.databaseId.isDefaultDatabase||(e+="."+t.databaseId.database),"firestore/"+t.persistenceKey+"/"+e+"/"},J_.prototype.releasePrimaryLeaseIfHeld=function(t){var e=this,n=Z_(t);return n.get(Jw.key).next(function(t){return e.isLocalClient(t)?(Tm(Q_,"Releasing primary lease."),n.delete(Jw.key)):Ig.resolve()})},J_.prototype.isWithinAge=function(t,e){var n=Date.now();return!(t<n-e||n<t&&(Sm("Detected an update time that is in the future: "+t+" > "+n),1))},J_.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)},J_.prototype.detachVisibilityHandler=function(){this.documentVisibilityHandler&&(Nm(null!==this.document&&"function"==typeof this.document.addEventListener,"Expected 'document.addEventListener' to be a function"),this.document.removeEventListener("visibilitychange",this.documentVisibilityHandler),this.documentVisibilityHandler=null)},J_.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))},J_.prototype.detachWindowUnloadHook=function(){this.windowUnloadHandler&&(Nm("function"==typeof this.window.removeEventListener,"Expected 'window.removeEventListener' to be a function"),this.window.removeEventListener("unload",this.windowUnloadHandler),this.windowUnloadHandler=null)},J_.prototype.isClientZombied=function(t){try{var e=null!==this.webStorage.getItem(this.zombiedClientLocalStorageKey(t));return Tm(Q_,"Client '"+t+"' "+(e?"is":"is not")+" zombied in LocalStorage"),e}catch(t){return Sm(Q_,"Failed to get zombied client id.",t),!1}},J_.prototype.markClientZombied=function(){try{this.webStorage.setItem(this.zombiedClientLocalStorageKey(this.clientId),String(Date.now()))}catch(t){Sm("Failed to set zombie client id.",t)}},J_.prototype.removeClientZombiedEntry=function(){try{this.webStorage.removeItem(this.zombiedClientLocalStorageKey(this.clientId))}catch(t){}},J_.prototype.zombiedClientLocalStorageKey=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},J_.MAIN_DATABASE="main",J_);function J_(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 eE(this,i),this.dbName=e+J_.MAIN_DATABASE,this.serializer=new D_(a),this.document=r.document,this.queryCache=new Jg(this.referenceDelegate,this.serializer),this.indexManager=new I_,this.remoteDocumentCache=new Lw(this.serializer,this.indexManager),!r.window||!r.window.localStorage)throw new Pm(Om.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");this.window=r.window,this.webStorage=this.window.localStorage}function $_(e){return ea(this,void 0,void 0,function(){return na(this,function(t){if(!function(t){return t.code===Om.FAILED_PRECONDITION&&t.message===H_}(e))throw e;return Tm(Q_,"Unexpectedly lost primary lease"),[2]})})}function Z_(t){return t.store(Jw.store)}function tE(t){return t.store(w_.store)}var eE=(nE.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocmentCount(t);return this.db.getQueryCache().getQueryCount(t).next(function(e){return n.next(function(t){return e+t})})},nE.prototype.orphanedDocmentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},nE.prototype.forEachTarget=function(t,e){return this.db.getQueryCache().forEachTarget(t,e)},nE.prototype.forEachOrphanedDocumentSequenceNumber=function(t,n){return this.forEachOrphanedDocument(t,function(t,e){return n(e)})},nE.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},nE.prototype.addReference=function(t,e){return rE(t,e)},nE.prototype.removeReference=function(t,e){return rE(t,e)},nE.prototype.removeTargets=function(t,e,n){return this.db.getQueryCache().removeTargets(t,e,n)},nE.prototype.removeMutationReference=function(t,e){return rE(t,e)},nE.prototype.isPinned=function(t,e){return this.inMemoryPins.containsKey(e)?Ig.resolve(!0):function(e,n){var r=!1;return Hg(e).iterateSerial(function(t){return Bg(e,t,n).next(function(t){return t&&(r=!0),Ig.resolve(!t)})}).next(function(){return r})}(t,e)},nE.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),nb(r).delete(function(t){return[0,Kv(t.path)]}(e))})});s.push(n)}}).next(function(){return Ig.waitFor(s)}).next(function(){return a.apply(r)}).next(function(){return u})},nE.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getQueryCache().updateQueryData(t,n)},nE.prototype.updateLimboDocument=function(t,e){return rE(t,e)},nE.prototype.forEachOrphanedDocument=function(t,o){var a,e=nb(t),s=bv.INVALID;return e.iterate({index:p_.documentTargetsIndex},function(t,e){var n=t[0],r=(t[1],e.path),i=e.sequenceNumber;0===n?(s!==bv.INVALID&&o(new Rv(Gv(a)),s),s=i,a=r):s=bv.INVALID}).next(function(){s!==bv.INVALID&&o(new Rv(Gv(a)),s)})},nE.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},nE);function nE(t,e){this.db=t,this.inMemoryPins=null,this.garbageCollector=new V_(this,e)}function rE(t,e){return nb(t).put(function(t,e){return new p_(0,Kv(t.path),e)}(e,t.currentSequenceNumber))}var iE=(oE.prototype.getDocument=function(e,n){var r=this;return this.mutationQueue.getAllMutationBatchesAffectingDocumentKey(e,n).next(function(t){return r.getDocumentInternal(e,n,t)})},oE.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})},oE.prototype.applyLocalMutationsToDocuments=function(t,e,i){var o=fg();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},oE.prototype.getDocuments=function(e,t){var n=this;return this.remoteDocumentCache.getEntries(e,t).next(function(t){return n.getLocalViewOfDocuments(e,t)})},oE.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=lg();return e.forEach(function(t,e){e=e||new Cw(t,Xv.forDeletedDoc()),n=n.insert(t,e)}),n})},oE.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)},oE.prototype.getDocumentsMatchingDocumentQuery=function(t,e){return this.getDocument(t,new Rv(e)).next(function(t){var e=dg();return t instanceof Tw&&(e=e.insert(t.key,t)),e})},oE.prototype.getDocumentsMatchingCollectionGroupQuery=function(n,r,i){var o=this;Nm(r.path.isEmpty(),"Currently we only support collection group queries at the root.");var a=r.collectionGroup,s=dg();return this.indexManager.getCollectionParents(n,a).next(function(t){return Ig.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})})},oE.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 Tw?h.insert(s,c):h.remove(s)}})}).next(function(){return h.forEach(function(t,e){n.matches(e)||(h=h.remove(t))}),h})},oE.prototype.addMissingBaseDocuments=function(t,e,n){for(var r=gg(),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 gb&&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 Tw&&(c=c.insert(t,e))}),c})},oE);function oE(t,e,n){this.remoteDocumentCache=t,this.mutationQueue=e,this.indexManager=n}var aE=(sE.prototype.isEmpty=function(){return this.refsByKey.isEmpty()},sE.prototype.addReference=function(t,e){var n=new uE(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 uE(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=Rv.EMPTY,r=new uE(n,t),i=new uE(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=Rv.EMPTY,n=new uE(e,t),r=new uE(e,t+1),i=gg();return this.refsByTarget.forEachInRange([n,r],function(t){i=i.add(t.key)}),i},sE.prototype.containsKey=function(t){var e=new uE(t,0),n=this.refsByKey.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},sE);function sE(){this.refsByKey=new ag(uE.compareByKey),this.refsByTarget=new ag(uE.compareByTargetId)}var uE=(cE.compareByKey=function(t,e){return Rv.comparator(t.key,e.key)||sv(t.targetOrBatchId,e.targetOrBatchId)},cE.compareByTargetId=function(t,e){return sv(t.targetOrBatchId,e.targetOrBatchId)||Rv.comparator(t.key,e.key)},cE);function cE(t,e){this.key=t,this.targetOrBatchId=e}var hE="LocalStore",lE=(fE.prototype.start=function(){return this.synchronizeLastDocumentChangeReadTime()},fE.prototype.handleUserChange=function(i){return ea(this,void 0,void 0,function(){var e,m,n,r=this;return na(this,function(t){switch(t.label){case 0:return e=this.mutationQueue,m=this.localDocuments,[4,this.persistence.runTransaction("Handle user change","readonly-idempotent",function(d){var y;return r.mutationQueue.getAllMutationBatches(d).next(function(t){return y=t,e=r.persistence.getMutationQueue(i),m=new iE(r.remoteDocuments,e,r.persistence.getIndexManager()),e.getAllMutationBatches(d)}).next(function(t){for(var e=[],n=[],r=gg(),i=0,o=y;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 m.getDocuments(d,r).next(function(t){return{affectedDocuments:t,removedBatchIds:e,addedBatchIds:n}})})})];case 1:return n=t.sent(),this.mutationQueue=e,this.localDocuments=m,this.queryEngine.setLocalDocumentsView(this.localDocuments),[2,n]}})})},fE.prototype.localWrite=function(s){var u,c=this,h=zv.now(),t=s.reduce(function(t,e){return t.add(e.key)},gg());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 gb(i.key,o,o.fieldMask(),hb.exists(!0)))}return c.mutationQueue.addMutationBatch(a,h,e,s)})}).then(function(t){var e=t.applyToLocalDocumentSet(u);return{batchId:t.batchId,changes:e}})},fE.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):Ig.resolve(null)})})},fE.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)})})},fE.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 Nm(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)})})},fE.prototype.getHighestUnacknowledgedBatchId=function(){var e=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly-idempotent",function(t){return e.mutationQueue.getHighestUnacknowledgedBatchId(t)})},fE.prototype.getLastStreamToken=function(){var e=this;return this.persistence.runTransaction("Get last stream token","readonly-idempotent",function(t){return e.mutationQueue.getLastStreamToken(t)})},fE.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)})},fE.prototype.getLastRemoteSnapshotVersion=function(){var e=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly-idempotent",function(t){return e.queryCache.getLastRemoteSnapshotVersion(t)})},fE.prototype.applyRemoteEvent=function(u){var c=this,h=u.snapshotVersion,l=this.queryDataByTarget;return this.persistence.runTransaction("Apply remote event","readwrite-primary-idempotent",function(o){var i=c.remoteDocuments.newChangeBuffer({trackRemovals:!0});l=c.queryDataByTarget;var a=[];Um(u.targetChanges,function(t,e){var n=l.get(t);if(n){a.push(c.queryCache.removeMatchingKeys(o,e.removedDocuments,t).next(function(){return c.queryCache.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),fE.shouldPersistQueryData(n,i,e)&&a.push(c.queryCache.updateQueryData(o,i))}}});var s=lg(),n=gg();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 Cw&&e.version.isEqual(Xv.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?(Xv.MIN.isEqual(h)&&Sm(hE,"Cannot add a document when the remote version is zero"),i.addEntry(e,h),s=s.insert(t,e)):Tm(hE,"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(Xv.MIN)){var t=c.queryCache.getLastRemoteSnapshotVersion(o).next(function(t){return Nm(0<=h.compareTo(t),"Watch stream reverted to previous snapshot?? "+h+" < "+t),c.queryCache.setTargetsMetadata(o,o.currentSequenceNumber,h)});a.push(t)}return Ig.waitFor(a).next(function(){return i.apply(o)}).next(function(){return c.localDocuments.getLocalViewOfDocuments(o,s)})}).then(function(t){return c.queryDataByTarget=l,t})},fE.shouldPersistQueryData=function(t,e,n){return Nm(0<e.resumeToken.length,"Attempted to persist query 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},fE.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.queryDataByTarget.get(o);Nm(null!==a,"Can't set limbo-free snapshot version for unknown target: "+o);var s=a.snapshotVersion,u=a.withLastLimboFreeSnapshotVersion(s);this.queryDataByTarget=this.queryDataByTarget.insert(o,u)}}return this.persistence.runTransaction("notifyLocalViewChanges","readwrite-idempotent",function(e){return Ig.forEach(t,function(t){return Ig.forEach(t.removedKeys,function(t){return n.persistence.referenceDelegate.removeReference(e,t)})})})},fE.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)})},fE.prototype.readDocument=function(e){var n=this;return this.persistence.runTransaction("read document","readonly-idempotent",function(t){return n.localDocuments.getDocument(t,e)})},fE.prototype.allocateQuery=function(r){var i=this;return this.persistence.runTransaction("Allocate query","readwrite-idempotent",function(e){var n;return i.queryCache.getQueryData(e,r).next(function(t){return t?(n=t,Ig.resolve(n)):i.queryCache.allocateTargetId(e).next(function(t){return n=new A_(r,t,E_.Listen,e.currentSequenceNumber),i.queryCache.addQueryData(e,n).next(function(){return n})})})}).then(function(t){return Nm(null===i.queryDataByTarget.get(t.targetId),"Tried to allocate an already allocated query: "+r),i.queryDataByTarget=i.queryDataByTarget.insert(t.targetId,t),i.targetIdByQuery.set(r,t.targetId),t})},fE.prototype.getQueryData=function(t,e){var n=this.targetIdByQuery.get(e);return void 0!==n?Ig.resolve(this.queryDataByTarget.get(n)):this.queryCache.getQueryData(t,e)},fE.prototype.releaseQuery=function(i,o){var a,s=this,t=o?"readwrite-idempotent":"readwrite-primary-idempotent";return this.persistence.runTransaction("Release query",t,function(e){var t=s.targetIdByQuery.get(i);Nm(void 0!==t,"Tried to release nonexistent query: "+i),a=t;var n=s.queryDataByTarget.get(a),r=s.localViewReferences.removeReferencesForId(a);return o?Ig.resolve():Ig.forEach(r,function(t){return s.persistence.referenceDelegate.removeReference(e,t)}).next(function(){s.persistence.referenceDelegate.removeTarget(e,n)})}).then(function(){s.queryDataByTarget=s.queryDataByTarget.remove(a),s.targetIdByQuery.delete(i)})},fE.prototype.executeQuery=function(t,n){var r=this,i=Xv.MIN,o=gg();return this.persistence.runTransaction("Execute query","readonly-idempotent",function(e){return r.getQueryData(e,t).next(function(t){if(t)return i=t.lastLimboFreeSnapshotVersion,r.queryCache.getMatchingKeysForTargetId(e,t.targetId).next(function(t){o=t})}).next(function(){return r.queryEngine.getDocumentsMatchingQuery(e,t,n?i:Xv.MIN,n?o:gg())}).next(function(t){return{documents:t,remoteKeys:o}})})},fE.prototype.remoteDocumentKeys=function(e){var n=this;return this.persistence.runTransaction("Remote document keys","readonly-idempotent",function(t){return n.queryCache.getMatchingKeysForTargetId(t,e)})},fE.prototype.getActiveClients=function(){return this.persistence.getActiveClients()},fE.prototype.removeCachedMutationBatchMetadata=function(t){this.mutationQueue.removeCachedMutationKeys(t)},fE.prototype.setNetworkEnabled=function(t){this.persistence.setNetworkEnabled(t)},fE.prototype.applyWriteToRemoteDocuments=function(t,i,o){var e=this,a=i.batch,n=a.keys(),s=Ig.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);Nm(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):Nm(!t,"Mutation batch "+a+" applied to document "+t+" resulted in null"))})}),s.next(function(){return e.mutationQueue.removeMutationBatch(t,a)})},fE.prototype.collectGarbage=function(e){var n=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary-idempotent",function(t){return e.collect(t,n.queryDataByTarget)})},fE.prototype.getQueryForTarget=function(e){var n=this,t=this.queryDataByTarget.get(e);return t?Promise.resolve(t.query):this.persistence.runTransaction("Get query data","readonly-idempotent",function(t){return n.queryCache.getQueryDataForTarget(t,e).next(function(t){return t?t.query:null})})},fE.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})},fE.prototype.synchronizeLastDocumentChangeReadTime=function(){return ea(this,void 0,void 0,function(){var e,n=this;return na(this,function(t){return this.remoteDocuments instanceof Lw?(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]})})},fE.RESUME_TOKEN_MAX_AGE_MICROS=3e8,fE);function fE(t,e,n){this.persistence=t,this.queryEngine=e,this.localViewReferences=new aE,this.queryDataByTarget=new $v(sv),this.targetIdByQuery=new Rw(function(t){return t.canonicalId()}),this.lastDocumentChangeReadTime=Xv.MIN,Nm(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.queryCache=t.getQueryCache(),this.localDocuments=new iE(this.remoteDocuments,this.mutationQueue,this.persistence.getIndexManager()),this.queryEngine.setLocalDocumentsView(this.localDocuments)}var pE=(dE.prototype.checkEmpty=function(t){return Ig.resolve(0===this.mutationQueue.length)},dE.prototype.acknowledgeBatch=function(t,e,n){var r=e.batchId,i=this.indexOfExistingBatchId(r,"acknowledged");Nm(0===i,"Can only acknowledge the first batch in the mutation queue");var o=this.mutationQueue[i];return Nm(r===o.batchId,"Queue ordering failure: expected batch "+r+", got batch "+o.batchId),this.lastStreamToken=n,Ig.resolve()},dE.prototype.getLastStreamToken=function(t){return Ig.resolve(this.lastStreamToken)},dE.prototype.setLastStreamToken=function(t,e){return this.lastStreamToken=e,Ig.resolve()},dE.prototype.addMutationBatch=function(t,e,n,r){Nm(0!==r.length,"Mutation batches should not be empty");var i=this.nextBatchId;this.nextBatchId++,0<this.mutationQueue.length&&Nm(this.mutationQueue[this.mutationQueue.length-1].batchId<i,"Mutation batchIDs must be monotonically increasing order");var o=new _g(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 uE(u.key,i)),this.indexManager.addToCollectionParentIndex(t,u.key.path.popLast())}return Ig.resolve(o)},dE.prototype.lookupMutationBatch=function(t,e){return Ig.resolve(this.findMutationBatch(e))},dE.prototype.lookupMutationKeys=function(t,e){var n=this.findMutationBatch(e);return Nm(null!=n,"Failed to find local mutation batch."),Ig.resolve(n.keys())},dE.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=e+1,r=this.indexOfBatchId(n),i=r<0?0:r;return Ig.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)},dE.prototype.getHighestUnacknowledgedBatchId=function(){return Ig.resolve(0===this.mutationQueue.length?-1:this.nextBatchId-1)},dE.prototype.getAllMutationBatches=function(t){return Ig.resolve(this.mutationQueue.slice())},dE.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,n){var r=this,e=new uE(n,0),i=new uE(n,Number.POSITIVE_INFINITY),o=[];return this.batchesByDocumentKey.forEachInRange([e,i],function(t){Nm(n.isEqual(t.key),"Should only iterate over a single key's batches");var e=r.findMutationBatch(t.targetOrBatchId);Nm(null!==e,"Batches in the index must exist in the main table"),o.push(e)}),Ig.resolve(o)},dE.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var r=this,i=new ag(sv);return e.forEach(function(e){var t=new uE(e,0),n=new uE(e,Number.POSITIVE_INFINITY);r.batchesByDocumentKey.forEachInRange([t,n],function(t){Nm(e.isEqual(t.key),"For each key, should only iterate over a single key's batches"),i=i.add(t.targetOrBatchId)})}),Ig.resolve(this.findMutationBatches(i))},dE.prototype.getAllMutationBatchesAffectingQuery=function(t,e){Nm(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");var n=e.path,r=n.length+1,i=n;Rv.isDocumentKey(i)||(i=i.child(""));var o=new uE(new Rv(i),0),a=new ag(sv);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),Ig.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;Nm(0===this.indexOfExistingBatchId(r.batchId,"removed"),"Can only remove the first entry of the mutation queue"),this.mutationQueue.shift();var o=this.batchesByDocumentKey;return Ig.forEach(r.mutations,function(t){var e=new uE(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 uE(e,0),r=this.batchesByDocumentKey.firstAfterOrEqual(n);return Ig.resolve(e.isEqual(r&&r.key))},dE.prototype.performConsistencyCheck=function(t){return 0===this.mutationQueue.length&&Nm(this.batchesByDocumentKey.isEmpty(),"Document leak -- detected dangling mutation references when queue is empty."),Ig.resolve()},dE.prototype.indexOfExistingBatchId=function(t,e){var n=this.indexOfBatchId(t);return Nm(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 Nm(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=Dm(),this.batchesByDocumentKey=new ag(uE.compareByKey)}var yE=(mE.prototype.getTargetCount=function(t){return Ig.resolve(this.targetCount)},mE.prototype.forEachTarget=function(t,n){return this.queries.forEach(function(t,e){return n(e)}),Ig.resolve()},mE.prototype.getLastRemoteSnapshotVersion=function(t){return Ig.resolve(this.lastRemoteSnapshotVersion)},mE.prototype.getHighestSequenceNumber=function(t){return Ig.resolve(this.highestSequenceNumber)},mE.prototype.allocateTargetId=function(t){var e=this.targetIdGenerator.after(this.highestTargetId);return this.highestTargetId=e,Ig.resolve(e)},mE.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.highestSequenceNumber&&(this.highestSequenceNumber=e),Ig.resolve()},mE.prototype.saveQueryData=function(t){this.queries.set(t.query,t);var e=t.targetId;e>this.highestTargetId&&(this.highestTargetId=e),t.sequenceNumber>this.highestSequenceNumber&&(this.highestSequenceNumber=t.sequenceNumber)},mE.prototype.addQueryData=function(t,e){return Nm(!this.queries.has(e.query),"Adding a query that already exists"),this.saveQueryData(e),this.targetCount+=1,Ig.resolve()},mE.prototype.updateQueryData=function(t,e){return Nm(this.queries.has(e.query),"Updating a non-existent query"),this.saveQueryData(e),Ig.resolve()},mE.prototype.removeQueryData=function(t,e){return Nm(0<this.targetCount,"Removing a target from an empty cache"),Nm(this.queries.has(e.query),"Removing a non-existent target from the cache"),this.queries.delete(e.query),this.references.removeReferencesForId(e.targetId),this.targetCount-=1,Ig.resolve()},mE.prototype.removeTargets=function(n,r,i){var o=this,a=0,s=[];return this.queries.forEach(function(t,e){e.sequenceNumber<=r&&null===i.get(e.targetId)&&(o.queries.delete(t),s.push(o.removeMatchingKeysForTargetId(n,e.targetId)),a++)}),Ig.waitFor(s).next(function(){return a})},mE.prototype.getQueryCount=function(t){return Ig.resolve(this.targetCount)},mE.prototype.getQueryData=function(t,e){var n=this.queries.get(e)||null;return Ig.resolve(n)},mE.prototype.getQueryDataForTarget=function(t,e){return Cm("Not yet implemented.")},mE.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))}),Ig.waitFor(i)},mE.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))}),Ig.waitFor(i)},mE.prototype.removeMatchingKeysForTargetId=function(t,e){return this.references.removeReferencesForId(e),Ig.resolve()},mE.prototype.getMatchingKeysForTargetId=function(t,e){var n=this.references.referencesForId(e);return Ig.resolve(n)},mE.prototype.containsKey=function(t,e){return Ig.resolve(this.references.containsKey(e))},mE);function mE(t){this.persistence=t,this.queries=new Rw(function(t){return t.canonicalId()}),this.lastRemoteSnapshotVersion=Xv.MIN,this.highestTargetId=0,this.highestSequenceNumber=0,this.references=new aE,this.targetCount=0,this.targetIdGenerator=Yg.forQueryCache()}var vE,gE=(bE.prototype.addEntry=function(t,e,n){Nm(!n.isEqual(Xv.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())},bE.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},bE.prototype.getEntry=function(t,e){var n=this.docs.get(e);return Ig.resolve(n?n.maybeDocument:null)},bE.prototype.getEntries=function(t,e){var n=this,r=fg();return e.forEach(function(t){var e=n.docs.get(t);r=r.insert(t,e?e.maybeDocument:null)}),Ig.resolve(r)},bE.prototype.getDocumentsMatchingQuery=function(t,e,n){Nm(!e.isCollectionGroupQuery(),"CollectionGroup queries should be handled in LocalDocumentsView");for(var r=dg(),i=new Rv(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 Tw&&e.matches(c)&&(r=r.insert(c.key,c))}return Ig.resolve(r)},bE.prototype.forEachDocumentKey=function(t,e){return Ig.forEach(this.docs,function(t){return e(t)})},bE.prototype.getNewDocumentChanges=function(t,e){throw new Error("getNewDocumentChanges() is not supported with MemoryPersistence")},bE.prototype.newChangeBuffer=function(t){return new bE.RemoteDocumentChangeBuffer(this)},bE.prototype.getSize=function(t){return Ig.resolve(this.size)},bE.RemoteDocumentChangeBuffer=(Zo(wE,vE=Pw),wE.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)}),Ig.waitFor(i)},wE.prototype.getFromCache=function(t,e){return this.documentCache.getEntry(t,e)},wE.prototype.getAllFromCache=function(t,e){return this.documentCache.getEntries(t,e)},wE),bE);function bE(t,e){this.indexManager=t,this.sizer=e,this.docs=new $v(Rv.comparator),this.size=0}function wE(t){var e=vE.call(this)||this;return e.documentCache=t,e}var _E=(EE.createLruPersistence=function(t,e,n){return new EE(t,function(t){return new AE(t,new D_(e),n)})},EE.createEagerPersistence=function(t){return new EE(t,function(t){return new CE(t)})},EE.prototype.shutdown=function(){return this._started=!1,Promise.resolve()},Object.defineProperty(EE.prototype,"started",{get:function(){return this._started},enumerable:!0,configurable:!0}),EE.prototype.getActiveClients=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){return[2,[this.clientId]]})})},EE.prototype.setPrimaryStateListener=function(t){return t(!0)},EE.prototype.setDatabaseDeletedListener=function(){},EE.prototype.setNetworkEnabled=function(t){},EE.prototype.getIndexManager=function(){return this.indexManager},EE.prototype.getMutationQueue=function(t){var e=this.mutationQueues[t.toKey()];return e||(e=new pE(this.indexManager,this.referenceDelegate),this.mutationQueues[t.toKey()]=e),e},EE.prototype.getQueryCache=function(){return this.queryCache},EE.prototype.getRemoteDocumentCache=function(){return this.remoteDocumentCache},EE.prototype.runTransaction=function(t,e,n){var r=this;Tm("MemoryPersistence","Starting transaction:",t);var i=new SE(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})},EE.prototype.mutationQueuesContainKey=function(e,n){return Ig.or(function(t){var n=[];return qm(t,function(t,e){return n.push(e)}),n}(this.mutationQueues).map(function(t){return function(){return t.containsKey(e,n)}}))},EE);function EE(t,e){var n=this;this.clientId=t,this.mutationQueues={},this.listenSequence=new bv(0),this._started=!1,this._started=!0,this.referenceDelegate=e(this),this.queryCache=new yE(this);this.indexManager=new Ww,this.remoteDocumentCache=new gE(this.indexManager,function(t){return n.referenceDelegate.documentSize(t)})}var TE,SE=(Zo(IE,TE=j_),IE);function IE(t){var e=TE.call(this)||this;return e.currentSequenceNumber=t,e}var CE=(Object.defineProperty(NE.prototype,"orphanedDocuments",{get:function(){if(this._orphanedDocuments)return this._orphanedDocuments;throw Cm("orphanedDocuments is only valid during a transaction.")},enumerable:!0,configurable:!0}),NE.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},NE.prototype.addReference=function(t,e){return this.orphanedDocuments.delete(e),Ig.resolve()},NE.prototype.removeReference=function(t,e){return this.orphanedDocuments.add(e),Ig.resolve()},NE.prototype.removeMutationReference=function(t,e){return this.orphanedDocuments.add(e),Ig.resolve()},NE.prototype.removeTarget=function(t,e){var n=this,r=this.persistence.getQueryCache();return r.getMatchingKeysForTargetId(t,e.targetId).next(function(t){t.forEach(function(t){return n.orphanedDocuments.add(t)})}).next(function(){return r.removeQueryData(t,e)})},NE.prototype.onTransactionStarted=function(){this._orphanedDocuments=new Set},NE.prototype.onTransactionCommitted=function(t){var n=this,r=this.persistence.getRemoteDocumentCache().newChangeBuffer();return Ig.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)})},NE.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)})},NE.prototype.documentSize=function(t){return 0},NE.prototype.isReferenced=function(t,e){var n=this;return Ig.or([function(){return n.persistence.getQueryCache().containsKey(t,e)},function(){return n.persistence.mutationQueuesContainKey(t,e)},function(){return Ig.resolve(n.inMemoryPins.containsKey(e))}])},NE);function NE(t){this.persistence=t,this.inMemoryPins=null,this._orphanedDocuments=null}var AE=(kE.prototype.onTransactionStarted=function(){},kE.prototype.onTransactionCommitted=function(t){return Ig.resolve()},kE.prototype.forEachTarget=function(t,e){return this.persistence.getQueryCache().forEachTarget(t,e)},kE.prototype.getSequenceNumberCount=function(t){var n=this.orphanedDocumentCount(t);return this.persistence.getQueryCache().getTargetCount(t).next(function(e){return n.next(function(t){return e+t})})},kE.prototype.orphanedDocumentCount=function(t){var e=0;return this.forEachOrphanedDocumentSequenceNumber(t,function(t){e++}).next(function(){return e})},kE.prototype.forEachOrphanedDocumentSequenceNumber=function(n,r){var i=this;return Ig.forEach(this.orphanedSequenceNumbers,function(t,e){return i.isPinned(n,t,e).next(function(t){return t?Ig.resolve():r(e)})})},kE.prototype.setInMemoryPins=function(t){this.inMemoryPins=t},kE.prototype.removeTargets=function(t,e,n){return this.persistence.getQueryCache().removeTargets(t,e,n)},kE.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})},kE.prototype.removeMutationReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Ig.resolve()},kE.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.persistence.getQueryCache().updateQueryData(t,n)},kE.prototype.addReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Ig.resolve()},kE.prototype.removeReference=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Ig.resolve()},kE.prototype.updateLimboDocument=function(t,e){return this.orphanedSequenceNumbers.set(e,t.currentSequenceNumber),Ig.resolve()},kE.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 Cm("Unknown remote document type");e=n.noDocument}return JSON.stringify(e).length},kE.prototype.isPinned=function(t,e,n){var r=this;return Ig.or([function(){return r.persistence.mutationQueuesContainKey(t,e)},function(){return Ig.resolve(r.inMemoryPins.containsKey(e))},function(){return r.persistence.getQueryCache().containsKey(t,e)},function(){var t=r.orphanedSequenceNumbers.get(e);return Ig.resolve(void 0!==t&&n<t)}])},kE.prototype.getCacheSize=function(t){return this.persistence.getRemoteDocumentCache().getSize(t)},kE);function kE(t,e,n){this.persistence=t,this.serializer=e,this.inMemoryPins=null,this.orphanedSequenceNumbers=new Rw(function(t){return Kv(t.path)}),this.garbageCollector=new V_(this,n)}var DE=(RE.prototype.setLocalDocumentsView=function(t){this.localDocumentsView=t},RE.prototype.getDocumentsMatchingQuery=function(t,e,n,r){return Nm(void 0!==this.localDocumentsView,"setLocalDocumentsView() not called"),this.localDocumentsView.getDocumentsMatchingQuery(t,e,Xv.MIN)},RE);function RE(){}var OE=Number,PE=OE.MIN_SAFE_INTEGER||-(Math.pow(2,53)-1),ME=OE.MAX_SAFE_INTEGER||Math.pow(2,53)-1,xE=OE.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t};function LE(t){return null==t}function FE(t){return xE(t)&&t<=ME&&PE<=t}var UE=(qE.prototype.reset=function(){this.currentBaseMs=0},qE.prototype.resetToMax=function(){this.currentBaseMs=this.maxDelayMs},qE.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&&Tm("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)},qE.prototype.cancel=function(){null!==this.timerPromise&&(this.timerPromise.cancel(),this.timerPromise=null)},qE.prototype.jitterDelayMs=function(){return(Math.random()-.5)*this.currentBaseMs},qE);function qE(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 VE,BE,jE="PersistentStream";(BE=VE=VE||{})[BE.Initial=0]="Initial",BE[BE.Starting=1]="Starting",BE[BE.Open=2]="Open",BE[BE.Error=3]="Error",BE[BE.Backoff=4]="Backoff";var WE=(KE.prototype.isStarted=function(){return this.state===VE.Starting||this.state===VE.Open||this.state===VE.Backoff},KE.prototype.isOpen=function(){return this.state===VE.Open},KE.prototype.start=function(){this.state!==VE.Error?(Nm(this.state===VE.Initial,"Already started"),this.auth()):this.performBackoff()},KE.prototype.stop=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return this.isStarted()?[4,this.close(VE.Initial)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},KE.prototype.inhibitBackoff=function(){Nm(!this.isStarted(),"Can only inhibit backoff in a stopped state"),this.state=VE.Initial,this.backoff.reset()},KE.prototype.markIdle=function(){var t=this;this.isOpen()&&null===this.idleTimer&&(this.idleTimer=this.queue.enqueueAfterDelay(this.idleTimerId,6e4,function(){return t.handleIdleCloseTimer()}))},KE.prototype.sendRequest=function(t){this.cancelIdleCheck(),this.stream.send(t)},KE.prototype.handleIdleCloseTimer=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){return this.isOpen()?[2,this.close(VE.Initial)]:[2]})})},KE.prototype.cancelIdleCheck=function(){this.idleTimer&&(this.idleTimer.cancel(),this.idleTimer=null)},KE.prototype.close=function(e,n){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return Nm(this.isStarted(),"Only started streams should be closed."),Nm(e===VE.Error||LE(n),"Can't provide an error when not in an error state."),this.cancelIdleCheck(),this.backoff.cancel(),this.closeCount++,e!==VE.Error?this.backoff.reset():n&&n.code===Om.RESOURCE_EXHAUSTED?(Sm(n.toString()),Sm("Using maximum backoff delay to prevent overloading the backend."),this.backoff.resetToMax()):n&&n.code===Om.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]}})})},KE.prototype.tearDown=function(){},KE.prototype.auth=function(){var n=this;Nm(this.state===VE.Initial,"Must be in initial state to auth"),this.state=VE.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 Pm(Om.UNKNOWN,"Fetching auth token failed: "+e.message);return n.handleStreamClose(t)})})},KE.prototype.startStream=function(t){var e=this;Nm(this.state===VE.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 Nm(e.state===VE.Starting,"Expected stream to be in state Starting, but was "+e.state),e.state=VE.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)})})},KE.prototype.performBackoff=function(){var t=this;Nm(this.state===VE.Error,"Should only perform backoff when in Error state"),this.state=VE.Backoff,this.backoff.backoffAndRun(function(){return ea(t,void 0,void 0,function(){return na(this,function(t){return Nm(this.state===VE.Backoff,"Backoff elapsed but state is now: "+this.state),this.state=VE.Initial,this.start(),Nm(this.isStarted(),"PersistentStream should have started"),[2]})})})},KE.prototype.handleStreamClose=function(t){return Nm(this.isStarted(),"Can't handle server close on non-started stream"),Tm(jE,"close with error: "+t),this.stream=null,this.close(VE.Error,t)},KE.prototype.getCloseGuardedDispatcher=function(e){var n=this;return function(t){n.queue.enqueueAndForget(function(){return n.closeCount===e?t():(Tm(jE,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},KE);function KE(t,e,n,r,i,o){this.queue=t,this.idleTimerId=n,this.connection=r,this.credentialsProvider=i,this.listener=o,this.state=VE.Initial,this.closeCount=0,this.idleTimer=null,this.stream=null,this.backoff=new UE(t,e)}var QE,HE=(Zo(GE,QE=WE),GE.prototype.startRpc=function(t){return this.connection.openStream("Listen",t)},GE.prototype.onMessage=function(t){this.backoff.reset();var e=this.serializer.fromWatchChange(t),n=this.serializer.versionFromListenResponse(t);return this.listener.onWatchChange(e,n)},GE.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)},GE.prototype.unwatch=function(t){var e={};e.database=this.serializer.encodedDatabaseId,e.removeTarget=t,this.sendRequest(e)},GE);function GE(t,e,n,r,i){var o=QE.call(this,t,Pv.ListenStreamConnectionBackoff,Pv.ListenStreamIdle,e,n,i)||this;return o.serializer=r,o}var zE,YE=(Zo(XE,zE=WE),Object.defineProperty(XE.prototype,"handshakeComplete",{get:function(){return this.handshakeComplete_},enumerable:!0,configurable:!0}),XE.prototype.start=function(){this.handshakeComplete_=!1,zE.prototype.start.call(this)},XE.prototype.tearDown=function(){this.handshakeComplete_&&this.writeMutations([])},XE.prototype.startRpc=function(t){return this.connection.openStream("Write",t)},XE.prototype.onMessage=function(t){if(Nm(!!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 Nm(!t.writeResults||0===t.writeResults.length,"Got mutation results for handshake"),this.handshakeComplete_=!0,this.listener.onHandshakeComplete()},XE.prototype.writeHandshake=function(){Nm(this.isOpen(),"Writing handshake requires an opened stream"),Nm(!this.handshakeComplete_,"Handshake already completed");var t={};t.database=this.serializer.encodedDatabaseId,this.sendRequest(t)},XE.prototype.writeMutations=function(t){var e=this;Nm(this.isOpen(),"Writing mutations requires an opened stream"),Nm(this.handshakeComplete_,"Handshake must be complete before writing mutations"),Nm(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)},XE);function XE(t,e,n,r,i){var o=zE.call(this,t,Pv.WriteStreamConnectionBackoff,Pv.WriteStreamIdle,e,n,i)||this;return o.serializer=r,o.handshakeComplete_=!1,o.lastStreamToken=Dm(),o}var JE=($E.prototype.newPersistentWriteStream=function(t){return new YE(this.queue,this.connection,this.credentials,this.serializer,t)},$E.prototype.newPersistentWatchStream=function(t){return new HE(this.queue,this.connection,this.credentials,this.serializer,t)},$E.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)})},$E.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=lg();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);Nm(!!e,"Missing entity in write response for "+t),r.push(e)}),r})},$E.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===Om.UNAUTHENTICATED&&r.credentials.invalidateToken(),t})},$E.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===Om.UNAUTHENTICATED&&r.credentials.invalidateToken(),t})},$E);function $E(t,e,n,r){this.queue=t,this.connection=e,this.credentials=n,this.serializer=r}var ZE,tT,eT,nT,rT=(iT.prototype.lookup=function(r){return ea(this,void 0,void 0,function(){var e,n=this;return na(this,function(t){switch(t.label){case 0:if(this.ensureCommitNotCalled(),0<this.mutations.length)throw new Pm(Om.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 Cw||t instanceof Tw?n.recordVersion(t):Cm("Document in a transaction was a "+t.constructor.name)}),[2,e]}})})},iT.prototype.set=function(t,e){this.write(e.toMutations(t,this.precondition(t))),this.writtenDocs.add(t)},iT.prototype.update=function(t,e){try{this.write(e.toMutations(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t)},iT.prototype.delete=function(t){this.write([new Ab(t,this.precondition(t))]),this.writtenDocs.add(t)},iT.prototype.commit=function(){return ea(this,void 0,void 0,function(){var e;return na(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 Pm(Om.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]}})})},iT.prototype.recordVersion=function(t){var e;if(t instanceof Tw)e=t.version;else{if(!(t instanceof Cw))throw Cm("Document in a transaction was a "+t.constructor.name);e=Xv.forDeletedDoc()}var n=this.readVersions.get(t.key);if(null!==n){if(!e.isEqual(n))throw new Pm(Om.ABORTED,"Document version changed between two reads.")}else this.readVersions=this.readVersions.insert(t.key,e)},iT.prototype.precondition=function(t){var e=this.readVersions.get(t);return!this.writtenDocs.has(t)&&e?hb.updateTime(e):hb.NONE},iT.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t);if(this.writtenDocs.has(t)||!e)return hb.exists(!0);if(e.isEqual(Xv.forDeletedDoc()))throw new Pm(Om.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return hb.updateTime(e)},iT.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations=this.mutations.concat(t)},iT.prototype.ensureCommitNotCalled=function(){Nm(!this.committed,"A transaction object cannot be used after its update callback has been invoked.")},iT);function iT(t){this.datastore=t,this.readVersions=mg(),this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}(tT=ZE=ZE||{})[tT.Unknown=0]="Unknown",tT[tT.Online=1]="Online",tT[tT.Offline=2]="Offline",(nT=eT=eT||{})[nT.RemoteStore=0]="RemoteStore",nT[nT.SharedClientState=1]="SharedClientState";var oT,aT,sT=(uT.prototype.handleWatchStreamStart=function(){var t=this;0===this.watchStreamFailures&&(this.setAndBroadcast(ZE.Unknown),Nm(null===this.onlineStateTimer,"onlineStateTimer shouldn't be started yet"),this.onlineStateTimer=this.asyncQueue.enqueueAfterDelay(Pv.OnlineStateTimeout,1e4,function(){return t.onlineStateTimer=null,Nm(t.state===ZE.Unknown,"Timer should be canceled if we transitioned to a different state."),t.logClientOfflineWarningIfNecessary("Backend didn't respond within 10 seconds."),t.setAndBroadcast(ZE.Offline),Promise.resolve()}))},uT.prototype.handleWatchStreamFailure=function(t){this.state===ZE.Online?(this.setAndBroadcast(ZE.Unknown),Nm(0===this.watchStreamFailures,"watchStreamFailures must be 0"),Nm(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(ZE.Offline)))},uT.prototype.set=function(t){this.clearOnlineStateTimer(),this.watchStreamFailures=0,t===ZE.Online&&(this.shouldWarnClientIsOffline=!1),this.setAndBroadcast(t)},uT.prototype.setAndBroadcast=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},uT.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?(Sm(e),this.shouldWarnClientIsOffline=!1):Tm("OnlineStateTracker",e)},uT.prototype.clearOnlineStateTimer=function(){null!==this.onlineStateTimer&&(this.onlineStateTimer.cancel(),this.onlineStateTimer=null)},uT);function uT(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state=ZE.Unknown,this.watchStreamFailures=0,this.onlineStateTimer=null,this.shouldWarnClientIsOffline=!0}function cT(t){switch(t){case Om.OK:return Cm("Treated status OK as error");case Om.CANCELLED:case Om.UNKNOWN:case Om.DEADLINE_EXCEEDED:case Om.RESOURCE_EXHAUSTED:case Om.INTERNAL:case Om.UNAVAILABLE:case Om.UNAUTHENTICATED:return!1;case Om.INVALID_ARGUMENT:case Om.NOT_FOUND:case Om.ALREADY_EXISTS:case Om.PERMISSION_DENIED:case Om.FAILED_PRECONDITION:case Om.ABORTED:case Om.OUT_OF_RANGE:case Om.UNIMPLEMENTED:case Om.DATA_LOSS:return!0;default:return Cm("Unknown status code: "+t)}}function hT(t){if(void 0===t)return Sm("GRPC error has no .code"),Om.UNKNOWN;switch(t){case oT.OK:return Om.OK;case oT.CANCELLED:return Om.CANCELLED;case oT.UNKNOWN:return Om.UNKNOWN;case oT.DEADLINE_EXCEEDED:return Om.DEADLINE_EXCEEDED;case oT.RESOURCE_EXHAUSTED:return Om.RESOURCE_EXHAUSTED;case oT.INTERNAL:return Om.INTERNAL;case oT.UNAVAILABLE:return Om.UNAVAILABLE;case oT.UNAUTHENTICATED:return Om.UNAUTHENTICATED;case oT.INVALID_ARGUMENT:return Om.INVALID_ARGUMENT;case oT.NOT_FOUND:return Om.NOT_FOUND;case oT.ALREADY_EXISTS:return Om.ALREADY_EXISTS;case oT.PERMISSION_DENIED:return Om.PERMISSION_DENIED;case oT.FAILED_PRECONDITION:return Om.FAILED_PRECONDITION;case oT.ABORTED:return Om.ABORTED;case oT.OUT_OF_RANGE:return Om.OUT_OF_RANGE;case oT.UNIMPLEMENTED:return Om.UNIMPLEMENTED;case oT.DATA_LOSS:return Om.DATA_LOSS;default:return Cm("Unknown status code: "+t)}}(aT=oT=oT||{})[aT.OK=0]="OK",aT[aT.CANCELLED=1]="CANCELLED",aT[aT.UNKNOWN=2]="UNKNOWN",aT[aT.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",aT[aT.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",aT[aT.NOT_FOUND=5]="NOT_FOUND",aT[aT.ALREADY_EXISTS=6]="ALREADY_EXISTS",aT[aT.PERMISSION_DENIED=7]="PERMISSION_DENIED",aT[aT.UNAUTHENTICATED=16]="UNAUTHENTICATED",aT[aT.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",aT[aT.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",aT[aT.ABORTED=10]="ABORTED",aT[aT.OUT_OF_RANGE=11]="OUT_OF_RANGE",aT[aT.UNIMPLEMENTED=12]="UNIMPLEMENTED",aT[aT.INTERNAL=13]="INTERNAL",aT[aT.UNAVAILABLE=14]="UNAVAILABLE",aT[aT.DATA_LOSS=15]="DATA_LOSS";var lT,fT,pT,dT,yT=(mT.emptySet=function(t){return new mT(t.comparator)},mT.prototype.has=function(t){return null!=this.keyedMap.get(t)},mT.prototype.get=function(t){return this.keyedMap.get(t)},mT.prototype.first=function(){return this.sortedSet.minKey()},mT.prototype.last=function(){return this.sortedSet.maxKey()},mT.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},mT.prototype.indexOf=function(t){var e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1},Object.defineProperty(mT.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!0,configurable:!0}),mT.prototype.forEach=function(n){this.sortedSet.inorderTraversal(function(t,e){return n(t),!1})},mT.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},mT.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.remove(e)):this},mT.prototype.isEqual=function(t){if(!(t instanceof mT))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},mT.prototype.toString=function(){var e=[];return this.forEach(function(t){e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"},mT.prototype.copy=function(t,e){var n=new mT;return n.comparator=this.comparator,n.keyedMap=t,n.sortedSet=e,n},mT);function mT(n){this.comparator=n?function(t,e){return n(t,e)||Rv.comparator(t.key,e.key)}:function(t,e){return Rv.comparator(t.key,e.key)},this.keyedMap=dg(),this.sortedSet=new $v(this.comparator)}(fT=lT=lT||{})[fT.Added=0]="Added",fT[fT.Removed=1]="Removed",fT[fT.Modified=2]="Modified",fT[fT.Metadata=3]="Metadata",(dT=pT=pT||{})[dT.Local=0]="Local",dT[dT.Synced=1]="Synced";var vT=(gT.prototype.track=function(t){var e=t.doc.key,n=this.changeMap.get(e);n?t.type!==lT.Added&&n.type===lT.Metadata?this.changeMap=this.changeMap.insert(e,t):t.type===lT.Metadata&&n.type!==lT.Removed?this.changeMap=this.changeMap.insert(e,{type:n.type,doc:t.doc}):t.type===lT.Modified&&n.type===lT.Modified?this.changeMap=this.changeMap.insert(e,{type:lT.Modified,doc:t.doc}):t.type===lT.Modified&&n.type===lT.Added?this.changeMap=this.changeMap.insert(e,{type:lT.Added,doc:t.doc}):t.type===lT.Removed&&n.type===lT.Added?this.changeMap=this.changeMap.remove(e):t.type===lT.Removed&&n.type===lT.Modified?this.changeMap=this.changeMap.insert(e,{type:lT.Removed,doc:n.doc}):t.type===lT.Added&&n.type===lT.Removed?this.changeMap=this.changeMap.insert(e,{type:lT.Modified,doc:t.doc}):Cm("unsupported combination of changes: "+JSON.stringify(t)+" after "+JSON.stringify(n)):this.changeMap=this.changeMap.insert(e,t)},gT.prototype.getChanges=function(){var n=[];return this.changeMap.inorderTraversal(function(t,e){n.push(e)}),n},gT);function gT(){this.changeMap=new $v(Rv.comparator)}var bT=(wT.fromInitialDocuments=function(t,e,n,r){var i=[];return e.forEach(function(t){i.push({type:lT.Added,doc:t})}),new wT(t,e,yT.emptySet(e),i,n,r,!0,!1)},Object.defineProperty(wT.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!0,configurable:!0}),wT.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},wT);function wT(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 _T=(ET.createSynthesizedRemoteEventForCurrentChange=function(t,e){var n,r=((n={})[t]=TT.createSynthesizedTargetChangeForCurrentChange(t,e),n);return new ET(Xv.MIN,r,wg(),lg(),gg())},ET);function ET(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}var TT=(ST.createSynthesizedTargetChangeForCurrentChange=function(t,e){return new ST(Dm(),e,gg(),gg(),gg())},ST);function ST(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}var IT,CT,NT=function(t,e,n,r){this.updatedTargetIds=t,this.removedTargetIds=e,this.key=n,this.newDoc=r},AT=function(t,e){this.targetId=t,this.existenceFilter=e};(CT=IT=IT||{})[CT.NoChange=0]="NoChange",CT[CT.Added=1]="Added",CT[CT.Removed=2]="Removed",CT[CT.Current=3]="Current",CT[CT.Reset=4]="Reset";var kT=function(t,e,n,r){void 0===n&&(n=Dm()),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},DT=(Object.defineProperty(RT.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(RT.prototype,"resumeToken",{get:function(){return this._resumeToken},enumerable:!0,configurable:!0}),Object.defineProperty(RT.prototype,"isPending",{get:function(){return 0!==this.pendingResponses},enumerable:!0,configurable:!0}),Object.defineProperty(RT.prototype,"hasPendingChanges",{get:function(){return this._hasPendingChanges},enumerable:!0,configurable:!0}),RT.prototype.updateResumeToken=function(t){0<t.length&&(this._hasPendingChanges=!0,this._resumeToken=t)},RT.prototype.toTargetChange=function(){var n=gg(),r=gg(),i=gg();return this.documentChanges.forEach(function(t,e){switch(e){case lT.Added:n=n.add(t);break;case lT.Modified:r=r.add(t);break;case lT.Removed:i=i.add(t);break;default:Cm("Encountered invalid change type: "+e)}}),new TT(this._resumeToken,this._current,n,r,i)},RT.prototype.clearPendingChanges=function(){this._hasPendingChanges=!1,this.documentChanges=xT()},RT.prototype.addDocumentChange=function(t,e){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.insert(t,e)},RT.prototype.removeDocumentChange=function(t){this._hasPendingChanges=!0,this.documentChanges=this.documentChanges.remove(t)},RT.prototype.recordPendingTargetRequest=function(){this.pendingResponses+=1},RT.prototype.recordTargetResponse=function(){this.pendingResponses-=1},RT.prototype.markCurrent=function(){this._hasPendingChanges=!0,this._current=!0},RT);function RT(){this.pendingResponses=0,this.documentChanges=xT(),this._resumeToken=Dm(),this._current=!1,this._hasPendingChanges=!0}var OT=(PT.prototype.handleDocumentChange=function(t){for(var e=0,n=t.updatedTargetIds;e<n.length;e++){var r=n[e];t.newDoc instanceof Tw?this.addDocumentToTarget(r,t.newDoc):t.newDoc instanceof Cw&&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)},PT.prototype.handleTargetChange=function(n){var r=this;this.forEachTarget(n,function(t){var e=r.ensureTargetState(t);switch(n.state){case IT.NoChange:r.isActiveTarget(t)&&e.updateResumeToken(n.resumeToken);break;case IT.Added:e.recordTargetResponse(),e.isPending||e.clearPendingChanges(),e.updateResumeToken(n.resumeToken);break;case IT.Removed:e.recordTargetResponse(),e.isPending||r.removeTarget(t),Nm(!n.cause,"WatchChangeAggregator does not handle errored targets");break;case IT.Current:r.isActiveTarget(t)&&(e.markCurrent(),e.updateResumeToken(n.resumeToken));break;case IT.Reset:r.isActiveTarget(t)&&(r.resetTarget(t),e.updateResumeToken(n.resumeToken));break;default:Cm("Unknown target watch change state: "+n.state)}})},PT.prototype.forEachTarget=function(t,e){0<t.targetIds.length?t.targetIds.forEach(e):Um(this.targetStates,e)},PT.prototype.handleExistenceFilter=function(t){var e=t.targetId,n=t.existenceFilter.count,r=this.queryDataForActiveTarget(e);if(r){var i=r.query;if(i.isDocumentQuery())if(0===n){var o=new Rv(i.path);this.removeDocumentFromTarget(e,o,new Cw(o,Xv.forDeletedDoc()))}else Nm(1===n,"Single document existence filter with count: "+n);else this.getCurrentDocumentCountForTarget(e)!==n&&(this.resetTarget(e),this.pendingTargetResets=this.pendingTargetResets.add(e))}},PT.prototype.createRemoteEvent=function(i){var o=this,a={};Um(this.targetStates,function(t,e){var n=o.queryDataForActiveTarget(t);if(n){if(e.current&&n.query.isDocumentQuery()){var r=new Rv(n.query.path);null!==o.pendingDocumentUpdates.get(r)||o.targetContainsDocument(t,r)||o.removeDocumentFromTarget(t,r,new Cw(r,i))}e.hasPendingChanges&&(a[t]=e.toTargetChange(),e.clearPendingChanges())}});var r=gg();this.pendingDocumentTargetMapping.forEach(function(t,e){var n=!0;e.forEachWhile(function(t){var e=o.queryDataForActiveTarget(t);return!e||e.purpose===E_.LimboResolution||(n=!1)}),n&&(r=r.add(t))});var t=new _T(i,a,this.pendingTargetResets,this.pendingDocumentUpdates,r);return this.pendingDocumentUpdates=lg(),this.pendingDocumentTargetMapping=MT(),this.pendingTargetResets=new ag(sv),t},PT.prototype.addDocumentToTarget=function(t,e){if(this.isActiveTarget(t)){var n=this.targetContainsDocument(t,e.key)?lT.Modified:lT.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))}},PT.prototype.removeDocumentFromTarget=function(t,e,n){if(this.isActiveTarget(t)){var r=this.ensureTargetState(t);this.targetContainsDocument(t,e)?r.addDocumentChange(e,lT.Removed):r.removeDocumentChange(e),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(e,this.ensureDocumentTargetMapping(e).delete(t)),n&&(this.pendingDocumentUpdates=this.pendingDocumentUpdates.insert(e,n))}},PT.prototype.removeTarget=function(t){delete this.targetStates[t]},PT.prototype.getCurrentDocumentCountForTarget=function(t){var e=this.ensureTargetState(t).toTargetChange();return this.metadataProvider.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},PT.prototype.recordPendingTargetRequest=function(t){this.ensureTargetState(t).recordPendingTargetRequest()},PT.prototype.ensureTargetState=function(t){return this.targetStates[t]||(this.targetStates[t]=new DT),this.targetStates[t]},PT.prototype.ensureDocumentTargetMapping=function(t){var e=this.pendingDocumentTargetMapping.get(t);return e||(e=new ag(sv),this.pendingDocumentTargetMapping=this.pendingDocumentTargetMapping.insert(t,e)),e},PT.prototype.isActiveTarget=function(t){var e=null!==this.queryDataForActiveTarget(t);return e||Tm("WatchChangeAggregator","Detected inactive target",t),e},PT.prototype.queryDataForActiveTarget=function(t){var e=this.targetStates[t];return e&&e.isPending?null:this.metadataProvider.getQueryDataForTarget(t)},PT.prototype.resetTarget=function(e){var n=this;Nm(!this.targetStates[e].isPending,"Should only reset active targets"),this.targetStates[e]=new DT,this.metadataProvider.getRemoteKeysForTarget(e).forEach(function(t){n.removeDocumentFromTarget(e,t,null)})},PT.prototype.targetContainsDocument=function(t,e){return this.metadataProvider.getRemoteKeysForTarget(t).has(e)},PT);function PT(t){this.metadataProvider=t,this.targetStates={},this.pendingDocumentUpdates=lg(),this.pendingDocumentTargetMapping=MT(),this.pendingTargetResets=new ag(sv)}function MT(){return new $v(Rv.comparator)}function xT(){return new $v(Rv.comparator)}var LT="RemoteStore",FT=(UT.prototype.start=function(){return this.enableNetwork()},UT.prototype.enableNetwork=function(){return ea(this,void 0,void 0,function(){var e;return na(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(ZE.Unknown),[4,this.fillWritePipeline()];case 2:t.sent(),t.label=3;case 3:return[2]}})})},UT.prototype.disableNetwork=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(ZE.Offline),[2]}})})},UT.prototype.disableNetworkInternal=function(){return ea(this,void 0,void 0,function(){return na(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&&(Tm(LT,"Stopping write stream with "+this.writePipeline.length+" pending writes"),this.writePipeline=[]),this.cleanUpWatchStreamState(),[2]}})})},UT.prototype.shutdown=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return Tm(LT,"RemoteStore shutting down."),this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.connectivityMonitor.shutdown(),this.onlineStateTracker.set(ZE.Unknown),[2]}})})},UT.prototype.listen=function(t){Nm(!Lm(this.listenTargets,t.targetId),"listen called with duplicate targetId!"),this.listenTargets[t.targetId]=t,this.shouldStartWatchStream()?this.startWatchStream():this.watchStream.isOpen()&&this.sendWatchRequest(t)},UT.prototype.unlisten=function(t){Nm(Lm(this.listenTargets,t),"unlisten called without assigned target ID!"),delete this.listenTargets[t],this.watchStream.isOpen()&&this.sendUnwatchRequest(t),Vm(this.listenTargets)&&(this.watchStream.isOpen()?this.watchStream.markIdle():this.canUseNetwork()&&this.onlineStateTracker.set(ZE.Unknown))},UT.prototype.getQueryDataForTarget=function(t){return this.listenTargets[t]||null},UT.prototype.getRemoteKeysForTarget=function(t){return this.syncEngine.getRemoteKeysForTarget(t)},UT.prototype.sendWatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t.targetId),this.watchStream.watch(t)},UT.prototype.sendUnwatchRequest=function(t){this.watchChangeAggregator.recordPendingTargetRequest(t),this.watchStream.unwatch(t)},UT.prototype.startWatchStream=function(){Nm(this.shouldStartWatchStream(),"startWatchStream() called when shouldStartWatchStream() is false."),this.watchChangeAggregator=new OT(this),this.watchStream.start(),this.onlineStateTracker.handleWatchStreamStart()},UT.prototype.shouldStartWatchStream=function(){return this.canUseNetwork()&&!this.watchStream.isStarted()&&!Vm(this.listenTargets)},UT.prototype.canUseNetwork=function(){return this.isPrimary&&this.networkEnabled},UT.prototype.cleanUpWatchStreamState=function(){this.watchChangeAggregator=null},UT.prototype.onWatchStreamOpen=function(){return ea(this,void 0,void 0,function(){var n=this;return na(this,function(t){return Um(this.listenTargets,function(t,e){n.sendWatchRequest(e)}),[2]})})},UT.prototype.onWatchStreamClose=function(e){return ea(this,void 0,void 0,function(){return na(this,function(t){return void 0===e&&Nm(!this.shouldStartWatchStream(),"Watch stream was stopped gracefully while still needed."),this.cleanUpWatchStreamState(),this.shouldStartWatchStream()?(this.onlineStateTracker.handleWatchStreamFailure(e),this.startWatchStream()):this.onlineStateTracker.set(ZE.Unknown),[2]})})},UT.prototype.onWatchStreamChange=function(n,r){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return this.onlineStateTracker.set(ZE.Online),n instanceof kT&&n.state===IT.Removed&&n.cause?[2,this.handleTargetError(n)]:(n instanceof NT?this.watchChangeAggregator.handleDocumentChange(n):n instanceof AT?this.watchChangeAggregator.handleExistenceFilter(n):(Nm(n instanceof kT,"Expected watchChange to be an instance of WatchTargetChange"),this.watchChangeAggregator.handleTargetChange(n)),r.isEqual(Xv.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]}})})},UT.prototype.raiseWatchSnapshot=function(r){var i=this;Nm(!r.isEqual(Xv.MIN),"Can't raise event for unknown SnapshotVersion");var t=this.watchChangeAggregator.createRemoteEvent(r);return Um(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(Dm(),e.snapshotVersion),i.sendUnwatchRequest(t);var n=new A_(e.query,t,E_.ExistenceFilterMismatch,e.sequenceNumber);i.sendWatchRequest(n)}}),this.syncEngine.applyRemoteEvent(t)},UT.prototype.handleTargetError=function(t){var n=this;Nm(!!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 ea(n,void 0,void 0,function(){return na(this,function(t){return Lm(this.listenTargets,e)?(delete this.listenTargets[e],this.watchChangeAggregator.removeTarget(e),[2,this.syncEngine.rejectListen(e,r)]):[2]})})})}),i},UT.prototype.fillWritePipeline=function(){return ea(this,void 0,void 0,function(){var e,n;return na(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]}})})},UT.prototype.canAddToWritePipeline=function(){return this.canUseNetwork()&&this.writePipeline.length<10},UT.prototype.outstandingWrites=function(){return this.writePipeline.length},UT.prototype.addToWritePipeline=function(t){Nm(this.canAddToWritePipeline(),"addToWritePipeline called when pipeline is full"),this.writePipeline.push(t),this.writeStream.isOpen()&&this.writeStream.handshakeComplete&&this.writeStream.writeMutations(t.mutations)},UT.prototype.shouldStartWriteStream=function(){return this.canUseNetwork()&&!this.writeStream.isStarted()&&0<this.writePipeline.length},UT.prototype.startWriteStream=function(){Nm(this.shouldStartWriteStream(),"startWriteStream() called when shouldStartWriteStream() is false."),this.writeStream.start()},UT.prototype.onWriteStreamOpen=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){return this.writeStream.writeHandshake(),[2]})})},UT.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($_)},UT.prototype.onMutationResult=function(t,e){var n=this;Nm(0<this.writePipeline.length,"Got result for empty write pipeline");var r=this.writePipeline.shift(),i=Tg.from(r,t,e,this.writeStream.lastStreamToken);return this.syncEngine.applySuccessfulWrite(i).then(function(){return n.fillWritePipeline()})},UT.prototype.onWriteStreamClose=function(n){return ea(this,void 0,void 0,function(){var e=this;return na(this,function(t){return void 0===n&&Nm(!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]})})},UT.prototype.handleHandshakeError=function(e){return ea(this,void 0,void 0,function(){return na(this,function(t){return cT(e.code)?(Tm(LT,"RemoteStore error before completed handshake; resetting stream token: ",this.writeStream.lastStreamToken),this.writeStream.lastStreamToken=Dm(),[2,this.localStore.setLastStreamToken(Dm()).catch($_)]):[2]})})},UT.prototype.handleWriteError=function(r){return ea(this,void 0,void 0,function(){var e,n=this;return na(this,function(t){return function(t){return cT(t)&&t!==Om.ABORTED}(r.code)?(e=this.writePipeline.shift(),this.writeStream.inhibitBackoff(),[2,this.syncEngine.rejectFailedWrite(e.batchId,r).then(function(){return n.fillWritePipeline()})]):[2]})})},UT.prototype.createTransaction=function(){return new rT(this.datastore)},UT.prototype.restartNetwork=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.disableNetworkInternal()];case 1:return t.sent(),this.onlineStateTracker.set(ZE.Unknown),[4,this.enableNetwork()];case 2:return t.sent(),[2]}})})},UT.prototype.handleCredentialChange=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return this.canUseNetwork()?(Tm(LT,"RemoteStore restarting streams for new credential"),[4,this.restartNetwork()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})},UT.prototype.applyPrimaryState=function(e){return ea(this,void 0,void 0,function(){return na(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(ZE.Unknown),t.label=4;case 4:return[2]}})})},UT);function UT(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 ea(o,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return this.canUseNetwork()?(Tm(LT,"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 sT(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 qT=(Object.defineProperty(VT.prototype,"latitude",{get:function(){return this._lat},enumerable:!0,configurable:!0}),Object.defineProperty(VT.prototype,"longitude",{get:function(){return this._long},enumerable:!0,configurable:!0}),VT.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},VT.prototype._compareTo=function(t){return sv(this._lat,t._lat)||sv(this._long,t._long)},VT);function VT(t,e){if(jm("GeoPoint",arguments,2),Qm("GeoPoint","number",1,t),Qm("GeoPoint","number",2,e),!isFinite(t)||t<-90||90<t)throw new Pm(Om.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||180<e)throw new Pm(Om.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}var BT=(jT.atPath=function(t){return new jT(t)},Object.defineProperty(jT.prototype,"orderBy",{get:function(){if(null===this.memoizedOrderBy){var t=this.getInequalityFilterField(),e=this.getFirstOrderByField();if(null!==t&&null===e)t.isKeyField()?this.memoizedOrderBy=[mS]:this.memoizedOrderBy=[new dS(t),mS];else{Nm(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:hS.ASCENDING;this.memoizedOrderBy.push(a===hS.ASCENDING?mS:vS)}}}return this.memoizedOrderBy},enumerable:!0,configurable:!0}),jT.prototype.addFilter=function(t){Nm(null==this.getInequalityFilterField()||!(t instanceof GT)||!t.isInequality()||t.field.isEqual(this.getInequalityFilterField()),"Query must only have one inequality field."),Nm(!this.isDocumentQuery(),"No filtering allowed for document query");var e=this.filters.concat([t]);return new jT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),e,this.limit,this.startAt,this.endAt)},jT.prototype.addOrderBy=function(t){Nm(!this.startAt&&!this.endAt,"Bounds must be set after orderBy");var e=this.explicitOrderBy.concat([t]);return new jT(this.path,this.collectionGroup,e,this.filters.slice(),this.limit,this.startAt,this.endAt)},jT.prototype.withLimit=function(t){return new jT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),t,this.startAt,this.endAt)},jT.prototype.withStartAt=function(t){return new jT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,t,this.endAt)},jT.prototype.withEndAt=function(t){return new jT(this.path,this.collectionGroup,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.startAt,t)},jT.prototype.asCollectionQueryAtPath=function(t){return new jT(t,null,this.explicitOrderBy.slice(),this.filters.slice(),this.limit,this.startAt,this.endAt)},jT.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())},jT.prototype.canonicalId=function(){if(null===this.memoizedCanonicalId){var t=this.path.canonicalString();this.isCollectionGroupQuery()&&(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+=",";LE(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},jT.prototype.toString=function(){var t="Query("+this.path.canonicalString();return this.isCollectionGroupQuery()&&(t+=" collectionGroup="+this.collectionGroup),0<this.filters.length&&(t+=", filters: ["+this.filters.join(", ")+"]"),LE(this.limit)||(t+=", limit: "+this.limit),0<this.explicitOrderBy.length&&(t+=", orderBy: ["+this.explicitOrderBy.join(", ")+"]"),this.startAt&&(t+=", startAt: "+this.startAt.canonicalId()),this.endAt&&(t+=", endAt: "+this.endAt.canonicalId()),t+")"},jT.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)},jT.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 Nm(n,"orderBy used that doesn't compare on key field"),0},jT.prototype.matches=function(t){return this.matchesPathAndCollectionGroup(t)&&this.matchesOrderBy(t)&&this.matchesFilters(t)&&this.matchesBounds(t)},jT.prototype.hasLimit=function(){return!LE(this.limit)},jT.prototype.getFirstOrderByField=function(){return 0<this.explicitOrderBy.length?this.explicitOrderBy[0].field:null},jT.prototype.getInequalityFilterField=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof GT&&n.isInequality())return n.field}return null},jT.prototype.findFilterOperator=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof GT&&0<=t.indexOf(r.op))return r.op}return null},jT.prototype.isDocumentQuery=function(){return Rv.isDocumentKey(this.path)&&null===this.collectionGroup&&0===this.filters.length},jT.prototype.isCollectionGroupQuery=function(){return null!==this.collectionGroup},jT.prototype.matchesPathAndCollectionGroup=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.hasCollectionId(this.collectionGroup)&&this.path.isPrefixOf(e):Rv.isDocumentKey(this.path)?this.path.isEqual(e):this.path.isImmediateParentOf(e)},jT.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},jT.prototype.matchesFilters=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},jT.prototype.matchesBounds=function(t){return!(this.startAt&&!this.startAt.sortsBeforeDocument(this.orderBy,t)||this.endAt&&this.endAt.sortsBeforeDocument(this.orderBy,t))},jT.prototype.assertValidBound=function(t){Nm(t.position.length<=this.orderBy.length,"Bound is longer than orderBy")},jT);function jT(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.explicitOrderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=a,this.memoizedCanonicalId=null,this.memoizedOrderBy=null,this.startAt&&this.assertValidBound(this.startAt),this.endAt&&this.assertValidBound(this.endAt)}function WT(){}var KT=(QT.fromString=function(t){switch(t){case"<":return QT.LESS_THAN;case"<=":return QT.LESS_THAN_OR_EQUAL;case"==":return QT.EQUAL;case">=":return QT.GREATER_THAN_OR_EQUAL;case">":return QT.GREATER_THAN;case"array-contains":return QT.ARRAY_CONTAINS;case"in":return QT.IN;case"array-contains-any":return QT.ARRAY_CONTAINS_ANY;default:return Cm("Unknown FieldFilter operator: "+t)}},QT.prototype.toString=function(){return this.name},QT.prototype.isEqual=function(t){return this.name===t.name},QT.LESS_THAN=new QT("<"),QT.LESS_THAN_OR_EQUAL=new QT("<="),QT.EQUAL=new QT("=="),QT.GREATER_THAN=new QT(">"),QT.GREATER_THAN_OR_EQUAL=new QT(">="),QT.ARRAY_CONTAINS=new QT("array-contains"),QT.IN=new QT("in"),QT.ARRAY_CONTAINS_ANY=new QT("array-contains-any"),QT);function QT(t){this.name=t}var HT,GT=(Zo(zT,HT=WT),zT.create=function(t,e,n){if(t.isKeyField())return e===KT.IN?(Nm(n instanceof gw,"Comparing on key with IN, but filter value not an ArrayValue"),Nm(n.internalValue.every(function(t){return t instanceof cw}),"Comparing on key with IN, but an array value was not a RefValue"),new ZT(t,n)):(Nm(n instanceof cw,"Comparing on key, but filter value not a RefValue"),Nm(e!==KT.ARRAY_CONTAINS&&e!==KT.ARRAY_CONTAINS_ANY,"'"+e.toString()+"' queries don't make sense on document keys."),new XT(t,e,n));if(n.isEqual(xb.INSTANCE)){if(e!==KT.EQUAL)throw new Pm(Om.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new zT(t,e,n)}if(n.isEqual(zb.NAN)){if(e!==KT.EQUAL)throw new Pm(Om.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new zT(t,e,n)}return e===KT.ARRAY_CONTAINS?new nS(t,n):e===KT.IN?(Nm(n instanceof gw,"IN filter has invalid value: "+n.toString()),new oS(t,n)):e===KT.ARRAY_CONTAINS_ANY?(Nm(n instanceof gw,"ARRAY_CONTAINS_ANY filter has invalid value: "+n.toString()),new uS(t,n)):new zT(t,e,n)},zT.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&this.value.typeOrder===e.typeOrder&&this.matchesComparison(e.compareTo(this.value))},zT.prototype.matchesComparison=function(t){switch(this.op){case KT.LESS_THAN:return t<0;case KT.LESS_THAN_OR_EQUAL:return t<=0;case KT.EQUAL:return 0===t;case KT.GREATER_THAN:return 0<t;case KT.GREATER_THAN_OR_EQUAL:return 0<=t;default:return Cm("Unknown FieldFilter operator: "+this.op)}},zT.prototype.isInequality=function(){return 0<=[KT.LESS_THAN,KT.LESS_THAN_OR_EQUAL,KT.GREATER_THAN,KT.GREATER_THAN_OR_EQUAL].indexOf(this.op)},zT.prototype.canonicalId=function(){return this.field.canonicalString()+this.op.toString()+this.value.toString()},zT.prototype.isEqual=function(t){return t instanceof zT&&this.op.isEqual(t.op)&&this.field.isEqual(t.field)&&this.value.isEqual(t.value)},zT.prototype.toString=function(){return this.field.canonicalString()+" "+this.op+" "+this.value.value()},zT);function zT(t,e,n){var r=HT.call(this)||this;return r.field=t,r.op=e,r.value=n,r}var YT,XT=(Zo(JT,YT=GT),JT.prototype.matches=function(t){var e=this.value,n=Rv.comparator(t.key,e.key);return this.matchesComparison(n)},JT);function JT(){return null!==YT&&YT.apply(this,arguments)||this}var $T,ZT=(Zo(tS,$T=GT),tS.prototype.matches=function(e){return this.value.internalValue.some(function(t){return e.key.isEqual(t.key)})},tS);function tS(t,e){var n=$T.call(this,t,KT.IN,e)||this;return n.value=e,n}var eS,nS=(Zo(rS,eS=GT),rS.prototype.matches=function(t){var e=t.field(this.field);return e instanceof gw&&e.contains(this.value)},rS);function rS(t,e){return eS.call(this,t,KT.ARRAY_CONTAINS,e)||this}var iS,oS=(Zo(aS,iS=GT),aS.prototype.matches=function(t){var e=this.value,n=t.field(this.field);return null!==n&&e.contains(n)},aS);function aS(t,e){var n=iS.call(this,t,KT.IN,e)||this;return n.value=e,n}var sS,uS=(Zo(cS,sS=GT),cS.prototype.matches=function(t){var e=this,n=t.field(this.field);return n instanceof gw&&n.internalValue.some(function(t){return e.value.contains(t)})},cS);function cS(t,e){var n=sS.call(this,t,KT.ARRAY_CONTAINS_ANY,e)||this;return n.value=e,n}var hS=(lS.prototype.toString=function(){return this.name},lS.ASCENDING=new lS("asc"),lS.DESCENDING=new lS("desc"),lS);function lS(t){this.name=t}var fS=(pS.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},pS.prototype.sortsBeforeDocument=function(t,e){Nm(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())Nm(o instanceof cw,"Bound has a non-key value where the key path is being used."),n=Rv.comparator(o.key,e.key);else{var a=e.field(i.field);Nm(null!==a,"Field should exist since document matched the orderBy already."),n=o.compareTo(a)}if(i.dir===hS.DESCENDING&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},pS.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},pS);function pS(t,e){this.position=t,this.before=e}var dS=(yS.prototype.compare=function(t,e){var n=this.isKeyOrderBy?Tw.compareByKey(t,e):Tw.compareByField(this.field,t,e);switch(this.dir){case hS.ASCENDING:return n;case hS.DESCENDING:return-1*n;default:return Cm("Unknown direction: "+this.dir)}},yS.prototype.canonicalId=function(){return this.field.canonicalString()+this.dir.toString()},yS.prototype.toString=function(){return this.field.canonicalString()+" ("+this.dir+")"},yS.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},yS);function yS(t,e){this.field=t,void 0===e&&(e=hS.ASCENDING),this.dir=e,this.isKeyOrderBy=t.isKeyField()}var mS=new dS(kv.keyField(),hS.ASCENDING),vS=new dS(kv.keyField(),hS.DESCENDING),gS=(bS.prototype.applyToLocalView=function(t,e){return new rw(e,t)},bS.prototype.applyToRemoteDocument=function(t,e){return e},bS.prototype.computeBaseValue=function(t){return null},bS.prototype.isEqual=function(t){return t instanceof bS},bS.instance=new bS,bS);function bS(){}var wS=(_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=CS(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 gw(n)},_S.prototype.computeBaseValue=function(t){return null},_S.prototype.isEqual=function(t){return t instanceof _S&&uv(t.elements,this.elements)},_S);function _S(t){this.elements=t}var ES=(TS.prototype.applyToLocalView=function(t,e){return this.apply(t)},TS.prototype.applyToRemoteDocument=function(t,e){return this.apply(t)},TS.prototype.apply=function(t){for(var n=CS(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 gw(n)},TS.prototype.computeBaseValue=function(t){return null},TS.prototype.isEqual=function(t){return t instanceof TS&&uv(t.elements,this.elements)},TS);function TS(t){this.elements=t}var SS=(IS.prototype.applyToLocalView=function(t,e){var n=this.computeBaseValue(t);if(n instanceof Qb&&this.operand instanceof Qb){var r=n.internalValue+this.operand.internalValue;return new Qb(r)}return r=n.internalValue+this.operand.internalValue,new zb(r)},IS.prototype.applyToRemoteDocument=function(t,e){return Nm(null!==e,"Didn't receive transformResult for NUMERIC_ADD transform"),e},IS.prototype.computeBaseValue=function(t){return t instanceof Bb?t:new Qb(0)},IS.prototype.isEqual=function(t){return t instanceof IS&&this.operand.isEqual(t.operand)},IS);function IS(t){this.operand=t}function CS(t){return t instanceof gw?t.internalValue.slice():[]}var NS=(AS.prototype.isEqual=function(t){return t&&t.count===this.count},AS);function AS(t){this.count=t}var kS,DS,RS=((kS={})[hS.ASCENDING.name]="ASCENDING",kS[hS.DESCENDING.name]="DESCENDING",kS),OS=((DS={})[KT.LESS_THAN.name]="LESS_THAN",DS[KT.LESS_THAN_OR_EQUAL.name]="LESS_THAN_OR_EQUAL",DS[KT.GREATER_THAN.name]="GREATER_THAN",DS[KT.GREATER_THAN_OR_EQUAL.name]="GREATER_THAN_OR_EQUAL",DS[KT.EQUAL.name]="EQUAL",DS[KT.ARRAY_CONTAINS.name]="ARRAY_CONTAINS",DS[KT.IN.name]="IN",DS[KT.ARRAY_CONTAINS_ANY.name]="ARRAY_CONTAINS_ANY",DS),PS=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function MS(t,e){Nm(!LE(t),e+" is missing")}function xS(t){return"number"==typeof t?t:"string"==typeof t?Number(t):Cm("can't parse "+t)}var LS=(FS.prototype.emptyByteString=function(){return this.options.useProto3Json?"":new Uint8Array(0)},FS.prototype.unsafeCastProtoByteString=function(t){return t},FS.prototype.fromRpcStatus=function(t){var e=void 0===t.code?Om.UNKNOWN:hT(t.code);return new Pm(e,t.message||"")},FS.prototype.toInt32Value=function(t){return this.options.useProto3Json||LE(t)?t:{value:t}},FS.prototype.fromInt32Value=function(t){var e;return LE(e="object"==typeof t?t.value:t)?null:e},FS.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}},FS.prototype.fromTimestamp=function(t){if("string"==typeof t)return this.fromIso8601String(t);Nm(!!t,"Cannot deserialize null or undefined timestamp.");var e=xS(t.seconds||"0"),n=t.nanos||0;return new zv(e,n)},FS.prototype.fromIso8601String=function(t){var e=0,n=PS.exec(t);if(Nm(!!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 zv(o,e)},FS.prototype.toBytes=function(t){return this.options.useProto3Json?t.toBase64():this.unsafeCastProtoByteString(t.toUint8Array())},FS.prototype.fromBlob=function(t){return"string"==typeof t?(Nm(this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),fv.fromBase64String(t)):(Nm(!this.options.useProto3Json,"Expected bytes to be passed in as Uint8Array, but got a string instead."),fv.fromUint8Array(t))},FS.prototype.toVersion=function(t){return this.toTimestamp(t.toTimestamp())},FS.prototype.fromVersion=function(t){return Nm(!!t,"Trying to deserialize version that isn't set"),Xv.fromTimestamp(this.fromTimestamp(t))},FS.prototype.toResourceName=function(t,e){return this.fullyQualifiedPrefixPath(t).child("documents").child(e).canonicalString()},FS.prototype.fromResourceName=function(t){var e=Iv.fromString(t);return Nm(this.isValidResourceName(e),"Tried to deserialize invalid key "+e.toString()),e},FS.prototype.toName=function(t){return this.toResourceName(this.databaseId,t.path)},FS.prototype.fromName=function(t){var e=this.fromResourceName(t);return Nm(e.get(1)===this.databaseId.projectId,"Tried to deserialize key from different project: "+e.get(1)+" vs "+this.databaseId.projectId),Nm(!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 Rv(this.extractLocalPathFromResourceName(e))},FS.prototype.toQueryPath=function(t){return this.toResourceName(this.databaseId,t)},FS.prototype.fromQueryPath=function(t){var e=this.fromResourceName(t);return 4===e.length?Iv.EMPTY_PATH:this.extractLocalPathFromResourceName(e)},Object.defineProperty(FS.prototype,"encodedDatabaseId",{get:function(){return new Iv(["projects",this.databaseId.projectId,"databases",this.databaseId.database]).canonicalString()},enumerable:!0,configurable:!0}),FS.prototype.fullyQualifiedPrefixPath=function(t){return new Iv(["projects",t.projectId,"databases",t.database])},FS.prototype.extractLocalPathFromResourceName=function(t){return Nm(4<t.length&&"documents"===t.get(4),"tried to deserialize invalid key "+t.toString()),t.popFirst(5)},FS.prototype.isValidResourceName=function(t){return 4<=t.length&&"projects"===t.get(0)&&"databases"===t.get(2)},FS.prototype.toValue=function(t){if(t instanceof xb)return{nullValue:"NULL_VALUE"};if(t instanceof Ub)return{booleanValue:t.value()};if(t instanceof Qb)return{integerValue:""+t.value()};if(t instanceof zb){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 Jb?{stringValue:t.value()}:t instanceof yw?{mapValue:this.toMapValue(t)}:t instanceof gw?{arrayValue:this.toArrayValue(t)}:t instanceof tw?{timestampValue:this.toTimestamp(t.internalValue)}:t instanceof fw?{geoPointValue:{latitude:t.value().latitude,longitude:t.value().longitude}}:t instanceof aw?{bytesValue:this.toBytes(t.value())}:t instanceof cw?{referenceValue:this.toResourceName(t.databaseId,t.key.path)}:Cm("Unknown FieldValue "+JSON.stringify(t))},FS.prototype.fromValue=function(t){var e=this;if("nullValue"in t)return xb.INSTANCE;if("booleanValue"in t)return Ub.of(t.booleanValue);if("integerValue"in t)return new Qb(xS(t.integerValue));if("doubleValue"in t){if(this.options.useProto3Json){if("NaN"===t.doubleValue)return zb.NAN;if("Infinity"===t.doubleValue)return zb.POSITIVE_INFINITY;if("-Infinity"===t.doubleValue)return zb.NEGATIVE_INFINITY}return new zb(t.doubleValue)}if("stringValue"in t)return new Jb(t.stringValue);if("mapValue"in t)return this.fromFields(t.mapValue.fields||{});if("arrayValue"in t){MS(t.arrayValue,"arrayValue");var n=t.arrayValue.values||[];return new gw(n.map(function(t){return e.fromValue(t)}))}if("timestampValue"in t)return MS(t.timestampValue,"timestampValue"),new tw(this.fromTimestamp(t.timestampValue));if("geoPointValue"in t){MS(t.geoPointValue,"geoPointValue");var r=t.geoPointValue.latitude||0,i=t.geoPointValue.longitude||0;return new fw(new qT(r,i))}if("bytesValue"in t){MS(t.bytesValue,"bytesValue");var o=this.fromBlob(t.bytesValue);return new aw(o)}if("referenceValue"in t){MS(t.referenceValue,"referenceValue");var a=this.fromResourceName(t.referenceValue),s=new vv(a.get(1),a.get(3)),u=new Rv(this.extractLocalPathFromResourceName(a));return new cw(s,u)}return Cm("Unknown Value proto "+JSON.stringify(t))},FS.prototype.toMutationDocument=function(t,e){return{name:this.toName(t),fields:this.toFields(e)}},FS.prototype.toDocument=function(t){return Nm(!t.hasLocalMutations,"Can't serialize documents with mutations."),{name:this.toName(t.key),fields:this.toFields(t.data()),updateTime:this.toTimestamp(t.version.toTimestamp())}},FS.prototype.fromDocument=function(t,e){var n=this,r=this.fromName(t.name),i=this.fromVersion(t.updateTime);return new Tw(r,i,{hasCommittedMutations:!!e},void 0,t,function(t){return n.fromValue(t)})},FS.prototype.toFields=function(t){var n=this,r={};return t.forEach(function(t,e){r[t]=n.toValue(e)}),r},FS.prototype.fromFields=function(t){var n=this,e=t,r=yw.EMPTY;return qm(e,function(t,e){r=r.set(new kv([t]),n.fromValue(e))}),r},FS.prototype.toMapValue=function(t){return{fields:this.toFields(t)}},FS.prototype.toArrayValue=function(t){var e=this,n=[];return t.forEach(function(t){n.push(e.toValue(t))}),{values:n}},FS.prototype.fromFound=function(t){var e=this;Nm(!!t.found,"Tried to deserialize a found document from a missing document."),MS(t.found.name,"doc.found.name"),MS(t.found.updateTime,"doc.found.updateTime");var n=this.fromName(t.found.name),r=this.fromVersion(t.found.updateTime);return new Tw(n,r,{},void 0,t.found,function(t){return e.fromValue(t)})},FS.prototype.fromMissing=function(t){Nm(!!t.missing,"Tried to deserialize a missing document from a found document."),Nm(!!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 Cw(e,n)},FS.prototype.fromMaybeDocument=function(t){return"found"in t?this.fromFound(t):"missing"in t?this.fromMissing(t):Cm("invalid batch get response: "+JSON.stringify(t))},FS.prototype.toWatchTargetChangeState=function(t){switch(t){case IT.Added:return"ADD";case IT.Current:return"CURRENT";case IT.NoChange:return"NO_CHANGE";case IT.Removed:return"REMOVE";case IT.Reset:return"RESET";default:return Cm("Unknown WatchTargetChangeState: "+t)}},FS.prototype.toTestWatchChange=function(t){if(t instanceof AT)return{filter:{count:t.existenceFilter.count,targetId:t.targetId}};if(t instanceof NT){if(t.newDoc instanceof Tw){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 Cw)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 kT){var n=void 0;return t.cause&&(n={code:function(t){if(void 0===t)return oT.OK;switch(t){case Om.OK:return oT.OK;case Om.CANCELLED:return oT.CANCELLED;case Om.UNKNOWN:return oT.UNKNOWN;case Om.DEADLINE_EXCEEDED:return oT.DEADLINE_EXCEEDED;case Om.RESOURCE_EXHAUSTED:return oT.RESOURCE_EXHAUSTED;case Om.INTERNAL:return oT.INTERNAL;case Om.UNAVAILABLE:return oT.UNAVAILABLE;case Om.UNAUTHENTICATED:return oT.UNAUTHENTICATED;case Om.INVALID_ARGUMENT:return oT.INVALID_ARGUMENT;case Om.NOT_FOUND:return oT.NOT_FOUND;case Om.ALREADY_EXISTS:return oT.ALREADY_EXISTS;case Om.PERMISSION_DENIED:return oT.PERMISSION_DENIED;case Om.FAILED_PRECONDITION:return oT.FAILED_PRECONDITION;case Om.ABORTED:return oT.ABORTED;case Om.OUT_OF_RANGE:return oT.OUT_OF_RANGE;case Om.UNIMPLEMENTED:return oT.UNIMPLEMENTED;case Om.DATA_LOSS:return oT.DATA_LOSS;default:return Cm("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 Cm("Unrecognized watch change: "+JSON.stringify(t))},FS.prototype.fromWatchChange=function(t){var e,n=this;if("targetChange"in t){MS(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 kT(r,i,o,s||null)}else if("documentChange"in t){MS(t.documentChange,"documentChange"),MS(t.documentChange.document,"documentChange.name"),MS(t.documentChange.document.name,"documentChange.document.name"),MS(t.documentChange.document.updateTime,"documentChange.document.updateTime");var u=t.documentChange,c=this.fromName(u.document.name),h=this.fromVersion(u.document.updateTime),l=new Tw(c,h,{},void 0,u.document,function(t){return n.fromValue(t)}),f=u.targetIds||[],p=u.removedTargetIds||[];e=new NT(f,p,l.key,l)}else if("documentDelete"in t){MS(t.documentDelete,"documentDelete"),MS(t.documentDelete.document,"documentDelete.document");var d=t.documentDelete;c=this.fromName(d.document),h=d.readTime?this.fromVersion(d.readTime):Xv.forDeletedDoc(),l=new Cw(c,h),p=d.removedTargetIds||[],e=new NT([],p,l.key,l)}else if("documentRemove"in t){MS(t.documentRemove,"documentRemove"),MS(t.documentRemove.document,"documentRemove");var y=t.documentRemove;c=this.fromName(y.document),p=y.removedTargetIds||[],e=new NT([],p,c,null)}else{if(!("filter"in t))return Cm("Unknown change type "+JSON.stringify(t));MS(t.filter,"filter"),MS(t.filter.targetId,"filter.targetId");var m=t.filter,v=m.count||0,g=new NS(v),b=m.targetId;e=new AT(b,g)}return e},FS.prototype.fromWatchTargetChangeState=function(t){return"NO_CHANGE"===t?IT.NoChange:"ADD"===t?IT.Added:"REMOVE"===t?IT.Removed:"CURRENT"===t?IT.Current:"RESET"===t?IT.Reset:Cm("Got unexpected TargetChange.state: "+t)},FS.prototype.versionFromListenResponse=function(t){if(!("targetChange"in t))return Xv.MIN;var e=t.targetChange;return e.targetIds&&e.targetIds.length?Xv.MIN:e.readTime?this.fromVersion(e.readTime):Xv.MIN},FS.prototype.toMutation=function(t){var e,n=this;if(t instanceof yb)e={update:this.toMutationDocument(t.key,t.value)};else if(t instanceof Ab)e={delete:this.toName(t.key)};else if(t instanceof gb)e={update:this.toMutationDocument(t.key,t.data),updateMask:this.toDocumentMask(t.fieldMask)};else{if(!(t instanceof _b))return Cm("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},FS.prototype.fromMutation=function(t){var e=this,n=t.currentDocument?this.fromPrecondition(t.currentDocument):hb.NONE;if(t.update){MS(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 gb(r,i,o,n)}return new yb(r,i,n)}if(t.delete)return r=this.fromName(t.delete),new Ab(r,n);if(t.transform){r=this.fromName(t.transform.document);var a=t.transform.fieldTransforms.map(function(t){return e.fromFieldTransform(t)});return Nm(!0===n.exists,'Transforms only support precondition "exists == true"'),new _b(r,a)}return Cm("unknown mutation proto: "+JSON.stringify(t))},FS.prototype.toPrecondition=function(t){return Nm(!t.isNone,"Can't serialize an empty precondition"),void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:Cm("Unknown precondition")},FS.prototype.fromPrecondition=function(t){return void 0!==t.updateTime?hb.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?hb.exists(t.exists):hb.NONE},FS.prototype.fromWriteResult=function(t,e){var n=this,r=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);r.isEqual(Xv.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 cb(r,i)},FS.prototype.fromWriteResults=function(t,e){var n=this;return t&&0<t.length?(Nm(void 0!==e,"Received a write result without a commit time"),t.map(function(t){return n.fromWriteResult(t,e)})):[]},FS.prototype.toFieldTransform=function(t){var e=this,n=t.transform;if(n instanceof gS)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof wS)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements.map(function(t){return e.toValue(t)})}};if(n instanceof ES)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements.map(function(t){return e.toValue(t)})}};if(n instanceof SS)return{fieldPath:t.field.canonicalString(),increment:this.toValue(n.operand)};throw Cm("Unknown transform: "+t.transform)},FS.prototype.fromFieldTransform=function(t){var e=this,n=null;if("setToServerValue"in t)Nm("REQUEST_TIME"===t.setToServerValue,"Unknown server value transform proto: "+JSON.stringify(t)),n=gS.instance;else if("appendMissingElements"in t){var r=t.appendMissingElements.values||[];n=new wS(r.map(function(t){return e.fromValue(t)}))}else if("removeAllFromArray"in t)r=t.removeAllFromArray.values||[],n=new ES(r.map(function(t){return e.fromValue(t)}));else if("increment"in t){var i=this.fromValue(t.increment);Nm(i instanceof Bb,"NUMERIC_ADD transform requires a NumberValue"),n=new SS(i)}else Cm("Unknown transform proto: "+JSON.stringify(t));var o=kv.fromServerFormat(t.fieldPath);return new ob(o,n)},FS.prototype.toDocumentsTarget=function(t){return{documents:[this.toQueryPath(t.path)]}},FS.prototype.fromDocumentsTarget=function(t){var e=t.documents.length;Nm(1===e,"DocumentsTarget contained other than 1 document: "+e);var n=t.documents[0];return BT.atPath(this.fromQueryPath(n))},FS.prototype.toQueryTarget=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(Nm(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}]):(Nm(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},FS.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){Nm(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 BT(e,i,s,a,u,c,h)},FS.prototype.toListenRequestLabels=function(t){var e=this.toLabel(t.purpose);return null==e?null:{"goog-listen-tags":e}},FS.prototype.toLabel=function(t){switch(t){case E_.Listen:return null;case E_.ExistenceFilterMismatch:return"existence-filter-mismatch";case E_.LimboResolution:return"limbo-document";default:return Cm("Unrecognized query purpose: "+t)}},FS.prototype.toTarget=function(t){var e,n=t.query;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},FS.prototype.toFilter=function(t){var e=this;if(0!==t.length){var n=t.map(function(t){return t instanceof GT?e.toUnaryOrFieldFilter(t):Cm("Unrecognized filter: "+JSON.stringify(t))});return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},FS.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)}):Cm("Unknown filter: "+JSON.stringify(t)):[]},FS.prototype.toOrder=function(t){var e=this;if(0!==t.length)return t.map(function(t){return e.toPropertyOrder(t)})},FS.prototype.fromOrder=function(t){var e=this;return t.map(function(t){return e.fromPropertyOrder(t)})},FS.prototype.toCursor=function(t){var e=this;return{before:t.before,values:t.position.map(function(t){return e.toValue(t)})}},FS.prototype.fromCursor=function(t){var e=this,n=!!t.before,r=t.values.map(function(t){return e.fromValue(t)});return new fS(r,n)},FS.prototype.toDirection=function(t){return RS[t.name]},FS.prototype.fromDirection=function(t){switch(t){case"ASCENDING":return hS.ASCENDING;case"DESCENDING":return hS.DESCENDING;default:return}},FS.prototype.toOperatorName=function(t){return OS[t.name]},FS.prototype.fromOperatorName=function(t){switch(t){case"EQUAL":return KT.EQUAL;case"GREATER_THAN":return KT.GREATER_THAN;case"GREATER_THAN_OR_EQUAL":return KT.GREATER_THAN_OR_EQUAL;case"LESS_THAN":return KT.LESS_THAN;case"LESS_THAN_OR_EQUAL":return KT.LESS_THAN_OR_EQUAL;case"ARRAY_CONTAINS":return KT.ARRAY_CONTAINS;case"IN":return KT.IN;case"ARRAY_CONTAINS_ANY":return KT.ARRAY_CONTAINS_ANY;case"OPERATOR_UNSPECIFIED":return Cm("Unspecified operator");default:return Cm("Unknown operator")}},FS.prototype.toFieldPathReference=function(t){return{fieldPath:t.canonicalString()}},FS.prototype.fromFieldPathReference=function(t){return kv.fromServerFormat(t.fieldPath)},FS.prototype.toPropertyOrder=function(t){return{field:this.toFieldPathReference(t.field),direction:this.toDirection(t.dir)}},FS.prototype.fromPropertyOrder=function(t){return new dS(this.fromFieldPathReference(t.field),this.fromDirection(t.direction))},FS.prototype.fromFieldFilter=function(t){return GT.create(this.fromFieldPathReference(t.fieldFilter.field),this.fromOperatorName(t.fieldFilter.op),this.fromValue(t.fieldFilter.value))},FS.prototype.toUnaryOrFieldFilter=function(t){if(t.op===KT.EQUAL){if(t.value.isEqual(zb.NAN))return{unaryFilter:{field:this.toFieldPathReference(t.field),op:"IS_NAN"}};if(t.value.isEqual(xb.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)}}},FS.prototype.fromUnaryFilter=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.fromFieldPathReference(t.unaryFilter.field);return GT.create(e,KT.EQUAL,zb.NAN);case"IS_NULL":var n=this.fromFieldPathReference(t.unaryFilter.field);return GT.create(n,KT.EQUAL,xb.INSTANCE);case"OPERATOR_UNSPECIFIED":return Cm("Unspecified filter");default:return Cm("Unknown filter")}},FS.prototype.toDocumentMask=function(t){var e=[];return t.fields.forEach(function(t){return e.push(t.canonicalString())}),{fieldPaths:e}},FS.prototype.fromDocumentMask=function(t){var e=(t.fieldPaths||[]).map(function(t){return kv.fromServerFormat(t)});return rb.fromArray(e)},FS);function FS(t,e){this.databaseId=t,this.options=e}var US=function(){this.viewSnap=null,this.targetId=0,this.listeners=[]},qS=(VS.prototype.listen=function(t){var e=t.query,n=!1,r=this.queries.get(e);return r||(n=!0,r=new US,this.queries.set(e,r)),r.listeners.push(t),Nm(!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)},VS.prototype.unlisten=function(o){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(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]})})},VS.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()},VS.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)},VS.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()},VS.prototype.addSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.add(t),t.next()},VS.prototype.removeSnapshotsInSyncListener=function(t){this.snapshotsInSyncListeners.delete(t)},VS.prototype.raiseSnapshotsInSyncEvent=function(){this.snapshotsInSyncListeners.forEach(function(t){t.next()})},VS);function VS(t){this.syncEngine=t,this.queries=new Rw(function(t){return t.canonicalId()}),this.onlineState=ZE.Unknown,this.snapshotsInSyncListeners=new Set,this.syncEngine.subscribe(this)}var BS=(jS.prototype.onViewSnapshot=function(t){if(Nm(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!==lT.Metadata&&e.push(i)}t=new bT(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},jS.prototype.onError=function(t){this.queryObserver.error(t)},jS.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},jS.prototype.shouldRaiseInitialEvent=function(t,e){if(Nm(!this.raisedInitialEvent,"Determining whether to raise first event but already had first event"),!t.fromCache)return!0;var n=e!==ZE.Offline;return this.options.waitForSyncWhenOnline&&n?(Nm(t.fromCache,"Waiting for sync, but snapshot is not from cache"),!1):!t.docs.isEmpty()||e===ZE.Offline},jS.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},jS.prototype.raiseInitialEvent=function(t){Nm(!this.raisedInitialEvent,"Trying to raise initial events for second time"),t=bT.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.raisedInitialEvent=!0,this.queryObserver.next(t)},jS);function jS(t,e,n){this.query=t,this.queryObserver=e,this.raisedInitialEvent=!1,this.snap=null,this.onlineState=ZE.Unknown,this.options=n||{}}var WS=(KS.fromSnapshot=function(t,e){for(var n=gg(),r=gg(),i=0,o=e.docChanges;i<o.length;i++){var a=o[i];switch(a.type){case lT.Added:n=n.add(a.doc.key);break;case lT.Removed:r=r.add(a.doc.key)}}return new KS(t,e.fromCache,n,r)},KS);function KS(t,e,n,r){this.targetId=t,this.fromCache=e,this.addedKeys=n,this.removedKeys=r}var QS=function(t){this.key=t},HS=function(t){this.key=t},GS=(Object.defineProperty(zS.prototype,"syncedDocuments",{get:function(){return this._syncedDocuments},enumerable:!0,configurable:!0}),zS.prototype.computeDocChanges=function(t,e){var s=this,u=e?e.changeSet:new vT,c=e?e.documentSet:this.documentSet,h=e?e.mutatedKeys:this.mutatedKeys,l=c,f=!1,p=this.query.hasLimit()&&c.size===this.query.limit?c.last():null;if(t.inorderTraversal(function(t,e){var n=c.get(t),r=e instanceof Tw?e:null;r&&(Nm(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:lT.Metadata,doc:r}),a=!0):s.shouldWaitForSyncedDocument(n,r)||(u.track({type:lT.Modified,doc:r}),a=!0,p&&0<s.query.docComparator(r,p)&&(f=!0)):!n&&r?(u.track({type:lT.Added,doc:r}),a=!0):n&&!r&&(u.track({type:lT.Removed,doc:n}),a=!0,p&&(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.hasLimit())for(;l.size>this.query.limit;){var n=l.last();l=l.delete(n.key),h=h.delete(n.key),u.track({type:lT.Removed,doc:n})}return Nm(!f||!e,"View was refilled using docs that themselves needed refilling."),{documentSet:l,changeSet:u,needsRefill:f,mutatedKeys:h}},zS.prototype.shouldWaitForSyncedDocument=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},zS.prototype.applyChanges=function(t,e,n){var r=this;Nm(!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 lT.Added:return 1;case lT.Modified:case lT.Metadata:return 2;case lT.Removed:return 0;default:return Cm("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?pT.Synced:pT.Local,u=s!==this.syncState;return this.syncState=s,0!==o.length||u?{snapshot:new bT(this.query,t.documentSet,i,o,t.mutatedKeys,s===pT.Local,u,!1),limboChanges:a}:{limboChanges:a}},zS.prototype.applyOnlineStateChange=function(t){return this.current&&t===ZE.Offline?(this.current=!1,this.applyChanges({documentSet:this.documentSet,changeSet:new vT,mutatedKeys:this.mutatedKeys,needsRefill:!1},!1)):{limboChanges:[]}},zS.prototype.shouldBeInLimbo=function(t){return!this._syncedDocuments.has(t)&&!!this.documentSet.has(t)&&!this.documentSet.get(t).hasLocalMutations},zS.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 Nm(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)},zS.prototype.updateLimboDocuments=function(){var e=this;if(!this.current)return[];var n=this.limboDocuments;this.limboDocuments=gg(),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 HS(t))}),this.limboDocuments.forEach(function(t){n.has(t)||r.push(new QS(t))}),r},zS.prototype.synchronizeWithPersistedState=function(t){this._syncedDocuments=t.remoteKeys,this.limboDocuments=gg();var e=this.computeDocChanges(t.documents);return this.applyChanges(e,!0)},zS.prototype.computeInitialSnapshot=function(){return bT.fromInitialDocuments(this.query,this.documentSet,this.mutatedKeys,this.syncState===pT.Local)},zS);function zS(t,e){this.query=t,this._syncedDocuments=e,this.syncState=null,this.current=!1,this.limboDocuments=gg(),this.mutatedKeys=gg(),this.documentSet=new yT(t.docComparator.bind(t))}var YS=(XS.prototype.run=function(){this.runWithBackOff()},XS.prototype.runWithBackOff=function(){var t=this;this.backoff.backoffAndRun(function(){return ea(t,void 0,void 0,function(){var e,n,r=this;return na(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]})})})},XS.prototype.tryRunUpdateFunction=function(t){try{var e=this.updateFunction(t);return!LE(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}},XS.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)},XS.prototype.isRetryableTransactionError=function(t){if("FirebaseError"!==t.name)return!1;var e=t.code;return"aborted"===e||"failed-precondition"===e||!cT(e)},XS);function XS(t,e,n,r){this.asyncQueue=t,this.remoteStore=e,this.updateFunction=n,this.deferred=r,this.retries=5,this.backoff=new UE(this.asyncQueue,Pv.RetryTransaction)}var JS="SyncEngine",$S=function(t,e,n){this.query=t,this.targetId=e,this.view=n},ZS=function(t){this.key=t,this.receivedDocument=!1},tI=(Object.defineProperty(eI.prototype,"isPrimaryClient",{get:function(){return!0===this.isPrimary},enumerable:!0,configurable:!0}),eI.prototype.subscribe=function(t){Nm(null!==t,"SyncEngine listener cannot be null"),Nm(null===this.syncEngineListener,"SyncEngine already has a subscriber."),this.syncEngineListener=t},eI.prototype.listen=function(a){return ea(this,void 0,void 0,function(){var e,n,r,i,o;return na(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.allocateQuery(a)];case 2:return i=t.sent(),o=this.sharedClientState.addLocalQueryTarget(i.targetId),e=i.targetId,[4,this.initializeViewAndComputeSnapshot(i,"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]}})})},eI.prototype.initializeViewAndComputeSnapshot=function(u,c){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return na(this,function(t){switch(t.label){case 0:return e=u.query,[4,this.localStore.executeQuery(e,!0)];case 1:return n=t.sent(),r=new GS(e,n.remoteKeys),i=r.computeDocChanges(n.documents),o=TT.createSynthesizedTargetChangeForCurrentChange(u.targetId,c&&this.onlineState!==ZE.Offline),Nm(0===(a=r.applyChanges(i,!0===this.isPrimary,o)).limboChanges.length,"View returned limbo docs before target ack from the server."),Nm(!!a.snapshot,"applyChanges for new view should always return a snapshot"),s=new $S(e,u.targetId,r),this.queryViewsByQuery.set(e,s),this.queryViewsByTarget[u.targetId]=s,[2,a.snapshot]}})})},eI.prototype.synchronizeViewAndComputeSnapshot=function(r){return ea(this,void 0,void 0,function(){var e,n;return na(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]}})})},eI.prototype.unlisten=function(r){return ea(this,void 0,void 0,function(){var e,n=this;return na(this,function(t){switch(t.label){case 0:return this.assertSubscribed("unlisten()"),Nm(!!(e=this.queryViewsByQuery.get(r)),"Trying to unlisten on query not found:"+r),this.isPrimary?(this.sharedClientState.removeLocalQueryTarget(e.targetId),this.sharedClientState.isActiveQueryTarget(e.targetId)?[3,2]:[4,this.localStore.releaseQuery(r,!1).then(function(){n.sharedClientState.clearQueryState(e.targetId),n.remoteStore.unlisten(e.targetId),n.removeAndCleanupQuery(e)}).catch($_)]):[3,3];case 1:t.sent(),t.label=2;case 2:return[3,5];case 3:return this.removeAndCleanupQuery(e),[4,this.localStore.releaseQuery(r,!0)];case 4:t.sent(),t.label=5;case 5:return[2]}})})},eI.prototype.write=function(n,r){return ea(this,void 0,void 0,function(){var e;return na(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]}})})},eI.prototype.runTransaction=function(t,e,n){new YS(t,this.remoteStore,e,n).run()},eI.prototype.applyRemoteEvent=function(n){return ea(this,void 0,void 0,function(){var e,r=this;return na(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(),qm(n.targetChanges,function(t,e){var n=r.limboResolutionsByTarget[Number(t)];n&&(Nm(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?Nm(n.receivedDocument,"Received change for limbo target document without add."):0<e.removedDocuments.size&&(Nm(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,$_(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},eI.prototype.applyOnlineStateChange=function(r,t){if(this.isPrimary&&t===eT.RemoteStore||!this.isPrimary&&t===eT.SharedClientState){this.assertSubscribed("applyOnlineStateChange()");var i=[];this.queryViewsByQuery.forEach(function(t,e){var n=e.view.applyOnlineStateChange(r);Nm(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)}},eI.prototype.rejectListen=function(u,c){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s=this;return na(this,function(t){switch(t.label){case 0:return this.assertSubscribed("rejectListens()"),this.sharedClientState.updateQueryState(u,"rejected",c),e=this.limboResolutionsByTarget[u],(n=e&&e.key)?(this.limboTargetsByKey=this.limboTargetsByKey.remove(n),delete this.limboResolutionsByTarget[u],r=(r=new $v(Rv.comparator)).insert(n,new Cw(n,Xv.forDeletedDoc())),i=gg().add(n),o=new _T(Xv.MIN,{},new ag(sv),r,i),[2,this.applyRemoteEvent(o)]):[3,1];case 1:return Nm(!!(a=this.queryViewsByTarget[u]),"Unknown targetId: "+u),[4,this.localStore.releaseQuery(a.query,!1).then(function(){return s.removeAndCleanupQuery(a)}).catch($_)];case 2:t.sent(),this.syncEngineListener.onWatchError(a.query,c),t.label=3;case 3:return[2]}})})},eI.prototype.applyBatchState=function(n,r,i){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return this.assertSubscribed("applyBatchState()"),[4,this.localStore.lookupMutationDocuments(n)];case 1:return null===(e=t.sent())?(Tm(JS,"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)):Cm("Unknown batchState: "+r),t.label=4;case 4:return[4,this.emitNewSnapsAndNotifyLocalStore(e)];case 5:return t.sent(),[2]}})})},eI.prototype.applySuccessfulWrite=function(r){return ea(this,void 0,void 0,function(){var e,n;return na(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,$_(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},eI.prototype.rejectFailedWrite=function(n,r){return ea(this,void 0,void 0,function(){var e;return na(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,$_(t.sent())];case 5:return t.sent(),[3,6];case 6:return[2]}})})},eI.prototype.registerPendingWritesCallback=function(r){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return this.remoteStore.canUseNetwork()||Tm(JS,"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]}})})},eI.prototype.triggerPendingWritesCallbacks=function(t){(this.pendingWritesCallbacks.get(t)||[]).forEach(function(t){t.resolve()}),this.pendingWritesCallbacks.delete(t)},eI.prototype.rejectOutstandingPendingWritesCallbacks=function(e){this.pendingWritesCallbacks.forEach(function(t){t.forEach(function(t){t.reject(new Pm(Om.CANCELLED,e))})}),this.pendingWritesCallbacks.clear()},eI.prototype.addMutationCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];n=(n=n||new $v(sv)).insert(t,e),this.mutationUserCallbacks[this.currentUser.toKey()]=n},eI.prototype.processUserCallback=function(t,e){var n=this.mutationUserCallbacks[this.currentUser.toKey()];if(n){var r=n.get(t);r&&(Nm(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}},eI.prototype.removeAndCleanupQuery=function(t){var e=this;if(this.sharedClientState.removeLocalQueryTarget(t.targetId),this.queryViewsByQuery.delete(t.query),delete this.queryViewsByTarget[t.targetId],this.isPrimary){var n=this.limboDocumentRefs.referencesForId(t.targetId);this.limboDocumentRefs.removeReferencesForId(t.targetId),n.forEach(function(t){e.limboDocumentRefs.containsKey(t)||e.removeLimboTarget(t)})}},eI.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])},eI.prototype.updateTrackedLimbos=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof QS?(this.limboDocumentRefs.addReference(i.key,t),this.trackLimboChange(i)):i instanceof HS?(Tm(JS,"Document no longer in limbo: "+i.key),this.limboDocumentRefs.removeReference(i.key,t),this.limboDocumentRefs.containsKey(i.key)||this.removeLimboTarget(i.key)):Cm("Unknown limbo change: "+JSON.stringify(i))}},eI.prototype.trackLimboChange=function(t){var e=t.key;if(!this.limboTargetsByKey.get(e)){Tm(JS,"New document in limbo: "+e);var n=this.limboTargetIdGenerator.next(),r=BT.atPath(e.path);this.limboResolutionsByTarget[n]=new ZS(e),this.remoteStore.listen(new A_(r,n,E_.LimboResolution,bv.INVALID)),this.limboTargetsByKey=this.limboTargetsByKey.insert(e,n)}},eI.prototype.currentLimboDocs=function(){return this.limboTargetsByKey},eI.prototype.emitNewSnapsAndNotifyLocalStore=function(r,u){return ea(this,void 0,void 0,function(){var o,a,e,s=this;return na(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=WS.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]}})})},eI.prototype.assertSubscribed=function(t){Nm(null!==this.syncEngineListener,"Trying to call "+t+" before calling subscribe().")},eI.prototype.handleCredentialChange=function(r){return ea(this,void 0,void 0,function(){var e,n;return na(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]}})})},eI.prototype.applyPrimaryState=function(c){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u=this;return na(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(),Um(this.queryViewsByTarget,function(t,e){u.sharedClientState.isLocalQueryTarget(t)?a.push(t):s=s.then(function(){return u.unlisten(e.query)}),u.remoteStore.unlisten(e.targetId)}),[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]}})})},eI.prototype.resetLimboDocuments=function(){var e=this;Um(this.limboResolutionsByTarget,function(t){e.remoteStore.unlisten(t)}),this.limboDocumentRefs.removeAllReferences(),this.limboResolutionsByTarget=[],this.limboTargetsByKey=new $v(Rv.comparator)},eI.prototype.synchronizeQueryViewsAndRaiseSnapshots=function(h){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c;return na(this,function(t){switch(t.label){case 0:e=[],n=[],r=0,i=h,t.label=1;case 1:return r<i.length?(o=i[r],a=void 0,(s=this.queryViewsByTarget[o])?[4,this.localStore.releaseQuery(s.query,!0)]:[3,5]):[3,11];case 2:return t.sent(),[4,this.localStore.allocateQuery(s.query)];case 3:return a=t.sent(),[4,this.synchronizeViewAndComputeSnapshot(s)];case 4:return(u=t.sent()).snapshot&&n.push(u.snapshot),[3,9];case 5:return Nm(!0===this.isPrimary,"A secondary tab should never have an active query without an active view."),[4,this.localStore.getQueryForTarget(o)];case 6:return Nm(!!(c=t.sent()),"Query data for target "+o+" not found"),[4,this.localStore.allocateQuery(c)];case 7:return a=t.sent(),[4,this.initializeViewAndComputeSnapshot(a,!1)];case 8:t.sent(),t.label=9;case 9:e.push(a),t.label=10;case 10:return r++,[3,1];case 11:return this.syncEngineListener.onWatchChange(n),[2,e]}})})},eI.prototype.getActiveClients=function(){return this.localStore.getActiveClients()},eI.prototype.applyTargetState=function(i,o,a){return ea(this,void 0,void 0,function(){var e,n,r;return na(this,function(t){switch(t.label){case 0:if(this.isPrimary)return Tm(JS,"Ignoring unexpected query state notification."),[2];if(!this.queryViewsByTarget[i])return[3,7];switch(o){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=_T.createSynthesizedRemoteEventForCurrentChange(i,"current"===o),[4,this.emitNewSnapsAndNotifyLocalStore(e,n)];case 3:return t.sent(),[3,7];case 4:return r=this.queryViewsByTarget[i],this.removeAndCleanupQuery(r),[4,this.localStore.releaseQuery(r.query,!0)];case 5:return t.sent(),this.syncEngineListener.onWatchError(r.query,a),[3,7];case 6:Cm("Unexpected target state: "+o),t.label=7;case 7:return[2]}})})},eI.prototype.applyActiveTargetsChange=function(l,f){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h=this;return na(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],Nm(!this.queryViewsByTarget[c],"Trying to add an already active target"),[4,this.localStore.getQueryForTarget(c)]):[3,6];case 2:return Nm(!!(r=t.sent()),"Query data for active target "+c+" not found"),[4,this.localStore.allocateQuery(r)];case 3:return i=t.sent(),[4,this.initializeViewAndComputeSnapshot(i,!1)];case 4:t.sent(),this.remoteStore.listen(i),t.label=5;case 5:return e++,[3,1];case 6:o=function(e){var n;return na(this,function(t){switch(t.label){case 0:return(n=a.queryViewsByTarget[e])?[4,a.localStore.releaseQuery(n.query,!1).then(function(){h.remoteStore.unlisten(e),h.removeAndCleanupQuery(n)}).catch($_)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[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]}})})},eI.prototype.enableNetwork=function(){return this.localStore.setNetworkEnabled(!0),this.remoteStore.enableNetwork()},eI.prototype.disableNetwork=function(){return this.localStore.setNetworkEnabled(!1),this.remoteStore.disableNetwork()},eI.prototype.getRemoteKeysForTarget=function(t){var e=this.limboResolutionsByTarget[t];return e&&e.receivedDocument?gg().add(e.key):this.queryViewsByTarget[t]?this.queryViewsByTarget[t].view.syncedDocuments:gg()},eI);function eI(t,e,n,r){this.localStore=t,this.remoteStore=e,this.sharedClientState=n,this.currentUser=r,this.syncEngineListener=null,this.queryViewsByQuery=new Rw(function(t){return t.canonicalId()}),this.queryViewsByTarget={},this.limboTargetsByKey=new $v(Rv.comparator),this.limboResolutionsByTarget={},this.limboDocumentRefs=new aE,this.mutationUserCallbacks={},this.pendingWritesCallbacks=new Map,this.limboTargetIdGenerator=Yg.forSyncEngine(),this.isPrimary=void 0,this.onlineState=ZE.Unknown}var nI=(rI.prototype.isAuthenticated=function(){return null!=this.uid},rI.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},rI.prototype.isEqual=function(t){return t.uid===this.uid},rI.UNAUTHENTICATED=new rI(null),rI.GOOGLE_CREDENTIALS=new rI("google-credentials-uid"),rI.FIRST_PARTY=new rI("first-party-uid"),rI);function rI(t){this.uid=t}var iI="SharedClientState",oI="firestore_clients",aI="firestore_mutations",sI="firestore_targets",uI=(cI.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 Pm(r.error.code,r.error.message)),i?new cI(t,e,r.state,o):(Sm(iI,"Failed to parse mutation state for ID '"+e+"': "+n),null)},cI.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)},cI);function cI(t,e,n,r){this.user=t,this.batchId=e,this.state=n,Nm(void 0!==(this.error=r)==("rejected"===n),"MutationMetadata must contain an error iff state is 'rejected'")}var hI=(lI.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 Pm(n.error.code,n.error.message)),r?new lI(t,n.state,i):(Sm(iI,"Failed to parse target state for ID '"+t+"': "+e),null)},lI.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)},lI);function lI(t,e,n){this.targetId=t,this.state=e,Nm(void 0!==(this.error=n)==("rejected"===e),"QueryTargetMetadata must contain an error iff state is 'rejected'")}var fI=(pI.fromWebStorageEntry=function(t,e){for(var n=JSON.parse(e),r="object"==typeof n&&n.activeTargetIds instanceof Array,i=wg(),o=0;r&&o<n.activeTargetIds.length;++o)r=FE(n.activeTargetIds[o]),i=i.add(n.activeTargetIds[o]);return r?new pI(t,i):(Sm(iI,"Failed to parse client data for instance '"+t+"': "+e),null)},pI);function pI(t,e){this.clientId=t,this.activeTargetIds=e}var dI=(yI.fromWebStorageEntry=function(t){var e=JSON.parse(t);return"object"==typeof e&&e.onlineState in ZE&&"string"==typeof e.clientId?new yI(e.clientId,ZE[e.onlineState]):(Sm(iI,"Failed to parse online state: "+t),null)},yI);function yI(t,e){this.clientId=t,this.onlineState=e}var mI=(vI.prototype.addQueryTarget=function(t){Nm(!this.activeTargetIds.has(t),"Target with ID '"+t+"' already active."),this.activeTargetIds=this.activeTargetIds.add(t)},vI.prototype.removeQueryTarget=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},vI.prototype.toWebStorageJSON=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},vI);function vI(){this.activeTargetIds=wg()}var gI=(bI.isAvailable=function(t){return!(!t.window||null==t.window.localStorage)},bI.prototype.start=function(){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f=this;return na(this,function(t){switch(t.label){case 0:return Nm(!this.started,"WebStorageSharedClientState already started"),Nm(null!==this.syncEngine,"syncEngine property must be set before calling start()"),Nm(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=fI.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]}})})},bI.prototype.writeSequenceNumber=function(t){this.setItem(this.sequenceNumberKey,JSON.stringify(t))},bI.prototype.getAllActiveQueryTargets=function(){var n=wg();return qm(this.activeClients,function(t,e){n=n.unionWith(e.activeTargetIds)}),n},bI.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},bI.prototype.addPendingMutation=function(t){this.persistMutationState(t,"pending")},bI.prototype.updateMutationState=function(t,e,n){this.persistMutationState(t,e,n),this.removeMutationState(t)},bI.prototype.addLocalQueryTarget=function(t){var e="not-current";if(this.isActiveQueryTarget(t)){var n=this.storage.getItem(this.toWebStorageQueryTargetMetadataKey(t));if(n){var r=hI.fromWebStorageEntry(t,n);r&&(e=r.state)}}return this.localClientState.addQueryTarget(t),this.persistClientState(),e},bI.prototype.removeLocalQueryTarget=function(t){this.localClientState.removeQueryTarget(t),this.persistClientState()},bI.prototype.isLocalQueryTarget=function(t){return this.localClientState.activeTargetIds.has(t)},bI.prototype.clearQueryState=function(t){this.removeItem(this.toWebStorageQueryTargetMetadataKey(t))},bI.prototype.updateQueryState=function(t,e,n){this.persistQueryTargetState(t,e,n)},bI.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)})},bI.prototype.setOnlineState=function(t){this.persistOnlineState(t)},bI.prototype.shutdown=function(){this.started&&(this.platform.window.removeEventListener("storage",this.storageListener),this.removeItem(this.localClientStorageKey),this.started=!1)},bI.prototype.getItem=function(t){var e=this.storage.getItem(t);return Tm(iI,"READ",t,e),e},bI.prototype.setItem=function(t,e){Tm(iI,"SET",t,e),this.storage.setItem(t,e)},bI.prototype.removeItem=function(t){Tm(iI,"REMOVE",t),this.storage.removeItem(t)},bI.prototype.handleWebStorageEvent=function(s){var t=this;if(s.storageArea===this.storage){if(Tm(iI,"EVENT",s.key,s.newValue),s.key===this.localClientStorageKey)return void Sm("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.queue.enqueueAndForget(function(){return ea(t,void 0,void 0,function(){var e,n,r,i,o,a;return na(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&&(Nm(!!this.sequenceNumberHandler,"Missing sequenceNumberHandler"),(a=function(t){var e=bv.INVALID;if(null!=t)try{var n=JSON.parse(t);Nm("number"==typeof n,"Found non-numeric sequence number"),e=n}catch(t){Sm(iI,"Failed to read sequence number from WebStorage",t)}return e}(s.newValue))!==bv.INVALID&&this.sequenceNumberHandler(a));return[2]})})})}},Object.defineProperty(bI.prototype,"localClientState",{get:function(){return this.activeClients[this.localClientId]},enumerable:!0,configurable:!0}),bI.prototype.persistClientState=function(){this.setItem(this.localClientStorageKey,this.localClientState.toWebStorageJSON())},bI.prototype.persistMutationState=function(t,e,n){var r=new uI(this.currentUser,t,e,n),i=this.toWebStorageMutationBatchKey(t);this.setItem(i,r.toWebStorageJSON())},bI.prototype.removeMutationState=function(t){var e=this.toWebStorageMutationBatchKey(t);this.removeItem(e)},bI.prototype.persistOnlineState=function(t){var e={clientId:this.localClientId,onlineState:ZE[t]};this.storage.setItem(this.onlineStateKey,JSON.stringify(e))},bI.prototype.persistQueryTargetState=function(t,e,n){var r=this.toWebStorageQueryTargetMetadataKey(t),i=new hI(t,e,n);this.setItem(r,i.toWebStorageJSON())},bI.prototype.toWebStorageClientStateKey=function(t){return Nm(-1===t.indexOf("_"),"Client key cannot contain '_', but was '"+t+"'"),oI+"_"+this.persistenceKey+"_"+t},bI.prototype.toWebStorageQueryTargetMetadataKey=function(t){return sI+"_"+this.persistenceKey+"_"+t},bI.prototype.toWebStorageMutationBatchKey=function(t){var e=aI+"_"+this.persistenceKey+"_"+t;return this.currentUser.isAuthenticated()&&(e+="_"+this.currentUser.uid),e},bI.prototype.fromWebStorageClientStateKey=function(t){var e=this.clientStateKeyRe.exec(t);return e?e[1]:null},bI.prototype.fromWebStorageClientState=function(t,e){var n=this.fromWebStorageClientStateKey(t);return Nm(null!==n,"Cannot parse client state key '"+t+"'"),fI.fromWebStorageEntry(n,e)},bI.prototype.fromWebStorageMutationMetadata=function(t,e){var n=this.mutationBatchKeyRe.exec(t);Nm(null!==n,"Cannot parse mutation batch key '"+t+"'");var r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return uI.fromWebStorageEntry(new nI(i),r,e)},bI.prototype.fromWebStorageQueryTargetMetadata=function(t,e){var n=this.queryTargetKeyRe.exec(t);Nm(null!==n,"Cannot parse query target key '"+t+"'");var r=Number(n[1]);return hI.fromWebStorageEntry(r,e)},bI.prototype.fromWebStorageOnlineState=function(t){return dI.fromWebStorageEntry(t)},bI.prototype.handleMutationBatchEvent=function(e){return ea(this,void 0,void 0,function(){return na(this,function(t){return e.user.uid!==this.currentUser.uid?(Tm(iI,"Ignoring mutation for non-active user "+e.user.uid),[2]):[2,this.syncEngine.applyBatchState(e.batchId,e.state,e.error)]})})},bI.prototype.handleQueryTargetEvent=function(t){return this.syncEngine.applyTargetState(t.targetId,t.state,t.error)},bI.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 ea(n,void 0,void 0,function(){return na(this,function(t){return r.has(e)||o.push(e),[2]})})}),r.forEach(function(e){return ea(n,void 0,void 0,function(){return na(this,function(t){return i.has(e)||a.push(e),[2]})})}),this.syncEngine.applyActiveTargetsChange(o,a)},bI.prototype.handleOnlineStateEvent=function(t){this.activeClients[t.clientId]&&this.onlineStateHandler(t.onlineState)},bI);function bI(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=[],!bI.isAvailable(this.platform))throw new Pm(Om.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 mI,this.clientStateKeyRe=new RegExp("^"+oI+"_"+o+"_([^_]*)$"),this.mutationBatchKeyRe=new RegExp("^"+aI+"_"+o+"_(\\d+)(?:_(.*))?$"),this.queryTargetKeyRe=new RegExp("^"+sI+"_"+o+"_(\\d+)$"),this.onlineStateKey="firestore_online_state_"+n,this.platform.window.addEventListener("storage",this.storageListener)}var wI=(_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 mI,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 mI,this.queryState={},this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null}var EI="FirestoreClient",TI=(SI.prototype.lruParams=function(){return L_.withCacheSize(this.cacheSizeBytes)},SI);function SI(t,e){this.cacheSizeBytes=t,this.synchronizeTabs=e}var II=function(){},CI=(NI.prototype.start=function(t){var n=this;this.verifyNotTerminated();var r=new xv,i=new xv,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},NI.prototype.enableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return t.syncEngine.enableNetwork()})},NI.prototype.initializePersistence=function(t,e,n){var r=this;return t instanceof TI?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())},NI.prototype.canFallback=function(t){return t instanceof Pm?t.code===Om.FAILED_PRECONDITION||t.code===Om.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},NI.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new Pm(Om.FAILED_PRECONDITION,"The client has already been terminated.")},NI.prototype.startIndexedDbPersistence=function(r,i){var t=this,o=X_.buildStoragePrefix(this.databaseInfo),a=new LS(this.databaseInfo.databaseId,{useProto3Json:!0});return Promise.resolve().then(function(){return ea(t,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:if(i.synchronizeTabs&&!gI.isAvailable(this.platform))throw new Pm(Om.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");return e=i.lruParams(),this.sharedClientState=i.synchronizeTabs?new gI(this.asyncQueue,this.platform,o,this.clientId,r):new wI,[4,X_.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]}})})})},NI.prototype.startMemoryPersistence=function(){return this.persistence=_E.createEagerPersistence(this.clientId),this.sharedClientState=new wI,Promise.resolve(null)},NI.prototype.initializeRest=function(c,h){var t=this;return Tm(EI,"Initializing. user=",c.uid),this.platform.loadConnection(this.databaseInfo).then(function(u){return ea(t,void 0,void 0,function(){var e,n,r,i,o,a,s=this;return na(this,function(t){switch(t.label){case 0:return e=new DE,this.localStore=new lE(this.persistence,e,c),[4,this.localStore.start()];case 1:return t.sent(),h&&(this.lruScheduler=new U_(h,this.asyncQueue,this.localStore)),n=this.platform.newConnectivityMonitor(),r=this.platform.newSerializer(this.databaseInfo.databaseId),i=new JE(this.asyncQueue,u,this.credentials,r),o=function(t){return s.syncEngine.applyOnlineStateChange(t,eT.RemoteStore)},a=function(t){return s.syncEngine.applyOnlineStateChange(t,eT.SharedClientState)},this.remoteStore=new FT(this.localStore,i,this.asyncQueue,o,n),this.syncEngine=new tI(this.localStore,this.remoteStore,this.sharedClientState,c),this.sharedClientState.onlineStateHandler=a,this.remoteStore.syncEngine=this.syncEngine,this.sharedClientState.syncEngine=this.syncEngine,this.eventMgr=new qS(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 ea(s,void 0,void 0,function(){return na(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 ea(s,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}})})})];case 5:return t.sent(),[2]}})})})},NI.prototype.handleCredentialChange=function(t){return this.asyncQueue.verifyOperationInProgress(),Tm(EI,"Credential Changed. Current user: "+t.uid),this.syncEngine.handleCredentialChange(t)},NI.prototype.disableNetwork=function(){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return t.syncEngine.disableNetwork()})},NI.prototype.terminate=function(){var t=this;return this.asyncQueue.enqueueAndInitiateShutdown(function(){return ea(t,void 0,void 0,function(){return na(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]}})})})},NI.prototype.waitForPendingWrites=function(){var t=this;this.verifyNotTerminated();var e=new xv;return this.asyncQueue.enqueueAndForget(function(){return t.syncEngine.registerPendingWritesCallback(e)}),e.promise},NI.prototype.listen=function(t,e,n){var r=this;this.verifyNotTerminated();var i=new BS(t,e,n);return this.asyncQueue.enqueueAndForget(function(){return r.eventMgr.listen(i)}),i},NI.prototype.unlisten=function(t){var e=this;this.clientTerminated||this.asyncQueue.enqueueAndForget(function(){return e.eventMgr.unlisten(t)})},NI.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 Tw)return t;if(t instanceof Cw)return null;throw new Pm(Om.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.)")})},NI.prototype.getDocumentsFromLocalCache=function(i){var t=this;return this.verifyNotTerminated(),this.asyncQueue.enqueue(function(){return ea(t,void 0,void 0,function(){var e,n,r;return na(this,function(t){switch(t.label){case 0:return[4,this.localStore.executeQuery(i,!0)];case 1:return e=t.sent(),n=new GS(i,e.remoteKeys),r=n.computeDocChanges(e.documents),[2,n.applyChanges(r,!1).snapshot]}})})})},NI.prototype.write=function(t){var e=this;this.verifyNotTerminated();var n=new xv;return this.asyncQueue.enqueueAndForget(function(){return e.syncEngine.write(t,n)}),n.promise},NI.prototype.databaseId=function(){return this.databaseInfo.databaseId},NI.prototype.addSnapshotsInSyncListener=function(t){var e=this;this.verifyNotTerminated(),this.asyncQueue.enqueueAndForget(function(){return e.eventMgr.addSnapshotsInSyncListener(t),Promise.resolve()})},NI.prototype.removeSnapshotsInSyncListener=function(t){this.clientTerminated||this.eventMgr.removeSnapshotsInSyncListener(t)},Object.defineProperty(NI.prototype,"clientTerminated",{get:function(){return this.asyncQueue.isShuttingDown},enumerable:!0,configurable:!0}),NI.prototype.transaction=function(t){var e=this;this.verifyNotTerminated();var n=new xv;return this.asyncQueue.enqueueAndForget(function(){return e.syncEngine.runTransaction(e.asyncQueue,t,n),Promise.resolve()}),n.promise},NI);function NI(t,e,n,r){this.platform=t,this.databaseInfo=e,this.credentials=n,this.asyncQueue=r,this.clientId=ov.newId()}var AI=(kI.prototype.next=function(t){this.scheduleEvent(this.observer.next,t)},kI.prototype.error=function(t){this.scheduleEvent(this.observer.error,t)},kI.prototype.mute=function(){this.muted=!0},kI.prototype.scheduleEvent=function(t,e){var n=this;this.muted||setTimeout(function(){n.muted||t(e)},0)},kI);function kI(t){this.observer=t,this.muted=!1}var DI=(RI.documentId=function(){return RI._DOCUMENT_ID},RI.prototype.isEqual=function(t){if(!(t instanceof RI))throw nv("isEqual","FieldPath",1,t);return this._internalPath.isEqual(t._internalPath)},RI._DOCUMENT_ID=new RI(kv.keyField().canonicalString()),RI);function RI(){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 Pm(Om.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" argument to be an array with at least "+iv(r,"element")+".")}("FieldPath",t,"fieldNames",1);for(var n=0;n<t.length;++n)if(Qm("FieldPath","string",n,t[n]),0===t[n].length)throw new Pm(Om.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new kv(t)}var OI=new RegExp("[~\\*/\\[\\]]");var PI=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={Authorization:"Bearer "+t}},MI=(xI.prototype.getToken=function(){return Promise.resolve(null)},xI.prototype.invalidateToken=function(){},xI.prototype.setChangeListener=function(t){Nm(!this.changeListener,"Can only call setChangeListener() once."),(this.changeListener=t)(nI.UNAUTHENTICATED)},xI.prototype.removeChangeListener=function(){Nm(null!==this.changeListener,"removeChangeListener() when no listener registered"),this.changeListener=null},xI);function xI(){this.changeListener=null}var LI=(FI.prototype.getToken=function(){var e=this;Nm(null!=this.tokenListener,"getToken cannot be called after listener removed.");var n=this.tokenCounter,t=this.forceRefresh;return this.forceRefresh=!1,this.app.INTERNAL.getToken(t).then(function(t){if(e.tokenCounter!==n)throw new Pm(Om.ABORTED,"getToken aborted due to token change.");return t?(Nm("string"==typeof t.accessToken,"Invalid tokenData returned from getToken():"+t),new PI(t.accessToken,e.currentUser)):null})},FI.prototype.invalidateToken=function(){this.forceRefresh=!0},FI.prototype.setChangeListener=function(t){Nm(!this.changeListener,"Can only call setChangeListener() once."),(this.changeListener=t)(this.currentUser)},FI.prototype.removeChangeListener=function(){Nm(null!=this.tokenListener,"removeChangeListener() called twice"),Nm(null!==this.changeListener,"removeChangeListener() called when no listener registered"),this.app.INTERNAL.removeAuthTokenListener(this.tokenListener),this.tokenListener=null,this.changeListener=null},FI.prototype.getUser=function(){var t=this.app.INTERNAL.getUid();return Nm(null===t||"string"==typeof t,"Received invalid UID: "+t),new nI(t)},FI);function FI(t){var e=this;this.app=t,this.tokenListener=null,this.currentUser=nI.UNAUTHENTICATED,this.tokenCounter=0,this.changeListener=null,this.forceRefresh=!1,this.tokenListener=function(){e.tokenCounter++,e.currentUser=e.getUser(),e.changeListener&&e.changeListener(e.currentUser)},this.currentUser=this.getUser(),this.tokenCounter=0,this.app.INTERNAL.addAuthTokenListener(this.tokenListener)}var UI=(Object.defineProperty(qI.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}),qI);function qI(t,e){this.gapi=t,this.sessionIndex=e,this.type="FirstParty",this.user=nI.FIRST_PARTY}var VI=(BI.prototype.getToken=function(){return Promise.resolve(new UI(this.gapi,this.sessionIndex))},BI.prototype.setChangeListener=function(t){t(nI.FIRST_PARTY)},BI.prototype.removeChangeListener=function(){},BI.prototype.invalidateToken=function(){},BI);function BI(t,e){this.gapi=t,this.sessionIndex=e}function jI(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 WI=(KI.delete=function(){return Bm("FieldValue.delete",arguments),HI.instance},KI.serverTimestamp=function(){return Bm("FieldValue.serverTimestamp",arguments),YI.instance},KI.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Wm("FieldValue.arrayUnion",arguments,1),new $I(t)},KI.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Wm("FieldValue.arrayRemove",arguments,1),new eC(t)},KI.increment=function(t){return Qm("FieldValue.increment","number",1,t),jm("FieldValue.increment",arguments,1),new iC(t)},KI.prototype.isEqual=function(t){return this===t},KI);function KI(t){this._methodName=t}var QI,HI=(Zo(GI,QI=WI),GI.instance=new GI,GI);function GI(){return QI.call(this,"FieldValue.delete")||this}var zI,YI=(Zo(XI,zI=WI),XI.instance=new XI,XI);function XI(){return zI.call(this,"FieldValue.serverTimestamp")||this}var JI,$I=(Zo(ZI,JI=WI),ZI);function ZI(t){var e=JI.call(this,"FieldValue.arrayUnion")||this;return e._elements=t,e}var tC,eC=(Zo(nC,tC=WI),nC);function nC(t){var e=tC.call(this,"FieldValue.arrayRemove")||this;return e._elements=t,e}var rC,iC=(Zo(oC,rC=WI),oC);function oC(t){var e=rC.call(this,"FieldValue.increment")||this;return e._operand=t,e}var aC=xm(WI,"Use FieldValue.<field>() instead."),sC=/^__.*__$/,uC=(cC.prototype.toMutations=function(t,e){var n=[];return null!==this.fieldMask?n.push(new gb(t,this.data,this.fieldMask,e)):n.push(new yb(t,this.data,e)),0<this.fieldTransforms.length&&n.push(new _b(t,this.fieldTransforms)),n},cC);function cC(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}var hC,lC,fC=(pC.prototype.toMutations=function(t,e){var n=[new gb(t,this.data,this.fieldMask,e)];return 0<this.fieldTransforms.length&&n.push(new _b(t,this.fieldTransforms)),n},pC);function pC(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}function dC(t){switch(t){case hC.Set:case hC.MergeSet:case hC.Update:return!0;case hC.Argument:return!1;default:throw Cm("Unexpected case for UserDataSource: "+t)}}(lC=hC=hC||{})[lC.Set=0]="Set",lC[lC.Update=1]="Update",lC[lC.MergeSet=2]="MergeSet",lC[lC.Argument=3]="Argument";var yC=(mC.prototype.childContextForField=function(t){var e=null==this.path?null:this.path.child(t),n=new mC(this.dataSource,this.methodName,e,!1,this.fieldTransforms,this.fieldMask);return n.validatePathSegment(t),n},mC.prototype.childContextForFieldPath=function(t){var e=null==this.path?null:this.path.child(t),n=new mC(this.dataSource,this.methodName,e,!1,this.fieldTransforms,this.fieldMask);return n.validatePath(),n},mC.prototype.childContextForArray=function(t){return new mC(this.dataSource,this.methodName,null,!0,this.fieldTransforms,this.fieldMask)},mC.prototype.createError=function(t){var e=null===this.path||this.path.isEmpty()?"":" (found in field "+this.path.toString()+")";return new Pm(Om.INVALID_ARGUMENT,"Function "+this.methodName+"() called with invalid data. "+t+e)},mC.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)})},mC.prototype.validatePath=function(){if(null!==this.path)for(var t=0;t<this.path.length;t++)this.validatePathSegment(this.path.get(t))},mC.prototype.validatePathSegment=function(t){if(dC(this.dataSource)&&sC.test(t))throw this.createError("Document fields cannot begin and end with __")},mC);function mC(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 vC=function(t,e){this.databaseId=t,this.key=e},gC=(bC.prototype.parseSetData=function(t,e){var n=new yC(hC.Set,t,kv.EMPTY_PATH);_C("Data must be an object, but it was:",n,e);var r=this.parseData(e,n);return new uC(r,null,n.fieldTransforms)},bC.prototype.parseMergeData=function(t,e,n){var r=new yC(hC.MergeSet,t,kv.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 ag(kv.comparator),u=0,c=n;u<c.length;u++){var h=c[u],l=void 0;if(h instanceof DI)l=h._internalPath;else{if("string"!=typeof h)throw Cm("Expected stringOrFieldPath to be a string or a FieldPath");l=TC(t,h)}if(!r.contains(l))throw new Pm(Om.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 uC(a,i,o)},bC.prototype.parseUpdateData=function(o,t){var a=this,s=new yC(hC.Update,o,kv.EMPTY_PATH);_C("Data must be an object, but it was:",s,t);var u=new ag(kv.comparator),c=yw.EMPTY;qm(t,function(t,e){var n=TC(o,t),r=s.childContextForFieldPath(n);if((e=a.runPreConverter(e,r))instanceof HI)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 fC(c,e,s.fieldTransforms)},bC.prototype.parseUpdateVarargs=function(t,e,n,r){var i=new yC(hC.Update,t,kv.EMPTY_PATH),o=[EC(t,e)],a=[n];if(r.length%2!=0)throw new Pm(Om.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(EC(t,r[s])),a.push(r[s+1]);var u=new ag(kv.comparator),c=yw.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 HI)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 fC(c,d,i.fieldTransforms)},bC.prototype.parseQueryValue=function(t,e){var n=new yC(hC.Argument,t,kv.EMPTY_PATH),r=this.parseData(e,n);return Nm(null!=r,"Parsed data should not be null."),Nm(0===n.fieldTransforms.length,"Field transforms should have been disallowed."),r},bC.prototype.runPreConverter=function(t,e){try{return this.preConverter(t)}catch(t){var n=SC(t);throw e.createError(n)}},bC.prototype.parseData=function(t,e){if(wC(t=this.runPreConverter(t,e)))return _C("Unsupported field value:",e,t),this.parseObject(t,e);if(t instanceof WI)return this.parseSentinelFieldValue(t,e),null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.arrayElement)throw e.createError("Nested arrays are not supported");return this.parseArray(t,e)}return this.parseScalarValue(t,e)},bC.prototype.parseObject=function(t,r){var i=this,o=new $v(sv);return Vm(t)?r.path&&0<r.path.length&&r.fieldMask.push(r.path):qm(t,function(t,e){var n=i.parseData(e,r.childContextForField(t));null!=n&&(o=o.insert(t,n))}),new yw(o)},bC.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=xb.INSTANCE),n.push(s),r++}return new gw(n)},bC.prototype.parseSentinelFieldValue=function(t,e){if(!dC(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 HI){if(e.dataSource!==hC.MergeSet)throw e.dataSource===hC.Update?(Nm(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 YI)e.fieldTransforms.push(new ob(e.path,gS.instance));else if(t instanceof $I){var n=this.parseArrayTransformElements(t._methodName,t._elements),r=new wS(n);e.fieldTransforms.push(new ob(e.path,r))}else if(t instanceof eC){n=this.parseArrayTransformElements(t._methodName,t._elements);var i=new ES(n);e.fieldTransforms.push(new ob(e.path,i))}else if(t instanceof iC){var o=this.parseQueryValue("FieldValue.increment",t._operand),a=new SS(o);e.fieldTransforms.push(new ob(e.path,a))}else Cm("Unknown FieldValue type: "+t)},bC.prototype.parseScalarValue=function(t,e){if(null===t)return xb.INSTANCE;if("number"==typeof t)return FE(t)?new Qb(t):new zb(t);if("boolean"==typeof t)return Ub.of(t);if("string"==typeof t)return new Jb(t);if(t instanceof Date)return new tw(zv.fromDate(t));if(t instanceof zv)return new tw(new zv(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)));if(t instanceof qT)return new fw(t);if(t instanceof fv)return new aw(t);if(t instanceof vC)return new cw(t.databaseId,t.key);throw e.createError("Unsupported field value: "+Zm(t))},bC.prototype.parseArrayTransformElements=function(r,t){var i=this;return t.map(function(t,e){var n=new yC(hC.Argument,r,kv.EMPTY_PATH);return i.parseData(t,n.childContextForArray(e))})},bC);function bC(t){this.preConverter=t}function wC(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof zv||t instanceof qT||t instanceof fv||t instanceof vC||t instanceof WI)}function _C(t,e,n){if(!wC(n)||!$m(n)){var r=Zm(n);throw"an object"===r?e.createError(t+" a custom object"):e.createError(t+" "+r)}}function EC(t,e){if(e instanceof DI)return e._internalPath;if("string"==typeof e)return TC(t,e);throw new Pm(Om.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function TC(e,t){try{return function(e){if(0<=e.search(OI))throw new Pm(Om.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(DI.bind.apply(DI,aa([void 0],e.split("."))))}catch(t){throw new Pm(Om.INVALID_ARGUMENT,"Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(t)._internalPath}catch(t){var n=SC(t);throw new Pm(Om.INVALID_ARGUMENT,"Function "+e+"() called with invalid data. "+n)}}function SC(t){return t instanceof Error?t.message:t.toString()}var IC=L_.COLLECTION_DISABLED,CC=(NC.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},NC);function NC(t){if(void 0===t.host){if(void 0!==t.ssl)throw new Pm(Om.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else Gm("settings","non-empty string","host",t.host),this.host=t.host,zm("settings","boolean","ssl",t.ssl),this.ssl=Fm(t.ssl,!0);if(ev("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling"]),zm("settings","object","credentials",t.credentials),this.credentials=t.credentials,zm("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),!0===t.timestampsInSnapshots?Sm("\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&&Sm("\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=Fm(t.timestampsInSnapshots,!0),zm("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=L_.DEFAULT_CACHE_SIZE_BYTES;else{if(t.cacheSizeBytes!==IC&&t.cacheSizeBytes<L_.MINIMUM_CACHE_SIZE_BYTES)throw new Pm(Om.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+L_.MINIMUM_CACHE_SIZE_BYTES);this.cacheSizeBytes=t.cacheSizeBytes}zm("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=void 0!==t.experimentalForceLongPolling&&t.experimentalForceLongPolling}var AC=(kC.prototype.settings=function(t){if(jm("Firestore.settings",arguments,1),Qm("Firestore.settings","object",1,t),Lm(t,"persistence"))throw new Pm(Om.INVALID_ARGUMENT,'"persistence" is now specified with a separate call to firestore.enablePersistence().');var e=new CC(t);if(this._firestoreClient&&!this._settings.isEqual(e))throw new Pm(Om.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 MI;switch(t.type){case"gapi":var e=t.client;return Nm(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty),"unexpected gapi interface"),new VI(e,t.sessionIndex||"0");case"provider":return t.client;default:throw new Pm(Om.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},kC.prototype.enableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.enableNetwork()},kC.prototype.disableNetwork=function(){return this.ensureClientConfigured(),this._firestoreClient.disableNetwork()},kC.prototype.enablePersistence=function(t){if(this._firestoreClient)throw new Pm(Om.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&&Sm("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=Fm(void 0!==t.synchronizeTabs?t.synchronizeTabs:t.experimentalTabSynchronization,!1)),this.configureClient(new TI(this._settings.cacheSizeBytes,e))},kC.prototype.clearPersistence=function(){var t=this,n=X_.buildStoragePrefix(this.makeDatabaseInfo()),r=new xv;return this._queue.enqueueAndForgetEvenAfterShutdown(function(){return ea(t,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:if(t.trys.push([0,2,,3]),void 0!==this._firestoreClient&&!this._firestoreClient.clientTerminated)throw new Pm(Om.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return[4,X_.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},kC.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(kC.prototype,"_isTerminated",{get:function(){return this.ensureClientConfigured(),this._firestoreClient.clientTerminated},enumerable:!0,configurable:!0}),kC.prototype.waitForPendingWrites=function(){return this.ensureClientConfigured(),this._firestoreClient.waitForPendingWrites()},kC.prototype.onSnapshotsInSync=function(t){if(this.ensureClientConfigured(),jI(t))return this.onSnapshotsInSyncInternal(t);Qm("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.onSnapshotsInSyncInternal(e)},kC.prototype.onSnapshotsInSyncInternal=function(t){var e=this,n=new AI({next:function(){t.next&&t.next()},error:function(t){throw Cm("Uncaught Error in onSnapshotsInSync")}});return this._firestoreClient.addSnapshotsInSyncListener(n),function(){n.mute(),e._firestoreClient.removeSnapshotsInSyncListener(n)}},kC.prototype.ensureClientConfigured=function(){return this._firestoreClient||this.configureClient(new II),this._firestoreClient},kC.prototype.makeDatabaseInfo=function(){return new yv(this._databaseId,this._persistenceKey,this._settings.host,this._settings.ssl,this._settings.forceLongPolling)},kC.prototype.configureClient=function(t){Nm(!!this._settings.host,"FirestoreSettings.host is not set"),Nm(!this._firestoreClient,"configureClient() called multiple times");var e=this.makeDatabaseInfo();return this._firestoreClient=new CI(Am.getPlatform(),e,this._credentials,this._queue),this._firestoreClient.start(t)},kC.prototype.createDataConverter=function(r){return new gC(function(t){if(t instanceof MC){var e=r,n=t.firestore._databaseId;if(!n.isEqual(e))throw new Pm(Om.INVALID_ARGUMENT,"Document reference is for database "+n.projectId+"/"+n.database+" but should be for database "+e.projectId+"/"+e.database);return new vC(r,t._key)}return t})},kC.databaseIdFromApp=function(t){var e=t.options;if(!Lm(e,"projectId"))throw new Pm(Om.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var n=e.projectId;if(!n||"string"!=typeof n)throw new Pm(Om.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new vv(n)},Object.defineProperty(kC.prototype,"app",{get:function(){if(!this._firebaseApp)throw new Pm(Om.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._firebaseApp},enumerable:!0,configurable:!0}),kC.prototype.collection=function(t){return jm("Firestore.collection",arguments,1),Qm("Firestore.collection","non-empty string",1,t),this.ensureClientConfigured(),new zC(Iv.fromString(t),this)},kC.prototype.doc=function(t){return jm("Firestore.doc",arguments,1),Qm("Firestore.doc","non-empty string",1,t),this.ensureClientConfigured(),MC.forPath(Iv.fromString(t),this)},kC.prototype.collectionGroup=function(t){if(jm("Firestore.collectionGroup",arguments,1),Qm("Firestore.collectionGroup","non-empty string",1,t),0<=t.indexOf("/"))throw new Pm(Om.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.ensureClientConfigured(),new WC(new BT(Iv.EMPTY_PATH,t),this)},kC.prototype.runTransaction=function(e){var n=this;return jm("Firestore.runTransaction",arguments,1),Qm("Firestore.runTransaction","function",1,e),this.ensureClientConfigured().transaction(function(t){return e(new DC(n,t))})},kC.prototype.batch=function(){return this.ensureClientConfigured(),new OC(this)},Object.defineProperty(kC,"logLevel",{get:function(){switch(_m()){case lm.DEBUG:return"debug";case lm.ERROR:return"error";case lm.SILENT:return"silent";default:return Cm("Unknown log level: "+_m())}},enumerable:!0,configurable:!0}),kC.setLogLevel=function(t){switch(jm("Firestore.setLogLevel",arguments,1),Qm("Firestore.setLogLevel","non-empty string",1,t),t){case"debug":Em(lm.DEBUG);break;case"error":Em(lm.ERROR);break;case"silent":Em(lm.SILENT);break;default:throw new Pm(Om.INVALID_ARGUMENT,"Invalid log level: "+t)}},kC.prototype._areTimestampsInSnapshotsEnabled=function(){return this._settings.timestampsInSnapshots},kC);function kC(t){var e=this;if(this._firebaseApp=null,this._queue=new Uv,this.INTERNAL={delete:function(){return ea(e,void 0,void 0,function(){return na(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 n=t;this._firebaseApp=n,this._databaseId=kC.databaseIdFromApp(n),this._persistenceKey=n.name,this._credentials=new LI(n)}else{var r=t;if(!r.projectId)throw new Pm(Om.INVALID_ARGUMENT,"Must provide projectId");this._databaseId=new vv(r.projectId,r.database),this._persistenceKey="[DEFAULT]",this._credentials=new MI}this._settings=new CC({}),this._dataConverter=this.createDataConverter(this._databaseId)}var DC=(RC.prototype.get=function(t){var n=this;jm("Transaction.get",arguments,1);var r=ZC("Transaction.get",t,this._firestore);return this._transaction.lookup([r._key]).then(function(t){if(!t||1!==t.length)return Cm("Mismatch in docs returned from document lookup.");var e=t[0];if(e instanceof Cw)return new UC(n._firestore,r._key,null,!1,!1);if(e instanceof Tw)return new UC(n._firestore,r._key,e,!1,!1);throw Cm("BatchGetDocumentsRequest returned unexpected document type: "+e.constructor.name)})},RC.prototype.set=function(t,e,n){Km("Transaction.set",arguments,2,3);var r=ZC("Transaction.set",t,this._firestore),i=(n=XC("Transaction.set",n)).merge||n.mergeFields?this._firestore._dataConverter.parseMergeData("Transaction.set",e,n.mergeFields):this._firestore._dataConverter.parseSetData("Transaction.set",e);return this._transaction.set(r._key,i),this},RC.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 DI?(Wm("Transaction.update",arguments,3),r=ZC("Transaction.update",t,this._firestore),this._firestore._dataConverter.parseUpdateVarargs("Transaction.update",e,n,o)):(jm("Transaction.update",arguments,2),r=ZC("Transaction.update",t,this._firestore),this._firestore._dataConverter.parseUpdateData("Transaction.update",e)),this._transaction.update(r._key,i),this},RC.prototype.delete=function(t){jm("Transaction.delete",arguments,1);var e=ZC("Transaction.delete",t,this._firestore);return this._transaction.delete(e._key),this},RC);function RC(t,e){this._firestore=t,this._transaction=e}var OC=(PC.prototype.set=function(t,e,n){Km("WriteBatch.set",arguments,2,3),this.verifyNotCommitted();var r=ZC("WriteBatch.set",t,this._firestore),i=(n=XC("WriteBatch.set",n)).merge||n.mergeFields?this._firestore._dataConverter.parseMergeData("WriteBatch.set",e,n.mergeFields):this._firestore._dataConverter.parseSetData("WriteBatch.set",e);return this._mutations=this._mutations.concat(i.toMutations(r._key,hb.NONE)),this},PC.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 DI?(Wm("WriteBatch.update",arguments,3),r=ZC("WriteBatch.update",t,this._firestore),this._firestore._dataConverter.parseUpdateVarargs("WriteBatch.update",e,n,o)):(jm("WriteBatch.update",arguments,2),r=ZC("WriteBatch.update",t,this._firestore),this._firestore._dataConverter.parseUpdateData("WriteBatch.update",e)),this._mutations=this._mutations.concat(i.toMutations(r._key,hb.exists(!0))),this},PC.prototype.delete=function(t){jm("WriteBatch.delete",arguments,1),this.verifyNotCommitted();var e=ZC("WriteBatch.delete",t,this._firestore);return this._mutations=this._mutations.concat(new Ab(e._key,hb.NONE)),this},PC.prototype.commit=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){return this.verifyNotCommitted(),this._committed=!0,0<this._mutations.length?[2,this._firestore.ensureClientConfigured().write(this._mutations)]:[2]})})},PC.prototype.verifyNotCommitted=function(){if(this._committed)throw new Pm(Om.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},PC);function PC(t){this._firestore=t,this._mutations=[],this._committed=!1}var MC=(xC.forPath=function(t,e){if(t.length%2!=0)throw new Pm(Om.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.canonicalString()+" has "+t.length);return new xC(new Rv(t),e)},Object.defineProperty(xC.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(xC.prototype,"parent",{get:function(){return new zC(this._key.path.popLast(),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(xC.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!0,configurable:!0}),xC.prototype.collection=function(t){if(jm("DocumentReference.collection",arguments,1),Qm("DocumentReference.collection","non-empty string",1,t),!t)throw new Pm(Om.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=Iv.fromString(t);return new zC(this._key.path.child(e),this.firestore)},xC.prototype.isEqual=function(t){if(!(t instanceof xC))throw nv("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this._key.isEqual(t._key)},xC.prototype.set=function(t,e){Km("DocumentReference.set",arguments,1,2);var n=(e=XC("DocumentReference.set",e)).merge||e.mergeFields?this.firestore._dataConverter.parseMergeData("DocumentReference.set",t,e.mergeFields):this.firestore._dataConverter.parseSetData("DocumentReference.set",t);return this._firestoreClient.write(n.toMutations(this._key,hb.NONE))},xC.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 DI?(Wm("DocumentReference.update",arguments,2),this.firestore._dataConverter.parseUpdateVarargs("DocumentReference.update",t,e,r)):(jm("DocumentReference.update",arguments,1),this.firestore._dataConverter.parseUpdateData("DocumentReference.update",t)),this._firestoreClient.write(n.toMutations(this._key,hb.exists(!0)))},xC.prototype.delete=function(){return jm("DocumentReference.delete",arguments,0),this._firestoreClient.write([new Ab(this._key,hb.NONE)])},xC.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Km("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||jI(t[i])||(ev("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),zm("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return n=jI(t[i])?t[i]:(Qm("DocumentReference.onSnapshot","function",i,t[i]),Hm("DocumentReference.onSnapshot","function",i+1,t[i+1]),Hm("DocumentReference.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.onSnapshotInternal(o,n)},xC.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 AI({next:function(t){if(n.next){Nm(t.docs.size<=1,"Too many documents returned on a document query");var e=t.docs.get(r._key);n.next(new UC(r.firestore,r._key,e,t.fromCache,t.hasPendingWrites))}},error:e}),o=this._firestoreClient.listen(BT.atPath(this._key.path),i,t);return function(){i.mute(),r._firestoreClient.unlisten(o)}},xC.prototype.get=function(n){var r=this;return Km("DocumentReference.get",arguments,0,1),$C("DocumentReference.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.ensureClientConfigured().getDocumentFromLocalCache(r._key).then(function(t){e(new UC(r.firestore,r._key,t,!0,t instanceof Tw&&t.hasLocalMutations))},t):r.getViaSnapshotListener(e,t,n)})},xC.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 Pm(Om.UNAVAILABLE,"Failed to get document because the client is offline.")):t.exists&&t.metadata.fromCache&&r&&"server"===r.source?n(new Pm(Om.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})},xC);function xC(t,e){this._key=t,this.firestore=e,this._firestoreClient=this.firestore.ensureClientConfigured()}var LC=(FC.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},FC);function FC(t,e){this.hasPendingWrites=t,this.fromCache=e}var UC=(qC.prototype.data=function(t){return Km("DocumentSnapshot.data",arguments,0,1),t=JC("DocumentSnapshot.data",t),this._document?this.convertObject(this._document.data(),Db.fromSnapshotOptions(t,this._firestore._areTimestampsInSnapshotsEnabled())):void 0},qC.prototype.get=function(t,e){if(Km("DocumentSnapshot.get",arguments,1,2),e=JC("DocumentSnapshot.get",e),this._document){var n=this._document.data().field(EC("DocumentSnapshot.get",t));if(null!==n)return this.convertValue(n,Db.fromSnapshotOptions(e,this._firestore._areTimestampsInSnapshotsEnabled()))}},Object.defineProperty(qC.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(qC.prototype,"ref",{get:function(){return new MC(this._key,this._firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(qC.prototype,"exists",{get:function(){return null!==this._document},enumerable:!0,configurable:!0}),Object.defineProperty(qC.prototype,"metadata",{get:function(){return new LC(this._hasPendingWrites,this._fromCache)},enumerable:!0,configurable:!0}),qC.prototype.isEqual=function(t){if(!(t instanceof qC))throw nv("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))},qC.prototype.convertObject=function(t,n){var r=this,i={};return t.forEach(function(t,e){i[t]=r.convertValue(e,n)}),i},qC.prototype.convertValue=function(t,e){if(t instanceof yw)return this.convertObject(t,e);if(t instanceof gw)return this.convertArray(t,e);if(t instanceof cw){var n=t.value(e),r=this._firestore.ensureClientConfigured().databaseId();return t.databaseId.isEqual(r)||Sm("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 MC(n,this._firestore)}return t.value(e)},qC.prototype.convertArray=function(t,e){var n=this;return t.internalValue.map(function(t){return n.convertValue(t,e)})},qC);function qC(t,e,n,r,i){this._firestore=t,this._key=e,this._document=n,this._fromCache=r,this._hasPendingWrites=i}var VC,BC=(Zo(jC,VC=UC),jC.prototype.data=function(t){var e=VC.prototype.data.call(this,t);return Nm("object"==typeof e,"Document in a QueryDocumentSnapshot should exist"),e},jC);function jC(){return null!==VC&&VC.apply(this,arguments)||this}var WC=(KC.prototype.where=function(t,e,n){jm("Query.where",arguments,3),tv("Query.where",3,n),"in"!==e&&"array-contains-any"!==e&&function(t,e,n,r){if(!e.some(function(t){return t===r}))throw new Pm(Om.INVALID_ARGUMENT,"Invalid value "+Zm(r)+" provided to function "+t+"() for its "+rv(n)+" argument. Acceptable values: "+e.join(", "))}("Query.where",["<","<=","==",">=",">","array-contains"],2,e);var r,i=EC("Query.where",t),o=KT.fromString(e);if(i.isKeyField()){if(o===KT.ARRAY_CONTAINS||o===KT.ARRAY_CONTAINS_ANY)throw new Pm(Om.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o.toString()+"' queries on FieldPath.documentId().");if(o===KT.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 gw(a)}else r=this.parseDocumentIdValue(n)}else o!==KT.IN&&o!==KT.ARRAY_CONTAINS_ANY||this.validateDisjunctiveFilterElements(n,o),r=this.firestore._dataConverter.parseQueryValue("Query.where",n);var h=GT.create(i,o,r);return this.validateNewFilter(h),new KC(this._query.addFilter(h),this.firestore)},KC.prototype.orderBy=function(t,e){var n;if(Km("Query.orderBy",arguments,1,2),Hm("Query.orderBy","non-empty string",2,e),void 0===e||"asc"===e)n=hS.ASCENDING;else{if("desc"!==e)throw new Pm(Om.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+e+"', expected 'asc' or 'desc'.");n=hS.DESCENDING}if(null!==this._query.startAt)throw new Pm(Om.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this._query.endAt)throw new Pm(Om.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var r=EC("Query.orderBy",t),i=new dS(r,n);return this.validateNewOrderBy(i),new KC(this._query.addOrderBy(i),this.firestore)},KC.prototype.limit=function(t){if(jm("Query.limit",arguments,1),Qm("Query.limit","number",1,t),t<=0)throw new Pm(Om.INVALID_ARGUMENT,"Invalid Query. Query limit ("+t+") is invalid. Limit must be positive.");return new KC(this._query.withLimit(t),this.firestore)},KC.prototype.startAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Wm("Query.startAt",arguments,1);var r=this.boundFromDocOrFields("Query.startAt",t,e,!0);return new KC(this._query.withStartAt(r),this.firestore)},KC.prototype.startAfter=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Wm("Query.startAfter",arguments,1);var r=this.boundFromDocOrFields("Query.startAfter",t,e,!1);return new KC(this._query.withStartAt(r),this.firestore)},KC.prototype.endBefore=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Wm("Query.endBefore",arguments,1);var r=this.boundFromDocOrFields("Query.endBefore",t,e,!0);return new KC(this._query.withEndAt(r),this.firestore)},KC.prototype.endAt=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];Wm("Query.endAt",arguments,1);var r=this.boundFromDocOrFields("Query.endAt",t,e,!1);return new KC(this._query.withEndAt(r),this.firestore)},KC.prototype.isEqual=function(t){if(!(t instanceof KC))throw nv("isEqual","Query",1,t);return this.firestore===t.firestore&&this._query.isEqual(t._query)},KC.prototype.boundFromDocOrFields=function(t,e,n,r){if(tv(t,1,e),e instanceof UC){if(0<n.length)throw new Pm(Om.INVALID_ARGUMENT,"Too many arguments provided to "+t+"().");var i=e;if(!i.exists)throw new Pm(Om.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)},KC.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 cw(this.firestore._databaseId,e.key));else{var s=e.field(a.field);if(s instanceof rw)throw new Pm(Om.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 Pm(Om.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 fS(r,n)},KC.prototype.boundFromFields=function(t,e,n){var r=this._query.explicitOrderBy;if(e.length>r.length)throw new Pm(Om.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 Pm(Om.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 Pm(Om.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(Iv.fromString(a));if(!Rv.isDocumentKey(s))throw new Pm(Om.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 Rv(s);i.push(new cw(this.firestore._databaseId,u))}else{var c=this.firestore._dataConverter.parseQueryValue(t,a);i.push(c)}}return new fS(i,n)},KC.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Km("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||jI(t[i])||(ev("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),zm("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),n=jI(t[i])?t[i]:(Qm("Query.onSnapshot","function",i,t[i]),Hm("Query.onSnapshot","function",i+1,t[i+1]),Hm("Query.onSnapshot","function",i+2,t[i+2]),{next:t[i],error:t[i+1],complete:t[i+2]}),this.onSnapshotInternal(r,n)},KC.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 AI({next:function(t){e.next&&e.next(new QC(n.firestore,n._query,t))},error:r}),o=this.firestore.ensureClientConfigured(),a=o.listen(this._query,i,t);return function(){i.mute(),o.unlisten(a)}},KC.prototype.get=function(n){var r=this;return Km("Query.get",arguments,0,1),$C("Query.get",n),new Promise(function(e,t){n&&"cache"===n.source?r.firestore.ensureClientConfigured().getDocumentsFromLocalCache(r._query).then(function(t){e(new QC(r.firestore,r._query,t))},t):r.getViaSnapshotListener(e,t,n)})},KC.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 Pm(Om.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})},KC.prototype.parseDocumentIdValue=function(t){if("string"==typeof t){if(""===t)throw new Pm(Om.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 Pm(Om.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(Iv.fromString(t));if(!Rv.isDocumentKey(e))throw new Pm(Om.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 cw(this.firestore._databaseId,new Rv(e))}if(t instanceof MC){var n=t;return new cw(this.firestore._databaseId,n._key)}throw new Pm(Om.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Zm(t)+".")},KC.prototype.validateDisjunctiveFilterElements=function(t,e){if(!Array.isArray(t)||0===t.length)throw new Pm(Om.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(10<t.length)throw new Pm(Om.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(0<=t.indexOf(null))throw new Pm(Om.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 Pm(Om.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},KC.prototype.validateNewFilter=function(t){if(t instanceof GT){var e=[KT.ARRAY_CONTAINS,KT.ARRAY_CONTAINS_ANY],n=[KT.IN,KT.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 Pm(Om.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 Pm(Om.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new Pm(Om.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+s.toString()+"' filters.")}}},KC.prototype.validateNewOrderBy=function(t){if(null===this._query.getFirstOrderByField()){var e=this._query.getInequalityFilterField();null!==e&&this.validateOrderByAndInequalityMatch(e,t.field)}},KC.prototype.validateOrderByAndInequalityMatch=function(t,e){if(!e.isEqual(t))throw new Pm(Om.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.")},KC);function KC(t,e){this._query=t,this.firestore=e}var QC=(Object.defineProperty(HC.prototype,"docs",{get:function(){var e=[];return this.forEach(function(t){return e.push(t)}),e},enumerable:!0,configurable:!0}),Object.defineProperty(HC.prototype,"empty",{get:function(){return this._snapshot.docs.isEmpty()},enumerable:!0,configurable:!0}),Object.defineProperty(HC.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!0,configurable:!0}),HC.prototype.forEach=function(e,n){var r=this;Km("QuerySnapshot.forEach",arguments,1,2),Qm("QuerySnapshot.forEach","function",1,e),this._snapshot.docs.forEach(function(t){e.call(n,r.convertToDocumentImpl(t))})},Object.defineProperty(HC.prototype,"query",{get:function(){return new WC(this._originalQuery,this._firestore)},enumerable:!0,configurable:!0}),HC.prototype.docChanges=function(t){t&&(ev("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),zm("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this._snapshot.excludesMetadataChanges)throw new Pm(Om.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){if(o.oldDocs.isEmpty()){var n,r=0;return o.docChanges.map(function(t){var e=new BC(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key));return Nm(t.type===lT.Added,"Invalid event type for first snapshot"),Nm(!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 a=o.oldDocs;return o.docChanges.filter(function(t){return e||t.type!==lT.Metadata}).map(function(t){var e=new BC(i,t.doc.key,t.doc,o.fromCache,o.mutatedKeys.has(t.doc.key)),n=-1,r=-1;return t.type!==lT.Added&&(Nm(0<=(n=a.indexOf(t.doc.key)),"Index for document not found"),a=a.delete(t.doc.key)),t.type!==lT.Removed&&(r=(a=a.add(t.doc)).indexOf(t.doc.key)),{type:function(t){switch(t){case lT.Added:return"added";case lT.Modified:case lT.Metadata:return"modified";case lT.Removed:return"removed";default:return Cm("Unknown change type: "+t)}}(t.type),doc:e,oldIndex:n,newIndex:r}})}(this._firestore,e,this._snapshot),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},HC.prototype.isEqual=function(t){if(!(t instanceof HC))throw nv("isEqual","QuerySnapshot",1,t);return this._firestore===t._firestore&&this._originalQuery.isEqual(t._originalQuery)&&this._snapshot.isEqual(t._snapshot)},HC.prototype.convertToDocumentImpl=function(t){return new BC(this._firestore,t.key,t,this.metadata.fromCache,this._snapshot.mutatedKeys.has(t.key))},HC);function HC(t,e,n){this._firestore=t,this._originalQuery=e,this._snapshot=n,this._cachedChanges=null,this._cachedChangesIncludeMetadataChanges=null,this.metadata=new LC(n.hasPendingWrites,n.fromCache)}aa(["length","forEach","map"],"undefined"!=typeof Symbol?[Symbol.iterator]:[]).forEach(function(t){try{Object.defineProperty(QC.prototype.docChanges,t,{get:function(){return function(){throw new Pm(Om.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 GC,zC=(Zo(YC,GC=WC),Object.defineProperty(YC.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!0,configurable:!0}),Object.defineProperty(YC.prototype,"parent",{get:function(){var t=this._query.path.popLast();return t.isEmpty()?null:new MC(new Rv(t),this.firestore)},enumerable:!0,configurable:!0}),Object.defineProperty(YC.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!0,configurable:!0}),YC.prototype.doc=function(t){if(Km("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=ov.newId()),Qm("CollectionReference.doc","non-empty string",1,t),""===t)throw new Pm(Om.INVALID_ARGUMENT,"Document path must be a non-empty string");var e=Iv.fromString(t);return MC.forPath(this._query.path.child(e),this.firestore)},YC.prototype.add=function(t){jm("CollectionReference.add",arguments,1),Qm("CollectionReference.add","object",1,t);var e=this.doc();return e.set(t).then(function(){return e})},YC);function YC(t,e){var n=GC.call(this,BT.atPath(t),e)||this;if(t.length%2!=1)throw new Pm(Om.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t.canonicalString()+" has "+t.length);return n}function XC(t,e){if(void 0===e)return{merge:!1};if(ev(t,e,["merge","mergeFields"]),zm(t,"boolean","merge",e.merge),Ym(t,"mergeFields","a string or a FieldPath",e.mergeFields,function(t){return"string"==typeof t||t instanceof DI}),void 0!==e.mergeFields&&void 0!==e.merge)throw new Pm(Om.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function JC(t,e){return void 0===e?{}:(ev(t,e,["serverTimestamps"]),Xm(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function $C(t,e){Hm(t,"object",1,e),e&&(ev(t,e,["source"]),Xm(t,0,"source",e.source,["default","server","cache"]))}function ZC(t,e,n){if(e instanceof MC){if(e.firestore!==n)throw new Pm(Om.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw nv(t,"DocumentReference",1,e)}var tN=xm(AC,"Use firebase.firestore() instead."),eN=xm(DC,"Use firebase.firestore().runTransaction() instead."),nN=xm(OC,"Use firebase.firestore().batch() instead."),rN=xm(MC,"Use firebase.firestore().doc() instead."),iN=xm(UC),oN=xm(BC),aN=xm(WC),sN=xm(QC),uN=xm(zC,"Use firebase.firestore().collection() instead."),cN={Firestore:tN,GeoPoint:qT,Timestamp:zv,Blob:dv,Transaction:eN,WriteBatch:nN,DocumentReference:rN,DocumentSnapshot:iN,Query:aN,QueryDocumentSnapshot:oN,QuerySnapshot:sN,CollectionReference:uN,FieldPath:DI,FieldValue:aC,setLogLevel:AC.setLogLevel,CACHE_SIZE_UNLIMITED:IC};function hN(t){t.INTERNAL.registerService("firestore",function(t){return new AC(t)},function(t){Nm(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}(cN))}var lN=(fN.prototype.addCallback=function(t){},fN.prototype.shutdown=function(){},fN);function fN(){}var pN="ConnectivityMonitor",dN=(yN.prototype.addCallback=function(t){this.callbacks.push(t)},yN.prototype.shutdown=function(){window.removeEventListener("online",this.networkAvailableListener),window.removeEventListener("offline",this.networkUnavailableListener)},yN.prototype.configureNetworkMonitoring=function(){window.addEventListener("online",this.networkAvailableListener),window.addEventListener("offline",this.networkUnavailableListener)},yN.prototype.onNetworkAvailable=function(){Tm(pN,"Network connectivity changed: AVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++)(0,e[t])(0)},yN.prototype.onNetworkUnavailable=function(){Tm(pN,"Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.callbacks;t<e.length;t++)(0,e[t])(1)},yN.isAvailable=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},yN);function yN(){var t=this;this.networkAvailableListener=function(){return t.onNetworkAvailable()},this.networkUnavailableListener=function(){return t.onNetworkUnavailable()},this.callbacks=[],this.configureNetworkMonitoring()}var mN=(vN.prototype.onOpen=function(t){Nm(!this.wrappedOnOpen,"Called onOpen on stream twice!"),this.wrappedOnOpen=t},vN.prototype.onClose=function(t){Nm(!this.wrappedOnClose,"Called onClose on stream twice!"),this.wrappedOnClose=t},vN.prototype.onMessage=function(t){Nm(!this.wrappedOnMessage,"Called onMessage on stream twice!"),this.wrappedOnMessage=t},vN.prototype.close=function(){this.closeFn()},vN.prototype.send=function(t){this.sendFn(t)},vN.prototype.callOnOpen=function(){Nm(void 0!==this.wrappedOnOpen,"Cannot call onOpen because no callback was set"),this.wrappedOnOpen()},vN.prototype.callOnClose=function(t){Nm(void 0!==this.wrappedOnClose,"Cannot call onClose because no callback was set"),this.wrappedOnClose(t)},vN.prototype.callOnMessage=function(t){Nm(void 0!==this.wrappedOnMessage,"Cannot call onMessage because no callback was set"),this.wrappedOnMessage(t)},vN);function vN(t){this.sendFn=t.sendFn,this.closeFn=t.closeFn}var gN="Connection",bN={BatchGetDocuments:"batchGet",Commit:"commit"},wN="gl-js/ fire/"+bm,_N=(EN.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"]=wN},EN.prototype.invokeRPC=function(s,r,u){var c=this,h=this.makeUrl(s);return new Promise(function(i,o){var a=new gm;a.listenOnce(mm.COMPLETE,function(){try{switch(a.getLastErrorCode()){case ym.NO_ERROR:var t=a.getResponseJson();Tm(gN,"XHR received:",JSON.stringify(t)),i(t);break;case ym.TIMEOUT:Tm(gN,'RPC "'+s+'" timed out'),o(new Pm(Om.DEADLINE_EXCEEDED,"Request time out"));break;case ym.HTTP_ERROR:var e=a.getStatus();if(Tm(gN,'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(Om).indexOf(e)?e:Om.UNKNOWN}(n.status);o(new Pm(r,n.message))}else o(new Pm(Om.UNKNOWN,"Server responded with status "+a.getStatus()))}else Tm(gN,'RPC "'+s+'" failed'),o(new Pm(Om.UNAVAILABLE,"Connection failed."));break;default:Cm('RPC "'+s+'" failed with unanticipated webchannel error '+a.getLastErrorCode()+": "+a.getLastError()+", giving up.")}}finally{Tm(gN,'RPC "'+s+'" completed.')}});var t=ta({},r);delete t.database;var e=JSON.stringify(t);Tm(gN,"XHR sending: ",h+" "+e);var n={"Content-Type":"text/plain"};c.modifyHeadersForRequest(n,u),a.send(h,"POST",e,n,15)})},EN.prototype.invokeStreamingRPC=function(t,e,n){return this.invokeRPC(t,e,n)},EN.prototype.openStream=function(t,e){var n=[this.baseUrl,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=dm(),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),ba()||(i.httpHeadersOverwriteParam="$httpHeaders");var o=n.join("");function a(t,e){s.listen(t,function(t){try{e(t)}catch(t){setTimeout(function(){throw t},0)}})}Tm(gN,"Creating WebChannel: "+o+" "+i);var s=r.createWebChannel(o,i),u=!1,c=!1,h=new mN({sendFn:function(t){c?Tm(gN,"Not sending because WebChannel is closed:",t):(u||(Tm(gN,"Opening WebChannel transport."),s.open(),u=!0),Tm(gN,"WebChannel sending:",t),s.send(t))},closeFn:function(){return s.close()}});return a(vm.EventType.OPEN,function(){c||Tm(gN,"WebChannel transport opened.")}),a(vm.EventType.CLOSE,function(){c||(c=!0,Tm(gN,"WebChannel transport closed"),h.callOnClose())}),a(vm.EventType.ERROR,function(t){c||(c=!0,Tm(gN,"WebChannel transport errored:",t),h.callOnClose(new Pm(Om.UNAVAILABLE,"The operation could not be completed")))}),a(vm.EventType.MESSAGE,function(t){if(!c){var e=t.data[0];Nm(!!e,"Got a webchannel message without data.");var n=e,r=n.error||n[0]&&n[0].error;if(r){Tm(gN,"WebChannel received error:",r);var i=r.status,o=function(t){var e=oT[t];if(void 0!==e)return hT(e)}(i),a=r.message;void 0===o&&(o=Om.INTERNAL,a="Unknown error status: "+i+" with message "+r.message),c=!0,h.callOnClose(new Pm(o,a)),s.close()}else Tm(gN,"WebChannel received:",e),h.callOnMessage(e)}}),setTimeout(function(){h.callOnOpen()},0),h},EN.prototype.makeUrl=function(t){var e=bN[t];Nm(void 0!==e,"Unknown REST mapping for: "+t);var n=[this.baseUrl,"/","v1"];return n.push("/projects/"),n.push(this.databaseId.projectId),n.push("/databases/"),n.push(this.databaseId.database),n.push("/documents"),n.push(":"),n.push(e),n.join("")},EN);function EN(t){this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.baseUrl=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}var TN=(Object.defineProperty(SN.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(SN.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),SN.prototype.loadConnection=function(t){return Promise.resolve(new _N(t))},SN.prototype.newConnectivityMonitor=function(){return dN.isAvailable()?new dN:new lN},SN.prototype.newSerializer=function(t){return new LS(t,{useProto3Json:!0})},SN.prototype.formatJSON=function(t){return JSON.stringify(t)},SN.prototype.atob=function(t){return atob(t)},SN.prototype.btoa=function(t){return btoa(t)},SN);function SN(){this.emptyByteString="",this.base64Available="undefined"!=typeof atob}Am.setPlatform(new TN),hN(fl);var IN,CN={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"},NN=(Zo(AN,IN=Error),AN);function AN(t,e,n){var r=IN.call(this,e)||this;return Object.setPrototypeOf(r,AN.prototype),r.code=t,r.details=n,r}function kN(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"}}(t),i=r,o=void 0;try{var a=e&&e.error;if(a){var s=a.status;if("string"==typeof s){if(!CN[s])return new NN("internal","internal");r=CN[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 NN(r,i,o)}var DN=(RN.prototype.getAuthToken=function(){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.app.INTERNAL.getToken()];case 1:return(e=t.sent())?[2,e.accessToken]:[2,void 0];case 2:return t.sent(),[2,void 0];case 3:return[2]}})})},RN.prototype.getInstanceIdToken=function(){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),this.app.messaging?[4,this.app.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]}})})},RN.prototype.getContext=function(){return ea(this,void 0,void 0,function(){var e,n;return na(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}]}})})},RN);function RN(t){this.app=t}function ON(t,e){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]=e(t[r]));return n}var PN=(MN.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 ON(t,function(t){return e.encode(t)});throw new Error("Data cannot be encoded in JSON: "+t)},MN.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?ON(t,function(t){return e.decode(t)}):t},MN);function MN(){}var xN=(Object.defineProperty(LN.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),LN.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},LN.prototype.useFunctionsEmulator=function(t){this.emulatorOrigin=t},LN.prototype.httpsCallable=function(e,n){var r=this;return function(t){return r.call(e,t,n||{})}},LN.prototype.postJSON=function(r,i,o){return ea(this,void 0,void 0,function(){var e,n;return na(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}]}})})},LN.prototype.call=function(c,h,l){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u;return na(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 NN("deadline-exceeded","deadline-exceeded"))},n)})}(o),this.cancelAllRequests])];case 2:if(!(a=t.sent()))throw new NN("cancelled","Firebase Functions instance was deleted.");if(s=kN(a.status,a.json,this.serializer))throw s;if(!a.json)throw new NN("internal","Response is not valid JSON object.");if(void 0===(u=a.json.data)&&(u=a.json.result),void 0===u)throw new NN("internal","Response is missing data field.");return[2,{data:this.serializer.decode(u)}]}})})},LN);function LN(t,e){var n=this;void 0===e&&(e="us-central1"),this.app_=t,this.region_=e,this.serializer=new PN,this.emulatorOrigin=null,this.INTERNAL={delete:function(){return n.deleteService()}},this.contextProvider=new DN(t),this.cancelAllRequests=new Promise(function(t){n.deleteService=function(){return t()}})}var FN;function UN(t,e,n){return new xN(t,n)}function qN(n){return new Promise(function(t,e){n.onsuccess=function(){t(n.result)},n.onerror=function(){e(n.error)}})}function VN(n,r,i){var o,t=new Promise(function(t,e){qN(o=n[r].apply(n,i)).then(t,e)});return t.request=o,t}function BN(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 jN(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return VN(this[n],t,arguments)})})}function WN(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 KN(e,n,r,t){t.forEach(function(t){t in r.prototype&&(e.prototype[t]=function(){return function(t,e,n){var r=VN(t,e,n);return r.then(function(t){if(t)return new HN(t,r.request)})}(this[n],t,arguments)})})}function QN(t){this._index=t}function HN(t,e){this._cursor=t,this._request=e}function GN(t){this._store=t}function zN(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 YN(t,e,n){this._db=t,this.oldVersion=e,this.transaction=new zN(n)}function XN(t){this._db=t}FN={Functions:xN},fl.INTERNAL.registerService("functions",UN,FN,void 0,!0),BN(QN,"_index",["name","keyPath","multiEntry","unique"]),jN(QN,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),KN(QN,"_index",IDBIndex,["openCursor","openKeyCursor"]),BN(HN,"_cursor",["direction","key","primaryKey","value"]),jN(HN,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(HN.prototype[n]=function(){var e=this,t=arguments;return Promise.resolve().then(function(){return e._cursor[n].apply(e._cursor,t),qN(e._request).then(function(t){if(t)return new HN(t,e._request)})})})}),GN.prototype.createIndex=function(){return new QN(this._store.createIndex.apply(this._store,arguments))},GN.prototype.index=function(){return new QN(this._store.index.apply(this._store,arguments))},BN(GN,"_store",["name","keyPath","indexNames","autoIncrement"]),jN(GN,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),KN(GN,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),WN(GN,"_store",IDBObjectStore,["deleteIndex"]),zN.prototype.objectStore=function(){return new GN(this._tx.objectStore.apply(this._tx,arguments))},BN(zN,"_tx",["objectStoreNames","mode"]),WN(zN,"_tx",IDBTransaction,["abort"]),YN.prototype.createObjectStore=function(){return new GN(this._db.createObjectStore.apply(this._db,arguments))},BN(YN,"_db",["name","version","objectStoreNames"]),WN(YN,"_db",IDBDatabase,["deleteObjectStore","close"]),XN.prototype.transaction=function(){return new zN(this._db.transaction.apply(this._db,arguments))},BN(XN,"_db",["name","version","objectStoreNames"]),WN(XN,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(i){[GN,QN].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)}})})}),[QN,GN].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 JN,$N=1e4,ZN="w:0.3.3",tA="FIS_v2",eA="https://firebaseinstallations.googleapis.com/v1",nA=36e5,rA=((JN={})["missing-app-config-values"]='Missing App configuration value: "{$valueName}"',JN["not-registered"]="Firebase Installation is not registered.",JN["installation-not-found"]="Firebase Installation not found.",JN["request-failed"]='{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',JN["app-offline"]="Could not process request. Application offline.",JN["delete-pending-registration"]="Can't delete installation while there is a pending registration request.",JN),iA=new Sa("installations","Installations",rA);function oA(t){return t instanceof Ea&&t.code.includes("request-failed")}function aA(t){var e,n;if(!t||!t.options)throw sA("App Configuration");if(!t.name)throw sA("App Name");try{for(var r=ra(["projectId","apiKey","appId"]),i=r.next();!i.done;i=r.next()){var o=i.value;if(!t.options[o])throw sA(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}}function sA(t){return iA.create("missing-app-config-values",{valueName:t})}function uA(t){var e=t.projectId;return eA+"/projects/"+e+"/installations"}function cA(t){return{token:t.token,requestStatus:2,expiresIn:function(t){return Number(t.replace("s","000"))}(t.expiresIn),creationTime:Date.now()}}function hA(r,i){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return[4,i.json()];case 1:return e=t.sent(),n=e.error,[2,iA.create("request-failed",{requestName:r,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})]}})})}function lA(t){var e=t.apiKey;return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function fA(t,e){var n=e.refreshToken,r=lA(t);return r.append("Authorization",function(t){return tA+" "+t}(n)),r}function pA(n){return ea(this,void 0,void 0,function(){var e;return na(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 dA(e){return new Promise(function(t){setTimeout(t,e)})}var yA=/^[cdef][\w-]{21}$/,mA="";function vA(){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,oa(t))).replace(/\+/g,"-").replace(/\//g,"_")}(t).substr(0,22)}(t);return yA.test(e)?e:mA}catch(t){return mA}}var gA,bA="firebase-installations-database",wA=1,_A="firebase-installations-store",EA=null;function TA(){return EA=EA||function(t,e,n){var r=VN(indexedDB,"open",[t,e]),i=r.request;return i&&(i.onupgradeneeded=function(t){n&&n(new YN(i.result,t.oldVersion,i.transaction))}),r.then(function(t){return new XN(t)})}(bA,wA,function(t){switch(t.oldVersion){case 0:t.createObjectStore(_A)}})}function SA(i,o){return ea(this,void 0,void 0,function(){var e,n,r;return na(this,function(t){switch(t.label){case 0:return e=NA(i),[4,TA()];case 1:return n=t.sent(),[4,(r=n.transaction(_A,"readwrite")).objectStore(_A).put(o,e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2,o]}})})}function IA(i){return ea(this,void 0,void 0,function(){var e,n,r;return na(this,function(t){switch(t.label){case 0:return e=NA(i),[4,TA()];case 1:return n=t.sent(),[4,(r=n.transaction(_A,"readwrite")).objectStore(_A).delete(e)];case 2:return t.sent(),[4,r.complete];case 3:return t.sent(),[2]}})})}function CA(s,u){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a;return na(this,function(t){switch(t.label){case 0:return e=NA(s),[4,TA()];case 1:return n=t.sent(),r=n.transaction(_A,"readwrite"),[4,(i=r.objectStore(_A)).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 NA(t){return t.appName+"!"+t.appId}function AA(i){return ea(this,void 0,void 0,function(){var r,e,n;return na(this,function(t){switch(t.label){case 0:return[4,CA(i,function(t){var e=function(t){return DA(t||{fid:vA(),registrationStatus:0})}(t),n=function(t,e){{if(0!==e.registrationStatus)return 1===e.registrationStatus?{installationEntry:e,registrationPromise:function(o){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(this,function(t){switch(t.label){case 0:return[4,kA(o)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.registrationStatus?[3,5]:[4,dA(100)];case 3:return t.sent(),[4,kA(o)];case 4:return e=t.sent(),[3,2];case 5:return 0!==e.registrationStatus?[3,7]:[4,AA(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(iA.create("app-offline"));return{installationEntry:e,registrationPromise:n}}var r={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},i=function(r,i){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,7]),[4,function(s,t){var u=t.fid;return ea(this,void 0,void 0,function(){var e,n,r,i,o,a;return na(this,function(t){switch(t.label){case 0:return e=uA(s),n=lA(s),r={fid:u,authVersion:tA,appId:s.appId,sdkVersion:ZN},i={method:"POST",headers:n,body:JSON.stringify(r)},[4,pA(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:cA(a.authToken)}];case 3:return[4,hA("Create Installation",o)];case 4:throw t.sent()}})})}(r,i)];case 1:return e=t.sent(),[2,SA(r,e)];case 2:return oA(n=t.sent())&&409===n.serverCode?[4,IA(r)]:[3,4];case 3:return t.sent(),[3,6];case 4:return[4,SA(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!==mA?[3,3]:(n={},[4,r]);case 2:return[2,(n.installationEntry=t.sent(),n)];case 3:return[2,{installationEntry:e,registrationPromise:r}]}})})}function kA(t){return CA(t,function(t){if(!t)throw iA.create("installation-not-found");return DA(t)})}function DA(t){return function(t){return 1===t.registrationStatus&&t.registrationTime+$N<Date.now()}(t)?{fid:t.fid,registrationStatus:0}:t}function RA(s,u){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a;return na(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return uA(t)+"/"+n+"/authTokens:generate"}(s,u),n=fA(s,u),r={installation:{sdkVersion:ZN}},i={method:"POST",headers:n,body:JSON.stringify(r)},[4,pA(function(){return fetch(e,i)})];case 1:return(o=t.sent()).ok?[4,o.json()]:[3,3];case 2:return a=t.sent(),[2,cA(a)];case 3:return[4,hA("Generate Auth Token",o)];case 4:throw t.sent()}})})}function OA(i,o){return void 0===o&&(o=!1),ea(this,void 0,void 0,function(){var r,e,n;return na(this,function(t){switch(t.label){case 0:return[4,CA(i,function(t){if(!MA(t))throw iA.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+nA}(t)}(e))return t;if(1===e.requestStatus)return r=function(r,i){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return[4,PA(r)];case 1:e=t.sent(),t.label=2;case 2:return 1!==e.authToken.requestStatus?[3,5]:[4,dA(100)];case 3:return t.sent(),[4,PA(r)];case 4:return e=t.sent(),[3,2];case 5:return 0===(n=e.authToken).requestStatus?[2,OA(r,i)]:[2,n]}})})}(i,o),t;if(!navigator.onLine)throw iA.create("app-offline");var n=function(t){var e={requestStatus:1,requestTime:Date.now()};return ta(ta({},t),{authToken:e})}(t);return r=function(i,o){return ea(this,void 0,void 0,function(){var e,n,r;return na(this,function(t){switch(t.label){case 0:return t.trys.push([0,3,,8]),[4,RA(i,o)];case 1:return e=t.sent(),r=ta(ta({},o),{authToken:e}),[4,SA(i,r)];case 2:return t.sent(),[2,e];case 3:return!oA(n=t.sent())||401!==n.serverCode&&404!==n.serverCode?[3,5]:[4,IA(i)];case 4:return t.sent(),[3,7];case 5:return r=ta(ta({},o),{authToken:{requestStatus:0}}),[4,SA(i,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 PA(t){return CA(t,function(t){if(!MA(t))throw iA.create("not-registered");return function(t){return 1===t.requestStatus&&t.requestTime+$N<Date.now()}(t.authToken)?ta(ta({},t),{authToken:{requestStatus:0}}):t})}function MA(t){return void 0!==t&&2===t.registrationStatus}function xA(n,r){return void 0===r&&(r=!1),ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return[4,function(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return[4,AA(n)];case 1:return(e=t.sent().registrationPromise)?[4,e]:[3,3];case 2:t.sent(),t.label=3;case 3:return[2]}})})}(e=aA(n))];case 1:return t.sent(),[4,OA(e,r)];case 2:return[2,t.sent().token]}})})}function LA(o,a){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(this,function(t){switch(t.label){case 0:return e=function(t,e){var n=e.fid;return uA(t)+"/"+n}(o,a),n=fA(o,a),r={method:"DELETE",headers:n},[4,pA(function(){return fetch(e,r)})];case 1:return(i=t.sent()).ok?[3,3]:[4,hA("Delete Installation",i)];case 2:throw t.sent();case 3:return[2]}})})}fl.INTERNAL.registerService("installations",function(e){return aA(e),{app:e,getId:function(){return function(o){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(this,function(t){switch(t.label){case 0:return[4,AA(e=aA(o))];case 1:return n=t.sent(),r=n.installationEntry,(i=n.registrationPromise)?i.catch(console.error):OA(e).catch(console.error),[2,r.fid]}})})}(e)},getToken:function(t){return xA(e,t)},delete:function(){return function(r){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return[4,CA(e=aA(r),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 iA.create("delete-pending-registration");case 2:if(2!==n.registrationStatus)return[3,6];if(navigator.onLine)return[3,3];throw iA.create("app-offline");case 3:return[4,LA(e,n)];case 4:return t.sent(),[4,IA(e)];case 5:t.sent(),t.label=6;case 6:return[2]}})})}(e)}}});var FA,UA,qA=((gA={})["only-available-in-window"]="This method is available in a Window context.",gA["only-available-in-sw"]="This method is available in a service worker context.",gA["should-be-overriden"]="This method should be overriden by extended classes.",gA["bad-sender-id"]="Please ensure that 'messagingSenderId' is set correctly in the options passed into firebase.initializeApp().",gA["permission-default"]="The required permissions were not granted and dismissed instead.",gA["permission-blocked"]="The required permissions were not granted and blocked instead.",gA["unsupported-browser"]="This browser doesn't support the API's required to use the firebase SDK.",gA["notifications-blocked"]="Notifications have been blocked.",gA["failed-serviceworker-registration"]="We are unable to register the default service worker. {$browserErrorMessage}",gA["sw-registration-expected"]="A service worker registration was the expected input.",gA["get-subscription-failed"]="There was an error when trying to get any existing Push Subscriptions.",gA["invalid-saved-token"]="Unable to access details of the saved token.",gA["sw-reg-redundant"]="The service worker being used for push was made redundant.",gA["token-subscribe-failed"]="A problem occured while subscribing the user to FCM: {$errorInfo}",gA["token-subscribe-no-token"]="FCM returned no token when subscribing the user to push.",gA["token-unsubscribe-failed"]="A problem occured while unsubscribing the user from FCM: {$errorInfo}",gA["token-update-failed"]="A problem occured while updating the user from FCM: {$errorInfo}",gA["token-update-no-token"]="FCM returned no token when updating the user to push.",gA["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.",gA["invalid-delete-token"]="You must pass a valid token into deleteToken(), i.e. the token from getToken().",gA["delete-token-not-found"]="The deletion attempt for token could not be performed as the token was not found.",gA["delete-scope-not-found"]="The deletion attempt for service worker scope could not be performed as the scope was not found.",gA["bg-handler-function-expected"]="The input to setBackgroundMessageHandler() must be a function.",gA["no-window-client-to-msg"]="An attempt was made to message a non-existant window client.",gA["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}",gA["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.",gA["failed-to-delete-token"]="Unable to delete the currently saved token.",gA["no-sw-in-reg"]="Even though the service worker registration was successful, there was a problem accessing the service worker itself.",gA["bad-scope"]="The service worker scope must be a string with at least one character.",gA["bad-vapid-key"]="The public VAPID key is not a Uint8Array with 65 bytes.",gA["bad-subscription"]="The subscription must be a valid PushSubscription.",gA["bad-token"]="The FCM Token used for storage / lookup was not a valid token string.",gA["failed-delete-vapid-key"]="The VAPID key could not be deleted.",gA["invalid-public-vapid-key"]="The public VAPID key must be a string.",gA["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.",gA["public-vapid-key-decryption-failed"]="The public VAPID key did not equal 65 bytes when decrypted.",gA),VA=new Sa("messaging","Messaging",qA),BA=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]),jA="google.c.a.c_id";function WA(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 KA(t){return function(t){var e=new Uint8Array(t);return btoa(String.fromCharCode.apply(String,oa(e)))}(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(UA=FA=FA||{}).PUSH_MSG_RECEIVED="push-msg-received",UA.NOTIFICATION_CLICKED="notification-clicked";var QA=(HA.prototype.getToken=function(s,u,c){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a;return na(this,function(t){switch(t.label){case 0:return[4,zA(s)];case 1:e=t.sent(),n=YA(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(GA(s),r)];case 3:return[4,t.sent().json()];case 4:return i=t.sent(),[3,6];case 5:throw o=t.sent(),VA.create("token-subscribe-failed",{errorInfo:o});case 6:if(i.error)throw a=i.error.message,VA.create("token-subscribe-failed",{errorInfo:a});if(!i.token)throw VA.create("token-subscribe-no-token");return[2,i.token]}})})},HA.prototype.updateToken=function(s,u,c,h){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a;return na(this,function(t){switch(t.label){case 0:return[4,zA(u)];case 1:e=t.sent(),n=YA(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(GA(u)+"/"+s.fcmToken,r)];case 3:return[4,t.sent().json()];case 4:return i=t.sent(),[3,6];case 5:throw o=t.sent(),VA.create("token-update-failed",{errorInfo:o});case 6:if(i.error)throw a=i.error.message,VA.create("token-update-failed",{errorInfo:a});if(!i.token)throw VA.create("token-update-no-token");return[2,i.token]}})})},HA.prototype.deleteToken=function(a,s){return ea(this,void 0,void 0,function(){var e,n,r,i,o;return na(this,function(t){switch(t.label){case 0:return[4,zA(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(GA(a)+"/"+s.fcmToken,n)];case 3:return[4,t.sent().json()];case 4:if((r=t.sent()).error)throw i=r.error.message,VA.create("token-unsubscribe-failed",{errorInfo:i});return[3,6];case 5:throw o=t.sent(),VA.create("token-unsubscribe-failed",{errorInfo:o});case 6:return[2]}})})},HA);function HA(){}function GA(t){return"https://fcmregistrations.googleapis.com/v1/projects/"+t.options.projectId+"/registrations"}function zA(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return[4,n.installations().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 YA(t,e){var n=KA(t.getKey("p256dh")),r=KA(t.getKey("auth")),i={web:{endpoint:t.endpoint,p256dh:n,auth:r}};return WA(e.buffer,BA.buffer)||(i.web.applicationPubKey=KA(e)),i}function XA(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 JA="undefined",$A="fcm_token_object_Store";function ZA(e){var n=indexedDB.open(JA);n.onerror=function(t){},n.onsuccess=function(t){!function(n,r){if(n.objectStoreNames.contains($A)){var t=n.transaction($A).objectStore($A),i=new QA,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(JA)}}}(n.result,e)}}var tk=(ek.prototype.get=function(e){return this.createTransaction(function(t){return t.get(e)})},ek.prototype.getIndex=function(e,n){return this.createTransaction(function(t){return t.index(e).get(n)})},ek.prototype.put=function(e){return this.createTransaction(function(t){return t.put(e)},"readwrite")},ek.prototype.delete=function(e){return this.createTransaction(function(t){return t.delete(e)},"readwrite")},ek.prototype.closeDatabase=function(){return ea(this,void 0,void 0,function(){return na(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]}})})},ek.prototype.createTransaction=function(o,a){return void 0===a&&(a="readonly"),ea(this,void 0,void 0,function(){var e,n,r,i;return na(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)}})]}})})},ek.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},ek);function ek(){this.dbPromise=null}var nk,rk=(Zo(ik,nk=tk),ik.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:ZA(this.app);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=ta({},e);e.createTime||(n.createTime=Date.now()),"string"==typeof e.vapidKey&&(n.vapidKey=XA(e.vapidKey)),"string"==typeof e.auth&&(n.auth=XA(e.auth).buffer),"string"==typeof e.auth&&(n.p256dh=XA(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=ta({},e);"string"==typeof e.fcmPushSet&&delete n.fcmPushSet,t.update(n),t.continue()}}}},ik.prototype.getTokenDetailsFromToken=function(e){return ea(this,void 0,void 0,function(){return na(this,function(t){if(!e)throw VA.create("bad-token");return ok({fcmToken:e}),[2,this.getIndex("fcmToken",e)]})})},ik.prototype.getTokenDetailsFromSWScope=function(e){return ea(this,void 0,void 0,function(){return na(this,function(t){if(!e)throw VA.create("bad-scope");return ok({swScope:e}),[2,this.get(e)]})})},ik.prototype.saveTokenDetails=function(e){return ea(this,void 0,void 0,function(){return na(this,function(t){if(!e.swScope)throw VA.create("bad-scope");if(!e.vapidKey)throw VA.create("bad-vapid-key");if(!e.endpoint||!e.auth||!e.p256dh)throw VA.create("bad-subscription");if(!e.fcmSenderId)throw VA.create("bad-sender-id");if(!e.fcmToken)throw VA.create("bad-token");return ok(e),[2,this.put(e)]})})},ik.prototype.deleteToken=function(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return"string"!=typeof n||0===n.length?[2,Promise.reject(VA.create("invalid-delete-token"))]:[4,this.getTokenDetailsFromToken(n)];case 1:if(!(e=t.sent()))throw VA.create("delete-token-not-found");return[4,this.delete(e.swScope)];case 2:return t.sent(),[2,e]}})})},ik);function ik(t){var e=nk.call(this)||this;return e.app=t,e.dbName="fcm_token_details_db",e.dbVersion=4,e.objectStoreName="fcm_token_object_Store",e}function ok(t){if(t.fcmToken&&("string"!=typeof t.fcmToken||0===t.fcmToken.length))throw VA.create("bad-token");if(t.swScope&&("string"!=typeof t.swScope||0===t.swScope.length))throw VA.create("bad-scope");if(t.vapidKey&&(!(t.vapidKey instanceof Uint8Array)||65!==t.vapidKey.length))throw VA.create("bad-vapid-key");if(t.endpoint&&("string"!=typeof t.endpoint||0===t.endpoint.length))throw VA.create("bad-subscription");if(t.auth&&!(t.auth instanceof ArrayBuffer))throw VA.create("bad-subscription");if(t.p256dh&&!(t.p256dh instanceof ArrayBuffer))throw VA.create("bad-subscription");if(t.fcmSenderId&&("string"!=typeof t.fcmSenderId||0===t.fcmSenderId.length))throw VA.create("bad-sender-id")}var ak,sk=(Zo(uk,ak=tk),uk.prototype.onDbUpgrade=function(t){t.result.createObjectStore(this.objectStoreName,{keyPath:"swScope"})},uk.prototype.getVapidFromSWScope=function(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:if("string"!=typeof n||0===n.length)throw VA.create("bad-scope");return[4,this.get(n)];case 1:return[2,(e=t.sent())?e.vapidKey:void 0]}})})},uk.prototype.saveVapidDetails=function(n,r){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){if("string"!=typeof n||0===n.length)throw VA.create("bad-scope");if(null===r||65!==r.length)throw VA.create("bad-vapid-key");return e={swScope:n,vapidKey:r},[2,this.put(e)]})})},uk.prototype.deleteVapidDetails=function(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return[4,this.getVapidFromSWScope(n)];case 1:if(!(e=t.sent()))throw VA.create("delete-scope-not-found");return[4,this.delete(n)];case 2:return t.sent(),[2,e]}})})},uk);function uk(){var t=null!==ak&&ak.apply(this,arguments)||this;return t.dbName="fcm_vapid_details_db",t.dbVersion=1,t.objectStoreName="fcm_vapid_object_Store",t}var ck=(hk.prototype.getToken=function(){return ea(this,void 0,void 0,function(){var e,n,r,i,o;return na(this,function(t){switch(t.label){case 0:if("denied"===(e=this.getNotificationPermission_()))throw VA.create("notifications-blocked");return"granted"!==e?[2,null]:[4,this.getSWRegistration_()];case 1:return n=t.sent(),[4,this.getPublicVapidKey_()];case 2:return r=t.sent(),[4,this.getPushSubscription(n,r)];case 3:return i=t.sent(),[4,this.tokenDetailsModel.getTokenDetailsFromSWScope(n.scope)];case 4:return(o=t.sent())?[2,this.manageExistingToken(n,i,r,o)]:[2,this.getNewToken(n,i,r)]}})})},hk.prototype.manageExistingToken=function(e,n,r,i){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return function(t,e,n){if(!n.vapidKey||!WA(e.buffer,n.vapidKey.buffer))return!1;var r=t.endpoint===n.endpoint,i=WA(t.getKey("auth"),n.auth),o=WA(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]}})})},hk.prototype.updateToken=function(i,o,a,s){return ea(this,void 0,void 0,function(){var e,n,r;return na(this,function(t){switch(t.label){case 0:return t.trys.push([0,4,,6]),[4,this.subscriptionManager.updateToken(s,this.app,o,a)];case 1:return e=t.sent(),n={swScope:i.scope,vapidKey:a,fcmSenderId:this.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]}})})},hk.prototype.getNewToken=function(r,i,o){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return[4,this.subscriptionManager.getToken(this.app,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]}})})},hk.prototype.deleteToken=function(r){return ea(this,void 0,void 0,function(){var e,n;return na(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]}})})},hk.prototype.deleteTokenFromDB=function(n){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return[4,this.tokenDetailsModel.deleteToken(n)];case 1:return e=t.sent(),[4,this.subscriptionManager.deleteToken(this.app,e)];case 2:return t.sent(),[2]}})})},hk.prototype.getPushSubscription=function(n,r){return ea(this,void 0,void 0,function(){var e;return na(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})]}})})},hk.prototype.requestPermission=function(){throw VA.create("only-available-in-window")},hk.prototype.useServiceWorker=function(t){throw VA.create("only-available-in-window")},hk.prototype.usePublicVapidKey=function(t){throw VA.create("only-available-in-window")},hk.prototype.onMessage=function(t,e,n){throw VA.create("only-available-in-window")},hk.prototype.onTokenRefresh=function(t,e,n){throw VA.create("only-available-in-window")},hk.prototype.setBackgroundMessageHandler=function(t){throw VA.create("only-available-in-sw")},hk.prototype.delete=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return[4,Promise.all([this.tokenDetailsModel.closeDatabase(),this.vapidDetailsModel.closeDatabase()])];case 1:return t.sent(),[2]}})})},hk.prototype.getNotificationPermission_=function(){return Notification.permission},hk.prototype.getTokenDetailsModel=function(){return this.tokenDetailsModel},hk.prototype.getVapidDetailsModel=function(){return this.vapidDetailsModel},hk.prototype.getSubscriptionManager=function(){return this.subscriptionManager},hk);function hk(t){var e=this;if(this.app=t,this.vapidDetailsModel=new sk,this.subscriptionManager=new QA,!t.options.messagingSenderId||"string"!=typeof t.options.messagingSenderId)throw VA.create("bad-sender-id");this.INTERNAL={delete:function(){return e.delete()}},this.tokenDetailsModel=new rk(t)}var lk,fk="FCM_MSG",pk=(Zo(dk,lk=ck),dk.prototype.onPush=function(t){t.waitUntil(this.onPush_(t))},dk.prototype.onSubChange=function(t){t.waitUntil(this.onSubChange_(t))},dk.prototype.onNotificationClick=function(t){t.waitUntil(this.onNotificationClick_(t))},dk.prototype.onPush_=function(s){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a;return na(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]}})})},dk.prototype.onSubChange_=function(t){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(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(),VA.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]}})})},dk.prototype.onNotificationClick_=function(o){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(this,function(t){switch(t.label){case 0:if(!(o.notification&&o.notification.data&&o.notification.data[fk]))return[2];if(o.action)return[2];if(o.stopImmediatePropagation(),o.notification.close(),!(e=o.notification.data[fk]).notification)return[2];if(!(n=e.fcmOptions&&e.fcmOptions.link||e.notification.click_action)){if(!(e.data&&jA 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=mk(FA.NOTIFICATION_CLICKED,e),[2,this.attemptToMessageClient_(r,i)]):[2]}})})},dk.prototype.getNotificationData_=function(t){var e;if(t&&"object"==typeof t.notification){var n=ta({},t.notification);return n.data=ta(ta({},t.notification.data),((e={})[fk]=t,e)),n}},dk.prototype.setBackgroundMessageHandler=function(t){if(!t||"function"!=typeof t)throw VA.create("bg-handler-function-expected");this.bgMessageHandler=t},dk.prototype.getWindowClient_=function(o){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(this,function(t){switch(t.label){case 0:return e=new URL(o,self.location.href).href,[4,yk()];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]}})})},dk.prototype.attemptToMessageClient_=function(e,n){return ea(this,void 0,void 0,function(){return na(this,function(t){if(!e)throw VA.create("no-window-client-to-msg");return e.postMessage(n),[2]})})},dk.prototype.hasVisibleClients_=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return[4,yk()];case 1:return[2,t.sent().some(function(t){return"visible"===t.visibilityState&&!t.url.startsWith("chrome-extension://")})]}})})},dk.prototype.sendMessageToWindowClients_=function(i){return ea(this,void 0,void 0,function(){var e,n,r=this;return na(this,function(t){switch(t.label){case 0:return[4,yk()];case 1:return e=t.sent(),n=mk(FA.PUSH_MSG_RECEIVED,i),[4,Promise.all(e.map(function(t){return r.attemptToMessageClient_(t,n)}))];case 2:return t.sent(),[2]}})})},dk.prototype.getSWRegistration_=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){return[2,self.registration]})})},dk.prototype.getPublicVapidKey_=function(){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return[4,this.getSWRegistration_()];case 1:if(!(e=t.sent()))throw VA.create("sw-registration-expected");return[4,this.getVapidDetailsModel().getVapidFromSWScope(e.scope)];case 2:return null==(n=t.sent())?[2,BA]:[2,n]}})})},dk);function dk(t){var e=lk.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 yk(){return self.clients.matchAll({type:"window",includeUncontrolled:!0})}function mk(t,e){return{firebaseMessagingType:t,firebaseMessagingData:e}}var vk,gk,bk=(Zo(wk,vk=ck),wk.prototype.requestPermission=function(){return ea(this,void 0,void 0,function(){var e;return na(this,function(t){switch(t.label){case 0:return"granted"===this.getNotificationPermission_()?[2]:[4,Notification.requestPermission()];case 1:if("granted"===(e=t.sent()))return[2];throw"denied"===e?VA.create("permission-blocked"):VA.create("permission-default")}})})},wk.prototype.useServiceWorker=function(t){if(!(t instanceof ServiceWorkerRegistration))throw VA.create("sw-registration-expected");if(null!=this.registrationToUse)throw VA.create("use-sw-before-get-token");this.registrationToUse=t},wk.prototype.usePublicVapidKey=function(t){if("string"!=typeof t)throw VA.create("invalid-public-vapid-key");if(null!=this.publicVapidKeyToUse)throw VA.create("use-public-key-before-get-token");var e=XA(t);if(65!==e.length)throw VA.create("public-vapid-key-decryption-failed");this.publicVapidKeyToUse=e},wk.prototype.onMessage=function(t,e,n){return"function"==typeof t?this.onMessageInternal(t,e,n):this.onMessageInternal(t)},wk.prototype.onTokenRefresh=function(t,e,n){return"function"==typeof t?this.onTokenRefreshInternal(t,e,n):this.onTokenRefreshInternal(t)},wk.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(VA.create("sw-reg-redundant"))}i.removeEventListener("statechange",n)};i.addEventListener("statechange",n)}else e(VA.create("sw-reg-redundant"));else t(r);else e(VA.create("no-sw-in-reg"))})},wk.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 VA.create("failed-serviceworker-registration",{browserErrorMessage:t.message})}).then(function(t){return e.waitForRegistrationToActivate_(t).then(function(){return(e.registrationToUse=t).update(),t})}))},wk.prototype.getPublicVapidKey_=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){return this.publicVapidKeyToUse?[2,this.publicVapidKeyToUse]:[2,BA]})})},wk.prototype.setupSWMessageListener_=function(){var a=this;navigator.serviceWorker.addEventListener("message",function(t){if(t.data&&t.data.firebaseMessagingType&&t.data.firebaseMessagingData){var e=t.data,n=e.firebaseMessagingType,r=e.firebaseMessagingData;a.messageObserver&&a.messageObserver.next(r);var i=r.data;if(i&&jA in i&&"1"===i["google.c.a.e"]){var o=function(t){switch(t){case FA.NOTIFICATION_CLICKED:return"notification_open";case FA.PUSH_MSG_RECEIVED:return"notification_foreground";default:throw new Error}}(n);a.app.INTERNAL.analytics.logEvent(o,{message_name:i["google.c.a.c_l"],message_id:i[jA],message_time:i["google.c.a.ts"],message_device_time:Math.floor(Date.now()/1e3)})}}},!1)},wk);function wk(t){var e=vk.call(this,t)||this;return e.registrationToUse=null,e.publicVapidKeyToUse=null,e.messageObserver=null,e.tokenRefreshObserver=null,e.onMessageInternal=La(function(t){e.messageObserver=t}),e.onTokenRefreshInternal=La(function(t){e.tokenRefreshObserver=t}),e.setupSWMessageListener_(),e}function _k(){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")}gk={isSupported:_k},fl.INTERNAL.registerService("messaging",function(t){if(!_k())throw VA.create("unsupported-browser");return self&&"ServiceWorkerGlobalScope"in self?new pk(t):new bk(t)},gk);var Ek="firebasestorage.googleapis.com",Tk="storageBucket",Sk=(Ik.prototype.codeProp=function(){return this.code},Ik.prototype.codeEquals=function(t){return Nk(t)===this.codeProp()},Ik.prototype.serverResponseProp=function(){return this.serverResponse_},Ik.prototype.setServerResponseProp=function(t){this.serverResponse_=t},Object.defineProperty(Ik.prototype,"name",{get:function(){return this.name_},enumerable:!0,configurable:!0}),Object.defineProperty(Ik.prototype,"code",{get:function(){return this.code_},enumerable:!0,configurable:!0}),Object.defineProperty(Ik.prototype,"message",{get:function(){return this.message_},enumerable:!0,configurable:!0}),Object.defineProperty(Ik.prototype,"serverResponse",{get:function(){return this.serverResponse_},enumerable:!0,configurable:!0}),Ik);function Ik(t,e){this.code_=Nk(t),this.message_="Firebase Storage: "+e,this.serverResponse_=null,this.name_="FirebaseError"}var Ck={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 Nk(t){return"storage/"+t}function Ak(){return new Sk(Ck.UNKNOWN,"An unknown error occurred, please check the error payload for server response.")}function kk(){return new Sk(Ck.CANCELED,"User canceled the upload/download.")}function Dk(){return new Sk(Ck.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function Rk(t,e,n){return new Sk(Ck.INVALID_ARGUMENT,"Invalid argument in `"+e+"` at index "+t+": "+n)}function Ok(){return new Sk(Ck.APP_DELETED,"The Firebase app was deleted.")}function Pk(t,e){return new Sk(Ck.INVALID_FORMAT,"String does not match format '"+t+"': "+e)}function Mk(t){throw new Sk(Ck.INTERNAL_ERROR,"Internal error: "+t)}var xk={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};function Lk(t){switch(t){case xk.RAW:case xk.BASE64:case xk.BASE64URL:case xk.DATA_URL:return;default:throw"Expected one of the event types: ["+xk.RAW+", "+xk.BASE64+", "+xk.BASE64URL+", "+xk.DATA_URL+"]."}}var Fk=function(t,e){this.data=t,this.contentType=e||null};function Uk(t,e){switch(t){case xk.RAW:return new Fk(qk(e));case xk.BASE64:case xk.BASE64URL:return new Fk(Vk(t,e));case xk.DATA_URL:return new Fk(function(t){var e=new Bk(t);return e.base64?Vk(xk.BASE64,e.rest):function(t){var e;try{e=decodeURIComponent(t)}catch(t){throw Pk(xk.DATA_URL,"Malformed data URL.")}return qk(e)}(e.rest)}(e),function(t){return new Bk(t).contentType}(e))}throw Ak()}function qk(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 Vk(e,t){switch(e){case xk.BASE64:var n=-1!==t.indexOf("-"),r=-1!==t.indexOf("_");if(n||r)throw Pk(e,"Invalid character '"+(n?"-":"_")+"' found: is it base64url encoded?");break;case xk.BASE64URL:var i=-1!==t.indexOf("+"),o=-1!==t.indexOf("/");if(i||o)throw Pk(e,"Invalid character '"+(i?"+":"/")+"' found: is it base64 encoded?");t=t.replace(/-/g,"+").replace(/_/g,"/")}var a;try{a=atob(t)}catch(t){throw Pk(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 Bk=function(t){this.base64=!1,this.contentType=null;var e=t.match(/^data:([^,]+)?,/);if(null===e)throw Pk(xk.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 jk,Wk,Kk={STATE_CHANGED:"state_changed"},Qk="running",Hk="pausing",Gk="paused",zk="success",Yk="canceling",Xk="canceled",Jk="error",$k={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function Zk(t){switch(t){case Qk:case Hk:case Yk:return $k.RUNNING;case Gk:return $k.PAUSED;case zk:return $k.SUCCESS;case Xk:return $k.CANCELED;case Jk:default:return $k.ERROR}}function tD(t){return null!=t}function eD(t){return void 0!==t}function nD(t){return"function"==typeof t}function rD(t){return"object"==typeof t}function iD(t){return"string"==typeof t||t instanceof String}function oD(t){return"number"==typeof t||t instanceof Number}function aD(t){return sD()&&t instanceof Blob}function sD(){return"undefined"!=typeof Blob}(Wk=jk=jk||{})[Wk.NO_ERROR=0]="NO_ERROR",Wk[Wk.NETWORK_ERROR=1]="NETWORK_ERROR",Wk[Wk.ABORT=2]="ABORT";var uD=(cD.prototype.send=function(t,e,n,r){if(this.sent_)throw Mk("cannot .send() more than once");if(this.sent_=!0,this.xhr_.open(e,t,!0),tD(r))for(var i in r)r.hasOwnProperty(i)&&this.xhr_.setRequestHeader(i,r[i].toString());return tD(n)?this.xhr_.send(n):this.xhr_.send(),this.sendPromise_},cD.prototype.getErrorCode=function(){if(!this.sent_)throw Mk("cannot .getErrorCode() before sending");return this.errorCode_},cD.prototype.getStatus=function(){if(!this.sent_)throw Mk("cannot .getStatus() before sending");try{return this.xhr_.status}catch(t){return-1}},cD.prototype.getResponseText=function(){if(!this.sent_)throw Mk("cannot .getResponseText() before sending");return this.xhr_.responseText},cD.prototype.abort=function(){this.xhr_.abort()},cD.prototype.getResponseHeader=function(t){return this.xhr_.getResponseHeader(t)},cD.prototype.addUploadProgressListener=function(t){tD(this.xhr_.upload)&&this.xhr_.upload.addEventListener("progress",t)},cD.prototype.removeUploadProgressListener=function(t){tD(this.xhr_.upload)&&this.xhr_.upload.removeEventListener("progress",t)},cD);function cD(){var e=this;this.sent_=!1,this.xhr_=new XMLHttpRequest,this.errorCode_=jk.NO_ERROR,this.sendPromise_=new Promise(function(t){e.xhr_.addEventListener("abort",function(){e.errorCode_=jk.ABORT,t(e)}),e.xhr_.addEventListener("error",function(){e.errorCode_=jk.NETWORK_ERROR,t(e)}),e.xhr_.addEventListener("load",function(){t(e)})})}var hD=(lD.prototype.createXhrIo=function(){return new uD},lD);function lD(){}function fD(){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(sD())return new Blob(t);throw Error("This browser doesn't seem to support creating Blobs")}var pD=(dD.prototype.size=function(){return this.size_},dD.prototype.type=function(){return this.type_},dD.prototype.slice=function(t,e){if(aD(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 dD(n)}return new dD(new Uint8Array(this.data_.buffer,t,e-t),!0)},dD.getBlob=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(sD()){var n=t.map(function(t){return t instanceof dD?t.data_:t});return new dD(fD.apply(null,n))}var r=t.map(function(t){return iD(t)?Uk(xk.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 dD(o,!0)},dD.prototype.uploadData=function(){return this.data_},dD);function dD(t,e){var n=0,r="";aD(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(mD.prototype,"path",{get:function(){return this.path_},enumerable:!0,configurable:!0}),Object.defineProperty(mD.prototype,"isRoot",{get:function(){return 0===this.path.length},enumerable:!0,configurable:!0}),mD.prototype.fullServerUrl=function(){var t=encodeURIComponent;return"/b/"+t(this.bucket)+"/o/"+t(this.path)},mD.prototype.bucketOnlyServerUrl=function(){return"/b/"+encodeURIComponent(this.bucket)+"/o"},mD.makeFromBucketSpec=function(e){var t;try{t=mD.makeFromUrl(e)}catch(t){return new mD(e,"")}if(""===t.path)return t;throw function(t){return new Sk(Ck.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+t+"'.")}(e)},mD.makeFromUrl=function(t){for(var e=null,n="([A-Za-z0-9.\\-_]+)",r=new RegExp("^gs://"+n+"(/(.*))?$","i"),i=Ek.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 mD(c,h=h||""),s.postModify(e);break}}if(null==e)throw function(t){return new Sk(Ck.INVALID_URL,"Invalid URL '"+t+"'.")}(t);return e},mD);function mD(t,e){this.bucket=t,this.path_=e}function vD(t){var e;try{e=JSON.parse(t)}catch(t){return null}return function(t){return rD(t)&&!Array.isArray(t)}(e)?e:null}function gD(t){var e=t.lastIndexOf("/",t.length-2);return-1===e?t:t.slice(e+1)}function bD(t){return"https://"+Ek+"/v0"+t}function wD(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 _D(t,e){return e}var ED=function(t,e,n,r){this.server=t,this.local=e||t,this.writable=!!n,this.xform=r||_D},TD=null;function SD(){if(TD)return TD;var t=[];t.push(new ED("bucket")),t.push(new ED("generation")),t.push(new ED("metageneration")),t.push(new ED("name","fullPath",!0));var e=new ED("name");e.xform=function(t,e){return function(t){return!iD(t)||t.length<2?t:gD(t)}(e)},t.push(e);var n=new ED("size");return n.xform=function(t,e){return tD(e)?Number(e):e},t.push(n),t.push(new ED("timeCreated")),t.push(new ED("updated")),t.push(new ED("md5Hash",null,!0)),t.push(new ED("cacheControl",null,!0)),t.push(new ED("contentDisposition",null,!0)),t.push(new ED("contentEncoding",null,!0)),t.push(new ED("contentLanguage",null,!0)),t.push(new ED("contentType",null,!0)),t.push(new ED("metadata","customMetadata",!0)),TD=t}function ID(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 CD(t,e,n){var r=vD(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 ID(r,t),r}(t,r,n)}function ND(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 AD(t){if(!rD(t)||!t)throw"Expected Metadata object.";for(var e in t)if(t.hasOwnProperty(e)){var n=t[e];if("customMetadata"===e){if(!rD(n))throw"Expected object for 'customMetadata' mapping."}else if(rD(r=n)&&null!==r)throw"Mapping for '"+e+"' cannot be an object."}var r}var kD="maxResults",DD=1e3,RD="pageToken",OD="prefixes",PD="items";function MD(t,e){var n={prefixes:[],items:[],nextPageToken:e.nextPageToken},r=t.bucket();if(null===r)throw new Sk(Ck.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Tk+"' property when initializing the app?");if(e[OD])for(var i=0,o=e[OD];i<o.length;i++){var a=o[i].replace(/\/$/,""),s=t.makeStorageReference(new yD(r,a));n.prefixes.push(s)}if(e[PD])for(var u=0,c=e[PD];u<c.length;u++){var h=c[u];s=t.makeStorageReference(new yD(r,h.name));n.items.push(s)}return n}function xD(t){if(!rD(t)||!t)throw"Expected ListOptions object.";for(var e in t)if(e===kD){if(!oD(n=t[kD])||!Number.isInteger(n)||t[kD]<=0)throw"Expected maxResults to be a positive number.";if(1e3<t[kD])throw"Expected maxResults to be less than or equal to "+DD+"."}else{if(e!==RD)throw"Unknown option: "+e;if(t[RD]&&!iD(t[RD]))throw"Expected pageToken to be string."}var n}var LD=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 FD(t){if(!t)throw Ak()}function UD(r,i){return function(t,e){var n=CD(r,e,i);return FD(null!==n),n}}function qD(r){return function(t,e){var n=function(t,e){var n=vD(e);return null===n?null:MD(t,n)}(r,e);return FD(null!==n),n}}function VD(r,i){return function(t,e){var n=CD(r,e,i);return FD(null!==n),function(r,t){var e=vD(t);if(null===e)return null;if(!iD(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 bD("/b/"+i(e)+"/o/"+i(n))+wD({alt:"media",token:t})})[0]}(n,e)}}function BD(r){return function(t,e){var n;return(n=401===t.getStatus()?new Sk(Ck.UNAUTHENTICATED,"User is not authenticated, please authenticate using Firebase Authentication and try again."):402===t.getStatus()?function(t){return new Sk(Ck.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 Sk(Ck.UNAUTHORIZED,"User does not have permission to access '"+t+"'.")}(r.path):e).setServerResponseProp(e.serverResponseProp()),n}}function jD(r){var i=BD(r);return function(t,e){var n=i(t,e);return 404===t.getStatus()&&(n=function(t){return new Sk(Ck.OBJECT_NOT_FOUND,"Object '"+t+"' does not exist.")}(r.path)),n.setServerResponseProp(e.serverResponseProp()),n}}function WD(t,e,n){var r=bD(e.fullServerUrl()),i=t.maxOperationRetryTime(),o=new LD(r,"GET",UD(t,n),i);return o.errorHandler=jD(e),o}function KD(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 QD(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=KD(e,r,i),c="--"+s+"\r\nContent-Type: application/json; charset=utf-8\r\n\r\n"+ND(u,n)+"\r\n--"+s+"\r\nContent-Type: "+u.contentType+"\r\n\r\n",h="\r\n--"+s+"--",l=pD.getBlob(c,r,h);if(null===l)throw Dk();var f={name:u.fullPath},p=bD(o),d=t.maxUploadRetryTime(),y=new LD(p,"POST",UD(t,n),d);return y.urlParams=f,y.headers=a,y.body=l.uploadData(),y.errorHandler=BD(e),y}var HD=function(t,e,n,r){this.current=t,this.total=e,this.finalized=!!n,this.metadata=r||null};function GD(t,e){var n=null;try{n=t.getResponseHeader("X-Goog-Upload-Status")}catch(t){FD(!1)}return FD(!!n&&-1!==(e||["active"]).indexOf(n)),n}function zD(t,e,n,r,i){var o=e.bucketOnlyServerUrl(),a=KD(e,r,i),s={name:a.fullPath},u=bD(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=ND(a,n),l=t.maxUploadRetryTime();var f=new LD(u,"POST",function(t){var e;GD(t);try{e=t.getResponseHeader("X-Goog-Upload-URL")}catch(t){FD(!1)}return FD(iD(e)),e},l);return f.urlParams=s,f.headers=c,f.body=h,f.errorHandler=BD(e),f}function YD(t,e,n,i){var r=t.maxUploadRetryTime(),o=new LD(n,"POST",function(t){var e=GD(t,["active","final"]),n=null;try{n=t.getResponseHeader("X-Goog-Upload-Size-Received")}catch(t){FD(!1)}n||FD(!1);var r=Number(n);return FD(!isNaN(r)),new HD(r,i.size(),"final"===e)},r);return o.headers={"X-Goog-Upload-Command":"query"},o.errorHandler=BD(e),o}function XD(t,a,e,s,n,u,r,i){var c=new HD(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 Sk(Ck.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 Dk();var y=a.maxUploadRetryTime(),m=new LD(e,"POST",function(t,e){var n,r=GD(t,["active","final"]),i=c.current+h,o=s.size();return n="final"===r?UD(a,u)(t,e):null,new HD(i,o,"final"===r,n)},y);return m.headers=p,m.body=d.uploadData(),m.progressCallback=i||null,m.errorHandler=BD(t),m}var JD=function(t,e,n){if(nD(t)||tD(e)||tD(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}},$D=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 ZD(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 Sk(Ck.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?Rk(o,e,t.message):Rk(o,e,t)}}var tR=function(e,t){var n=this;this.validator=function(t){n.optional&&!eD(t)||e(t)},this.optional=!!t};function eR(t,e){function n(t){if(!iD(t))throw"Expected string."}var r;return r=t?function(e,n){return function(t){e(t),n(t)}}(n,t):n,new tR(r,e)}function nR(){return new tR(function(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer||sD()&&t instanceof Blob))throw"Expected Blob or File."})}function rR(t){return new tR(AD,t)}function iR(){return new tR(function(t){if(!(oD(t)&&0<=t))throw"Expected a number 0 or greater."})}function oR(e,t){return new tR(function(t){if(!(null===t||tD(t)&&t instanceof Object))throw"Expected an Object.";null!=e&&e(t)},t)}function aR(t){return new tR(function(t){if(!(null===t||nD(t)))throw"Expected a Function."},t)}function sR(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 uR=(cR.prototype.makeProgressCallback_=function(){var e=this,n=this.transferred_;return function(t){return e.updateProgress_(n+t)}},cR.prototype.shouldDoResumable_=function(t){return 262144<t.size()},cR.prototype.start_=function(){this.state_===Qk&&null===this.request_&&(this.resumable_?null===this.uploadUrl_?this.createResumable_():this.needToFetchStatus_?this.fetchStatus_():this.needToFetchMetadata_?this.fetchMetadata_():this.continueUpload_():this.oneShotUpload_())},cR.prototype.resolveToken_=function(e){var n=this;this.authWrapper_.getAuthToken().then(function(t){switch(n.state_){case Qk:e(t);break;case Yk:n.transition_(Xk);break;case Hk:n.transition_(Gk)}})},cR.prototype.createResumable_=function(){var r=this;this.resolveToken_(function(t){var e=zD(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_)})},cR.prototype.fetchStatus_=function(){var r=this,i=this.uploadUrl_;this.resolveToken_(function(t){var e=YD(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_)})},cR.prototype.continueUpload_=function(){var r=this,i=262144*this.chunkMultiplier_,o=new HD(this.transferred_,this.blob_.size()),a=this.uploadUrl_;this.resolveToken_(function(t){var e;try{e=XD(r.location_,r.authWrapper_,a,r.blob_,i,r.mappings_,o,r.makeProgressCallback_())}catch(t){return r.error_=t,void r.transition_(Jk)}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_(zk)):r.completeTransitions_()},r.errorHandler_)})},cR.prototype.increaseMultiplier_=function(){262144*this.chunkMultiplier_<33554432&&(this.chunkMultiplier_*=2)},cR.prototype.fetchMetadata_=function(){var r=this;this.resolveToken_(function(t){var e=WD(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_(zk)},r.metadataErrorHandler_)})},cR.prototype.oneShotUpload_=function(){var r=this;this.resolveToken_(function(t){var e=QD(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_(zk)},r.errorHandler_)})},cR.prototype.updateProgress_=function(t){var e=this.transferred_;this.transferred_=t,this.transferred_!==e&&this.notifyObservers_()},cR.prototype.transition_=function(t){if(this.state_!==t)switch(t){case Yk:case Hk:this.state_=t,null!==this.request_&&this.request_.cancel();break;case Qk:var e=this.state_===Gk;this.state_=t,e&&(this.notifyObservers_(),this.start_());break;case Gk:this.state_=t,this.notifyObservers_();break;case Xk:this.error_=kk(),this.state_=t,this.notifyObservers_();break;case Jk:case zk:this.state_=t,this.notifyObservers_()}},cR.prototype.completeTransitions_=function(){switch(this.state_){case Hk:this.transition_(Gk);break;case Yk:this.transition_(Xk);break;case Qk:this.start_()}},Object.defineProperty(cR.prototype,"snapshot",{get:function(){var t=Zk(this.state_);return new $D(this.transferred_,this.blob_.size(),t,this.metadata_,this,this.ref_)},enumerable:!0,configurable:!0}),cR.prototype.on=function(t,e,n,o){var r="Expected a function or an Object with one of `next`, `error`, `complete` properties.",i=aR(!0).validator,a=oR(null,!0).validator;function s(t){try{return void i(t)}catch(t){}try{if(a(t),!(eD(t.next)||eD(t.error)||eD(t.complete)))throw"";return}catch(t){throw r}}ZD("on",[eR(function(){if(t!==Kk.STATE_CHANGED)throw"Expected one of the event types: ["+Kk.STATE_CHANGED+"]."}),oR(s,!0),aR(!0),aR(!0)],arguments);var u=this;function c(i){return function(t,e,n){null!==i&&ZD("on",i,arguments);var r=new JD(t,e,o);return u.addObserver_(r),function(){u.removeObserver_(r)}}}var h=[oR(function(t){if(null===t)throw r;s(t)}),aR(!0),aR(!0)];return eD(e)||eD(n)||eD(o)?c(null)(e,n,o):c(h)},cR.prototype.then=function(t,e){return this.promise_.then(t,e)},cR.prototype.catch=function(t){return this.then(null,t)},cR.prototype.addObserver_=function(t){this.observers_.push(t),this.notifyObserver_(t)},cR.prototype.removeObserver_=function(t){var e=this.observers_.indexOf(t);-1!==e&&this.observers_.splice(e,1)},cR.prototype.notifyObservers_=function(){var e=this;this.finishPromise_(),this.observers_.slice().forEach(function(t){e.notifyObserver_(t)})},cR.prototype.finishPromise_=function(){if(null!==this.resolve_){var t=!0;switch(Zk(this.state_)){case $k.SUCCESS:sR(this.resolve_.bind(null,this.snapshot))();break;case $k.CANCELED:case $k.ERROR:sR(this.reject_.bind(null,this.error_))();break;default:t=!1}t&&(this.resolve_=null,this.reject_=null)}},cR.prototype.notifyObserver_=function(t){switch(Zk(this.state_)){case $k.RUNNING:case $k.PAUSED:t.next&&sR(t.next.bind(t,this.snapshot))();break;case $k.SUCCESS:t.complete&&sR(t.complete.bind(t))();break;case $k.CANCELED:case $k.ERROR:t.error&&sR(t.error.bind(t,this.error_))();break;default:t.error&&sR(t.error.bind(t,this.error_))()}},cR.prototype.resume=function(){ZD("resume",[],arguments);var t=this.state_===Gk||this.state_===Hk;return t&&this.transition_(Qk),t},cR.prototype.pause=function(){ZD("pause",[],arguments);var t=this.state_===Qk;return t&&this.transition_(Hk),t},cR.prototype.cancel=function(){ZD("cancel",[],arguments);var t=this.state_===Qk||this.state_===Hk;return t&&this.transition_(Yk),t},cR);function cR(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_=Qk,this.errorHandler_=function(t){a.request_=null,a.chunkMultiplier_=1,t.codeEquals(Ck.CANCELED)?(a.needToFetchStatus_=!0,a.completeTransitions_()):(a.error_=t,a.transition_(Jk))},this.metadataErrorHandler_=function(t){a.request_=null,t.codeEquals(Ck.CANCELED)?a.completeTransitions_():(a.error_=t,a.transition_(Jk))},this.promise_=new Promise(function(t,e){a.resolve_=t,a.reject_=e,a.start_()}),this.promise_.then(null,function(){})}var hR=(lR.prototype.toString=function(){return ZD("toString",[],arguments),"gs://"+this.location.bucket+"/"+this.location.path},lR.prototype.newRef=function(t,e){return new lR(t,e)},lR.prototype.mappings=function(){return SD()},lR.prototype.child=function(t){ZD("child",[eR()],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(lR.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(lR.prototype,"root",{get:function(){var t=new yD(this.location.bucket,"");return this.newRef(this.authWrapper,t)},enumerable:!0,configurable:!0}),Object.defineProperty(lR.prototype,"bucket",{get:function(){return this.location.bucket},enumerable:!0,configurable:!0}),Object.defineProperty(lR.prototype,"fullPath",{get:function(){return this.location.path},enumerable:!0,configurable:!0}),Object.defineProperty(lR.prototype,"name",{get:function(){return gD(this.location.path)},enumerable:!0,configurable:!0}),Object.defineProperty(lR.prototype,"storage",{get:function(){return this.authWrapper.service()},enumerable:!0,configurable:!0}),lR.prototype.put=function(t,e){return void 0===e&&(e=null),ZD("put",[nR(),rR(!0)],arguments),this.throwIfRoot_("put"),new uR(this,this.authWrapper,this.location,this.mappings(),new pD(t),e)},lR.prototype.putString=function(t,e,n){void 0===e&&(e=xk.RAW),ZD("putString",[eR(),eR(Lk,!0),rR(!0)],arguments),this.throwIfRoot_("putString");var r=Uk(e,t),i=Object.assign({},n);return!tD(i.contentType)&&tD(r.contentType)&&(i.contentType=r.contentType),new uR(this,this.authWrapper,this.location,this.mappings(),new pD(r.data,!0),i)},lR.prototype.delete=function(){var n=this;return ZD("delete",[],arguments),this.throwIfRoot_("delete"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e){var n=bD(e.fullServerUrl()),r=t.maxOperationRetryTime(),i=new LD(n,"DELETE",function(t,e){},r);return i.successCodes=[200,204],i.errorHandler=jD(e),i}(n.authWrapper,n.location);return n.authWrapper.makeRequest(e,t).getPromise()})},lR.prototype.listAll=function(){ZD("listAll",[],arguments);var t={prefixes:[],items:[]};return this.listAllHelper(t).then(function(){return t})},lR.prototype.listAllHelper=function(o,a){return ea(this,void 0,void 0,function(){var e,n,r,i;return na(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]}})})},lR.prototype.list=function(r){ZD("list",[function(t){return new tR(xD,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=bD(e.bucketOnlyServerUrl()),s=t.maxOperationRetryTime(),u=new LD(a,"GET",qD(t),s);return u.urlParams=o,u.errorHandler=BD(e),u}(i.authWrapper,i.location,"/",e.pageToken,e.maxResults);return i.authWrapper.makeRequest(n,t).getPromise()})},lR.prototype.getMetadata=function(){var n=this;return ZD("getMetadata",[],arguments),this.throwIfRoot_("getMetadata"),this.authWrapper.getAuthToken().then(function(t){var e=WD(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(e,t).getPromise()})},lR.prototype.updateMetadata=function(n){var r=this;return ZD("updateMetadata",[rR()],arguments),this.throwIfRoot_("updateMetadata"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e,n,r){var i=bD(e.fullServerUrl()),o=ND(n,r),a=t.maxOperationRetryTime(),s=new LD(i,"PATCH",UD(t,r),a);return s.headers={"Content-Type":"application/json; charset=utf-8"},s.body=o,s.errorHandler=jD(e),s}(r.authWrapper,r.location,n,r.mappings());return r.authWrapper.makeRequest(e,t).getPromise()})},lR.prototype.getDownloadURL=function(){var n=this;return ZD("getDownloadURL",[],arguments),this.throwIfRoot_("getDownloadURL"),this.authWrapper.getAuthToken().then(function(t){var e=function(t,e,n){var r=bD(e.fullServerUrl()),i=t.maxOperationRetryTime(),o=new LD(r,"GET",VD(t,n),i);return o.errorHandler=jD(e),o}(n.authWrapper,n.location,n.mappings());return n.authWrapper.makeRequest(e,t).getPromise().then(function(t){if(null===t)throw new Sk(Ck.NO_DOWNLOAD_URL,"The given file does not have any download URLs.");return t})})},lR.prototype.throwIfRoot_=function(t){if(""===this.location.path)throw function(t){return new Sk(Ck.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)},lR);function lR(t,e){this.authWrapper=t,this.location=e instanceof yD?e:yD.makeFromUrl(e)}var fR=(pR.prototype.getPromise=function(){return this.promise_},pR.prototype.cancel=function(t){},pR);function pR(t){this.promise_=Promise.reject(t)}var dR=(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 mR=(vR.extractBucket_=function(t){var e=t[Tk]||null;return null==e?null:yD.makeFromBucketSpec(e).bucket},vR.prototype.getAuthToken=function(){return null!==this.app_&&tD(this.app_.INTERNAL)&&tD(this.app_.INTERNAL.getToken)?this.app_.INTERNAL.getToken().then(function(t){return null!==t?t.accessToken:null},function(){return null}):Promise.resolve(null)},vR.prototype.bucket=function(){if(this.deleted_)throw Ok();return this.bucket_},vR.prototype.service=function(){return this.service_},vR.prototype.makeStorageReference=function(t){return this.storageRefMaker_(this,t)},vR.prototype.makeRequest=function(t,e){if(this.deleted_)return new fR(Ok());var n=this.requestMaker_(t,e,this.pool_);return this.requestMap_.addRequest(n),n},vR.prototype.deleteApp=function(){this.deleted_=!0,this.app_=null,this.requestMap_.clear()},vR.prototype.maxUploadRetryTime=function(){return this.maxUploadRetryTime_},vR.prototype.setMaxUploadRetryTime=function(t){this.maxUploadRetryTime_=t},vR.prototype.maxOperationRetryTime=function(){return this.maxOperationRetryTime_},vR.prototype.setMaxOperationRetryTime=function(t){this.maxOperationRetryTime_=t},vR);function vR(t,e,n,r,i){if(this.bucket_=null,this.deleted_=!1,this.app_=t,null!==this.app_){var o=this.app_.options;tD(o)&&(this.bucket_=vR.extractBucket_(o))}this.storageRefMaker_=e,this.requestMaker_=n,this.pool_=i,this.service_=r,this.maxOperationRetryTime_=12e4,this.maxUploadRetryTime_=6e5,this.requestMap_=new dR}var gR=(bR.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());eD(a)?r(a):r()}catch(t){i(t)}else null!==o?((n=Ak()).setServerResponseProp(o.getResponseText()),s.errorCallback_?i(s.errorCallback_(o,n)):i(n)):e.canceled?i(n=s.appDelete_?Ok():kk()):i(n=new Sk(Ck.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again."))}this.canceled_?t(0,new wR(!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,aa([null,t],e)):s()||o?c.call.apply(c,aa([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 wR(!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()===jk.NO_ERROR,n=t.getStatus();if(e&&!s.isRetryStatusCode_(n)){var r=-1!==s.successCodes_.indexOf(n);o(!0,new wR(r,t))}else{var i=t.getErrorCode()===jk.ABORT;o(!1,new wR(!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_)},bR.prototype.getPromise=function(){return this.promise_},bR.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()},bR.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},bR);function bR(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 wR=function(t,e,n){this.wasSuccessCode=t,this.xhr=e,this.canceled=!!n};function _R(t,e,n){var r=wD(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 gR(i,t.method,o,t.body,t.successCodes,t.additionalRetryCodes,t.handler,t.errorHandler,t.timeout,t.progressCallback,n)}var ER=(TR.prototype.ref=function(t){if(ZD("ref",[eR(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 hR(this.authWrapper_,this.bucket_);return null!=t?e.child(t):e},TR.prototype.refFromURL=function(t){return ZD("refFromURL",[eR(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 hR(this.authWrapper_,t)},Object.defineProperty(TR.prototype,"maxUploadRetryTime",{get:function(){return this.authWrapper_.maxUploadRetryTime()},enumerable:!0,configurable:!0}),TR.prototype.setMaxUploadRetryTime=function(t){ZD("setMaxUploadRetryTime",[iR()],arguments),this.authWrapper_.setMaxUploadRetryTime(t)},TR.prototype.setMaxOperationRetryTime=function(t){ZD("setMaxOperationRetryTime",[iR()],arguments),this.authWrapper_.setMaxOperationRetryTime(t)},Object.defineProperty(TR.prototype,"app",{get:function(){return this.app_},enumerable:!0,configurable:!0}),Object.defineProperty(TR.prototype,"INTERNAL",{get:function(){return this.internals_},enumerable:!0,configurable:!0}),TR);function TR(t,e,n){if(this.bucket_=null,this.authWrapper_=new mR(t,function(t,e){return new hR(t,e)},_R,this,e),this.app_=t,null!=n)this.bucket_=yD.makeFromBucketSpec(n);else{var r=this.authWrapper_.bucket();null!=r&&(this.bucket_=new yD(r,""))}this.internals_=new SR(this)}var SR=(IR.prototype.delete=function(){return this.service_.authWrapper_.deleteApp(),Promise.resolve()},IR);function IR(t){this.service_=t}var CR;function NR(t,e,n){return new ER(t,new hD,n)}CR={TaskState:$k,TaskEvent:Kk,StringFormat:xk,Storage:ER,Reference:hR},fl.INTERNAL.registerService("storage",NR,CR,void 0,!0);var AR,kR,DR,RR,OR="0.2.23",PR="FB-PERF-TRACE-MEASURE",MR="@firebase/performance/config",xR="@firebase/performance/configexpire",LR="Performance",FR=((AR={})["trace started"]="Trace {$traceName} was started before.",AR["trace stopped"]="Trace {$traceName} is not running.",AR["no window"]="Window is not available.",AR["no app id"]="App id is not available.",AR["no project id"]="Project id is not available.",AR["no api key"]="Api key is not available.",AR["invalid cc log"]="Attempted to queue invalid cc event",AR["FB not default"]="Performance can only start when Firebase app instance is the default one.",AR["RC response not ok"]="RC response is not ok",AR["invalid attribute name"]="Attribute name {$attributeName} is invalid.",AR["invalid attribute value"]="Attribute value {$attributeValue} is invalid.",AR["invalide custom metric name"]="Custom metric name {$customMetricName} is invalid",AR),UR=new Sa("performance",LR,FR),qR=(VR.prototype.getUrl=function(){return this.windowLocation.href.split("?")[0]},VR.prototype.mark=function(t){this.performance&&this.performance.mark&&this.performance.mark(t)},VR.prototype.measure=function(t,e,n){this.performance&&this.performance.measure&&this.performance.measure(t,e,n)},VR.prototype.getEntriesByType=function(t){return this.performance&&this.performance.getEntriesByType?this.performance.getEntriesByType(t):[]},VR.prototype.getEntriesByName=function(t){return this.performance&&this.performance.getEntriesByName?this.performance.getEntriesByName(t):[]},VR.prototype.getTimeOrigin=function(){return this.performance&&(this.performance.timeOrigin||this.performance.timing.navigationStart)},VR.prototype.requiredApisAvailable=function(){return!!(fetch&&Promise&&this.navigator&&this.navigator.cookieEnabled)},VR.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]})},VR.getInstance=function(){return void 0===kR&&(kR=new VR(DR)),kR},VR);function VR(t){if(!t)throw UR.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 BR,jR,WR,KR=(QR.prototype.getAppId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.appId;if(!t)throw UR.create("no app id");return t},QR.prototype.getProjectId=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.projectId;if(!t)throw UR.create("no project id");return t},QR.prototype.getApiKey=function(){var t=this.firebaseAppInstance&&this.firebaseAppInstance.options&&this.firebaseAppInstance.options.apiKey;if(!t)throw UR.create("no api key");return t},QR.getInstance=function(){return void 0===RR&&(RR=new QR),RR},QR);function QR(){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 HR(){return BR}(WR=jR=jR||{})[WR.UNKNOWN=0]="UNKNOWN",WR[WR.VISIBLE=1]="VISIBLE",WR[WR.HIDDEN=2]="HIDDEN",WR[WR.PRERENDER=3]="PRERENDER",WR[WR.UNLOADED=4]="UNLOADED";var GR=["firebase_","google_","ga_"],zR=new RegExp("^[a-zA-Z]\\w*$");function YR(){switch(qR.getInstance().document.visibilityState){case"visible":return jR.VISIBLE;case"hidden":return jR.HIDDEN;case"prerender":return jR.PRERENDER;default:return jR.UNKNOWN}}var XR=new Ja(LR);XR.logLevel=Qa.INFO;var JR="0.0.1",$R={loggingEnabled:!0},ZR="FIREBASE_INSTALLATIONS_AUTH";function tO(t){var e=function(){var t=qR.getInstance().localStorage,e=t.getItem(xR);if(!e||!function(t){return Number(t)>Date.now()}(e))return;var n=t.getItem(MR);if(!n)return;try{return JSON.parse(n)}catch(t){return}}();return e?(nO(e),Promise.resolve()):function(r){return function(){var t=KR.getInstance().firebaseAppInstance.installations().getToken();return t.then(function(t){}),t}().then(function(t){var e="https://firebaseremoteconfig.googleapis.com/v1/projects/"+KR.getInstance().getProjectId()+"/namespaces/fireperf:fetch?key="+KR.getInstance().getApiKey(),n=new Request(e,{method:"POST",headers:{Authorization:ZR+" "+t},body:JSON.stringify({app_instance_id:r,app_instance_id_token:t,app_id:KR.getInstance().getAppId(),app_version:OR,sdk_version:JR})});return fetch(n).then(function(t){if(t.ok)return t.json();throw UR.create("RC response not ok")})}).catch(function(){XR.info(eO)})}(t).then(function(t){return nO(t)}).then(function(t){return function(t){if(!t)return;var e=qR.getInstance().localStorage;e.setItem(MR,JSON.stringify(t)),e.setItem(xR,String(Date.now()+60*KR.getInstance().configTimeToLive*60*1e3))}(t)},function(){})}var eO="Could not fetch config, will use default configs";function nO(t){if(!t)return t;var e=KR.getInstance(),n=t.entries||{};return void 0!==n.fpr_enabled?e.loggingEnabled="true"===String(n.fpr_enabled):e.loggingEnabled=$R.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=rO(e.tracesSamplingRate),e.logNetworkAfterSampling=rO(e.networkRequestsSamplingRate),t}function rO(t){return Math.random()<=t}var iO,oO=1;function aO(){return oO=2,iO=iO||function(){var n=qR.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=KR.getInstance().firebaseAppInstance.installations().getId();return t.then(function(t){BR=t}),t}()}).then(function(t){return tO(t)}).then(function(){return sO()},function(){return sO()})}function sO(){oO=3}var uO,cO=1e4,hO=3,lO=hO,fO=[];function pO(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 UR.create("invalid cc log");fO=aa(fO,[t])}({message:i.apply(void 0,n),eventTime:Date.now()})}}function dO(){if(uO)return uO;var t=pO(vO);return(uO=new Ja("@firebase/performance/cc")).logHandler=t,uO}function yO(t){var e=KR.getInstance();!e.instrumentationEnabled&&t.isAuto||(e.dataCollectionEnabled||t.isAuto)&&qR.getInstance().requiredApisAvailable()&&(t.isAuto&&YR()!==jR.VISIBLE||e.loggingEnabled&&e.logTraceAfterSampling&&(3===oO?mO(t):aO().then(function(){return mO(t)},function(){return mO(t)})))}function mO(t){HR()&&setTimeout(function(){return dO().log(t,1)},0)}function vO(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:gO(),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=bO(t.counters));var n=t.getAttributes();0!==Object.keys(n).length&&(e.custom_attributes=bO(n));var r={application_info:gO(),trace_metric:e};return JSON.stringify(r)}(t)}function gO(){return{google_app_id:KR.getInstance().getAppId(),app_instance_id:HR(),web_app_info:{sdk_version:OR,page_url:qR.getInstance().getUrl(),service_worker_status:function(){var t=qR.getInstance().navigator;return"serviceWorker"in t?t.serviceWorker.controller?2:3:1}(),visibility_state:YR(),effective_connection_type:function(){var t=qR.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 bO(e){return Object.keys(e).map(function(t){return{key:t,value:e[t]}})}!function r(t){setTimeout(function(){if(0!==lO){if(!fO.length)return r(cO);var t=aa(fO);fO=[];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:KR.getInstance().logSource,log_event:e};fetch(KR.getInstance().logEndPointUrl,{method:"POST",body:JSON.stringify(n)}).then(function(t){return t.ok||XR.info("Call to Firebase backend failed."),t.json()}).then(function(t){var e=Number(t.next_request_wait_millis),n=isNaN(e)?cO:Math.max(cO,e);lO=hO,r(n)}).catch(function(){fO=aa(t,fO),lO--,XR.info("Tries left: "+lO+"."),r(cO)})}},t)}(5500);var wO=["_fp","_fcp","_fid"];var _O=(EO.prototype.start=function(){if(1!==this.state)throw UR.create("trace started",{traceName:this.name});this.api.mark(this.traceStartMark),this.state=2},EO.prototype.stop=function(){if(2!==this.state)throw UR.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(),yO(this)},EO.prototype.record=function(t,e,n){if(this.durationUs=Math.floor(1e3*e),this.startTimeUs=Math.floor(1e3*t),n&&n.attributes&&(this.customAttributes=ta({},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])))}yO(this)},EO.prototype.incrementMetric=function(t,e){void 0===e&&(e=1),void 0===this.counters[t]&&this.putMetric(t,0),this.counters[t]+=e},EO.prototype.putMetric=function(t,e){if(!function(t,e){return!(0===t.length||100<t.length)&&(e&&e.startsWith("_wt_")&&-1<wO.indexOf(t)||!t.startsWith("_"))}(t,this.name))throw UR.create("invalide custom metric name",{customMetricName:t});this.counters[t]=e},EO.prototype.getMetric=function(t){return this.counters[t]||0},EO.prototype.putAttribute=function(t,e){var n=function(e){return!(0===e.length||40<e.length||GR.some(function(t){return e.startsWith(t)})||!e.match(zR))}(t),r=function(t){return 0!==t.length&&t.length<=100}(e);if(n&&r)this.customAttributes[t]=e;else{if(!n)throw UR.create("invalid attribute name",{attributeName:t});if(!r)throw UR.create("invalid attribute value",{attributeValue:e})}},EO.prototype.getAttribute=function(t){return this.customAttributes[t]},EO.prototype.removeAttribute=function(t){void 0!==this.customAttributes[t]&&delete this.customAttributes[t]},EO.prototype.getAttributes=function(){return ta({},this.customAttributes)},EO.prototype.setStartTime=function(t){this.startTimeUs=t},EO.prototype.setDuration=function(t){this.durationUs=t},EO.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())))},EO.createOobTrace=function(t,e,n){var r=qR.getInstance().getUrl();if(r){var i=new EO("_wt_"+r,!0),o=Math.floor(1e3*qR.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))}yO(i)}},EO.createUserTimingTrace=function(t){yO(new EO(t,!1,t))},EO);function EO(t,e,n){void 0===e&&(e=!1),this.name=t,this.isAuto=e,this.state=1,this.customAttributes={},this.counters={},this.api=qR.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||PR+"-"+this.randomId+"-"+this.name,n&&this.calculateTraceMetrics())}function TO(t){var e=t;if(e&&void 0!==e.responseStart){var n=qR.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=KR.getInstance();e.instrumentationEnabled&&t.url!==e.logEndPointUrl.split("?")[0]&&e.loggingEnabled&&e.logNetworkAfterSampling&&setTimeout(function(){return dO().log(t,0)},0)}({url:e.name&&e.name.split("?")[0],responsePayloadBytes:e.transferSize,startTimeUs:r,timeToResponseInitiatedUs:i,timeToResponseCompletedUs:o})}}var SO=5e3;function IO(){HR()&&(setTimeout(function(){return function(){var t=qR.getInstance(),e=t.getEntriesByType("navigation"),n=t.getEntriesByType("paint");if(t.onFirstInputDelay){var r=setTimeout(function(){_O.createOobTrace(e,n),r=void 0},SO);t.onFirstInputDelay(function(t){r&&(clearTimeout(r),_O.createOobTrace(e,n,t))})}else _O.createOobTrace(e,n)}()},0),setTimeout(function(){return function(){for(var t=qR.getInstance(),e=t.getEntriesByType("resource"),n=0,r=e;n<r.length;n++){TO(r[n])}t.setupObserver("resource",TO)}()},0),setTimeout(function(){return function(){for(var t=qR.getInstance(),e=t.getEntriesByType("measure"),n=0,r=e;n<r.length;n++){CO(r[n])}t.setupObserver("measure",CO)}()},0))}function CO(t){var e=t.name;e.substring(0,PR.length)!==PR&&_O.createUserTimingTrace(e)}var NO=(AO.prototype.trace=function(t){return new _O(t)},Object.defineProperty(AO.prototype,"instrumentationEnabled",{get:function(){return KR.getInstance().instrumentationEnabled},set:function(t){KR.getInstance().instrumentationEnabled=t},enumerable:!0,configurable:!0}),Object.defineProperty(AO.prototype,"dataCollectionEnabled",{get:function(){return KR.getInstance().dataCollectionEnabled},set:function(t){KR.getInstance().dataCollectionEnabled=t},enumerable:!0,configurable:!0}),AO);function AO(t){this.app=t,qR.getInstance().requiredApisAvailable()?aO().then(IO,IO):XR.info("Firebase Performance cannot start if browser does not support fetch and Promise or cookie is disabled.")}fl.INTERNAL.registerService("performance",function(t){if("[DEFAULT]"!==t.name)throw UR.create("FB not default");if("undefined"==typeof window)throw UR.create("no window");return function(t){DR=t}(window),KR.getInstance().firebaseAppInstance=t,new NO(t)},{});var kO,DO,RO,OO,PO,MO="measurementId",xO="firebase_id",LO="origin";function FO(t){return Array.isArray(window[t])}function UO(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===kO.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(kO.EVENT,e,n||{})}).catch(function(t){return console.error(t)})}else if(t===kO.CONFIG){(p[e]||Promise.resolve()).then(function(){f(kO.CONFIG,e,n)}).catch(function(t){return console.error(t)})}else f(kO.SET,e)}}(r,t),{gtagCore:r,wrappedGtag:window[e]}}(DO=kO=kO||{}).EVENT="event",DO.SET="set",DO.CONFIG="config",(OO=RO=RO||{}).ADD_PAYMENT_INFO="add_payment_info",OO.ADD_TO_CART="add_to_cart",OO.ADD_TO_WISHLIST="add_to_wishlist",OO.BEGIN_CHECKOUT="begin_checkout",OO.CHECKOUT_PROGRESS="checkout_progress",OO.EXCEPTION="exception",OO.GENERATE_LEAD="generate_lead",OO.LOGIN="login",OO.PAGE_VIEW="page_view",OO.PURCHASE="purchase",OO.REFUND="refund",OO.REMOVE_FROM_CART="remove_from_cart",OO.SCREEN_VIEW="screen_view",OO.SEARCH="search",OO.SELECT_CONTENT="select_content",OO.SET_CHECKOUT_OPTION="set_checkout_option",OO.SHARE="share",OO.SIGN_UP="sign_up",OO.TIMING_COMPLETE="timing_complete",OO.VIEW_ITEM="view_item",OO.VIEW_ITEM_LIST="view_item_list",OO.VIEW_PROMOTION="view_promotion",OO.VIEW_SEARCH_RESULTS="view_search_results";var qO,VO,BO=((PO={})["no-ga-id"]='"'+MO+'" field is empty in Firebase config. Firebase Analytics requires this field to contain a valid measurement ID.',PO["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.",PO["already-initialized"]="Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.",PO),jO=new Sa("analytics","Analytics",BO),WO={},KO="dataLayer",QO="gtag",HO=!1;function GO(t){if(HO)throw jO.create("already-initialized");t.dataLayerName&&(KO=t.dataLayerName),t.gtagName&&(QO=t.gtagName)}function zO(t,e){var r=t.options[MO];if(!r)throw jO.create("no-ga-id");if(null!=WO[r])throw jO.create("already-exists",{id:r});if(!HO){FO(KO)||function(t){var e=document.createElement("script");e.src="https://www.googletagmanager.com/gtag/js?l="+t,e.async=!0,document.head.appendChild(e)}(KO),function(t){FO(t)?window[t]:window[t]=[]}(KO);var n=UO(WO,KO,QO),i=n.wrappedGtag,o=n.gtagCore;VO=i,qO=o,HO=!0}WO[r]=function(r,i){return ea(this,void 0,void 0,function(){var e,n;return na(this,function(t){switch(t.label){case 0:return[4,r.installations().getId()];case 1:return e=t.sent(),i("js",new Date),i(kO.CONFIG,r.options[MO],((n={})[xO]=e,n[LO]="firebase",n.update=!0,n)),[2]}})})}(t,qO);var a={app:t,logEvent:function(t,e,n){return function(t,e,n,r,i){var o=r||{};i&&i.global||(o=ta(ta({},r),{send_to:e})),t(kO.EVENT,n,o||{})}(VO,r,t,e,n)},setCurrentScreen:function(t,e){return function(t,e,n,r){r&&r.global?t(kO.SET,{screen_name:n}):t(kO.CONFIG,e,{update:!0,screen_name:n})}(VO,r,t,e)},setUserId:function(t,e){return function(t,e,n,r){r&&r.global?t(kO.SET,{user_id:n}):t(kO.CONFIG,e,{update:!0,user_id:n})}(VO,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(kO.SET,i)}else t(kO.CONFIG,e,{update:!0,user_properties:n})}(VO,r,t,e)},setAnalyticsCollectionEnabled:function(t){return function(t,e){window["ga-disable-"+t]=!e}(r,t)}};return e({INTERNAL:{analytics:{logEvent:a.logEvent}}}),a}fl.INTERNAL.registerService("analytics",zO,{settings:GO,EventName:RO},void 0,!1);var YO,XO=(JO.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},JO.prototype.fetch=function(a){return ea(this,void 0,void 0,function(){var e,n,r,i,o;return na(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]}})})},JO);function JO(t,e,n,r){this.client=t,this.storage=e,this.storageCache=n,this.logger=r}var $O=((YO={})["registration-window"]="Undefined window object. This SDK only supports usage in a browser environment.",YO["registration-project-id"]="Undefined project identifier. Check Firebase app initialization.",YO["registration-api-key"]="Undefined API key. Check Firebase app initialization.",YO["registration-app-id"]="Undefined app identifier. Check Firebase app initialization.",YO["storage-open"]="Error thrown when opening storage. Original error: {$originalErrorMessage}.",YO["storage-get"]="Error thrown when reading from storage. Original error: {$originalErrorMessage}.",YO["storage-set"]="Error thrown when writing to storage. Original error: {$originalErrorMessage}.",YO["storage-delete"]="Error thrown when deleting from storage. Original error: {$originalErrorMessage}.",YO["fetch-client-network"]="Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.",YO["fetch-timeout"]='The config fetch request timed out. Configure timeout using "fetchTimeoutMillis" SDK setting.',YO["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}.',YO["fetch-client-parse"]="Fetch client could not parse response. Original error: {$originalErrorMessage}.",YO["fetch-status"]="Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.",YO),ZO=new Sa("remoteconfig","Remote Config",$O);var tP=(eP.prototype.fetch=function(w){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,h,l,f,p,d,y,m,v,g,b;return na(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"),ZO.create(p,{originalErrorMessage:f.message});case 6:if(d=l.status,y=l.headers.get("ETag")||void 0,200!==l.status)return[3,11];g=void 0,t.label=7;case 7:return t.trys.push([7,9,,10]),[4,l.json()];case 8:return g=t.sent(),[3,10];case 9:throw b=t.sent(),ZO.create("fetch-client-parse",{originalErrorMessage:b.message});case 10:m=g.entries,v=g.state,t.label=11;case 11:if("INSTANCE_STATE_UNSPECIFIED"===v?d=500:"NO_CHANGE"===v?d=304:"NO_TEMPLATE"!==v&&"EMPTY_CONFIG"!==v||(m={}),304!==d&&200!==d)throw ZO.create("fetch-status",{httpStatus:d});return[2,{status:d,eTag:y,config:m}]}})})},eP);function eP(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 nP=(rP.prototype.addEventListener=function(t){this.listeners.push(t)},rP.prototype.abort=function(){this.listeners.forEach(function(t){return t()})},rP);function rP(){this.listeners=[]}var iP=["1","true","t","yes","y","on"],oP=(aP.prototype.asString=function(){return this._value},aP.prototype.asBoolean=function(){return"static"!==this._source&&0<=iP.indexOf(this._value.toLowerCase())},aP.prototype.asNumber=function(){if("static"===this._source)return 0;var t=Number(this._value);return isNaN(t)&&(t=0),t},aP.prototype.getSource=function(){return this._source},aP);function aP(t,e){void 0===e&&(e=""),this._source=t,this._value=e}var sP=(uP.prototype.setLogLevel=function(t){switch(t){case"debug":this._logger.logLevel=Qa.DEBUG;break;case"silent":this._logger.logLevel=Qa.SILENT;break;default:this._logger.logLevel=Qa.ERROR}},Object.defineProperty(uP.prototype,"fetchTimeMillis",{get:function(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1},enumerable:!0,configurable:!0}),Object.defineProperty(uP.prototype,"lastFetchStatus",{get:function(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"},enumerable:!0,configurable:!0}),uP.prototype.activate=function(){return ea(this,void 0,void 0,function(){var e,n,r;return na(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]}})})},uP.prototype.ensureInitialized=function(){var t=this;return this._initializePromise||(this._initializePromise=this._storageCache.loadFromStorage().then(function(){t._isInitializationComplete=!0})),this._initializePromise},uP.prototype.fetch=function(){return ea(this,void 0,void 0,function(){var e=this;return na(this,function(t){return[2,new Promise(function(o,a){return ea(e,void 0,void 0,function(){var e,n,r,i=this;return na(this,function(t){switch(t.label){case 0:e=new nP,setTimeout(function(){return ea(i,void 0,void 0,function(){return na(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(),o(),[3,6];case 4:return n=t.sent(),r=function(t,e){return t instanceof Ea&&-1!==t.code.indexOf(e)}(n,"fetch-throttle")?"throttle":"failure",[4,this._storageCache.setLastFetchStatus(r)];case 5:return t.sent(),a(n),[3,6];case 6:return[2]}})})})]})})},uP.prototype.fetchAndActivate=function(){return ea(this,void 0,void 0,function(){return na(this,function(t){switch(t.label){case 0:return[4,this.fetch()];case 1:return t.sent(),[2,this.activate()]}})})},uP.prototype.getAll=function(){var n=this;return function(t,e){return void 0===t&&(t={}),void 0===e&&(e={}),Object.keys(ta(ta({},t),e))}(this._storageCache.getActiveConfig(),this.defaultConfig).reduce(function(t,e){return t[e]=n.getValue(e),t},{})},uP.prototype.getBoolean=function(t){return this.getValue(t).asBoolean()},uP.prototype.getNumber=function(t){return this.getValue(t).asNumber()},uP.prototype.getString=function(t){return this.getValue(t).asString()},uP.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 oP("remote",e[t]):this.defaultConfig&&void 0!==this.defaultConfig[t]?new oP("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 oP("static"))},uP);function uP(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 cP(t,e){var n=t.target.error||void 0;return ZO.create(e,{originalErrorMessage:n&&n.message})}var hP="app_namespace_store",lP="firebase_remote_config",fP=1;var pP=(dP.prototype.getLastFetchStatus=function(){return this.get("last_fetch_status")},dP.prototype.setLastFetchStatus=function(t){return this.set("last_fetch_status",t)},dP.prototype.getLastSuccessfulFetchTimestampMillis=function(){return this.get("last_successful_fetch_timestamp_millis")},dP.prototype.setLastSuccessfulFetchTimestampMillis=function(t){return this.set("last_successful_fetch_timestamp_millis",t)},dP.prototype.getLastSuccessfulFetchResponse=function(){return this.get("last_successful_fetch_response")},dP.prototype.setLastSuccessfulFetchResponse=function(t){return this.set("last_successful_fetch_response",t)},dP.prototype.getActiveConfig=function(){return this.get("active_config")},dP.prototype.setActiveConfig=function(t){return this.set("active_config",t)},dP.prototype.getActiveConfigEtag=function(){return this.get("active_config_etag")},dP.prototype.setActiveConfigEtag=function(t){return this.set("active_config_etag",t)},dP.prototype.getThrottleMetadata=function(){return this.get("throttle_metadata")},dP.prototype.setThrottleMetadata=function(t){return this.set("throttle_metadata",t)},dP.prototype.deleteThrottleMetadata=function(){return this.delete("throttle_metadata")},dP.prototype.get=function(s){return ea(this,void 0,void 0,function(){var o,a=this;return na(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([hP],"readonly").objectStore(hP),r=a.createCompositeKey(s);try{var i=t.get(r);i.onerror=function(t){e(cP(t,"storage-get"))},i.onsuccess=function(t){var e=t.target.result;n(e?e.value:void 0)}}catch(t){e(ZO.create("storage-get",{originalErrorMessage:t&&t.message}))}})]}})})},dP.prototype.set=function(s,u){return ea(this,void 0,void 0,function(){var o,a=this;return na(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([hP],"readwrite").objectStore(hP),r=a.createCompositeKey(s);try{var i=n.put({compositeKey:r,value:u});i.onerror=function(t){e(cP(t,"storage-set"))},i.onsuccess=function(){t()}}catch(t){e(ZO.create("storage-set",{originalErrorMessage:t&&t.message}))}})]}})})},dP.prototype.delete=function(s){return ea(this,void 0,void 0,function(){var o,a=this;return na(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([hP],"readwrite").objectStore(hP),r=a.createCompositeKey(s);try{var i=n.delete(r);i.onerror=function(t){e(cP(t,"storage-delete"))},i.onsuccess=function(){t()}}catch(t){e(ZO.create("storage-delete",{originalErrorMessage:t&&t.message}))}})]}})})},dP.prototype.createCompositeKey=function(t){return[this.appId,this.appName,this.namespace,t].join()},dP);function dP(t,e,n,r){void 0===r&&(r=new Promise(function(e,n){var t=indexedDB.open(lP,fP);t.onerror=function(t){n(cP(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(hP,{keyPath:"compositeKey"})}}})),this.appId=t,this.appName=e,this.namespace=n,this.openDbPromise=r}var yP=(mP.prototype.getLastFetchStatus=function(){return this.lastFetchStatus},mP.prototype.getLastSuccessfulFetchTimestampMillis=function(){return this.lastSuccessfulFetchTimestampMillis},mP.prototype.getActiveConfig=function(){return this.activeConfig},mP.prototype.loadFromStorage=function(){return ea(this,void 0,void 0,function(){var e,n,r,i,o,a;return na(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]}})})},mP.prototype.setLastFetchStatus=function(t){return this.lastFetchStatus=t,this.storage.setLastFetchStatus(t)},mP.prototype.setLastSuccessfulFetchTimestampMillis=function(t){return this.lastSuccessfulFetchTimestampMillis=t,this.storage.setLastSuccessfulFetchTimestampMillis(t)},mP.prototype.setActiveConfig=function(t){return this.activeConfig=t,this.storage.setActiveConfig(t)},mP);function mP(t){this.storage=t}var vP=(gP.prototype.fetch=function(n){return ea(this,void 0,void 0,function(){var e;return na(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)]}})})},gP.prototype.attemptFetch=function(i,t){var o=t.throttleEndTimeMillis,a=t.backoffCount;return ea(this,void 0,void 0,function(){var e,n,r;return na(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(ZO.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 Ea))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]}})})},gP);function gP(t,e){this.client=t,this.storage=e}var bP;return(bP=fl).INTERNAL.registerService("remoteConfig",function(t,e,n){if("undefined"==typeof window)throw ZO.create("registration-window");var r=t.options,i=r.projectId,o=r.apiKey,a=r.appId;if(!i)throw ZO.create("registration-project-id");if(!o)throw ZO.create("registration-api-key");if(!a)throw ZO.create("registration-app-id");n=n||"firebase";var s=new pP(a,t.name,n),u=new yP(s),c=new Ja("@firebase/remote-config");c.logLevel=Qa.ERROR;var h=new tP(t.installations(),bP.SDK_VERSION,n,i,o,a),l=new vP(h,s),f=new XO(l,s,u,c),p=new sP(t,f,u,s,c);return p.ensureInitialized(),p},void 0,void 0,!0),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});
2//# sourceMappingURL=firebase.js.map